Search in sources :

Example 1 with TreeBuilder

use of com.alibaba.maxgraph.compiler.tree.TreeBuilder 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;
}
Also used : LogicalQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalQueryPlan) TreeManager(com.alibaba.maxgraph.compiler.tree.TreeManager) TreeBuilder(com.alibaba.maxgraph.compiler.tree.TreeBuilder)

Example 2 with TreeBuilder

use of com.alibaba.maxgraph.compiler.tree.TreeBuilder 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;
}
Also used : LogicalQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalQueryPlan) TreeManager(com.alibaba.maxgraph.compiler.tree.TreeManager) TreeBuilder(com.alibaba.maxgraph.compiler.tree.TreeBuilder)

Example 3 with TreeBuilder

use of com.alibaba.maxgraph.compiler.tree.TreeBuilder 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());
}
Also used : TreeManager(com.alibaba.maxgraph.compiler.tree.TreeManager) CostModelManager(com.alibaba.maxgraph.compiler.cost.CostModelManager) CostPath(com.alibaba.maxgraph.compiler.cost.CostPath) TreeBuilder(com.alibaba.maxgraph.compiler.tree.TreeBuilder) OptimizeConfig(com.alibaba.maxgraph.compiler.optimizer.OptimizeConfig)

Aggregations

TreeBuilder (com.alibaba.maxgraph.compiler.tree.TreeBuilder)3 TreeManager (com.alibaba.maxgraph.compiler.tree.TreeManager)3 LogicalQueryPlan (com.alibaba.maxgraph.compiler.logical.LogicalQueryPlan)2 CostModelManager (com.alibaba.maxgraph.compiler.cost.CostModelManager)1 CostPath (com.alibaba.maxgraph.compiler.cost.CostPath)1 OptimizeConfig (com.alibaba.maxgraph.compiler.optimizer.OptimizeConfig)1