use of com.alibaba.maxgraph.sdkcommon.compiler.custom.map.RangeSumFunction in project GraphScope by alibaba.
the class LambdaMapTreeNode method buildLogicalQueryPlan.
@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
if (this.mapFunction instanceof RangeSumFunction) {
RangeSumFunction rangeSumFunction = RangeSumFunction.class.cast(this.mapFunction);
int propId = SchemaUtils.getPropId(rangeSumFunction.getPropName(), schema);
ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.RANGE_SUM, Message.Value.newBuilder().setIntValue(propId).addIntValueList(rangeSumFunction.getStart()).addIntValueList(rangeSumFunction.getCount()));
return parseSingleUnaryVertex(contextManager.getVertexIdManager(), contextManager.getTreeNodeLabelManager(), processorFunction, contextManager);
} else if (this.mapFunction instanceof MapPropFillFunction) {
MapPropFillFunction mapPropFillFunction = MapPropFillFunction.class.cast(this.mapFunction);
setPropLocalFlag(true);
List<String> propNameList = mapPropFillFunction.getPropNameList();
List<Integer> propIdList = propNameList.stream().map(v -> CompilerUtils.getPropertyId(schema, v)).collect(Collectors.toList());
LogicalVertex logicalVertex = getInputNode().getOutputVertex();
if (logicalVertex.getProcessorFunction().getOperatorType() == QueryFlowOuterClass.OperatorType.PROP_FILL) {
logicalVertex.getProcessorFunction().getArgumentBuilder().addAllIntValueList(propIdList);
LogicalSubQueryPlan logicalSubQueryPlan = new LogicalSubQueryPlan(contextManager);
logicalSubQueryPlan.addLogicalVertex(new LogicalSourceDelegateVertex(logicalVertex));
return logicalSubQueryPlan;
} else {
ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.PROP_FILL, Message.Value.newBuilder().addAllIntValueList(propIdList));
return parseSingleUnaryVertex(contextManager.getVertexIdManager(), contextManager.getTreeNodeLabelManager(), processorFunction, contextManager);
}
} else {
Message.Value.Builder argumentBuilder = Message.Value.newBuilder().setStrValue(this.lambdaIndex);
ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.LAMBDA_MAP, argumentBuilder);
return parseSingleUnaryVertex(contextManager.getVertexIdManager(), contextManager.getTreeNodeLabelManager(), processorFunction, contextManager);
}
}
use of com.alibaba.maxgraph.sdkcommon.compiler.custom.map.RangeSumFunction 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