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());
}
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);
}
Aggregations