Beispiel #1
0
 @Override
 public synchronized void append(WritableComparable key, Writable val) throws IOException {
   super.append(key, val);
   buf.reset();
   key.write(buf);
   bloomKey.set(byteArrayForBloomKey(buf), 1.0);
   bloomFilter.add(bloomKey);
 }
Beispiel #2
0
 /**
  * Checks if this MapFile has the indicated key. The membership test is performed using a Bloom
  * filter, so the result has always non-zero probability of false positives.
  *
  * @param key key to check
  * @return false iff key doesn't exist, true if key probably exists.
  * @throws IOException
  */
 public boolean probablyHasKey(WritableComparable key) throws IOException {
   if (bloomFilter == null) {
     return true;
   }
   buf.reset();
   key.write(buf);
   bloomKey.set(byteArrayForBloomKey(buf), 1.0);
   return bloomFilter.membershipTest(bloomKey);
 }