title: How to populate avro nested map structure
body: <p>Has anyone used <code>GenericData.Record</code> with Avro and nested map records. Giving the below schema, I am struggling to populate the <code>GenericData.Record</code> within a map:</p>
  
  <pre><code> {"name": "log_data", "type":
     [ "null",
       { "type": "map", "values":
         { "type": "record",
           "name": "TypeValuePair",
           "fields": [
             {"name": "type", "type": "string"},
             {"name": "value", "type": ["null", "string"]}
           ]
         }
       }
     ]
   }
  </code></pre>
  
  <p>The java code:</p>
  
  <pre><code>Schema mapSchema = schema.getField("log_data").schema().getTypes().get(1);
  
  //The code below fails
  
  GenericRecord typeValuePair =
      new GenericData.Record(mapSchema.getField("TypeValuePair").schema());
  </code></pre>
  
  <p>with:</p>
  
  <pre><code>org.apache.avro.AvroRuntimeException: Not a record..
  </code></pre>
  
  <p>Any idea how I should be building setting a map within avro schema that holds values of type record?</p>