jon-wei commented on a change in pull request #7133: 6088 - Time Ordering On
Scans
URL: https://github.com/apache/incubator-druid/pull/7133#discussion_r263640043
##########
File path:
processing/src/main/java/org/apache/druid/query/scan/ScanQueryRunnerFactory.java
##########
@@ -68,34 +81,121 @@ 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 (queryPlus, responseContext) -> {
+ ScanQuery query = (ScanQuery) queryPlus.getQuery();
+ int numSegments = 0;
+ final Iterator<QueryRunner<ScanResultValue>> segmentIt =
queryRunners.iterator();
+ for (; segmentIt.hasNext(); numSegments++) {
+ segmentIt.next();
+ }
+ // 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.getTimeOrder().equals(ScanQuery.TimeOrder.NONE)) {
+ // Use normal strategy
return 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)
)
);
+ } else if (query.getLimit() <=
scanQueryConfig.getMaxRowsQueuedForTimeOrdering()) {
Review comment:
The docs will need some adjustment since it suggests that time ordering will
only work when both the row limit and segment limit are met, but the N-way
merge is really used when the row limit is exceeded but the segment limit is met
----------------------------------------------------------------
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]