stevenzwu commented on code in PR #7978:
URL: https://github.com/apache/iceberg/pull/7978#discussion_r1256860948
##########
flink/v1.17/flink/src/main/java/org/apache/iceberg/flink/source/split/IcebergSourceSplit.java:
##########
@@ -120,4 +131,56 @@ static IcebergSourceSplit deserializeV1(byte[] serialized)
throws IOException {
throw new RuntimeException("Failed to deserialize the split.", e);
}
}
+
+ byte[] serializeV2() throws IOException {
+ if (serializedBytesCache == null) {
+ DataOutputSerializer out = SERIALIZER_CACHE.get();
+ Collection<FileScanTask> fileScanTasks = task.tasks();
+ Preconditions.checkArgument(
+ fileOffset >= 0 && fileOffset < fileScanTasks.size(),
+ "Invalid file offset: %s. Should within the range of [0, %s)",
+ fileOffset,
+ fileScanTasks.size());
+
+ out.writeInt(fileOffset);
+ out.writeLong(recordOffset);
+ out.writeInt(fileScanTasks.size());
+
+ Iterator<FileScanTask> iter = fileScanTasks.iterator();
+ int writtenTasks = 0;
+ while (iter.hasNext()) {
+ String taskJson = FileScanTaskParser.toJson(iter.next());
+ out.writeUTF(taskJson);
+ writtenTasks += 1;
+ }
+
+ Preconditions.checkArgument(
+ writtenTasks == fileScanTasks.size(),
+ "Invalid combined scan task: collection size = %s, iterator size =
%s",
Review Comment:
totally agree. removed this unnecessary check and simplified the loop.
--
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]