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);
}
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);
}
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);
}
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);
}
}
}
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);
}
Aggregations