Zakelly commented on code in PR #26364:
URL: https://github.com/apache/flink/pull/26364#discussion_r2022324270
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/ForStKeyedStateBackend.java:
##########
@@ -405,10 +424,11 @@ public <N, S extends InternalKeyedState, SV> S
createStateInternal(
return Tuple2.of(newStateInfo.columnFamilyHandle, newMetaInfo);
}
- private <N, SV> RegisteredKeyValueStateBackendMetaInfo<N, SV>
updateRestoredStateMetaInfo(
+ private <N, UK, SV> RegisteredKeyValueStateBackendMetaInfo<N, SV>
updateRestoredStateMetaInfo(
Tuple2<ColumnFamilyHandle,
RegisteredKeyValueStateBackendMetaInfo<N, SV>> oldStateInfo,
StateDescriptor<SV> stateDesc,
TypeSerializer<SV> stateSerializer,
+ TypeSerializer userKeySerializer,
Review Comment:
```suggestion
TypeSerializer<UK> userKeySerializer,
```
##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/ForStKeyedStateBackend.java:
##########
@@ -372,20 +379,32 @@ public <N, S extends InternalKeyedState, SV> S
createStateInternal(
Tuple2.of(oldStateInfo.columnFamilyHandle,
castedMetaInfo),
stateDesc,
stateSerializer,
+ userKeySerializer,
namespaceSerializer);
newStateInfo =
new ForStOperationUtils.ForStKvStateInfo(
oldStateInfo.columnFamilyHandle, newMetaInfo);
kvStateInformation.put(stateDesc.getStateId(), newStateInfo);
} else {
- newMetaInfo =
- new RegisteredKeyValueStateBackendMetaInfo<>(
- stateDesc.getStateId(),
- stateDesc.getType(),
- namespaceSerializer,
- stateSerializer,
-
StateSnapshotTransformer.StateSnapshotTransformFactory.noTransform());
+ if (stateDesc.getType().equals(StateDescriptor.Type.MAP)) {
+ newMetaInfo =
+ new RegisteredKeyAndUserKeyValueStateBackendMetaInfo<>(
+ stateDesc.getStateId(),
+ stateDesc.getType(),
+ namespaceSerializer,
+ stateSerializer,
+ userKeySerializer);
+ } else {
+ newMetaInfo =
+ new RegisteredKeyValueStateBackendMetaInfo<>(
+ stateDesc.getStateId(),
+ stateDesc.getType(),
+ namespaceSerializer,
+ stateSerializer,
+
StateSnapshotTransformer.StateSnapshotTransformFactory
+ .noTransform());
+ }
Review Comment:
Could we align these two constructor? Either both provide
`StateSnapshotTransformer` or both not
##########
flink-runtime/src/main/java/org/apache/flink/runtime/state/v2/RegisteredKeyAndUserKeyValueStateBackendMetaInfo.java:
##########
@@ -0,0 +1,237 @@
+/*
+ * 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.runtime.state.v2;
+
+import org.apache.flink.api.common.state.v2.StateDescriptor;
+import org.apache.flink.api.common.typeutils.TypeSerializer;
+import org.apache.flink.api.common.typeutils.TypeSerializerSchemaCompatibility;
+import org.apache.flink.api.common.typeutils.TypeSerializerSnapshot;
+import org.apache.flink.runtime.state.StateSerializerProvider;
+import
org.apache.flink.runtime.state.StateSnapshotTransformer.StateSnapshotTransformFactory;
+import org.apache.flink.runtime.state.metainfo.StateMetaInfoSnapshot;
+import org.apache.flink.util.CollectionUtil;
+import org.apache.flink.util.Preconditions;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Compound meta information for a registered state in a keyed state backend.
This combines all
+ * serializers and the state name.
+ *
+ * @param <S> Type of state value
+ */
+public class RegisteredKeyAndUserKeyValueStateBackendMetaInfo<N, UK, S>
+ extends RegisteredKeyValueStateBackendMetaInfo<N, S> {
+
+ @Nullable private StateSerializerProvider<UK> userKeySerializerProvider;
Review Comment:
Add some words to explain the `Nullable`?
```suggestion
// We keep it @Nullable since in the very first version we did not
store this serializer here.
@Nullable private StateSerializerProvider<UK> userKeySerializerProvider;
```
--
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]