An addendum:
The workaround perhaps is not so useful - it seems that the __isset
field is set for each list member, but not for
the list itself.  So when the object is serialized, it is serialized
without the list



Slightly modified thrift file
struct lstMember {
  1: optional i16                data1,
}
struct someStruct {
  1: optional list<lstMember>   item  = [{'data1':1},{'data1':2}]
}

with the main app looking like this:
#include <iostream>
#include <protocol/TDebugProtocol.h>
#include "t1_types.h"

using namespace ::apache::thrift;
using namespace ::apache::thrift::protocol;
using namespace ::apache::thrift::transport;
using namespace std;

int main()
{
  someStruct dummy;
  cout << "Dump:" << ThriftDebugString(dummy) << endl;
  cout << "Size:" <<dummy.item.size() << endl;
}



The output indicates that the serialization is broken
as no elements are printed, yet the container size is 2
   Dump:someStruct {
   }
   Size:2


That said, if the int element is optional but the list is required is
does seem to work


On Sun, Feb 27, 2011 at 1:38 PM, Nevo Hed <[email protected]> wrote:
>
> Hi All
>
> I ran into a case where thrift generated code that would not compile
>
> For the following data definition:
> struct lstMember {
>   1: required i16                data1,
> }
> struct someStruct {
>   1: required list<lstMember>   lst = [{'data1':1}]
> }
>
> With the following generation
> thrift -r -o generated --gen "cpp:pure_enums" t1.thrift
>
> I get the following compilation errors:
> g++  -MD -I/usr/local/include/thrift -Igenerated/gen-cpp -c 
> generated/gen-cpp/t1_types.cpp
> generated/gen-cpp/t1_types.h: In constructor ‘someStruct::someStruct()’:
> generated/gen-cpp/t1_types.h:59: error: ‘class lstMember’ has no member named 
> ‘__isset’
>
>
> Observation:
> The generated struct seems to have no 'isset' (internal) for required members 
> (totally expected)
> yet the generated constructor attempts to set the isset (internal) member
>
> Workaround:
> If its not critical, make the data members 'optional' to force generation of 
> the isset members
>
> Questions:
>
> Anything wrong in my thrift file?
> Should this email e considered a bug report or do I need to enter something 
> in JIRA?
>
> Possibly related
> https://issues.apache.org/jira/browse/THRIFT-72
> https://issues.apache.org/jira/browse/THRIFT-627
>
> Thanks
>   -Nevo
>



--
Nevo Hed

[email protected]
617-302-6175

Reply via email to