question

Upvotes
Accepted
5 0 0 1

encode Vector in FieldList

Hi all,

From the RFA_DevelopersGuide:

FieldList is a non-uniform container of field identifier-value paired entries known as a fieldEntry. A Field
Identifier, also known as a fieldId (or FID), is a signed value refering to a specific name and information
type defined by an external field dictionary, such as the RDMFieldDictionary. Values in a FieldList can be
a primitive or container type.

that means a FieldList can have a FieldEntry which encodes a container type : Vector, Map, FieldList.
FieldEntry(FieldId, ContainerType)

However, the RDMFieldDictionary supports only

- ALPHANUMERIC
- ENUMERATED
- BINARY
- DATE
- TIME_SECONDS
- TIME
- PRICE
- INTEGER

I didn't manage to find out an example from RFA_Example.


Do you know how to encode a container type like Vector in FieldList ?

rfarfa-api#technologyc++rdmcontainer
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.

1 Answer

Upvotes
Accepted
56k 145 45 65

@iamtho

Thanks for reaching out to us.

Yes, you are correct. A field entry can contain a container, such as Vector.

A vector in a field entry is typically used in the yield curve domain with the following fields.

CASH_RATES "CASH RATES"         30141  NULL        NONE                0  VECTOR           0
FUTR_PRCS  "FUTURE PRICES"      30151  NULL        NONE                0  VECTOR           0
SWAP_RATES "SWAP RATES"         30161  NULL        NONE                0  VECTOR           0

The code to encode a vector in a field entry looks like this:

    field.clear();
    field.setFieldID(30141);
    Vector vector;
    encodeTestVector(&vector);
    field.setData(static_cast<const Data&>(vector));
    fieldListWIt.bind(field);


void Encoder::encodeTestFieldList(FieldList* pFieldList)
{
    assert(pFieldList);
    FieldListWriteIterator fieldListWIt;
    DataBuffer dataBuffer;
    pFieldList->clear();    
    fieldListWIt.start(*pFieldList);
    FieldEntry field;


    Real32 real32;
    real32.setMagnitudeType(ExponentNeg2);
    real32.setValue(_trdPrice++);


    field.setFieldID(6);//TRDPRC_1
    dataBuffer.setReal32(real32);
    field.setData(dataBuffer);
    fieldListWIt.bind(field);


    fieldListWIt.complete();
}
void Encoder::encodeTestVector(Vector* pVector) 
{
    assert(pVector);
    VectorWriteIterator vectorWIt;
    
    vectorWIt.start(*pVector);
    FieldList fieldList;
    encodeTestFieldList(&fieldList);


    VectorEntry vEntry;
    
    vEntry.setPosition(0);
    vEntry.setAction(VectorEntry::Set);    
    vEntry.setData(static_cast<const Data&>(fieldList));
    vectorWIt.bind(vEntry);


    vEntry.clear();
    vEntry.setPosition(1);
    vEntry.setAction(VectorEntry::Set);
    vEntry.setData(static_cast<const Data&>(fieldList));
    vectorWIt.bind(vEntry);
    vectorWIt.complete();
}

The consumer will get the following data.

<updateMsg domainType="RSSL_DMT_MARKET_PRICE" streamId="4" containerType="RSSL_DT_FIELD_LIST" flags="0x0" updateType="0 (RDM_UPD_EVENT_TYPE_UNSPECIFIED)" dataSize="58">
    <dataBody>
        <fieldList flags="0x8 (RSSL_FLF_HAS_STANDARD_DATA)">
            <fieldEntry fieldId="2" data="64"/>
            <fieldEntry fieldId="6" data="0C00 88"/>
            <fieldEntry fieldId="258" data="5445 5354 2053 7472 696E 67"/>
            <fieldEntry fieldId="30141" data="0004 0002 0200 0908 0001 0006 030C 0089 0201 0908 0001 0006 030C 0089"/>
        </fieldList>
    </dataBody>
</updateMsg>


<!-- End Message (Channel IPC descriptor = 560) -->
UpdateMsg
    streamId="5"
    domain="MarketPrice Domain"
    updateTypeNum="0"
    name=".CSI931818CNY04"
    serviceId="1"
    serviceName="DIRECT_FEED"
    Payload dataType="FieldList"
        FieldList
            FieldEntry fid="2" name="RDNDISPLAY" dataType="UInt" value="100"
            FieldEntry fid="6" name="TRDPRC_1" dataType="Real" value="1.36"
            FieldEntry fid="258" name="SEG_TEXT" dataType="Rmtes" value="TEST String"
            FieldEntry fid="30141" name="CASH_RATES" dataType="Vector"
                Vector sortable="false"
                    VectorEntry action="Set index="0" dataType="FieldList"
                        FieldList
                            FieldEntry fid="6" name="TRDPRC_1" dataType="Real" value="1.37"
                        FieldListEnd
                    VectorEntryEnd
                    VectorEntry action="Set index="1" dataType="FieldList"
                        FieldList
                            FieldEntry fid="6" name="TRDPRC_1" dataType="Real" value="1.37"
                        FieldListEnd
                    VectorEntryEnd
                VectorEnd
            FieldEntryEnd
        FieldListEnd


    PayloadEnd
UpdateMsgEnd
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.

Hi Jirapongse,

Thanks for your help!

That works like a charm!