Search in sources :

Example 6 with InputFactory

use of io.crate.operation.InputFactory in project crate by crate.

the class ProjectionToProjectorVisitorTest method prepare.

@Before
public void prepare() {
    MockitoAnnotations.initMocks(this);
    functions = getFunctions();
    threadPool = new ThreadPool("testing");
    visitor = new ProjectionToProjectorVisitor(mock(ClusterService.class), functions, new IndexNameExpressionResolver(Settings.EMPTY), threadPool, Settings.EMPTY, mock(TransportActionProvider.class, Answers.RETURNS_DEEP_STUBS.get()), mock(BulkRetryCoordinatorPool.class), new InputFactory(functions), EvaluatingNormalizer.functionOnlyNormalizer(functions, ReplaceMode.COPY), null);
    countInfo = new FunctionInfo(new FunctionIdent(CountAggregation.NAME, Collections.singletonList(DataTypes.STRING)), DataTypes.LONG);
    avgInfo = new FunctionInfo(new FunctionIdent(AverageAggregation.NAME, Collections.singletonList(DataTypes.INTEGER)), DataTypes.DOUBLE);
}
Also used : InputFactory(io.crate.operation.InputFactory) ThreadPool(org.elasticsearch.threadpool.ThreadPool) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) Before(org.junit.Before)

Example 7 with InputFactory

use of io.crate.operation.InputFactory in project crate by crate.

the class NodeStatsIteratorTest method testRequestsAreIssued.

@Test
public void testRequestsAreIssued() throws InterruptedException, ExecutionException, TimeoutException {
    List<Symbol> toCollect = new ArrayList<>();
    toCollect.add(idRef);
    toCollect.add(nameRef);
    when(collectPhase.toCollect()).thenReturn(toCollect);
    BatchIterator iterator = NodeStatsIterator.newInstance(transportNodeStatsAction, collectPhase, nodes, new InputFactory(getFunctions()));
    iterator.loadNextBatch();
    verifyNoMoreInteractions(transportNodeStatsAction);
}
Also used : InputFactory(io.crate.operation.InputFactory) Symbol(io.crate.analyze.symbol.Symbol) BatchIterator(io.crate.data.BatchIterator) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 8 with InputFactory

use of io.crate.operation.InputFactory 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 9 with InputFactory

use of io.crate.operation.InputFactory in project crate by crate.

the class NodeStatsIteratorTest method testNoRequestIfNotRequired.

@Test
public void testNoRequestIfNotRequired() throws InterruptedException, ExecutionException, TimeoutException {
    List<Symbol> toCollect = new ArrayList<>();
    toCollect.add(idRef);
    when(collectPhase.toCollect()).thenReturn(toCollect);
    BatchIterator iterator = NodeStatsIterator.newInstance(transportNodeStatsAction, collectPhase, nodes, new InputFactory(getFunctions()));
    iterator.loadNextBatch();
    // Because only id and name are selected, transportNodesStatsAction should be never used
    verifyNoMoreInteractions(transportNodeStatsAction);
}
Also used : InputFactory(io.crate.operation.InputFactory) Symbol(io.crate.analyze.symbol.Symbol) BatchIterator(io.crate.data.BatchIterator) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 10 with InputFactory

use of io.crate.operation.InputFactory in project crate by crate.

the class NodeStatsIteratorTest method testRequestsIfRequired.

@Test
public void testRequestsIfRequired() throws InterruptedException, ExecutionException, TimeoutException {
    List<Symbol> toCollect = new ArrayList<>();
    toCollect.add(idRef);
    toCollect.add(hostnameRef);
    when(collectPhase.toCollect()).thenReturn(toCollect);
    BatchIterator iterator = NodeStatsIterator.newInstance(transportNodeStatsAction, collectPhase, nodes, new InputFactory(getFunctions()));
    iterator.loadNextBatch();
    // Hostnames needs to be collected so requests need to be performed
    verify(transportNodeStatsAction).execute(eq("nodeOne"), any(NodeStatsRequest.class), any(ActionListener.class), eq(TimeValue.timeValueMillis(3000L)));
    verify(transportNodeStatsAction).execute(eq("nodeTwo"), any(NodeStatsRequest.class), any(ActionListener.class), eq(TimeValue.timeValueMillis(3000L)));
    verifyNoMoreInteractions(transportNodeStatsAction);
}
Also used : InputFactory(io.crate.operation.InputFactory) ActionListener(org.elasticsearch.action.ActionListener) NodeStatsRequest(io.crate.executor.transport.NodeStatsRequest) Symbol(io.crate.analyze.symbol.Symbol) BatchIterator(io.crate.data.BatchIterator) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

InputFactory (io.crate.operation.InputFactory)10 Symbol (io.crate.analyze.symbol.Symbol)5 CrateUnitTest (io.crate.test.integration.CrateUnitTest)4 Before (org.junit.Before)4 Test (org.junit.Test)4 BatchIterator (io.crate.data.BatchIterator)3 OrderBy (io.crate.analyze.OrderBy)2 CollectExpression (io.crate.operation.collect.CollectExpression)2 WhereClause (io.crate.analyze.WhereClause)1 InputColumn (io.crate.analyze.symbol.InputColumn)1 Row (io.crate.data.Row)1 NodeStatsRequest (io.crate.executor.transport.NodeStatsRequest)1 InputRow (io.crate.operation.InputRow)1 RoutedCollectPhase (io.crate.planner.node.dql.RoutedCollectPhase)1 BatchIteratorTester (io.crate.testing.BatchIteratorTester)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 BytesRef (org.apache.lucene.util.BytesRef)1 ActionListener (org.elasticsearch.action.ActionListener)1