@Test public void innerLimitReasons() throws ExecutionException, InterruptedException { List<FirableCursor<Integer>> cursors = Arrays.asList( new FirableCursor<>(RecordCursor.fromList(Arrays.asList(0, 1)).limitRowsTo(1)), new FirableCursor<>(RecordCursor.fromList(Arrays.asList(3, 4))) ); RecordCursorIterator<Integer> cursor = UnorderedUnionCursor.create(functionsFromCursors(cursors), null, null).asIterator(); cursors.get(0).fireAll(); assertEquals(0, (int)cursor.next()); cursors.get(1).fire(); assertEquals(3, (int)cursor.next()); cursors.get(1).fire(); assertEquals(4, (int)cursor.next()); cursors.get(1).fire(); assertThat(cursor.hasNext(), is(false)); assertEquals(RecordCursor.NoNextReason.RETURN_LIMIT_REACHED, cursor.getNoNextReason()); cursors = Arrays.asList( new FirableCursor<>(RecordCursor.fromList(Arrays.asList(0, 1)).limitRowsTo(1)), new FirableCursor<>(RecordCursor.fromList(Arrays.asList(3, 4))) ); cursor = UnorderedUnionCursor.create(functionsFromCursors(cursors), null, null).asIterator(); cursors.get(1).fire(); assertEquals(3, (int)cursor.next()); cursors.get(0).fireAll(); assertEquals(0, (int)cursor.next()); cursors.get(1).fire(); assertEquals(4, (int)cursor.next()); cursors.get(1).fire(); assertThat(cursor.hasNext(), is(false)); assertEquals(RecordCursor.NoNextReason.RETURN_LIMIT_REACHED, cursor.getNoNextReason()); cursors = Arrays.asList( new FirableCursor<>(RecordCursor.fromList(Arrays.asList(0, 1)).limitRowsTo(1)), new FirableCursor<>(RecordCursor.fromList(Collections.singletonList(3))) ); cursor = UnorderedUnionCursor.create(functionsFromCursors(cursors), null, null).asIterator(); cursors.get(1).fire(); assertEquals(3, (int)cursor.next()); cursors.get(0).fireAll(); cursors.get(1).fireAll(); assertEquals(0, (int)cursor.next()); assertThat(cursor.hasNext(), is(false)); assertEquals(RecordCursor.NoNextReason.RETURN_LIMIT_REACHED, cursor.getNoNextReason()); cursors = Arrays.asList( new FirableCursor<>(RecordCursor.fromList(Arrays.asList(0, 1)).limitRowsTo(1)), new FirableCursor<>(new RecordCursorTest.FakeOutOfBandCursor<>(RecordCursor.fromList(Arrays.asList(3, 4)), 1, RecordCursor.NoNextReason.SCAN_LIMIT_REACHED)) ); cursor = UnorderedUnionCursor.create(functionsFromCursors(cursors), null, null).asIterator(); cursors.get(1).fire(); assertEquals(3, (int)cursor.next()); cursors.get(0).fireAll(); assertEquals(0, (int)cursor.next()); cursors.get(1).fireAll(); assertThat(cursor.hasNext(), is(false)); assertEquals(RecordCursor.NoNextReason.SCAN_LIMIT_REACHED, cursor.getNoNextReason()); }
@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);  }