Skip to content

Commit

Permalink
Flink: Fix long casting issues
Browse files Browse the repository at this point in the history
Backport of apache#10580 and resolve IDE warning/error wrt `floorMod`/`floorDiv`.
  • Loading branch information
snazy committed Jul 4, 2024
1 parent c7eba34 commit a50f57f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public TimestampData read(TimestampData ignored) {
long value = readLong();
return TimestampData.fromLocalDateTime(
Instant.ofEpochSecond(
Math.floorDiv(value, 1000_000), Math.floorMod(value, 1000_000) * 1000)
Math.floorDiv(value, 1000_000L), Math.floorMod(value, 1000_000L) * 1000L)
.atOffset(ZoneOffset.UTC)
.toLocalDateTime());
}
Expand All @@ -444,7 +444,7 @@ public TimestampData read(TimestampData ignored) {
long value = readLong();
return TimestampData.fromInstant(
Instant.ofEpochSecond(
Math.floorDiv(value, 1000_000), Math.floorMod(value, 1000_000) * 1000));
Math.floorDiv(value, 1000_000L), Math.floorMod(value, 1000_000L) * 1000L));
}

@Override
Expand Down Expand Up @@ -517,7 +517,7 @@ private static class LossyMicrosToMillisTimeReader
@Override
public Integer read(Integer reuse) {
// Discard microseconds since Flink uses millisecond unit for TIME type.
return (int) Math.floorDiv(column.nextLong(), 1000);
return (int) Math.floorDiv(column.nextLong(), 1000L);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected List<IcebergSourceSplit> createSplits(
.mapToObj(
fileNum ->
RandomGenericData.generate(
SCHEMA, 2, splitNum * filesPerSplit + fileNum))
SCHEMA, 2, (long) splitNum * filesPerSplit + fileNum))
.collect(Collectors.toList())))
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public TimestampData read(TimestampData ignored) {
long value = readLong();
return TimestampData.fromLocalDateTime(
Instant.ofEpochSecond(
Math.floorDiv(value, 1000_000), Math.floorMod(value, 1000_000) * 1000)
Math.floorDiv(value, 1000_000L), Math.floorMod(value, 1000_000L) * 1000L)
.atOffset(ZoneOffset.UTC)
.toLocalDateTime());
}
Expand All @@ -444,7 +444,7 @@ public TimestampData read(TimestampData ignored) {
long value = readLong();
return TimestampData.fromInstant(
Instant.ofEpochSecond(
Math.floorDiv(value, 1000_000), Math.floorMod(value, 1000_000) * 1000));
Math.floorDiv(value, 1000_000L), Math.floorMod(value, 1000_000L) * 1000L));
}

@Override
Expand Down Expand Up @@ -517,7 +517,7 @@ private static class LossyMicrosToMillisTimeReader
@Override
public Integer read(Integer reuse) {
// Discard microseconds since Flink uses millisecond unit for TIME type.
return (int) Math.floorDiv(column.nextLong(), 1000);
return (int) Math.floorDiv(column.nextLong(), 1000L);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected List<IcebergSourceSplit> createSplits(
.mapToObj(
fileNum ->
RandomGenericData.generate(
SCHEMA, 2, splitNum * filesPerSplit + fileNum))
SCHEMA, 2, (long) splitNum * filesPerSplit + fileNum))
.collect(Collectors.toList())))
.collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public TimestampData read(TimestampData ignored) {
long value = readLong();
return TimestampData.fromLocalDateTime(
Instant.ofEpochSecond(
Math.floorDiv(value, 1000_000), Math.floorMod(value, 1000_000) * 1000L)
Math.floorDiv(value, 1000_000L), Math.floorMod(value, 1000_000L) * 1000L)
.atOffset(ZoneOffset.UTC)
.toLocalDateTime());
}
Expand All @@ -444,7 +444,7 @@ public TimestampData read(TimestampData ignored) {
long value = readLong();
return TimestampData.fromInstant(
Instant.ofEpochSecond(
Math.floorDiv(value, 1000_000), Math.floorMod(value, 1000_000) * 1000L));
Math.floorDiv(value, 1000_000L), Math.floorMod(value, 1000_000L) * 1000L));
}

@Override
Expand Down Expand Up @@ -517,7 +517,7 @@ private static class LossyMicrosToMillisTimeReader
@Override
public Integer read(Integer reuse) {
// Discard microseconds since Flink uses millisecond unit for TIME type.
return (int) Math.floorDiv(column.nextLong(), 1000);
return (int) Math.floorDiv(column.nextLong(), 1000L);
}
}

Expand Down

0 comments on commit a50f57f

Please sign in to comment.