Search in sources :

Example 41 with RecordCursor

use of com.apple.foundationdb.record.RecordCursor in project fdb-record-layer by FoundationDB.

the class UnionIntersectionTest method intersectionMultiReasons.

@Test
public void intersectionMultiReasons() throws Exception {
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> first = continuation -> scanRecordsBetween(10L, 20L, continuation);
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> firstLimited = first.andThen(cursor -> new RecordCursorTest.FakeOutOfBandCursor<>(cursor, 3));
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> second = continuation -> scanRecordsBetween(12L, 17L, continuation);
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> secondLimited = second.andThen(cursor -> new RecordCursorTest.FakeOutOfBandCursor<>(cursor, 2));
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> third = continuation -> scanRecordsBetween(13L, 21L, continuation);
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> thirdLimited = third.andThen(cursor -> cursor.limitRowsTo(2));
    try (FDBRecordContext context = openContext()) {
        openSimpleRecordStore(context);
        RecordCursor<FDBStoredRecord<Message>> cursor = IntersectionCursor.create(recordStore, comparisonKey, false, Arrays.asList(firstLimited, second, third), null);
        assertEquals(Collections.emptyList(), cursor.map(this::storedRecordRecNo).asList().get());
        RecordCursorResult<FDBStoredRecord<Message>> noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.TIME_LIMIT_REACHED, noNextResult.getNoNextReason());
        cursor = IntersectionCursor.create(recordStore, comparisonKey, false, Arrays.asList(firstLimited, secondLimited, thirdLimited), noNextResult.getContinuation().toBytes());
        assertEquals(Arrays.asList(13L, 14L), cursor.map(this::storedRecordRecNo).asList().get());
        noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.RETURN_LIMIT_REACHED, noNextResult.getNoNextReason());
        cursor = IntersectionCursor.create(recordStore, comparisonKey, false, Arrays.asList(firstLimited, second, thirdLimited), noNextResult.getContinuation().toBytes());
        assertEquals(Arrays.asList(15L, 16L), cursor.map(this::storedRecordRecNo).asList().get());
        noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.SOURCE_EXHAUSTED, noNextResult.getNoNextReason());
    }
}
Also used : IndexEntry(com.apple.foundationdb.record.IndexEntry) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) FDBRecord(com.apple.foundationdb.record.provider.foundationdb.FDBRecord) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) Function(java.util.function.Function) ArrayList(java.util.ArrayList) ExecuteProperties(com.apple.foundationdb.record.ExecuteProperties) IndexScanType(com.apple.foundationdb.record.IndexScanType) Tuple(com.apple.foundationdb.tuple.Tuple) RecordCursorResult(com.apple.foundationdb.record.RecordCursorResult) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) EndpointType(com.apple.foundationdb.record.EndpointType) ScanProperties(com.apple.foundationdb.record.ScanProperties) PipelineOperation(com.apple.foundationdb.record.PipelineOperation) RecordCursorIterator(com.apple.foundationdb.record.RecordCursorIterator) Tag(org.junit.jupiter.api.Tag) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) FDBStoredRecord(com.apple.foundationdb.record.provider.foundationdb.FDBStoredRecord) ValueSource(org.junit.jupiter.params.provider.ValueSource) KeyExpression(com.apple.foundationdb.record.metadata.expressions.KeyExpression) LongStream(java.util.stream.LongStream) TestRecords1Proto(com.apple.foundationdb.record.TestRecords1Proto) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) Tags(com.apple.test.Tags) ScanComparisons(com.apple.foundationdb.record.query.plan.ScanComparisons) Collectors(java.util.stream.Collectors) TupleRange(com.apple.foundationdb.record.TupleRange) FDBRecordStoreTestBase(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreTestBase) Test(org.junit.jupiter.api.Test) PrimitiveIterator(java.util.PrimitiveIterator) Comparisons(com.apple.foundationdb.record.query.expressions.Comparisons) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) List(java.util.List) Index(com.apple.foundationdb.record.metadata.Index) TestHelpers.assertDiscardedAtMost(com.apple.foundationdb.record.TestHelpers.assertDiscardedAtMost) TupleHelpers(com.apple.foundationdb.tuple.TupleHelpers) Message(com.google.protobuf.Message) RecordCursor(com.apple.foundationdb.record.RecordCursor) RecordCursorTest(com.apple.foundationdb.record.RecordCursorTest) Collections(java.util.Collections) RecordCursor(com.apple.foundationdb.record.RecordCursor) RecordCursorTest(com.apple.foundationdb.record.RecordCursorTest) Message(com.google.protobuf.Message) FDBStoredRecord(com.apple.foundationdb.record.provider.foundationdb.FDBStoredRecord) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) RecordCursorTest(com.apple.foundationdb.record.RecordCursorTest)

