use of com.alibaba.maxgraph.compiler.tree.TreeManager in project GraphScope by alibaba.
the class LogicalPlanOptimizer method build.
/**
* Build dfs traversal to query flow
*
* @param dfsTraversal The given dfs traversal
* @return The result query flow
*/
public QueryFlowManager build(DfsTraversal dfsTraversal) {
TreeBuilder treeBuilder = TreeBuilder.newTreeBuilder(schema, optimizeConfig, this.lambdaEnableFlag);
treeBuilder.setDisableBarrierOptimizer(true);
TreeManager treeManager = dfsTraversal.buildDfsTree(treeBuilder, schema);
if (this.globalPullGraphFlag) {
treeManager.getQueryConfig().addProperty(CompilerConstant.QUERY_GRAPH_PULL_ENABLE, true);
}
LogicalQueryPlan logicalQueryPlan = LogicalPlanBuilder.newBuilder().build(treeManager);
logicalQueryPlan = logicalQueryPlan.chainOptimize();
QueryFlowBuilder queryFlowBuilder = new QueryFlowBuilder();
QueryFlowManager queryFlowManager = queryFlowBuilder.prepareQueryFlow(logicalQueryPlan, snapshotId);
queryFlowManager.validQueryFlow();
return queryFlowManager;
}
use of com.alibaba.maxgraph.compiler.tree.TreeManager in project GraphScope by alibaba.
the class LogicalPlanOptimizer method build.
public QueryFlowManager build(GraphTraversal traversal) {
TreeBuilder treeBuilder = TreeBuilder.newTreeBuilder(schema, optimizeConfig, lambdaEnableFlag);
TreeManager treeManager = treeBuilder.build(traversal);
if (this.globalPullGraphFlag) {
treeManager.getQueryConfig().addProperty(CompilerConstant.QUERY_GRAPH_PULL_ENABLE, true);
}
treeManager.optimizeTree();
LogicalQueryPlan logicalQueryPlan = LogicalPlanBuilder.newBuilder().build(treeManager);
logicalQueryPlan = logicalQueryPlan.chainOptimize();
QueryFlowBuilder queryFlowBuilder = new QueryFlowBuilder();
QueryFlowManager queryFlowManager = queryFlowBuilder.prepareQueryFlow(logicalQueryPlan, snapshotId);
queryFlowManager.validQueryFlow();
return queryFlowManager;
}
use of com.alibaba.maxgraph.compiler.tree.TreeManager in project GraphScope by alibaba.
the class MixedOpProcessor method buildCostPathList.
private List<String> buildCostPathList(GraphTraversal traversal) {
TreeBuilder treeBuilder = TreeBuilder.newTreeBuilder(this.schemaFetcher.getSchemaSnapshotPair().getLeft(), new OptimizeConfig(), true);
TreeManager treeManager = treeBuilder.build(traversal);
treeManager.optimizeTree();
CostModelManager costModelManager = treeManager.optimizeCostModel();
List<CostPath> pathList = costModelManager.getPathList();
if (pathList == null || pathList.isEmpty()) {
return Lists.newArrayList();
}
return pathList.stream().map(CostPath::toString).collect(Collectors.toList());
}
use of com.alibaba.maxgraph.compiler.tree.TreeManager in project GraphScope by alibaba.
the class DfsTraversal method buildDfsTree.
/**
* Build bfs tree manager
*
* @param treeBuilder The tree builder
* @param schema The schema
* @return The result tree managet
*/
public TreeManager buildDfsTree(TreeBuilder treeBuilder, GraphSchema schema) {
TreeManager treeManager = treeBuilder.build(traversal);
treeManager.optimizeTree();
TreeNode currentNode = treeManager.getTreeLeaf();
while (!(currentNode instanceof SourceTreeNode)) {
if (currentNode.getNodeType() == NodeType.AGGREGATE) {
throw new IllegalArgumentException("There's aggregate in the query and can'e be executed in bfs mode");
}
currentNode = UnaryTreeNode.class.cast(currentNode).getInputNode();
}
SourceDfsTreeNode sourceBfsTreeNode = new SourceDfsTreeNode(schema, batchSize);
RepeatTreeNode repeatTreeNode = new RepeatTreeNode(sourceBfsTreeNode, schema, Maps.newHashMap());
TreeNode sourceOutputNode = currentNode.getOutputNode();
SourceDelegateNode repeatSourceTreeNode = new SourceDelegateNode(sourceBfsTreeNode, schema);
DfsRepeatGraphTreeNode dfsRepeatGraphTreeNode = new DfsRepeatGraphTreeNode(repeatSourceTreeNode, SourceTreeNode.class.cast(currentNode), schema);
if (null != sourceOutputNode) {
UnaryTreeNode.class.cast(sourceOutputNode).setInputNode(dfsRepeatGraphTreeNode);
} else {
treeManager.setLeafNode(dfsRepeatGraphTreeNode);
}
TreeNode bodyLeafTreeNode = treeManager.getTreeLeaf();
repeatTreeNode.setRepeatBodyTreeNode(bodyLeafTreeNode);
repeatTreeNode.setEmitTreeNode(new SourceDelegateNode(bodyLeafTreeNode, schema));
if (order) {
OrderGlobalTreeNode orderTreeNode = new OrderGlobalTreeNode(new SourceDelegateNode(bodyLeafTreeNode, schema), schema, Lists.newArrayList(Pair.of(new SourceDelegateNode(bodyLeafTreeNode, schema), Order.asc)));
repeatTreeNode.setDfsEmitTreeNode(orderTreeNode);
}
repeatTreeNode.setDfsFeedTreeNode(new DfsFinishTreeNode(new SourceDelegateNode(bodyLeafTreeNode, schema), schema, high));
repeatTreeNode.setMaxLoopTimes(MAX_BFS_ITERATION_TIMES);
RangeGlobalTreeNode rangeGlobalTreeNode = new RangeGlobalTreeNode(repeatTreeNode, schema, low, high);
return new TreeManager(rangeGlobalTreeNode, schema, treeManager.getLabelManager(), treeManager.getQueryConfig());
}
Aggregations