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 Threaded View
Avro >> mail # user >> Does avro support Generic Record with map values that are records?


Copy link to this message
-
Re: Does avro support Generic Record with map values that are records?
On Thu, Jul 19, 2012 at 10:32 PM, Sameer Deokule <[EMAIL PROTECTED]> wrote:
>   Is this something that has been tested/used via a generic record?

I wrote the following test, added it to TestSchema.java, and it passes.

Can you provide a self-contained test that fails?

Thanks,

Doug

  @Test
  public void testMapInRecord2() throws Exception {
    String xJson = "{\"type\":\"record\", \"name\":\"X\", \"fields\":"
      +"[{\"name\":\"g\", \"type\":\"long\"}]}";
    String json = "{\"type\":\"record\", \"name\":\"Test\", \"fields\":"
      +"[{\"name\":\"f\", \"type\": {\"type\":\"map\", \"values\":"
      + xJson
      +"}}]}";
    Schema schema = Schema.parse(json);
    Schema xSchema = Schema.parse(xJson);

    GenericData.Record x = new GenericData.Record(xSchema);
    x.put("g", 11L);
    HashMap<Utf8,GenericData.Record> map=new HashMap<Utf8,GenericData.Record>();
    map.put(new Utf8("a"), x);
    GenericData.Record r = new GenericData.Record(schema);
    r.put("f", map);
    check(json, "{\"f\":{\"a\":{\"g\":11}}}", r, false);
  }
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