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.
*
* @param seqOfSequences
* @param ordered whether the seqOfSequences is ordered or not.
*
* @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);

View File

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

View File

@ -191,16 +191,18 @@ public class GroupByQueryQueryToolChest extends QueryToolChest<Row, GroupByQuery
@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);
} else {
return new MergeSequence<>(getOrdering(), seqOfSequences);
}
return new OrderedMergeSequence<>(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();
}

View File

@ -144,13 +144,15 @@ public class SegmentMetadataQueryQueryToolChest extends QueryToolChest<SegmentAn
}
@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);
} else {
return new MergeSequence<>(getOrdering(), seqOfSequences);
}
return new OrderedMergeSequence<>(getOrdering(), seqOfSequences);
}
@Override
public Sequence<SegmentAnalysis> mergeSequencesUnordered(Sequence<Sequence<SegmentAnalysis>> seqOfSequences)
{
return new MergeSequence<>(getOrdering(), seqOfSequences);
}
@Override

View File

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

View File

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

View File

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

View File

@ -110,16 +110,15 @@ public class TimeseriesQueryQueryToolChest extends QueryToolChest<Result<Timeser
}
@Override
public Sequence<Result<TimeseriesResultValue>> mergeSequences(
Sequence<Sequence<Result<TimeseriesResultValue>>> seqOfSequences,
boolean ordered
)
public Sequence<Result<TimeseriesResultValue>> mergeSequences(Sequence<Sequence<Result<TimeseriesResultValue>>> seqOfSequences)
{
if (ordered) {
return new OrderedMergeSequence<>(getOrdering(), seqOfSequences);
} else {
return new MergeSequence<>(getOrdering(), seqOfSequences);
}
return new OrderedMergeSequence<>(getOrdering(), seqOfSequences);
}
@Override
public Sequence<Result<TimeseriesResultValue>> mergeSequencesUnordered(Sequence<Sequence<Result<TimeseriesResultValue>>> seqOfSequences)
{
return new MergeSequence<>(getOrdering(), seqOfSequences);
}
@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 final TopNQueryConfig config;
@Inject
@ -126,16 +125,15 @@ public class TopNQueryQueryToolChest extends QueryToolChest<Result<TopNResultVal
}
@Override
public Sequence<Result<TopNResultValue>> mergeSequences(
Sequence<Sequence<Result<TopNResultValue>>> seqOfSequences,
boolean ordered
)
public Sequence<Result<TopNResultValue>> mergeSequences(Sequence<Sequence<Result<TopNResultValue>>> seqOfSequences)
{
if (ordered) {
return new OrderedMergeSequence<>(getOrdering(), seqOfSequences);
} else {
return new MergeSequence<>(getOrdering(), seqOfSequences);
}
return new OrderedMergeSequence<>(getOrdering(), seqOfSequences);
}
@Override
public Sequence<Result<TopNResultValue>> mergeSequencesUnordered(Sequence<Sequence<Result<TopNResultValue>>> seqOfSequences)
{
return new MergeSequence<>(getOrdering(), seqOfSequences);
}
@Override

View File

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