Search in sources :

Example 1 with CustomWhenThenFunction

use of com.alibaba.maxgraph.sdkcommon.compiler.custom.branch.CustomWhenThenFunction in project GraphScope by alibaba.

the class TreeBuilder method processCaseWhenFunction.

private TreeNode processCaseWhenFunction(TreeNode prev, CustomCaseWhenFunction customCaseWhenFunction) {
    Traversal<?, ?> caseTraversal = customCaseWhenFunction.getCaseTraversal();
    List<CustomWhenThenFunction> whenThenFunctionList = customCaseWhenFunction.getWhenThenFunctionList();
    Traversal<?, ?> elseEndTraversal = customCaseWhenFunction.getElseEndTraversal();
    boolean saveFlag = rootPathFlag;
    this.rootPathFlag = false;
    TreeNode caseTreeNode = travelTraversalAdmin(caseTraversal.asAdmin(), new SourceDelegateNode(prev, schema));
    List<Pair<TreeNode, TreeNode>> whenThenNodeList = Lists.newArrayList();
    for (CustomWhenThenFunction whenThenFunction : whenThenFunctionList) {
        Pair<TreeNode, TreeNode> whenThenPair = Pair.of(travelTraversalAdmin(whenThenFunction.getWhenPredicate().asAdmin(), new SourceDelegateNode(caseTreeNode, schema)), travelTraversalAdmin(whenThenFunction.getThenTraversal().asAdmin(), new SourceDelegateNode(caseTreeNode, schema)));
        whenThenNodeList.add(whenThenPair);
    }
    TreeNode elseEndTreeNode = elseEndTraversal == null ? null : travelTraversalAdmin(elseEndTraversal.asAdmin(), new SourceDelegateNode(caseTreeNode, schema));
    this.rootPathFlag = saveFlag;
    return new CaseWhenTreeNode(prev, schema, caseTreeNode, whenThenNodeList, elseEndTreeNode);
}
Also used : CustomWhenThenFunction(com.alibaba.maxgraph.sdkcommon.compiler.custom.branch.CustomWhenThenFunction) SourceTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode) EstimateCountTreeNode(com.alibaba.maxgraph.compiler.tree.source.EstimateCountTreeNode) SourceEdgeTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceEdgeTreeNode) SourceVertexTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode) SourceCreateGraphTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceCreateGraphTreeNode) SourceDelegateNode(com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode) Pair(org.apache.commons.lang3.tuple.Pair)

Aggregations

EstimateCountTreeNode (com.alibaba.maxgraph.compiler.tree.source.EstimateCountTreeNode)1 SourceCreateGraphTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceCreateGraphTreeNode)1 SourceDelegateNode (com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode)1 SourceEdgeTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceEdgeTreeNode)1 SourceTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode)1 SourceVertexTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode)1 CustomWhenThenFunction (com.alibaba.maxgraph.sdkcommon.compiler.custom.branch.CustomWhenThenFunction)1 Pair (org.apache.commons.lang3.tuple.Pair)1