StefanRRichter commented on a change in pull request #8611: [FLINK-12693][state] Store state per key-group in CopyOnWriteStateTable URL: https://github.com/apache/flink/pull/8611#discussion_r293563138
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/state/heap/AbstractStateTableSnapshot.java ########## @@ -19,34 +19,123 @@ package org.apache.flink.runtime.state.heap; import org.apache.flink.annotation.Internal; +import org.apache.flink.api.common.typeutils.TypeSerializer; +import org.apache.flink.core.memory.DataOutputView; +import org.apache.flink.runtime.state.StateEntry; import org.apache.flink.runtime.state.StateSnapshot; +import org.apache.flink.runtime.state.StateSnapshotTransformer; +import org.apache.flink.runtime.state.metainfo.StateMetaInfoSnapshot; import org.apache.flink.util.Preconditions; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import java.io.IOException; + /** * Abstract base class for snapshots of a {@link StateTable}. Offers a way to serialize the snapshot (by key-group). * All snapshots should be released after usage. */ @Internal -abstract class AbstractStateTableSnapshot<K, N, S, T extends StateTable<K, N, S>> implements StateSnapshot { +abstract class AbstractStateTableSnapshot<K, N, S, T extends StateTable<K, N, S>> + implements StateSnapshot, StateSnapshot.StateKeyGroupWriter { /** * The {@link StateTable} from which this snapshot was created. */ - final T owningStateTable; + protected final T owningStateTable; + + /** + * A local duplicate of the table's key serializer. + */ + @Nonnull + protected final TypeSerializer<K> localKeySerializer; + + /** + * A local duplicate of the table's namespace serializer. + */ + @Nonnull + protected final TypeSerializer<N> localNamespaceSerializer; + + /** + * A local duplicate of the table's state serializer. + */ + @Nonnull + protected final TypeSerializer<S> localStateSerializer; + + @Nullable + protected final StateSnapshotTransformer<S> stateSnapshotTransformer; /** * Creates a new {@link AbstractStateTableSnapshot} for and owned by the given table. * * @param owningStateTable the {@link StateTable} for which this object represents a snapshot. */ - AbstractStateTableSnapshot(T owningStateTable) { + AbstractStateTableSnapshot( + T owningStateTable, + TypeSerializer<K> localKeySerializer, Review comment: You could also use `@Nonnull` for the parameters that go to non-null fields instead of `Preconditions`. The annotation also generates an assertion check for non-null if the code is executed with `-ea` ---------------------------------------------------------------- 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