Package be.bagofwords.db.bloomfilter

Examples of be.bagofwords.db.bloomfilter.LongBloomFilter$BitArray


        if (first.getNumOfHashFunctions() != second.getNumOfHashFunctions()) {
            throw new RuntimeException("Unequal number of hash functions!");
        }
        LongBloomFilter.BitArray bitArray1 = first.getBits();
        LongBloomFilter.BitArray bitArray2 = second.getBits();
        return new LongBloomFilter(bitArray1.mergeWith(bitArray2), first.getNumOfHashFunctions());
    }
View Full Code Here


            return filterCounts.mightContain(key);
        }
    }

    public void makeNonSparse() {
        this.filterCounts = new LongBloomFilter(numberOfFeatures, FPP);
        for (Long key : cachedKeys) {
            filterCounts.put(key);
        }
        this.cachedKeys = null;
    }
View Full Code Here

            result.setCachedKeys(new ArrayList<>(this.getCachedKeys()));
            for (Long key : second.getCachedKeys()) {
                result.addKey(key);
            }
        } else {
            LongBloomFilter mergedCounts;
            if (!this.isSparse() && !second.isSparse()) {
                mergedCounts = ApproximateCountsUtils.mergeBloomFilters(this.getFilterCounts(), second.getFilterCounts());
            } else {
                if (!this.isSparse()) {
                    mergedCounts = this.getFilterCounts().clone();
                } else if (!second.isSparse()) {
                    mergedCounts = second.getFilterCounts().clone();
                } else {
                    //Both sparse
                    mergedCounts = new LongBloomFilter(this.getNumberOfFeatures(), CompactIndex.FPP);
                }
            }
            if (this.isSparse()) {
                for (Long key : this.getCachedKeys()) {
                    mergedCounts.put(key);
                }
            }
            if (second.isSparse()) {
                for (Long key : second.getCachedKeys()) {
                    mergedCounts.put(key);
                }
            }
            result = new CompactIndex(this.getNumberOfFeatures(), mergedCounts, this.getNumberOfCounts() + second.getNumberOfCounts());
        }
        return result;
View Full Code Here

public class TestBloomFiltersSpeed {

    private static final int NUM_OF_VALUES = 1000000;

    public static void main(String[] args) {
        LongBloomFilter bloomFilter1 = new LongBloomFilter(NUM_OF_VALUES, 0.001);

        BloomFilter<Long> bloomFilter2 = BloomFilter.create(new Funnel<Long>() {
            @Override
            public void funnel(Long from, PrimitiveSink into) {
                into.putLong(from);
View Full Code Here

                    averageValues[i] = 1;
                }
            }
        }
        long[] numOfExpectedValues = countValues(dataInterface);
        LongBloomFilter oneCountsBloomFilter = new LongBloomFilter(numOfExpectedValues[0], fpp);
        LongCountsBloomFilter otherCountsBloomFilter = new LongCountsBloomFilter(numOfExpectedValues[1], fpp);
        UI.write("Adding all counts to the filter with size " + otherCountsBloomFilter.getBytes().size() + "+" + (oneCountsBloomFilter.getBits().size() / 8) + ". This might take a while");
        it = dataInterface.iterator();
        while (it.hasNext()) {
            KeyValue<Long> value = it.next();
            if (value.getValue() == 1) {
                oneCountsBloomFilter.put(value.getKey());
            } else {
                int bin = NumUtils.getBin(binBorders, value.getValue());
                otherCountsBloomFilter.addCount(value.getKey(), bin + 1);
            }
        }
View Full Code Here

        long[] averages = new long[0];
        return new ApproximateCountsFilter(averages, createEmptyBloomFilter(), bloomFilter);
    }

    public static LongBloomFilter createEmptyBloomFilter() {
        return new LongBloomFilter(1, 0.1);
    }
View Full Code Here

            if (it.next().getValue() >= minFrequency) {
                numOfValuesToAdd++;
            }
        }
        it.close();
        LongBloomFilter result = new LongBloomFilter(numOfValuesToAdd, 0.01);
        it = totalCountsDI.iterator();
        while (it.hasNext()) {
            KeyValue<Long> next = it.next();
            if (next.getValue() >= minFrequency) {
                result.put(next.getKey());
            }
        }
        it.close();
        UI.write("Creating bloom filter took " + (System.currentTimeMillis() - start) + " ms for " + numOfValuesToAdd + " values, taking " + (result.getBits().getData().length * 8) + " bytes");
        return result;
    }
View Full Code Here

TOP

Related Classes of be.bagofwords.db.bloomfilter.LongBloomFilter$BitArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.