@author Ka Ming Nip
| 38 | * @author Ka Ming Nip |
| 39 | */ |
| 40 | public class PairedKeysBloomFilter { |
| 41 | |
| 42 | protected AbstractLargeBitBuffer bitArrayPair; |
| 43 | protected int numHash; |
| 44 | protected long size; |
| 45 | protected HashFunction hashFunction; |
| 46 | protected long popcount = -1; |
| 47 | |
| 48 | public PairedKeysBloomFilter(long size, int numHash, HashFunction hashFunction) { |
| 49 | this.size = size; |
| 50 | try { |
| 51 | this.bitArrayPair = new UnsafeBitBuffer(size); |
| 52 | } |
| 53 | catch(NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { |
| 54 | this.bitArrayPair = new LargeBitBuffer(size); |
| 55 | } |
| 56 | this.numHash = numHash; |
| 57 | this.hashFunction = hashFunction; |
| 58 | } |
| 59 | |
| 60 | private static final String LABEL_SEPARATOR = ":"; |
| 61 | private static final String LABEL_SIZE = "size"; |
| 62 | private static final String LABEL_NUM_HASH = "numhash"; |
| 63 | private static final String LABEL_FPR = "fpr"; |
| 64 | |
| 65 | public PairedKeysBloomFilter(File desc, File pairBits, |
| 66 | HashFunction hashFunction) throws FileNotFoundException, IOException { |
| 67 | |
| 68 | BufferedReader br = new BufferedReader(new FileReader(desc)); |
| 69 | String line; |
| 70 | while ((line = br.readLine()) != null) { |
| 71 | String[] entry = line.split(LABEL_SEPARATOR); |
| 72 | String key = entry[0]; |
| 73 | String val = entry[1]; |
| 74 | switch(key) { |
| 75 | case LABEL_SIZE: |
| 76 | size = Long.parseLong(val); |
| 77 | break; |
| 78 | case LABEL_NUM_HASH: |
| 79 | numHash = Integer.parseInt(val); |
| 80 | break; |
| 81 | } |
| 82 | } |
| 83 | br.close(); |
| 84 | |
| 85 | this.hashFunction = hashFunction; |
| 86 | |
| 87 | try { |
| 88 | //System.out.println("unsafe"); |
| 89 | this.bitArrayPair = new UnsafeBitBuffer(size); |
| 90 | } |
| 91 | catch(NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { |
| 92 | this.bitArrayPair = new LargeBitBuffer(size); |
| 93 | } |
| 94 | |
| 95 | FileInputStream fin = new FileInputStream(pairBits); |
| 96 | this.bitArrayPair.read(fin); |
| 97 | fin.close(); |
nothing calls this directly
no outgoing calls
no test coverage detected