@Internal public interface AsyncDataInput<T> extends AvailabilityListener
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 AvailabilityListener.isFinished()
. If not, he should wait for AvailabilityListener.isAvailable()
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.isAvailable().get();
}
AVAILABLE
Modifier and Type | Method and Description |
---|---|
Optional<T> |
pollNext()
Poll the next element.
|
isAvailable, isFinished
Optional<T> pollNext() throws Exception
Optional.empty()
will be returned if there is no data to return or
if AvailabilityListener.isFinished()
returns true. Otherwise Optional.of(element)
.Exception
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.