public long run(int agent_id, String phone_no, long call_id, TimestampType start_ts) {
        voltQueueSQL(findOpenCall, EXPECT_ZERO_OR_ONE_ROW, call_id, agent_id, phone_no);
        voltQueueSQL(findCompletedCall, EXPECT_ZERO_OR_ONE_ROW, call_id, agent_id, phone_no);
        VoltTable[] results = voltExecuteSQL();

        boolean completedCall = results[1].getRowCount() > 0;
        if (completedCall) {
            return -1;
        }

        VoltTable openRowTable = results[0];
        if (openRowTable.getRowCount() > 0) {
            VoltTableRow existingCall = openRowTable.fetchRow(0);

            // check if this is the second begin we've seen for this open call
            existingCall.getTimestampAsTimestamp("start_ts");
            if (existingCall.wasNull() == false) {
                return -1;
            }

            // check if this completes the call
            TimestampType end_ts = existingCall.getTimestampAsTimestamp("end_ts");
            if (existingCall.wasNull() == false) {

                int durationms = (int) ((end_ts.getTime() - start_ts.getTime()) / 1000);

                // update per-day running stddev calculation
                computeRunningStdDev(agent_id, end_ts, durationms);

                // completes the call
                voltQueueSQL(deleteOpenCall, EXPECT_SCALAR_MATCH(1),
                        call_id, agent_id, phone_no);
                voltQueueSQL(insertCompletedCall, EXPECT_SCALAR_MATCH(1),
                        call_id, agent_id, phone_no, start_ts, end_ts, durationms);

                voltExecuteSQL(true);
                return 0;
            }
        }

        voltQueueSQL(upsertOpenCall, EXPECT_SCALAR_MATCH(1), call_id, agent_id, phone_no, start_ts);
        voltExecuteSQL(true);
        return 0;
    }
public long run ( int agent_id , String phone_no , long call_id , TimestampType start_ts ) { voltQueueSQL ( findOpenCall , EXPECT_ZERO_OR_ONE_ROW , call_id , agent_id , phone_no ) ; voltQueueSQL ( findCompletedCall , EXPECT_ZERO_OR_ONE_ROW , call_id , agent_id , phone_no ) ; VoltTable [ ] results = voltExecuteSQL ( ) ; boolean completedCall = results [ 1 ] . getRowCount ( ) > 0 ; if ( completedCall ) { return - 1 ; } VoltTable openRowTable = results [ 0 ] ; if ( openRowTable . getRowCount ( ) > 0 ) { VoltTableRow existingCall = openRowTable . fetchRow ( 0 ) ; existingCall . getTimestampAsTimestamp ( "start_ts" ) ; if ( existingCall . wasNull ( ) == false ) { return - 1 ; } TimestampType end_ts = existingCall . getTimestampAsTimestamp ( "end_ts" ) ; if ( existingCall . wasNull ( ) == false ) { int durationms = ( int ) ( ( end_ts . getTime ( ) - start_ts . getTime ( ) ) / 1000 ) ; computeRunningStdDev ( agent_id , end_ts , durationms ) ; voltQueueSQL ( deleteOpenCall , EXPECT_SCALAR_MATCH ( 1 ) , call_id , agent_id , phone_no ) ; voltQueueSQL ( insertCompletedCall , EXPECT_SCALAR_MATCH ( 1 ) , call_id , agent_id , phone_no , start_ts , end_ts , durationms ) ; voltExecuteSQL ( true ) ; return 0 ; } } voltQueueSQL ( upsertOpenCall , EXPECT_SCALAR_MATCH ( 1 ) , call_id , agent_id , phone_no , start_ts ) ; voltExecuteSQL ( true ) ; return 0 ; }
Procedure main logic.

@param uuid Column value for tuple insertion and partitioning key for this procedure.
@param val Column value for tuple insertion.
@param update_ts Column value for tuple insertion.
@param newestToDiscard Try to remove any tuples as old or older than this value.
@param targetMaxRowsToDelete The upper limit on the number of rows to delete per transaction.
@return The number of deleted rows.
@throws VoltAbortException on bad input.