Alfred Zhong
Alfred Zhong

Reputation: 7081

does thrift support data type of "list of arrays" like java?

I am looking for something like

list<float[]> foo

in thrift, I know I can use

list>

but just curious if there is any way to put an array into a list.

seems like java supports

List<float[]>

in python, like

[[]]

thanks!

Upvotes: 0

Views: 2387

Answers (1)

JensG
JensG

Reputation: 13411

No, but you can of course have list< list< double>>.

From https://thrift.apache.org/docs/types (only slightly redacted):

The base types were selected with the goal of simplicity and clarity rather than abundance, focusing on the key types available in all programming languages.

  • bool: boolean value (true or false)
  • i8 or byte: 8-bit signed integer
  • i16: 16-bit signed integer
  • i32: 32-bit signed integer
  • i64: 64-bit signed integer
  • double: 64-bit floating point number
  • string: text string
  • binary: sequence of unencoded bytes
  • list<T>: ordered list of elements
  • set<T>: unordered set of unique elements
  • map<K,V>: map of strictly unique keys to values

While defaults are provided, the type mappings are not explicitly fixed. Custom code generator directives have been added to allow substitution of custom types in various destination languages.

The latter paragraph highly depends on the target language, there is no general rule about what's possible and what isn't. The custom types can be introduced by means of IDL annotations.

Upvotes: 3

Related Questions