Search in sources :

Example 1 with InputPortDeclaration

use of com.ibm.streams.flow.declare.InputPortDeclaration in project streamsx.topology by IBMStreams.

the class BOperatorInvocation method inputFrom.

public BInputPort inputFrom(BOutput output, BInputPort input) {
    if (input != null) {
        assert input.operator() == this.op;
        assert inputs != null;
        output.connectTo(input);
        return input;
    }
    if (inputs == null) {
        inputs = new ArrayList<>();
    }
    InputPortDeclaration inputPort = op.addInput(this.op.getName() + "_IN" + inputs.size(), output.schema());
    input = new BInputPort(this, inputPort);
    inputs.add(input);
    output.connectTo(input);
    return input;
}
Also used : InputPortDeclaration(com.ibm.streams.flow.declare.InputPortDeclaration)

Example 2 with InputPortDeclaration

use of com.ibm.streams.flow.declare.InputPortDeclaration in project streamsx.topology by IBMStreams.

the class EmbeddedGraph method declareInputs.

private void declareInputs(OperatorInvocation<? extends Operator> opDecl, JsonArray inputs) {
    if (jisEmpty(inputs))
        return;
    // Ensure we deal with them in port order.
    JsonObject[] ports = new JsonObject[inputs.size()];
    for (JsonElement e : inputs) {
        JsonObject input = e.getAsJsonObject();
        ports[input.get("index").getAsInt()] = input;
    }
    for (JsonObject input : ports) {
        String name = jstring(input, "name");
        StreamSchema schema = Type.Factory.getTupleType(jstring(input, "type")).getTupleSchema();
        InputPortDeclaration port = opDecl.addInput(name, schema);
        assert !inputPorts.containsKey(name);
        inputPorts.put(name, port);
        if (input.has("window"))
            windowInput(input, port);
    }
}
Also used : InputPortDeclaration(com.ibm.streams.flow.declare.InputPortDeclaration) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) StreamSchema(com.ibm.streams.operator.StreamSchema)

Example 3 with InputPortDeclaration

use of com.ibm.streams.flow.declare.InputPortDeclaration in project streamsx.topology by IBMStreams.

the class EmbeddedGraph method declareOpConnections.

private void declareOpConnections(JsonObject json) {
    JsonArray outputs = json.getAsJsonArray("outputs");
    if (jisEmpty(outputs))
        return;
    for (JsonElement e : outputs) {
        JsonObject output = e.getAsJsonObject();
        String name = jstring(output, "name");
        JsonArray conns = output.getAsJsonArray("connections");
        if (jisEmpty(conns))
            continue;
        OutputPortDeclaration port = requireNonNull(outputPorts.get(name));
        for (JsonElement c : conns) {
            String iname = c.getAsString();
            InputPortDeclaration iport = requireNonNull(inputPorts.get(iname));
            port.connect(iport);
        }
    }
}
Also used : JsonArray(com.google.gson.JsonArray) InputPortDeclaration(com.ibm.streams.flow.declare.InputPortDeclaration) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) OutputPortDeclaration(com.ibm.streams.flow.declare.OutputPortDeclaration)

Aggregations

InputPortDeclaration (com.ibm.streams.flow.declare.InputPortDeclaration)3 JsonElement (com.google.gson.JsonElement)2 JsonObject (com.google.gson.JsonObject)2 JsonArray (com.google.gson.JsonArray)1 OutputPortDeclaration (com.ibm.streams.flow.declare.OutputPortDeclaration)1 StreamSchema (com.ibm.streams.operator.StreamSchema)1