Search in sources :

Example 46 with ProcessorFunction

use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.

the class SampleGlobalTreeNode method buildLogicalQueryPlan.

@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
    TreeNodeLabelManager labelManager = contextManager.getTreeNodeLabelManager();
    VertexIdManager vertexIdManager = contextManager.getVertexIdManager();
    Message.Value.Builder argumentBuilder = createArgumentBuilder();
    argumentBuilder.setIntValue(amountToSample);
    ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.SAMPLE, argumentBuilder);
    return parseSingleUnaryVertex(vertexIdManager, labelManager, processorFunction, contextManager);
}
Also used : ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) VertexIdManager(com.alibaba.maxgraph.compiler.logical.VertexIdManager)

Example 47 with ProcessorFunction

use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.

the class SelectOneTreeNode method buildLogicalQueryPlan.

@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
    TreeNodeLabelManager labelManager = contextManager.getTreeNodeLabelManager();
    VertexIdManager vertexIdManager = contextManager.getVertexIdManager();
    Map<String, Integer> labelIndexList = labelManager.getLabelIndexList();
    ProcessorFunction selectOneFunction = TreeNodeUtils.createSelectOneFunction(selectLabel, pop, labelIndexList);
    LogicalSubQueryPlan logicalSubQueryPlan = parseSingleUnaryVertex(vertexIdManager, labelManager, selectOneFunction, contextManager, LogicalEdge.shuffleByKey(0), null == traversalTreeNode);
    if (null != traversalTreeNode && !contextManager.getCostModelManager().processFieldValue(selectLabel)) {
        LogicalSubQueryPlan traversalValuePlan = TreeNodeUtils.buildSubQueryPlan(traversalTreeNode, logicalSubQueryPlan.getOutputVertex(), contextManager);
        logicalSubQueryPlan.mergeLogicalQueryPlan(traversalValuePlan);
        LogicalVertex outputVertex = logicalSubQueryPlan.getOutputVertex();
        addUsedLabelAndRequirement(outputVertex, labelManager);
        setFinishVertex(outputVertex, labelManager);
    }
    return logicalSubQueryPlan;
}
Also used : ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) LogicalVertex(com.alibaba.maxgraph.compiler.logical.LogicalVertex) VertexIdManager(com.alibaba.maxgraph.compiler.logical.VertexIdManager) LogicalSubQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)

Example 48 with ProcessorFunction

use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.

the class SelectTreeNode method parseJoinQueryPlan.

private LogicalSubQueryPlan parseJoinQueryPlan(ContextManager contextManager, VertexIdManager vertexIdManager, TreeNodeLabelManager labelManager, Map<String, Integer> labelIndexList) {
    LogicalSubQueryPlan logicalSubQueryPlan = new LogicalSubQueryPlan(contextManager);
    LogicalVertex delegateSourceVertex = getInputNode().getOutputVertex();
    logicalSubQueryPlan.addLogicalVertex(delegateSourceVertex);
    Set<String> selectKeySet = Sets.newHashSet();
    List<Integer> keyIdList = Lists.newArrayList();
    List<Integer> valueIdList = Lists.newArrayList();
    for (int i = 0; i < selectKeyList.size(); i++) {
        String selectKey = selectKeyList.get(i);
        if (selectKeySet.contains(selectKey)) {
            continue;
        }
        selectKeySet.add(selectKey);
        TreeNode traversalTreeNode = traversalTreeNodeList.get(i % traversalTreeNodeList.size());
        int labelIndex = labelIndexList.get(selectKey);
        keyIdList.add(labelIndex);
        valueIdList.add(labelIndexList.get(selectKey));
        if (!(traversalTreeNode instanceof SourceDelegateNode)) {
            TreeNode currentTraversalNode = TreeNodeUtils.buildSingleOutputNode(traversalTreeNode, schema);
            LogicalVertex outputVertex = logicalSubQueryPlan.getOutputVertex();
            LogicalSubQueryPlan traversalPlan = TreeNodeUtils.buildSubQueryPlan(currentTraversalNode, outputVertex, contextManager);
            List<LogicalVertex> resultVertexList = traversalPlan.getLogicalVertexList();
            if (resultVertexList.size() == 2) {
                LogicalVertex fieldValueVertex = resultVertexList.get(1);
                ProcessorLabelValueFunction labelValueFunction = new ProcessorLabelValueFunction(labelIndex, fieldValueVertex);
                labelValueFunction.setRequireLabelFlag(true);
                LogicalVertex labelValueVertex = new LogicalUnaryVertex(vertexIdManager.getId(), labelValueFunction, outputVertex);
                logicalSubQueryPlan.addLogicalVertex(labelValueVertex);
                logicalSubQueryPlan.addLogicalEdge(outputVertex, labelValueVertex, LogicalEdge.shuffleByKey(labelIndex));
            } else {
                LogicalVertex fieldValueVertex = traversalPlan.getOutputVertex();
                fieldValueVertex.getAfterRequirementList().add(QueryFlowOuterClass.RequirementValue.newBuilder().setReqType(QueryFlowOuterClass.RequirementType.LABEL_START).setReqArgument(Message.Value.newBuilder().addIntValueList(labelIndex)));
                logicalSubQueryPlan.mergeLogicalQueryPlan(traversalPlan);
                LogicalVertex outputKeyVertex = new LogicalUnaryVertex(vertexIdManager.getId(), new ProcessorFunction(QueryFlowOuterClass.OperatorType.KEY_MESSAGE), fieldValueVertex);
                logicalSubQueryPlan.addLogicalVertex(outputKeyVertex);
                logicalSubQueryPlan.addLogicalEdge(fieldValueVertex, outputKeyVertex, LogicalEdge.forwardEdge());
            }
        }
    }
    LogicalVertex selectInputVertex = logicalSubQueryPlan.getOutputVertex();
    Message.Value.Builder argumentBuilder = Message.Value.newBuilder().setBoolValue(true).setIntValue(pop == null ? Message.PopType.POP_EMPTY.getNumber() : Message.PopType.valueOf(StringUtils.upperCase(pop.name())).getNumber()).addAllIntValueList(valueIdList).addAllStrValueList(keyIdList.stream().map(labelManager::getLabelName).collect(Collectors.toList()));
    ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.SELECT, argumentBuilder);
    processorFunction.getUsedLabelList().addAll(valueIdList);
    LogicalVertex selectVertex = new LogicalUnaryVertex(vertexIdManager.getId(), processorFunction, false, selectInputVertex);
    logicalSubQueryPlan.addLogicalVertex(selectVertex);
    logicalSubQueryPlan.addLogicalEdge(selectInputVertex, selectVertex, new LogicalEdge(EdgeShuffleType.FORWARD));
    return logicalSubQueryPlan;
}
Also used : LogicalUnaryVertex(com.alibaba.maxgraph.compiler.logical.LogicalUnaryVertex) ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) LogicalEdge(com.alibaba.maxgraph.compiler.logical.LogicalEdge) SourceDelegateNode(com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode) LogicalVertex(com.alibaba.maxgraph.compiler.logical.LogicalVertex) ProcessorLabelValueFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorLabelValueFunction) LogicalSubQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)

