review comment - have separate methods

This commit is contained in:
nishantmonu51 2014-09-05 00:03:36 +05:30
parent 2772a78b3b
commit 90632ecf3a
11 changed files with 72 additions and 68 deletions

View File

@ -42,11 +42,13 @@ public abstract class QueryToolChest<ResultType, QueryType extends Query<ResultT
* This method doesn't belong here, but it's here for now just to make it work. * This method doesn't belong here, but it's here for now just to make it work.
* *
* @param seqOfSequences * @param seqOfSequences
* @param ordered whether the seqOfSequences is ordered or not.
* *
* @return * @return
*/ */
public abstract Sequence<ResultType> mergeSequences(Sequence<Sequence<ResultType>> seqOfSequences, boolean ordered); public abstract Sequence<ResultType> mergeSequences(Sequence<Sequence<ResultType>> seqOfSequences);
public abstract Sequence<ResultType> mergeSequencesUnordered(Sequence<Sequence<ResultType>> seqOfSequences);
public abstract ServiceMetricEvent.Builder makeMetricBuilder(QueryType query); public abstract ServiceMetricEvent.Builder makeMetricBuilder(QueryType query);

View File

@ -46,7 +46,7 @@ public class UnionQueryRunner<T> implements QueryRunner<T>
{ {
DataSource dataSource = query.getDataSource(); DataSource dataSource = query.getDataSource();
if (dataSource instanceof UnionDataSource) { if (dataSource instanceof UnionDataSource) {
return toolChest.mergeSequences( return toolChest.mergeSequencesUnordered(
Sequences.simple( Sequences.simple(
Lists.transform( Lists.transform(
((UnionDataSource) dataSource).getDataSources(), ((UnionDataSource) dataSource).getDataSources(),
@ -61,8 +61,7 @@ public class UnionQueryRunner<T> implements QueryRunner<T>
} }
} }
) )
), )
false
); );
} else { } else {
return baseRunner.run(query); return baseRunner.run(query);

View File

@ -191,16 +191,18 @@ public class GroupByQueryQueryToolChest extends QueryToolChest<Row, GroupByQuery
@Override @Override
public Sequence<Row> mergeSequences(Sequence<Sequence<Row>> seqOfSequences, boolean ordered) public Sequence<Row> mergeSequences(Sequence<Sequence<Row>> seqOfSequences)
{ {
if (ordered) { return new OrderedMergeSequence<>(getOrdering(), seqOfSequences);
return new OrderedMergeSequence<>(getOrdering(), seqOfSequences);
} else {
return new MergeSequence<>(getOrdering(), seqOfSequences);
}
} }
private Ordering<Row> getOrdering() @Override
public Sequence<Row> mergeSequencesUnordered(Sequence<Sequence<Row>> seqOfSequences)
{
return new MergeSequence<>(getOrdering(), seqOfSequences);
}
private Ordering<Row> getOrdering()
{ {
return Ordering.<Row>natural().nullsFirst(); return Ordering.<Row>natural().nullsFirst();
} }

View File

@ -144,13 +144,15 @@ public class SegmentMetadataQueryQueryToolChest extends QueryToolChest<SegmentAn
} }
@Override @Override
public Sequence<SegmentAnalysis> mergeSequences(Sequence<Sequence<SegmentAnalysis>> seqOfSequences, boolean ordered) public Sequence<SegmentAnalysis> mergeSequences(Sequence<Sequence<SegmentAnalysis>> seqOfSequences)
{ {
if (ordered) { return new OrderedMergeSequence<>(getOrdering(), seqOfSequences);
return new OrderedMergeSequence<>(getOrdering(), seqOfSequences); }
} else {
return new MergeSequence<>(getOrdering(), seqOfSequences); @Override
} public Sequence<SegmentAnalysis> mergeSequencesUnordered(Sequence<Sequence<SegmentAnalysis>> seqOfSequences)
{
return new MergeSequence<>(getOrdering(), seqOfSequences);
} }
@Override @Override

View File

@ -109,16 +109,15 @@ public class SearchQueryQueryToolChest extends QueryToolChest<Result<SearchResul
} }
@Override @Override
public Sequence<Result<SearchResultValue>> mergeSequences( public Sequence<Result<SearchResultValue>> mergeSequences(Sequence<Sequence<Result<SearchResultValue>>> seqOfSequences)
Sequence<Sequence<Result<SearchResultValue>>> seqOfSequences,
boolean ordered
)
{ {
if (ordered) { return new OrderedMergeSequence<>(getOrdering(), seqOfSequences);
return new OrderedMergeSequence<>(getOrdering(), seqOfSequences); }
} else {
return new MergeSequence<>(getOrdering(), seqOfSequences); @Override
} public Sequence<Result<SearchResultValue>> mergeSequencesUnordered(Sequence<Sequence<Result<SearchResultValue>>> seqOfSequences)
{
return new MergeSequence<>(getOrdering(), seqOfSequences);
} }
@Override @Override

View File

