Search code examples
javaserializationavro

How to create Avro schema for Map<Integer,Map<Integer,Float>>?


The documentation of map of map is not very clear. I'm trying to serialize such an object(Map>) to Avro, how can I achieve that.

{"namespace": "example",
 "type": "map",
 "name": "Map",
 "keys": "int",
 "values": {
  "type":"map",
  "keys":"int",
  "values":"float" 
 }
}  

Solution

  • My own solution:

    {"namespace": "Schema",
      "name":"PvMap",
      "type":"record",
      "fields":[
      {"name": "TradeId", "type": "int"},
        { "name": "Tmap",
          "type":{
          "type":"map",
          "values":"float"}
          }
      ]
    }