Copilot commented on code in PR #16075: URL: https://github.com/apache/pinot/pull/16075#discussion_r2140095695
########## pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/MultiStageOperator.java: ########## @@ -72,9 +73,29 @@ public MultiStageOperator(OpChainExecutionContext context) { public abstract void registerExecution(long time, int numRows); - // Samples resource usage of the operator. The operator should call this function for every block of data or - // assuming the block holds 10000 rows or more. + /// This method should be called periodically by the operator to check whether the execution should be interrupted. + /// + /// This could happen when the request deadline is reached, or the thread accountant decides to interrupt the query + /// due to resource constraints. + /// + /// Normally, callers should call [#sampleAndCheckInterruption(long deadlineMs)] passing the correct deadline, but + /// given most operators use either the active or the passive deadline, this method is provided as a convenience + /// method. By default, it uses the active deadline, which is the one that should be used for most operators, but + /// if the operator is not actively waiting for data, it could override this method to use the passive deadline + /// (see for example [MailboxSendOperator][org.apache.pinot.query.runtime.operator.MailboxSendOperator]). protected void sampleAndCheckInterruption() { + sampleAndCheckInterruption(_context.getActiveDeadlineMs()); + } + + /// This method should be called periodically by the operator to check whether the execution should be interrupted. + /// + /// This could happen when the request deadline is reached, or the thread accountant decides to interrupt the query + /// due to resource constraints. + protected void sampleAndCheckInterruption(long deadlineMs) { + if (System.currentTimeMillis() - deadlineMs > 0) { Review Comment: Consider replacing the subtraction check with a more direct comparison (e.g. System.currentTimeMillis() >= deadlineMs) for clarity. ```suggestion if (System.currentTimeMillis() >= deadlineMs) { ``` -- 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. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org