Skip to content

gorillib record schema

Philip (flip) Kromer edited this page May 16, 2012 · 2 revisions

gorillib/model/schema -- dynamically define classes from an avro schema

Model::Schema

a schema is either

  • a string, naming a defined type;

  • a class, embodying the defined type

  • an object of the form

      { "schema_type": (typename), ... attributes ... }
    

methods:

  • klass
  • namespace
  • fullname, pathname, basename
  • schema_type: one of :record, :array, etc. (question: should this be schema?)
  • doc
  • fields
  • is_a
  • doc_hints
  • core?
  • make -- manufactures class representing type

ModelSchema

  • name: a JSON string providing the name of the record (required).
  • namespace: a JSON string that qualifies the name;
  • doc: a JSON string providing documentation to the user of this schema (optional).
  • aliases: a JSON array of strings, providing alternate names for this record (optional).
  • fields: an array of Fields (required)

Field

  • name: a JSON string providing the name of the field (required), and

  • doc: a JSON string describing this field for users (optional).

  • type: A JSON object defining a schema, or a JSON string naming a record definition (required).

  • default: A default value for this field, used when reading instances that lack this field (optional). Permitted values depend on the field's schema type, according to the table below. Default values for union fields correspond to the first schema in the union. Default values for bytes and fixed fields are JSON strings, where Unicode code points 0-255 are mapped to unsigned 8-bit byte values 0-255.

  • a class has fields -- the schema description of each property.

  • an instance has attributes -- a map of each field's name to the value (if any) set on the instance.