java - how can I define a map accept different kind of value in thrift? -


i define struct thrift:

struct querysetrecord {     1:string recordid,     2:string crawlername,     3:string recordtype,     4:map<string,string> datamap,     5:i16 priority, } 

the problem datamap, not want accept string value, may still want accept list or map, such map<string, list<string>> datamap. in other words, want type root object in java, object in python

can this?

you have create own object , list possible classes in it.

union object {    1: string str;    2: i32 number32; } 

(as i'm not sure how union implementation works in langs i'd go struct fields optional)

struct object {    1: optional string str;    2: optional i32 number32; } 

and then: map<string, object>

in thrift can't create 'accept all' field, not portable across languages, , that's 1 of key functionalities of thrift.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -