Average Trade Price with Timer

Use a timer to send a new row to an output window every five seconds.

The example creates a schema named TradesSchema and an input window named TradeWindow. The File CSV Input adapter is attached to the window.

The example creates a Flex stream named FlexTimer that places a data retention policy of 10 rows on TradeWindow. The ON clause tells the project server to apply the computation vvalue ++ to the trade price every 5 seconds. This expression increments the current value of the local variable vvalue.

CREATE FLEX FlexTimer IN TradeWindow 
	KEEP 10 ROWS 
	OUT OUTPUT WINDOW SimpleOutput 
		SCHEMA ( a integer, b string)
  		PRIMARY KEY ( a)BEGIN
	declare 
	   integer vvalue := 0;
	END;    ON TradeWindow    {    }    ;
    every 5 seconds {
    	vvalue ++;
    	output [a=vvalue; b='msg1';|];
    	};END;