use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class ShardCollectorProvider method getIterator.
private BatchIterator<Row> getIterator(RoutedCollectPhase collectPhase, boolean requiresScroll, CollectTask collectTask) throws Exception {
assert collectPhase.orderBy() == null : "getDocCollector shouldn't be called if there is an orderBy on the collectPhase";
assert collectPhase.maxRowGranularity() == RowGranularity.DOC : "granularity must be DOC";
boolean isOpenIndex = indexShard.mapperService() != null;
RoutedCollectPhase normalizedCollectNode = collectPhase.normalize(shardNormalizer, collectTask.txnCtx());
if (isOpenIndex) {
BatchIterator<Row> fusedIterator = getProjectionFusedIterator(normalizedCollectNode, collectTask);
if (fusedIterator != null) {
return fusedIterator;
}
}
final BatchIterator<Row> iterator;
if (isOpenIndex && WhereClause.canMatch(normalizedCollectNode.where())) {
iterator = getUnorderedIterator(normalizedCollectNode, requiresScroll, collectTask);
} else {
iterator = InMemoryBatchIterator.empty(SentinelRow.SENTINEL);
}
return Projectors.wrap(Projections.shardProjections(collectPhase.projections()), collectPhase.jobId(), collectTask.txnCtx(), collectTask.getRamAccounting(), collectTask.memoryManager(), projectorFactory, iterator);
}
use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class DistributingConsumerFactoryTest method createDownstream.
private RowConsumer createDownstream(Set<String> downstreamExecutionNodes) {
UUID jobId = UUID.randomUUID();
Routing routing = new Routing(Map.of("n1", Map.of("i1", IntArrayList.from(1, 2))));
RoutedCollectPhase collectPhase = new RoutedCollectPhase(jobId, 1, "collect", routing, RowGranularity.DOC, List.of(), List.of(), WhereClause.MATCH_ALL.queryOrFallback(), DistributionInfo.DEFAULT_MODULO);
MergePhase mergePhase = new MergePhase(jobId, 2, "merge", 1, 1, downstreamExecutionNodes, List.of(LongType.INSTANCE), List.of(), DistributionInfo.DEFAULT_BROADCAST, null);
NodeOperation nodeOperation = NodeOperation.withDownstream(collectPhase, mergePhase, (byte) 0);
return rowDownstreamFactory.create(nodeOperation, RamAccounting.NO_ACCOUNTING, collectPhase.distributionInfo(), jobId, Paging.PAGE_SIZE);
}
use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class CollectQueryCastRulesTest method assertCollectQuery.
private void assertCollectQuery(String query, String expected) {
var collect = new Collect(tr1, Collections.emptyList(), new WhereClause(e.asSymbol(query)), 100, 10);
var plan = (io.crate.planner.node.dql.Collect) collect.build(plannerContext, Set.of(), new ProjectionBuilder(e.nodeCtx), TopN.NO_LIMIT, 0, null, null, Row.EMPTY, new SubQueryResults(emptyMap()) {
@Override
public Object getSafe(SelectSymbol key) {
return Literal.of(key.valueType(), null);
}
});
assertThat(((RoutedCollectPhase) plan.collectPhase()).where().toString(), is(expected));
}
use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class CopyToPlannerTest method testCopyToWithPartitionInWhereClauseRoutesToPartitionIndexOnly.
@Test
public void testCopyToWithPartitionInWhereClauseRoutesToPartitionIndexOnly() {
Merge merge = plan("copy parted where date = 1395874800000 to directory '/tmp/foo'");
Collect collect = (Collect) merge.subPlan();
String expectedIndex = new PartitionName(new RelationName("doc", "parted"), singletonList("1395874800000")).asIndexName();
assertThat(((RoutedCollectPhase) collect.collectPhase()).routing().locations().values().stream().flatMap(shardsByIndices -> shardsByIndices.keySet().stream()).collect(Collectors.toSet()), contains(expectedIndex));
}
use of io.crate.execution.dsl.phases.RoutedCollectPhase in project crate by crate.
the class CopyToPlannerTest method testCopyToWithColumnsReferenceRewrite.
@Test
public void testCopyToWithColumnsReferenceRewrite() {
Merge plan = plan("copy users (name) to directory '/tmp'");
Collect innerPlan = (Collect) plan.subPlan();
RoutedCollectPhase node = ((RoutedCollectPhase) innerPlan.collectPhase());
Reference nameRef = (Reference) node.toCollect().get(0);
assertThat(nameRef.column().name(), is(DocSysColumns.DOC.name()));
assertThat(nameRef.column().path().get(0), is("name"));
}
Aggregations