Poorvankbhatia commented on code in PR #6:
URL: 
https://github.com/apache/flink-connector-redis-streams/pull/6#discussion_r3159850044


##########
flink-connector-redis-streams/src/main/java/org/apache/flink/connector/redis/streams/source/enumerator/RedisStreamsSourceEnumeratorStateSerializer.java:
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.redis.streams.source.enumerator;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.core.io.SimpleVersionedSerializer;
+import org.apache.flink.core.memory.DataInputDeserializer;
+import org.apache.flink.core.memory.DataOutputSerializer;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Binary serializer for {@link RedisStreamsSourceEnumeratorState}. v1: 
pending +
+ * discoveredStreamKeys (legacy, dropped). v2: pending only. v3: pending + 
stoppingEntryIds.
+ */
+@Internal
+public class RedisStreamsSourceEnumeratorStateSerializer
+        implements 
SimpleVersionedSerializer<RedisStreamsSourceEnumeratorState> {
+
+    public static final RedisStreamsSourceEnumeratorStateSerializer INSTANCE =
+            new RedisStreamsSourceEnumeratorStateSerializer();
+
+    public static final int CURRENT_VERSION = 3;
+
+    private static final int SERIALIZER_INITIAL_CAPACITY = 128;
+
+    private RedisStreamsSourceEnumeratorStateSerializer() {}
+
+    @Override
+    public int getVersion() {
+        return CURRENT_VERSION;
+    }
+
+    @Override
+    public byte[] serialize(RedisStreamsSourceEnumeratorState state) throws 
IOException {
+        DataOutputSerializer out = new 
DataOutputSerializer(SERIALIZER_INITIAL_CAPACITY);
+        Set<String> pendingSplits = state.getPendingSplits();
+        out.writeInt(pendingSplits.size());
+        for (String split : pendingSplits) {
+            out.writeUTF(split);

Review Comment:
   Today, this writes raw streamKey strings (out.writeUTF(split)). If we adopt 
the Set<RedisStreamsSourceSplit> shape for State, this serializer can delegate 
to RedisStreamsSourceSplitSerializer 
   instead. So now, when Split's wire format changes (new field, anything 
else), this serializer doesn't need a version bump because it just records      
   SplitSerializer's embedded version.



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