mirror of https://github.com/apache/druid.git
fix bysegment-query-runner
This commit is contained in:
parent
294a9ba78f
commit
93f97a5d86
|
@ -28,6 +28,7 @@ import com.metamx.common.guava.Yielders;
|
||||||
import com.metamx.common.guava.YieldingAccumulator;
|
import com.metamx.common.guava.YieldingAccumulator;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,15 +56,10 @@ public class BySegmentQueryRunner<T> implements QueryRunner<T>
|
||||||
{
|
{
|
||||||
if (query.getContextBySegment(false)) {
|
if (query.getContextBySegment(false)) {
|
||||||
final Sequence<T> baseSequence = base.run(query);
|
final Sequence<T> baseSequence = base.run(query);
|
||||||
return new Sequence<T>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public <OutType> OutType accumulate(OutType initValue, Accumulator<OutType, T> accumulator)
|
|
||||||
{
|
|
||||||
List<T> results = Sequences.toList(baseSequence, Lists.<T>newArrayList());
|
|
||||||
|
|
||||||
return accumulator.accumulate(
|
final List<T> results = Sequences.toList(baseSequence, Lists.<T>newArrayList());
|
||||||
initValue,
|
return Sequences.simple(
|
||||||
|
Arrays.asList(
|
||||||
(T) new Result<BySegmentResultValueClass<T>>(
|
(T) new Result<BySegmentResultValueClass<T>>(
|
||||||
timestamp,
|
timestamp,
|
||||||
new BySegmentResultValueClass<T>(
|
new BySegmentResultValueClass<T>(
|
||||||
|
@ -72,29 +68,8 @@ public class BySegmentQueryRunner<T> implements QueryRunner<T>
|
||||||
query.getIntervals().get(0)
|
query.getIntervals().get(0)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
)
|
||||||
}
|
);
|
||||||
|
|
||||||
@Override
|
|
||||||
public <OutType> Yielder<OutType> toYielder(OutType initValue, YieldingAccumulator<OutType, T> accumulator)
|
|
||||||
{
|
|
||||||
List<T> results = Sequences.toList(baseSequence, Lists.<T>newArrayList());
|
|
||||||
|
|
||||||
final OutType retVal = accumulator.accumulate(
|
|
||||||
initValue,
|
|
||||||
(T) new Result<BySegmentResultValueClass<T>>(
|
|
||||||
timestamp,
|
|
||||||
new BySegmentResultValueClass<T>(
|
|
||||||
results,
|
|
||||||
segmentIdentifier,
|
|
||||||
query.getIntervals().get(0)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return Yielders.done(retVal, null);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.run(query);
|
return base.run(query);
|
||||||
|
|
Loading…
Reference in New Issue