Zakelly commented on a change in pull request #15420:
URL: https://github.com/apache/flink/pull/15420#discussion_r651620703
##########
File path:
flink-state-backends/flink-statebackend-changelog/src/main/java/org/apache/flink/state/changelog/ChangelogReducingState.java
##########
@@ -65,16 +80,31 @@ public V get() throws Exception {
@Override
public void add(V value) throws Exception {
delegatedState.add(value);
+ changeLogger.stateUpdated(delegatedState.get(), getCurrentNamespace());
Review comment:
For interface semantics, using ```delegatedState.getInternal()``` is
better? However, it's no big deal.
##########
File path:
flink-state-backends/flink-statebackend-changelog/src/main/java/org/apache/flink/state/changelog/restore/KvStateStateChangeApplier.java
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.state.changelog.restore;
+
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.runtime.state.KeyGroupRangeAssignment;
+import org.apache.flink.runtime.state.heap.InternalKeyContext;
+import org.apache.flink.runtime.state.internal.InternalKvState;
+import org.apache.flink.state.changelog.StateChangeOperation;
+
+abstract class KvStateStateChangeApplier<K, N> implements StateChangeApplier {
+ private final InternalKeyContext<K> keyContext;
+
+ protected abstract InternalKvState<K, N, ?> getState();
+
+ protected KvStateStateChangeApplier(InternalKeyContext<K> keyContext) {
+ this.keyContext = keyContext;
+ }
+
+ @Override
+ public void apply(StateChangeOperation operation, DataInputView in) throws
Exception {
+ K key = getState().getKeySerializer().deserialize(in);
+ keyContext.setCurrentKey(key);
+ keyContext.setCurrentKeyGroupIndex(
+ KeyGroupRangeAssignment.assignToKeyGroup(key,
keyContext.getNumberOfKeyGroups()));
+
getState().setCurrentNamespace(getState().getNamespaceSerializer().deserialize(in));
+ switch (operation) {
+ case ADD:
+ applyStateAdded(in);
+ return;
+ case CLEAR:
+ applyStateClear();
+ return;
+ case CHANGE_ELEMENT:
+ applyStateElementChanged(in);
+ return;
+ case SET:
+ applyStateUpdate(in);
+ return;
+ case MERGE_NS:
+ applyNameSpaceMerge(in);
+ return;
+ case REMOVE_ELEMENT:
+ applyStateElementRemoved(in);
+ return;
+ default:
+ throw new IllegalArgumentException("Unknown state change
operation: " + operation);
+ }
+ }
+
+ protected abstract void applyNameSpaceMerge(DataInputView in) throws
Exception;
Review comment:
```applyNameSpaceMerge``` -> ```applyNamespaceMerge``` or
```applyNamespaceMerged``` ?
##########
File path:
flink-state-backends/flink-statebackend-changelog/src/main/java/org/apache/flink/state/changelog/restore/AggregatingStateChangeApplier.java
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.state.changelog.restore;
+
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.runtime.state.heap.InternalKeyContext;
+import org.apache.flink.runtime.state.internal.InternalAggregatingState;
+import org.apache.flink.runtime.state.internal.InternalKvState;
+
+class AggregatingStateChangeApplier<K, N, IN, SV, OUT> extends
KvStateStateChangeApplier<K, N> {
+ private final InternalAggregatingState<K, N, IN, SV, OUT> state;
+
+ protected AggregatingStateChangeApplier(
+ InternalKeyContext<K> keyContext, InternalAggregatingState<K, N,
IN, SV, OUT> state) {
+ super(keyContext);
+ this.state = state;
+ }
+
+ @Override
+ protected void applyStateUpdate(DataInputView in) throws Exception {
+ state.updateInternal(state.getValueSerializer().deserialize(in));
+ }
+
+ @Override
+ protected void applyStateAdded(DataInputView in) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected void applyStateElementChanged(DataInputView in) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected InternalKvState<K, N, ?> getState() {
+ return state;
+ }
+
+ @Override
+ protected void applyNameSpaceMerge(DataInputView in) {
+ throw new UnsupportedOperationException();
Review comment:
Will implement this later?
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]