Search in sources :

Example 1 with CostPath

use of com.alibaba.maxgraph.compiler.cost.CostPath 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)

Example 2 with CostPath

use of com.alibaba.maxgraph.compiler.cost.CostPath in project GraphScope by alibaba.

the class TreeManager method optimizeCostModel.

public CostModelManager optimizeCostModel() {
    List<TreeNode> treeNodeList = TreeNodeUtils.buildTreeNodeListFromLeaf(this.getTreeLeaf());
    CostGraph costGraph = CostUtils.buildCostGraph(this.getTreeLeaf(), this.labelManager);
    NodeLabelManager nodeLabelManager = new NodeLabelManager();
    NodeLabelList previousNodeLabel = null;
    for (TreeNode treeNode : treeNodeList) {
        NodeLabelList nodeLabelList = NodeLabelList.buildNodeLabel(previousNodeLabel, treeNode, schema);
        nodeLabelManager.addNodeLabelList(nodeLabelList);
        previousNodeLabel = nodeLabelList;
    }
    int pathIndex = this.getQueryConfig().getInt(CompilerConstant.QUERY_COSTMODEL_PLAN_PATH, -1);
    List<CostPath> costPathList = costGraph.getCostPathList();
    CostPath useCostPath;
    if (pathIndex < 0 || pathIndex >= costPathList.size()) {
        CostDataStatistics costDataStatistics = CostDataStatistics.getInstance();
        List<Double> stepCountList = costDataStatistics.computeStepCountList(nodeLabelManager, treeNodeList);
        List<Double> shuffleThresholdList = Lists.newArrayList(1.0);
        for (int i = 1; i < stepCountList.size(); i++) {
            shuffleThresholdList.add(1.5);
        }
        useCostPath = costGraph.computePath(stepCountList, shuffleThresholdList);
    } else {
        useCostPath = costPathList.get(pathIndex);
        logger.info("Use specify cost path " + useCostPath.toString());
    }
    return new CostModelManager(costGraph, useCostPath);
}
Also used : NodeLabelManager(com.alibaba.maxgraph.compiler.cost.statistics.NodeLabelManager) SourceTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode) SourceVertexTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode) CostDataStatistics(com.alibaba.maxgraph.compiler.cost.statistics.CostDataStatistics) NodeLabelList(com.alibaba.maxgraph.compiler.cost.statistics.NodeLabelList) CostModelManager(com.alibaba.maxgraph.compiler.cost.CostModelManager) CostGraph(com.alibaba.maxgraph.compiler.cost.CostGraph) CostPath(com.alibaba.maxgraph.compiler.cost.CostPath)

Aggregations

CostModelManager (com.alibaba.maxgraph.compiler.cost.CostModelManager)2 CostPath (com.alibaba.maxgraph.compiler.cost.CostPath)2 CostGraph (com.alibaba.maxgraph.compiler.cost.CostGraph)1 CostDataStatistics (com.alibaba.maxgraph.compiler.cost.statistics.CostDataStatistics)1 NodeLabelList (com.alibaba.maxgraph.compiler.cost.statistics.NodeLabelList)1 NodeLabelManager (com.alibaba.maxgraph.compiler.cost.statistics.NodeLabelManager)1 OptimizeConfig (com.alibaba.maxgraph.compiler.optimizer.OptimizeConfig)1 TreeBuilder (com.alibaba.maxgraph.compiler.tree.TreeBuilder)1 TreeManager (com.alibaba.maxgraph.compiler.tree.TreeManager)1 SourceTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode)1 SourceVertexTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode)1