bool test_bars_fmt2()

in src/dxapi-tests.cpp [345:434]


bool test_bars_fmt2(TickDb &db) {
    const char *messageNames[] = { "Unknown", "deltix.qsrv.hf.pub.BarMessage" };
    static const uintptr_t preloadSize = 200000000;

    auto stream = db.getStream("bars1min");

    SelectionOptions opt;
    /*vector<string> types;
    vector<InstrumentIdentity> symbols;*/

    unique_ptr<TickCursor> pCursor(stream->select(TIMESTAMP_NULL, opt, NULL, NULL));
    TickCursor &cursor = *pCursor;

    Bar msg;

    for (intptr_t i = 0; i < COUNTOF(messageNames); ++i)
        cursor.registerMessageType((unsigned)i, messageNames[i]);

#ifdef PRELOAD
    preload(cursor, preloadSize, 0x400);
#endif

    START_TEST(bars1min);
    DataReader &reader = cursor.getReader();

    static volatile double y = 0.0; // these vars are for fighting compiler optimizations
    double x = 0;

    msg.volume = 0.0;
    msg.cursor = &cursor;
    while (cursor.next(&msg) && nMessagesRead < 5000000) {
        switch (msg.typeIdLocal) {
        case MY_BAR_ID:
            //msg.originalTimestamp = cursor.getInt64();
            //msg.currencyCode = cursor.getInt16();
            //msg.sequenceNumber = cursor.getInt64();

            //msg.hasExchangeCode = 
            //cursor.getAlphanumeric(msg.exchangeCode, 10);

            /*
            msg.hasClose =
                cursor.getDecimal(msg.close);
            msg.hasOpen =
                cursor.getDecimal(msg.open);
            msg.hasHigh =
                cursor.getDecimal(msg.high);
            msg.hasLow =
                cursor.getDecimal(msg.low);
            msg.hasVolume =
                cursor.getDecimal(msg.volume);
                */

            msg.hasClose =
                reader.readDecimal(msg.close);
            msg.hasOpen =
                reader.readDecimal(msg.open);
            msg.hasHigh =
                reader.readDecimal(msg.high);
            //msg.low = 0;
            msg.hasLow = reader.readDecimal(msg.low);
            msg.hasVolume = reader.readDecimal(msg.volume);

            //msg.hasVolume = reader->getDecimal(msg.volume);

            msg.open += msg.close;
            msg.high += msg.close;
            msg.low += msg.close;

            x += msg.open; // This is to prevent some extreme compiler optimizations
            // Print contents
            //puts(msg.toString().c_str());
            break;
        default:
            printf("Unknown message. id: %d -> localId: %d", (int)msg.typeId, (int)msg.typeIdLocal);
            puts(msg.MarketMessage::toString().c_str());
        }
        ++nMessagesRead;

        //if (9210617 == nMessagesRead) {
        //    nMessagesRead &= 0xFFFFFFFFF;
        //}
        //if (nMessagesRead > 9210591 /*&& nMessagesRead % 32 == 0*/)
            //printf("%llu ", (long long unsigned)nMessagesRead);
    }

    END_READING(bars1min);
    y = x;
    return true;
}