emkornfield commented on code in PR #50916:
URL: https://github.com/apache/arrow/pull/50916#discussion_r3819117910
##########
cpp/src/parquet/statistics.cc:
##########
@@ -463,6 +463,56 @@ struct RebindLogical<Float16LogicalType> {
using c_type = DType::c_type;
};
+// Tag type for FLBA(12) timestamps.
+struct Flba12TimestampType {};
+
+// Max / min representable signed 96-bit two's-complement, little-endian.
+constexpr uint8_t kFlba12SignedMax[12] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F};
+constexpr uint8_t kFlba12SignedMin[12] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x80};
+
+template <>
+struct CompareHelper<Flba12TimestampType, /*is_signed=*/true> {
+ using T = FLBA;
+
+ // Seed for the running minimum is the maximum value; for the maximum, the
minimum
+ // value.
+ static T DefaultMin() { return T{kFlba12SignedMax}; }
+ static T DefaultMax() { return T{kFlba12SignedMin}; }
+
+ static T Coalesce(T val, T fallback) { return val.ptr == nullptr ? fallback
: val; }
+
+ // Signed little-endian comparison.
+ // Differing signs: negative (MSB >= 0x80) is smaller.
+ // Same sign: unsigned scan and comparison.
+ static inline bool Compare(int /*type_length*/, const T& a, const T& b) {
+ const bool a_neg = (a.ptr[11] & 0x80) != 0;
+ const bool b_neg = (b.ptr[11] & 0x80) != 0;
+ if (a_neg != b_neg) return a_neg;
+ for (int i = 11; i >= 0; --i) if (a.ptr[i] != b.ptr[i]) return a.ptr[i] <
b.ptr[i];
Review Comment:
do the two step integer comparison?
--
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]