From 2528a5614267c48714abdb30fd7a2ccdb61b802d Mon Sep 17 00:00:00 2001 From: Justin Borromeo Date: Mon, 18 Mar 2019 14:00:50 -0700 Subject: [PATCH] Renaming --- .../druid/benchmark/query/ScanBenchmark.java | 10 +++++----- docs/content/querying/scan-query.md | 2 +- .../main/java/org/apache/druid/query/Druids.java | 12 ++++++------ .../org/apache/druid/query/scan/ScanQuery.java | 14 +++++++------- .../apache/druid/query/scan/ScanQueryEngine.java | 8 ++++---- .../query/scan/ScanQueryLimitRowIterator.java | 2 +- .../druid/query/scan/ScanQueryRunnerFactory.java | 2 +- .../scan/ScanResultValueTimestampComparator.java | 2 +- .../scan/ScanQueryLimitRowIteratorTest.java | 6 +++--- .../query/scan/ScanQueryRunnerFactoryTest.java | 16 ++++++++-------- .../druid/query/scan/ScanQueryRunnerTest.java | 8 ++++---- .../druid/query/scan/ScanQuerySpecTest.java | 2 +- .../ScanResultValueTimestampComparatorTest.java | 8 ++++---- 13 files changed, 46 insertions(+), 46 deletions(-) diff --git a/benchmarks/src/main/java/org/apache/druid/benchmark/query/ScanBenchmark.java b/benchmarks/src/main/java/org/apache/druid/benchmark/query/ScanBenchmark.java index 6b250af2120..f5eeba3c766 100644 --- a/benchmarks/src/main/java/org/apache/druid/benchmark/query/ScanBenchmark.java +++ b/benchmarks/src/main/java/org/apache/druid/benchmark/query/ScanBenchmark.java @@ -114,7 +114,7 @@ public class ScanBenchmark private int limit; @Param({"NONE", "DESCENDING", "ASCENDING"}) - private static ScanQuery.TimeOrder timeOrdering; + private static ScanQuery.Order ordering; private static final Logger log = new Logger(ScanBenchmark.class); private static final ObjectMapper JSON_MAPPER; @@ -182,7 +182,7 @@ public class ScanBenchmark return Druids.newScanQueryBuilder() .dataSource("blah") .intervals(intervalSpec) - .timeOrder(timeOrdering); + .timeOrder(ordering); } private static Druids.ScanQueryBuilder basicB(final BenchmarkSchemaInfo basicSchema) @@ -203,7 +203,7 @@ public class ScanBenchmark .filters(filter) .dataSource("blah") .intervals(intervalSpec) - .timeOrder(timeOrdering); + .timeOrder(ordering); } private static Druids.ScanQueryBuilder basicC(final BenchmarkSchemaInfo basicSchema) @@ -216,7 +216,7 @@ public class ScanBenchmark .filters(new SelectorDimFilter(dimName, "3", StrlenExtractionFn.instance())) .intervals(intervalSpec) .dataSource("blah") - .timeOrder(timeOrdering); + .timeOrder(ordering); } private static Druids.ScanQueryBuilder basicD(final BenchmarkSchemaInfo basicSchema) @@ -231,7 +231,7 @@ public class ScanBenchmark .filters(new BoundDimFilter(dimName, "100", "10000", true, true, true, null, null)) .intervals(intervalSpec) .dataSource("blah") - .timeOrder(timeOrdering); + .timeOrder(ordering); } @Setup diff --git a/docs/content/querying/scan-query.md b/docs/content/querying/scan-query.md index c747dcb7bb6..0ad7bf16762 100644 --- a/docs/content/querying/scan-query.md +++ b/docs/content/querying/scan-query.md @@ -61,7 +61,7 @@ The following are the main parameters for Scan queries: |columns|A String array of dimensions and metrics to scan. If left empty, all dimensions and metrics are returned.|no| |batchSize|How many rows buffered before return to client. Default is `20480`|no| |limit|How many rows to return. If not specified, all rows will be returned.|no| -|timeOrder|The ordering of returned rows based on timestamp. "ascending", "descending", and "none" (default) are supported. Currently, "ascending" and "descending" are only supported for queries where the limit is less than `druid.query.scan.maxRowsTimeOrderedInMemory`. Scan queries that are either legacy mode or have a limit greater than `druid.query.scan.maxRowsTimeOrderedInMemory` will not be time-ordered and default to a timeOrder of "none".|none| +|order|The ordering of returned rows based on timestamp. "ascending", "descending", and "none" (default) are supported. Currently, "ascending" and "descending" are only supported for queries where the limit is less than `druid.query.scan.maxRowsTimeOrderedInMemory`. Scan queries that are either legacy mode or have a limit greater than `druid.query.scan.maxRowsTimeOrderedInMemory` will not be time-ordered and default to a order of "none".|none| |legacy|Return results consistent with the legacy "scan-query" contrib extension. Defaults to the value set by `druid.query.scan.legacy`, which in turn defaults to false. See [Legacy mode](#legacy-mode) for details.|no| |context|An additional JSON Object which can be used to specify certain flags.|no| diff --git a/processing/src/main/java/org/apache/druid/query/Druids.java b/processing/src/main/java/org/apache/druid/query/Druids.java index a0d85cbb5f9..22d1e93b5a1 100644 --- a/processing/src/main/java/org/apache/druid/query/Druids.java +++ b/processing/src/main/java/org/apache/druid/query/Druids.java @@ -924,7 +924,7 @@ public class Druids private DimFilter dimFilter; private List columns; private Boolean legacy; - private ScanQuery.TimeOrder timeOrder; + private ScanQuery.Order order; public ScanQueryBuilder() { @@ -938,7 +938,7 @@ public class Druids dimFilter = null; columns = new ArrayList<>(); legacy = null; - timeOrder = null; + order = null; } public ScanQuery build() @@ -950,7 +950,7 @@ public class Druids resultFormat, batchSize, limit, - timeOrder, + order, dimFilter, columns, legacy, @@ -971,7 +971,7 @@ public class Druids .columns(query.getColumns()) .legacy(query.isLegacy()) .context(query.getContext()) - .timeOrder(query.getTimeOrder()); + .timeOrder(query.getOrder()); } public ScanQueryBuilder dataSource(String ds) @@ -1051,9 +1051,9 @@ public class Druids return this; } - public ScanQueryBuilder timeOrder(ScanQuery.TimeOrder timeOrder) + public ScanQueryBuilder timeOrder(ScanQuery.Order order) { - this.timeOrder = timeOrder; + this.order = order; return this; } } diff --git a/processing/src/main/java/org/apache/druid/query/scan/ScanQuery.java b/processing/src/main/java/org/apache/druid/query/scan/ScanQuery.java index 223776d8c26..fb5da14be3a 100644 --- a/processing/src/main/java/org/apache/druid/query/scan/ScanQuery.java +++ b/processing/src/main/java/org/apache/druid/query/scan/ScanQuery.java @@ -78,7 +78,7 @@ public class ScanQuery extends BaseQuery } } - public enum TimeOrder + public enum Order { ASCENDING, DESCENDING, @@ -92,7 +92,7 @@ public class ScanQuery extends BaseQuery } @JsonCreator - public static TimeOrder fromString(String name) + public static Order fromString(String name) { return valueOf(StringUtils.toUpperCase(name)); } @@ -111,7 +111,7 @@ public class ScanQuery extends BaseQuery private final DimFilter dimFilter; private final List columns; private final Boolean legacy; - private final TimeOrder timeOrder; + private final Order order; @JsonCreator public ScanQuery( @@ -121,7 +121,7 @@ public class ScanQuery extends BaseQuery @JsonProperty("resultFormat") ResultFormat resultFormat, @JsonProperty("batchSize") int batchSize, @JsonProperty("limit") long limit, - @JsonProperty("timeOrder") TimeOrder timeOrder, + @JsonProperty("order") Order order, @JsonProperty("filter") DimFilter dimFilter, @JsonProperty("columns") List columns, @JsonProperty("legacy") Boolean legacy, @@ -138,7 +138,7 @@ public class ScanQuery extends BaseQuery this.dimFilter = dimFilter; this.columns = columns; this.legacy = legacy; - this.timeOrder = timeOrder == null ? TimeOrder.NONE : timeOrder; + this.order = order == null ? Order.NONE : order; } @JsonProperty @@ -166,9 +166,9 @@ public class ScanQuery extends BaseQuery } @JsonProperty - public TimeOrder getTimeOrder() + public Order getOrder() { - return timeOrder; + return order; } @Override diff --git a/processing/src/main/java/org/apache/druid/query/scan/ScanQueryEngine.java b/processing/src/main/java/org/apache/druid/query/scan/ScanQueryEngine.java index 93482694100..ad38c87e328 100644 --- a/processing/src/main/java/org/apache/druid/query/scan/ScanQueryEngine.java +++ b/processing/src/main/java/org/apache/druid/query/scan/ScanQueryEngine.java @@ -68,7 +68,7 @@ public class ScanQueryEngine if (responseContext.get(ScanQueryRunnerFactory.CTX_COUNT) != null) { long count = (long) responseContext.get(ScanQueryRunnerFactory.CTX_COUNT); - if (count >= query.getLimit() && query.getTimeOrder().equals(ScanQuery.TimeOrder.NONE)) { + if (count >= query.getLimit() && query.getOrder().equals(ScanQuery.Order.NONE)) { return Sequences.empty(); } } @@ -131,8 +131,8 @@ public class ScanQueryEngine intervals.get(0), query.getVirtualColumns(), Granularities.ALL, - query.getTimeOrder().equals(ScanQuery.TimeOrder.DESCENDING) || - (query.getTimeOrder().equals(ScanQuery.TimeOrder.NONE) && query.isDescending()), + query.getOrder().equals(ScanQuery.Order.DESCENDING) || + (query.getOrder().equals(ScanQuery.Order.NONE) && query.isDescending()), null ) .map(cursor -> new BaseSequence<>( @@ -264,7 +264,7 @@ public class ScanQueryEngine */ private long calculateLimit(ScanQuery query, Map responseContext) { - if (query.getTimeOrder().equals(ScanQuery.TimeOrder.NONE)) { + if (query.getOrder().equals(ScanQuery.Order.NONE)) { return query.getLimit() - (long) responseContext.get(ScanQueryRunnerFactory.CTX_COUNT); } return query.getLimit(); diff --git a/processing/src/main/java/org/apache/druid/query/scan/ScanQueryLimitRowIterator.java b/processing/src/main/java/org/apache/druid/query/scan/ScanQueryLimitRowIterator.java index ab24c2af878..4ec29f5208a 100644 --- a/processing/src/main/java/org/apache/druid/query/scan/ScanQueryLimitRowIterator.java +++ b/processing/src/main/java/org/apache/druid/query/scan/ScanQueryLimitRowIterator.java @@ -98,7 +98,7 @@ public class ScanQueryLimitRowIterator implements CloseableIterator timeOrder = ImmutableList.of( - ScanQuery.TimeOrder.ASCENDING, - ScanQuery.TimeOrder.DESCENDING + List order = ImmutableList.of( + ScanQuery.Order.ASCENDING, + ScanQuery.Order.DESCENDING ); return QueryRunnerTestHelper.cartesian( @@ -91,7 +91,7 @@ public class ScanQueryRunnerFactoryTest batchSizes, limits, resultFormats, - timeOrder + order ); } @@ -112,7 +112,7 @@ public class ScanQueryRunnerFactoryTest } else if (o1 < o2) { retVal = -1; } - if (query.getTimeOrder().equals(ScanQuery.TimeOrder.DESCENDING)) { + if (query.getOrder().equals(ScanQuery.Order.DESCENDING)) { return retVal * -1; } return retVal; @@ -138,7 +138,7 @@ public class ScanQueryRunnerFactoryTest // check ordering is correct for (int i = 1; i < output.size(); i++) { - if (query.getTimeOrder().equals(ScanQuery.TimeOrder.DESCENDING)) { + if (query.getOrder().equals(ScanQuery.Order.DESCENDING)) { Assert.assertTrue(output.get(i).getFirstEventTimestamp(resultFormat) < output.get(i - 1).getFirstEventTimestamp(resultFormat)); } else { diff --git a/processing/src/test/java/org/apache/druid/query/scan/ScanQueryRunnerTest.java b/processing/src/test/java/org/apache/druid/query/scan/ScanQueryRunnerTest.java index 6d9834bc83d..9d1e2adaea5 100644 --- a/processing/src/test/java/org/apache/druid/query/scan/ScanQueryRunnerTest.java +++ b/processing/src/test/java/org/apache/druid/query/scan/ScanQueryRunnerTest.java @@ -526,7 +526,7 @@ public class ScanQueryRunnerTest .filters(new SelectorDimFilter(QueryRunnerTestHelper.marketDimension, "spot", null)) .columns(QueryRunnerTestHelper.qualityDimension, QueryRunnerTestHelper.indexMetric) .limit(limit) - .timeOrder(ScanQuery.TimeOrder.ASCENDING) + .timeOrder(ScanQuery.Order.ASCENDING) .context(ImmutableMap.of(ScanQuery.CTX_KEY_OUTERMOST, false)) .build(); @@ -585,7 +585,7 @@ public class ScanQueryRunnerTest .filters(new SelectorDimFilter(QueryRunnerTestHelper.marketDimension, "spot", null)) .columns(QueryRunnerTestHelper.qualityDimension, QueryRunnerTestHelper.indexMetric) .limit(limit) - .timeOrder(ScanQuery.TimeOrder.DESCENDING) + .timeOrder(ScanQuery.Order.DESCENDING) .build(); HashMap context = new HashMap<>(); @@ -668,7 +668,7 @@ public class ScanQueryRunnerTest .filters(new SelectorDimFilter(QueryRunnerTestHelper.marketDimension, "spot", null)) .columns(QueryRunnerTestHelper.qualityDimension, QueryRunnerTestHelper.indexMetric) .resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST) - .timeOrder(ScanQuery.TimeOrder.ASCENDING) + .timeOrder(ScanQuery.Order.ASCENDING) .limit(limit) .build(); @@ -729,7 +729,7 @@ public class ScanQueryRunnerTest .filters(new SelectorDimFilter(QueryRunnerTestHelper.marketDimension, "spot", null)) .columns(QueryRunnerTestHelper.qualityDimension, QueryRunnerTestHelper.indexMetric) .resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST) - .timeOrder(ScanQuery.TimeOrder.DESCENDING) + .timeOrder(ScanQuery.Order.DESCENDING) .context(ImmutableMap.of(ScanQuery.CTX_KEY_OUTERMOST, false)) .limit(limit) .build(); diff --git a/processing/src/test/java/org/apache/druid/query/scan/ScanQuerySpecTest.java b/processing/src/test/java/org/apache/druid/query/scan/ScanQuerySpecTest.java index b4cf5631c48..5d7e80c6042 100644 --- a/processing/src/test/java/org/apache/druid/query/scan/ScanQuerySpecTest.java +++ b/processing/src/test/java/org/apache/druid/query/scan/ScanQuerySpecTest.java @@ -68,7 +68,7 @@ public class ScanQuerySpecTest ScanQuery.ResultFormat.RESULT_FORMAT_LIST, 0, 3, - ScanQuery.TimeOrder.NONE, + ScanQuery.Order.NONE, null, Arrays.asList("market", "quality", "index"), null, diff --git a/processing/src/test/java/org/apache/druid/query/scan/ScanResultValueTimestampComparatorTest.java b/processing/src/test/java/org/apache/druid/query/scan/ScanResultValueTimestampComparatorTest.java index 293462217f2..ea1b3676912 100644 --- a/processing/src/test/java/org/apache/druid/query/scan/ScanResultValueTimestampComparatorTest.java +++ b/processing/src/test/java/org/apache/druid/query/scan/ScanResultValueTimestampComparatorTest.java @@ -52,7 +52,7 @@ public class ScanResultValueTimestampComparatorTest public void comparisonDescendingListTest() { ScanQuery query = Druids.newScanQueryBuilder() - .timeOrder(ScanQuery.TimeOrder.DESCENDING) + .timeOrder(ScanQuery.Order.DESCENDING) .resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_LIST) .dataSource("some src") .intervals(intervalSpec) @@ -89,7 +89,7 @@ public class ScanResultValueTimestampComparatorTest public void comparisonAscendingListTest() { ScanQuery query = Druids.newScanQueryBuilder() - .timeOrder(ScanQuery.TimeOrder.ASCENDING) + .timeOrder(ScanQuery.Order.ASCENDING) .resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_LIST) .dataSource("some src") .intervals(intervalSpec) @@ -126,7 +126,7 @@ public class ScanResultValueTimestampComparatorTest public void comparisonDescendingCompactedListTest() { ScanQuery query = Druids.newScanQueryBuilder() - .timeOrder(ScanQuery.TimeOrder.DESCENDING) + .timeOrder(ScanQuery.Order.DESCENDING) .resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST) .dataSource("some src") .intervals(intervalSpec) @@ -161,7 +161,7 @@ public class ScanResultValueTimestampComparatorTest public void comparisonAscendingCompactedListTest() { ScanQuery query = Druids.newScanQueryBuilder() - .timeOrder(ScanQuery.TimeOrder.ASCENDING) + .timeOrder(ScanQuery.Order.ASCENDING) .resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST) .dataSource("some src") .intervals(intervalSpec)