zanmato1984 commented on code in PR #45789:
URL: https://github.com/apache/arrow/pull/45789#discussion_r2002519487


##########
cpp/src/arrow/acero/scalar_aggregate_node.cc:
##########
@@ -240,8 +240,8 @@ Status ScalarAggregateNode::InputReceived(ExecNode* input, 
ExecBatch batch) {
     // We add segment to the current segment group aggregation
     auto exec_batch = full_batch.Slice(segment.offset, segment.length);
     RETURN_NOT_OK(DoConsume(ExecSpan(exec_batch), thread_index));
-    RETURN_NOT_OK(
-        ExtractSegmenterValues(&segmenter_values_, exec_batch, 
segment_field_ids_));
+    RETURN_NOT_OK(ExtractSegmenterValues(&GetLocalState()->segmenter_values, 
exec_batch,
+                                         segment_field_ids_));

Review Comment:
   > `OutputResult` seems non-thread safe, 
   
   True.
   
   > how can `InputReceived` be called from several threads at once?
   
   `InputReceived` can't be parallel if there exists any segment keys [1]. So 
if `InputReceived` is parallel, then the segmenter will be `NoKeysSegmenter` 
which only generates "open and extending" segments, which in turn never 
triggers `OutputResult`.
   
   [1] 
https://github.com/apache/arrow/blob/fc0862a25fa2d6aa17df14daa9ad37430d432425/cpp/src/arrow/acero/scalar_aggregate_node.cc#L178-L180



-- 
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]

Reply via email to