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_r293880412
##########
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:
Yes, we can create a spliterator with known size as you say. But in this
case, we will not iterate keys in parallel, so the size will not be used. On
the other hand, the size for `NestedStateMap` need some computation. So I think
there is no need to get the size of the spliterator.
----------------------------------------------------------------
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