Search in sources :

Example 26 with BatchIteratorTester

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

the class NodeStatsIteratorTest method testNodeStatsIteratorContrat.

@Test
public void testNodeStatsIteratorContrat() throws Exception {
    List<Symbol> toCollect = new ArrayList<>();
    toCollect.add(idRef);
    when(collectPhase.toCollect()).thenReturn(toCollect);
    when(collectPhase.whereClause()).thenReturn(WhereClause.MATCH_ALL);
    when(collectPhase.orderBy()).thenReturn(new OrderBy(Collections.singletonList(idRef), new boolean[] { false }, new Boolean[] { true }));
    List<Object[]> expectedResult = Arrays.asList(new Object[] { new BytesRef("nodeOne") }, new Object[] { new BytesRef("nodeTwo") });
    BatchIteratorTester tester = new BatchIteratorTester(() -> NodeStatsIterator.newInstance(transportNodeStatsAction, collectPhase, nodes, new InputFactory(getFunctions())));
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : OrderBy(io.crate.analyze.OrderBy) InputFactory(io.crate.operation.InputFactory) Symbol(io.crate.analyze.symbol.Symbol) BatchIteratorTester(io.crate.testing.BatchIteratorTester) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 27 with BatchIteratorTester

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

the class OrderedLuceneBatchIteratorFactoryTest method testOrderedLuceneBatchIterator.

@Test
public void testOrderedLuceneBatchIterator() throws Exception {
    BatchIteratorTester tester = new BatchIteratorTester(() -> {
        LuceneOrderedDocCollector collector1 = createOrderedCollector(searcher1, 1);
        LuceneOrderedDocCollector collector2 = createOrderedCollector(searcher2, 2);
        return OrderedLuceneBatchIteratorFactory.newInstance(Arrays.asList(collector1, collector2), 1, OrderingByPosition.rowOrdering(new int[] { 0 }, reverseFlags, nullsFirst), MoreExecutors.directExecutor(), true);
    });
    tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
Also used : BatchIteratorTester(io.crate.testing.BatchIteratorTester) 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