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