lidavidm commented on code in PR #34060: URL: https://github.com/apache/arrow/pull/34060#discussion_r1099545793
########## cpp/src/arrow/compute/exec/fetch_node.cc: ########## @@ -0,0 +1,207 @@ +// 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. + +#include <sstream> + +#include "arrow/compute/api_vector.h" +#include "arrow/compute/exec.h" +#include "arrow/compute/exec/accumulation_queue.h" +#include "arrow/compute/exec/exec_plan.h" +#include "arrow/compute/exec/expression.h" +#include "arrow/compute/exec/map_node.h" +#include "arrow/compute/exec/options.h" +#include "arrow/compute/exec/query_context.h" +#include "arrow/compute/exec/util.h" +#include "arrow/datum.h" +#include "arrow/result.h" +#include "arrow/util/checked_cast.h" +#include "arrow/util/future.h" +#include "arrow/util/logging.h" +#include "arrow/util/tracing_internal.h" + +namespace arrow { + +using internal::checked_cast; + +namespace compute { +namespace { + +class FetchCounter { + public: + struct Page { + int64_t to_skip; + int64_t to_send; + bool ended; + }; + + FetchCounter(int64_t rows_to_skip, int64_t rows_to_send) + : rows_to_send_(rows_to_send), rows_to_skip_(rows_to_skip) {} + + Page NextPage(const ExecBatch& batch) { + int64_t rows_in_batch_to_skip = 0; + if (rows_to_skip_ > 0) { + rows_in_batch_to_skip = std::min(rows_to_skip_, batch.length); + rows_to_skip_ -= rows_in_batch_to_skip; + } + + int64_t rows_in_batch_to_send = 0; + if (rows_to_send_ > 0) { Review Comment: Ah, indeed. Ok, sounds good. -- 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]
