Skip to content

Commit

Permalink
skip value lookup
Browse files Browse the repository at this point in the history
compare ids instead of values
  • Loading branch information
nishantmonu51 authored and xvrl committed Oct 21, 2014
1 parent 71831e4 commit 10db941
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public class FilteredAggregator implements Aggregator
private final String name;
private final DimensionSelector dimSelector;
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.dimSelector = dimSelector;
Expand All @@ -45,14 +45,7 @@ public void aggregate()
{
if (
Iterables.any(
dimSelector.getRow(), new Predicate<Integer>()
{
@Override
public boolean apply(@Nullable Integer input)
{
return predicate.apply(dimSelector.lookupName(input));
}
}
dimSelector.getRow(), predicate
)
) {
delegate.aggregate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Aggregator factorize(ColumnSelectorFactory metricFactory)
{
final Aggregator aggregator = delegate.factorize(metricFactory);
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);
}

Expand All @@ -69,7 +69,7 @@ public BufferAggregator factorizeBuffered(ColumnSelectorFactory metricFactory)
{
final BufferAggregator aggregator = delegate.factorizeBuffered(metricFactory);
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
public class FilteredBufferAggregator implements BufferAggregator
{
private final DimensionSelector dimSelector;
private final Predicate<String> predicate;
private final Predicate<Integer> predicate;
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.predicate = predicate;
Expand All @@ -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);
}
}
)
Expand Down

0 comments on commit 10db941

Please sign in to comment.