Class HeapKeyValueStateIterator
- java.lang.Object
-
- org.apache.flink.runtime.state.heap.HeapKeyValueStateIterator
-
- All Implemented Interfaces:
AutoCloseable
,KeyValueStateIterator
@Internal @NotThreadSafe public final class HeapKeyValueStateIterator extends Object implements KeyValueStateIterator
AKeyValueStateIterator
over Heap backend snapshot resources.
-
-
Constructor Summary
Constructors Constructor Description HeapKeyValueStateIterator(KeyGroupRange keyGroupRange, TypeSerializer<?> keySerializer, int totalKeyGroups, Map<org.apache.flink.runtime.state.heap.StateUID,Integer> stateNamesToId, Map<org.apache.flink.runtime.state.heap.StateUID,StateSnapshot> stateSnapshots)
-
Method Summary
All Methods Instance Methods Concrete 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()
-
-
-
Constructor Detail
-
HeapKeyValueStateIterator
public HeapKeyValueStateIterator(@Nonnull KeyGroupRange keyGroupRange, @Nonnull TypeSerializer<?> keySerializer, @Nonnegative int totalKeyGroups, @Nonnull Map<org.apache.flink.runtime.state.heap.StateUID,Integer> stateNamesToId, @Nonnull Map<org.apache.flink.runtime.state.heap.StateUID,StateSnapshot> stateSnapshots) throws IOException
- Throws:
IOException
-
-
Method Detail
-
isValid
public boolean isValid()
Description copied from interface:KeyValueStateIterator
Check if the iterator is still valid. Getters likeKeyValueStateIterator.key()
,KeyValueStateIterator.value()
, etc. as well asKeyValueStateIterator.next()
should only be called if valid returned true. Should be checked after each call toKeyValueStateIterator.next()
before accessing iterator state.- Specified by:
isValid
in interfaceKeyValueStateIterator
- Returns:
- True iff this iterator is valid.
-
isNewKeyValueState
public boolean isNewKeyValueState()
Description copied from interface:KeyValueStateIterator
Indicates if current key starts a new k/v-state, i.e. belong to a different k/v-state than it's predecessor.- Specified by:
isNewKeyValueState
in interfaceKeyValueStateIterator
- Returns:
- true iff the current key belong to a different k/v-state than it's predecessor.
-
isNewKeyGroup
public boolean isNewKeyGroup()
Description copied from interface:KeyValueStateIterator
Indicates if current key starts a new key-group, i.e. belong to a different key-group than it's predecessor.- Specified by:
isNewKeyGroup
in interfaceKeyValueStateIterator
- Returns:
- true iff the current key belong to a different key-group than it's predecessor.
-
keyGroup
public int keyGroup()
Description copied from interface:KeyValueStateIterator
Returns the key-group for the current key.- Specified by:
keyGroup
in interfaceKeyValueStateIterator
-
kvStateId
public int kvStateId()
Description copied from interface:KeyValueStateIterator
Returns the Id of the K/V state to which the current key belongs.- Specified by:
kvStateId
in interfaceKeyValueStateIterator
-
next
public void next() throws IOException
Description copied from interface:KeyValueStateIterator
Advances the iterator. Should only be called ifKeyValueStateIterator.isValid()
returned true. Valid flag can only change after callingKeyValueStateIterator.next()
.- Specified by:
next
in interfaceKeyValueStateIterator
- Throws:
IOException
-
key
public byte[] key()
- Specified by:
key
in interfaceKeyValueStateIterator
-
value
public byte[] value()
- Specified by:
value
in interfaceKeyValueStateIterator
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceKeyValueStateIterator
-
-