use of com.hazelcast.jet.core.Vertex in project hazelcast by hazelcast.
the class CreateDagVisitor method onHashJoin.
public Vertex onHashJoin(JoinHashPhysicalRel rel) {
JetJoinInfo joinInfo = rel.joinInfo(parameterMetadata);
Vertex joinVertex = dag.newUniqueVertex("Hash Join", SqlHashJoinP.supplier(joinInfo, rel.getRight().getRowType().getFieldCount()));
connectJoinInput(joinInfo, rel.getLeft(), rel.getRight(), joinVertex);
return joinVertex;
}
use of com.hazelcast.jet.core.Vertex in project hazelcast by hazelcast.
the class CreateDagVisitor method connectInput.
/**
* Converts the {@code inputRel} into a {@code Vertex} by visiting it and
* create an edge from the input vertex into {@code thisVertex}.
*
* @param configureEdgeFn optional function to configure the edge
* @return the input vertex
*/
private Vertex connectInput(RelNode inputRel, Vertex thisVertex, @Nullable Consumer<Edge> configureEdgeFn) {
Vertex inputVertex = ((PhysicalRel) inputRel).accept(this);
Edge edge = between(inputVertex, thisVertex);
if (configureEdgeFn != null) {
configureEdgeFn.accept(edge);
}
dag.edge(edge);
return inputVertex;
}
use of com.hazelcast.jet.core.Vertex in project hazelcast by hazelcast.
the class CreateDagVisitor method onSlidingWindowAggregate.
public Vertex onSlidingWindowAggregate(SlidingWindowAggregatePhysicalRel rel) {
FunctionEx<JetSqlRow, ?> groupKeyFn = rel.groupKeyFn();
AggregateOperation<?, JetSqlRow> aggregateOperation = rel.aggrOp();
Expression<?> timestampExpression = rel.timestampExpression();
ToLongFunctionEx<JetSqlRow> timestampFn = row -> WindowUtils.extractMillis(timestampExpression.eval(row.getRow(), MOCK_EEC));
SlidingWindowPolicy windowPolicy = rel.windowPolicyProvider().apply(MOCK_EEC);
KeyedWindowResultFunction<? super Object, ? super JetSqlRow, ?> resultMapping = rel.outputValueMapping();
if (rel.numStages() == 1) {
Vertex vertex = dag.newUniqueVertex("Sliding-Window-AggregateByKey", Processors.aggregateToSlidingWindowP(singletonList(groupKeyFn), singletonList(timestampFn), TimestampKind.EVENT, windowPolicy, 0, aggregateOperation, resultMapping));
connectInput(rel.getInput(), vertex, edge -> edge.distributeTo(localMemberAddress).allToOne(""));
return vertex;
} else {
assert rel.numStages() == 2;
Vertex vertex1 = dag.newUniqueVertex("Sliding-Window-AccumulateByKey", Processors.accumulateByFrameP(singletonList(groupKeyFn), singletonList(timestampFn), TimestampKind.EVENT, windowPolicy, aggregateOperation));
Vertex vertex2 = dag.newUniqueVertex("Sliding-Window-CombineByKey", Processors.combineToSlidingWindowP(windowPolicy, aggregateOperation, resultMapping));
connectInput(rel.getInput(), vertex1, edge -> edge.partitioned(groupKeyFn));
dag.edge(between(vertex1, vertex2).distributed().partitioned(entryKey()));
return vertex2;
}
}
use of com.hazelcast.jet.core.Vertex in project hazelcast by hazelcast.
the class CreateDagVisitor method onFilter.
public Vertex onFilter(FilterPhysicalRel rel) {
Expression<Boolean> filter = rel.filter(parameterMetadata);
Vertex vertex = dag.newUniqueVertex("Filter", filterUsingServiceP(ServiceFactories.nonSharedService(ctx -> ExpressionUtil.filterFn(filter, ExpressionEvalContext.from(ctx))), (Predicate<JetSqlRow> filterFn, JetSqlRow row) -> filterFn.test(row)));
connectInputPreserveCollation(rel, vertex);
return vertex;
}
use of com.hazelcast.jet.core.Vertex in project hazelcast by hazelcast.
the class CreateDagVisitor method onAccumulateByKey.
public Vertex onAccumulateByKey(AggregateAccumulateByKeyPhysicalRel rel) {
FunctionEx<JetSqlRow, ?> groupKeyFn = rel.groupKeyFn();
AggregateOperation<?, JetSqlRow> aggregateOperation = rel.aggrOp();
Vertex vertex = dag.newUniqueVertex("AccumulateByKey", Processors.accumulateByKeyP(singletonList(groupKeyFn), aggregateOperation));
connectInput(rel.getInput(), vertex, edge -> edge.partitioned(groupKeyFn));
return vertex;
}
Aggregations