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 overKeyValueState
. Encoded/Decoded types of key and value are all generic.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract K
decodeKey(KENCODEDT key)
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
isEndOfDataFromStorage()
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.protected abstract Iterator<Map.Entry<KENCODEDT,VENCODEDT>>
loadChunkFromStateStorage()
Load some part of state KVs from storage and returns iterator of cached data from storage.Map.Entry<K,V>
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 Detail
-
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 Detail
-
loadChunkFromStateStorage
protected abstract Iterator<Map.Entry<KENCODEDT,VENCODEDT>> 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
protected abstract K decodeKey(KENCODEDT key)
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
protected abstract V decodeValue(VENCODEDT value)
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
protected abstract boolean isTombstoneValue(VENCODEDT value)
Check whether the value is tombstone (deletion mark) value.- Parameters:
value
- the value to check- Returns:
- true if the value is tombstone, false otherwise
-
-