1、required字段没有__isset属性, 而默认的(就是既没有required,也没有optional)和optional的属性有该方法。
2、创建对象的时候,optional和默认的__isset属性为false,同样不设置该属性,而在经过thrift rpc传输之后,server端的默认的__isset属性为true。
3、有默认值的属性,不赋值的话,其值就是thrift中的默认值。
4、optional的如果没有设置__isset为true,则经过rpc传输(或者说是经过序列化再反序列化)之后,其值会丢失。
struct Student{
1: required i32 sno,
2: optional string name,
3: i64 age,
}
service Serv{
void put(1: Student s),
}
一、
typedef struct _Student__isset {
_Student__isset() : name(false), age(false) {
}
bool name :1;
bool age :1;
} _Student__isset;
可有看到,该结构体重只包含了非required的属性。因此只有非required属性才有__isset的属性。
write
uint32_t Student::write(::apache::thrift::protocol::TProtocol* oprot) const {
uint32_t xfer = 0;
::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
xfer += oprot->writeStructBegin("Student");
xfer += oprot-&g