use of com.alibaba.maxgraph.compiler.logical.LogicalVertex in project GraphScope by alibaba.
the class TreeNodeUtils method buildSubQueryPlan.
/**
* Build sub query plan from given leaf tree node
*
* @param treeNode The given leaf tree node
* @param sourceVertex The source vertex
* @param contextManager The context manager
* @param generateUseKey The flag of generated use key, it may be generated outside such as
* group
* @return The query plan of sub query
*/
public static LogicalSubQueryPlan buildSubQueryPlan(TreeNode treeNode, LogicalVertex sourceVertex, ContextManager contextManager, boolean generateUseKey) {
TreeNodeLabelManager treeNodeLabelManager = contextManager.getTreeNodeLabelManager();
VertexIdManager vertexIdManager = contextManager.getVertexIdManager();
List<TreeNode> treeNodeList = buildTreeNodeListFromLeaf(treeNode);
boolean useKeyFlag = checkNodeListUseKey(treeNodeList);
LogicalSubQueryPlan logicalSubQueryPlan = new LogicalSubQueryPlan(contextManager);
LogicalVertex currentSourceVertex = sourceVertex;
for (TreeNode currentNode : treeNodeList) {
if (currentNode instanceof AbstractUseKeyNode) {
((AbstractUseKeyNode) currentNode).enableUseKeyFlag(currentSourceVertex);
}
if (currentNode instanceof SourceDelegateNode) {
if (useKeyFlag && generateUseKey) {
LogicalVertex enterKeyVertex = new LogicalUnaryVertex(vertexIdManager.getId(), new ProcessorFunction(QueryFlowOuterClass.OperatorType.ENTER_KEY, Message.Value.newBuilder().setPayload(QueryFlowOuterClass.EnterKeyArgumentProto.newBuilder().setEnterKeyType(QueryFlowOuterClass.EnterKeyTypeProto.KEY_SELF).setUniqFlag(true).build().toByteString())), false, currentSourceVertex);
currentNode.setFinishVertex(enterKeyVertex, treeNodeLabelManager);
logicalSubQueryPlan.addLogicalVertex(currentSourceVertex);
logicalSubQueryPlan.addLogicalVertex(enterKeyVertex);
logicalSubQueryPlan.addLogicalEdge(currentSourceVertex, enterKeyVertex, new LogicalEdge());
currentSourceVertex = enterKeyVertex;
} else {
currentNode.setFinishVertex(currentSourceVertex, treeNodeLabelManager);
logicalSubQueryPlan.addLogicalVertex(currentSourceVertex);
}
}
logicalSubQueryPlan.mergeLogicalQueryPlan(currentNode.buildLogicalQueryPlan(contextManager));
}
return logicalSubQueryPlan;
}
use of com.alibaba.maxgraph.compiler.logical.LogicalVertex in project GraphScope by alibaba.
the class WherePredicateTreeNode method processFirstValueNode.
private int processFirstValueNode(ContextManager contextManager, VertexIdManager vertexIdManager, TreeNodeLabelManager labelManager, LogicalSubQueryPlan logicalSubQueryPlan, TreeNode firstRingNode) {
LogicalVertex currentSourceVertex = logicalSubQueryPlan.getOutputVertex();
LogicalSubQueryPlan subQueryPlan = TreeNodeUtils.buildSubQueryPlan(firstRingNode, currentSourceVertex, contextManager);
logicalSubQueryPlan.mergeLogicalQueryPlan(subQueryPlan);
LogicalVertex valueVertex = subQueryPlan.getOutputVertex();
String sourceLabel = labelManager.createSysLabelStart(valueVertex, "val");
return labelManager.getLabelIndex(sourceLabel);
}
use of com.alibaba.maxgraph.compiler.logical.LogicalVertex in project GraphScope by alibaba.
the class AbstractUseKeyNode method processJoinZeroVertex.
/**
* Process zero for sum and count vertex
*
* @param vertexIdManager The vertex id manager
* @param logicalSubQueryPlan The logical sub query plan
* @param valueVertex The value vertex
* @param joinZeroFlag The join zero flag
* @return The output vertex after deal with join zero flag
*/
protected LogicalVertex processJoinZeroVertex(VertexIdManager vertexIdManager, LogicalSubQueryPlan logicalSubQueryPlan, LogicalVertex valueVertex, boolean joinZeroFlag) {
LogicalVertex outputVertex = valueVertex;
LogicalVertex leftVertex = getSourceVertex();
if (joinZeroFlag && null != leftVertex) {
ProcessorFunction joinZeroFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.JOIN_RIGHT_ZERO_JOIN);
LogicalBinaryVertex logicalBinaryVertex = new LogicalBinaryVertex(vertexIdManager.getId(), joinZeroFunction, false, leftVertex, valueVertex);
logicalSubQueryPlan.addLogicalVertex(logicalBinaryVertex);
logicalSubQueryPlan.addLogicalEdge(valueVertex, logicalBinaryVertex, new LogicalEdge());
outputVertex = logicalBinaryVertex;
}
return outputVertex;
}
Aggregations