default Flowable<T> streamData(C concept, Range<Long> range) { Flowable<T> result = createPaginator(concept).apply(range); return result; }
@Override public Single<Range<Long>> fetchCount(Long itemLimit, Long rowLimit) { Single<Range<Long>> result = base.fetchCount(itemLimit, rowLimit); return result; } }
Stream<Entry<Node, Node>> rawItems = paginator.fetchList(requestRange).stream();
Stream<Entry<Node, Node>> rawItems = paginator.fetchList(requestRange).stream();
@Override public Flowable<List<I>> apply(Range<Long> range) { Range<Long> newRange = RangeUtils.multiplyByPageSize(range, batchSize); Flowable<I> in = base.apply(newRange); Flowable<List<I>> result = in.buffer((int)batchSize); //Stream<List<I>> result = StreamUtils.mapToBatch(in, (int)batchSize); return result; }
@Override public Single<Range<Long>> fetchCount(Long itemLimit, Long rowLimit) { return base.fetchCount(itemLimit, rowLimit).map(countInfo -> { long baseCount = countInfo.lowerEndpoint(); long n = (baseCount + batchSize - 1) / batchSize; // TODO We silently assume the range to be a singleton if is has an upperBound // TODO Add a method that correctly captures the corner cases to RangeUtils. Range<Long> result = countInfo.hasUpperBound() ? Range.singleton(n) : Range.atLeast(n); //CountInfo result = new CountInfo(n, countInfo.isHasMoreItems(), itemLimit); return result; }); }
default List<T> fetchList(Range<Long> range) { List<T> result = apply(range).toList().blockingGet(); //.collect(Collectors.toList()); return result; }
@Override public Flowable<O> apply(Range<Long> range) { Flowable<I> baseInStream = base.apply(range); Flowable<O> result = baseInStream.buffer(batchSize).flatMap(batch -> { // Map<I, O> map Flowable<O> r = lookup.apply(batch).map(Entry::getValue); return r; }); // Stream<O> result = StreamUtils.mapToBatch(baseInStream, batchSize) // .flatMap(batch -> { // Map<I, O> map = lookup.apply(batch); // Collection<O> values = map.values(); // // return values.stream(); // }); return result; }