Package org.apache.storm.state
Class BaseStateIterator<K,V,KENCODEDT,VENCODEDT>
java.lang.Object
org.apache.storm.state.BaseStateIterator<K,V,KENCODEDT,VENCODEDT>
- Direct Known Subclasses:
BaseBinaryStateIterator
public abstract class BaseStateIterator<K,V,KENCODEDT,VENCODEDT>
extends Object
implements Iterator<Map.Entry<K,V>>
Base implementation of iterator over
KeyValueState
. Encoded/Decoded types of key and value are all generic.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract K
Decode key to convert encoded type of key to state key type.protected abstract V
decodeValue
(VENCODEDT value) Decode value to convert encoded type of value to state value type.boolean
hasNext()
protected abstract boolean
Check whether end of data is reached from storage state KVs.protected abstract boolean
isTombstoneValue
(VENCODEDT value) Check whether the value is tombstone (deletion mark) value.Load some part of state KVs from storage and returns iterator of cached data from storage.next()
void
remove()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
BaseStateIterator
public BaseStateIterator(Iterator<Map.Entry<KENCODEDT, VENCODEDT>> pendingPrepareIterator, Iterator<Map.Entry<KENCODEDT, VENCODEDT>> pendingCommitIterator, Set<KENCODEDT> initialProvidedKeys) Constructor.- Parameters:
pendingPrepareIterator
- The iterator of pendingPreparependingCommitIterator
- The iterator of pendingCommitinitialProvidedKeys
- The initial value of provided keys
-
-
Method Details
-
hasNext
public boolean hasNext() -
next
-
remove
public void remove() -
loadChunkFromStateStorage
Load some part of state KVs from storage and returns iterator of cached data from storage.- Returns:
- Iterator of loaded state KVs
-
isEndOfDataFromStorage
protected abstract boolean isEndOfDataFromStorage()Check whether end of data is reached from storage state KVs.- Returns:
- whether end of data is reached from storage state KVs
-
decodeKey
Decode key to convert encoded type of key to state key type.- Parameters:
key
- raw type of encoded key- Returns:
- Decoded value of key
-
decodeValue
Decode value to convert encoded type of value to state value type.- Parameters:
value
- raw type of encoded value- Returns:
- Decoded value of value
-
isTombstoneValue
Check whether the value is tombstone (deletion mark) value.- Parameters:
value
- the value to check- Returns:
- true if the value is tombstone, false otherwise
-