Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Avro >> mail # user >> Adding extra fields into the schema


Copy link to this message
-
Adding extra fields into the schema
I'm wondering if there's a way to add user-defined name:value pairs
into the Avro JSON schema itself?

For instance, while building my schema (by using setFields for a
collection of fields), for some fields I do the following: [Using Java
API]

fieldObject.schema().addProp("myproperty", "myvalue");

I see that it adds to the schema like this:
{
    "name" : "someFieldXYZ",
    "type" : {
      "type" : "bytes",
      "myproperty" : "myvalue"
    },
    "default" : "XYZ"
}

But when I re-parse this created schema and try to retrieve my
property back, I get a null. I do this for getting it back:

fieldObject.schema.getProp("myproperty");

Why am I getting a null here? How do I access what's I embedded into
the schema properly back again? Or is this plain WRONG a thing to do?

[Type resolution still works fine even after it getting modified like that].

--
Harsh J
www.harshj.com
+
Harsh J 2010-07-19, 06:38
+
Doug Cutting 2010-07-19, 18:40
+
Harsh J 2010-07-28, 02:12
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB