public interface LazyFutureStream<U> extends LazyStream<U>, FutureStream<U>, LazyToQueue<U>
FutureStream.Val<T>
java.util.stream.Stream.Builder<T>
ConfigurableStream.SimpleReactConfigurableStream<U>
Modifier and Type | Field and Description |
---|---|
static java.lang.Object |
NULL |
softener
Modifier and Type | Method and Description |
---|---|
default <T,R> LazyFutureStream<R> |
allOf(java.util.stream.Collector collector,
java.util.function.Function<T,R> fn) |
default <T,R> LazyFutureStream<R> |
allOf(java.util.function.Function<java.util.List<T>,R> fn)
React and allOf
allOf is a non-blocking equivalent of block.
|
default <R> LazyFutureStream<R> |
anyOf(java.util.function.Function<U,R> fn)
React to the completion of any of the events in the previous stage.
|
default LazyFutureStream<U> |
async() |
default LazyFutureStream<java.util.Collection<U>> |
batch(java.util.function.Function<java.util.function.Supplier<U>,java.util.function.Supplier<java.util.Collection<U>>> fn)
Batch elements into a Stream of collections with user defined function
|
default LazyFutureStream<java.util.Collection<U>> |
batchBySize(int size)
Batch the elements in this stream into Lists of specified size
|
default LazyFutureStream<java.util.Collection<U>> |
batchBySize(int size,
java.util.function.Supplier<java.util.Collection<U>> supplier)
Batch the elements in this stream into Collections of specified size The
type of Collection is determined by the specified supplier
|
default LazyFutureStream<java.util.Collection<U>> |
batchByTime(long time,
java.util.concurrent.TimeUnit unit)
Organise elements in a Stream into a Collections based on the time period
they pass through this stage
|
default LazyFutureStream<java.util.Collection<U>> |
batchByTime(long time,
java.util.concurrent.TimeUnit unit,
java.util.function.Supplier<java.util.Collection<U>> factory)
Organise elements in a Stream into a Collections based on the time period
they pass through this stage
|
default LazyFutureStream<U> |
boundedWaitFree(int size)
Use an Agrona ManyToOneConcurrentArrayQueue for the next operations (wait-free, mechanical sympathy).
|
default LazyFutureStream<U> |
capture(java.util.function.Consumer<? extends java.lang.Throwable> errorHandler)
React capture
While onFail is used for disaster recovery (when it is possible to
recover) - capture is used to capture those occasions where the full
pipeline has failed and is unrecoverable.
|
default <U> LazyFutureStream<U> |
cast(java.lang.Class<U> type) |
default LazyFutureStream<java.util.Collection<U>> |
chunkSinceLastRead() |
static void |
close(java.util.Iterator it) |
default void |
closeAll() |
default <R> R |
collect(java.util.function.Supplier<R> supplier,
java.util.function.BiConsumer<R,? super U> accumulator,
java.util.function.BiConsumer<R,R> combiner) |
default <T> LazyFutureStream<org.jooq.lambda.tuple.Tuple2<U,T>> |
combineLatest(FutureStream<T> s)
Similar to zip and withLatest, except will always take the latest from
either Stream (merged with last available from the other).
|
default LazyFutureStream<U> |
concat(java.util.stream.Stream<U> other)
Concatenate two streams.
|
default LazyFutureStream<U> |
control(java.util.function.Function<java.util.function.Supplier<U>,java.util.function.Supplier<U>> fn)
Allows clients to control the emission of data for the next phase of the
Stream.
|
default EagerFutureStream<U> |
convertToEagerStream()
Convert between an Lazy and Eager future stream,
can be used to take advantages of each approach during a single Stream
|
default LazyFutureStream<U> |
debounce(long time,
java.util.concurrent.TimeUnit unit)
Can be used to debounce (accept a single data point from a unit of time)
data.
|
default org.jooq.lambda.Seq<U> |
distinct() |
default org.jooq.lambda.tuple.Tuple2<org.jooq.lambda.Seq<U>,org.jooq.lambda.Seq<U>> |
duplicate()
Duplicate a Streams into two equivalent Streams.
|
default org.jooq.lambda.tuple.Tuple2<LazyFutureStream<U>,LazyFutureStream<U>> |
duplicateFutures()
Duplicate a Stream into two equivalent LazyFutureStreams
LazyFutureStream.of(1, 2, 3).duplicate()
results in
tuple((1,2,3),(1,2,3))
Care should be taken not to use this method with infinite streams!
|
default org.jooq.lambda.tuple.Tuple2<org.jooq.lambda.Seq<U>,org.jooq.lambda.Seq<U>> |
duplicateFuturesSeq()
Duplicate a Stream into two equivalent Sequences
LazyFutureStream.of(1, 2, 3).duplicate()
results in
tuple((1,2,3),(1,2,3))
Care should be taken not to use this method with infinite streams!
|
static <T> LazyFutureStream<T> |
empty() |
default LazyFutureStream<U> |
filter(java.util.function.Predicate<? super U> p)
Removes elements that do not match the supplied predicate from the
dataflow
|
default java.util.Optional<U> |
findFirst()
Returns an
Optional describing the first element of this stream,
or an empty Optional if the stream is empty. |
static <U> LazyFutureStream<U> |
firstOf(LazyFutureStream<U>... futureStreams)
Return first Stream out of provided Streams that starts emitted results
|
default LazyFutureStream<U> |
fixedDelay(long time,
java.util.concurrent.TimeUnit unit)
Apply a fixed delay before emitting elements to the next phase of the
Stream.
|
default <R> LazyFutureStream<R> |
flatMap(java.util.function.Function<? super U,? extends java.util.stream.Stream<? extends R>> flatFn)
Allows aggregate values in a Stream to be flatten into a single Stream.
|
default void |
forEach(java.util.function.Consumer<? super U> c)
Stream supporting methods
|
default <R> LazyFutureStream<R> |
fromStream(java.util.stream.Stream<R> stream) |
default <R> LazyFutureStream<R> |
fromStreamOfFutures(java.util.stream.Stream<java.util.concurrent.CompletableFuture<R>> stream)
Construct a SimpleReactStream from provided Stream of CompletableFutures
|
static LazyFutureStream<java.lang.Void> |
generate() |
static <T> LazyFutureStream<T> |
generate(java.util.function.Supplier<T> s) |
static <T> LazyFutureStream<T> |
generate(T value) |
default LazyFutureStream<U> |
intersperse(U value)
Returns a stream with a given value interspersed between any two values
of this stream.
|
static <T> LazyFutureStream<T> |
iterate(T seed,
java.util.function.UnaryOperator<T> f) |
default LazyFutureStream<U> |
jitter(long jitterInNanos)
Introduce a random delay between events in a stream Can be used to
prevent behaviour synchronizing within a system
|
default LazyFutureStream<U> |
limit(long maxSize) |
default LazyFutureStream<U> |
limitUntil(java.util.function.Predicate<? super U> predicate)
Returns a stream limited to all elements for which a predicate evaluates
to false.
|
static <T> org.jooq.lambda.Seq<T> |
limitUntil(java.util.stream.Stream<T> stream,
java.util.function.Predicate<? super T> predicate)
Returns a stream ed to all elements for which a predicate evaluates to
true . |
default LazyFutureStream<U> |
limitWhile(java.util.function.Predicate<? super U> predicate)
Returns a stream limited to all elements for which a predicate evaluates
to true.
|
static <T> org.jooq.lambda.Seq<T> |
limitWhile(java.util.stream.Stream<T> stream,
java.util.function.Predicate<? super T> predicate)
Returns a stream limited to all elements for which a predicate evaluates
to
true . |
default <R> LazyFutureStream<R> |
map(java.util.function.Function<? super U,? extends R> mapper) |
default LazyFutureStream<U> |
maxActive(int concurrentTasks)
Configure the max active concurrent tasks.
|
default LazyFutureStream<U> |
merge(SimpleReactStream<U> s)
Merge this reactive dataflow with another of the same type.
|
static <T> LazyFutureStream<T> |
of(java.util.Iterator<T> iterator)
Wrap an Iterator into a FutureStream.
|
static <T> LazyFutureStream<T> |
of(java.util.stream.Stream<T> stream)
Wrap a Stream into a FutureStream.
|
static <T> LazyFutureStream<T> |
of(T... values) |
static <T> LazyFutureStream<T> |
of(T value) |
static <T> LazyFutureStream<T> |
ofIterable(java.lang.Iterable<T> iterable)
Wrap an Iterable into a FutureStream.
|
default <U> FutureStream<U> |
ofType(java.lang.Class<U> type)
Keep only those elements in a stream that are of a given type.
|
default LazyFutureStream<U> |
onClose(java.lang.Runnable closeHandler) |
default LazyFutureStream<U> |
onePer(long time,
java.util.concurrent.TimeUnit unit)
Slow emissions down, emiting one element per specified time period
|
default LazyFutureStream<U> |
onFail(java.lang.Class<? extends java.lang.Throwable> exceptionClass,
java.util.function.Function<? extends SimpleReactFailedStageException,U> fn)
Recover for a particular class of exceptions only.
|
default LazyFutureStream<U> |
onFail(java.util.function.Function<? extends SimpleReactFailedStageException,U> fn)
React onFail
Define a function that can be used to recover from exceptions during the
preceeding stage of the dataflow.
|
default LazyFutureStream<U> |
parallel() |
static <U> LazyFutureStream<U> |
parallel(U... array)
Construct an Lazy SimpleReact Stream from specified array
|
static LazyReact |
parallelBuilder() |
static LazyReact |
parallelBuilder(int parallelism)
Construct a new LazyReact builder, with a new task executor and retry
executor with configured number of threads
|
static LazyReact |
parallelCommonBuilder() |
static <U> LazyFutureStream<U> |
parallelOf(U... array)
Construct a SimpleReact Stage from a supplied array
|
default org.jooq.lambda.tuple.Tuple2<org.jooq.lambda.Seq<U>,org.jooq.lambda.Seq<U>> |
partition(java.util.function.Predicate<? super U> predicate)
Partition a stream into two given a predicate.
|
default LazyFutureStream<U> |
peek(java.util.function.Consumer<? super U> consumer)
Peek asynchronously at the results in the current stage.
|
static <T> LazyFutureStream<T> |
react(java.util.function.Supplier<T>... values)
Create a parallel asynchronous stream
|
static <T> LazyFutureStream<T> |
react(java.util.function.Supplier<T> value)
Create a parallel asynchronous stream
|
default java.util.Optional<U> |
reduce(java.util.function.BinaryOperator<U> accumulator) |
default <T> T |
reduce(T identity,
java.util.function.BiFunction<T,? super U,T> accumulator,
java.util.function.BinaryOperator<T> combiner) |
default U |
reduce(U identity,
java.util.function.BinaryOperator<U> accumulator) |
default <R> LazyFutureStream<R> |
retry(java.util.function.Function<U,R> fn)
Will execute this phase on the RetryExecutor (default or user supplied).
|
default LazyFutureStream<U> |
reverse()
Reverse a stream.
|
default <T> LazyFutureStream<T> |
scanLeft(T seed,
java.util.function.BiFunction<T,? super U,T> function)
Scan a stream to the left.
|
default <R> LazyFutureStream<R> |
scanRight(R seed,
java.util.function.BiFunction<? super U,R,R> function)
Scan a stream to the right.
|
default LazyFutureStream<U> |
self(java.util.function.Consumer<FutureStream<U>> consumer)
Give a function access to the current stage of a SimpleReact Stream
|
default LazyFutureStream<U> |
sequential() |
static LazyReact |
sequentialBuilder() |
static LazyReact |
sequentialCommonBuilder() |
default <K> java.util.Map<K,LazyFutureStream<U>> |
shard(java.util.Map<K,Queue<U>> shards,
java.util.function.Function<U,K> sharder)
Break a stream into multiple Streams based of some characteristic of the
elements of the Stream
e.g.
|
default LazyFutureStream<U> |
shuffle()
Shuffle a stream
// e.g.
|
default LazyFutureStream<U> |
shuffle(java.util.Random random)
Shuffle a stream using specified source of randomness
// e.g.
|
default LazyFutureStream<U> |
skip(long n) |
default <T> LazyFutureStream<U> |
skipUntil(FutureStream<T> s)
Return a Stream with the same values as this Stream, but with all values
omitted until the provided stream starts emitting values.
|
default LazyFutureStream<U> |
skipUntil(java.util.function.Predicate<? super U> predicate)
Returns a stream with all elements skipped for which a predicate
evaluates to false.
|
default LazyFutureStream<U> |
skipWhile(java.util.function.Predicate<? super U> predicate)
Returns a stream with all elements skipped for which a predicate
evaluates to true.
|
default LazyFutureStream<U> |
slice(long from,
long to)
Returns a limited interval from a given Stream.
|
default LazyFutureStream<U> |
sorted() |
default LazyFutureStream<U> |
sorted(java.util.Comparator<? super U> comparator) |
default java.util.stream.Stream<U> |
stream() |
default LazyFutureStream<U> |
sync() |
default <T> LazyFutureStream<U> |
takeUntil(FutureStream<T> s)
Return a Stream with the same values, but will stop emitting values once
the provided Stream starts to emit values.
|
default <R> LazyFutureStream<R> |
then(java.util.function.Function<U,R> fn)
Override return type on SimpleReactStream
|
default <R> LazyFutureStream<R> |
then(java.util.function.Function<U,R> fn,
java.util.concurrent.Executor service) |
default <R> LazyFutureStream<R> |
thenSync(java.util.function.Function<U,R> fn) |
default LazyFutureStream<U> |
unboundedWaitFree()
This is the default setting, internal queues are backed by a ConcurrentLinkedQueue
This operator will return the next stage to using this Queue type if it has been changed
|
default LazyFutureStream<U> |
unordered() |
LazyFutureStream<U> |
withAsync(boolean async) |
LazyFutureStream<U> |
withErrorHandler(java.util.Optional<java.util.function.Consumer<java.lang.Throwable>> errorHandler) |
LazyFutureStream<U> |
withLastActive(StreamWrapper streamWrapper) |
default <T> LazyFutureStream<org.jooq.lambda.tuple.Tuple2<U,T>> |
withLatest(FutureStream<T> s)
Similar to zip and combineLatest, except will always take the latest from
this Stream while taking the last available value from the provided
stream.
|
LazyFutureStream<U> |
withLazyCollector(LazyResultConsumer<U> lazy) |
LazyFutureStream<U> |
withParallelReduction(ParallelReductionConfig parallelReductionConfig) |
LazyFutureStream<U> |
withQueueFactory(QueueFactory<U> queue) |
LazyFutureStream<U> |
withRetrier(com.nurkiewicz.asyncretry.RetryExecutor retry) |
LazyFutureStream<U> |
withSubscription(Continueable sub) |
LazyFutureStream<U> |
withTaskExecutor(java.util.concurrent.Executor e) |
LazyFutureStream<U> |
withWaitStrategy(java.util.function.Consumer<java.util.concurrent.CompletableFuture> c) |
default FutureStream<U> |
xPer(int x,
long time,
java.util.concurrent.TimeUnit unit)
Allows x (specified number of) emissions with a time period before
stopping emmissions until specified time has elapsed since last emission
|
default <T> LazyFutureStream<org.jooq.lambda.tuple.Tuple2<U,T>> |
zip(org.jooq.lambda.Seq<T> other)
Zip two streams into one.
|
default <T,R> LazyFutureStream<R> |
zip(org.jooq.lambda.Seq<T> other,
java.util.function.BiFunction<U,T,R> zipper)
Zip two streams into one using a
BiFunction to produce resulting
values. |
static <T1,T2> org.jooq.lambda.Seq<org.jooq.lambda.tuple.Tuple2<T1,T2>> |
zip(java.util.stream.Stream<T1> left,
java.util.stream.Stream<T2> right)
Zip two streams into one.
|
static <T1,T2,R> org.jooq.lambda.Seq<R> |
zip(java.util.stream.Stream<T1> left,
java.util.stream.Stream<T2> right,
java.util.function.BiFunction<T1,T2,R> zipper)
Zip two streams into one using a
BiFunction to produce resulting
values. |
default <R> LazyFutureStream<org.jooq.lambda.tuple.Tuple2<U,R>> |
zipFutures(FutureStream<R> other)
Zip two Streams, zipping against the underlying futures of both Streams
Placeholders (Futures) will be populated immediately in the new zipped Stream and results
will be populated asyncrhonously
|
default <R> LazyFutureStream<org.jooq.lambda.tuple.Tuple2<U,R>> |
zipFutures(java.util.stream.Stream<R> other)
Zip two Streams, zipping against the underlying futures of this stream
|
default LazyFutureStream<org.jooq.lambda.tuple.Tuple2<U,java.lang.Long>> |
zipFuturesWithIndex()
Zip this Stream with an index, but Zip based on the underlying tasks, not completed results.
|
default LazyFutureStream<org.jooq.lambda.tuple.Tuple2<U,java.lang.Long>> |
zipWithIndex()
Zip a Stream with a corresponding Stream of indexes.
|
getErrorHandler, getLastActive, getLazyCollector, getParallelReduction, getWaitStrategy, run, run, run, runContinuation, runOnCurrent, runThread
allMatch, anyMatch, cancel, cast, chunkLastReadIterator, close, closeOthers, closeOthers, combineLatest, combineLatest, count, findAny, firstOf, flatMapToDouble, flatMapToInt, flatMapToLong, forEachOrdered, intersperse, isParallel, iterator, lift, lift2, mapToDouble, mapToInt, mapToLong, max, merge, min, noneMatch, ofType, reversedIterator, skipUntil, slice, spliterator, takeUntil, toArray, toArray, withLatest, withLatest
cast, concat, concat, concat, cycle, cycle, duplicate, foldLeft, foldLeft, foldRight, foldRight, groupBy, groupBy, groupBy, groupBy, groupBy, groupBy, intersperse, join, join, join, join, join, join, limit, maxBy, maxBy, minBy, minBy, ofType, partition, reverse, scanLeft, scanRight, seq, seq, seq, seq, seq, shuffle, shuffle, skip, skipUntil, skipWhile, slice, splitAt, splitAt, splitAtHead, splitAtHead, toCollection, toCollection, toList, toList, toMap, toMap, toMap, toSet, toSet, toString, toString, toString, unfold, unzip, unzip, unzip, unzip, zipWithIndex
assureSimpleReactException, bind, doOnEach, doOnEachSync, filterSync, fromListCompletableFuture, fromStreamCompletableFutureReplace, getOriginalFutures, getSubscription, handleExceptions, join, lastActiveArray, merge, peekSync, streamCompletableFutures, with
block, block, block, block, blockAndExtract, blockAndExtract, first, last
getRetrier, getSimpleReact, getTaskExecutor, isAsync, isEager
getQueueFactory, toQueue, toQueue, toQueue
add, getPopulator, returnPopulator, toQueue, toQueue, toQueue
LazyFutureStream<U> withTaskExecutor(java.util.concurrent.Executor e)
withTaskExecutor
in interface ConfigurableStream<U>
withTaskExecutor
in interface ConfigurableStream.SimpleReactConfigurableStream<U>
LazyFutureStream<U> withRetrier(com.nurkiewicz.asyncretry.RetryExecutor retry)
withRetrier
in interface ConfigurableStream<U>
withRetrier
in interface ConfigurableStream.SimpleReactConfigurableStream<U>
LazyFutureStream<U> withWaitStrategy(java.util.function.Consumer<java.util.concurrent.CompletableFuture> c)
withWaitStrategy
in interface ConfigurableStream<U>
withWaitStrategy
in interface ConfigurableStream.SimpleReactConfigurableStream<U>
LazyFutureStream<U> withLazyCollector(LazyResultConsumer<U> lazy)
withLazyCollector
in interface ConfigurableStream<U>
withLazyCollector
in interface ConfigurableStream.SimpleReactConfigurableStream<U>
LazyFutureStream<U> withQueueFactory(QueueFactory<U> queue)
withQueueFactory
in interface ConfigurableStream<U>
withQueueFactory
in interface ConfigurableStream.SimpleReactConfigurableStream<U>
LazyFutureStream<U> withErrorHandler(java.util.Optional<java.util.function.Consumer<java.lang.Throwable>> errorHandler)
withErrorHandler
in interface ConfigurableStream<U>
withErrorHandler
in interface ConfigurableStream.SimpleReactConfigurableStream<U>
LazyFutureStream<U> withSubscription(Continueable sub)
withSubscription
in interface ConfigurableStream<U>
withSubscription
in interface ConfigurableStream.SimpleReactConfigurableStream<U>
LazyFutureStream<U> withLastActive(StreamWrapper streamWrapper)
withLastActive
in interface ConfigurableStream<U>
withLastActive
in interface ConfigurableStream.SimpleReactConfigurableStream<U>
LazyFutureStream<U> withAsync(boolean async)
withAsync
in interface ConfigurableStream<U>
withAsync
in interface ConfigurableStream.SimpleReactConfigurableStream<U>
default void forEach(java.util.function.Consumer<? super U> c)
FutureStream
forEach
in interface FutureStream<U>
forEach
in interface java.lang.Iterable<U>
forEach
in interface LazyStream<U>
forEach
in interface org.jooq.lambda.Seq<U>
forEach
in interface java.util.stream.Stream<U>
default U reduce(U identity, java.util.function.BinaryOperator<U> accumulator)
reduce
in interface FutureStream<U>
reduce
in interface LazyStream<U>
reduce
in interface java.util.stream.Stream<U>
default <T> T reduce(T identity, java.util.function.BiFunction<T,? super U,T> accumulator, java.util.function.BinaryOperator<T> combiner)
reduce
in interface FutureStream<U>
reduce
in interface LazyStream<U>
reduce
in interface java.util.stream.Stream<U>
default java.util.Optional<U> reduce(java.util.function.BinaryOperator<U> accumulator)
reduce
in interface FutureStream<U>
reduce
in interface LazyStream<U>
reduce
in interface java.util.stream.Stream<U>
default <R> R collect(java.util.function.Supplier<R> supplier, java.util.function.BiConsumer<R,? super U> accumulator, java.util.function.BiConsumer<R,R> combiner)
collect
in interface FutureStream<U>
collect
in interface LazyStream<U>
collect
in interface java.util.stream.Stream<U>
default LazyFutureStream<U> sync()
sync
in interface FutureStream<U>
sync
in interface SimpleReactStream<U>
default LazyFutureStream<U> async()
async
in interface FutureStream<U>
async
in interface SimpleReactStream<U>
default LazyFutureStream<U> unboundedWaitFree()
default LazyFutureStream<U> boundedWaitFree(int size)
size
- Buffer sizedefault LazyFutureStream<U> maxActive(int concurrentTasks)
List<String> data = new LazyReact().react(urlFile)
.maxActive(100)
.flatMap(this::loadUrls)
.map(this::callUrls)
.block();
concurrentTasks
- Maximum number of active task chainsdefault <R> LazyFutureStream<R> thenSync(java.util.function.Function<U,R> fn)
thenSync
in interface LazyToQueue<U>
thenSync
in interface SimpleReactStream<U>
default void closeAll()
default java.util.Optional<U> findFirst()
Optional
describing the first element of this stream,
or an empty Optional
if the stream is empty. If the stream has
no encounter order, then any element may be returned.
This is a short-circuiting terminal operation.
findFirst
in interface FutureStream<U>
findFirst
in interface java.util.stream.Stream<U>
Optional
describing the first element of this stream,
or an empty Optional
if the stream is emptyjava.lang.NullPointerException
- if the element selected is nulldefault EagerFutureStream<U> convertToEagerStream()
default <R> LazyFutureStream<R> map(java.util.function.Function<? super U,? extends R> mapper)
map
in interface FutureStream<U>
map
in interface org.jooq.lambda.Seq<U>
map
in interface java.util.stream.Stream<U>
default LazyFutureStream<org.jooq.lambda.tuple.Tuple2<U,java.lang.Long>> zipFuturesWithIndex()
LazyFutureStream.react(()-gt;takesALotOfTime(),()-gt;veryQuick()).zipWithIndex();
[["takesALotOfTime",0],["veryQuick",1]]
Where as with standard zipWithIndex you would get a new Stream ordered by completion
[["veryQuick",0],["takesALotOfTime",1]]
Care should be taken not to use this method with infinite streams!default org.jooq.lambda.tuple.Tuple2<org.jooq.lambda.Seq<U>,org.jooq.lambda.Seq<U>> duplicateFuturesSeq()
duplicate()
default org.jooq.lambda.tuple.Tuple2<LazyFutureStream<U>,LazyFutureStream<U>> duplicateFutures()
duplicate()
default <R> LazyFutureStream<org.jooq.lambda.tuple.Tuple2<U,R>> zipFutures(java.util.stream.Stream<R> other)
zipFutures
in interface FutureStream<U>
other
- default <R> LazyFutureStream<org.jooq.lambda.tuple.Tuple2<U,R>> zipFutures(FutureStream<R> other)
zipFutures
in interface FutureStream<U>
other
- Another FutureStream to zip Futures withdefault LazyFutureStream<java.util.Collection<U>> chunkSinceLastRead()
chunkSinceLastRead
in interface FutureStream<U>
default <K> java.util.Map<K,LazyFutureStream<U>> shard(java.util.Map<K,Queue<U>> shards, java.util.function.Function<U,K> sharder)
LazyFutureStream.of(10,20,25,30,41,43).shard(ImmutableMap.of("even",new
Queue(),"odd",new Queue(),element-> element%2==0? "even" : "odd");
results in 2 Streams "even": 10,20,30 "odd" : 25,41,43shard
in interface FutureStream<U>
shards
- Map of Queue's keyed by shard identifiersharder
- Function to split split incoming elements into shardsdefault LazyFutureStream<U> debounce(long time, java.util.concurrent.TimeUnit unit)
debounce
in interface FutureStream<U>
time
- Time from which to accept only one elementunit
- Time unit for specified timedefault <T> LazyFutureStream<U> skipUntil(FutureStream<T> s)
skipUntil
in interface FutureStream<U>
s
- Stream that will start the emission of values from this streamdefault <T> LazyFutureStream<U> takeUntil(FutureStream<T> s)
takeUntil
in interface FutureStream<U>
s
- Stream that will stop the emission of values from this streamdefault LazyFutureStream<U> control(java.util.function.Function<java.util.function.Supplier<U>,java.util.function.Supplier<U>> fn)
control
in interface FutureStream<U>
fn
- Function takes a supplier, which can be used repeatedly to get
the next value from the Stream. If there are no more values, a
ClosedQueueException will be thrown. This function should
return a Supplier which returns the desired result for the
next element (or just the next element).default LazyFutureStream<java.util.Collection<U>> batch(java.util.function.Function<java.util.function.Supplier<U>,java.util.function.Supplier<java.util.Collection<U>>> fn)
batch
in interface FutureStream<U>
fn
- Function takes a supplier, which can be used repeatedly to get
the next value from the Stream. If there are no more values, a
ClosedQueueException will be thrown. This function should
return a Supplier which creates a collection of the batched
valuesdefault LazyFutureStream<java.util.Collection<U>> batchBySize(int size)
batchBySize
in interface FutureStream<U>
size
- Size of lists elements should be batched intodefault LazyFutureStream<java.util.Collection<U>> batchBySize(int size, java.util.function.Supplier<java.util.Collection<U>> supplier)
batchBySize
in interface FutureStream<U>
size
- Size of batchsupplier
- Create the batch holding collectiondefault LazyFutureStream<U> jitter(long jitterInNanos)
jitter
in interface FutureStream<U>
jitterInNanos
- Max number of nanos for jitter (random number less than this
will be selected)/default LazyFutureStream<U> fixedDelay(long time, java.util.concurrent.TimeUnit unit)
fixedDelay
in interface FutureStream<U>
time
- amount of time between emissionsunit
- TimeUnit for emissionsdefault LazyFutureStream<U> onePer(long time, java.util.concurrent.TimeUnit unit)
onePer
in interface FutureStream<U>
time
- Frequency period of element emissionunit
- Time unit for frequency perioddefault FutureStream<U> xPer(int x, long time, java.util.concurrent.TimeUnit unit)
xPer
in interface FutureStream<U>
x
- Number of allowable emissions per time periodtime
- Frequency time periodunit
- Frequency time unitdefault LazyFutureStream<java.util.Collection<U>> batchByTime(long time, java.util.concurrent.TimeUnit unit)
batchByTime
in interface FutureStream<U>
time
- Time period during which all elements should be collectedunit
- Time unit during which all elements should be collecteddefault LazyFutureStream<java.util.Collection<U>> batchByTime(long time, java.util.concurrent.TimeUnit unit, java.util.function.Supplier<java.util.Collection<U>> factory)
batchByTime
in interface FutureStream<U>
time
- Time period during which all elements should be collectedunit
- Time unit during which all elements should be collectedfactory
- Instantiates the collections used in the batchingdefault <T> LazyFutureStream<org.jooq.lambda.tuple.Tuple2<U,T>> combineLatest(FutureStream<T> s)
combineLatest
in interface FutureStream<U>
s
- Stream to merge withdefault <T> LazyFutureStream<org.jooq.lambda.tuple.Tuple2<U,T>> withLatest(FutureStream<T> s)
withLatest
in interface FutureStream<U>
s
- Stream to merge with@SafeVarargs static <U> LazyFutureStream<U> firstOf(LazyFutureStream<U>... futureStreams)
futureStreams
- Streams to racedefault <R> LazyFutureStream<R> then(java.util.function.Function<U,R> fn, java.util.concurrent.Executor service)
then
in interface LazyToQueue<U>
then
in interface SimpleReactStream<U>
default <R> LazyFutureStream<R> then(java.util.function.Function<U,R> fn)
then
in interface FutureStream<U>
then
in interface SimpleReactStream<U>
fn
- Function to be applied to the results of the currently active
event tasksdefault LazyFutureStream<U> merge(SimpleReactStream<U> s)
SimpleReactStream
merge
in interface FutureStream<U>
merge
in interface SimpleReactStream<U>
s
- Reactive stage builder to merge withdefault LazyFutureStream<U> onFail(java.util.function.Function<? extends SimpleReactFailedStageException,U> fn)
SimpleReactStream
List<String> strings = new SimpleReact().<Integer, Integer> react(() -> 100, () -> 2, () -> 3)
.then(it -> {
if (it == 100)
throw new RuntimeException("boo!");
return it;
})
.onFail(e -> 1)
.then(it -> "*" + it)
.block();
In this example onFail recovers from the RuntimeException thrown when the
input to the first 'then' stage is 100.onFail
in interface FutureStream<U>
onFail
in interface SimpleReactStream<U>
fn
- Recovery function, the exception is input, and the recovery
value is outputdefault LazyFutureStream<U> onFail(java.lang.Class<? extends java.lang.Throwable> exceptionClass, java.util.function.Function<? extends SimpleReactFailedStageException,U> fn)
SimpleReactStream
onFail(IOException.class, recoveryFunction1)
.onFail(Throwable.class,recovertyFunction2)
For an IOException recoveryFunction1 will be executed
but with the definitions reveresed
onFail(Throwable.class,recovertyFunction2)
.onFail(IOException.class, recoveryFunction1)
recoveryFunction1 will not be calledonFail
in interface FutureStream<U>
onFail
in interface SimpleReactStream<U>
exceptionClass
- Class of exceptions to recover fromfn
- Recovery functiondefault LazyFutureStream<U> capture(java.util.function.Consumer<? extends java.lang.Throwable> errorHandler)
SimpleReactStream
List<String> strings = new SimpleReact().<Integer, Integer> react(() -> 1, () -> 2, () -> 3)
.then(it -> it * 100)
.then(it -> {
if (it == 100)
throw new RuntimeException("boo!");
return it;
})
.onFail(e -> 1)
.then(it -> "*" + it)
.then(it -> {
if ("*200".equals(it))
throw new RuntimeException("boo!");
return it;
})
.capture(e -> logger.error(e.getMessage(),e))
.block();
In this case, strings will only contain the two successful results (for
()->1 and ()->3), an exception for the chain starting from Supplier
()->2 will be logged by capture. Capture will not capture the
exception thrown when an Integer value of 100 is found, but will catch
the exception when the String value "*200" is passed along the chain.capture
in interface FutureStream<U>
capture
in interface SimpleReactStream<U>
errorHandler
- A consumer that recieves and deals with an unrecoverable error
in the dataflowdefault <T,R> LazyFutureStream<R> allOf(java.util.function.Function<java.util.List<T>,R> fn)
SimpleReactStream
boolean blocked[] = {false};
new SimpleReact().<Integer, Integer> react(() -> 1, () -> 2, () -> 3)
.then(it -> {
try {
Thread.sleep(50000);
} catch (Exception e) {
}
blocked[0] =true;
return 10;
})
.allOf( it -> it.size());
assertThat(blocked[0],is(false));
In this example, the current thread will continue and assert that it is
not blocked, allOf could continue and be executed in a separate thread.allOf
in interface FutureStream<U>
allOf
in interface SimpleReactStream<U>
fn
- Function that recieves the results of all currently active
tasks as inputdefault <R> LazyFutureStream<R> anyOf(java.util.function.Function<U,R> fn)
SimpleReactStream
anyOf
in interface FutureStream<U>
anyOf
in interface SimpleReactStream<U>
fn
- Function to apply when any of the previous events completedefault LazyFutureStream<U> peek(java.util.function.Consumer<? super U> consumer)
SimpleReactStream
peek
in interface FutureStream<U>
peek
in interface org.jooq.lambda.Seq<U>
peek
in interface SimpleReactStream<U>
peek
in interface java.util.stream.Stream<U>
consumer
- That will recieve current resultsdefault LazyFutureStream<U> filter(java.util.function.Predicate<? super U> p)
SimpleReactStream
filter
in interface FutureStream<U>
filter
in interface org.jooq.lambda.Seq<U>
filter
in interface SimpleReactStream<U>
filter
in interface java.util.stream.Stream<U>
p
- Predicate that will be used to filter elements from the
dataflowdefault <R> LazyFutureStream<R> flatMap(java.util.function.Function<? super U,? extends java.util.stream.Stream<? extends R>> flatFn)
SimpleReactStream
flatMap
in interface FutureStream<U>
flatMap
in interface org.jooq.lambda.Seq<U>
flatMap
in interface SimpleReactStream<U>
flatMap
in interface java.util.stream.Stream<U>
flatFn
- Function that coverts a value (e.g. a Collection) into a Streamdefault <R> LazyFutureStream<R> retry(java.util.function.Function<U,R> fn)
SimpleReactStream
retry
in interface FutureStream<U>
retry
in interface SimpleReactStream<U>
fn
- Function that will be executed and retried on failuredefault <T,R> LazyFutureStream<R> allOf(java.util.stream.Collector collector, java.util.function.Function<T,R> fn)
allOf
in interface FutureStream<U>
allOf
in interface LazyToQueue<U>
allOf
in interface SimpleReactStream<U>
collector
- to perform aggregation / reduction operation on the results
from active stage (e.g. to Collect into a List or String)fn
- Function that receives the results of all currently active
tasks as inputdefault <R> LazyFutureStream<R> fromStream(java.util.stream.Stream<R> stream)
fromStream
in interface FutureStream<U>
fromStream
in interface SimpleReactStream<U>
default <R> LazyFutureStream<R> fromStreamOfFutures(java.util.stream.Stream<java.util.concurrent.CompletableFuture<R>> stream)
SimpleReactStream
fromStreamOfFutures
in interface FutureStream<U>
fromStreamOfFutures
in interface SimpleReactStream<U>
stream
- JDK Stream to construct new SimpleReactStream fromdefault LazyFutureStream<U> concat(java.util.stream.Stream<U> other)
concat
in interface org.jooq.lambda.Seq<U>
Seq.concat(Stream[])
default <U> LazyFutureStream<U> cast(java.lang.Class<U> type)
cast
in interface FutureStream<U>
cast
in interface org.jooq.lambda.Seq<U>
default <U> FutureStream<U> ofType(java.lang.Class<U> type)
ofType
in interface FutureStream<U>
ofType
in interface org.jooq.lambda.Seq<U>
FutureStream.ofType(java.lang.Class)
default LazyFutureStream<U> intersperse(U value)
// (1, 0, 2, 0, 3, 0, 4)
LazyFutureStream.of(1, 2, 3, 4).intersperse(0)
intersperse
in interface FutureStream<U>
intersperse
in interface org.jooq.lambda.Seq<U>
Seq.intersperse(Stream, Object)
default LazyFutureStream<U> limit(long maxSize)
default LazyFutureStream<U> skip(long n)
static <U> LazyFutureStream<U> parallel(U... array)
array
- Values to react todefault org.jooq.lambda.Seq<U> distinct()
default org.jooq.lambda.tuple.Tuple2<org.jooq.lambda.Seq<U>,org.jooq.lambda.Seq<U>> duplicate()
// tuple((1, 2, 3), (1, 2, 3))
LazyFutureStream.of(1, 2, 3).duplicate()
duplicate
in interface org.jooq.lambda.Seq<U>
Seq.duplicate(Stream)
default org.jooq.lambda.tuple.Tuple2<org.jooq.lambda.Seq<U>,org.jooq.lambda.Seq<U>> partition(java.util.function.Predicate<? super U> predicate)
// tuple((1, 3, 5), (2, 4, 6))
LazyFutureStream.of(1, 2, 3, 4, 5,6).partition(i -> i % 2 != 0)
partition
in interface org.jooq.lambda.Seq<U>
Seq.partition(Stream, Predicate)
default LazyFutureStream<U> slice(long from, long to)
FutureStream
slice
in interface FutureStream<U>
slice
in interface org.jooq.lambda.Seq<U>
Seq.slice(Stream, long, long)
default LazyFutureStream<org.jooq.lambda.tuple.Tuple2<U,java.lang.Long>> zipWithIndex()
// (tuple("a", 0), tuple("b", 1), tuple("c", 2))
LazyFutureStream.of("a","b", "c").zipWithIndex()
zipWithIndex
in interface org.jooq.lambda.Seq<U>
Seq.zipWithIndex(Stream)
default <T> LazyFutureStream<org.jooq.lambda.tuple.Tuple2<U,T>> zip(org.jooq.lambda.Seq<T> other)
// (tuple(1, "a"), tuple(2, "b"), tuple(3, "c"))
Seq.of(1, 2, 3).zip(Seq.of("a", "b", "c"))
zip
in interface org.jooq.lambda.Seq<U>
zip(Stream, Stream)
default <T,R> LazyFutureStream<R> zip(org.jooq.lambda.Seq<T> other, java.util.function.BiFunction<U,T,R> zipper)
BiFunction
to produce resulting
values.
// ("1:a", "2:b", "3:c")
LazyFutureStream.of(1, 2, 3).zip(Seq.of("a", "b", "c"), (i, s) -> i + ":" + s)
zip
in interface org.jooq.lambda.Seq<U>
zip(Seq, BiFunction)
default <T> LazyFutureStream<T> scanLeft(T seed, java.util.function.BiFunction<T,? super U,T> function)
scanLeft
in interface org.jooq.lambda.Seq<U>
default <R> LazyFutureStream<R> scanRight(R seed, java.util.function.BiFunction<? super U,R,R> function)
scanRight
in interface org.jooq.lambda.Seq<U>
default LazyFutureStream<U> reverse()
reverse
in interface FutureStream<U>
reverse
in interface org.jooq.lambda.Seq<U>
default LazyFutureStream<U> shuffle()
shuffle
in interface org.jooq.lambda.Seq<U>
default LazyFutureStream<U> shuffle(java.util.Random random)
shuffle
in interface org.jooq.lambda.Seq<U>
default LazyFutureStream<U> skipWhile(java.util.function.Predicate<? super U> predicate)
skipWhile
in interface org.jooq.lambda.Seq<U>
Seq.skipWhile(Stream, Predicate)
default LazyFutureStream<U> skipUntil(java.util.function.Predicate<? super U> predicate)
skipUntil
in interface org.jooq.lambda.Seq<U>
Seq.skipUntil(Stream, Predicate)
default LazyFutureStream<U> limitWhile(java.util.function.Predicate<? super U> predicate)
limitWhile
in interface org.jooq.lambda.Seq<U>
limitWhile(Stream, Predicate)
default LazyFutureStream<U> limitUntil(java.util.function.Predicate<? super U> predicate)
limitUntil
in interface org.jooq.lambda.Seq<U>
limitUntil(Stream, Predicate)
static <U> LazyFutureStream<U> parallelOf(U... array)
parallelOf
in interface SimpleReactStream<U>
array
- Array of value to form the reactive stream / sequencestatic LazyReact parallelBuilder()
parallelBuilder
in interface SimpleReactStream<U>
SimpleReact.SimpleReact()
static LazyReact parallelBuilder(int parallelism)
parallelBuilder
in interface SimpleReactStream<U>
parallelism
- Number of threads task executor should havestatic LazyReact parallelCommonBuilder()
parallelCommonBuilder
in interface SimpleReactStream<U>
see RetryBuilder#getDefaultInstance()
static LazyReact sequentialBuilder()
sequentialBuilder
in interface SimpleReactStream<U>
static LazyReact sequentialCommonBuilder()
sequentialCommonBuilder
in interface SimpleReactStream<U>
static <T> LazyFutureStream<T> react(java.util.function.Supplier<T> value)
react
in interface SimpleReactStream<U>
Stream.of(Object)
@SafeVarargs static <T> LazyFutureStream<T> react(java.util.function.Supplier<T>... values)
react
in interface SimpleReactStream<U>
Stream.of(Object[])
static <T> LazyFutureStream<T> of(T value)
of
in interface org.jooq.lambda.Seq<U>
of
in interface SimpleReactStream<U>
of
in interface java.util.stream.Stream<U>
Stream.of(Object)
@SafeVarargs static <T> LazyFutureStream<T> of(T... values)
of
in interface org.jooq.lambda.Seq<U>
of
in interface SimpleReactStream<U>
of
in interface java.util.stream.Stream<U>
Stream.of(Object[])
static <T> LazyFutureStream<T> empty()
empty
in interface org.jooq.lambda.Seq<U>
empty
in interface SimpleReactStream<U>
empty
in interface java.util.stream.Stream<U>
Stream.empty()
static <T> LazyFutureStream<T> iterate(T seed, java.util.function.UnaryOperator<T> f)
static LazyFutureStream<java.lang.Void> generate()
generate
in interface org.jooq.lambda.Seq<U>
Stream.generate(Supplier)
static <T> LazyFutureStream<T> generate(T value)
static <T> LazyFutureStream<T> generate(java.util.function.Supplier<T> s)
static <T> LazyFutureStream<T> of(java.util.stream.Stream<T> stream)
of
in interface org.jooq.lambda.Seq<U>
of
in interface SimpleReactStream<U>
of
in interface java.util.stream.Stream<U>
Stream.of(Object)
static <T> LazyFutureStream<T> ofIterable(java.lang.Iterable<T> iterable)
ofIterable
in interface SimpleReactStream<U>
static <T> LazyFutureStream<T> of(java.util.Iterator<T> iterator)
of
in interface org.jooq.lambda.Seq<U>
of
in interface SimpleReactStream<U>
of
in interface java.util.stream.Stream<U>
Stream.of(Object)
static <T1,T2> org.jooq.lambda.Seq<org.jooq.lambda.tuple.Tuple2<T1,T2>> zip(java.util.stream.Stream<T1> left, java.util.stream.Stream<T2> right)
// (tuple(1, "a"), tuple(2, "b"), tuple(3, "c"))
Seq.of(1, 2, 3).zip(Seq.of("a", "b", "c"))
zip
in interface org.jooq.lambda.Seq<U>
static <T1,T2,R> org.jooq.lambda.Seq<R> zip(java.util.stream.Stream<T1> left, java.util.stream.Stream<T2> right, java.util.function.BiFunction<T1,T2,R> zipper)
BiFunction
to produce resulting
values.
// ("1:a", "2:b", "3:c")
Seq.of(1, 2, 3).zip(Seq.of("a", "b", "c"), (i, s) -> i + ":" + s)
zip
in interface org.jooq.lambda.Seq<U>
static void close(java.util.Iterator it)
static <T> org.jooq.lambda.Seq<T> limitWhile(java.util.stream.Stream<T> stream, java.util.function.Predicate<? super T> predicate)
true
.
// (1, 2)
Seq.of(1, 2, 3, 4, 5).limitWhile(i -> i < 3)
limitWhile
in interface org.jooq.lambda.Seq<U>
static <T> org.jooq.lambda.Seq<T> limitUntil(java.util.stream.Stream<T> stream, java.util.function.Predicate<? super T> predicate)
true
.
// (1, 2)
Seq.of(1, 2, 3, 4, 5).limitUntil(i -> i == 3)
limitUntil
in interface org.jooq.lambda.Seq<U>
default java.util.stream.Stream<U> stream()
stream
in interface FutureStream<U>
stream
in interface org.jooq.lambda.Seq<U>
default LazyFutureStream<U> parallel()
default LazyFutureStream<U> sequential()
sequential
in interface java.util.stream.BaseStream<U,java.util.stream.Stream<U>>
sequential
in interface FutureStream<U>
sequential
in interface org.jooq.lambda.Seq<U>
default LazyFutureStream<U> unordered()
default LazyFutureStream<U> onClose(java.lang.Runnable closeHandler)
default LazyFutureStream<U> sorted()
sorted
in interface FutureStream<U>
sorted
in interface org.jooq.lambda.Seq<U>
sorted
in interface java.util.stream.Stream<U>
default LazyFutureStream<U> sorted(java.util.Comparator<? super U> comparator)
sorted
in interface FutureStream<U>
sorted
in interface org.jooq.lambda.Seq<U>
sorted
in interface java.util.stream.Stream<U>
default LazyFutureStream<U> self(java.util.function.Consumer<FutureStream<U>> consumer)
self
in interface FutureStream<U>
consumer
- Consumer that will recieve current stageLazyFutureStream<U> withParallelReduction(ParallelReductionConfig parallelReductionConfig)