Search in sources :

Example 1 with Builder

use of com.alibaba.maxgraph.QueryFlowOuterClass.OdpsOutputConfig.Builder 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 2 with Builder

use of com.alibaba.maxgraph.QueryFlowOuterClass.OdpsOutputConfig.Builder in project GraphScope by alibaba.

the class OutputTreeNode method buildArg.

private Builder buildArg() {
    if (this.path.startsWith(TUNNEL)) {
        String remain = StringUtils.removeStart(path, TUNNEL);
        String[] tokens = StringUtils.split(remain, '@');
        if (tokens.length != 2) {
            throw ILLEGAL_TUNNEL_EXCEPTION;
        }
        String[] idKey = StringUtils.split(tokens[0], ':');
        if (idKey.length != 2) {
            throw ILLEGAL_TUNNEL_EXCEPTION;
        }
        Builder odpsConfigBuilder = QueryFlowOuterClass.OdpsOutputConfig.newBuilder().setAccessId(idKey[0]).setAccessKey(idKey[1]);
        String[] endpointAndOthers = StringUtils.split(tokens[1], '#');
        if (endpointAndOthers.length != 2) {
            throw ILLEGAL_TUNNEL_EXCEPTION;
        }
        odpsConfigBuilder.setEndpoint(endpointAndOthers[0]);
        String[] details = StringUtils.split(endpointAndOthers[1], '&');
        for (String detail : details) {
            String[] keyValue = StringUtils.split(detail, '=');
            if (keyValue.length != 2) {
                throw ILLEGAL_TUNNEL_EXCEPTION;
            }
            if (keyValue[0].equalsIgnoreCase("project")) {
                odpsConfigBuilder.setProject(keyValue[1]);
            } else if (keyValue[0].equalsIgnoreCase("table")) {
                odpsConfigBuilder.setTableName(keyValue[1]);
            } else if (keyValue[0].equalsIgnoreCase("ds")) {
                odpsConfigBuilder.setDs(keyValue[1]);
            } else {
                throw ILLEGAL_TUNNEL_EXCEPTION;
            }
        }
        return odpsConfigBuilder;
    }
    throw ILLEGAL_TUNNEL_EXCEPTION;
}
Also used : Builder(com.alibaba.maxgraph.QueryFlowOuterClass.OdpsOutputConfig.Builder)

Aggregations

Builder (com.alibaba.maxgraph.QueryFlowOuterClass.OdpsOutputConfig.Builder)2 LogicalEdge (com.alibaba.maxgraph.compiler.logical.LogicalEdge)1 LogicalSubQueryPlan (com.alibaba.maxgraph.compiler.logical.LogicalSubQueryPlan)1 LogicalUnaryVertex (com.alibaba.maxgraph.compiler.logical.LogicalUnaryVertex)1 LogicalVertex (com.alibaba.maxgraph.compiler.logical.LogicalVertex)1 VertexIdManager (com.alibaba.maxgraph.compiler.logical.VertexIdManager)1 ProcessorFunction (com.alibaba.maxgraph.compiler.logical.function.ProcessorFunction)1