pitrou commented on a change in pull request #9742: URL: https://github.com/apache/arrow/pull/9742#discussion_r598572601
########## File path: cpp/src/arrow/engine/exec_plan.h ########## @@ -0,0 +1,131 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include <memory> +#include <string> +#include <vector> + +#include "arrow/compute/type_fwd.h" +#include "arrow/type_fwd.h" +#include "arrow/util/future.h" +#include "arrow/util/macros.h" +#include "arrow/util/mutex.h" +#include "arrow/util/optional.h" +#include "arrow/util/type_fwd.h" +#include "arrow/util/visibility.h" + +namespace arrow { +namespace engine { + +class ExecNode; +class QueryNode; +class QueryPlan; + +class ARROW_EXPORT ExecPlan { + public: + using NodeVector = std::vector<ExecNode*>; + + virtual ~ExecPlan() = default; + + /// The query plan this ExecPlan is an instance of + const QueryPlan& query_plan() const { return *query_plan_; } + + compute::ExecContext* context() { return context_; } + + protected: + friend class QueryPlan; + + ExecPlan() = default; + + const std::shared_ptr<const QueryPlan> query_plan_; + compute::ExecContext* context_; +}; + +class ARROW_EXPORT ExecNode { + public: + using NodeVector = std::vector<ExecNode*>; + + virtual ~ExecNode(); + + /// The query node this ExecNode is an instance of + const QueryNode& query_node() const { return *query_node_; } + + /// This node's exec plan + ExecPlan* plan() { return plan_; } + + /// Transfer input batch to ExecNode + /// + /// When all inputs are received for a given batch_index, the batch is ready + /// for execution. + Status InputReceived(int32_t input_index, int32_t batch_index, + compute::ExecBatch batch); + + /// Mark the inputs finished after the given number of batches. + /// + /// This may be called before all inputs are received. This simply fixes + /// the total number of incoming batches so that the ExecNode knows when + /// it has received all input. + Status InputFinished(int32_t num_batches); Review comment: As the docstring says, this may or may not be called before all inputs are received. But it must be called at some point so that the node knows that input is finished. -- 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: us...@infra.apache.org