Search in sources :

Example 1 with Constants

use of com.ibm.streamsx.topology.internal.logic.Constants 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)

Example 2 with Constants

use of com.ibm.streamsx.topology.internal.logic.Constants in project streamsx.topology by IBMStreams.

the class Topology method _periodicMultiSource.

private <T> TStream<T> _periodicMultiSource(Supplier<Iterable<T>> data, long period, TimeUnit unit, Type tupleType) {
    String opName = LogicUtils.functionName(data);
    if (opName.isEmpty()) {
        opName = TypeDiscoverer.getTupleName(tupleType) + "PeriodicMultiSource";
    } else if (data instanceof Constants) {
        opName = TypeDiscoverer.getTupleName(tupleType) + opName;
    }
    double dperiod = ((double) unit.toMillis(period)) / 1000.0;
    Map<String, Object> params = new HashMap<>();
    params.put("period", dperiod);
    BOperatorInvocation bop = JavaFunctional.addFunctionalOperator(this, opName, FunctionPeriodicSource.class, data, params);
    SourceInfo.setSourceInfo(bop, getClass());
    return JavaFunctional.addJavaOutput(this, bop, tupleType);
}
Also used : HashMap(java.util.HashMap) Constants(com.ibm.streamsx.topology.internal.logic.Constants) BOperatorInvocation(com.ibm.streamsx.topology.builder.BOperatorInvocation) JSONObject(com.ibm.json.java.JSONObject)

Aggregations

BOperatorInvocation (com.ibm.streamsx.topology.builder.BOperatorInvocation)2 Constants (com.ibm.streamsx.topology.internal.logic.Constants)2 JSONObject (com.ibm.json.java.JSONObject)1 HashMap (java.util.HashMap)1