Search in sources :

Example 1 with AndTreeNode

use of com.alibaba.maxgraph.compiler.tree.AndTreeNode in project GraphScope by alibaba.

the class LabelPushDownStrategy method apply.

@Override
public void apply(TreeManager treeManager) {
    while (true) {
        BaseTreeNode treeNode = (BaseTreeNode) TreeNodeUtils.getSourceTreeNode(treeManager.getTreeLeaf());
        boolean labelOptimizeFlag = false;
        while (true) {
            Map<QueryFlowOuterClass.RequirementType, Object> afterRequirementList = treeNode.getAfterRequirementList();
            BaseTreeNode outputNode = (BaseTreeNode) treeNode.getOutputNode();
            if (null != outputNode && !(outputNode instanceof RepeatTreeNode) && !(outputNode instanceof UnionTreeNode) && !(outputNode instanceof AndTreeNode) && !(outputNode instanceof WherePredicateTreeNode) && outputNode.getNodeType() != NodeType.AGGREGATE) {
                Set<String> labelList = (Set<String>) afterRequirementList.remove(QueryFlowOuterClass.RequirementType.LABEL_START);
                if (null != labelList) {
                    labelOptimizeFlag = true;
                    outputNode.getBeforeRequirementList().put(QueryFlowOuterClass.RequirementType.LABEL_START, labelList);
                }
            }
            if (outputNode == null) {
                break;
            }
            treeNode = outputNode;
        }
        if (!labelOptimizeFlag) {
            break;
        }
    }
}
Also used : WherePredicateTreeNode(com.alibaba.maxgraph.compiler.tree.WherePredicateTreeNode) Set(java.util.Set) UnionTreeNode(com.alibaba.maxgraph.compiler.tree.UnionTreeNode) AndTreeNode(com.alibaba.maxgraph.compiler.tree.AndTreeNode) RepeatTreeNode(com.alibaba.maxgraph.compiler.tree.RepeatTreeNode) BaseTreeNode(com.alibaba.maxgraph.compiler.tree.BaseTreeNode)

Aggregations

AndTreeNode (com.alibaba.maxgraph.compiler.tree.AndTreeNode)1 BaseTreeNode (com.alibaba.maxgraph.compiler.tree.BaseTreeNode)1 RepeatTreeNode (com.alibaba.maxgraph.compiler.tree.RepeatTreeNode)1 UnionTreeNode (com.alibaba.maxgraph.compiler.tree.UnionTreeNode)1 WherePredicateTreeNode (com.alibaba.maxgraph.compiler.tree.WherePredicateTreeNode)1 Set (java.util.Set)1