From 11814119019232e7c17d68b665526f6462c3e521 Mon Sep 17 00:00:00 2001 From: Clint Wylie Date: Tue, 19 Dec 2017 14:47:00 -0800 Subject: [PATCH] small optimization in timeseries if 'skipEmptyBuckets' is true and cursor completed (#5178) --- .../io/druid/query/timeseries/TimeseriesQueryEngine.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/processing/src/main/java/io/druid/query/timeseries/TimeseriesQueryEngine.java b/processing/src/main/java/io/druid/query/timeseries/TimeseriesQueryEngine.java index 4fa93de263b..8c2ae5f81d5 100644 --- a/processing/src/main/java/io/druid/query/timeseries/TimeseriesQueryEngine.java +++ b/processing/src/main/java/io/druid/query/timeseries/TimeseriesQueryEngine.java @@ -62,6 +62,10 @@ public class TimeseriesQueryEngine @Override public Result apply(Cursor cursor) { + if (skipEmptyBuckets && cursor.isDone()) { + return null; + } + Aggregator[] aggregators = new Aggregator[aggregatorSpecs.size()]; String[] aggregatorNames = new String[aggregatorSpecs.size()]; @@ -70,10 +74,6 @@ public class TimeseriesQueryEngine aggregatorNames[i] = aggregatorSpecs.get(i).getName(); } - if (skipEmptyBuckets && cursor.isDone()) { - return null; - } - try { while (!cursor.isDone()) { for (Aggregator aggregator : aggregators) {