kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject kylin git commit: minor, add more test case for HLLC
Date Tue, 26 Apr 2016 23:07:35 GMT
Repository: kylin
Updated Branches:
  refs/heads/yang-m1 1f8ec67a5 -> ad485ecb0


minor, add more test case for HLLC


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/ad485ecb
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/ad485ecb
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/ad485ecb

Branch: refs/heads/yang-m1
Commit: ad485ecb01cac0e402285cd55c370e657903ae33
Parents: 1f8ec67
Author: Yang Li <liyang@apache.org>
Authored: Wed Apr 27 07:05:01 2016 +0800
Committer: Yang Li <liyang@apache.org>
Committed: Wed Apr 27 07:07:15 2016 +0800

----------------------------------------------------------------------
 .../kylin/measure/hllc/HyperLogLogPlusCounter.java       |  2 ++
 .../apache/kylin/measure/hll/HyperLogLogCounterTest.java | 11 +++++++++++
 2 files changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/ad485ecb/core-metadata/src/main/java/org/apache/kylin/measure/hllc/HyperLogLogPlusCounter.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/measure/hllc/HyperLogLogPlusCounter.java
b/core-metadata/src/main/java/org/apache/kylin/measure/hllc/HyperLogLogPlusCounter.java
index b5028d6..4f9755b 100644
--- a/core-metadata/src/main/java/org/apache/kylin/measure/hllc/HyperLogLogPlusCounter.java
+++ b/core-metadata/src/main/java/org/apache/kylin/measure/hllc/HyperLogLogPlusCounter.java
@@ -71,6 +71,7 @@ public class HyperLogLogPlusCounter implements Serializable, Comparable<HyperLog
     public void clear() {
         byte zero = (byte) 0;
         Arrays.fill(registers, zero);
+        singleBucket = -1;
     }
 
     public void add(int value) {
@@ -276,6 +277,7 @@ public class HyperLogLogPlusCounter implements Serializable, Comparable<HyperLog
 
     public void readRegistersArray(ByteBuffer in) {
         in.get(registers, 0, m);
+        singleBucket = Integer.MIN_VALUE;
     }
 
     private int getRegisterIndexSize() {

http://git-wip-us.apache.org/repos/asf/kylin/blob/ad485ecb/core-metadata/src/test/java/org/apache/kylin/measure/hll/HyperLogLogCounterTest.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/test/java/org/apache/kylin/measure/hll/HyperLogLogCounterTest.java
b/core-metadata/src/test/java/org/apache/kylin/measure/hll/HyperLogLogCounterTest.java
index e96b9d0..15a3a47 100644
--- a/core-metadata/src/test/java/org/apache/kylin/measure/hll/HyperLogLogCounterTest.java
+++ b/core-metadata/src/test/java/org/apache/kylin/measure/hll/HyperLogLogCounterTest.java
@@ -46,6 +46,17 @@ public class HyperLogLogCounterTest {
     int errorCount3 = 0;
 
     @Test
+    public void testOneAdd() throws IOException {
+        HyperLogLogPlusCounter hllc = new HyperLogLogPlusCounter(14);
+        HyperLogLogPlusCounter one = new HyperLogLogPlusCounter(14);
+        for (int i = 0; i < 1000000; i++) {
+            one.clear();
+            one.add(rand1.nextInt());
+            hllc.merge(one);
+        }
+    }
+    
+    @Test
     public void testPeekLength() throws IOException {
         HyperLogLogPlusCounter hllc = new HyperLogLogPlusCounter(10);
         HyperLogLogPlusCounter copy = new HyperLogLogPlusCounter(10);


Mime
View raw message