You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ss...@apache.org on 2018/01/12 00:00:03 UTC
[6/6] phoenix git commit: PHOENIX-4525 Integer overflow in GroupBy
execution
PHOENIX-4525 Integer overflow in GroupBy execution
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/25ded7c4
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/25ded7c4
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/25ded7c4
Branch: refs/heads/4.x-cdh5.11.2
Commit: 25ded7c462b04af1b757bf086314debe0ad01845
Parents: 3990741
Author: Sergey Soldatov <ss...@apache.org>
Authored: Wed Jan 10 13:04:00 2018 -0800
Committer: Sergey Soldatov <ss...@apache.org>
Committed: Thu Jan 11 15:59:21 2018 -0800
----------------------------------------------------------------------
.../main/java/org/apache/phoenix/util/SizedUtil.java | 2 +-
.../org/apache/phoenix/memory/MemoryManagerTest.java | 15 +++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/25ded7c4/phoenix-core/src/main/java/org/apache/phoenix/util/SizedUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/SizedUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/SizedUtil.java
index f82c1b8..d67ed7f 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/SizedUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/SizedUtil.java
@@ -67,7 +67,7 @@ public class SizedUtil {
public static long sizeOfMap(int nRows, int keySize, int valueSize) {
return SizedUtil.OBJECT_SIZE * 4 + sizeOfArrayList(nRows) /* key set */ + nRows * (
- SizedUtil.MAP_ENTRY_SIZE + /* entry set */
+ SizedUtil.MAP_ENTRY_SIZE * 1L + /* entry set */
keySize + // key size
valueSize); // value size
}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/25ded7c4/phoenix-core/src/test/java/org/apache/phoenix/memory/MemoryManagerTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/memory/MemoryManagerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/memory/MemoryManagerTest.java
index 6da2526..897bb5b 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/memory/MemoryManagerTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/memory/MemoryManagerTest.java
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.phoenix.coprocessor.GroupedAggregateRegionObserver;
import org.apache.phoenix.memory.MemoryManager.MemoryChunk;
import org.junit.Test;
@@ -177,4 +178,18 @@ public class MemoryManagerTest {
// make sure all memory is freed
assertTrue(gmm.getAvailableMemory() == gmm.getMaxMemory());
}
+
+ /**
+ * Test for SpillableGroupByCache which is using MemoryManager to allocate chunks for GroupBy execution
+ * @throws Exception
+ */
+ @Test
+ public void testCorrectnessOfChunkAllocation() throws Exception {
+ for(int i = 1000;i < Integer.MAX_VALUE;) {
+ i *=1.5f;
+ long result = GroupedAggregateRegionObserver.sizeOfUnorderedGroupByMap(i, 100);
+ assertTrue("Size for GroupByMap is negative" , result > 0);
+ }
+ }
+
}