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