Search in sources :

Example 1 with NodeLabelManager

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

CostGraph (com.alibaba.maxgraph.compiler.cost.CostGraph)1 CostModelManager (com.alibaba.maxgraph.compiler.cost.CostModelManager)1 CostPath (com.alibaba.maxgraph.compiler.cost.CostPath)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 SourceTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode)1 SourceVertexTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode)1