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_r299435750
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/state/heap/StateTable.java
##########
@@ -172,14 +229,110 @@ 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)
+ .flatMap(stateMap ->
StreamSupport.stream(Spliterators.spliteratorUnknownSize(stateMap.iterator(),
0), false))
+ .filter(entry -> entry.getNamespace().equals(namespace))
+ .map(StateEntry::getKey);
+ }
+
+ public StateIncrementalVisitor<K, N, S> getStateIncrementalVisitor(int
recommendedMaxNumberOfReturnedRecords) {
+ return new
StateEntryIterator(recommendedMaxNumberOfReturnedRecords);
+ }
- public abstract Stream<K> getKeys(N namespace);
+ //
------------------------------------------------------------------------
- public abstract StateIncrementalVisitor<K, N, S>
getStateIncrementalVisitor(int recommendedMaxNumberOfReturnedRecords);
+ private S get(K key, int keyGroupIndex, N namespace) {
+ checkKeyNamespacePreconditions(key, namespace);
+
+ StateMap<K, N, S> stateMap = getMapForKeyGroup(keyGroupIndex);
+
+ if (stateMap == null) {
Review comment:
I think this check can go away with the changes that make all maps non-null.
----------------------------------------------------------------
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