Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 f0939f235 -> 964a96d29 refs/heads/4.x-HBase-1.1 a16abdf8c -> 24288ab31 refs/heads/4.x-HBase-1.2 a90c1547f -> bf0c65990 refs/heads/4.x-cdh5.11.2 3990741b9 -> 25ded7c46 refs/heads/5.x-HBase-2.0 3d6ef8525 -> 7fa371977 refs/heads/master 83adf0d1a -> 3035fb11b
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/3035fb11 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/3035fb11 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/3035fb11 Branch: refs/heads/master Commit: 3035fb11b8523c68b70e55d9a0fd1646eb6d15cf Parents: 83adf0d Author: Sergey Soldatov <s...@apache.org> Authored: Wed Jan 10 13:04:00 2018 -0800 Committer: Sergey Soldatov <s...@apache.org> Committed: Thu Jan 11 15:57:52 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/3035fb11/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/3035fb11/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); + } + } + }