Example 42 with RecordCursor

use of com.apple.foundationdb.record.RecordCursor in project fdb-record-layer by FoundationDB.

the class UnionIntersectionTest method nonIntersectingReasons.

@Test
public void nonIntersectingReasons() {
    final List<Integer> leftList = Arrays.asList(0, 2, 4, 6);
    final Function<byte[], RecordCursor<Integer>> left = continuation -> RecordCursor.fromList(leftList, continuation).limitRowsTo(1);
    final List<Integer> rightList = Arrays.asList(1, 3, 5, 7);
    final Function<byte[], RecordCursor<Integer>> right = continuation -> RecordCursor.fromList(rightList, continuation).limitRowsTo(1);
    FDBStoreTimer timer = new FDBStoreTimer();
    boolean done = false;
    byte[] continuation = null;
    List<Integer> results = new ArrayList<>();
    while (!done) {
        IntersectionCursor<Integer> intersectionCursor = IntersectionCursor.create(Collections::singletonList, false, left, right, continuation, timer);
        intersectionCursor.forEach(results::add).join();
        RecordCursorResult<Integer> noNextResult = intersectionCursor.getNext();
        done = noNextResult.getNoNextReason().isSourceExhausted();
        continuation = noNextResult.getContinuation().toBytes();
        if (!done) {
            assertEquals(RecordCursor.NoNextReason.RETURN_LIMIT_REACHED, noNextResult.getNoNextReason());
        }
    }
    assertEquals(Collections.emptyList(), results);
    System.out.println(timer.getKeysAndValues());
}
Also used : IndexEntry(com.apple.foundationdb.record.IndexEntry) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) FDBRecord(com.apple.foundationdb.record.provider.foundationdb.FDBRecord) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) Function(java.util.function.Function) ArrayList(java.util.ArrayList) ExecuteProperties(com.apple.foundationdb.record.ExecuteProperties) IndexScanType(com.apple.foundationdb.record.IndexScanType) Tuple(com.apple.foundationdb.tuple.Tuple) RecordCursorResult(com.apple.foundationdb.record.RecordCursorResult) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) EndpointType(com.apple.foundationdb.record.EndpointType) ScanProperties(com.apple.foundationdb.record.ScanProperties) PipelineOperation(com.apple.foundationdb.record.PipelineOperation) RecordCursorIterator(com.apple.foundationdb.record.RecordCursorIterator) Tag(org.junit.jupiter.api.Tag) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) FDBStoredRecord(com.apple.foundationdb.record.provider.foundationdb.FDBStoredRecord) ValueSource(org.junit.jupiter.params.provider.ValueSource) KeyExpression(com.apple.foundationdb.record.metadata.expressions.KeyExpression) LongStream(java.util.stream.LongStream) TestRecords1Proto(com.apple.foundationdb.record.TestRecords1Proto) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) Tags(com.apple.test.Tags) ScanComparisons(com.apple.foundationdb.record.query.plan.ScanComparisons) Collectors(java.util.stream.Collectors) TupleRange(com.apple.foundationdb.record.TupleRange) FDBRecordStoreTestBase(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreTestBase) Test(org.junit.jupiter.api.Test) PrimitiveIterator(java.util.PrimitiveIterator) Comparisons(com.apple.foundationdb.record.query.expressions.Comparisons) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) List(java.util.List) Index(com.apple.foundationdb.record.metadata.Index) TestHelpers.assertDiscardedAtMost(com.apple.foundationdb.record.TestHelpers.assertDiscardedAtMost) TupleHelpers(com.apple.foundationdb.tuple.TupleHelpers) Message(com.google.protobuf.Message) RecordCursor(com.apple.foundationdb.record.RecordCursor) RecordCursorTest(com.apple.foundationdb.record.RecordCursorTest) Collections(java.util.Collections) RecordCursor(com.apple.foundationdb.record.RecordCursor) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) ArrayList(java.util.ArrayList) Collections(java.util.Collections) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) RecordCursorTest(com.apple.foundationdb.record.RecordCursorTest)

