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_r293850537
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/state/heap/StateTable.java
 ##########
 @@ -156,10 +203,23 @@ public boolean isEmpty() {
         * @param transformation the transformation function.
         * @throws Exception if some exception happens in the transformation 
function.
         */
-       public abstract <T> void transform(
+       public <T> void transform(
                        N namespace,
                        T value,
-                       StateTransformationFunction<S, T> transformation) 
throws Exception;
+                       StateTransformationFunction<S, T> transformation) 
throws Exception {
+               K key = keyContext.getCurrentKey();
+               checkKeyNamespacePreconditions(key, namespace);
+
+               int keyGroup = keyContext.getCurrentKeyGroupIndex();
+               StateMap<K, N, S> stateMap = getMapForKeyGroup(keyGroup);
+
+               if (stateMap == null) {
+                       stateMap = createStateMap();
 
 Review comment:
   The style of checking `null` is just following the original 
NestedMapsStateTable. For the followup spill implementation, we just replace 
the on-heap map with on-disk map, instead of removing the map from the array, 
so there is no need to set `null` in the array. I agree with you that no map 
will stay `null` for long if the number of keys is more than the number of 
key-groups and keys are uniformly distributed, which I think is the most case. 
So I will initialize all array positions with maps and remove the check. 

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