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

 ##########
 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:
   > The annotation also generates an assertion check for non-null if the code 
is executed with -ea
   
   I am confused about this. I use a simple code to test the assertion, but 
nothing happened no matter whether the `-ea` is added. The code is as follows, 
the version of jsr305 jar is 1.3.9 which is the same as flink used, and the 
version of java is 1.8.0_162.
   ```Java
   import javax.annotation.Nonnull;
   
   public class AnnotationTest {
   
        public static void main(String[] args) {
                func(null);
        }
   
        private static void func(@Nonnull Object object) {
                System.out.println("success");
        }
   }
   ```
   But I find Intellij has a setting `Add runtime assertions for not-null 
annotated methods and parameters`,and if I run the code in Intellij with this 
setting enabled, there will be an `IllegalArgumentException` throwed. Please 
let me know if I'm wrong. 

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


With regards,
Apache Git Services

Reply via email to