Package org.sensorhub.api.datastore
Interface AsyncStream<T>
- Type Parameters:
T
- the type of the stream elements
- All Superinterfaces:
AutoCloseable
,BaseStream<T,
,Stream<T>> Stream<T>
Interface for asynchronous streams.
This adds asynchronous methods for all terminal operations returning completable futures. When these methods are called the stream pipeline is run asynchronously as data is pushed to the stream.
Default implementations of these new methods simply execute their synchronous counterparts and return the result wrapped in a completed future.
The implementation works by separating the terminal operation from the rest of the stream. The non-terminal part of the stream is then surrounded by 2 (spl)iterators that are controlled by the thread supplying the new data. The terminal operation is also executed by the supplier thread everytime an element comes out of the non-terminal part of the stream.-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.stream.Stream
Stream.Builder<T extends Object>
-
Method Summary
Modifier and TypeMethodDescriptiondefault CompletableFuture<Boolean>
allMatchAsync
(Predicate<? super T> predicate) default CompletableFuture<Boolean>
anyMatchAsync
(Predicate<? super T> predicate) default <R> CompletableFuture<R>
collectAsync
(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner) default <R,
A> CompletableFuture<R> collectAsync
(Collector<? super T, A, R> collector) default CompletableFuture<Long>
distinct()
default CompletableFuture<Optional<T>>
default CompletableFuture<Optional<T>>
<R> AsyncStream<R>
default CompletableFuture<Void>
forEachAsync
(Consumer<? super T> action) default CompletableFuture<Void>
forEachOrderedAsync
(Consumer<? super T> action) limit
(long maxSize) <R> AsyncStream<R>
default CompletableFuture<Optional<T>>
maxAsync
(Comparator<? super T> comparator) default CompletableFuture<Optional<T>>
minAsync
(Comparator<? super T> comparator) parallel()
default CompletableFuture<Optional<T>>
reduceAsync
(BinaryOperator<T> accumulator) default CompletableFuture<T>
reduceAsync
(T identity, BinaryOperator<T> accumulator) default <U> CompletableFuture<U>
reduceAsync
(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner) skip
(long n) sorted()
sorted
(Comparator<? super T> comparator) Methods inherited from interface java.util.stream.BaseStream
close, isParallel, iterator, onClose, spliterator
Methods inherited from interface java.util.stream.Stream
allMatch, anyMatch, collect, collect, count, dropWhile, findAny, findFirst, flatMapToDouble, flatMapToInt, flatMapToLong, forEach, forEachOrdered, mapMulti, mapMultiToDouble, mapMultiToInt, mapMultiToLong, mapToDouble, mapToInt, mapToLong, max, min, noneMatch, reduce, reduce, reduce, takeWhile, toArray, toArray, toList
-
Method Details
-
allMatchAsync
-
anyMatchAsync
-
collectAsync
-
collectAsync
default <R> CompletableFuture<R> collectAsync(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner) -
countAsync
-
findAnyAsync
-
findFirstAsync
-
forEachAsync
-
forEachOrderedAsync
-
maxAsync
-
minAsync
-
reduceAsync
-
reduceAsync
-
reduceAsync
default <U> CompletableFuture<U> reduceAsync(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner) -
parallel
AsyncStream<T> parallel()- Specified by:
parallel
in interfaceBaseStream<T,
Stream<T>>
-
sequential
AsyncStream<T> sequential()- Specified by:
sequential
in interfaceBaseStream<T,
Stream<T>>
-
unordered
AsyncStream<T> unordered()- Specified by:
unordered
in interfaceBaseStream<T,
Stream<T>>
-
distinct
AsyncStream<T> distinct() -
filter
-
flatMap
-
limit
-
map
-
peek
-
skip
-
sorted
AsyncStream<T> sorted() -
sorted
-