View annotation
The SPL annotation @view specifies that a view is to be created when the streams processing application is run.
>>-@view--(--name--="--view-name--"-----------------------------> >--,--port--="--output-port--"----------------------------------> >--,--sampleSize--="--sample-size--"----------------------------> >--,--+-bufferSize--="--buffer-size--"-+------------------------> '-bufferTime--="--buffer-time--"-' >--+--------------------------------------+---------------------> '-description--="--view-description--"-' >--+--------------------------------------+---------------------> '-,--attributes--=[--attribute-list--]-' >--+----------------------------------------------------------------------------------+--> '-,--filter--={--attr--="--attribute-name--", -regEx--="--regular-expression--"--}-' >--+-------------------------------------------+--)------------>< '-,--activateOption--="--+-firstAccess-+--"-' '-automatic---'
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.
- attr
- Specifies an attribute name to use for filtering the sampled tuples. The type of the parameter is rstring.
- regEx
- Specifies a regular expression to use for filtering the sampled tuples. The type of the parameter is rstring.
- activateOption
Specifies when the view starts buffering data. If you do not specifty activateOption, data starts being buffered on first access.
- firstAccess
- Starts buffering data when the view is first used.
- automatic
- Starts buffering data when you submit the job for the streams processing application.
Examples
- Example 1: Creating a view for use in Microsoft Excel 2010, 2013, or 2016
IBM® Streams can display streaming data in Microsoft Excel 2010, 2013, or 2016 if you install the IBM Streams for Microsoft Excel add-in that is available. To make streaming data available for display in Excel, you must first define a view in your SPL application. The following @view annotation creates a view called analyticsview, with a sample size of five tuples per second and a buffer size of 10 tuples. The output port is Analytics:
@view(name = "analyticsview", port = Analytics, sampleSize = 5, bufferSize = 10)
- Example 2: 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:
@view(name = "ViewWithRegEx", port = MyOutputPort, sampleSize = 1000, bufferSize = 8000, description = "Stream containing trade quotes", filter ={attr = ticker, regEx = "IBM|GOOG"}, activateOption = firstAccess)
