View annotation
The SPL annotation @view
specifies that a view is to be created when the
streams application is run.
The @view
annotation can be applied to primitive and composite operators and
must appear in the set of annotations immediately preceding an operator invocation. The
@view
annotation can be applied to an operator that is also part of a parallel
region through the @parallel
annotation. The @view
annotation
cannot be applied to import operators.
Required elements
- name
- Specifies the name of the view. The view name must be unique within the composite, which means
they are unique within a job. The type of the parameter is
rstring
. - port
- Specifies the output port on which the view is to be created. Must specify a valid output port or a valid output port alias.
- sampleSize
- Specifies the number of tuples to sample per second. The value you specify must be greater than
zero. The type of the parameter is
int32
. - bufferSize
- Specifies the buffer size to use measured in tuples. The value you specify must be greater than
the value specified for the sampleSize element. You cannot specify this element
if bufferTime is also specified. The type of the parameter is
int32
. - bufferTime
- Specifies the buffer size to use measured in seconds. The value you specify must be greater than
zero. You cannot specify this element if bufferSize is also specified. The type
of the parameter is
float64
.
Optional elements
- description
- Describes the view. The type of the parameter is
rstring
. - attributes
-
Specifies a list of the tuple attributes to include in the view. If attributes not specified, the view includes all attributes. Must contain a list of the valid attributes for the output port specified by the port element.
If you wish to view the attributes of a nested tuple, you must explicitly specify the nested (leaf) attributes in the attributes list. For example, given the following types:
If you wish to view the attributes of nested tuple inner, you must specify:type static InnerType=rstring s1, int32 i1; static OuterType = InnerType inner, rstring s2;
[inner.s1, inner.i1]
- filter
-
Filters the sampled tuples and returns only those tuples that match the conditions you specify. If you do not specify filter, the view includes all tuples that are sampled.
- activateOption
-
Specifies when the view starts buffering data. If you do not specifty activateOption, data starts being buffered on first access.
Examples
- Example 1: Creating a view using a filter
-
The following
@view
annotation creates a view called ViewWithRegEx, using a filter to find tuples where the ticker matches the values IBM or GOOG: