pitrou commented on code in PR #13635:
URL: https://github.com/apache/arrow/pull/13635#discussion_r982488320
##########
r/src/compute-exec.cpp:
##########
@@ -91,21 +95,28 @@ class ExecPlanReader : public arrow::RecordBatchReader {
std::shared_ptr<arrow::Schema> schema() const override { return schema_; }
arrow::Status ReadNext(std::shared_ptr<arrow::RecordBatch>* batch_out)
override {
- // TODO(ARROW-11841) check a StopToken to potentially cancel this plan
-
// If this is the first batch getting pulled, tell the exec plan to
// start producing
- if (status_ == PLAN_NOT_STARTED) {
+ if (plan_status_ == PLAN_NOT_STARTED) {
ARROW_RETURN_NOT_OK(StartProducing());
}
// If we've closed the reader, keep sending nullptr
// (consistent with what most RecordBatchReader subclasses do)
- if (status_ == PLAN_FINISHED) {
+ if (plan_status_ == PLAN_FINISHED) {
batch_out->reset();
return arrow::Status::OK();
}
+ // Check for cancellation and stop the plan if we have a request. When
+ // the ExecPlan supports passing a StopToken and handling this itself,
+ // this will be redundant.
+ if (stop_token_.IsStopRequested()) {
+ StopProducing();
+ ARROW_RETURN_NOT_OK(stop_token_.Poll());
+ return arrow::Status::Cancelled("Cancelled");
Review Comment:
```suggestion
return stop_token_.Poll();
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]