This implementation parses Avro schemas for both the key and entities. The entities contain metadata in annotations of the Avro record and Avro record fields. Each field must have a mapping annotation, which specifies how that field is mapped to an HBase column. Allowed mapping types are "column", "keyAsColumn", and "occVersion". The column mapping type on a field tells this entity mapper to map that field to the fully_qualified_column. The keyAsColumn mapping type on a field tells the entity mapper to map each key of the value type to a column in the specified column_family. This annotation is only allowed on map and record types. The entity record can contain a transactional annotation that tells HBase Common that this entity takes part in transactions The entity record should also contain a tables annotation, which tells HBase Common which tables this entity can be persisted to. Here is an example schema:
{ "name": "record_name", "type": "record", "tables": ["table1", "table2"], "transactional": "true", "fields": [ { "name": "field1", "type": "int", "mapping": { "type": "column", "value": "meta:field1" } }, { "name": "field2", "type": { "type": "map", "values": "string" }, "mapping": { "type": "keyAsColumn": "value": "map_family" } } ] }
An Avro instance of this schema would have its field1 value encoded to the meta:field1 column. Each key/value pair of the field2 map type would have its value mapped to the map_family:[key] column. It will also participate in transactions.