public class SPL
extends java.lang.Object
JavaPrimitive
must be used.
::
'. For example
the FileSource
operator from the SPL Standard toolkit must be specified
as spl.adapter::FileSource
.
When necessary use createValue(T, MetaType)
,
or createNullValue()
,
to create parameter values for SPL types.
For example:
Map<String,Object> params = ...
params.put("aInt32", 13);
params.put("aUInt32", SPL.createValue(13, MetaType.UINT32));
params.put("aRString", "some string value");
params.put("aUString", SPL.createValue("some ustring value", MetaType.USTRING));
... = SPLPrimitive.invokeOperator(..., params);
In addition to the usual Java types used for operator parameter values,
a Supplier<T>
parameter value may be specified.
Submission time parameters are passed in this manner.
See createSubmissionParameter(Topology, String, Object, boolean)
.
For example:
Map<String,Object> params = ...
params.put("aInt32", topology.createSubmissionParameter("int32Param", 13);
params.put("aUInt32", SPL.createSubmissionParameter(topology, "uint32Param", SPL.createValue(13, MetaType.UINT32), true);
params.put("aRString", topology.createSubmissionParameter("rstrParam", "some string value");
params.put("aUString", SPL.createSubmissionParameter(topology, "ustrParam", SPL.createValue("some ustring value", MetaType.USTRING), true);
params.put("aUInt8", SPL.createSubmissionParameter(topology, "uint8Param", SPL.createValue((byte)13, MetaType.UINT8), true);
... = SPLPrimitive.invokeOperator(..., params);
Note: Invoking an SPL composite operator with internal
config placement
clauses can cause logical topology constraints
declared by isolate
, lowLatency
or colocate
to be violated. This is due to the config placement clause within the composite definition
overriding the invocation clauses generated for the logical constraints.
Constructor and Description |
---|
SPL() |
Modifier and Type | Method and Description |
---|---|
static void |
addToolkit(TopologyElement te,
java.io.File toolkitRoot)
Add a dependency on an SPL toolkit.
|
static void |
addToolkitDependency(TopologyElement te,
java.lang.String name,
java.lang.String version)
Add a logical dependency on an SPL toolkit.
|
static java.lang.Object |
createNullValue()
Create an SPL value wrapper object for an SPL null value.
|
static <T> Supplier<T> |
createSubmissionParameter(Topology top,
java.lang.String name,
java.lang.Object paramValue,
boolean withDefault)
Create a submission parameter with or without a default value.
|
static <T> java.lang.Object |
createValue(T value,
com.ibm.streams.operator.Type.MetaType metaType)
Create an SPL value wrapper object for the
specified SPL
MetaType . |
static SPLStream |
invokeOperator(java.lang.String kind,
SPLInput input,
com.ibm.streams.operator.StreamSchema outputSchema,
java.util.Map<java.lang.String,? extends java.lang.Object> params)
Create an SPLStream from the invocation of an SPL operator
that consumes a stream.
|
static SPLStream |
invokeOperator(java.lang.String name,
java.lang.String kind,
SPLInput input,
com.ibm.streams.operator.StreamSchema outputSchema,
java.util.Map<java.lang.String,? extends java.lang.Object> params)
Create an SPLStream from the invocation of an SPL operator
that consumes a stream and produces a stream.
|
static java.util.List<SPLStream> |
invokeOperator(TopologyElement te,
java.lang.String name,
java.lang.String kind,
java.util.List<? extends SPLInput> inputs,
java.util.List<com.ibm.streams.operator.StreamSchema> outputSchemas,
java.util.Map<java.lang.String,? extends java.lang.Object> params)
Invoke an SPL operator with an arbitrary number
of input and output ports.
|
static TSink |
invokeSink(java.lang.String kind,
SPLInput input,
java.util.Map<java.lang.String,? extends java.lang.Object> params)
Invocation an SPL operator that consumes a Stream.
|
static TSink |
invokeSink(java.lang.String name,
java.lang.String kind,
SPLInput input,
java.util.Map<java.lang.String,? extends java.lang.Object> params)
Invocation an SPL operator that consumes a Stream.
|
static SPLStream |
invokeSource(TopologyElement te,
java.lang.String kind,
java.util.Map<java.lang.String,java.lang.Object> params,
com.ibm.streams.operator.StreamSchema schema)
Invocation an SPL source operator to produce a Stream.
|
static void |
tagOpAsJavaPrimitive(com.ibm.streamsx.topology.builder.BOperatorInvocation op,
java.lang.String kind,
java.lang.String className)
Internal method.
|
public static <T> java.lang.Object createValue(T value, com.ibm.streams.operator.Type.MetaType metaType)
MetaType
.
Use of this is required to construct an SPL operator parameter value
whose SPL type is not implied from simple Java type. e.g.,
a String
value is interpreted as an SPL rstring
,
and Byte,Short,Integer,Long
are interpreted as SPL signed integers.
value
- the value to wrapmetaType
- the SPL meta typejava.lang.IllegalArgumentException
- if value is null or its class is
not appropriate for metaType
public static java.lang.Object createNullValue()
Use of this is required to construct an SPL operator parameter null value for an optional type.
public static <T> Supplier<T> createSubmissionParameter(Topology top, java.lang.String name, java.lang.Object paramValue, boolean withDefault)
Use of this is required to construct a submission parameter for
an SPL operator parameter whose SPL type requires the use of
createValue(Object, MetaType)
.
See Topology.createSubmissionParameter(String, Class)
for
general information about submission parameters.
top
- the topologyname
- the submission parameter nameparamValue
- a value from createValue()
withDefault
- true to create a submission parameter with
a default value, false to create one without a default value
When false, the paramValue's wrapped value's value in ignored.Supplier<T>
for the submission parameterjava.lang.IllegalArgumentException
- if paramValue
is not a
value from createValue()
.public static SPLStream invokeOperator(java.lang.String kind, SPLInput input, com.ibm.streams.operator.StreamSchema outputSchema, java.util.Map<java.lang.String,? extends java.lang.Object> params)
kind
- SPL kind of the operator to be invoked.input
- Stream that will be connected to the only input port of the
operatoroutputSchema
- SPL schema of the operator's only output port.params
- Parameters for the SPL operator, ignored if it is null.public static SPLStream invokeOperator(java.lang.String name, java.lang.String kind, SPLInput input, com.ibm.streams.operator.StreamSchema outputSchema, java.util.Map<java.lang.String,? extends java.lang.Object> params)
name
- Name for the operator invocation.kind
- SPL kind of the operator to be invoked.input
- Stream that will be connected to the only input port of the
operatoroutputSchema
- SPL schema of the operator's only output port.params
- Parameters for the SPL operator, ignored if it is null.public static java.util.List<SPLStream> invokeOperator(TopologyElement te, java.lang.String name, java.lang.String kind, java.util.List<? extends SPLInput> inputs, java.util.List<com.ibm.streams.operator.StreamSchema> outputSchemas, java.util.Map<java.lang.String,? extends java.lang.Object> params)
inputs
results in
a input port for the operator with the input port index
matching the position of the input in inputs
.
If inputs
is null
or empty then the operator will not
have any input ports.
outputSchemas
an output port
for the operator with the output port index
matching the position of the schema in outputSchemas
.
If outputSchemas
is null
or empty then the operator will not
have any output ports.te
- Reference to Topology the operator will be in.name
- Name for the operator invocation.kind
- SPL kind of the operator to be invoked.inputs
- Input streams to be connected to the operator. May be null
if no input streams are required.outputSchemas
- Schemas of the output streams. May be null
if no output streams are required.params
- Parameters for the SPL Java Primitive operator, ignored if null
.SPLStream
instances that represent the outputs of the operator.public static TSink invokeSink(java.lang.String kind, SPLInput input, java.util.Map<java.lang.String,? extends java.lang.Object> params)
kind
- SPL kind of the operator to be invoked.input
- Stream that will be connected to the only input port of the
operatorparams
- Parameters for the SPL operator, ignored if it is null.public static TSink invokeSink(java.lang.String name, java.lang.String kind, SPLInput input, java.util.Map<java.lang.String,? extends java.lang.Object> params)
name
- Name of the operatorkind
- SPL kind of the operator to be invoked.input
- Stream that will be connected to the only input port of the
operatorparams
- Parameters for the SPL operator, ignored if it is null.public static SPLStream invokeSource(TopologyElement te, java.lang.String kind, java.util.Map<java.lang.String,java.lang.Object> params, com.ibm.streams.operator.StreamSchema schema)
te
- Reference to Topology the operator will be in.kind
- SPL kind of the operator to be invoked.params
- Parameters for the SPL operator.schema
- Schema of the output port.public static void addToolkit(TopologyElement te, java.io.File toolkitRoot) throws java.io.IOException
te
- Element within the topology.toolkitRoot
- Root directory of the toolkit.java.io.IOException
- toolkitRoot
is not a valid path.public static void addToolkitDependency(TopologyElement te, java.lang.String name, java.lang.String version)
te
- Element within the topology.name
- Name of the toolkit.version
- Version dependency string.public static void tagOpAsJavaPrimitive(com.ibm.streamsx.topology.builder.BOperatorInvocation op, java.lang.String kind, java.lang.String className)
op
- the operator invocationkind
- SPL kind of the operator to be invoked.className
- the Java primitive operator's class name.