Copilot commented on code in PR #1703:
URL: https://github.com/apache/fluss/pull/1703#discussion_r2351609331


##########
fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/lake/LakeSplitSerializerTest.java:
##########
@@ -61,14 +63,42 @@ class LakeSplitSerializerTest {
     @Test
     void testSerializeAndDeserializeLakeSnapshotSplit() throws IOException {
         // Prepare test data
+        int splitIndex = 1;
+        LakeSnapshotSplit originalSplit =
+                new LakeSnapshotSplit(tableBucket, "2025-08-18", LAKE_SPLIT, 
splitIndex);
+
+        DataOutputSerializer output = new 
DataOutputSerializer(STOPPING_OFFSET);
+        serializer.serialize(output, originalSplit);
+
+        SourceSplitBase deserializedSplit =
+                serializer.deserialize(
+                        sourceSplitSerializer.getVersion(),
+                        LAKE_SNAPSHOT_SPLIT_KIND,
+                        tableBucket,
+                        "2025-08-18",
+                        new DataInputDeserializer(output.getCopyOfBuffer()));
+
+        assertThat(deserializedSplit instanceof LakeSnapshotSplit).isTrue();
+        LakeSnapshotSplit result = (LakeSnapshotSplit) deserializedSplit;
+
+        assertThat(tableBucket).isEqualTo(result.getTableBucket());
+        assertThat("2025-08-18").isEqualTo(result.getPartitionName());
+        assertThat(LAKE_SPLIT).isEqualTo(result.getLakeSplit());
+        assertThat(splitIndex).isEqualTo(result.getSplitIndex());
+    }
+
+    @Test
+    void testSerializeAndDeserializeLakeSnapshotSplitForVersion0() throws 
IOException {
+        // test back compatibility with verison = 0

Review Comment:
   There's a typo in the comment: 'verison' should be 'version'.
   ```suggestion
           // test back compatibility with version = 0
   ```



##########
fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/lake/LakeSplitSerializerTest.java:
##########
@@ -118,6 +150,42 @@ void 
testSerializeAndDeserializeLakeSnapshotAndFlussLogSplit() throws IOExceptio
         assertThat(result.isLakeSplitFinished()).isEqualTo(true);
     }
 
+    @Test
+    void testSerializeAndDeserializeLakeSnapshotAndFlussLogSplitForVersion0() 
throws IOException {
+        // test back compatibility with verison = 0

Review Comment:
   There's a typo in the comment: 'verison' should be 'version'.
   ```suggestion
           // test back compatibility with version = 0
   ```



##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/lake/LakeSplitSerializer.java:
##########
@@ -86,18 +90,25 @@ public void serialize(DataOutputSerializer out, 
SourceSplitBase split) throws IO
     }
 
     public SourceSplitBase deserialize(
+            int version,
             byte splitKind,
             TableBucket tableBucket,
             @Nullable String partition,
             DataInputDeserializer input)
             throws IOException {
         if (splitKind == LAKE_SNAPSHOT_SPLIT_KIND) {
-            int splitIndex = input.readInt();
+            int splitIndex = -1;
+            if (version > VERSION_0) {
+                splitIndex = input.readInt();
+            }

Review Comment:
   Consider using a more descriptive constant for the default split index value 
instead of the magic number -1. For example, define `private static final int 
DEFAULT_SPLIT_INDEX = -1;` to make the intent clearer.



-- 
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]

Reply via email to