Developers: Defining Dequeue Predicates

Home
Documentation
Library
Sample Code and Applications
FAQs
Articles
Community
Training
Download Center
Contact DevZone

Printer Friendly

Library Articles

Defining Dequeue Predicates

Authors: Richard Tibbetts, Dr. John Lifter
StreamBase Systems

Date: 01-September-2007

Introduction


You may want to restrict the tuples that can be dequeued from an output stream.  In earlier releases of StreamBase, you could limit the tuples available to a dequeuer application by using a filter specification when subscribing to an output stream.  Introduced in StreamBase 5.0 is the ability to define a dequeue predicate on the output stream itself.  With this approach, only those tuples satisfying the dequeue predicate are available to clients that subscribe to the stream.  If dequeuer applications are only interested in this restricted set of tuples, there is no additional requirement to use the filter subscribe approach.

Dequeue Predicates in an EventFlow Application


The output stream's StreamBase Properties view includes a new tab — Advanced. On this tab, you enter an expression into the Dequeue predicate expression: text box. Only tuples for which the expression evaluates to true will be emitted by this output stream.  For example, to select only those tuples with a value in the price field that is greater than 100, make the following entry within the Advanced tab.

Dequeue Predicates in a StreamSQL Application


In a StreamSQL application, an additional clause in the CREATE OUTPUT STREAM statement is used to define a dequeue predicate.  A predicate may be added to all syntax variations of this statement. For example:

  CREATE OUTPUT STREAM Out1 WITH OUTPUT PREDICATE predicate_expression;

  CREATE OUTPUT STREAM Out2 WITH OUTPUT PREDICATE predicate_expression AS
    StreamSQL_statement;

  CREATE OUTPUT STREAM Out3 (tuple_schema)
    WITH OUTPUT PREDICATE predicate_expresion;

  StreamSQL_statement =>
    CREATE OUTPUT STREAM Out4 WITH OUTPUT PREDICATE predicate_expression;