@Internal public interface PullingAsyncDataInput<T> extends AvailabilityProvider
For the most efficient usage, user of this class is supposed to call pollNext() until
it returns that no more elements are available. If that happens, he should check if input isFinished(). If not, he should wait for AvailabilityProvider.getAvailableFuture() CompletableFuture to be completed. For example:
AsyncDataInput<T> input = ...;
while (!input.isFinished()) {
Optional<T> next;
while (true) {
next = input.pollNext();
if (!next.isPresent()) {
break;
}
// do something with next
}
input.getAvailableFuture().get();
}
| 限定符和类型 | 接口和说明 |
|---|---|
static class |
PullingAsyncDataInput.EndOfDataStatus
Status for describing if we have reached the end of data.
|
AvailabilityProvider.AvailabilityHelperAVAILABLE| 限定符和类型 | 方法和说明 |
|---|---|
PullingAsyncDataInput.EndOfDataStatus |
hasReceivedEndOfData()
Tells if we consumed all available data.
|
boolean |
isFinished() |
Optional<T> |
pollNext()
Poll the next element.
|
and, getAvailableFuture, isApproximatelyAvailable, isAvailable, orOptional<T> pollNext() throws Exception
Optional.empty() will be returned if there is no data to return or if isFinished() returns true. Otherwise Optional.of(element).Exceptionboolean isFinished()
PullingAsyncDataInput.EndOfDataStatus hasReceivedEndOfData()
Moreover it tells us the reason why there is no more data incoming. If any of the upstream
subtasks finished because of the stop-with-savepoint --no-drain, we should not drain the
input. See also StopMode.
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.