magnuss / java-bloomfilter Goto Github PK
View Code? Open in Web Editor NEWA stand-alone Bloom filter implementation written in Java
License: GNU Lesser General Public License v3.0
A stand-alone Bloom filter implementation written in Java
License: GNU Lesser General Public License v3.0
Your hash implementation has a problem. What you do is:
The last part is wrong/dangerous since it violates the assumption that hash values are evenly distributed over [1,m) with m being the size of the bloom filter. Here is why:
Suppose the bloom filter has a size of 3 billion. The hash value are integers so approximately uniformly distributed from 0 to roughly 4 billion. By taking the modulo the hash values between 0 and 1 billion get generated twice as often as the range 1 billion to 3 billion, as the range 3 billion to 4 billion is mapped to 0 - 1 billion. You should easily be able to verify that by taking a histogram of a large number of hashes.
This corruption of uniformity will lead to a decreased false positive rate and hence should be fixed (for instance by discarding the values which are two high instead of taking the modulo).
There was a change that said "Changed license from GPL to LGPL", but it just added the LGPL without removing the GPL. This makes the licensing a bit ambiguous. I'd love to give this a shot, but in a project which is LGPL, but not GPL, compatible.
Thanks,
I'm getting:
java.lang.ArithmeticException: / by zero
at com.skjegstad.utils.BloomFilter.contains(BloomFilter.java:345)
after creating filter with expectedNumberOfElements = 0 with constructor:
public BloomFilter(double falsePositiveProbability, int expectedNumberOfElements)
and check if it contains some element
What I'm expecting is either:
i have import the bloomfiter in my program
but the program can errors a message
redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Broken pipe (Write failed)
at redis.clients.jedis.Protocol.sendCommand(Protocol.java:104)
at redis.clients.jedis.Protocol.sendCommand(Protocol.java:84)
at redis.clients.jedis.Connection.sendCommand(Connection.java:127)
at redis.clients.jedis.BinaryClient.setbit(BinaryClient.java:912)
at redis.clients.jedis.Client.setbit(Client.java:671)
at redis.clients.jedis.Jedis.setbit(Jedis.java:2555)
at com.github.wxisme.bloomfilter.bitset.RedisBitSet.set(RedisBitSet.java:70)
at com.github.wxisme.bloomfilter.common.BloomFilter.add(BloomFilter.java:231)
so i can‘t find the problem
This library was used to develop and test Bloofi :
https://github.com/lemire/bloofi
(I am raising this issue merely to thank you for making the code available in the first place.)
Looks like the k
should be a double.
public BloomFilter(int bitSetSize, int expectedNumberOElements) {
this(bitSetSize / (double)expectedNumberOElements,
expectedNumberOElements,
(int) Math.round((bitSetSize / (double)expectedNumberOElements) * Math.log(2.0)));
}
It never hashes when the bitSetSize
is 10, as an example.
For iterating through huge lists with duplicates and using the bloom filter to make sure each use of an item from the list is only done once, it might speed things up to have a combined containsAndAdd method to avoid hanging to hash the same input twice.
if (myBloom.contains(itemFromList)) {
return;
}
myBloom.add(itemFromList);
//... do things ...
Hi,
Thanks you very much for your program. I wanted to use your program. I wanted to make the bloom filter size a fixed amount. how should I do that?
Thank you!
same as title
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.