rtpsw commented on code in PR #14352:
URL: https://github.com/apache/arrow/pull/14352#discussion_r1027309741
##########
cpp/src/arrow/compute/exec/aggregate_node.cc:
##########
@@ -60,17 +101,47 @@ void AggregatesToString(std::stringstream* ss, const
Schema& input_schema,
*ss << ']';
}
+ExecBatch SelectBatchValues(const ExecBatch& batch, const std::vector<int>&
ids) {
+ std::vector<Datum> values(ids.size());
+ for (size_t i = 0; i < ids.size(); i++) {
+ values[i] = batch.values[ids[i]];
+ }
+ return ExecBatch(std::move(values), batch.length);
+}
Review Comment:
Done.
##########
cpp/src/arrow/compute/exec/aggregate_node.cc:
##########
@@ -60,17 +101,47 @@ void AggregatesToString(std::stringstream* ss, const
Schema& input_schema,
*ss << ']';
}
+ExecBatch SelectBatchValues(const ExecBatch& batch, const std::vector<int>&
ids) {
+ std::vector<Datum> values(ids.size());
+ for (size_t i = 0; i < ids.size(); i++) {
+ values[i] = batch.values[ids[i]];
+ }
+ return ExecBatch(std::move(values), batch.length);
+}
+
+template <typename BatchHandler>
+Status HandleSegments(std::unique_ptr<GroupingSegmenter>& segmenter,
+ const ExecBatch& batch, const std::vector<int>& ids,
+ const BatchHandler& handle_batch) {
+ int64_t offset = 0;
+ ARROW_RETURN_NOT_OK(segmenter->Reset());
+ auto segment_batch = SelectBatchValues(batch, ids);
+ do {
+ ARROW_ASSIGN_OR_RAISE(auto segment,
segmenter->GetNextSegment(segment_batch, offset));
+ if (segment.offset >= segment_batch.length) break;
+ auto batch_slice = batch.Slice(segment.offset, segment.length);
+ ARROW_RETURN_NOT_OK(handle_batch(ExecSpan(batch_slice), segment.is_open));
+ offset = segment.offset + segment.length;
+ } while (true);
Review Comment:
Fixed.
--
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]