mirror of https://github.com/apache/druid.git
parent
71831e49d9
commit
10db94101f
|
@ -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();
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue