diff --git a/processing/src/main/java/io/druid/query/RetryQueryRunner.java b/processing/src/main/java/io/druid/query/RetryQueryRunner.java index 9f3921bd87d..bf402ccb63f 100644 --- a/processing/src/main/java/io/druid/query/RetryQueryRunner.java +++ b/processing/src/main/java/io/druid/query/RetryQueryRunner.java @@ -27,6 +27,7 @@ import com.metamx.common.guava.Sequence; import com.metamx.common.guava.Yielder; import com.metamx.common.guava.YieldingAccumulator; import com.metamx.common.guava.YieldingSequenceBase; +import com.metamx.emitter.EmittingLogger; import io.druid.query.spec.MultipleSpecificSegmentSpec; import io.druid.segment.SegmentMissingException; @@ -36,6 +37,7 @@ import java.util.Map; public class RetryQueryRunner implements QueryRunner { public static String MISSING_SEGMENTS_KEY = "missingSegments"; + private static final EmittingLogger log = new EmittingLogger(RetryQueryRunner.class); private final QueryRunner baseRunner; private final RetryQueryRunnerConfig config; @@ -73,6 +75,8 @@ public class RetryQueryRunner implements QueryRunner } for (int i = 0; i < config.numTries(); i++) { + log.info("[%,d] missing segments found. Retry attempt [%,d]", missingSegments.size(), i); + context.put(MISSING_SEGMENTS_KEY, Lists.newArrayList()); final Query retryQuery = query.withQuerySegmentSpec( new MultipleSpecificSegmentSpec( diff --git a/processing/src/main/java/io/druid/query/spec/SpecificSegmentQueryRunner.java b/processing/src/main/java/io/druid/query/spec/SpecificSegmentQueryRunner.java index b8b25922e26..b8b68f86895 100644 --- a/processing/src/main/java/io/druid/query/spec/SpecificSegmentQueryRunner.java +++ b/processing/src/main/java/io/druid/query/spec/SpecificSegmentQueryRunner.java @@ -23,7 +23,6 @@ import com.google.common.base.Throwables; import com.google.common.collect.Lists; import com.metamx.common.guava.Accumulator; import com.metamx.common.guava.Sequence; -import com.metamx.common.guava.Sequences; import com.metamx.common.guava.Yielder; import com.metamx.common.guava.YieldingAccumulator; import io.druid.query.Query; @@ -68,20 +67,7 @@ public class SpecificSegmentQueryRunner implements QueryRunner @Override public Sequence call() throws Exception { - Sequence returningSeq; - try { - returningSeq = base.run(query, context); - } - catch (SegmentMissingException e) { - List missingSegments = (List) context.get(RetryQueryRunner.MISSING_SEGMENTS_KEY); - if (missingSegments == null) { - missingSegments = Lists.newArrayList(); - context.put(RetryQueryRunner.MISSING_SEGMENTS_KEY, missingSegments); - } - missingSegments.add(specificSpec.getDescriptor()); - returningSeq = Sequences.empty(); - } - return returningSeq; + return base.run(query, context); } } ); @@ -97,7 +83,18 @@ public class SpecificSegmentQueryRunner implements QueryRunner @Override public OutType call() throws Exception { - return baseSequence.accumulate(initValue, accumulator); + try { + return baseSequence.accumulate(initValue, accumulator); + } + catch (SegmentMissingException e) { + List missingSegments = (List) context.get(RetryQueryRunner.MISSING_SEGMENTS_KEY); + if (missingSegments == null) { + missingSegments = Lists.newArrayList(); + context.put(RetryQueryRunner.MISSING_SEGMENTS_KEY, missingSegments); + } + missingSegments.add(specificSpec.getDescriptor()); + return initValue; + } } } ); 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 9489e400a6e..98882a75a9d 100644 --- a/processing/src/main/java/io/druid/query/timeseries/TimeseriesQueryEngine.java +++ b/processing/src/main/java/io/druid/query/timeseries/TimeseriesQueryEngine.java @@ -36,8 +36,6 @@ import java.util.List; */ public class TimeseriesQueryEngine { - private static final int AGG_UNROLL_COUNT = 8; - public Sequence> process(final TimeseriesQuery query, final StorageAdapter adapter) { if (adapter == null) { @@ -61,7 +59,7 @@ public class TimeseriesQueryEngine Aggregator[] aggregators = QueryRunnerHelper.makeAggregators(cursor, aggregatorSpecs); try { while (!cursor.isDone()) { - for(Aggregator aggregator : aggregators) { + for (Aggregator aggregator : aggregators) { aggregator.aggregate(); } cursor.advance(); diff --git a/server/src/main/java/io/druid/server/QueryResource.java b/server/src/main/java/io/druid/server/QueryResource.java index b66b080f6b9..be09886f4a9 100644 --- a/server/src/main/java/io/druid/server/QueryResource.java +++ b/server/src/main/java/io/druid/server/QueryResource.java @@ -153,8 +153,8 @@ public class QueryResource log.debug("Got query [%s]", query); } - final Map context = new MapMaker().makeMap(); - final Sequence res = query.run(texasRanger, context); + final Map responseContext = new MapMaker().makeMap(); + final Sequence res = query.run(texasRanger, responseContext); final Sequence results; if (res == null) { results = Sequences.empty(); @@ -212,7 +212,7 @@ public class QueryResource isSmile ? APPLICATION_JSON : APPLICATION_SMILE ) .header("X-Druid-Query-Id", queryId) - .header("X-Druid-Response-Context", jsonMapper.writeValueAsString(context)) + .header("X-Druid-Response-Context", jsonMapper.writeValueAsString(responseContext)) .build(); } catch (Exception e) {