Example 49 with ProcessorFunction

use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.

the class ShortestPathTreeNode method buildLogicalQueryPlan.

@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
    TreeNodeLabelManager labelManager = contextManager.getTreeNodeLabelManager();
    VertexIdManager vertexIdManager = contextManager.getVertexIdManager();
    ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.PROGRAM_GRAPH_SHORTESTPATH, createOperatorArgument());
    return parseSingleUnaryVertex(vertexIdManager, labelManager, processorFunction, contextManager);
}
Also used : ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) VertexIdManager(com.alibaba.maxgraph.compiler.logical.VertexIdManager)

Example 50 with ProcessorFunction

use of com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction in project GraphScope by alibaba.

the class ShortestPathVertexProgramTreeNode method buildLogicalQueryPlan.

@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
    TreeNodeLabelManager labelManager = contextManager.getTreeNodeLabelManager();
    VertexIdManager vertexIdManager = contextManager.getVertexIdManager();
    ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.PROGRAM_GRAPH_SHORTESTPATH, createOperatorArgument());
    return parseSingleUnaryVertex(vertexIdManager, labelManager, processorFunction, contextManager);
}
Also used : ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) VertexIdManager(com.alibaba.maxgraph.compiler.logical.VertexIdManager)

Aggregations

ProcessorFunction (com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction)71 LogicalVertex (com.alibaba.maxgraph.compiler.logical.LogicalVertex)38 LogicalEdge (com.alibaba.maxgraph.compiler.logical.LogicalEdge)36 LogicalSubQueryPlan (com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)34 VertexIdManager (com.alibaba.maxgraph.compiler.logical.VertexIdManager)34 LogicalUnaryVertex (com.alibaba.maxgraph.compiler.logical.LogicalUnaryVertex)27 QueryFlowOuterClass (com.alibaba.maxgraph.QueryFlowOuterClass)18 LogicalBinaryVertex (com.alibaba.maxgraph.compiler.logical.LogicalBinaryVertex)18 SourceDelegateNode (com.alibaba.maxgraph.compiler.tree.source.SourceDelegateNode)10 SourceTreeNode (com.alibaba.maxgraph.compiler.tree.source.SourceTreeNode)9 Message (com.alibaba.maxgraph.Message)7 LogicalQueryPlan (com.alibaba.maxgraph.compiler.logical.LogicalQueryPlan)7 TreeNode (com.alibaba.maxgraph.compiler.tree.TreeNode)5 List (java.util.List)5 ProcessorSourceFunction (com.alibaba.maxgraph.compiler.logical.function.ProcessorSourceFunction)4 CountGlobalTreeNode (com.alibaba.maxgraph.compiler.tree.CountGlobalTreeNode)4 FoldTreeNode (com.alibaba.maxgraph.compiler.tree.FoldTreeNode)4 HasTreeNode (com.alibaba.maxgraph.compiler.tree.HasTreeNode)4 MaxTreeNode (com.alibaba.maxgraph.compiler.tree.MaxTreeNode)4 MinTreeNode (com.alibaba.maxgraph.compiler.tree.MinTreeNode)4