Skip to content

Commit

Permalink
Fixes for review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
malhotrashivam committed Nov 10, 2023
1 parent a48ea8d commit 9932f33
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
12 changes: 5 additions & 7 deletions engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.time.zone.ZoneRulesException;
import java.util.Date;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -992,7 +993,8 @@ public static long epochNanosUTC(@Nullable final LocalDateTime localDateTime) {
if (localDateTime == null) {
return NULL_LONG;
}
return epochNanos(localDateTime.toInstant(ZoneOffset.UTC));
return TimeUnit.SECONDS.toNanos(localDateTime.toEpochSecond(ZoneOffset.UTC))
+ localDateTime.toLocalTime().getNano();
}

/**
Expand Down Expand Up @@ -1438,9 +1440,7 @@ public static ZonedDateTime excelToZonedDateTime(final double excel, @Nullable f
if (micros == QueryConstants.NULL_LONG) {
return null;
}
final long microsPerSecond = 1_000_000;
return LocalDateTime.ofEpochSecond(micros / microsPerSecond, (int) ((micros % microsPerSecond) * MICRO),
ZoneOffset.UTC);
return epochNanosToLocalDateTimeUTC(micros * MICRO);
}

/**
Expand All @@ -1454,9 +1454,7 @@ public static ZonedDateTime excelToZonedDateTime(final double excel, @Nullable f
if (millis == QueryConstants.NULL_LONG) {
return null;
}
final long millisPerSecond = 1_000;
return LocalDateTime.ofEpochSecond(millis / millisPerSecond, (int) ((millis % millisPerSecond) * MILLI),
ZoneOffset.UTC);
return epochNanosToLocalDateTimeUTC(millis * MILLI);
}

// endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ private static LogicalTypeAnnotation getLogicalTypeAnnotation(final ConvertedTyp
case DATE:
return LogicalTypeAnnotation.dateType();
case TIME_MILLIS:
// isAdjustedToUTC parameter is ignored while reading Parquet TIME type, so assume it whatever
// isAdjustedToUTC parameter is ignored while reading Parquet TIME type, so disregard it here
return LogicalTypeAnnotation.timeType(true, LogicalTypeAnnotation.TimeUnit.MILLIS);
case TIME_MICROS:
return LogicalTypeAnnotation.timeType(true, LogicalTypeAnnotation.TimeUnit.MICROS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import java.nio.LongBuffer;
import java.time.LocalDateTime;

final class LocalDateTimeTransfer
extends GettingPrimitiveTransfer<ObjectChunk<LocalDateTime, Values>, LongBuffer> {
final class LocalDateTimeTransfer extends GettingPrimitiveTransfer<ObjectChunk<LocalDateTime, Values>, LongBuffer> {

LocalDateTimeTransfer(@NotNull final ColumnSource<?> columnSource, @NotNull final RowSequence tableRowSet,
final int targetPageSizeInBytes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,10 @@ public void testArrayColumns() {
"someByteArrayColumn = new byte[] {i % 10 == 0 ? null : (byte)i}",
"someCharArrayColumn = new char[] {i % 10 == 0 ? null : (char)i}",
"someTimeArrayColumn = new Instant[] {i % 10 == 0 ? null : (Instant)DateTimeUtils.now() + i}",
"someBiColumn = new java.math.BigInteger[] {i % 10 == 0 ? null : java.math.BigInteger.valueOf(i)}",
"someDateColumn = new java.time.LocalDate[] {i % 10 == 0 ? null : java.time.LocalDate.ofEpochDay(i)}",
"someTimeColumn = new java.time.LocalTime[] {i % 10 == 0 ? null : java.time.LocalTime.of(i%24, i%60, (i+10)%60)}",
"someDateTimeColumn = new java.time.LocalDateTime[] {i % 10 == 0 ? null : java.time.LocalDateTime.of(2000+i%10, i%12+1, i%30+1, (i+4)%24, (i+5)%60, (i+6)%60, i)}",
"someBiArrayColumn = new java.math.BigInteger[] {i % 10 == 0 ? null : java.math.BigInteger.valueOf(i)}",
"someDateArrayColumn = new java.time.LocalDate[] {i % 10 == 0 ? null : java.time.LocalDate.ofEpochDay(i)}",
"someTimeArrayColumn = new java.time.LocalTime[] {i % 10 == 0 ? null : java.time.LocalTime.of(i%24, i%60, (i+10)%60)}",
"someDateTimeArrayColumn = new java.time.LocalDateTime[] {i % 10 == 0 ? null : java.time.LocalDateTime.of(2000+i%10, i%12+1, i%30+1, (i+4)%24, (i+5)%60, (i+6)%60, i)}",
"nullStringArrayColumn = new String[] {(String)null}",
"nullIntArrayColumn = new int[] {(int)null}",
"nullLongArrayColumn = new long[] {(long)null}",
Expand Down

0 comments on commit 9932f33

Please sign in to comment.