Class AbstractStateIterator<T>
- java.lang.Object
-
- org.apache.flink.runtime.asyncprocessing.AbstractStateIterator<T>
-
- All Implemented Interfaces:
org.apache.flink.api.common.state.v2.StateIterator<T>,org.apache.flink.core.state.InternalStateIterator<T>
public abstract class AbstractStateIterator<T> extends Object implements org.apache.flink.core.state.InternalStateIterator<T>
AStateIteratorimplementation to facilitate async data load of iterator. Each state backend could override this class to maintain more variables in need. Any subclass should implement two methods,hasNextLoading()andnextPayloadForContinuousLoading(). The philosophy behind this class is to carry some already loaded elements and provide iterating right on the task thread, and load following ones if needed (determined byhasNextLoading()) by creating **ANOTHER** iterating request. Thus, later it returns another iterator instance, and we continue to apply the user iteration on that instance. The whole elements will be iterated by recursive call of#onNext().
-
-
Constructor Summary
Constructors Constructor Description AbstractStateIterator(org.apache.flink.api.common.state.v2.State originalState, StateRequestType requestType, StateRequestHandler stateHandler, Collection<T> partialResult)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Iterable<T>getCurrentCache()protected StateRequestTypegetRequestType()abstract booleanhasNextLoading()Return whether this iterator has more elements to load besides current cache.booleanisEmpty()protected abstract ObjectnextPayloadForContinuousLoading()To perform following loading, build and get next payload for the next request.<U> org.apache.flink.api.common.state.v2.StateFuture<Collection<U>>onNext(org.apache.flink.util.function.FunctionWithException<T,org.apache.flink.api.common.state.v2.StateFuture<? extends U>,Exception> iterating)org.apache.flink.api.common.state.v2.StateFuture<Void>onNext(org.apache.flink.util.function.ThrowingConsumer<T,Exception> iterating)voidonNextSync(Consumer<T> iterating)
-
-
-
Constructor Detail
-
AbstractStateIterator
public AbstractStateIterator(org.apache.flink.api.common.state.v2.State originalState, StateRequestType requestType, StateRequestHandler stateHandler, Collection<T> partialResult)
-
-
Method Detail
-
hasNextLoading
public abstract boolean hasNextLoading()
Return whether this iterator has more elements to load besides current cache.- Specified by:
hasNextLoadingin interfaceorg.apache.flink.core.state.InternalStateIterator<T>
-
nextPayloadForContinuousLoading
protected abstract Object nextPayloadForContinuousLoading()
To perform following loading, build and get next payload for the next request. This will put intoStateRequest.getPayload().- Returns:
- the packed payload for next loading.
-
getCurrentCache
public Iterable<T> getCurrentCache()
- Specified by:
getCurrentCachein interfaceorg.apache.flink.core.state.InternalStateIterator<T>
-
getRequestType
protected StateRequestType getRequestType()
-
onNext
public <U> org.apache.flink.api.common.state.v2.StateFuture<Collection<U>> onNext(org.apache.flink.util.function.FunctionWithException<T,org.apache.flink.api.common.state.v2.StateFuture<? extends U>,Exception> iterating)
- Specified by:
onNextin interfaceorg.apache.flink.api.common.state.v2.StateIterator<T>
-
onNext
public org.apache.flink.api.common.state.v2.StateFuture<Void> onNext(org.apache.flink.util.function.ThrowingConsumer<T,Exception> iterating)
- Specified by:
onNextin interfaceorg.apache.flink.api.common.state.v2.StateIterator<T>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceorg.apache.flink.api.common.state.v2.StateIterator<T>
-
-