Search in sources :

Example 6 with ProcessorFunction

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

the class OutputTreeNode method buildLogicalQueryPlan.

@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
    TreeNodeLabelManager labelManager = contextManager.getTreeNodeLabelManager();
    VertexIdManager vertexIdManager = contextManager.getVertexIdManager();
    Builder odpsConfigBuilder = buildArg();
    for (String propName : properties) {
        odpsConfigBuilder.addPropId(SchemaUtils.getPropId(propName, schema));
    }
    Message.Value.Builder argumentBuilder = Message.Value.newBuilder().setPayload(odpsConfigBuilder.build().toByteString());
    ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.WRITE_ODPS, argumentBuilder);
    LogicalSubQueryPlan logicalSubQueryPlan = parseSingleUnaryVertex(vertexIdManager, labelManager, processorFunction, contextManager);
    LogicalVertex outputVertex = logicalSubQueryPlan.getOutputVertex();
    ProcessorFunction sumFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.SUM, Message.Value.newBuilder().setValueType(Message.VariantType.VT_LONG));
    LogicalVertex sumVertex = new LogicalUnaryVertex(vertexIdManager.getId(), sumFunction, true, outputVertex);
    logicalSubQueryPlan.addLogicalVertex(sumVertex);
    logicalSubQueryPlan.addLogicalEdge(outputVertex, sumVertex, new LogicalEdge(EdgeShuffleType.SHUFFLE_BY_CONST));
    addUsedLabelAndRequirement(sumVertex, labelManager);
    setFinishVertex(sumVertex, labelManager);
    return logicalSubQueryPlan;
}
Also used : LogicalUnaryVertex(com.alibaba.maxgraph.compiler.logical.LogicalUnaryVertex) ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) LogicalVertex(com.alibaba.maxgraph.compiler.logical.LogicalVertex) LogicalEdge(com.alibaba.maxgraph.compiler.logical.LogicalEdge) Builder(com.alibaba.maxgraph.QueryFlowOuterClass.OdpsOutputConfig.Builder) VertexIdManager(com.alibaba.maxgraph.compiler.logical.VertexIdManager) LogicalSubQueryPlan(com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)

Example 7 with ProcessorFunction

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

the class PeerPressureVertexProgramTreeNode method buildLogicalQueryPlan.

@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
    TreeNodeLabelManager labelManager = contextManager.getTreeNodeLabelManager();
    VertexIdManager vertexIdManager = contextManager.getVertexIdManager();
    ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.PROGRAM_GRAPH_PEERPRESSURE, 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 8 with ProcessorFunction

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

the class PropFillTreeNode method buildLogicalQueryPlan.

@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
    TreeNodeLabelManager labelManager = contextManager.getTreeNodeLabelManager();
    VertexIdManager vertexIdManager = contextManager.getVertexIdManager();
    Message.Value.Builder argumentBuilder = Message.Value.newBuilder();
    propKeyList.forEach(v -> argumentBuilder.addIntValueList(SchemaUtils.getPropId(v, schema)));
    ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.PROP_FILL, argumentBuilder);
    if (getInputNode() instanceof SourceVertexTreeNode) {
        return parseSingleUnaryVertex(vertexIdManager, labelManager, processorFunction, contextManager, new LogicalEdge(EdgeShuffleType.FORWARD));
    } else {
        return parseSingleUnaryVertex(vertexIdManager, labelManager, processorFunction, contextManager);
    }
}
Also used : ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) LogicalEdge(com.alibaba.maxgraph.compiler.logical.LogicalEdge) SourceVertexTreeNode(com.alibaba.maxgraph.compiler.tree.source.SourceVertexTreeNode) VertexIdManager(com.alibaba.maxgraph.compiler.logical.VertexIdManager)

Example 9 with ProcessorFunction

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

the class ColumnTreeNode method buildLogicalQueryPlan.

@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
    Map<String, Integer> labelIndexList = contextManager.getTreeNodeLabelManager().getLabelIndexList();
    List<Integer> labelIdList = Lists.newArrayList();
    List<String> labelNameList = Lists.newArrayList();
    for (Map.Entry<String, Integer> entry : labelIndexList.entrySet()) {
        if (entry.getValue() > TreeConstants.SYS_LABEL_START && entry.getValue() <= TreeConstants.USER_LABEL_START)
            labelIdList.add(entry.getValue());
        labelNameList.add(entry.getKey());
    }
    ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.COLUMN, Message.Value.newBuilder().setIntValue(QueryFlowOuterClass.ColumnType.valueOf("COLUMN_" + StringUtils.upperCase(column.name())).getNumber()).addAllIntValueList(labelIdList).addAllStrValueList(labelNameList));
    return parseSingleUnaryVertex(contextManager.getVertexIdManager(), contextManager.getTreeNodeLabelManager(), processorFunction, contextManager);
}
Also used : ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) Map(java.util.Map)

Example 10 with ProcessorFunction

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

the class ConstantTreeNode method buildLogicalQueryPlan.

@Override
public LogicalSubQueryPlan buildLogicalQueryPlan(ContextManager contextManager) {
    Message.Value.Builder argumentBuilder = Message.Value.newBuilder().setValueType(variantType);
    switch(variantType) {
        case VT_INT:
            {
                argumentBuilder.setIntValue((int) constant);
                break;
            }
        case VT_LONG:
            {
                argumentBuilder.setLongValue((long) constant);
                break;
            }
        case VT_FLOAT:
            {
                argumentBuilder.setFloatValue((float) constant);
                break;
            }
        case VT_DOUBLE:
            {
                argumentBuilder.setDoubleValue((double) constant);
                break;
            }
        case VT_STRING:
            {
                argumentBuilder.setStrValue((String) constant);
                break;
            }
        case VT_INT_LIST:
            {
                argumentBuilder.addAllIntValueList((Collection<Integer>) constant);
                break;
            }
        case VT_LONG_LIST:
            {
                argumentBuilder.addAllLongValueList((Collection<Long>) constant);
                break;
            }
        case VT_STRING_LIST:
            {
                argumentBuilder.addAllStrValueList((Collection<String>) constant);
                break;
            }
        default:
            {
                throw new IllegalArgumentException("Not support " + variantType + " constant value");
            }
    }
    ProcessorFunction processorFunction = new ProcessorFunction(QueryFlowOuterClass.OperatorType.CONSTANT, argumentBuilder);
    return parseSingleUnaryVertex(contextManager.getVertexIdManager(), contextManager.getTreeNodeLabelManager(), processorFunction, contextManager);
}
Also used : ProcessorFunction(com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction) Collection(java.util.Collection)

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