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 Details

    • delegate

      protected io.reactivex.rxjava3.core.FlowableEmitter<? super T> delegate
    • extractSeqId

      protected Function<? super T,? extends S> extractSeqId
    • incrementSeqId

      protected Function<? super S,? extends S> incrementSeqId
    • distanceFn

      protected BiFunction<? super S,? super S,? extends Number> distanceFn
    • expectedSeqId

      protected S expectedSeqId
    • isComplete

      protected boolean isComplete
    • seqIdToValue

      protected NavigableMap<S,T> seqIdToValue
  • Constructor Details

    • FlowableTransformerLocalOrderingOld

      public FlowableTransformerLocalOrderingOld(S expectedSeqId, 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)
  • Method Details

    • onError

      public void onError(Throwable throwable)
      Specified by:
      onError in interface io.reactivex.rxjava3.core.Emitter<T>
    • onComplete

      public void onComplete()
      Specified by:
      onComplete in interface io.reactivex.rxjava3.core.Emitter<T>
    • onNext

      public void onNext(T value)
      Specified by:
      onNext in interface io.reactivex.rxjava3.core.Emitter<T>
    • forLong

      public static <T> io.reactivex.rxjava3.core.Emitter<T> forLong(long initiallyExpectedId, Function<? super T,? extends Long> extractSeqId, io.reactivex.rxjava3.core.FlowableEmitter<? super T> delegate)
    • 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)