clintropolis commented on a change in pull request #7133: Time Ordering On Scans
URL: https://github.com/apache/incubator-druid/pull/7133#discussion_r269836743
##########
File path:
processing/src/main/java/org/apache/druid/query/scan/ScanQueryRunnerFactory.java
##########
@@ -68,34 +89,229 @@ public ScanQueryRunnerFactory(
)
{
// in single thread and in jetty thread instead of processing thread
- return new QueryRunner<ScanResultValue>()
- {
- @Override
- public Sequence<ScanResultValue> run(
- final QueryPlus<ScanResultValue> queryPlus, final Map<String,
Object> responseContext
- )
- {
- // Note: this variable is effective only when queryContext has a
timeout.
- // See the comment of CTX_TIMEOUT_AT.
- final long timeoutAt = System.currentTimeMillis() +
QueryContexts.getTimeout(queryPlus.getQuery());
- responseContext.put(CTX_TIMEOUT_AT, timeoutAt);
- return Sequences.concat(
+ return (queryPlus, responseContext) -> {
+ ScanQuery query = (ScanQuery) queryPlus.getQuery();
+
+ // Note: this variable is effective only when queryContext has a timeout.
+ // See the comment of CTX_TIMEOUT_AT.
+ final long timeoutAt = System.currentTimeMillis() +
QueryContexts.getTimeout(queryPlus.getQuery());
+ responseContext.put(CTX_TIMEOUT_AT, timeoutAt);
+
+ if (query.getOrder().equals(ScanQuery.Order.NONE)) {
+ // Use normal strategy
+ Sequence<ScanResultValue> returnedRows = Sequences.concat(
Sequences.map(
Sequences.simple(queryRunners),
- new Function<QueryRunner<ScanResultValue>,
Sequence<ScanResultValue>>()
- {
- @Override
- public Sequence<ScanResultValue> apply(final
QueryRunner<ScanResultValue> input)
- {
- return input.run(queryPlus, responseContext);
- }
- }
+ input -> input.run(queryPlus, responseContext)
)
);
+ if (query.getLimit() <= Integer.MAX_VALUE) {
+ return returnedRows.limit(Math.toIntExact(query.getLimit()));
+ } else {
+ return returnedRows;
+ }
+ } else {
+ if (!(query.getQuerySegmentSpec() instanceof
MultipleSpecificSegmentSpec)) {
+ throw new UOE("Time-ordering on scan queries is only supported for
queries with segment specs"
+ + "of type MultipleSpecificSegmentSpec");
+ }
+ List<SegmentDescriptor> descriptorsOrdered =
+ ((MultipleSpecificSegmentSpec)
query.getQuerySegmentSpec()).getDescriptors(); // Ascending time order
Review comment:
nit: this and the following line have nearly the same end of line comments,
suggest consolidating and putting on it's own line before specifying that
ascending order is the default
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]