emkornfield commented on a change in pull request #9504: URL: https://github.com/apache/arrow/pull/9504#discussion_r577359813
########## File path: cpp/src/arrow/record_batch.cc ########## @@ -37,6 +37,26 @@ namespace arrow { +namespace { +// If there will only be one slice returned it is cheaper to just return the original +// RecordBatch (no overhead from vector and std::shared_ptr copying on underlying arrays). + +struct SliceIteratorFunctor { + Result<std::shared_ptr<RecordBatch>> Next() { + if (current_offset < batch->num_rows()) { + std::shared_ptr<RecordBatch> next = batch->Slice(current_offset, slice_size); + current_offset += slice_size; + return next; + } + return IterationTraits<std::shared_ptr<RecordBatch>>::End(); + } + const RecordBatch* const batch; Review comment: yes, it would. The tricky part is we can't get a shared_ptr to record batch if this is a member method. (unless we add enable_shared_from_this). To avoid any contention here for now I've moved this to be an implementation detail. ---------------------------------------------------------------- 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