It is not fully general, but I am sure if somebody is desperate for performance like I am they will make it more general by themselves :)
I used Murmur hash implementation that you can download here: http://d3s.mff.cuni.cz/~holub/sw/javamurmurhash/
The code:
package uk.ac.cam.cl.ss958.SpringBoardSimulation; package uk.ac.cam.cl.ss958; import ie.ucd.murmur.MurmurHash; import java.util.BitSet; import java.util.Random; public class FastBloomFilter { private final BitSet bs; final int [] hashSeeds; final int capacity; public FastBloomFilter(int slots, int hashFunctions) { bs = new BitSet(slots); Random r = new Random(System.currentTimeMillis()); hashSeeds = new int[hashFunctions]; for (int i=0; i < hashFunctions; ++i) { hashSeeds[i] = r.nextInt(); } capacity = slots; } public void add(int value) { byte [] b = new byte[] { (byte)(value >>> 24), (byte)(value >>> 16), (byte)(value >>> 8), (byte)value}; for (int i=0; i < hashSeeds.length; ++i) { int h = MurmurHash.hash32(b, 4, hashSeeds[i]); bs.set(Math.abs(h)%capacity, true); } } public void clear() { bs.clear(); } public boolean mightContain(int value) { byte [] b = new byte[] { (byte)(value >>> 24), (byte)(value >>> 16), (byte)(value >>> 8), (byte)value}; for (int i=0; i < hashSeeds.length; ++i) { int h = MurmurHash.hash32(b, 4, hashSeeds[i]); if(!bs.get(Math.abs(h)%capacity)) { return false; } } return true; } public static void main(String [] args) { FastBloomFilter bf = new FastBloomFilter(1000, 10); System.out.println("Query for 2000: " + bf.mightContain(2000)); System.out.println("Adding 2000"); bf.add(2000); System.out.println("Query for 2000: " + bf.mightContain(2000)); } }
This comment has been removed by the author.
ReplyDeleteAl-Bustan Company for the transportation of furniture and furniture in Jazan and its services with precision and skill, شركة نقل عفش
ReplyDeleteشركة نقل اثاث من الرياض الى قطر
شركة نقل عفش من الرياض الى قطر
شركة نقل عفش ببريدة
English code = true
ReplyDeleteCuz True is an english word
Your blog on computers is fantastic! Your writing is clear, concise, and informative. You have a great way of breaking down complex topics into easily understandable language. Your passion for technology is evident in your writing. Keep up the excellent work!
ReplyDeleteDo My Homework is a leading academic company that offers homework help for students of all levels, from high school to college and beyond. With a team of well-qualified and experienced experts, the company provides students with high-quality homework solutions that are tailored to their specific needs.
At Do My Homework, students can find online experts right now who specialize in a wide range of subjects, from math and science to humanities and social sciences. These experts are carefully selected based on their academic credentials, professional experience, and proven track record of success in helping students achieve their academic goals.
I must say you have written a great article. A must read post that need to bookmarked
ReplyDeleteThis was super interesting article to read. Thanks for sharing it here!
ReplyDeleteThis content data gives truly quality and unique information. Thanks
ReplyDeleteI’m excited to uncover this page. Thank you for this fantastic read!
ReplyDelete
ReplyDeleteI got really good information from this content, thanks for sharing.
Fabulous, what a weblog it is! This blog provides valuable information to us, keep it up.
ReplyDeleteEither way keep up the excellent quality writing.
ReplyDeleteYou have a good point here! I totally agree with what you have said!!
ReplyDeleteThanks for sharing your views. hope more people will read this article!!
ReplyDeleteI must tell you this is an excellent post.
ReplyDeleteThanks again and keep it up.
ReplyDeletei love this article thank you!!
ReplyDeleteGreate article. Keep writing such kind of info on your page. Im really impressed by it.
ReplyDeletethat's truly good, keep up writing.
ReplyDeleteThanks and Best of luck to your next Blog in future.
ReplyDelete
ReplyDeleteThanks very much for helping me
Wonderful items from you, man. You’re making it entertaining blog. Thanks
ReplyDeleteHello there, You have performed an excellent article.. Goodjob!
ReplyDeleteWe truly dearly loved examining this web site. Thanks for this blog!
ReplyDeleteHi everyone, This web site is piece of writing is actually good, keep up posting.
ReplyDeleteWhat’s up, everything is going nicely in this blog here, keep up writing.
ReplyDeletePretty! This was an extremely wonderful post. Thank you for providing this info.
ReplyDeleteThis is the right site for everyone who would like to find out about this topic.
ReplyDeleteBookmarked this website, This site contains valuable information. Thanks..
ReplyDeleteI am really happy with the articles quality. Keep on blogging, its great!
ReplyDeleteThanks a lot for this great stuff here. I am very much thankful for this site.
ReplyDeleteI will bookmark this blog and check here again. Keep doing your blog post
ReplyDeleteVery informative the stuff you provide I really enjoyed reading, Thanks for this
ReplyDeleteNice knowledge gaining article. This post is really the best on this valuable topic.
ReplyDeleteVery useful post. I found so many Interesting stuff in your blog. Its great article.
ReplyDeleteIt shows your effort and dedication. Thanks for sharing such a nice post.
ReplyDelete