Package org.aksw.jena_sparql_api.rx
Class FlowableTransformerLocalOrderingOld<T,S>
java.lang.Object
org.aksw.jena_sparql_api.rx.FlowableTransformerLocalOrderingOld<T,S>
- Type Parameters:
T-S-
- All Implemented Interfaces:
io.reactivex.rxjava3.core.Emitter<T>
public class FlowableTransformerLocalOrderingOld<T,S>
extends Object
implements io.reactivex.rxjava3.core.Emitter<T>
USE OperatorLocalOrder
A subscriber that performs local ordering of the items by their sequence id.
Local ordering means, that ordering is accomplished in a streaming fashion
without the need of a global view of *all* items.
This is the case when items arrive "mostly" sequentially, with some "outliers" arriving out of order,
as it can happen e.g. due to network delay.
This implementation uses a 'extractSeqId' lambda to obtain an item's sequence id,
and 'incrementSeqId' in order to find out next id to expect.
This class then caches all arriving items in memory until
an item with the expected id arrives. In this case that item and all consecutive
ones are emitted and removed from the cache.
Example Usage:
flowable
.zipWith(() -> LongStream.iterate(0, i -> i + 1).iterator(), Maps::immutableEntry)
.map(...)
.compose(FlowableTransformerLocalOrdering.transformer(0l, i -> i + 1, Entry::getValue))
- Author:
- raven May 12, 2018
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected io.reactivex.rxjava3.core.FlowableEmitter<? super T>protected BiFunction<? super S,? super S, ? extends Number> protected Sprotected booleanprotected NavigableMap<S,T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> io.reactivex.rxjava3.core.Emitter<T>forLong(long initiallyExpectedId, Function<? super T, ? extends Long> extractSeqId, io.reactivex.rxjava3.core.FlowableEmitter<? super T> delegate) voidvoidvoidstatic <T,S extends Comparable<S>>
io.reactivex.rxjava3.core.FlowableTransformer<T,T> transformer(S initiallyExpectedId, Function<? super S, ? extends S> incrementSeqId, BiFunction<? super S, ? super S, ? extends Number> distanceFn, Function<? super T, ? extends S> extractSeqId) static <T,S extends Comparable<S>>
FlowableTransformerLocalOrderingOld<T,S> wrap(S initiallyExpectedId, Function<? super S, ? extends S> incrementSeqId, BiFunction<? super S, ? super S, ? extends Number> distanceFn, Function<? super T, ? extends S> extractSeqId, io.reactivex.rxjava3.core.FlowableEmitter<? super T> delegate)
-
Field Details
-
delegate
-
extractSeqId
-
incrementSeqId
-
distanceFn
-
expectedSeqId
-
isComplete
protected boolean isComplete -
seqIdToValue
-
-
Constructor Details
-
FlowableTransformerLocalOrderingOld
-
-
Method Details
-
onError
- Specified by:
onErrorin interfaceio.reactivex.rxjava3.core.Emitter<T>
-
onComplete
public void onComplete()- Specified by:
onCompletein interfaceio.reactivex.rxjava3.core.Emitter<T>
-
onNext
- Specified by:
onNextin interfaceio.reactivex.rxjava3.core.Emitter<T>
-
forLong
-
wrap
public static <T,S extends Comparable<S>> FlowableTransformerLocalOrderingOld<T,S> wrap(S initiallyExpectedId, Function<? super S, ? extends S> incrementSeqId, BiFunction<? super S, ? super S, ? extends Number> distanceFn, Function<? super T, ? extends S> extractSeqId, io.reactivex.rxjava3.core.FlowableEmitter<? super T> delegate) -
transformer
public static <T,S extends Comparable<S>> io.reactivex.rxjava3.core.FlowableTransformer<T,T> transformer(S initiallyExpectedId, Function<? super S, ? extends S> incrementSeqId, BiFunction<? super S, ? super S, ? extends Number> distanceFn, Function<? super T, ? extends S> extractSeqId)
-