use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.
the class GroupCountTreeNode method buildLogicalQueryPlan.
@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
LogicalSubQueryPlan logicalSubQueryPlan = new LogicalSubQueryPlan(contextManager);
LogicalVertex sourceVertex = getInputNode().getOutputVertex();
logicalSubQueryPlan.addLogicalVertex(sourceVertex);
LogicalVertex outputVertex;
if (null == keyTreeNode || keyTreeNode instanceof SourceDelegateNode) {
ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.GROUP_COUNT);
outputVertex = new LogicalUnaryVertex(contextManager.getVertexIdManager().getId(), processorFunction, false, sourceVertex);
logicalSubQueryPlan.addLogicalVertex(outputVertex);
logicalSubQueryPlan.addLogicalEdge(sourceVertex, outputVertex, new LogicalEdge());
} else {
TreeNode currentKeyNode = TreeNodeUtils.buildSingleOutputNode(keyTreeNode, schema);
if (currentKeyNode instanceof JoinZeroNode) {
((JoinZeroNode) currentKeyNode).disableJoinZero();
}
LogicalSubQueryPlan keyValuePlan = TreeNodeUtils.buildSubQueryPlan(currentKeyNode, sourceVertex, contextManager);
LogicalVertex groupValueVertex = keyValuePlan.getOutputVertex();
LogicalVertex enterKeyVertex = TreeNodeUtils.getSourceTreeNode(currentKeyNode).getOutputVertex();
logicalSubQueryPlan.mergeLogicalQueryPlan(keyValuePlan);
if (TreeNodeUtils.checkJoinSourceFlag(currentKeyNode)) {
String valueLabel = contextManager.getTreeNodeLabelManager().createSysLabelStart("val");
getUsedLabelList().add(valueLabel);
int valueLabelId = contextManager.getTreeNodeLabelManager().getLabelIndex(valueLabel);
LogicalBinaryVertex logicalBinaryVertex = new LogicalBinaryVertex(contextManager.getVertexIdManager().getId(), new ProcessorFunction(CompilerUtils.parseJoinOperatorType(currentKeyNode), Message.Value.newBuilder().setIntValue(valueLabelId)), false, enterKeyVertex, groupValueVertex);
logicalSubQueryPlan.addLogicalVertex(logicalBinaryVertex);
logicalSubQueryPlan.addLogicalEdge(enterKeyVertex, logicalBinaryVertex, new LogicalEdge());
logicalSubQueryPlan.addLogicalEdge(groupValueVertex, logicalBinaryVertex, new LogicalEdge());
ProcessorFunction selectValueFunction = TreeNodeUtils.createSelectOneFunction(valueLabel, Pop.first, contextManager.getTreeNodeLabelManager().getLabelIndexList());
LogicalVertex selectLabelVertex = new LogicalUnaryVertex(contextManager.getVertexIdManager().getId(), selectValueFunction, false, logicalBinaryVertex);
logicalSubQueryPlan.addLogicalVertex(selectLabelVertex);
logicalSubQueryPlan.addLogicalEdge(logicalBinaryVertex, selectLabelVertex, LogicalEdge.forwardEdge());
}
groupValueVertex = logicalSubQueryPlan.getOutputVertex();
ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.GROUP_COUNT, Message.Value.newBuilder());
outputVertex = new LogicalUnaryVertex(contextManager.getVertexIdManager().getId(), processorFunction, false, groupValueVertex);
logicalSubQueryPlan.addLogicalVertex(outputVertex);
logicalSubQueryPlan.addLogicalEdge(groupValueVertex, outputVertex, new LogicalEdge());
}
ProcessorFunction foldMapFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.FOLDMAP);
LogicalVertex foldMapVertex = new LogicalUnaryVertex(contextManager.getVertexIdManager().getId(), foldMapFunction, false, outputVertex);
logicalSubQueryPlan.addLogicalVertex(foldMapVertex);
logicalSubQueryPlan.addLogicalEdge(outputVertex, foldMapVertex, new LogicalEdge());
addUsedLabelAndRequirement(foldMapVertex, contextManager.getTreeNodeLabelManager());
setFinishVertex(foldMapVertex, contextManager.getTreeNodeLabelManager());
return logicalSubQueryPlan;
}
use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.
the class HitsVertexProgramTreeNode method buildLogicalQueryPlan.
@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
TreeNodeLabelManager labelManager = contextManager.getTreeNodeLabelManager();
VertexIdManager vertexIdManager = contextManager.getVertexIdManager();
ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.PROGRAM_GRAPH_HITS, createOperatorArgument());
return parseSingleUnaryVertex(vertexIdManager, labelManager, processorFunction, contextManager);
}
use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.
the class QueryFlowBuilder method createChainedFunction.
private OperatorBase.Builder createChainedFunction(LogicalVertex logicalVertex) {
OperatorBase.Builder functionBuilder = OperatorBase.newBuilder();
ProcessorFunction processorFunction = logicalVertex.getProcessorFunction();
functionBuilder.setOperatorType(processorFunction.getOperatorType());
Value.Builder argumentBuilder = processorFunction.getArgumentBuilder();
if (processorFunction instanceof ProcessorLabelValueFunction) {
if (null == argumentBuilder) {
argumentBuilder = Value.newBuilder();
}
ProcessorLabelValueFunction processorLabelValueFunction = (ProcessorLabelValueFunction) processorFunction;
argumentBuilder.setIntValue(processorLabelValueFunction.getLabelId());
if (null != processorLabelValueFunction.getLabelValueVertex()) {
OperatorBase.Builder labelValueBuilder = createChainedFunction(processorLabelValueFunction.getLabelValueVertex());
argumentBuilder.setPayload(labelValueBuilder.build().toByteString());
}
}
if (argumentBuilder != null) {
functionBuilder.setArgument(argumentBuilder);
}
functionBuilder.addAllLogicalCompare(processorFunction.getLogicalCompareList());
if (processorFunction.getRangeLimit() != null) {
functionBuilder.setRangeLimit(processorFunction.getRangeLimit());
}
functionBuilder.addAllAfterRequirement(logicalVertex.getAfterRequirementList().stream().map(v -> v.build()).collect(Collectors.toList()));
functionBuilder.addAllBeforeRequirement(logicalVertex.getBeforeRequirementList().stream().map(v -> v.build()).collect(Collectors.toList()));
return functionBuilder;
}
use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.
the class LambdaFilterTreeNode method buildLogicalQueryPlan.
@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
Message.Value.Builder argumentBuilder = Message.Value.newBuilder().setStrValue(this.lambdaIndex);
ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.LAMBDA_FILTER, argumentBuilder);
return parseSingleUnaryVertex(contextManager.getVertexIdManager(), contextManager.getTreeNodeLabelManager(), processorFunction, contextManager);
}
use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.
the class LambdaFlatMapTreeNode method buildLogicalQueryPlan.
@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
Message.Value.Builder argumentBuilder = Message.Value.newBuilder().setStrValue(this.lambdaIndex);
ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.LAMBDA_FLATMAP, argumentBuilder);
return parseSingleUnaryVertex(contextManager.getVertexIdManager(), contextManager.getTreeNodeLabelManager(), processorFunction, contextManager);
}
Aggregations