You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2015/10/22 07:17:12 UTC
incubator-kylin git commit: KYLIN-1068 add debug info
Repository: incubator-kylin
Updated Branches:
refs/heads/KYLIN-1068 4208962f4 -> b352a61dd
KYLIN-1068 add debug info
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/b352a61d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/b352a61d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/b352a61d
Branch: refs/heads/KYLIN-1068
Commit: b352a61dde90e1d013283c87018ee8cdc9324cc1
Parents: 4208962
Author: shaofengshi <sh...@apache.org>
Authored: Thu Oct 22 13:16:50 2015 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Thu Oct 22 13:16:50 2015 +0800
----------------------------------------------------------------------
.../apache/kylin/common/topn/TopNCounter.java | 41 ++++++++++++++++----
1 file changed, 33 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/b352a61d/core-common/src/main/java/org/apache/kylin/common/topn/TopNCounter.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/topn/TopNCounter.java b/core-common/src/main/java/org/apache/kylin/common/topn/TopNCounter.java
index b6d5553..cc4780c 100644
--- a/core-common/src/main/java/org/apache/kylin/common/topn/TopNCounter.java
+++ b/core-common/src/main/java/org/apache/kylin/common/topn/TopNCounter.java
@@ -104,6 +104,8 @@ public class TopNCounter<T> implements ITopK<T>, Iterable<Counter<T>> {
counterMap.remove(droppedItem);
counter.item = item;
counter.count = 0.0;
+ //FIXME: throw for testing
+ throw new IllegalStateException();
}
counterMap.put(item, counterNode);
}
@@ -117,20 +119,40 @@ public class TopNCounter<T> implements ITopK<T>, Iterable<Counter<T>> {
Counter<T> counter = counterNode.getValue();
counter.count += incrementCount;
- ListNode2<Counter<T>> nodeNext = counterNode.getNext();
+ ListNode2<Counter<T>> nodeNext;
+
+ if (incrementCount > 0) {
+ nodeNext = counterNode.getNext();
+ } else {
+ nodeNext = counterNode.getPrev();
+ }
counterList.remove(counterNode);
counterNode.prev = null;
counterNode.next = null;
- while (nodeNext != null && counter.count >= nodeNext.getValue().count) {
- nodeNext = nodeNext.getNext();
- }
- if (nodeNext != null) {
- counterList.addBefore(nodeNext, counterNode);
+ if (incrementCount > 0) {
+ while (nodeNext != null && counter.count >= nodeNext.getValue().count) {
+ nodeNext = nodeNext.getNext();
+ }
+ if (nodeNext != null) {
+ counterList.addBefore(nodeNext, counterNode);
+ } else {
+ counterList.add(counterNode);
+ }
+
} else {
- counterList.add(counterNode);
+ while (nodeNext != null && counter.count < nodeNext.getValue().count) {
+ nodeNext = nodeNext.getPrev();
+ }
+ if (nodeNext != null) {
+ counterList.addAfter(nodeNext, counterNode);
+ } else {
+ counterList.enqueue(counterNode);
+ }
}
+
+
}
@Override
@@ -227,12 +249,15 @@ public class TopNCounter<T> implements ITopK<T>, Iterable<Counter<T>> {
T item = entry.getKey();
ListNode2<Counter<T>> existing = another.counterMap.get(item);
if (existing != null) {
- this.offer(item, another.counterMap.get(item).getValue().count);
duplicateItems.add(item);
} else {
notDuplicateItems.add(item);
}
}
+
+ for(T item : duplicateItems) {
+ this.offer(item, another.counterMap.get(item).getValue().count);
+ }
for(T item : notDuplicateItems) {
this.offer(item, m2);