@ -111,16 +111,15 @@ public class SelectQueryQueryToolChest extends QueryToolChest<Result<SelectResul
} }
@Override @Override
public Sequence<Result<SelectResultValue>> mergeSequences( public Sequence<Result<SelectResultValue>> mergeSequences(Sequence<Sequence<Result<SelectResultValue>>> seqOfSequences)
Sequence<Sequence<Result<SelectResultValue>>> seqOfSequences,
boolean ordered
)
{ {
if (ordered) { return new OrderedMergeSequence<>(getOrdering(), seqOfSequences);
return new OrderedMergeSequence<>(getOrdering(), seqOfSequences); }
} else {
return new MergeSequence<>(getOrdering(), seqOfSequences); @Override
} public Sequence<Result<SelectResultValue>> mergeSequencesUnordered(Sequence<Sequence<Result<SelectResultValue>>> seqOfSequences)
{
return new MergeSequence<>(getOrdering(), seqOfSequences);
} }
@Override @Override

View File

@ -109,16 +109,15 @@ public class TimeBoundaryQueryQueryToolChest
} }
@Override @Override
public Sequence<Result<TimeBoundaryResultValue>> mergeSequences( public Sequence<Result<TimeBoundaryResultValue>> mergeSequences(Sequence<Sequence<Result<TimeBoundaryResultValue>>> seqOfSequences)
Sequence<Sequence<Result<TimeBoundaryResultValue>>> seqOfSequences,
boolean ordered
)
{ {
if (ordered) { return new OrderedMergeSequence<>(getOrdering(), seqOfSequences);
return new OrderedMergeSequence<>(getOrdering(), seqOfSequences); }
} else {
return new MergeSequence<>(getOrdering(), seqOfSequences); @Override
} public Sequence<Result<TimeBoundaryResultValue>> mergeSequencesUnordered(Sequence<Sequence<Result<TimeBoundaryResultValue>>> seqOfSequences)
{
return new MergeSequence<>(getOrdering(), seqOfSequences);
} }
@Override @Override

View File

@ -110,16 +110,15 @@ public class TimeseriesQueryQueryToolChest extends QueryToolChest<Result<Timeser
} }
@Override @Override
public Sequence<Result<TimeseriesResultValue>> mergeSequences( public Sequence<Result<TimeseriesResultValue>> mergeSequences(Sequence<Sequence<Result<TimeseriesResultValue>>> seqOfSequences)
Sequence<Sequence<Result<TimeseriesResultValue>>> seqOfSequences,
boolean ordered
)
{ {
if (ordered) { return new OrderedMergeSequence<>(getOrdering(), seqOfSequences);
return new OrderedMergeSequence<>(getOrdering(), seqOfSequences); }
} else {
return new MergeSequence<>(getOrdering(), seqOfSequences); @Override
} public Sequence<Result<TimeseriesResultValue>> mergeSequencesUnordered(Sequence<Sequence<Result<TimeseriesResultValue>>> seqOfSequences)
{
return new MergeSequence<>(getOrdering(), seqOfSequences);
} }
@Override @Override

View File

@ -72,7 +72,6 @@ public class TopNQueryQueryToolChest extends QueryToolChest<Result<TopNResultVal
private static final TypeReference<Object> OBJECT_TYPE_REFERENCE = new TypeReference<Object>() private static final TypeReference<Object> OBJECT_TYPE_REFERENCE = new TypeReference<Object>()
{ {
}; };
private final TopNQueryConfig config; private final TopNQueryConfig config;
@Inject @Inject
@ -126,16 +125,15 @@ public class TopNQueryQueryToolChest extends QueryToolChest<Result<TopNResultVal
} }
@Override @Override
public Sequence<Result<TopNResultValue>> mergeSequences( public Sequence<Result<TopNResultValue>> mergeSequences(Sequence<Sequence<Result<TopNResultValue>>> seqOfSequences)
Sequence<Sequence<Result<TopNResultValue>>> seqOfSequences,
boolean ordered
)
{ {
if (ordered) { return new OrderedMergeSequence<>(getOrdering(), seqOfSequences);
return new OrderedMergeSequence<>(getOrdering(), seqOfSequences); }
} else {
return new MergeSequence<>(getOrdering(), seqOfSequences); @Override
} public Sequence<Result<TopNResultValue>> mergeSequencesUnordered(Sequence<Sequence<Result<TopNResultValue>>> seqOfSequences)
{
return new MergeSequence<>(getOrdering(), seqOfSequences);
} }
@Override @Override

View File

@ -265,7 +265,7 @@ public class CachingClusteredClient<T> implements QueryRunner<T>
Iterables.transform(listOfSequences, Pair.<DateTime, Sequence<T>>rhsFn()) Iterables.transform(listOfSequences, Pair.<DateTime, Sequence<T>>rhsFn())
); );
if (strategy == null) { if (strategy == null) {
return toolChest.mergeSequences(seq, true); return toolChest.mergeSequences(seq);
} else { } else {
return strategy.mergeSequences(seq); return strategy.mergeSequences(seq);
} }
@ -383,8 +383,7 @@ public class CachingClusteredClient<T> implements QueryRunner<T>
); );
} }
} }
), )
true
); );
} }

View File

@ -567,7 +567,13 @@ public class ServerManagerTest
} }
@Override @Override
public Sequence<T> mergeSequences(Sequence<Sequence<T>> seqOfSequences, boolean ordered) public Sequence<T> mergeSequences(Sequence<Sequence<T>> seqOfSequences)
{
return new ConcatSequence<T>(seqOfSequences);
}
@Override
public Sequence<T> mergeSequencesUnordered(Sequence<Sequence<T>> seqOfSequences)
{ {
return new ConcatSequence<T>(seqOfSequences); return new ConcatSequence<T>(seqOfSequences);
} }