use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class RemoteCollectorTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
UUID jobId = UUID.randomUUID();
RoutedCollectPhase collectPhase = new RoutedCollectPhase(jobId, 0, "remoteCollect", new Routing(ImmutableMap.<String, Map<String, List<Integer>>>of("remoteNode", ImmutableMap.of("dummyTable", Collections.singletonList(1)))), RowGranularity.DOC, Collections.<Symbol>singletonList(createReference("name", DataTypes.STRING)), Collections.<Projection>emptyList(), WhereClause.MATCH_ALL, DistributionInfo.DEFAULT_BROADCAST);
transportJobAction = mock(TransportJobAction.class);
transportKillJobsNodeAction = mock(TransportKillJobsNodeAction.class);
consumer = new TestingBatchConsumer();
JobsLogs jobsLogs = new JobsLogs(() -> true);
JobContextService jobContextService = new JobContextService(Settings.EMPTY, new NoopClusterService(), jobsLogs);
remoteCollector = new RemoteCollector(jobId, "localNode", "remoteNode", transportJobAction, transportKillJobsNodeAction, jobContextService, mock(RamAccountingContext.class), consumer, collectPhase);
}
use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class DocLevelCollectTest method testCollectWithPartitionedColumns.
@Test
public void testCollectWithPartitionedColumns() throws Throwable {
TableIdent tableIdent = new TableIdent(Schemas.DEFAULT_SCHEMA_NAME, PARTITIONED_TABLE_NAME);
Routing routing = schemas.getTableInfo(tableIdent).getRouting(WhereClause.MATCH_ALL, null);
RoutedCollectPhase collectNode = getCollectNode(Arrays.<Symbol>asList(new Reference(new ReferenceIdent(tableIdent, "id"), RowGranularity.DOC, DataTypes.INTEGER), new Reference(new ReferenceIdent(tableIdent, "date"), RowGranularity.SHARD, DataTypes.TIMESTAMP)), routing, WhereClause.MATCH_ALL);
Bucket result = collect(collectNode);
for (Row row : result) {
System.out.println("Row:" + Arrays.toString(row.materialize()));
}
assertThat(result, containsInAnyOrder(isRow(1, 0L), isRow(2, 1L)));
}
use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class DocLevelCollectTest method testCollectDocLevel.
@Test
public void testCollectDocLevel() throws Throwable {
List<Symbol> toCollect = Arrays.<Symbol>asList(testDocLevelReference, underscoreRawReference, underscoreIdReference);
RoutedCollectPhase collectNode = getCollectNode(toCollect, WhereClause.MATCH_ALL);
Bucket result = collect(collectNode);
assertThat(result, containsInAnyOrder(isRow(2, "{\"id\":1,\"doc\":2}", "1"), isRow(4, "{\"id\":3,\"doc\":4}", "3")));
}
use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class HandlerSideLevelCollectTest method testInformationSchemaColumns.
@Test
public void testInformationSchemaColumns() throws Exception {
InformationSchemaInfo schemaInfo = internalCluster().getInstance(InformationSchemaInfo.class);
TableInfo tableInfo = schemaInfo.getTableInfo("columns");
assert tableInfo != null;
Routing routing = tableInfo.getRouting(WhereClause.MATCH_ALL, null);
List<Symbol> toCollect = new ArrayList<>();
for (Reference ref : tableInfo.columns()) {
toCollect.add(ref);
}
RoutedCollectPhase collectNode = collectNode(routing, toCollect, RowGranularity.DOC);
Bucket result = collect(collectNode);
String expected = "id| string| NULL| false| true| 1| cluster| sys\n" + "master_node| string| NULL| false| true| 2| cluster| sys\n" + "name| string| NULL| false| true| 3| cluster| sys\n" + "settings| object| NULL| false| true| 4| cluster| sys\n";
assertThat(TestingHelpers.printedTable(result), Matchers.containsString(expected));
// second time - to check if the internal iterator resets
result = collect(collectNode);
assertThat(TestingHelpers.printedTable(result), Matchers.containsString(expected));
}
use of io.crate.planner.node.dql.RoutedCollectPhase in project crate by crate.
the class JobCollectContextTest method testThreadPoolNameForNonDocTables.
@Test
public void testThreadPoolNameForNonDocTables() throws Exception {
RoutedCollectPhase collectPhase = Mockito.mock(RoutedCollectPhase.class);
Routing routing = Mockito.mock(Routing.class);
when(collectPhase.routing()).thenReturn(routing);
when(routing.containsShards(localNodeId)).thenReturn(false);
// sys.cluster (single row collector)
when(collectPhase.maxRowGranularity()).thenReturn(RowGranularity.CLUSTER);
String threadPoolExecutorName = JobCollectContext.threadPoolName(collectPhase, localNodeId);
assertThat(threadPoolExecutorName, is(ThreadPool.Names.PERCOLATE));
// partition values only of a partitioned doc table (single row collector)
when(collectPhase.maxRowGranularity()).thenReturn(RowGranularity.PARTITION);
threadPoolExecutorName = JobCollectContext.threadPoolName(collectPhase, localNodeId);
assertThat(threadPoolExecutorName, is(ThreadPool.Names.PERCOLATE));
// sys.nodes (single row collector)
when(collectPhase.maxRowGranularity()).thenReturn(RowGranularity.NODE);
threadPoolExecutorName = JobCollectContext.threadPoolName(collectPhase, localNodeId);
assertThat(threadPoolExecutorName, is(ThreadPool.Names.MANAGEMENT));
// sys.shards
when(routing.containsShards(localNodeId)).thenReturn(true);
when(collectPhase.maxRowGranularity()).thenReturn(RowGranularity.SHARD);
threadPoolExecutorName = JobCollectContext.threadPoolName(collectPhase, localNodeId);
assertThat(threadPoolExecutorName, is(ThreadPool.Names.MANAGEMENT));
when(routing.containsShards(localNodeId)).thenReturn(false);
// information_schema.*
when(collectPhase.maxRowGranularity()).thenReturn(RowGranularity.DOC);
threadPoolExecutorName = JobCollectContext.threadPoolName(collectPhase, localNodeId);
assertThat(threadPoolExecutorName, is(ThreadPool.Names.PERCOLATE));
}
Aggregations