Class AbstractStateIterator<T>

  • All Implemented Interfaces:
    org.apache.flink.api.common.state.v2.StateIterator<T>

    public abstract class AbstractStateIterator<T>
    extends Object
    implements org.apache.flink.api.common.state.v2.StateIterator<T>
    A StateIterator implementation 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, hasNext() and nextPayloadForContinuousLoading(). 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 by hasNext()) 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().
    • Method Detail

      • hasNext

        protected abstract boolean hasNext()
        Return whether this iterator has more elements to load besides current cache.
      • nextPayloadForContinuousLoading

        protected abstract Object nextPayloadForContinuousLoading()
        To perform following loading, build and get next payload for the next request. This will put into StateRequest.getPayload().
        Returns:
        the packed payload for next loading.
      • onNext

        public <U> org.apache.flink.api.common.state.v2.StateFuture<Collection<U>> onNext​(Function<T,​org.apache.flink.api.common.state.v2.StateFuture<? extends U>> iterating)
        Specified by:
        onNext in interface org.apache.flink.api.common.state.v2.StateIterator<T>
      • onNext

        public org.apache.flink.api.common.state.v2.StateFuture<Void> onNext​(Consumer<T> iterating)
        Specified by:
        onNext in interface org.apache.flink.api.common.state.v2.StateIterator<T>
      • onNextSync

        public void onNextSync​(Consumer<T> iterating)
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface org.apache.flink.api.common.state.v2.StateIterator<T>