rdblue commented on code in PR #3610:
URL: https://github.com/apache/parquet-java/pull/3610#discussion_r3562411010
##########
parquet-column/src/test/java/org/apache/parquet/schema/TestPrimitiveComparator.java:
##########
@@ -354,6 +359,60 @@ public void
testBinaryAsSignedIntegerComparatorWithEquals() {
}
}
+ private static Binary int96(int julianDay, long nanosOfDay) {
+ return new NanoTime(julianDay, nanosOfDay).toBinary();
+ }
+
+ private static Binary timestampToInt96(String timestamp) {
+ LocalDateTime dt = LocalDateTime.parse(timestamp);
+ int julianDay = (int) (dt.toLocalDate().toEpochDay() + 2440588);
+ return new NanoTime(julianDay, dt.toLocalTime().toNanoOfDay()).toBinary();
+ }
+
+ @Test
+ public void testInt96TimestampComparator() {
+ Binary[] valuesInAscendingOrder = {
+ int96(Integer.MIN_VALUE, 0), // most negative julian day
+ int96(-1, 86_399_999_999_999L), // negative julian days sort before day 0
+ int96(0, 0), // start of the julian period
+ int96(0, 86_399_999_999_999L), // same day, later time of day
+ timestampToInt96("1968-05-23T00:00:00.000000123"), // pre-epoch but
positive julian day
+ timestampToInt96("2020-01-01T12:00:00"),
+ timestampToInt96("2020-02-01T11:00:00"), // later day even though
earlier time of day
+ timestampToInt96("2020-02-01T11:00:00.000000001"), // nanos tie-break
+ int96(Integer.MAX_VALUE, 86_399_999_999_999L)
+ };
+
+ // The same value in different Binary representations must compare
identically; the offset
+ // variant guards against absolute reads not being relative to the value's
start
+ List<Function<Binary, Binary>> representations = List.of(
+ b -> b,
+ b -> Binary.fromReusedByteArray(b.getBytes()),
Review Comment:
There's no functional difference between reused and constant here. It is
just a way to inform Parquet that the value may be modified (and should be
copied) or not.
I also don't think there is much value in these cases more generally. This
is testing that `Binary#toByteBuffer` does the right thing and that is not the
responsibility of this test to validate.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]