Last active
June 21, 2017 01:32
-
-
Save thomasjungblut/4495808 to your computer and use it in GitHub Desktop.
serialize bloom filters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package de.jungblut.benchmark; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.ObjectInputStream; | |
import java.io.ObjectOutputStream; | |
import com.google.common.hash.BloomFilter; | |
import com.google.common.hash.Funnels; | |
public class BloomFilterTest { | |
@SuppressWarnings({ "resource", "unchecked" }) | |
public static void main(String[] args) throws IOException, | |
ClassNotFoundException { | |
BloomFilter<CharSequence> filter = BloomFilter.create( | |
Funnels.stringFunnel(), 4000000); | |
for (int i = 0; i < 4000000; i++) | |
filter.put(i + ""); | |
ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream( | |
"/Users/Thomas/Downloads/filter.obj")); | |
stream.writeObject(filter); | |
stream.close(); | |
filter = (BloomFilter<CharSequence>) new ObjectInputStream( | |
new FileInputStream("/Users/Thomas/Downloads/filter.obj")).readObject(); | |
System.out.println(filter.mightContain("-1")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment