@Test public void loopIterationWithLimit() throws ExecutionException, InterruptedException { FDBStoreTimer timer = new FDBStoreTimer(); FirableCursor<Integer> secondCursor = new FirableCursor<>(RecordCursor.fromList(Arrays.asList(3, 4))); RecordCursor<Integer> cursor = UnorderedUnionCursor.create(Arrays.asList( continuation -> RecordCursor.fromList(Arrays.asList(1, 2), continuation).limitRowsTo(1), continuation -> secondCursor ), null, timer); RecordCursorResult<Integer> cursorResult = cursor.getNext(); assertEquals(1, (int)cursorResult.get()); CompletableFuture<RecordCursorResult<Integer>> cursorResultFuture = cursor.onNext(); assertFalse(cursorResultFuture.isDone()); secondCursor.fire(); cursorResult = cursorResultFuture.get(); assertEquals(3, (int)cursorResult.get()); cursorResultFuture = cursor.onNext(); assertFalse(cursorResultFuture.isDone()); secondCursor.fire(); cursorResult = cursorResultFuture.get(); assertEquals(4, (int)cursorResult.get()); cursorResultFuture = cursor.onNext(); assertFalse(cursorResultFuture.isDone()); secondCursor.fire(); cursorResult = cursorResultFuture.get(); assertFalse(cursorResult.hasNext()); assertEquals(RecordCursor.NoNextReason.RETURN_LIMIT_REACHED, cursorResult.getNoNextReason()); assertThat(timer.getCount(FDBStoreTimer.Events.QUERY_INTERSECTION), lessThanOrEqualTo(5)); }
@Nonnull public static <T> UnorderedUnionCursor<T> create( @Nonnull List<Function<byte[], RecordCursor<T>>> cursorFunctions, @Nullable byte[] continuation, @Nullable FDBStoreTimer timer) { return new UnorderedUnionCursor<>(createCursorStates(cursorFunctions, continuation), timer); }
UnorderedUnionCursor extends UnionCursorBase<T, MergeCursorState<T>> { @Nonnull public static <T> UnorderedUnionCursor<T> create( @Nonnull List<Function<byte[], RecordCursor<T>>> cursorFunctions, @Nullable byte[] continuation, @Nullable FDBStoreTimer timer) { return new UnorderedUnionCursor<>(createCursorStates(cursorFunctions, continuation), timer); } }
UnorderedUnionCursor extends UnionCursorBase<T, MergeCursorState<T>> { @Nonnull public static <T> UnorderedUnionCursor<T> create( @Nonnull List<Function<byte[], RecordCursor<T>>> cursorFunctions, @Nullable byte[] continuation, @Nullable FDBStoreTimer timer) { return new UnorderedUnionCursor<>(createCursorStates(cursorFunctions, continuation), timer); } protected  UnorderedUnionCursor(@Nonnull List<MergeCursorState<T>> cursorStates,
                                   @Nullable FDBStoreTimer timer); }
UnorderedUnionCursor extends UnionCursorBase<T, MergeCursorState<T>> { @Nonnull public static <T> UnorderedUnionCursor<T> create( @Nonnull List<Function<byte[], RecordCursor<T>>> cursorFunctions, @Nullable byte[] continuation, @Nullable FDBStoreTimer timer) { return new UnorderedUnionCursor<>(createCursorStates(cursorFunctions, continuation), timer); } protected  UnorderedUnionCursor(@Nonnull List<MergeCursorState<T>> cursorStates,
                                   @Nullable FDBStoreTimer timer); @Nonnull static UnorderedUnionCursor<T> create(
            @Nonnull List<Function<byte[], RecordCursor<T>>> cursorFunctions,
            @Nullable byte[] continuation,
            @Nullable FDBStoreTimer timer); }
UnorderedUnionCursor extends UnionCursorBase<T, MergeCursorState<T>> { @Nonnull public static <T> UnorderedUnionCursor<T> create( @Nonnull List<Function<byte[], RecordCursor<T>>> cursorFunctions, @Nullable byte[] continuation, @Nullable FDBStoreTimer timer) { return new UnorderedUnionCursor<>(createCursorStates(cursorFunctions, continuation), timer); } protected  UnorderedUnionCursor(@Nonnull List<MergeCursorState<T>> cursorStates,
                                   @Nullable FDBStoreTimer timer); @Nonnull static UnorderedUnionCursor<T> create(
            @Nonnull List<Function<byte[], RecordCursor<T>>> cursorFunctions,
            @Nullable byte[] continuation,
            @Nullable FDBStoreTimer timer);  }