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 05:02:40 UTC
incubator-kylin git commit: KYLIN-1068 fix a concurrent modification
bug
Repository: incubator-kylin
Updated Branches:
refs/heads/KYLIN-1068 864f9b464 -> 4208962f4
KYLIN-1068 fix a concurrent modification bug
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/4208962f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/4208962f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/4208962f
Branch: refs/heads/KYLIN-1068
Commit: 4208962f46866730773950ef3e96a1760ef9c24c
Parents: 864f9b4
Author: shaofengshi <sh...@apache.org>
Authored: Thu Oct 22 11:02:19 2015 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Thu Oct 22 11:02:19 2015 +0800
----------------------------------------------------------------------
.../java/org/apache/kylin/common/topn/TopNCounter.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/4208962f/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 db5e0c8..b6d5553 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
@@ -166,6 +166,7 @@ public class TopNCounter<T> implements ITopK<T>, Iterable<Counter<T>> {
* @return number of items stored
*/
public int size() {
+ assert counterMap.size() == counterList.size();
return counterMap.size();
}
@@ -219,19 +220,23 @@ public class TopNCounter<T> implements ITopK<T>, Iterable<Counter<T>> {
m2 = another.counterList.tail().getValue().count;
}
- Set<T> duplicateItems = Sets.newHashSet();
+ Set<T> duplicateItems = Sets.newHashSet();
+ List<T> notDuplicateItems = Lists.newArrayList();
for (Map.Entry<T, ListNode2<Counter<T>>> entry : this.counterMap.entrySet()) {
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 {
- this.offer(item, m2);
+ notDuplicateItems.add(item);
}
}
+
+ for(T item : notDuplicateItems) {
+ this.offer(item, m2);
+ }
for (Map.Entry<T, ListNode2<Counter<T>>> entry : another.counterMap.entrySet()) {
T item = entry.getKey();