Example 43 with RecordCursor

use of com.apple.foundationdb.record.RecordCursor in project fdb-record-layer by FoundationDB.

the class UnionIntersectionTest method unionReasons.

// Union / intersection merges need to pause whenever either side hits an out-of-band reason for stopping.
@Test
public void unionReasons() throws Exception {
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> left = continuation -> scanRecordsBetween(10L, 20L, continuation);
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> leftLimited = left.andThen(cursor -> new RecordCursorTest.FakeOutOfBandCursor<>(cursor, 3));
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> right = continuation -> scanRecordsBetween(12L, 15L, continuation);
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> rightLimited = right.andThen(cursor -> new RecordCursorTest.FakeOutOfBandCursor<>(cursor, 2));
    try (FDBRecordContext context = openContext()) {
        openSimpleRecordStore(context);
        RecordCursor<FDBStoredRecord<Message>> cursor = UnionCursor.create(recordStore, comparisonKey, false, leftLimited, right, null);
        assertEquals(Arrays.asList(10L, 11L, 12L), cursor.map(this::storedRecordRecNo).asList().get());
        RecordCursorResult<FDBStoredRecord<Message>> noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.TIME_LIMIT_REACHED, noNextResult.getNoNextReason());
        cursor = UnionCursor.create(recordStore, comparisonKey, false, left, rightLimited, noNextResult.getContinuation().toBytes());
        assertEquals(Arrays.asList(13L, 14L), cursor.map(this::storedRecordRecNo).asList().get());
        noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.TIME_LIMIT_REACHED, noNextResult.getNoNextReason());
        cursor = UnionCursor.create(recordStore, comparisonKey, false, leftLimited, rightLimited, noNextResult.getContinuation().toBytes());
        assertEquals(Arrays.asList(15L, 16L, 17L), cursor.map(this::storedRecordRecNo).asList().get());
        noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.TIME_LIMIT_REACHED, noNextResult.getNoNextReason());
        cursor = UnionCursor.create(recordStore, comparisonKey, false, leftLimited, rightLimited, noNextResult.getContinuation().toBytes());
        assertEquals(Arrays.asList(18L, 19L), cursor.map(this::storedRecordRecNo).asList().get());
        noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.SOURCE_EXHAUSTED, noNextResult.getNoNextReason());
    }
}
Also used : IndexEntry(com.apple.foundationdb.record.IndexEntry) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) FDBRecord(com.apple.foundationdb.record.provider.foundationdb.FDBRecord) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) Function(java.util.function.Function) ArrayList(java.util.ArrayList) ExecuteProperties(com.apple.foundationdb.record.ExecuteProperties) IndexScanType(com.apple.foundationdb.record.IndexScanType) Tuple(com.apple.foundationdb.tuple.Tuple) RecordCursorResult(com.apple.foundationdb.record.RecordCursorResult) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) EndpointType(com.apple.foundationdb.record.EndpointType) ScanProperties(com.apple.foundationdb.record.ScanProperties) PipelineOperation(com.apple.foundationdb.record.PipelineOperation) RecordCursorIterator(com.apple.foundationdb.record.RecordCursorIterator) Tag(org.junit.jupiter.api.Tag) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) FDBStoredRecord(com.apple.foundationdb.record.provider.foundationdb.FDBStoredRecord) ValueSource(org.junit.jupiter.params.provider.ValueSource) KeyExpression(com.apple.foundationdb.record.metadata.expressions.KeyExpression) LongStream(java.util.stream.LongStream) TestRecords1Proto(com.apple.foundationdb.record.TestRecords1Proto) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) Tags(com.apple.test.Tags) ScanComparisons(com.apple.foundationdb.record.query.plan.ScanComparisons) Collectors(java.util.stream.Collectors) TupleRange(com.apple.foundationdb.record.TupleRange) FDBRecordStoreTestBase(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreTestBase) Test(org.junit.jupiter.api.Test) PrimitiveIterator(java.util.PrimitiveIterator) Comparisons(com.apple.foundationdb.record.query.expressions.Comparisons) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) List(java.util.List) Index(com.apple.foundationdb.record.metadata.Index) TestHelpers.assertDiscardedAtMost(com.apple.foundationdb.record.TestHelpers.assertDiscardedAtMost) TupleHelpers(com.apple.foundationdb.tuple.TupleHelpers) Message(com.google.protobuf.Message) RecordCursor(com.apple.foundationdb.record.RecordCursor) RecordCursorTest(com.apple.foundationdb.record.RecordCursorTest) Collections(java.util.Collections) RecordCursor(com.apple.foundationdb.record.RecordCursor) RecordCursorTest(com.apple.foundationdb.record.RecordCursorTest) Message(com.google.protobuf.Message) FDBStoredRecord(com.apple.foundationdb.record.provider.foundationdb.FDBStoredRecord) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) RecordCursorTest(com.apple.foundationdb.record.RecordCursorTest)

