Search in sources :

Example 6 with BOperatorInvocation

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);
}
Also used : BInputPort(com.ibm.streamsx.topology.builder.BInputPort) BOperatorInvocation(com.ibm.streamsx.topology.builder.BOperatorInvocation)

Example 7 with BOperatorInvocation

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();
}
Also used : BOperatorInvocation(com.ibm.streamsx.topology.builder.BOperatorInvocation) BOutputPort(com.ibm.streamsx.topology.builder.BOutputPort)

Example 8 with BOperatorInvocation

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);
}
Also used : TSinkImpl(com.ibm.streamsx.topology.internal.core.TSinkImpl) BOperatorInvocation(com.ibm.streamsx.topology.builder.BOperatorInvocation)

Example 9 with BOperatorInvocation

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);
}
Also used : TSinkImpl(com.ibm.streamsx.topology.internal.core.TSinkImpl) BOperatorInvocation(com.ibm.streamsx.topology.builder.BOperatorInvocation)

Example 10 with BOperatorInvocation

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);
}
Also used : Constants(com.ibm.streamsx.topology.internal.logic.Constants) BOperatorInvocation(com.ibm.streamsx.topology.builder.BOperatorInvocation)

Aggregations

BOperatorInvocation (com.ibm.streamsx.topology.builder.BOperatorInvocation)26 BInputPort (com.ibm.streamsx.topology.builder.BInputPort)6 BOutputPort (com.ibm.streamsx.topology.builder.BOutputPort)4 ArrayList (java.util.ArrayList)4 JSONObject (com.ibm.json.java.JSONObject)3 StreamSchema (com.ibm.streams.operator.StreamSchema)3 HashMap (java.util.HashMap)3 JSONArray (com.ibm.json.java.JSONArray)2 TStream (com.ibm.streamsx.topology.TStream)2 TSinkImpl (com.ibm.streamsx.topology.internal.core.TSinkImpl)2 Constants (com.ibm.streamsx.topology.internal.logic.Constants)2 Type (java.lang.reflect.Type)2 BOperator (com.ibm.streamsx.topology.builder.BOperator)1 BOutput (com.ibm.streamsx.topology.builder.BOutput)1 Predicate (com.ibm.streamsx.topology.function.Predicate)1 KeyFunctionHasher (com.ibm.streamsx.topology.internal.logic.KeyFunctionHasher)1 Print (com.ibm.streamsx.topology.internal.logic.Print)1 SPLStream (com.ibm.streamsx.topology.spl.SPLStream)1 Path (java.nio.file.Path)1 Map (java.util.Map)1