use of io.crate.analyze.symbol.InputColumn in project crate by crate.
the class FetchBatchAccumulatorTest method buildFetchProjectorContext.
private FetchProjectorContext buildFetchProjectorContext() {
Map<String, IntSet> nodeToReaderIds = new HashMap<>(2);
IntSet nodeReadersNodeOne = new IntHashSet();
nodeReadersNodeOne.add(0);
IntSet nodeReadersNodeTwo = new IntHashSet();
nodeReadersNodeTwo.add(2);
nodeToReaderIds.put("nodeOne", nodeReadersNodeOne);
nodeToReaderIds.put("nodeTwo", nodeReadersNodeTwo);
TreeMap<Integer, String> readerIndices = new TreeMap<>();
readerIndices.put(0, "t1");
Map<String, TableIdent> indexToTable = new HashMap<>(1);
indexToTable.put("t1", USER_TABLE_IDENT);
Map<TableIdent, FetchSource> tableToFetchSource = new HashMap<>(2);
FetchSource fetchSource = new FetchSource(Collections.emptyList(), Collections.singletonList(new InputColumn(0)), Collections.singletonList(ID));
tableToFetchSource.put(USER_TABLE_IDENT, fetchSource);
return new FetchProjectorContext(tableToFetchSource, nodeToReaderIds, readerIndices, indexToTable);
}
use of io.crate.analyze.symbol.InputColumn in project crate by crate.
the class DeleteStatementPlanner method collectWithDeleteProjection.
private static Plan collectWithDeleteProjection(TableInfo tableInfo, WhereClause whereClause, Planner.Context plannerContext) {
// for delete, we always need to collect the `_uid`
Reference idReference = tableInfo.getReference(DocSysColumns.ID);
DeleteProjection deleteProjection = new DeleteProjection(new InputColumn(0, DataTypes.STRING));
Routing routing = plannerContext.allocateRouting(tableInfo, whereClause, Preference.PRIMARY.type());
RoutedCollectPhase collectPhase = new RoutedCollectPhase(plannerContext.jobId(), plannerContext.nextExecutionPhaseId(), "collect", routing, tableInfo.rowGranularity(), ImmutableList.of(idReference), ImmutableList.of(deleteProjection), whereClause, DistributionInfo.DEFAULT_BROADCAST);
Collect collect = new Collect(collectPhase, TopN.NO_LIMIT, 0, 1, 1, null);
return Merge.ensureOnHandler(collect, plannerContext, Collections.singletonList(MergeCountProjection.INSTANCE));
}
use of io.crate.analyze.symbol.InputColumn in project crate by crate.
the class UpdateConsumer method upsertByQuery.
private static Plan upsertByQuery(UpdateAnalyzedStatement.NestedAnalyzedStatement nestedAnalysis, Planner.Context plannerContext, DocTableInfo tableInfo, WhereClause whereClause) {
Symbol versionSymbol = null;
if (whereClause.hasVersions()) {
versionSymbol = VersionRewriter.get(whereClause.query());
whereClause = new WhereClause(whereClause.query(), whereClause.docKeys().orElse(null), whereClause.partitions());
}
if (!whereClause.noMatch() || !(tableInfo.isPartitioned() && whereClause.partitions().isEmpty())) {
// for updates, we always need to collect the `_id`
Reference idReference = tableInfo.getReference(DocSysColumns.ID);
Tuple<String[], Symbol[]> assignments = Assignments.convert(nestedAnalysis.assignments());
Long version = null;
if (versionSymbol != null) {
version = ValueSymbolVisitor.LONG.process(versionSymbol);
}
UpdateProjection updateProjection = new UpdateProjection(new InputColumn(0, DataTypes.STRING), assignments.v1(), assignments.v2(), version);
Routing routing = plannerContext.allocateRouting(tableInfo, whereClause, Preference.PRIMARY.type());
return createPlan(plannerContext, routing, tableInfo, idReference, updateProjection, whereClause);
} else {
return null;
}
}
use of io.crate.analyze.symbol.InputColumn in project crate by crate.
the class RowShardResolverTest method testMultiPrimaryKeyNullException.
@Test
public void testMultiPrimaryKeyNullException() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("A primary key value must not be NULL");
List<Symbol> primaryKeySymbols = ImmutableList.<Symbol>of(new InputColumn(1), new InputColumn(0));
RowShardResolver rowShardResolver = new RowShardResolver(functions, ImmutableList.of(ci("id"), ci("foo")), primaryKeySymbols, null, new InputColumn(1));
rowShardResolver.setNextRow(row(1, null));
}
use of io.crate.analyze.symbol.InputColumn in project crate by crate.
the class RowShardResolverTest method testPrimaryKeyNoRouting.
@Test
public void testPrimaryKeyNoRouting() {
List<Symbol> primaryKeySymbols = ImmutableList.<Symbol>of(new InputColumn(0), new InputColumn(1));
RowShardResolver rowShardResolver = new RowShardResolver(functions, ImmutableList.of(ci("id"), ci("foo")), primaryKeySymbols, null, null);
rowShardResolver.setNextRow(row(1, "hoschi"));
// compound encoded id, no special routing
assertThat(rowShardResolver.id(), is("AgExBmhvc2NoaQ=="));
assertNull(rowShardResolver.routing());
}
Aggregations