bool test_bars_fmt1()

in src/dxapi-tests.cpp [221:283]


bool test_bars_fmt1(TickDb& db) {
    const char *messageNames[] = { "Unknown", "deltix.qsrv.hf.pub.BarMessage" };
    static const uintptr_t preloadSize = 300000000;
    auto stream = db.getStream("test");

    SelectionOptions opt;
    /*vector<string> types;
    vector<InstrumentIdentity> symbols;*/
    //opt.setTypeTransmission(DxApi::DEFINITION);
    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

    DataReader &reader = cursor.getReader();
    START_TEST(test bars);
    msg.cursor = &cursor;
    while (cursor.next(&msg) && nMessagesRead < 5000000) {

        switch (msg.typeIdLocal) {
        case MY_BAR_ID:
            msg.hasCurrencyCode = INT16_NULL != (msg.currencyCode = reader.readInt16());

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

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

            // 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;
    }

    //uint64_t end = time_ns();
    //printf("Bytes received: %llu\n", (long long unsigned)cursor.getNumBytesReceived());
    //printf("Bytes read: %llu, avg msg size: %.1lf bytes\n", (long long unsigned)cursor.getNumBytesRead(), (double)cursor.getNumBytesRead() / nMessagesRead);
    //printf("Decoding speed: %.1lf bytes/s\n", (double)cursor.getNumBytesRead() / timetodouble(end - start));

    END_READING(test bars);
    return true;
}