StefanRRichter commented on a change in pull request #7866: [FLINK-11730] 
[State Backends] Make HeapKeyedStateBackend follow the builder pattern
URL: https://github.com/apache/flink/pull/7866#discussion_r262115368
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/state/heap/HeapRestoreOperation.java
 ##########
 @@ -0,0 +1,296 @@
+/*
+ * 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.heap;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.flink.api.common.typeutils.TypeSerializerSchemaCompatibility;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.core.fs.CloseableRegistry;
+import org.apache.flink.core.fs.FSDataInputStream;
+import org.apache.flink.core.memory.DataInputViewStreamWrapper;
+import org.apache.flink.runtime.state.KeyExtractorFunction;
+import org.apache.flink.runtime.state.KeyGroupRange;
+import org.apache.flink.runtime.state.KeyGroupRangeOffsets;
+import org.apache.flink.runtime.state.KeyGroupedInternalPriorityQueue;
+import org.apache.flink.runtime.state.KeyGroupsStateHandle;
+import org.apache.flink.runtime.state.Keyed;
+import org.apache.flink.runtime.state.KeyedBackendSerializationProxy;
+import org.apache.flink.runtime.state.KeyedStateHandle;
+import org.apache.flink.runtime.state.PriorityComparable;
+import org.apache.flink.runtime.state.RegisteredKeyValueStateBackendMetaInfo;
+import 
org.apache.flink.runtime.state.RegisteredPriorityQueueStateBackendMetaInfo;
+import org.apache.flink.runtime.state.RestoreOperation;
+import org.apache.flink.runtime.state.SnappyStreamCompressionDecorator;
+import org.apache.flink.runtime.state.StateSerializerProvider;
+import org.apache.flink.runtime.state.StateSnapshotKeyGroupReader;
+import org.apache.flink.runtime.state.StateSnapshotRestore;
+import org.apache.flink.runtime.state.StreamCompressionDecorator;
+import org.apache.flink.runtime.state.UncompressedStreamCompressionDecorator;
+import org.apache.flink.runtime.state.metainfo.StateMetaInfoSnapshot;
+import org.apache.flink.util.Preconditions;
+import org.apache.flink.util.StateMigrationException;
+
+import javax.annotation.Nonnegative;
+import javax.annotation.Nonnull;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Implementation of heap restore operation.
+ *
+ * @param <K> The data type that the serializer serializes.
+ */
+public class HeapRestoreOperation<K> implements RestoreOperation<Void> {
+       private final Collection<KeyedStateHandle> restoreStateHandles;
+       private final StateSerializerProvider<K> keySerializerProvider;
+       private final ClassLoader userCodeClassLoader;
+       private final Map<String, StateTable<K, ?, ?>> registeredKVStates;
+       private final Map<String, HeapPriorityQueueSnapshotRestoreWrapper> 
registeredPQStates;
+       private final CloseableRegistry cancelStreamRegistry;
+       private final HeapPriorityQueueSetFactory priorityQueueSetFactory;
+       @Nonnull
+       private final KeyGroupRange keyGroupRange;
+       @Nonnegative
+       private final int numberOfKeyGroups;
+       private final HeapSnapshotStrategy<K> snapshotStrategy;
+       private final HeapKeyedStateBackend<K> backend;
+
+       public HeapRestoreOperation(
+               @Nonnull Collection<KeyedStateHandle> restoreStateHandles,
+               StateSerializerProvider<K> keySerializerProvider,
+               ClassLoader userCodeClassLoader,
+               Map<String, StateTable<K, ?, ?>> registeredKVStates,
+               Map<String, HeapPriorityQueueSnapshotRestoreWrapper> 
registeredPQStates,
+               CloseableRegistry cancelStreamRegistry,
+               HeapPriorityQueueSetFactory priorityQueueSetFactory,
+               @Nonnull KeyGroupRange keyGroupRange,
+               int numberOfKeyGroups,
+               HeapSnapshotStrategy<K> snapshotStrategy,
+               HeapKeyedStateBackend<K> backend) {
+               this.restoreStateHandles = restoreStateHandles;
+               this.keySerializerProvider = keySerializerProvider;
+               this.userCodeClassLoader = userCodeClassLoader;
+               this.registeredKVStates = registeredKVStates;
+               this.registeredPQStates = registeredPQStates;
+               this.cancelStreamRegistry = cancelStreamRegistry;
+               this.priorityQueueSetFactory = priorityQueueSetFactory;
+               this.keyGroupRange = keyGroupRange;
+               this.numberOfKeyGroups = numberOfKeyGroups;
+               this.snapshotStrategy = snapshotStrategy;
+               this.backend = backend;
+       }
+
+       @Override
+       public Void restore() throws Exception {
 
 Review comment:
   Ok, if you think there is benefit in keeping the interface, it is also fine 
for me.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to