Search in sources :

Example 16 with BatchIteratorTester

use of io.crate.testing.BatchIteratorTester in project crate by crate.

the class LuceneBatchIteratorTest method testLuceneBatchIterator.

@Test
public void testLuceneBatchIterator() throws Exception {
    BatchIteratorTester tester = new BatchIteratorTester(() -> {
        return new LuceneBatchIterator(indexSearcher, new MatchAllDocsQuery(), null, false, new CollectorContext(mock(IndexFieldDataService.class), new CollectorFieldsVisitor(0)), new RamAccountingContext("dummy", new NoopCircuitBreaker("dummy")), columnRefs, columnRefs);
    });
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : RamAccountingContext(io.crate.breaker.RamAccountingContext) BatchIteratorTester(io.crate.testing.BatchIteratorTester) CollectorContext(io.crate.operation.reference.doc.lucene.CollectorContext) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) NoopCircuitBreaker(org.elasticsearch.common.breaker.NoopCircuitBreaker) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 17 with BatchIteratorTester

use of io.crate.testing.BatchIteratorTester in project crate by crate.

the class RowTransformingBatchIteratorTest method testRowTransformingIterator.

@Test
public void testRowTransformingIterator() throws Exception {
    BatchIteratorTester tester = new BatchIteratorTester(() -> new RowTransformingBatchIterator(TestingBatchIterators.range(0, 10), inputs, expressions));
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : BatchIteratorTester(io.crate.testing.BatchIteratorTester) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 18 with BatchIteratorTester

use of io.crate.testing.BatchIteratorTester in project crate by crate.

the class FileReadingIteratorTest method testIteratorContract.

@Test
public void testIteratorContract() throws Exception {
    String fileUri = tempFilePath.toUri().toString();
    Supplier<BatchIterator> batchIteratorSupplier = () -> createBatchIterator(Collections.singletonList(fileUri), null);
    byte[] firstLine = "{\"name\": \"Arthur\", \"id\": 4, \"details\": {\"age\": 38}}".getBytes(StandardCharsets.UTF_8);
    byte[] secondLine = "{\"id\": 5, \"name\": \"Trillian\", \"details\": {\"age\": 33}}".getBytes(StandardCharsets.UTF_8);
    List<Object[]> expectedResult = Arrays.asList(new Object[] { new BytesRef(firstLine) }, new Object[] { new BytesRef(secondLine) });
    BatchIteratorTester tester = new BatchIteratorTester(batchIteratorSupplier);
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : BatchIteratorTester(io.crate.testing.BatchIteratorTester) BatchIterator(io.crate.data.BatchIterator) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 19 with BatchIteratorTester

use of io.crate.testing.BatchIteratorTester in project crate by crate.

the class NestedLoopBatchIteratorTest method testFullOuterJoin.

@Test
public void testFullOuterJoin() throws Exception {
    Supplier<BatchIterator> batchIteratorSupplier = () -> NestedLoopBatchIterator.fullOuterJoin(TestingBatchIterators.range(0, 4), TestingBatchIterators.range(2, 6), getCol0EqCol1JoinCondition());
    BatchIteratorTester tester = new BatchIteratorTester(batchIteratorSupplier);
    tester.verifyResultAndEdgeCaseBehaviour(fullJoinResult);
}
Also used : BatchIteratorTester(io.crate.testing.BatchIteratorTester) NestedLoopBatchIterator(io.crate.data.join.NestedLoopBatchIterator) Test(org.junit.Test)

Example 20 with BatchIteratorTester

use of io.crate.testing.BatchIteratorTester in project crate by crate.

the class NestedLoopBatchIteratorTest method testRightJoin.

@Test
public void testRightJoin() throws Exception {
    Supplier<BatchIterator> batchIteratorSupplier = () -> NestedLoopBatchIterator.rightJoin(TestingBatchIterators.range(0, 4), TestingBatchIterators.range(2, 6), getCol0EqCol1JoinCondition());
    BatchIteratorTester tester = new BatchIteratorTester(batchIteratorSupplier);
    tester.verifyResultAndEdgeCaseBehaviour(rightJoinResult);
}
Also used : BatchIteratorTester(io.crate.testing.BatchIteratorTester) NestedLoopBatchIterator(io.crate.data.join.NestedLoopBatchIterator) Test(org.junit.Test)

Aggregations

BatchIteratorTester (io.crate.testing.BatchIteratorTester)27 Test (org.junit.Test)26 BatchSimulatingIterator (io.crate.testing.BatchSimulatingIterator)9 NestedLoopBatchIterator (io.crate.data.join.NestedLoopBatchIterator)6 CrateUnitTest (io.crate.test.integration.CrateUnitTest)4 BytesRef (org.apache.lucene.util.BytesRef)3 Symbol (io.crate.analyze.symbol.Symbol)2 BatchIterator (io.crate.data.BatchIterator)2 Row (io.crate.data.Row)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IntStream (java.util.stream.IntStream)2 OrderBy (io.crate.analyze.OrderBy)1 InputColumn (io.crate.analyze.symbol.InputColumn)1 RamAccountingContext (io.crate.breaker.RamAccountingContext)1 Input (io.crate.data.Input)1 RowsBatchIterator (io.crate.data.RowsBatchIterator)1 ShardUpsertRequest (io.crate.executor.transport.ShardUpsertRequest)1 TransportShardUpsertAction (io.crate.executor.transport.TransportShardUpsertAction)1 SQLTransportIntegrationTest (io.crate.integrationtests.SQLTransportIntegrationTest)1