From 81a8a84e6cf0495b748f41ebd4ada77ca3807422 Mon Sep 17 00:00:00 2001 From: auden-woolfson Date: Fri, 13 Dec 2024 14:21:01 -0800 Subject: [PATCH] add conversion in reader --- .../presto/orc/reader/LongDirectBatchStreamReader.java | 8 ++++---- .../com/facebook/presto/orc/writer/LongColumnWriter.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDirectBatchStreamReader.java b/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDirectBatchStreamReader.java index ea3110c0e0496..942adc0b68d6b 100644 --- a/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDirectBatchStreamReader.java +++ b/presto-orc/src/main/java/com/facebook/presto/orc/reader/LongDirectBatchStreamReader.java @@ -92,7 +92,7 @@ public LongDirectBatchStreamReader(Type type, StreamDescriptor streamDescriptor, this.streamDescriptor = requireNonNull(streamDescriptor, "stream is null"); this.systemMemoryContext = requireNonNull(systemMemoryContext, "systemMemoryContext is null"); if (this.type instanceof TimeType) { - this.convertUnits = longValue -> longValue / 1000; + this.convertUnits = longValue -> Math.floorDiv(longValue, 1000L); } else { this.convertUnits = longValue -> longValue; @@ -170,10 +170,10 @@ private Block readNonNullBlock() if (type instanceof TimeType) { long[] values = new long[nextBatchSize]; dataStream.next(values, nextBatchSize); - LongArrayBlock result = new LongArrayBlock(nextBatchSize, Optional.empty(), values); - for (int i = 0; i < result.getPositionCount(); i++) { - // unit conversion? + for (int i = 0; i < values.length; i++) { + values[i] = convertUnits.apply(values[i]); } + return new LongArrayBlock(nextBatchSize, Optional.empty(), values); } if (type instanceof IntegerType || type instanceof DateType) { int[] values = new int[nextBatchSize]; diff --git a/presto-orc/src/main/java/com/facebook/presto/orc/writer/LongColumnWriter.java b/presto-orc/src/main/java/com/facebook/presto/orc/writer/LongColumnWriter.java index 45a8396c3d2c2..298e62de4060d 100644 --- a/presto-orc/src/main/java/com/facebook/presto/orc/writer/LongColumnWriter.java +++ b/presto-orc/src/main/java/com/facebook/presto/orc/writer/LongColumnWriter.java @@ -116,7 +116,7 @@ public LongColumnWriter( this.statisticsBuilder = statisticsBuilderSupplier.get(); if (this.type instanceof TimeType) { - this.convertUnits = longValue -> longValue * 1000; + this.convertUnits = longValue -> Math.multiplyExact(longValue, 1000L); } else { this.convertUnits = longValue -> longValue;