public long run ( String symbol , TimestampType time , long seq_number , String exchange , int bidPrice , int bidSize , int askPrice , int askSize ) throws VoltAbortException { // convert bid and ask 0 values to null Integer bidPriceSafe = askPrice > 0 ? askPrice : null ; Integer askPriceSafe = askPrice > 0 ? askPrice : null ; voltQueueSQL ( insertTick , symbol , time , seq_number , exchange , bidPriceSafe , bidSize , askPriceSafe , askSize ) ; voltQueueSQL ( upsertLastTick , symbol , time , seq_number , exchange , bidPrice , bidSize , askPrice , askSize ) ; // Queue best bid and ask selects voltQueueSQL ( selectMaxBid , symbol ) ; voltQueueSQL ( selectMinAsk , symbol ) ; // Execute queued statements VoltTable results0 [ ] = voltExecuteSQL ( ) ; // Read the best bid results VoltTable tb = results0 [ 2 ] ; tb . advanceRow ( ) ; String bex = tb . getString ( 0 ) ; long bid = tb . getLong ( 1 ) ; long bsize = tb . getLong ( 2 ) ; // Read the best ask results VoltTable ta = results0 [ 3 ] ; ta . advanceRow ( ) ; String aex = ta . getString ( 0 ) ; long ask = ta . getLong ( 1 ) ; long asize = ta . getLong ( 2 ) ; // check if the tick is part of the nbbo if ( bex . equals ( exchange ) || aex . equals ( exchange ) ) { // this new quote was the best bid or ask // insert a new NBBO record // use this quote's symbol, time and sequence number voltQueueSQL ( insertNBBO , symbol , time , seq_number , bid , bsize , bex , ask , asize , aex ) ; voltExecuteSQL ( true ) ; } return ClientResponse . SUCCESS ; }
main method the procedure starts here .