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_r293560863
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/state/heap/StateTable.java ########## @@ -172,14 +232,133 @@ public boolean isEmpty() { * @return the state of the mapping with the specified key/namespace composite key, or {@code null} * if no mapping for the specified key is found. */ - public abstract S get(K key, N namespace); + public S get(K key, N namespace) { + int keyGroup = KeyGroupRangeAssignment.assignToKeyGroup(key, keyContext.getNumberOfKeyGroups()); + return get(key, keyGroup, namespace); + } + + public Stream<K> getKeys(N namespace) { + return Arrays.stream(state) + .filter(Objects::nonNull) + .map(StateMap::iterator) + .flatMap(iter -> StreamSupport.stream(Spliterators.spliteratorUnknownSize(iter, 0), false)) Review comment: I think if you flatmap directly from the StateMap, you could get the size of the spliterator instead of using `spliteratorUnknownSize` ? ---------------------------------------------------------------- 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