phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject [2/6] phoenix git commit: PHOENIX-4525 Integer overflow in GroupBy execution
Date Thu, 11 Jan 2018 23:59:59 GMT
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/7fa37197
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7fa37197
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7fa37197

Branch: refs/heads/5.x-HBase-2.0
Commit: 7fa3719775ee28941f5322063f6a13a17b97be28
Parents: 3d6ef85
Author: Sergey Soldatov <ssa@apache.org>
Authored: Wed Jan 10 13:04:00 2018 -0800
Committer: Sergey Soldatov <ssa@apache.org>
Committed: Thu Jan 11 15:58: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/7fa37197/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/7fa37197/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);
+        }
+    }
+
 }


Mime
View raw message