HBASE-2625 Make testDynamicBloom()'s randomness deterministic
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@949423 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
914f415fd5
commit
9f7ecc2b02
|
@ -1260,6 +1260,8 @@ Release 0.20.0 - Tue Sep 8 12:53:05 PDT 2009
|
||||||
HBASE-1743 [debug tool] Add regionsInTransition list to ClusterStatus
|
HBASE-1743 [debug tool] Add regionsInTransition list to ClusterStatus
|
||||||
detailed output
|
detailed output
|
||||||
HBASE-1772 Up the default ZK session timeout from 30seconds to 60seconds
|
HBASE-1772 Up the default ZK session timeout from 30seconds to 60seconds
|
||||||
|
HBASE-2625 Make testDynamicBloom()'s "randomness" deterministic
|
||||||
|
(Nicolas Spiegelberg via Stack)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
HBASE-1412 Change values for delete column and column family in KeyValue
|
HBASE-1412 Change values for delete column and column family in KeyValue
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
@ -150,13 +151,23 @@ public class TestByteBloomFilter extends TestCase {
|
||||||
Hash.MURMUR_HASH);
|
Hash.MURMUR_HASH);
|
||||||
bf1.allocBloom();
|
bf1.allocBloom();
|
||||||
|
|
||||||
|
long seed = System.currentTimeMillis();
|
||||||
|
Random r = new Random(seed);
|
||||||
|
System.out.println("seed = " + seed);
|
||||||
|
|
||||||
for (int i = 0; i < keyInterval*4; ++i) { // add
|
for (int i = 0; i < keyInterval*4; ++i) { // add
|
||||||
if (Math.random() > 0.5) {
|
if (r.nextBoolean()) {
|
||||||
bf1.add(Bytes.toBytes(i));
|
bf1.add(Bytes.toBytes(i));
|
||||||
valid.set(i);
|
valid.set(i);
|
||||||
|
|
||||||
|
// we assume only 2 blooms in this test, so exit before a 3rd is made
|
||||||
|
if (bf1.getKeyCount() == 2000) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertTrue(2 <= bf1.bloomCount() && bf1.bloomCount() <= 3);
|
}
|
||||||
|
assertTrue(2 <= bf1.bloomCount());
|
||||||
|
System.out.println("keys added = " + bf1.getKeyCount());
|
||||||
|
|
||||||
// test serialization/deserialization
|
// test serialization/deserialization
|
||||||
ByteArrayOutputStream metaOut = new ByteArrayOutputStream();
|
ByteArrayOutputStream metaOut = new ByteArrayOutputStream();
|
||||||
|
@ -178,8 +189,11 @@ public class TestByteBloomFilter extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// note that actualErr = err * bloomCount
|
// Dynamic Blooms are a little sneaky. The error rate currently isn't
|
||||||
// error rate should be roughly: (keyInterval*2)*(err*2), allow some tolerance
|
// 'err', it's err * bloomCount. bloomCount == 2000/1000 == 2 in this case
|
||||||
|
// So, the actual error rate should be roughly:
|
||||||
|
// (keyInterval*2) * err * bloomCount
|
||||||
|
// allow some tolerance
|
||||||
System.out.println("False positives: " + falsePositives);
|
System.out.println("False positives: " + falsePositives);
|
||||||
assertTrue(falsePositives <= (keyInterval*5)*err);
|
assertTrue(falsePositives <= (keyInterval*5)*err);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue