question

Upvotes
Accepted
48 8 18 20

dictionary load problem

Hello, everyone. Currently I encounter some question on using reuter dictionary. My sample code as follows:

thomsonreuters::ema::rdm::DataDictionary fid_dict_;
map<Int16, const emardm::DictionaryEntry*>   map_fid_dict_;

fid_dict_.loadFieldDictionary(dict_file.c_str());
fid_dict_.loadEnumTypeDictionary(enum_file.c_str());

const emaaccess::EmaVector<emardm::DictionaryEntry>& vec_entry = fid_dict_.getEntries();
for(unsigned i = 0; i < vec_entry.size(); i++)
{
    const emardm::DictionaryEntry* ptr = &(vec_entry[i]);
    map_fid_dict_[ vec_entry[i].getFid() ] = ptr;
    LOG_DEBUG("acronym:%s, ddeAcronym:%s, fid:%d, rippleToField:%d, fieldType:%d, length:%d, "
        "enumLength:%d, rwfType:%d, rwfLength:%d", 
        ptr->getAcronym().c_str(), ptr->getDDEAcronym().c_str(), ptr->getFid(),
        ptr->getRippleToField(), ptr->getFieldType(), ptr->getLength(),
        ptr->getRwfType(), ptr->getRwfLength());
}

The sample code load field dictionary and enum type dictionary from RDMFieldDictionary and enumtype.def which are shipped with EMA SDK. But when using LOG_DEBUG print certain field value, it seems the RwfType and RwfLength is unitialized at this moment, for example I got following output for BIDSIZE field:

Debug: acronym:BIDSIZE, ddeAcronym:BID SIZE, fid:30, rippleToField:0, fieldType:1, length:15, enumLength:8, rwfType:7, rwfLength:30603272

But later when I use map_fid_dict to fetching DictonaryEntry info for adding data into FieldList, I print the entry for BIDSIZE again like this:

Debug: BIDSIZE with type:1, fid:30, rwfType:8, length:7

The latter is right according to RDMFieldDictionary file. But why the previous printed rwf type & length is incorrect at that moment? My code has no further modification to map_fid_dict after load dictionary file. Many thanks.


elektronrefinitiv-realtimeelektron-sdkema-apirrtelektron-message-apielektron-data-dictionary
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
78.8k 250 52 74

@wangfugen

The number of format characters and variables mismatch.

There are nine format characters in the format string but there are only eight values.

  1. ptr->getAcronym().c_str() => acronym:%s
  2. ptr->getDDEAcronym().c_str() => ddeAcronym:%s
  3. ptr->getFid() => fid:%d
  4. ptr->getRippleToField() => rippleToField:%d
  5. ptr->getFieldType() => fieldType:%d
  6. ptr->getLength() => length:%d
  7. => enumLength:%d
  8. ptr->getRwfType() => rwfType:%d
  9. ptr->getRwfLength() => rwfLength:%d

You need to add ptr->getEnumLength().

printf("acronym:%s, ddeAcronym:%s, fid:%d, rippleToField:%d, fieldType:%d, length:%d, "
                "enumLength:%d, rwfType:%d, rwfLength:%d\n",
                ptr->getAcronym().c_str(), ptr->getDDEAcronym().c_str(), ptr->getFid(),
                ptr->getRippleToField(), ptr->getFieldType(), ptr->getLength(),
                ptr->getEnumLength(),
                ptr->getRwfType(), ptr->getRwfLength());

The output is:

acronym:PROD_PERM, ddeAcronym:PERMISSION, fid:1, rippleToField:0, fieldType:1, length:5, enumLength:0, rwfType:4, rwfLength:2
acronym:RDNDISPLAY, ddeAcronym:DISPLAYTEMPLATE, fid:2, rippleToField:0, fieldType:1, length:3, enumLength:0, rwfType:4, rwfLength:1
acronym:DSPLY_NAME, ddeAcronym:DISPLAY NAME, fid:3, rippleToField:0, fieldType:5, length:16, enumLength:0, rwfType:19, rwfLength:16
acronym:RDN_EXCHID, ddeAcronym:IDN EXCHANGE ID, fid:4, rippleToField:0, fieldType:6, length:3, enumLength:3, rwfType:14, rwfLength:1
acronym:TIMACT, ddeAcronym:TIME OF UPDATE, fid:5, rippleToField:0, fieldType:7, length:5, enumLength:0, rwfType:10, rwfLength:5
acronym:TRDPRC_1, ddeAcronym:LAST, fid:6, rippleToField:7, fieldType:4, length:17, enumLength:0, rwfType:8, rwfLength:7
acronym:TRDPRC_2, ddeAcronym:LAST 1, fid:7, rippleToField:8, fieldType:4, length:17, enumLength:0, rwfType:8, rwfLength:7
acronym:TRDPRC_3, ddeAcronym:LAST 2, fid:8, rippleToField:9, fieldType:4, length:17, enumLength:0, rwfType:8, rwfLength:7
acronym:TRDPRC_4, ddeAcronym:LAST 3, fid:9, rippleToField:10, fieldType:4, length:17, enumLength:0, rwfType:8, rwfLength:7
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
7.6k 15 6 9

