如何在Avro架构中创建记录列表

时间:2019-01-22 06:53:08

标签: avro avro-tools

我有如下所述的Avro模式。

{"type":"record",
"namespace": "com.test",
"name": "bck",
"fields": [ {"name": "accountid","type": "string"},
{"name":"amendmentpositionid","type": "int"},
{"name":"booking","type":
{"type":"array","items":
{"namespace":"com.test",
"name":"bkkk",
"type":"record",
"fields":
[{"name":"accountid","type":"string"},{"name":"clientid","type":"int"},
{"name":"clientname","type":"string"},{"name":"exerciseid","type":"int"},
{"name":"hedgeid","type":"int"},{"name":"originatingpositionid","type":"int"},
{"name":"positionid","type":"int"},{"name":"relatedpositionid","type":"int"} ]}}}]}

我想再创建一个与上述相同类型的记录。或者我的意思是说我想创建一个记录列表,其中每个记录的架构与上面相同。如何在单个Avro文件模式中实现它?

1 个答案:

答案 0 :(得分:0)

您提供的架构已包含记录数组。如果我的理解是正确的,则您想使用/包含此模式来创建另一个记录数组,这将使其在一个模式文件中的记录数组中成为一个记录数组。

我希望这会有所帮助。

{
    "type": "record",
    "namespace": "com.test",
    "name": "list",
    "fields": [{
        "name":"listOfBck","type":
        {"type":"array","items":
            {
                "type":         "record",
                "namespace":    "com.test",
                "name":         "bck",
                "fields": [
                    {"name": "accountid","type": "string"},
                    {"name":"amendmentpositionid","type": "int"},
                    {"name":"booking","type":
                        {"type":"array","items":
                            {"namespace":"com.test",
                                "name":"bkkk",
                                "type":"record",
                                "fields": [
                                    {"name":"accountid","type":"string"},{"name":"clientid","type":"int"},
                                    {"name":"clientname","type":"string"},{"name":"exerciseid","type":"int"},
                                    {"name":"hedgeid","type":"int"},{"name":"originatingpositionid","type":"int"},
                                    {"name":"positionid","type":"int"},{"name":"relatedpositionid","type":"int"}
                                ]
                            }
                        }
                    }
                ]
            }
        }
    }]
}
相关问题