You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by Ben Weaver <be...@orangesoda.net> on 2010/04/13 00:02:19 UTC

named primitive types, additional containers

Hey all,

I'm using Avro to store and transfer content for a website.  I've run into
some situations where it'd be nice to have named primitive types and
additional mapping containers.  I've seen some tickets requesting these
features and hope to get some advice about how to proceed.

In the hypothetical example below, "text" is an alias for "string" and the
"Folder" record has a "children" field that's an Ordered Map of "Key" (not
shown).  If I go ahead and hack together support for something like this,
what are the chances it could be supported in a future version of the
specification?

    { "name": "text", "type": "string" }

    { "name": "Folder", "type": "record",
      "fields": [
          { "name": "children", "type": { "type": "omap", "values": "Key" }
}
          ...
      ]
    }

To give a little more context, I'd like a primitive type called "text", an
Ordered Map container, and a Tree container.  My application would treat the
"text" type a string from Avro's perspective, but would assume that "string"
meant "single-line" and "text" meant "multi-line" when doing things like
rendering input widgets or doing form validation.  The Ordered Map keeps its
items in insertion-order; I use an Ordered Map to represent the contents of
a Folder.  The Tree keeps its items in key-order; I use it to guarantee the
mapping is kept in a consistent order because so I can make certain
assumptions about the data when storing it.

Does anyone have thoughts or suggestions?  I could implement workarounds by
adding something like a "multiline: true" attribute to field definitions
that need to be "text" and making record-boxes around maps to implement
Ordered Maps.  I'd prefer not to do this because the attribute is repetitive
and boxing seems cumbersome.

Thanks,

-Ben