SPLASH with getOpcode

Use a Flex stream to capture items when they are deleted or expire.

The example creates a schema named TradeSchema, then another schema named DeleteOrExpireSchema, which inherits the structure of TradeSchema. The example creates an input window named TradeWindow, to which the File CSV Input adapter is attached.

The example then creates a Flex stream named TrackOldTrades that outputs data from TradeWindow to OldTradeEvents.

CREATE FLEX TrackOldTrades 
	IN TradeWindow 
	OUT OUTPUT WINDOW OldTradeEvents 
	  SCHEMA DeleteOrExpireSchema 
	    Primary Key (DeleteOrExpireTime, Ts)
BEGIN
	declare
		integer oc;
	end;

The getOpcode function determines the operation that is performed on the window. The switch statement only processes deletes.

 ON TradeWindow
    {
    	oc := getOpcode(TradeWindow);
  	
		switch (oc){

			case delete: 
				output [DeleteOrExpireTime = now();| 
				    Ts= TradeWindow.Ts; Symbol=TradeWindow.Symbol ; 
				    Price = TradeWindow.Price; Volume = TradeWindow.Volume; ];
				break;
			Default:
				break;		
		}
    }
    ;
END
;