Skip to content

Commit

Permalink
add conversion in reader
Browse files Browse the repository at this point in the history
  • Loading branch information
auden-woolfson committed Dec 13, 2024
1 parent 751049a commit 81a8a84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 81a8a84

Please sign in to comment.