You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2016/04/27 01:05:47 UTC

kylin git commit: minor, add more test case for HLLC

Repository: kylin
Updated Branches:
  refs/heads/master 76cbfede9 -> dd855a512


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/dd855a51
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/dd855a51
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/dd855a51

Branch: refs/heads/master
Commit: dd855a512f5d70e1734a4637e3dfee554a40aaf4
Parents: 76cbfed
Author: Yang Li <li...@apache.org>
Authored: Wed Apr 27 07:05:01 2016 +0800
Committer: Yang Li <li...@apache.org>
Committed: Wed Apr 27 07:05:35 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/dd855a51/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/dd855a51/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..e7602a9 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);