From 10db94101ffabdf0f781064a8d2f60b2fc9e5969 Mon Sep 17 00:00:00 2001 From: nishantmonu51 Date: Tue, 21 Oct 2014 16:31:39 +0530 Subject: [PATCH] skip value lookup compare ids instead of values --- .../druid/query/aggregation/FilteredAggregator.java | 13 +++---------- .../aggregation/FilteredAggregatorFactory.java | 4 ++-- .../query/aggregation/FilteredBufferAggregator.java | 6 +++--- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/processing/src/main/java/io/druid/query/aggregation/FilteredAggregator.java b/processing/src/main/java/io/druid/query/aggregation/FilteredAggregator.java index 9a124c5e7a1e..2134317d74fe 100644 --- a/processing/src/main/java/io/druid/query/aggregation/FilteredAggregator.java +++ b/processing/src/main/java/io/druid/query/aggregation/FilteredAggregator.java @@ -30,9 +30,9 @@ public class FilteredAggregator implements Aggregator private final String name; private final DimensionSelector dimSelector; private final Aggregator delegate; - private final Predicate predicate; + private final Predicate predicate; - public FilteredAggregator(String name, DimensionSelector dimSelector, Predicate predicate, Aggregator delegate) + public FilteredAggregator(String name, DimensionSelector dimSelector, Predicate predicate, Aggregator delegate) { this.name = name; this.dimSelector = dimSelector; @@ -45,14 +45,7 @@ public void aggregate() { if ( Iterables.any( - dimSelector.getRow(), new Predicate() - { - @Override - public boolean apply(@Nullable Integer input) - { - return predicate.apply(dimSelector.lookupName(input)); - } - } + dimSelector.getRow(), predicate ) ) { delegate.aggregate(); diff --git a/processing/src/main/java/io/druid/query/aggregation/FilteredAggregatorFactory.java b/processing/src/main/java/io/druid/query/aggregation/FilteredAggregatorFactory.java index 9d3e676ecb73..817846e48c8a 100644 --- a/processing/src/main/java/io/druid/query/aggregation/FilteredAggregatorFactory.java +++ b/processing/src/main/java/io/druid/query/aggregation/FilteredAggregatorFactory.java @@ -60,7 +60,7 @@ public Aggregator factorize(ColumnSelectorFactory metricFactory) { final Aggregator aggregator = delegate.factorize(metricFactory); final DimensionSelector dimSelector = metricFactory.makeDimensionSelector(((SelectorDimFilter)filter).getDimension()); - Predicate predicate = Predicates.equalTo(((SelectorDimFilter)filter).getValue()); + Predicate predicate = Predicates.equalTo(dimSelector.lookupId(((SelectorDimFilter)filter).getValue())); return new FilteredAggregator(name, dimSelector, predicate, aggregator); } @@ -69,7 +69,7 @@ public BufferAggregator factorizeBuffered(ColumnSelectorFactory metricFactory) { final BufferAggregator aggregator = delegate.factorizeBuffered(metricFactory); final DimensionSelector dimSelector = metricFactory.makeDimensionSelector(((SelectorDimFilter)filter).getDimension()); - Predicate predicate = Predicates.equalTo(((SelectorDimFilter)filter).getValue()); + Predicate predicate = Predicates.equalTo(dimSelector.lookupId(((SelectorDimFilter)filter).getValue())); return new FilteredBufferAggregator(dimSelector, predicate, aggregator); } diff --git a/processing/src/main/java/io/druid/query/aggregation/FilteredBufferAggregator.java b/processing/src/main/java/io/druid/query/aggregation/FilteredBufferAggregator.java index ce8795d49daf..9444bee0bffc 100644 --- a/processing/src/main/java/io/druid/query/aggregation/FilteredBufferAggregator.java +++ b/processing/src/main/java/io/druid/query/aggregation/FilteredBufferAggregator.java @@ -29,10 +29,10 @@ public class FilteredBufferAggregator implements BufferAggregator { private final DimensionSelector dimSelector; - private final Predicate predicate; + private final Predicate predicate; private final BufferAggregator delegate; - public FilteredBufferAggregator(DimensionSelector dimSelector, Predicate predicate, BufferAggregator delegate) + public FilteredBufferAggregator(DimensionSelector dimSelector, Predicate predicate, BufferAggregator delegate) { this.dimSelector = dimSelector; this.predicate = predicate; @@ -55,7 +55,7 @@ public void aggregate(ByteBuffer buf, int position) @Override public boolean apply(@Nullable Integer input) { - return predicate.apply(dimSelector.lookupName(input)); + return predicate.apply(input); } } )