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..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() } @@ -153,7 +152,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 = {