mirror of https://github.com/apache/druid.git
simplify query toolchest interface
This commit is contained in:
parent
e3822f6ca7
commit
1b85eaad3e
|
@ -22,12 +22,9 @@ package com.metamx.druid.query;
|
|||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.google.common.base.Function;
|
||||
import com.metamx.common.guava.Sequence;
|
||||
import com.metamx.druid.LogicalSegment;
|
||||
import com.metamx.druid.Query;
|
||||
import com.metamx.druid.TimelineObjectHolder;
|
||||
import com.metamx.druid.client.selector.ServerSelector;
|
||||
import com.metamx.emitter.service.ServiceMetricEvent;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -50,7 +47,7 @@ public abstract class QueryToolChest<ResultType, QueryType extends Query<ResultT
|
|||
public abstract Function<ResultType, ResultType> makeMetricManipulatorFn(QueryType query, MetricManipulationFn fn);
|
||||
public abstract TypeReference<ResultType> getResultTypeReference();
|
||||
|
||||
public <T> CacheStrategy<ResultType, T, QueryType> getCacheStrategy(QueryType query) {
|
||||
public <T> CacheStrategy<ResultType, T, QueryType> getCacheStrategy(QueryType query) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -62,10 +59,7 @@ public abstract class QueryToolChest<ResultType, QueryType extends Query<ResultT
|
|||
return runner;
|
||||
}
|
||||
|
||||
public List<TimelineObjectHolder<String, ServerSelector>> filterSegments(
|
||||
QueryType query,
|
||||
List<TimelineObjectHolder<String, ServerSelector>> segments
|
||||
) {
|
||||
public <T extends LogicalSegment> List<T> filterSegments(QueryType query, List<T> segments) {
|
||||
return segments;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,16 +22,14 @@ package com.metamx.druid.query.timeboundary;
|
|||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Functions;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.metamx.common.guava.MergeSequence;
|
||||
import com.metamx.common.guava.Sequence;
|
||||
import com.metamx.common.guava.Sequences;
|
||||
import com.metamx.druid.LogicalSegment;
|
||||
import com.metamx.druid.Query;
|
||||
import com.metamx.druid.TimelineObjectHolder;
|
||||
import com.metamx.druid.client.selector.ServerSelector;
|
||||
import com.metamx.druid.collect.OrderedMergeSequence;
|
||||
import com.metamx.druid.query.BySegmentSkippingQueryRunner;
|
||||
import com.metamx.druid.query.CacheStrategy;
|
||||
|
@ -47,8 +45,6 @@ import org.joda.time.DateTime;
|
|||
import javax.annotation.Nullable;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -64,32 +60,17 @@ public class TimeBoundaryQueryQueryToolChest
|
|||
{
|
||||
};
|
||||
|
||||
|
||||
@Override
|
||||
public List<TimelineObjectHolder<String, ServerSelector>> filterSegments(
|
||||
TimeBoundaryQuery query,
|
||||
List<TimelineObjectHolder<String, ServerSelector>> input
|
||||
) {
|
||||
long minMillis = Long.MAX_VALUE;
|
||||
long maxMillis = Long.MIN_VALUE;
|
||||
TimelineObjectHolder<String, ServerSelector> min = null;
|
||||
TimelineObjectHolder<String, ServerSelector> max = null;
|
||||
|
||||
for(TimelineObjectHolder<String, ServerSelector> e : input) {
|
||||
final long start = e.getInterval().getStartMillis();
|
||||
final long end = e.getInterval().getEndMillis();
|
||||
|
||||
if(min == null || start < minMillis) {
|
||||
min = e;
|
||||
minMillis = start;
|
||||
}
|
||||
if(max == null || end > maxMillis) {
|
||||
max = e;
|
||||
maxMillis = end;
|
||||
}
|
||||
public <T extends LogicalSegment> List<T> filterSegments(TimeBoundaryQuery query, List<T> input)
|
||||
{
|
||||
if(input.size() <= 1) {
|
||||
return input;
|
||||
}
|
||||
|
||||
return min == max ? Lists.newArrayList(min) : Lists.newArrayList(min , max);
|
||||
return Lists.newArrayList(
|
||||
Iterables.getFirst(input, null),
|
||||
Iterables.getLast(input)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package com.metamx.druid;
|
||||
|
||||
import org.joda.time.Interval;
|
||||
|
||||
public interface LogicalSegment
|
||||
{
|
||||
public Interval getInterval();
|
||||
}
|
|
@ -24,7 +24,7 @@ import org.joda.time.Interval;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class TimelineObjectHolder<VersionType, ObjectType>
|
||||
public class TimelineObjectHolder<VersionType, ObjectType> implements LogicalSegment
|
||||
{
|
||||
private final Interval interval;
|
||||
private final VersionType version;
|
||||
|
@ -41,6 +41,7 @@ public class TimelineObjectHolder<VersionType, ObjectType>
|
|||
this.object = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interval getInterval()
|
||||
{
|
||||
return interval;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<groupId>com.metamx</groupId>
|
||||
<artifactId>druid-examples</artifactId>
|
||||
<version>0.2.8-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<groupId>com.metamx</groupId>
|
||||
<artifactId>druid-examples</artifactId>
|
||||
<version>0.2.8-SNAPSHOT</version>
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
Loading…
Reference in New Issue