Example 44 with RecordCursor

use of com.apple.foundationdb.record.RecordCursor in project fdb-record-layer by FoundationDB.

the class UnionIntersectionTest method unionMultiReasons.

@Test
public void unionMultiReasons() throws Exception {
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> first = continuation -> scanRecordsBetween(10L, 20L, continuation);
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> firstLimited = first.andThen(cursor -> new RecordCursorTest.FakeOutOfBandCursor<>(cursor, 3));
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> second = continuation -> scanRecordsBetween(12L, 15L, continuation);
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> secondLimited = second.andThen(cursor -> new RecordCursorTest.FakeOutOfBandCursor<>(cursor, 2));
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> third = continuation -> scanRecordsBetween(16L, 21L, continuation);
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> thirdLimited = third.andThen(cursor -> cursor.limitRowsTo(2));
    try (FDBRecordContext context = openContext()) {
        openSimpleRecordStore(context);
        RecordCursor<FDBStoredRecord<Message>> cursor = UnionCursor.create(recordStore, comparisonKey, false, Arrays.asList(firstLimited, second, thirdLimited), null);
        assertEquals(Arrays.asList(10L, 11L, 12L), cursor.map(this::storedRecordRecNo).asList().get());
        RecordCursorResult<FDBStoredRecord<Message>> noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.TIME_LIMIT_REACHED, noNextResult.getNoNextReason());
        cursor = UnionCursor.create(recordStore, comparisonKey, false, Arrays.asList(first, secondLimited, thirdLimited), noNextResult.getContinuation().toBytes());
        assertEquals(Arrays.asList(13L, 14L), cursor.map(this::storedRecordRecNo).asList().get());
        noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.TIME_LIMIT_REACHED, noNextResult.getNoNextReason());
        cursor = UnionCursor.create(recordStore, comparisonKey, false, Arrays.asList(firstLimited, secondLimited, thirdLimited), noNextResult.getContinuation().toBytes());
        assertEquals(Arrays.asList(15L, 16L, 17L), cursor.map(this::storedRecordRecNo).asList().get());
        noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.TIME_LIMIT_REACHED, noNextResult.getNoNextReason());
        cursor = UnionCursor.create(recordStore, comparisonKey, false, Arrays.asList(firstLimited, secondLimited, thirdLimited), noNextResult.getContinuation().toBytes());
        assertEquals(Arrays.asList(18L, 19L), cursor.map(this::storedRecordRecNo).asList().get());
        noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.RETURN_LIMIT_REACHED, noNextResult.getNoNextReason());
        cursor = UnionCursor.create(recordStore, comparisonKey, false, Arrays.asList(firstLimited, secondLimited, thirdLimited), noNextResult.getContinuation().toBytes());
        assertEquals(Collections.singletonList(20L), cursor.map(this::storedRecordRecNo).asList().get());
        noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.SOURCE_EXHAUSTED, noNextResult.getNoNextReason());
    }
}
Also used : IndexEntry(com.apple.foundationdb.record.IndexEntry) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) FDBRecord(com.apple.foundationdb.record.provider.foundationdb.FDBRecord) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) Function(java.util.function.Function) ArrayList(java.util.ArrayList) ExecuteProperties(com.apple.foundationdb.record.ExecuteProperties) IndexScanType(com.apple.foundationdb.record.IndexScanType) Tuple(com.apple.foundationdb.tuple.Tuple) RecordCursorResult(com.apple.foundationdb.record.RecordCursorResult) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) EndpointType(com.apple.foundationdb.record.EndpointType) ScanProperties(com.apple.foundationdb.record.ScanProperties) PipelineOperation(com.apple.foundationdb.record.PipelineOperation) RecordCursorIterator(com.apple.foundationdb.record.RecordCursorIterator) Tag(org.junit.jupiter.api.Tag) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) FDBStoredRecord(com.apple.foundationdb.record.provider.foundationdb.FDBStoredRecord) ValueSource(org.junit.jupiter.params.provider.ValueSource) KeyExpression(com.apple.foundationdb.record.metadata.expressions.KeyExpression) LongStream(java.util.stream.LongStream) TestRecords1Proto(com.apple.foundationdb.record.TestRecords1Proto) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) Tags(com.apple.test.Tags) ScanComparisons(com.apple.foundationdb.record.query.plan.ScanComparisons) Collectors(java.util.stream.Collectors) TupleRange(com.apple.foundationdb.record.TupleRange) FDBRecordStoreTestBase(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreTestBase) Test(org.junit.jupiter.api.Test) PrimitiveIterator(java.util.PrimitiveIterator) Comparisons(com.apple.foundationdb.record.query.expressions.Comparisons) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) List(java.util.List) Index(com.apple.foundationdb.record.metadata.Index) TestHelpers.assertDiscardedAtMost(com.apple.foundationdb.record.TestHelpers.assertDiscardedAtMost) TupleHelpers(com.apple.foundationdb.tuple.TupleHelpers) Message(com.google.protobuf.Message) RecordCursor(com.apple.foundationdb.record.RecordCursor) RecordCursorTest(com.apple.foundationdb.record.RecordCursorTest) Collections(java.util.Collections) RecordCursor(com.apple.foundationdb.record.RecordCursor) RecordCursorTest(com.apple.foundationdb.record.RecordCursorTest) Message(com.google.protobuf.Message) FDBStoredRecord(com.apple.foundationdb.record.provider.foundationdb.FDBStoredRecord) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) RecordCursorTest(com.apple.foundationdb.record.RecordCursorTest)

