use of com.ibm.streamsx.topology.builder.BOperatorInvocation in project streamsx.topology by IBMStreams.
the class StreamImpl method _transform.
private <U> TStream<U> _transform(Function<T, U> transformer, Type tupleType) {
String opName = transformer.getClass().getSimpleName();
if (opName.isEmpty()) {
opName = TypeDiscoverer.getTupleName(tupleType) + "Transform" + getTupleName();
}
BOperatorInvocation bop = JavaFunctional.addFunctionalOperator(this, opName, FunctionTransform.class, transformer);
SourceInfo.setSourceInfo(bop, StreamImpl.class);
BInputPort inputPort = connectTo(bop, true, null);
// By default add a queue
inputPort.addQueue(true);
return JavaFunctional.addJavaOutput(this, bop, tupleType);
}
use of com.ibm.streamsx.topology.builder.BOperatorInvocation in project streamsx.topology by IBMStreams.
the class StreamImpl method asType.
/**
* Get a stream that is typed to tupleClass,
* adds a dependency on the type.
*/
@Override
public TStream<T> asType(Class<T> tupleClass) {
if (tupleClass.equals(getTupleClass()))
return this;
// Is a schema change needed?
if (Schemas.usesDirectSchema(tupleClass) && !Schemas.getSPLMappingSchema(tupleClass).equals(output().schema())) {
return fixDirectSchema(tupleClass);
}
if (output() instanceof BOutputPort) {
BOutputPort boutput = (BOutputPort) output();
BOperatorInvocation bop = (BOperatorInvocation) boutput.operator();
return JavaFunctional.getJavaTStream(this, bop, boutput, tupleClass);
}
// TODO
throw new UnsupportedOperationException();
}
use of com.ibm.streamsx.topology.builder.BOperatorInvocation in project streamsx.topology by IBMStreams.
the class JavaPrimitive method invokeJavaPrimitiveSink.
/**
* Invocation of a Java primitive operator that consumes a Stream.
*
* @param opClass
* Class of the operator to be invoked
* @param input
* Stream that will be connected to the only input port of the
* operator
* @param params
* Parameters for the SPL Java Primitive operator, ignored if {@code null}.
*/
public static TSink invokeJavaPrimitiveSink(Class<? extends Operator> opClass, SPLInput input, Map<String, ? extends Object> params) {
BOperatorInvocation sink = input.builder().addOperator(getInvocationName(opClass), opClass, params);
SourceInfo.setSourceInfo(sink, JavaPrimitive.class);
SPL.connectInputToOperator(input, sink);
return new TSinkImpl(input.topology(), sink);
}
use of com.ibm.streamsx.topology.builder.BOperatorInvocation in project streamsx.topology by IBMStreams.
the class SPL method invokeSink.
/**
* Invocation an SPL operator that consumes a Stream.
*
* @param name
* Name of the operator
* @param kind
* SPL kind of the operator to be invoked.
* @param input
* Stream that will be connected to the only input port of the
* operator
* @param params
* Parameters for the SPL operator, ignored if it is null.
* @return the sink element
*/
public static TSink invokeSink(String name, String kind, SPLInput input, Map<String, ? extends Object> params) {
BOperatorInvocation op = input.builder().addSPLOperator(name, kind, params);
SourceInfo.setSourceInfo(op, SPL.class);
SPL.connectInputToOperator(input, op);
return new TSinkImpl(input.topology(), op);
}
use of com.ibm.streamsx.topology.builder.BOperatorInvocation in project streamsx.topology by IBMStreams.
the class Topology method _source.
private <T> TStream<T> _source(Supplier<Iterable<T>> data, Type tupleType) {
String opName = LogicUtils.functionName(data);
if (opName.isEmpty()) {
opName = getTupleName(tupleType) + "Source";
} else if (data instanceof Constants) {
opName = getTupleName(tupleType) + opName;
}
BOperatorInvocation bop = JavaFunctional.addFunctionalOperator(this, opName, FunctionSource.class, data);
SourceInfo.setSourceInfo(bop, getClass());
return JavaFunctional.addJavaOutput(this, bop, tupleType);
}
Aggregations