avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Meinert <ke...@subatomicglue.com>
Subject AvroIDL and nested records
Date Thu, 02 Feb 2012 21:22:30 GMT
------------------------------
From: Kevin Meinert
Sent: 2/2/2012 1:58 PM
To: user@avro.apache.org
Subject: AvroIDL and nested records


How would I nest records in AvroIDL?

Here's my datastructure for "Actor" (see bottom), initially I tried to nest
records inside of records, but the idl compiler didn't take it.   My
datafiles will only ever include an "Actor", never the other types, i'm
concerned about space and dont want extra fields hanging around bloating
the filesize...

Do I risk having CompeteShape and Joint being instantiated (and taking
extra space), or is the below correct way to nest records (and use custom
record types inside arrays).   Would be nice to see this type of example in
the AvroIDL example online... defining your own types and using them nested
in other types, as well as inside arrays.

thanks,

/**
 * Actor protocol
 */
@namespace("kevin.foo.bar")
protocol ActorProto
{
   /** definition, do not want instantiated! */
   enum ShapeType
   {
      SQUARE,
      CIRCLE,
      POLYGON
   }
   /** definition, do not want instantiated! */
   enum PhysicsType
   {
      STATIC,
      DYNAMIC
   }
   /** definition, do not want instantiated! */
   enum JointType
   {
      REVOLUTE
   }

   /** definition, do not want instantiated! */
   record CompleteShape
   {
      int x;
      int y;
      int height;
      int width;
      float rotation;
      PhysicsType type;
      ShapeType shape;
      float elasticity;
      float friction;
      float mass;
      array<float> verts;
   }
   /** definition, do not want instantiated! */
   record Joint
   {
      int l0;
      int l1;
      JointType type;
   }

   record Actor
   {
      int other_misc_data; // todo: fill in more actor fields...
      array<CompleteShape> body_shapes;
      array<Joint>         body_joints;
   }
}

Mime
View raw message