andishgar commented on code in PR #46422:
URL: https://github.com/apache/arrow/pull/46422#discussion_r2121518987


##########
cpp/src/arrow/array/statistics.cc:
##########
@@ -15,7 +15,66 @@
 // specific language governing permissions and limitations
 // under the License.
 
-// This empty .cc file is for embedding not inlined symbols in
-// arrow::ArrayStatistics into libarrow.
-
 #include "arrow/array/statistics.h"
+
+#include <cmath>
+#include <type_traits>
+
+#include "arrow/compare.h"
+#include "arrow/util/logging_internal.h"
+namespace arrow {
+
+namespace {
+
+using ValueType = ArrayStatistics::ValueType;
+
+bool DoubleEquals(const double& left, const double& right, const EqualOptions& 
options) {
+  if (left == right) {
+    return options.signed_zeros_equal() || (std::signbit(left) == 
std::signbit(right));
+  } else if (options.nans_equal() && (std::isnan(left) || std::isnan(right))) {
+    return std::isnan(left) && std::isnan(right);
+  } else if (options.use_atol()) {
+    return std::fabs(left - right) <= options.atol();
+  } else {
+    return false;
+  }
+}

Review Comment:
   @kou
   Two possible solutions come to mind:
   
   1-Declare the ArrayStatisticsEquals function in arrow/compare.h and 
implement it in arrow/compare.cc. This allows reuse of the floating-point 
comparison utilities available in the anonymous namespace, similar to the 
approach in this 
[patch](https://github.com/user-attachments/files/20554467/8bd364.zip) (Note: 
this is just an approximate solution that passes the current test cases.)
   
   2-Convert the double values to DoubleScalar and use Scalar::{Equals, 
Approximate} methods.
   
   Which approach do you prefer?
   



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