Search in sources :

Example 11 with LogicalSubQueryPlan

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;
}
Also used : LogicalVertex(com.alibaba.maxgraph.compiler.logical.LogicalVertex) LogicalQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalQueryPlan) LogicalBinaryVertex(com.alibaba.maxgraph.compiler.logical.LogicalBinaryVertex) LogicalSubQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)

Example 12 with LogicalSubQueryPlan

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);
    }
}
Also used : ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) LogicalVertex(com.alibaba.maxgraph.compiler.logical.LogicalVertex) LogicalSourceDelegateVertex(com.alibaba.maxgraph.compiler.logical.LogicalSourceDelegateVertex) Message(com.alibaba.maxgraph.Message) List(java.util.List) RangeSumFunction(com.alibaba.maxgraph.sdkcommon.compiler.custom.map.RangeSumFunction) MapPropFillFunction(com.alibaba.maxgraph.sdkcommon.compiler.custom.map.MapPropFillFunction) LogicalSubQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)

Example 13 with LogicalSubQueryPlan

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;
}
Also used : LogicalUnaryVertex(com.alibaba.maxgraph.compiler.logical.LogicalUnaryVertex) LogicalVertex(com.alibaba.maxgraph.compiler.logical.LogicalVertex) ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) LogicalEdge(com.alibaba.maxgraph.compiler.logical.LogicalEdge) ValueValueType(com.alibaba.maxgraph.compiler.tree.value.ValueValueType) QueryFlowOuterClass(com.alibaba.maxgraph.QueryFlowOuterClass) LogicalSubQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)

Example 14 with 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;
}
Also used : LogicalUnaryVertex(com.alibaba.maxgraph.compiler.logical.LogicalUnaryVertex) LogicalVertex(com.alibaba.maxgraph.compiler.logical.LogicalVertex) ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) LogicalEdge(com.alibaba.maxgraph.compiler.logical.LogicalEdge) ValueValueType(com.alibaba.maxgraph.compiler.tree.value.ValueValueType) QueryFlowOuterClass(com.alibaba.maxgraph.QueryFlowOuterClass) LogicalSubQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)

Example 15 with 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;
}
Also used : LogicalVertex(com.alibaba.maxgraph.compiler.logical.LogicalVertex) ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) LogicalEdge(com.alibaba.maxgraph.compiler.logical.LogicalEdge) LogicalBinaryVertex(com.alibaba.maxgraph.compiler.logical.LogicalBinaryVertex) LogicalSubQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)

Aggregations

LogicalSubQueryPlan (com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)49 LogicalVertex (com.alibaba.maxgraph.compiler.logical.LogicalVertex)41 ProcessorFunction (com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction)34 LogicalEdge (com.alibaba.maxgraph.compiler.logical.LogicalEdge)29 LogicalUnaryVertex (com.alibaba.maxgraph.compiler.logical.LogicalUnaryVertex)27 VertexIdManager (com.alibaba.maxgraph.compiler.logical.VertexIdManager)18 LogicalBinaryVertex (com.alibaba.maxgraph.compiler.logical.LogicalBinaryVertex)15 QueryFlowOuterClass (com.alibaba.maxgraph.QueryFlowOuterClass)13 SourceDelegateNode (com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode)11 SourceTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode)10 LogicalQueryPlan (com.alibaba.maxgraph.compiler.logical.LogicalQueryPlan)6 Message (com.alibaba.maxgraph.Message)5 ProcessorSourceFunction (com.alibaba.maxgraph.compiler.logical.function.ProcessorSourceFunction)5 CountGlobalTreeNode (com.alibaba.maxgraph.compiler.tree.CountGlobalTreeNode)5 FoldTreeNode (com.alibaba.maxgraph.compiler.tree.FoldTreeNode)5 HasTreeNode (com.alibaba.maxgraph.compiler.tree.HasTreeNode)5 MaxTreeNode (com.alibaba.maxgraph.compiler.tree.MaxTreeNode)5 MinTreeNode (com.alibaba.maxgraph.compiler.tree.MinTreeNode)5 PropertyMapTreeNode (com.alibaba.maxgraph.compiler.tree.PropertyMapTreeNode)5 RangeGlobalTreeNode (com.alibaba.maxgraph.compiler.tree.RangeGlobalTreeNode)5