Package org.apache.flink.runtime.state
Interface KeyValueStateIterator
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
HeapKeyValueStateIterator
,RocksStatesPerKeyGroupMergeIterator
public interface KeyValueStateIterator extends AutoCloseable
Iterator that over all key-value state entries in aKeyedStateBackend
. For use during snapshotting.This is required to partition all states into contiguous key-groups. The resulting iteration sequence is ordered by (key-group, kv-state).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
boolean
isNewKeyGroup()
Indicates if current key starts a new key-group, i.e. belong to a different key-group than it's predecessor.boolean
isNewKeyValueState()
Indicates if current key starts a new k/v-state, i.e. belong to a different k/v-state than it's predecessor.boolean
isValid()
Check if the iterator is still valid.byte[]
key()
int
keyGroup()
Returns the key-group for the current key.int
kvStateId()
Returns the Id of the K/V state to which the current key belongs.void
next()
Advances the iterator.byte[]
value()
-
-
-
Method Detail
-
next
void next() throws IOException
Advances the iterator. Should only be called ifisValid()
returned true. Valid flag can only change after callingnext()
.- Throws:
IOException
-
keyGroup
int keyGroup()
Returns the key-group for the current key.
-
key
byte[] key()
-
value
byte[] value()
-
kvStateId
int kvStateId()
Returns the Id of the K/V state to which the current key belongs.
-
isNewKeyValueState
boolean isNewKeyValueState()
Indicates if current key starts a new k/v-state, i.e. belong to a different k/v-state than it's predecessor.- Returns:
- true iff the current key belong to a different k/v-state than it's predecessor.
-
isNewKeyGroup
boolean isNewKeyGroup()
Indicates if current key starts a new key-group, i.e. belong to a different key-group than it's predecessor.- Returns:
- true iff the current key belong to a different key-group than it's predecessor.
-
isValid
boolean isValid()
Check if the iterator is still valid. Getters likekey()
,value()
, etc. as well asnext()
should only be called if valid returned true. Should be checked after each call tonext()
before accessing iterator state.- Returns:
- True iff this iterator is valid.
-
close
void close()
- Specified by:
close
in interfaceAutoCloseable
-
-