use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.
the class SampleGlobalTreeNode method buildLogicalQueryPlan.
@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
TreeNodeLabelManager labelManager = contextManager.getTreeNodeLabelManager();
VertexIdManager vertexIdManager = contextManager.getVertexIdManager();
Message.Value.Builder argumentBuilder = createArgumentBuilder();
argumentBuilder.setIntValue(amountToSample);
ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.SAMPLE, argumentBuilder);
return parseSingleUnaryVertex(vertexIdManager, labelManager, processorFunction, contextManager);
}
use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.
the class SelectOneTreeNode method buildLogicalQueryPlan.
@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
TreeNodeLabelManager labelManager = contextManager.getTreeNodeLabelManager();
VertexIdManager vertexIdManager = contextManager.getVertexIdManager();
Map<String, Integer> labelIndexList = labelManager.getLabelIndexList();
ProcessorFunction selectOneFunction = TreeNodeUtils.createSelectOneFunction(selectLabel, pop, labelIndexList);
LogicalSubQueryPlan logicalSubQueryPlan = parseSingleUnaryVertex(vertexIdManager, labelManager, selectOneFunction, contextManager, LogicalEdge.shuffleByKey(0), null == traversalTreeNode);
if (null != traversalTreeNode && !contextManager.getCostModelManager().processFieldValue(selectLabel)) {
LogicalSubQueryPlan traversalValuePlan = TreeNodeUtils.buildSubQueryPlan(traversalTreeNode, logicalSubQueryPlan.getOutputVertex(), contextManager);
logicalSubQueryPlan.mergeLogicalQueryPlan(traversalValuePlan);
LogicalVertex outputVertex = logicalSubQueryPlan.getOutputVertex();
addUsedLabelAndRequirement(outputVertex, labelManager);
setFinishVertex(outputVertex, labelManager);
}
return logicalSubQueryPlan;
}
use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.
the class SelectTreeNode method parseJoinQueryPlan.
private LogicalSubQueryPlan parseJoinQueryPlan(ContextManager contextManager, VertexIdManager vertexIdManager, TreeNodeLabelManager labelManager, Map<String, Integer> labelIndexList) {
LogicalSubQueryPlan logicalSubQueryPlan = new LogicalSubQueryPlan(contextManager);
LogicalVertex delegateSourceVertex = getInputNode().getOutputVertex();
logicalSubQueryPlan.addLogicalVertex(delegateSourceVertex);
Set<String> selectKeySet = Sets.newHashSet();
List<Integer> keyIdList = Lists.newArrayList();
List<Integer> valueIdList = Lists.newArrayList();
for (int i = 0; i < selectKeyList.size(); i++) {
String selectKey = selectKeyList.get(i);
if (selectKeySet.contains(selectKey)) {
continue;
}
selectKeySet.add(selectKey);
TreeNode traversalTreeNode = traversalTreeNodeList.get(i % traversalTreeNodeList.size());
int labelIndex = labelIndexList.get(selectKey);
keyIdList.add(labelIndex);
valueIdList.add(labelIndexList.get(selectKey));
if (!(traversalTreeNode instanceof SourceDelegateNode)) {
TreeNode currentTraversalNode = TreeNodeUtils.buildSingleOutputNode(traversalTreeNode, schema);
LogicalVertex outputVertex = logicalSubQueryPlan.getOutputVertex();
LogicalSubQueryPlan traversalPlan = TreeNodeUtils.buildSubQueryPlan(currentTraversalNode, outputVertex, contextManager);
List<LogicalVertex> resultVertexList = traversalPlan.getLogicalVertexList();
if (resultVertexList.size() == 2) {
LogicalVertex fieldValueVertex = resultVertexList.get(1);
ProcessorLabelValueFunction labelValueFunction = new ProcessorLabelValueFunction(labelIndex, fieldValueVertex);
labelValueFunction.setRequireLabelFlag(true);
LogicalVertex labelValueVertex = new LogicalUnaryVertex(vertexIdManager.getId(), labelValueFunction, outputVertex);
logicalSubQueryPlan.addLogicalVertex(labelValueVertex);
logicalSubQueryPlan.addLogicalEdge(outputVertex, labelValueVertex, LogicalEdge.shuffleByKey(labelIndex));
} else {
LogicalVertex fieldValueVertex = traversalPlan.getOutputVertex();
fieldValueVertex.getAfterRequirementList().add(QueryFlowOuterClass.RequirementValue.newBuilder().setReqType(QueryFlowOuterClass.RequirementType.LABEL_START).setReqArgument(Message.Value.newBuilder().addIntValueList(labelIndex)));
logicalSubQueryPlan.mergeLogicalQueryPlan(traversalPlan);
LogicalVertex outputKeyVertex = new LogicalUnaryVertex(vertexIdManager.getId(), new ProcessorFunction(QueryFlowOuterClass.OperatorType.KEY_MESSAGE), fieldValueVertex);
logicalSubQueryPlan.addLogicalVertex(outputKeyVertex);
logicalSubQueryPlan.addLogicalEdge(fieldValueVertex, outputKeyVertex, LogicalEdge.forwardEdge());
}
}
}
LogicalVertex selectInputVertex = logicalSubQueryPlan.getOutputVertex();
Message.Value.Builder argumentBuilder = Message.Value.newBuilder().setBoolValue(true).setIntValue(pop == null ? Message.PopType.POP_EMPTY.getNumber() : Message.PopType.valueOf(StringUtils.upperCase(pop.name())).getNumber()).addAllIntValueList(valueIdList).addAllStrValueList(keyIdList.stream().map(labelManager::getLabelName).collect(Collectors.toList()));
ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.SELECT, argumentBuilder);
processorFunction.getUsedLabelList().addAll(valueIdList);
LogicalVertex selectVertex = new LogicalUnaryVertex(vertexIdManager.getId(), processorFunction, false, selectInputVertex);
logicalSubQueryPlan.addLogicalVertex(selectVertex);
logicalSubQueryPlan.addLogicalEdge(selectInputVertex, selectVertex, new LogicalEdge(EdgeShuffleType.FORWARD));
return logicalSubQueryPlan;
}
use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.
the class ShortestPathTreeNode method buildLogicalQueryPlan.
@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
TreeNodeLabelManager labelManager = contextManager.getTreeNodeLabelManager();
VertexIdManager vertexIdManager = contextManager.getVertexIdManager();
ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.PROGRAM_GRAPH_SHORTESTPATH, createOperatorArgument());
return parseSingleUnaryVertex(vertexIdManager, labelManager, processorFunction, contextManager);
}
use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.
the class ShortestPathVertexProgramTreeNode method buildLogicalQueryPlan.
@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
TreeNodeLabelManager labelManager = contextManager.getTreeNodeLabelManager();
VertexIdManager vertexIdManager = contextManager.getVertexIdManager();
ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.PROGRAM_GRAPH_SHORTESTPATH, createOperatorArgument());
return parseSingleUnaryVertex(vertexIdManager, labelManager, processorFunction, contextManager);
}
Aggregations