Striim 3.9.4 / 3.9.5 documentation

CREATE STREAM

CREATE STREAM <name> OF <type name> 
[ PARTITION BY <field name>, ... ]
[ PERSIST USING <property set> ]
[ GRACE PERIOD <integer> { SECOND | MINUTE | HOUR | DAY } ON <field name> ];

Creates a stream using a previously defined type.

Note

A stream and its type may also be created as part of a CREATE CQ declaration. See Parsing the data field of WAEvent for an example.

For example, PosApp defines the MerchantTxRate type and creates a stream based on that type:

CREATE TYPE MerchantTxRate(
  merchantId String KEY,
  zip String,
  startTime DateTime,
  count integer,
  totalAmount double,
  hourlyAve integer,
  upperLimit double,
  lowerLimit double,
  category String,
  status String
);
CREATE STREAM MerchantTxRateOnlyStream OF MerchantTxRate PARTITION BY merchantId;

PARTITION BYfield_name controls how events are distributed across multiple servers in a Striim cluster . See Adapting TQL applications for multi-server deployment for more information.

GRACE PERIOD should be used when data may be received out of order. For example, if you were collecting log data from servers all over the world, network latency might result in events with a logTime value of 1427890320 arriving from a nearby server before events with a timestamp of 1427890319 (one second earlier) from a server on another continent. If you knew that the maximum latency was two seconds, you could use the clause GRACE PERIOD 2 SECOND ON logTime to ensure that all events are processed in order. The events of the stream would then be buffered for two seconds, continuously sorted based on the logTime value, and passed to the next component in the application. If the time interval is too short, any out-of-order events received too late to be sorted in the correct order are discarded. Without the GRACE PERIOD option, out-of-order events are processed as they arrive, which may result in incorrect calculations.

For example, this sample sorter for out of order events is paired with a stream created with a 2 second grace period on the log time:

CREATE SORTER MySorter OVER
Stream1 ON logTime OUTPUT TO Stream1Sorted,
Stream2 ON logTime OUTPUT TO Stream2Sorted
WITHIN 2 second
OUTPUT ERRORS TO fooErrorStream;
 
CREATE STREAM EventStream1 OF EventType1 GRACE PERIOD 2 SECOND ON logTime;