【问题标题】:How to create Avro schema for Map<Integer,Map<Integer,Float>>?如何为 Map<Integer,Map<Integer,Float>> 创建 Avro 模式?
【发布时间】:2016-07-08 20:39:59
【问题描述】:

map of map 的文档不是很清楚。我正在尝试将这样的对象(Map>)序列化到 Avro,我该如何实现。

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

【问题讨论】:

  • @Alex A. 你能帮我解决这个问题吗?

标签: java serialization avro


【解决方案1】:

我自己的解决方案:

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

【讨论】:

  • 这不是真正的使用 int 作为键的地图,对吧?我认为这在 avro 中是不可能的.. 你手动转换为 str 吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-09-30
  • 1970-01-01
  • 2019-12-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多