Search in sources :

Example 46 with BatchIterator

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

the class HashInnerJoinBatchIteratorTest method testInnerHashJoinWithHashCollisions.

@Test
public void testInnerHashJoinWithHashCollisions() throws Exception {
    Supplier<BatchIterator<Row>> batchIteratorSupplier = () -> new HashInnerJoinBatchIterator(leftIterator.get(), rightIterator.get(), mock(RowAccounting.class), new CombinedRow(1, 1), getCol0EqCol1JoinCondition(), getHashWithCollisions(), getHashWithCollisions(), () -> 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 47 with BatchIterator

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

the class HashInnerJoinBatchIteratorTest method testInnerHashJoinWithBlockSizeBiggerThanIteratorBatchSize.

@Test
public void testInnerHashJoinWithBlockSizeBiggerThanIteratorBatchSize() throws Exception {
    Supplier<BatchIterator<Row>> batchIteratorSupplier = () -> new HashInnerJoinBatchIterator(leftIterator.get(), rightIterator.get(), mock(RowAccounting.class), new CombinedRow(1, 1), getCol0EqCol1JoinCondition(), getHashForLeft(), getHashForRight(), () -> 3);
    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 48 with BatchIterator

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

the class SortingProjectorTest method testOrderBy.

@Test
public void testOrderBy() throws Exception {
    SortingProjector projector = createProjector(2, 0);
    BatchIterator batchIterator = projector.apply(TestingBatchIterators.range(1, 11));
    consumer.accept(batchIterator, null);
    Bucket rows = consumer.getBucket();
    assertThat(rows.size(), is(10));
    int iterateLength = 1;
    for (Row row : rows) {
        assertThat(row, isRow(iterateLength++, true));
    }
}
Also used : Bucket(io.crate.data.Bucket) BatchIterator(io.crate.data.BatchIterator) TestingHelpers.isRow(io.crate.testing.TestingHelpers.isRow) Row(io.crate.data.Row) Test(org.junit.Test)

Example 49 with BatchIterator

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

the class SortingProjectorTest method testOrderByWithOffset.

@Test
public void testOrderByWithOffset() throws Exception {
    SortingProjector projector = createProjector(2, 5);
    BatchIterator batchIterator = projector.apply(TestingBatchIterators.range(1, 11));
    consumer.accept(batchIterator, null);
    Bucket rows = consumer.getBucket();
    assertThat(rows.size(), is(5));
    int iterateLength = 6;
    for (Row row : rows) {
        assertThat(row, isRow(iterateLength++, true));
    }
}
Also used : Bucket(io.crate.data.Bucket) BatchIterator(io.crate.data.BatchIterator) TestingHelpers.isRow(io.crate.testing.TestingHelpers.isRow) Row(io.crate.data.Row) Test(org.junit.Test)

Example 50 with BatchIterator

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

the class ExplainPlannerTest method testExplainAnalyzeMultiPhasePlanNotSupported.

@Test
public void testExplainAnalyzeMultiPhasePlanNotSupported() {
    ExplainPlan plan = e.plan("EXPLAIN ANALYZE SELECT * FROM users WHERE name = (SELECT 'crate') or id = (SELECT 1)");
    PlannerContext plannerContext = e.getPlannerContext(clusterService.state());
    CountDownLatch counter = new CountDownLatch(1);
    AtomicReference<BatchIterator<Row>> itRef = new AtomicReference<>();
    AtomicReference<Throwable> failureRef = new AtomicReference<>();
    plan.execute(null, plannerContext, new RowConsumer() {

        @Override
        public void accept(BatchIterator<Row> iterator, @Nullable Throwable failure) {
            itRef.set(iterator);
            failureRef.set(failure);
            counter.countDown();
        }

        @Override
        public CompletableFuture<?> completionFuture() {
            return null;
        }
    }, Row.EMPTY, SubQueryResults.EMPTY);
    assertNull(itRef.get());
    assertNotNull(failureRef.get());
    assertThat(failureRef.get().getMessage(), containsString("EXPLAIN ANALYZE does not support profiling multi-phase plans, such as queries with scalar subselects."));
}
Also used : BatchIterator(io.crate.data.BatchIterator) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) CompletableFuture(java.util.concurrent.CompletableFuture) RowConsumer(io.crate.data.RowConsumer) Row(io.crate.data.Row) ExplainPlan(io.crate.planner.node.management.ExplainPlan) Test(org.junit.Test) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest)

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