use of com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan in project GraphScope by alibaba.
the class TraversalFlatMapTreeNode method buildLogicalQueryPlan.
@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
TreeNodeLabelManager treeNodeLabelManager = contextManager.getTreeNodeLabelManager();
LogicalVertex inputVertex = getInputNode().getOutputVertex();
LogicalSubQueryPlan logicalQueryPlan = new LogicalSubQueryPlan(contextManager);
logicalQueryPlan.addLogicalVertex(inputVertex);
LogicalQueryPlan flatMapPlan = TreeNodeUtils.buildSubQueryPlan(flatMapNode, inputVertex, contextManager);
logicalQueryPlan.mergeLogicalQueryPlan(flatMapPlan);
LogicalVertex flatOutputVertex = logicalQueryPlan.getOutputVertex();
LogicalVertex inputTargetVertex = flatMapPlan.getTargetVertex(inputVertex);
if (inputTargetVertex.getProcessorFunction().getOperatorType() == QueryFlowOuterClass.OperatorType.ENTER_KEY && !(flatOutputVertex instanceof LogicalBinaryVertex)) {
flatOutputVertex.getAfterRequirementList().add(QueryFlowOuterClass.RequirementValue.newBuilder().setReqType(QueryFlowOuterClass.RequirementType.KEY_DEL));
}
addUsedLabelAndRequirement(flatOutputVertex, treeNodeLabelManager);
setFinishVertex(flatOutputVertex, treeNodeLabelManager);
return logicalQueryPlan;
}
use of com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan 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.compiler.logical.LogicalSubQueryPlan in project GraphScope by alibaba.
the class MaxTreeNode method buildLogicalQueryPlan.
@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
LogicalSubQueryPlan logicalSubQueryPlan = new LogicalSubQueryPlan(contextManager);
LogicalVertex sourceVertex = getInputNode().getOutputVertex();
logicalSubQueryPlan.addLogicalVertex(sourceVertex);
ValueValueType valueValueType = ValueValueType.class.cast(getInputNode().getOutputValueType());
QueryFlowOuterClass.OperatorType operatorType = getUseKeyOperator(QueryFlowOuterClass.OperatorType.MAX);
ProcessorFunction maxFunction = new ProcessorFunction(operatorType, Message.Value.newBuilder().setValueType(valueValueType.getDataType()));
LogicalUnaryVertex maxVertex = new LogicalUnaryVertex(contextManager.getVertexIdManager().getId(), maxFunction, isPropLocalFlag(), sourceVertex);
logicalSubQueryPlan.addLogicalVertex(maxVertex);
logicalSubQueryPlan.addLogicalEdge(sourceVertex, maxVertex, new LogicalEdge());
setFinishVertex(maxVertex, contextManager.getTreeNodeLabelManager());
addUsedLabelAndRequirement(maxVertex, contextManager.getTreeNodeLabelManager());
return logicalSubQueryPlan;
}
use of com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan in project GraphScope by alibaba.
the class MinTreeNode method buildLogicalQueryPlan.
@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
LogicalSubQueryPlan logicalSubQueryPlan = new LogicalSubQueryPlan(contextManager);
LogicalVertex sourceVertex = getInputNode().getOutputVertex();
logicalSubQueryPlan.addLogicalVertex(sourceVertex);
ValueValueType valueValueType = ValueValueType.class.cast(getInputNode().getOutputValueType());
QueryFlowOuterClass.OperatorType operatorType = getUseKeyOperator(QueryFlowOuterClass.OperatorType.MIN);
ProcessorFunction minFunction = new ProcessorFunction(operatorType, Message.Value.newBuilder().setValueType(valueValueType.getDataType()));
LogicalUnaryVertex minVertex = new LogicalUnaryVertex(contextManager.getVertexIdManager().getId(), minFunction, isPropLocalFlag(), sourceVertex);
logicalSubQueryPlan.addLogicalVertex(minVertex);
logicalSubQueryPlan.addLogicalEdge(sourceVertex, minVertex, new LogicalEdge());
setFinishVertex(minVertex, contextManager.getTreeNodeLabelManager());
addUsedLabelAndRequirement(minVertex, contextManager.getTreeNodeLabelManager());
return logicalSubQueryPlan;
}
use of com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan in project GraphScope by alibaba.
the class NotTreeNode method buildLogicalQueryPlan.
@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
LogicalSubQueryPlan logicalSubQueryPlan = new LogicalSubQueryPlan(contextManager);
LogicalVertex delegateSourceVertex = getInputNode().getOutputVertex();
logicalSubQueryPlan.addLogicalVertex(delegateSourceVertex);
TreeNode currentNotNode = TreeNodeUtils.buildSingleOutputNode(notTreeNode, schema);
LogicalSubQueryPlan notQueryPlan = TreeNodeUtils.buildSubQueryPlanWithKey(currentNotNode, delegateSourceVertex, contextManager.getTreeNodeLabelManager(), contextManager, contextManager.getVertexIdManager());
LogicalVertex notValueVertex = notQueryPlan.getOutputVertex();
logicalSubQueryPlan.mergeLogicalQueryPlan(notQueryPlan);
TreeNode sourceNode = TreeNodeUtils.getSourceTreeNode(currentNotNode);
LogicalVertex enterKeyVertex = sourceNode.getOutputVertex();
ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.JOIN_DIRECT_FILTER_NEGATE);
LogicalBinaryVertex logicalBinaryVertex = new LogicalBinaryVertex(contextManager.getVertexIdManager().getId(), processorFunction, false, enterKeyVertex, notValueVertex);
logicalSubQueryPlan.addLogicalVertex(logicalBinaryVertex);
logicalSubQueryPlan.addLogicalEdge(enterKeyVertex, logicalBinaryVertex, new LogicalEdge());
logicalSubQueryPlan.addLogicalEdge(notValueVertex, logicalBinaryVertex, new LogicalEdge());
LogicalVertex outputVertex = logicalSubQueryPlan.getOutputVertex();
addUsedLabelAndRequirement(outputVertex, contextManager.getTreeNodeLabelManager());
setFinishVertex(outputVertex, contextManager.getTreeNodeLabelManager());
return logicalSubQueryPlan;
}
Aggregations