You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2010/05/29 19:21:18 UTC
svn commit: r949423 - in /hbase/trunk: CHANGES.txt
src/test/java/org/apache/hadoop/hbase/util/TestByteBloomFilter.java
Author: stack
Date: Sat May 29 17:21:18 2010
New Revision: 949423
URL: http://svn.apache.org/viewvc?rev=949423&view=rev
Log:
HBASE-2625 Make testDynamicBloom()'s randomness deterministic
Modified:
hbase/trunk/CHANGES.txt
hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestByteBloomFilter.java
Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=949423&r1=949422&r2=949423&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Sat May 29 17:21:18 2010
@@ -1260,6 +1260,8 @@ Release 0.20.0 - Tue Sep 8 12:53:05 PDT
HBASE-1743 [debug tool] Add regionsInTransition list to ClusterStatus
detailed output
HBASE-1772 Up the default ZK session timeout from 30seconds to 60seconds
+ HBASE-2625 Make testDynamicBloom()'s "randomness" deterministic
+ (Nicolas Spiegelberg via Stack)
OPTIMIZATIONS
HBASE-1412 Change values for delete column and column family in KeyValue
Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestByteBloomFilter.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestByteBloomFilter.java?rev=949423&r1=949422&r2=949423&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestByteBloomFilter.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/util/TestByteBloomFilter.java Sat May 29 17:21:18 2010
@@ -26,6 +26,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.nio.ByteBuffer;
import java.util.BitSet;
+import java.util.Random;
import junit.framework.TestCase;
@@ -150,13 +151,23 @@ public class TestByteBloomFilter extends
Hash.MURMUR_HASH);
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
- if (Math.random() > 0.5) {
+ if (r.nextBoolean()) {
bf1.add(Bytes.toBytes(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
ByteArrayOutputStream metaOut = new ByteArrayOutputStream();
@@ -178,8 +189,11 @@ public class TestByteBloomFilter extends
}
}
- // note that actualErr = err * bloomCount
- // error rate should be roughly: (keyInterval*2)*(err*2), allow some tolerance
+ // Dynamic Blooms are a little sneaky. The error rate currently isn't
+ // '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);
assertTrue(falsePositives <= (keyInterval*5)*err);
}