Search in sources :

Example 1 with BOutput

use of com.ibm.streamsx.topology.builder.BOutput in project streamsx.topology by IBMStreams.

the class StreamImpl method endLowLatency.

@Override
public TStream<T> endLowLatency() {
    BOutput toEndLowLatency = output();
    // to a composite output port
    if (UNION.isThis(toEndLowLatency.operator().kind()))
        toEndLowLatency = builder().addPassThroughOperator(toEndLowLatency);
    BOutput endedLowLatency = builder().endLowLatency(toEndLowLatency);
    return addMatchingStream(endedLowLatency);
}
Also used : BOutput(com.ibm.streamsx.topology.builder.BOutput)

Example 2 with BOutput

use of com.ibm.streamsx.topology.builder.BOutput in project streamsx.topology by IBMStreams.

the class StreamImpl method lowLatency.

@Override
public TStream<T> lowLatency() {
    BOutput toBeLowLatency = output();
    BOutput lowLatencyOutput = builder().lowLatency(toBeLowLatency);
    return addMatchingStream(lowLatencyOutput);
}
Also used : BOutput(com.ibm.streamsx.topology.builder.BOutput)

Example 3 with BOutput

use of com.ibm.streamsx.topology.builder.BOutput in project streamsx.topology by IBMStreams.

the class StreamImpl method isolate.

@Override
public TStream<T> isolate() {
    BOutput toBeIsolated = output();
    if (builder().isInLowLatencyRegion(toBeIsolated))
        throw new IllegalStateException(Messages.getString("CORE_ISOLATE_IN_LOW_LATENCY_REGION"));
    BOutput isolatedOutput = builder().isolate(toBeIsolated);
    return addMatchingStream(isolatedOutput);
}
Also used : BOutput(com.ibm.streamsx.topology.builder.BOutput)

Example 4 with BOutput

use of com.ibm.streamsx.topology.builder.BOutput in project streamsx.topology by IBMStreams.

the class TupleCollection method setupEmbeddedTestHandlers.

public void setupEmbeddedTestHandlers(JavaTestableGraph tg) throws Exception {
    for (TStream<?> stream : handlers.keySet()) {
        Set<StreamHandler<Tuple>> streamHandlers = handlers.get(stream);
        for (StreamHandler<Tuple> streamHandler : streamHandlers) {
            BOutput output = stream.output();
            if (output instanceof BOutputPort) {
                BOutputPort outputPort = (BOutputPort) output;
                tg.registerStreamHandler(outputPort.port(), streamHandler);
            }
        // tg.registerStreamHandler(stream.getPort(), streamHandler);
        }
    }
}
Also used : BOutput(com.ibm.streamsx.topology.builder.BOutput) StreamHandler(com.ibm.streams.flow.handlers.StreamHandler) BOutputPort(com.ibm.streamsx.topology.builder.BOutputPort) OutputTuple(com.ibm.streams.operator.OutputTuple) Tuple(com.ibm.streams.operator.Tuple)

Example 5 with BOutput

use of com.ibm.streamsx.topology.builder.BOutput in project streamsx.topology by IBMStreams.

the class StreamImpl method _parallel.

private TStream<T> _parallel(Supplier<Integer> width, Function<T, ?> keyer) {
    if (width == null)
        throw new IllegalArgumentException("width");
    Integer widthVal;
    if (width.get() != null)
        widthVal = width.get();
    else if (width instanceof SubmissionParameter<?>)
        widthVal = ((SubmissionParameter<Integer>) width).getDefaultValue();
    else
        throw new IllegalArgumentException("Illegal width Supplier: width.get() returns null.");
    if (widthVal != null && widthVal <= 0)
        throw new IllegalArgumentException("The parallel width must be greater than or equal to 1.");
    BOutput toBeParallelized = output();
    boolean isPartitioned = false;
    if (keyer != null) {
        final ToIntFunction<T> hasher = new KeyFunctionHasher<>(keyer);
        BOperatorInvocation hashAdder = JavaFunctional.addFunctionalOperator(this, "HashAdder", HashAdder.class, hasher);
        // hashAdder.json().put("routing", routing.toString());
        BInputPort ip = connectTo(hashAdder, true, null);
        StreamSchema hashSchema = ip.port().getStreamSchema().extend("int32", "__spl_hash");
        toBeParallelized = hashAdder.addOutput(hashSchema);
        isPartitioned = true;
    }
    BOutput parallelOutput = builder().parallel(toBeParallelized, width);
    if (isPartitioned) {
        parallelOutput.json().put("partitioned", true);
        JSONArray partitionKeys = new JSONArray();
        partitionKeys.add("__spl_hash");
        parallelOutput.json().put("partitionedKeys", partitionKeys);
        // Add hash remover
        StreamImpl<T> parallelStream = new StreamImpl<T>(this, parallelOutput, getTupleType());
        BOperatorInvocation hashRemover = builder().addOperator(HashRemover.class, null);
        BInputPort pip = parallelStream.connectTo(hashRemover, true, null);
        parallelOutput = hashRemover.addOutput(pip.port().getStreamSchema().remove("__spl_hash"));
    }
    return addMatchingStream(parallelOutput);
}
Also used : JSONArray(com.ibm.json.java.JSONArray) BOperatorInvocation(com.ibm.streamsx.topology.builder.BOperatorInvocation) StreamSchema(com.ibm.streams.operator.StreamSchema) BOutput(com.ibm.streamsx.topology.builder.BOutput) BInputPort(com.ibm.streamsx.topology.builder.BInputPort) KeyFunctionHasher(com.ibm.streamsx.topology.internal.logic.KeyFunctionHasher)

Aggregations

BOutput (com.ibm.streamsx.topology.builder.BOutput)8 StreamHandler (com.ibm.streams.flow.handlers.StreamHandler)2 Tuple (com.ibm.streams.operator.Tuple)2 TStream (com.ibm.streamsx.topology.TStream)2 BInputPort (com.ibm.streamsx.topology.builder.BInputPort)2 BOperatorInvocation (com.ibm.streamsx.topology.builder.BOperatorInvocation)2 CONSISTENT (com.ibm.streamsx.topology.generator.operator.OpProperties.CONSISTENT)2 KeyFunctionHasher (com.ibm.streamsx.topology.internal.logic.KeyFunctionHasher)2 HashSet (java.util.HashSet)2 JsonArray (com.google.gson.JsonArray)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 JSONArray (com.ibm.json.java.JSONArray)1 OutputPortDeclaration (com.ibm.streams.flow.declare.OutputPortDeclaration)1 JavaTestableGraph (com.ibm.streams.flow.javaprimitives.JavaTestableGraph)1 OutputTuple (com.ibm.streams.operator.OutputTuple)1 StreamSchema (com.ibm.streams.operator.StreamSchema)1 BOutputPort (com.ibm.streamsx.topology.builder.BOutputPort)1 Print (com.ibm.streamsx.topology.internal.logic.Print)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1