DRILL-5824: Retain original memory limit for 1st phase HashAgg with 1 partition

closes #966


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/f958d4d0
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/f958d4d0
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/f958d4d0

Branch: refs/heads/master
Commit: f958d4d0545c2d886e16f3413e2166f69c80d772
Parents: 5a100d1
Author: Ben-Zvi <bben-...@mapr.com>
Authored: Thu Sep 28 17:09:53 2017 -0700
Committer: Paul Rogers <prog...@maprtech.com>
Committed: Sat Sep 30 19:13:35 2017 -0700

----------------------------------------------------------------------
 .../drill/exec/physical/impl/aggregate/HashAggTemplate.java     | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/f958d4d0/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggTemplate.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggTemplate.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggTemplate.java
index 1e65c49..4a81f3c 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggTemplate.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggTemplate.java
@@ -441,8 +441,9 @@ public abstract class HashAggTemplate implements 
HashAggregator {
 
     // The following initial safety check should be revisited once we can 
lower the number of rows in a batch
     // In cases of very tight memory -- need at least memory to process one 
batch, plus overhead (e.g. hash table)
-    if ( numPartitions == 1 ) {
-      // if too little memory - behave like the old code -- no memory limit 
for hash aggregate
+    if ( numPartitions == 1 && ! canSpill ) {
+      // if too little memory - behave like the old code -- practically no 
memory limit for hash aggregate
+      // (but 1st phase can still spill, so it will maintain the original 
memory limit)
       allocator.setLimit(AbstractBase.MAX_ALLOCATION);  // 10_000_000_000L
     }
     // Based on the number of partitions: Set the mask and bit count

Reply via email to