use of io.crate.expression.InputFactory in project crate by crate.
the class FileReadingIteratorTest method prepare.
@Before
public void prepare() {
NodeContext nodeCtx = new NodeContext(new Functions(Map.of()));
inputFactory = new InputFactory(nodeCtx);
}
use of io.crate.expression.InputFactory in project crate by crate.
the class NodeStatsTest method testNoRequestIfNotRequired.
@Test
public void testNoRequestIfNotRequired() throws Exception {
List<Symbol> toCollect = new ArrayList<>();
toCollect.add(idRef);
when(collectPhase.toCollect()).thenReturn(toCollect);
BatchIterator iterator = NodeStats.newInstance(transportNodeStatsAction, collectPhase, nodes, txnCtx, new InputFactory(nodeCtx));
iterator.loadNextBatch();
// Because only id and name are selected, transportNodesStatsAction should be never used
verifyNoMoreInteractions(transportNodeStatsAction);
}
use of io.crate.expression.InputFactory in project crate by crate.
the class NodeStatsTest method testRequestsAreIssued.
@Test
public void testRequestsAreIssued() throws Exception {
List<Symbol> toCollect = new ArrayList<>();
toCollect.add(idRef);
toCollect.add(nameRef);
when(collectPhase.toCollect()).thenReturn(toCollect);
BatchIterator iterator = NodeStats.newInstance(transportNodeStatsAction, collectPhase, nodes, txnCtx, new InputFactory(nodeCtx));
iterator.loadNextBatch();
verifyNoMoreInteractions(transportNodeStatsAction);
}
use of io.crate.expression.InputFactory in project crate by crate.
the class AbstractWindowFunctionTest method prepareFunctions.
@Before
public void prepareFunctions() {
DocTableInfo tableInfo = SQLExecutor.tableInfo(new RelationName("doc", "t1"), "create table doc.t1 (x int, y bigint, z string, d double)", clusterService);
DocTableRelation tableRelation = new DocTableRelation(tableInfo);
Map<RelationName, AnalyzedRelation> tableSources = Map.of(tableInfo.ident(), tableRelation);
memoryManager = new OnHeapMemoryManager(bytes -> {
});
sqlExpressions = new SqlExpressions(tableSources, tableRelation, User.CRATE_USER, additionalModules);
inputFactory = new InputFactory(sqlExpressions.nodeCtx);
}
use of io.crate.expression.InputFactory in project crate by crate.
the class ProjectionToProjectorVisitor method visitSysUpdateProjection.
@Override
public Projector visitSysUpdateProjection(SysUpdateProjection projection, Context context) {
Map<Reference, Symbol> assignments = projection.assignments();
assert !assignments.isEmpty() : "at least one assignment is required";
List<Input<?>> valueInputs = new ArrayList<>(assignments.size());
List<ColumnIdent> assignmentCols = new ArrayList<>(assignments.size());
RelationName relationName = null;
InputFactory.Context<NestableCollectExpression<?, ?>> readCtx = null;
for (Map.Entry<Reference, Symbol> e : assignments.entrySet()) {
Reference ref = e.getKey();
assert relationName == null || relationName.equals(ref.ident().tableIdent()) : "mixed table assignments found";
relationName = ref.ident().tableIdent();
if (readCtx == null) {
StaticTableDefinition<?> tableDefinition = staticTableDefinitionGetter.apply(relationName);
readCtx = inputFactory.ctxForRefs(context.txnCtx, tableDefinition.getReferenceResolver());
}
assignmentCols.add(ref.column());
Input<?> sourceInput = readCtx.add(e.getValue());
valueInputs.add(sourceInput);
}
SysRowUpdater<?> rowUpdater = sysUpdaterGetter.apply(relationName);
assert readCtx != null : "readCtx must not be null";
assert rowUpdater != null : "row updater needs to exist";
Consumer<Object> rowWriter = rowUpdater.newRowWriter(assignmentCols, valueInputs, readCtx.expressions());
if (projection.returnValues() == null) {
return new SysUpdateProjector(rowWriter);
} else {
InputFactory.Context<NestableCollectExpression<SysNodeCheck, ?>> cntx = new InputFactory(nodeCtx).ctxForRefs(context.txnCtx, new StaticTableReferenceResolver<>(SysNodeChecksTableInfo.create().expressions()));
cntx.add(List.of(projection.returnValues()));
return new SysUpdateResultSetProjector(rowUpdater, rowWriter, cntx.expressions(), cntx.topLevelInputs());
}
}
Aggregations