avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: Why Array and Map are not named type ?
Date Wed, 25 Aug 2010 16:41:10 GMT
On 08/25/2010 09:27 AM, Jeff Zhang wrote:
> Since the purpose of named type is to allow it to be reference in
> other types, and Record, enums and fixed are named types, so why Array
> and map is not named type ? What's the design consideration ? I think
> if array and map is named type, I can create more complex data type.

Arrays and maps are not named types because the corresponding data 
structures in most programming languages are not named types.

Any datatype can be named by wrapping it in a single-field record.  This 
adds nothing to its serialized size, since records and fields have no 
overheads.  So if you wish to reuse a particular array or map type, you 
can use something like:

{"type":"record", "name":"my.ArrayOfInt", "fields": [
   {"name":"values", "type": {"type:"array", "items":"int"}}
]}

Note that, in release 1.4.0, Avro IDL will support file includes, 
simplifying schema reuse.

https://issues.apache.org/jira/browse/AVRO-495

Doug

Mime
View raw message