skip value lookup

compare ids instead of values
This commit is contained in:
nishantmonu51 2014-10-21 16:31:39 +05:30 committed by Xavier Léauté
parent 71831e49d9
commit 10db94101f
3 changed files with 8 additions and 15 deletions

View File

@ -30,9 +30,9 @@ public class FilteredAggregator implements Aggregator
private final String name; private final String name;
private final DimensionSelector dimSelector; private final DimensionSelector dimSelector;
private final Aggregator delegate; private final Aggregator delegate;
private final Predicate<String> predicate; private final Predicate<Integer> predicate;
public FilteredAggregator(String name, DimensionSelector dimSelector, Predicate<String> predicate, Aggregator delegate) public FilteredAggregator(String name, DimensionSelector dimSelector, Predicate<Integer> predicate, Aggregator delegate)
{ {
this.name = name; this.name = name;
this.dimSelector = dimSelector; this.dimSelector = dimSelector;
@ -45,14 +45,7 @@ public class FilteredAggregator implements Aggregator
{ {
if ( if (
Iterables.any( Iterables.any(
dimSelector.getRow(), new Predicate<Integer>() dimSelector.getRow(), predicate
{
@Override
public boolean apply(@Nullable Integer input)
{
return predicate.apply(dimSelector.lookupName(input));
}
}
) )
) { ) {
delegate.aggregate(); delegate.aggregate();

View File

@ -60,7 +60,7 @@ public class FilteredAggregatorFactory implements AggregatorFactory
{ {
final Aggregator aggregator = delegate.factorize(metricFactory); final Aggregator aggregator = delegate.factorize(metricFactory);
final DimensionSelector dimSelector = metricFactory.makeDimensionSelector(((SelectorDimFilter)filter).getDimension()); final DimensionSelector dimSelector = metricFactory.makeDimensionSelector(((SelectorDimFilter)filter).getDimension());
Predicate<String> predicate = Predicates.equalTo(((SelectorDimFilter)filter).getValue()); Predicate<Integer> predicate = Predicates.equalTo(dimSelector.lookupId(((SelectorDimFilter)filter).getValue()));
return new FilteredAggregator(name, dimSelector, predicate, aggregator); return new FilteredAggregator(name, dimSelector, predicate, aggregator);
} }
@ -69,7 +69,7 @@ public class FilteredAggregatorFactory implements AggregatorFactory
{ {
final BufferAggregator aggregator = delegate.factorizeBuffered(metricFactory); final BufferAggregator aggregator = delegate.factorizeBuffered(metricFactory);
final DimensionSelector dimSelector = metricFactory.makeDimensionSelector(((SelectorDimFilter)filter).getDimension()); final DimensionSelector dimSelector = metricFactory.makeDimensionSelector(((SelectorDimFilter)filter).getDimension());
Predicate<String> predicate = Predicates.equalTo(((SelectorDimFilter)filter).getValue()); Predicate<Integer> predicate = Predicates.equalTo(dimSelector.lookupId(((SelectorDimFilter)filter).getValue()));
return new FilteredBufferAggregator(dimSelector, predicate, aggregator); return new FilteredBufferAggregator(dimSelector, predicate, aggregator);
} }

View File

@ -29,10 +29,10 @@ import java.nio.ByteBuffer;
public class FilteredBufferAggregator implements BufferAggregator public class FilteredBufferAggregator implements BufferAggregator
{ {
private final DimensionSelector dimSelector; private final DimensionSelector dimSelector;
private final Predicate<String> predicate; private final Predicate<Integer> predicate;
private final BufferAggregator delegate; private final BufferAggregator delegate;
public FilteredBufferAggregator(DimensionSelector dimSelector, Predicate<String> predicate, BufferAggregator delegate) public FilteredBufferAggregator(DimensionSelector dimSelector, Predicate<Integer> predicate, BufferAggregator delegate)
{ {
this.dimSelector = dimSelector; this.dimSelector = dimSelector;
this.predicate = predicate; this.predicate = predicate;
@ -55,7 +55,7 @@ public class FilteredBufferAggregator implements BufferAggregator
@Override @Override
public boolean apply(@Nullable Integer input) public boolean apply(@Nullable Integer input)
{ {
return predicate.apply(dimSelector.lookupName(input)); return predicate.apply(input);
} }
} }
) )