Loading the RAPStore from the RAPCache

If the data in the RAPStore becomes stale due to the loss of the primary Event Stream Processor instance, use a manual procedure to load the RAPStore from data in the RAPCache.

  1. Determine the maximum key value currently in the RAPStore.
    The maximum key value is determined by date and time. Each market data message is stored in its corresponding database table with a date and timestamp value. Corresponding values for these key fields are the current date and maximum timestamp value less 10 minutes. Since the messages may arrive out of order, Sybase recommends that you allow a grace period of at least 10 minutes.
  2. Create a view in the current RAPCache to select from the corresponding Adaptive Server Enterprise table where key values are greater than the key values from RAPStore.
    For example, if you are transferring the STOCK_QUOTE table, you can create a view called STOCK_QUOTE_XFER using:
    create view RAP_USER.STOCK_QUOTE_XFER ( INSTRUMENT_ID, QUOTE_DATE, QUOTE_SEQ_NBR, TRADING_SYMBOL, QUOTE_TIME, ASK_PRICE, ASK_SIZE, BID_PRICE, BID_SIZE ) as select from STOCK_QUOTE where QUOTE_TIME > 'datetime key value from previous step'
  3. Bulk-copy the table out to a file from the view in current RAPCache using the Adaptive Server bcp utility.
    Use these flags: -c -t , -r \\n:
    • -c flag - tells bcp to output character data instead of binary data.

    • -t , flag - tells bcp to use the comma as a field terminator.

    • -r \\n flag - tells bcp to use a newline as a row terminator.

    Here is the bcp command, using the example view STOCK_QUOTE_XFER:
    bcp RAP_USER.STOCK_QUOTE_XFER out
    stock_quote_xfer.csv -c -t , -r \\n
    -URAP_USER -Prap_user
    -S<RAPCache Database Server Name>
  4. Transfer the bulk copy files from the Adaptive Server Enterprise server to the Sybase IQ server that is hosting the RAPStore database.
  5. Load the data into the RAPStore on the Sybase IQ server using dbisql to submit a LOAD TABLE command. The IGNORE CONSTRAINT UNIQUE 0 option allows IQ to throw away any duplicate key values without terminating the load operation.
    Continuing the example from above, the LOAD TABLE command looks similar to:
    load table RAP_USER.STOCK_QUOTE
    (
    INSTRUMENT_ID    null (blanks,'NULL') ,
    QUOTE_DATE    null (blanks,'NULL') ,
    QUOTE_SEQ_NBR    null (blanks,'NULL') ,
    TRADING_SYMBOL null (blanks,'NULL') ,
    QUOTE_TIME    null (blanks,'NULL') ,
    ASK_PRICE    null (blanks,'NULL') ,
    ASK_SIZE    null (blanks,'NULL') ,
    BID_PRICE    null (blanks,'NULL') ,
    BID_SIZE  '\x0a'
    )
    from '<path>/stock_quote_xfer.csv'
    quotes off
    escapes off
    preview on
    ignore constraint unique 0
    ;
    commit
    ;