You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Simon Reavely <si...@gmail.com> on 2011/06/02 16:26:33 UTC
Can I specify records separately rather than inlining/nesting records
in a single record tree in a schema file?
I am trying to explore schema inlining versus being able to specify records
separately (I would prefer separately). I reviewed the following...
http://apache-avro.679487.n3.nabble.com/references-to-other-schemas-tt771887.html#none
<http://apache-avro.679487.n3.nabble.com/references-to-other-schemas-tt771887.html#none>...but
it covered protocols and I just want a schema
So for example, I have a schema
// START OF FILE
{
"type": "record",
"namespace": "org.openrtb.mobile",
"name": "BidRequest",
"doc" : "Top-Level BidRequest Object from OpenRTB Mobile 1.0 Spec",
"fields": [
{"name": "id", "type": "string", "required":"true","comment":"Unique
ID of the bid request (i.e., the overall auction ID)."},
{"name": "at", "type": ["int", "null"],
"required":"false","comment":"Auction type - 1 indicates 1st Price, others
denote alternate rules."},
{"name": "imp", "type": {"type": "array", "items": {
"type": "record",
"namespace": "org.openrtb.mobile",
"name": "BidImpression",
"doc" : "Bid Impression Object used in Bid Request from OpenRTB Mobile 1.0
Spec",
"fields": [
{"name": "impid", "type": "string","required":"true","comment":"Unique
ID of the impression."}
]
}
}, "required":"true","comment":"1 object per impression being offered
for bid"}
]
}
<http://apache-avro.679487.n3.nabble.com/references-to-other-schemas-tt771887.html#none>//
END OF FILE
<http://apache-avro.679487.n3.nabble.com/references-to-other-schemas-tt771887.html#none>I
load that schema using...
import org.apache.avro.Schema;
Schema schema = Schema.parse(schemaStream);
What I wanted to do was create a single file with the records split out
(rather than inlined) e.g.
(See below how the array references the record underneath)
// START OF FILE
{
"type": "record",
"namespace": "org.openrtb.mobile",
"name": "BidRequest",
"doc" : "Top-Level BidRequest Object from OpenRTB Mobile 1.0 Spec",
"fields": [
{"name": "id", "type": "string", "required":"true","comment":"Unique
ID of the bid request (i.e., the overall auction ID)."},
{"name": "at", "type": ["int", "null"],
"required":"false","comment":"Auction type - 1 indicates 1st Price, others
denote alternate rules."},
{"name": "imp", "type": {"type": "array", "items":
"org.openrtb.mobile.BidImpression"}, "required":"true","comment":"1 object
per impression being offered for bid"}
]
}
{
"type": "record",
"namespace": "org.openrtb.mobile",
"name": "BidImpression",
"doc" : "Bid Impression Object used in Bid Request from OpenRTB Mobile 1.0
Spec",
"fields": [
{"name": "impid", "type": "string","required":"true","comment":"Unique
ID of the impression."}
]
}
// END OF FILE
...seems like you can't do this
...seems like you have to inline everything
...am I correct?
--
Simon Reavely
simon.reavely@gmail.com