@wangfugen

I did a quick test your codes to print the dict. I just changed LOG_DEBUG to use normal cout and use static_cast when display integer value and then get a correct output according to the dic I load.

cout << "acronym:" << ptr->getAcronym().c_str() <<"\tddeAcronym:" << ptr->getDDEAcronym().c_str() << "\tfid:" << static_cast<int>(ptr->getFid()) << "\trippleToField:" << (int)ptr->getRippleToField() << "\tfieldType:" << static_cast<int>(ptr->getFieldType()) << "\tlength:" << static_cast<int>(ptr->getLength()) << "\tenumLength:" << static_cast<int>(ptr->getEnumLength()) << "\trwfType:" << static_cast<int>(ptr->getRwfType()) << "\trwfLength:" << static_cast<int>(ptr->getRwfLength()) << "\n";

Below is dictionary and sample output from the codes.

! Previous latest bid prices the first being most recent. ! ASK        "ASK"                   25  ASK_1       PRICE              17  REAL64           7 ! ! Latest Ask Price (price offering to sell) ! ASK_1      "ASK 1"                 26  ASK_2       PRICE              17  REAL64           7 ASK_2      "ASK 2"                 27  ASK_3       PRICE              17  REAL64           7 ! ! Previous latest ask prices the first being most recent. ! NEWS       "NEWS"                  28  NULL        ALPHANUMERIC        4  RMTES_STRING     4 ! ! News retrieval page code. ! NEWS_TIME  "NEWS TIME"             29  NULL        TIME                5  TIME             5 ! ! Time of generation of news item whose page code is given by NEWS. ! BIDSIZE    "BID SIZE"              30  NULL        INTEGER            15  REAL64           7 ! ! The number of shares, lots, or contracts willing to buy at the Bid price ! ASKSIZE    "ASK SIZE"              31  NULL        INTEGER            15  REAL64           7 ! ! The number of shares, lots, or contracts willing to sell at the Ask price ! ACVOL_1    "VOL ACCUMULATED"       32  NULL        INTEGER            15  REAL64           7 ! ! Accumulated number of shares, lots or contracts traded according to the market  ! convention ! EARNINGS   "EARNINGS"              34  NULL        PRICE              17  REAL64           7 ! ! Latest reported earnings per share. ! YIELD      "YIELD"                 35  NULL        PRICE              17  REAL64           7
acronym:ASK    ddeAcronym:ASK    fid:25    rippleToField:26    fieldType:4    length:17    enumLength:0    rwfType:8    rwfLength:7 acronym:ASK_1    ddeAcronym:ASK 1    fid:26    rippleToField:27    fieldType:4    length:17    enumLength:0    rwfType:8    rwfLength:7 acronym:ASK_2    ddeAcronym:ASK 2    fid:27    rippleToField:6130    fieldType:4    length:17    enumLength:0    rwfType:8    rwfLength:7 acronym:NEWS    ddeAcronym:NEWS    fid:28    rippleToField:0    fieldType:5    length:4    enumLength:0    rwfType:19    rwfLength:4 acronym:NEWS_TIME    ddeAcronym:NEWS TIME    fid:29    rippleToField:0    fieldType:7    length:5    enumLength:0    rwfType:10    rwfLength:5 acronym:BIDSIZE    ddeAcronym:BID SIZE    fid:30    rippleToField:0    fieldType:1    length:15    enumLength:0    rwfType:8    rwfLength:7 acronym:ASKSIZE    ddeAcronym:ASK SIZE    fid:31    rippleToField:0    fieldType:1    length:15    enumLength:0    rwfType:8    rwfLength:7 acronym:ACVOL_1    ddeAcronym:VOL ACCUMULATED    fid:32    rippleToField:0    fieldType:1    length:15    enumLength:0    rwfType:8    rwfLength:7 acronym:EARNINGS    ddeAcronym:EARNINGS    fid:34    rippleToField:0    fieldType:4    length:17    enumLength:0    rwfType:8    rwfLength:7 acronym:YIELD    ddeAcronym:YIELD    fid:35    rippleToField:0    fieldType:4    length:17    enumLength:0    rwfType:8    rwfLength:7
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
48 8 18 20

@jirapongse.phuriphanvichai @moragodkrit.chumsri_1 Thank you all. As jirapongse.phuriphanvichai replied, it's a problem of printf formatting. Sorry for my carelessness, and thanks you two again.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.