@Test public void limiterWithLookahead() { fdb.run(context -> { RecordScanLimiter limiter = RecordScanLimiterFactory.enforce(1); KeyValueCursor kvCursor = KeyValueCursor.Builder.withSubspace(subspace) .setContext(context) .setLow(Tuple.from(3, 3), EndpointType.RANGE_EXCLUSIVE) .setHigh(Tuple.from(4, 2), EndpointType.RANGE_EXCLUSIVE) .setScanProperties(forwardScanWithLimiter(limiter)) .build(); RecordCursor<KeyValue> cursor = kvCursor.skip(2); RecordCursorResult<KeyValue> result = cursor.getNext(); assertThat("skipped items should exhaust limit", result.hasNext(), is(false)); assertThat("no next reason should be SCAN_LIMIT_REACHED", result.getNoNextReason(), equalTo(RecordCursor.NoNextReason.SCAN_LIMIT_REACHED)); return null; }); }
@Override @Nonnull public RecordCursorResult<KeyValue> getNext() { return context.asyncToSync(FDBStoreTimer.Waits.WAIT_ADVANCE_CURSOR, onNext()); }
KeyValueCursor extends AsyncIteratorCursor<KeyValue> implements BaseCursor<KeyValue> { @Override @Nonnull public RecordCursorResult<KeyValue> getNext() { return context.asyncToSync(FDBStoreTimer.Waits.WAIT_ADVANCE_CURSOR, onNext()); } }
KeyValueCursor extends AsyncIteratorCursor<KeyValue> implements BaseCursor<KeyValue> { @Override @Nonnull public RecordCursorResult<KeyValue> getNext() { return context.asyncToSync(FDBStoreTimer.Waits.WAIT_ADVANCE_CURSOR, onNext()); } private  KeyValueCursor(@Nonnull final FDBRecordContext context,
                           @Nonnull final AsyncIterator<KeyValue> iterator,
                           int prefixLength,
                           @Nonnull final CursorLimitManager limitManager,
                           int valuesLimit); }
KeyValueCursor extends AsyncIteratorCursor<KeyValue> implements BaseCursor<KeyValue> { @Override @Nonnull public RecordCursorResult<KeyValue> getNext() { return context.asyncToSync(FDBStoreTimer.Waits.WAIT_ADVANCE_CURSOR, onNext()); } private  KeyValueCursor(@Nonnull final FDBRecordContext context,
                           @Nonnull final AsyncIterator<KeyValue> iterator,
                           int prefixLength,
                           @Nonnull final CursorLimitManager limitManager,
                           int valuesLimit); @Nonnull @Override CompletableFuture<RecordCursorResult<KeyValue>> onNext(); @Override @Nonnull RecordCursorResult<KeyValue> getNext(); }
KeyValueCursor extends AsyncIteratorCursor<KeyValue> implements BaseCursor<KeyValue> { @Override @Nonnull public RecordCursorResult<KeyValue> getNext() { return context.asyncToSync(FDBStoreTimer.Waits.WAIT_ADVANCE_CURSOR, onNext()); } private  KeyValueCursor(@Nonnull final FDBRecordContext context,
                           @Nonnull final AsyncIterator<KeyValue> iterator,
                           int prefixLength,
                           @Nonnull final CursorLimitManager limitManager,
                           int valuesLimit); @Nonnull @Override CompletableFuture<RecordCursorResult<KeyValue>> onNext(); @Override @Nonnull RecordCursorResult<KeyValue> getNext();  }