Example 45 with RecordCursor

use of com.apple.foundationdb.record.RecordCursor in project fdb-record-layer by FoundationDB.

the class UnionIntersectionTest method intersectionReasons.

@Test
public void intersectionReasons() throws Exception {
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> left = continuation -> scanRecordsBetween(7L, 20L, continuation);
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> leftLimited = left.andThen(cursor -> new RecordCursorTest.FakeOutOfBandCursor<>(cursor, 3));
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> right = continuation -> scanRecordsBetween(12L, 15L, continuation);
    final Function<byte[], RecordCursor<FDBStoredRecord<Message>>> rightLimited = right.andThen(cursor -> new RecordCursorTest.FakeOutOfBandCursor<>(cursor, 2));
    try (FDBRecordContext context = openContext()) {
        openSimpleRecordStore(context);
        RecordCursor<FDBStoredRecord<Message>> cursor = IntersectionCursor.create(recordStore, comparisonKey, false, leftLimited, right, null);
        assertEquals(Collections.emptyList(), cursor.map(this::storedRecordRecNo).asList().get());
        RecordCursorResult<FDBStoredRecord<Message>> noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.TIME_LIMIT_REACHED, noNextResult.getNoNextReason());
        cursor = IntersectionCursor.create(recordStore, comparisonKey, false, leftLimited, right, noNextResult.getContinuation().toBytes());
        assertEquals(Arrays.asList(12L), cursor.map(this::storedRecordRecNo).asList().get());
        noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.TIME_LIMIT_REACHED, noNextResult.getNoNextReason());
        cursor = IntersectionCursor.create(recordStore, comparisonKey, false, left, rightLimited, noNextResult.getContinuation().toBytes());
        assertEquals(Arrays.asList(13L, 14L), cursor.map(this::storedRecordRecNo).asList().get());
        noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.TIME_LIMIT_REACHED, noNextResult.getNoNextReason());
        cursor = IntersectionCursor.create(recordStore, comparisonKey, false, leftLimited, rightLimited, noNextResult.getContinuation().toBytes());
        assertEquals(Collections.emptyList(), cursor.map(this::storedRecordRecNo).asList().get());
        noNextResult = cursor.getNext();
        assertEquals(RecordCursor.NoNextReason.SOURCE_EXHAUSTED, noNextResult.getNoNextReason());
    }
}
Also used : IndexEntry(com.apple.foundationdb.record.IndexEntry) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) FDBRecord(com.apple.foundationdb.record.provider.foundationdb.FDBRecord) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) Function(java.util.function.Function) ArrayList(java.util.ArrayList) ExecuteProperties(com.apple.foundationdb.record.ExecuteProperties) IndexScanType(com.apple.foundationdb.record.IndexScanType) Tuple(com.apple.foundationdb.tuple.Tuple) RecordCursorResult(com.apple.foundationdb.record.RecordCursorResult) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) EndpointType(com.apple.foundationdb.record.EndpointType) ScanProperties(com.apple.foundationdb.record.ScanProperties) PipelineOperation(com.apple.foundationdb.record.PipelineOperation) RecordCursorIterator(com.apple.foundationdb.record.RecordCursorIterator) Tag(org.junit.jupiter.api.Tag) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) FDBStoredRecord(com.apple.foundationdb.record.provider.foundationdb.FDBStoredRecord) ValueSource(org.junit.jupiter.params.provider.ValueSource) KeyExpression(com.apple.foundationdb.record.metadata.expressions.KeyExpression) LongStream(java.util.stream.LongStream) TestRecords1Proto(com.apple.foundationdb.record.TestRecords1Proto) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) Tags(com.apple.test.Tags) ScanComparisons(com.apple.foundationdb.record.query.plan.ScanComparisons) Collectors(java.util.stream.Collectors) TupleRange(com.apple.foundationdb.record.TupleRange) FDBRecordStoreTestBase(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreTestBase) Test(org.junit.jupiter.api.Test) PrimitiveIterator(java.util.PrimitiveIterator) Comparisons(com.apple.foundationdb.record.query.expressions.Comparisons) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) List(java.util.List) Index(com.apple.foundationdb.record.metadata.Index) TestHelpers.assertDiscardedAtMost(com.apple.foundationdb.record.TestHelpers.assertDiscardedAtMost) TupleHelpers(com.apple.foundationdb.tuple.TupleHelpers) Message(com.google.protobuf.Message) RecordCursor(com.apple.foundationdb.record.RecordCursor) RecordCursorTest(com.apple.foundationdb.record.RecordCursorTest) Collections(java.util.Collections) RecordCursor(com.apple.foundationdb.record.RecordCursor) RecordCursorTest(com.apple.foundationdb.record.RecordCursorTest) Message(com.google.protobuf.Message) FDBStoredRecord(com.apple.foundationdb.record.provider.foundationdb.FDBStoredRecord) FDBRecordContext(com.apple.foundationdb.record.provider.foundationdb.FDBRecordContext) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) RecordCursorTest(com.apple.foundationdb.record.RecordCursorTest)

Aggregations

RecordCursor (com.apple.foundationdb.record.RecordCursor)66 List (java.util.List)59 Nonnull (javax.annotation.Nonnull)57 Message (com.google.protobuf.Message)50 Collections (java.util.Collections)48 Function (java.util.function.Function)48 ArrayList (java.util.ArrayList)47 ExecuteProperties (com.apple.foundationdb.record.ExecuteProperties)46 Tuple (com.apple.foundationdb.tuple.Tuple)44 Test (org.junit.jupiter.api.Test)43 ScanProperties (com.apple.foundationdb.record.ScanProperties)42 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)40 RecordCursorResult (com.apple.foundationdb.record.RecordCursorResult)39 Tags (com.apple.test.Tags)37 Collectors (java.util.stream.Collectors)37 Tag (org.junit.jupiter.api.Tag)37 Arrays (java.util.Arrays)36 Nullable (javax.annotation.Nullable)35 Index (com.apple.foundationdb.record.metadata.Index)34 KeyExpression (com.apple.foundationdb.record.metadata.expressions.KeyExpression)33