Search in sources :

Example 1 with CustomCaseWhenFunction

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

the class TreeBuilder method visitLambdaMapStep.

private TreeNode visitLambdaMapStep(LambdaMapStep step, TreeNode prev) {
    Function functionObj = step.getMapFunction();
    Function mapFunction;
    if (functionObj instanceof FunctionTraverser) {
        mapFunction = ReflectionUtils.getFieldValue(FunctionTraverser.class, functionObj, "function");
    } else {
        mapFunction = functionObj;
    }
    if (mapFunction instanceof CustomCaseWhenFunction) {
        CustomCaseWhenFunction customCaseWhenFunction = CustomCaseWhenFunction.class.cast(mapFunction);
        return processCaseWhenFunction(prev, customCaseWhenFunction);
    } else if (mapFunction instanceof CustomAggregationListTraversal) {
        CustomAggregationListTraversal customAggregationListTraversal = CustomAggregationListTraversal.class.cast(mapFunction);
        List<Traversal<?, ?>> aggregateTraversalList = customAggregationListTraversal.getTraversalList();
        List<TreeNode> aggregateNodeList = Lists.newArrayList();
        boolean saveFlag = rootPathFlag;
        this.rootPathFlag = false;
        for (Traversal<?, ?> traversal : aggregateTraversalList) {
            aggregateNodeList.add(travelTraversalAdmin(traversal.asAdmin(), new SourceDelegateNode(prev, schema)));
        }
        this.rootPathFlag = saveFlag;
        return new AggregationListTreeNode(prev, schema, customAggregationListTraversal.getNameList(), aggregateNodeList);
    } else if (mapFunction instanceof MapPropFillFunction || mapFunction instanceof RangeSumFunction) {
        return new LambdaMapTreeNode(prev, schema, mapFunction, null);
    } else {
        if (this.lambdaEnableFlag) {
            return new LambdaMapTreeNode(prev, schema, mapFunction, buildLambdaIndex(step));
        } else {
            throw new UnsupportedOperationException("Not support lambda map yet");
        }
    }
}
Also used : CustomAggregationListTraversal(com.alibaba.maxgraph.sdkcommon.compiler.custom.aggregate.CustomAggregationListTraversal) CustomCaseWhenFunction(com.alibaba.maxgraph.sdkcommon.compiler.custom.branch.CustomCaseWhenFunction) RangeSumFunction(com.alibaba.maxgraph.sdkcommon.compiler.custom.map.RangeSumFunction) MapPropFillFunction(com.alibaba.maxgraph.sdkcommon.compiler.custom.map.MapPropFillFunction) CustomWhenThenFunction(com.alibaba.maxgraph.sdkcommon.compiler.custom.branch.CustomWhenThenFunction) Function(java.util.function.Function) CustomCaseWhenFunction(com.alibaba.maxgraph.sdkcommon.compiler.custom.branch.CustomCaseWhenFunction) CustomAggregationListTraversal(com.alibaba.maxgraph.sdkcommon.compiler.custom.aggregate.CustomAggregationListTraversal) Traversal(org.apache.tinkerpop.gremlin.process.traversal.Traversal) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) SourceDelegateNode(com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode) RangeSumFunction(com.alibaba.maxgraph.sdkcommon.compiler.custom.map.RangeSumFunction) MapPropFillFunction(com.alibaba.maxgraph.sdkcommon.compiler.custom.map.MapPropFillFunction)

Aggregations

SourceDelegateNode (com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode)1 CustomAggregationListTraversal (com.alibaba.maxgraph.sdkcommon.compiler.custom.aggregate.CustomAggregationListTraversal)1 CustomCaseWhenFunction (com.alibaba.maxgraph.sdkcommon.compiler.custom.branch.CustomCaseWhenFunction)1 CustomWhenThenFunction (com.alibaba.maxgraph.sdkcommon.compiler.custom.branch.CustomWhenThenFunction)1 MapPropFillFunction (com.alibaba.maxgraph.sdkcommon.compiler.custom.map.MapPropFillFunction)1 RangeSumFunction (com.alibaba.maxgraph.sdkcommon.compiler.custom.map.RangeSumFunction)1 Function (java.util.function.Function)1 Traversal (org.apache.tinkerpop.gremlin.process.traversal.Traversal)1 GraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal)1