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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations