Search in sources :

Example 16 with BatchIterator

use of io.crate.data.BatchIterator in project crate by crate.

the class NestedLoopBatchIteratorsTest method testFullOuterJoinBatchedSource.

@Test
public void testFullOuterJoinBatchedSource() throws Exception {
    Supplier<BatchIterator<Row>> batchIteratorSupplier = () -> new FullOuterJoinNLBatchIterator<>(new BatchSimulatingIterator<>(TestingBatchIterators.range(0, 4), 2, 2, null), new BatchSimulatingIterator<>(TestingBatchIterators.range(2, 6), 2, 2, null), new CombinedRow(1, 1), getCol0EqCol1JoinCondition());
    BatchIteratorTester tester = new BatchIteratorTester(batchIteratorSupplier);
    tester.verifyResultAndEdgeCaseBehaviour(fullJoinResult);
}
Also used : BatchIteratorTester(io.crate.testing.BatchIteratorTester) InMemoryBatchIterator(io.crate.data.InMemoryBatchIterator) BatchIterator(io.crate.data.BatchIterator) Test(org.junit.Test)

Example 17 with BatchIterator

use of io.crate.data.BatchIterator in project crate by crate.

the class NestedLoopBatchIteratorsTest method testRightJoinBatchedSource.

@Test
public void testRightJoinBatchedSource() throws Exception {
    Supplier<BatchIterator<Row>> batchIteratorSupplier = () -> new RightJoinNLBatchIterator<>(new BatchSimulatingIterator<>(TestingBatchIterators.range(0, 4), 2, 2, null), new BatchSimulatingIterator<>(TestingBatchIterators.range(2, 6), 2, 2, null), new CombinedRow(1, 1), getCol0EqCol1JoinCondition());
    BatchIteratorTester tester = new BatchIteratorTester(batchIteratorSupplier);
    tester.verifyResultAndEdgeCaseBehaviour(rightJoinResult);
}
Also used : BatchIteratorTester(io.crate.testing.BatchIteratorTester) InMemoryBatchIterator(io.crate.data.InMemoryBatchIterator) BatchIterator(io.crate.data.BatchIterator) Test(org.junit.Test)

Example 18 with BatchIterator

use of io.crate.data.BatchIterator in project crate by crate.

the class HashInnerJoinBatchIteratorTest method testInnerHashJoin.

@Test
public void testInnerHashJoin() throws Exception {
    Supplier<BatchIterator<Row>> batchIteratorSupplier = () -> new HashInnerJoinBatchIterator(leftIterator.get(), rightIterator.get(), mock(RowAccounting.class), new CombinedRow(1, 1), getCol0EqCol1JoinCondition(), getHashForLeft(), getHashForRight(), () -> 5);
    BatchIteratorTester tester = new BatchIteratorTester(batchIteratorSupplier);
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : RowAccounting(io.crate.breaker.RowAccounting) BatchIteratorTester(io.crate.testing.BatchIteratorTester) BatchIterator(io.crate.data.BatchIterator) CombinedRow(io.crate.data.join.CombinedRow) Test(org.junit.Test)

Example 19 with BatchIterator

use of io.crate.data.BatchIterator in project crate by crate.

the class FileReadingIteratorTest method testIteratorContract_givenDefaultJsonInputFormat_AndJSONExtension_thenWritesAsMap.

@Test
public void testIteratorContract_givenDefaultJsonInputFormat_AndJSONExtension_thenWritesAsMap() throws Exception {
    tempFilePath = createTempFile("tempfile", ".json");
    tmpFile = tempFilePath.toFile();
    try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(tmpFile), StandardCharsets.UTF_8)) {
        writer.write("{\"name\": \"Arthur\", \"id\": 4, \"details\": {\"age\": 38}}\n");
        writer.write("{\"id\": 5, \"name\": \"Trillian\", \"details\": {\"age\": 33}}\n");
    }
    fileUri = tempFilePath.toUri().toString();
    Supplier<BatchIterator<Row>> batchIteratorSupplier = () -> createBatchIterator(Collections.singletonList(fileUri), JSON);
    List<Object[]> expectedResult = Arrays.asList(new Object[] { JSON_AS_MAP_FIRST_LINE }, new Object[] { JSON_AS_MAP_SECOND_LINE });
    BatchIteratorTester tester = new BatchIteratorTester(batchIteratorSupplier);
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : FileOutputStream(java.io.FileOutputStream) BatchIteratorTester(io.crate.testing.BatchIteratorTester) OutputStreamWriter(java.io.OutputStreamWriter) BatchIterator(io.crate.data.BatchIterator) Test(org.junit.Test)

Example 20 with BatchIterator

use of io.crate.data.BatchIterator in project crate by crate.

the class FileReadingIteratorTest method testIteratorContract_givenJSONInputFormat_AndNoRelevantFileExtension_thenWritesAsMap.

@Test
public void testIteratorContract_givenJSONInputFormat_AndNoRelevantFileExtension_thenWritesAsMap() throws Exception {
    tempFilePath = createTempFile("tempfile", ".any-suffix");
    tmpFile = tempFilePath.toFile();
    try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(tmpFile), StandardCharsets.UTF_8)) {
        writer.write("{\"name\": \"Arthur\", \"id\": 4, \"details\": {\"age\": 38}}\n");
        writer.write("{\"id\": 5, \"name\": \"Trillian\", \"details\": {\"age\": 33}}\n");
    }
    fileUri = tempFilePath.toUri().toString();
    Supplier<BatchIterator<Row>> batchIteratorSupplier = () -> createBatchIterator(Collections.singletonList(fileUri), JSON);
    List<Object[]> expectedResult = Arrays.asList(new Object[] { JSON_AS_MAP_FIRST_LINE }, new Object[] { JSON_AS_MAP_SECOND_LINE });
    BatchIteratorTester tester = new BatchIteratorTester(batchIteratorSupplier);
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : FileOutputStream(java.io.FileOutputStream) BatchIteratorTester(io.crate.testing.BatchIteratorTester) OutputStreamWriter(java.io.OutputStreamWriter) BatchIterator(io.crate.data.BatchIterator) Test(org.junit.Test)

Aggregations

BatchIterator (io.crate.data.BatchIterator)50 Test (org.junit.Test)37 BatchIteratorTester (io.crate.testing.BatchIteratorTester)22 InMemoryBatchIterator (io.crate.data.InMemoryBatchIterator)17 Row (io.crate.data.Row)16 ArrayList (java.util.ArrayList)10 CrateUnitTest (io.crate.test.integration.CrateUnitTest)8 List (java.util.List)8 Map (java.util.Map)7 CompletableFuture (java.util.concurrent.CompletableFuture)7 Bucket (io.crate.data.Bucket)6 InputFactory (io.crate.expression.InputFactory)6 Symbol (io.crate.analyze.symbol.Symbol)4 RowAccounting (io.crate.breaker.RowAccounting)4 RowN (io.crate.data.RowN)4 CombinedRow (io.crate.data.join.CombinedRow)4 InputFactory (io.crate.operation.InputFactory)4 TestingHelpers.isRow (io.crate.testing.TestingHelpers.isRow)4 UUID (java.util.UUID)4 ClusterService (org.elasticsearch.cluster.service.ClusterService)4