You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/07/13 17:57:22 UTC

[GitHub] [arrow-datafusion] alamb opened a new pull request, #6960: Minor: remove duplication in Min/Max accumulator

alamb opened a new pull request, #6960:
URL: https://github.com/apache/arrow-datafusion/pull/6960

   # Which issue does this PR close?
   
   related to 
   # Rationale for this change
   
   While working on https://github.com/apache/arrow-datafusion/pull/6957 to provide a default starting value, I realized this could be used to consolidate the Min/Max accumulator implementation as well to avoid duplication
   
   # What changes are included in this PR?
   Change min/max to use the standard `PrimitiveGroupsAccumulator` rather than implementing itself
   
   # Are these changes tested?
   Existing coverage
   
   # Are there any user-facing changes?
   No, this is just less code


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #6960: Minor: remove duplication in Min/Max accumulator

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #6960:
URL: https://github.com/apache/arrow-datafusion/pull/6960#discussion_r1262896100


##########
datafusion/physical-expr/src/aggregate/min_max.rs:
##########
@@ -99,13 +95,46 @@ impl Max {
         }
     }
 }
+/// Creates a [`PrimitiveGroupsAccumulator`] for computing `MAX`
+/// the specified [`ArrowPrimitiveType`].
+///
+/// [`ArrowPrimitiveType`]: arrow::datatypes::ArrowPrimitiveType
+macro_rules! instantiate_max_accumulator {
+    ($SELF:expr, $NATIVE:ident, $PRIMTYPE:ident) => {{
+        Ok(Box::new(
+            PrimitiveGroupsAccumulator::<$PRIMTYPE, _>::new(
+                &$SELF.data_type,
+                |cur, new| {
+                    if *cur < new {
+                        *cur = new
+                    }
+                },
+            )
+            // Initialize each accumulator to $NATIVE::MIN
+            .with_starting_value($NATIVE::MIN),

Review Comment:
   Min/max need to start with some value other than zero



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on pull request #6960: Minor: remove duplication in Min/Max accumulator

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #6960:
URL: https://github.com/apache/arrow-datafusion/pull/6960#issuecomment-1634669108

   FYI @Dandandan 


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb merged pull request #6960: Minor: remove duplication in Min/Max accumulator

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #6960:
URL: https://github.com/apache/arrow-datafusion/pull/6960


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org