use of com.alibaba.maxgraph.sdkcommon.compiler.custom.aggregate.CustomAggregationListTraversal in project GraphScope by alibaba.
the class TreeBuilder method travelTraversalDirectly.
private <S, E> TreeNode travelTraversalDirectly(Traversal.Admin<S, E> admin, TreeNode parent) {
if (admin instanceof TokenTraversal) {
return new TokenTreeNode(parent, schema, TokenTraversal.class.cast(admin).getToken());
} else if (admin instanceof ValueTraversal) {
ValueTraversal elementValueTraversal = ValueTraversal.class.cast(admin);
String propKey = elementValueTraversal.getPropertyKey();
TreeNode bypassTreeNode = null;
Traversal.Admin<?, ?> bypassTraversal = ReflectionUtils.getFieldValue(AbstractLambdaTraversal.class, elementValueTraversal, "bypassTraversal");
if (null != bypassTraversal) {
bypassTreeNode = travelTraversalAdmin(bypassTraversal, new SourceDelegateNode(parent, schema));
}
return new ElementValueTreeNode(parent, propKey, bypassTreeNode, schema);
} else if (admin instanceof ColumnTraversal) {
ColumnTraversal columnTraversal = ColumnTraversal.class.cast(admin);
return new ColumnTreeNode(parent, schema, columnTraversal.getColumn());
} else if (admin instanceof IdentityTraversal) {
return parent;
} else if (admin instanceof TrueTraversal) {
return parent;
} else if (admin instanceof ConstantTraversal) {
return new ConstantTreeNode(parent, schema, admin.next());
} else if (admin instanceof CustomAggregationListTraversal) {
CustomAggregationListTraversal customAggregationListTraversal = CustomAggregationListTraversal.class.cast(admin);
List<TreeNode> aggNodeList = Lists.newArrayList();
boolean saveFlag = this.rootPathFlag;
this.rootPathFlag = false;
List<Traversal<?, ?>> traversalList = customAggregationListTraversal.getTraversalList();
for (Traversal<?, ?> aggTraversal : traversalList) {
aggNodeList.add(travelTraversalAdmin(aggTraversal.asAdmin(), new SourceDelegateNode(parent, schema)));
}
this.rootPathFlag = saveFlag;
return new AggregationListTreeNode(parent, schema, customAggregationListTraversal.getNameList(), aggNodeList);
} else {
throw new IllegalArgumentException("Not deal with direct traversal => " + admin);
}
}
use of com.alibaba.maxgraph.sdkcommon.compiler.custom.aggregate.CustomAggregationListTraversal 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");
}
}
}
Aggregations