From f7092e12c1013c166f344d3a1c87cabefe485646 Mon Sep 17 00:00:00 2001 From: Yuan Zhou Date: Fri, 15 Jan 2021 00:38:44 +0800 Subject: [PATCH 1/2] early close sort input to reduce memory footprint Signed-off-by: Yuan Zhou --- .../scala/com/intel/oap/expression/ColumnarSorter.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/scala/com/intel/oap/expression/ColumnarSorter.scala b/core/src/main/scala/com/intel/oap/expression/ColumnarSorter.scala index 0b459289a..9a874d55c 100644 --- a/core/src/main/scala/com/intel/oap/expression/ColumnarSorter.scala +++ b/core/src/main/scala/com/intel/oap/expression/ColumnarSorter.scala @@ -153,7 +153,12 @@ class ColumnarSorter( sort_elapse += System.nanoTime() - beforeSort total_elapse += System.nanoTime() - beforeSort } - sort_iterator.hasNext() + if (sort_iterator.hasNext()) { + return true + } else { + inputBatchHolder.foreach(cb => cb.close()) + return false + } } override def next(): ColumnarBatch = { From ae60f644e41380aab756b3adc2da0b13d3e86743 Mon Sep 17 00:00:00 2001 From: Yuan Zhou Date: Mon, 18 Jan 2021 21:18:44 +0800 Subject: [PATCH 2/2] remove double close Signed-off-by: Yuan Zhou --- .../src/main/scala/com/intel/oap/expression/ColumnarSorter.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/scala/com/intel/oap/expression/ColumnarSorter.scala b/core/src/main/scala/com/intel/oap/expression/ColumnarSorter.scala index 9a874d55c..b23ee7339 100644 --- a/core/src/main/scala/com/intel/oap/expression/ColumnarSorter.scala +++ b/core/src/main/scala/com/intel/oap/expression/ColumnarSorter.scala @@ -92,7 +92,6 @@ class ColumnarSorter( elapse.set(NANOSECONDS.toMillis(total_elapse)) sortTime.set(NANOSECONDS.toMillis(sort_elapse)) shuffleTime.set(NANOSECONDS.toMillis(shuffle_elapse)) - inputBatchHolder.foreach(cb => cb.close()) if (sorter != null) { sorter.close() }