Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Plain View
Avro >> mail # user >> Serializing nested records


+
yimca 2013-01-21, 14:14
+
robturner 2013-01-21, 22:29
Copy link to this message
-
Re: Serializing nested records
Thanks very much Doug and Rob for the quick and accurate replies.   Doug's
suggestion helped make sense of the error, and Rob's suggestion got me most
of the way to resolving it.   It turned out there was a second error in the
definition of the first "components" field - instead of:

  {"name": "components", "type":
     [{ "type": "array", "items" :
          [{ "type": "record",

It needed to be:

  {"name": "components", "type":
    ["null",
      { "type": "array", "items":
        { "type": "record",

This, along with Doug's suggestion, resulted in the working schema:

{
  "namespace": "com.wily.apm.blackjack",
  "type": "record",
  "name": "TransactionStatic",
  "fields":
   [
       {"name": "id", "type": "int"},
       {"name": "isIdLocal", "type": "boolean", "default": "true"},
       {"name": "contextPath", "type": [{ "type": "array", "items": "string"
},"null"] },
       {"name": "components", "type":
          ["null",
           { "type": "array", "items":
              { "type": "record",
                "name": "TransactionStaticComponent",
                "fields":
                [                      
                    {"name": "id", "type": "int"},
                    {"name": "isIdLocal", "type": "boolean", "default":
"true"},
                    {"name": "contextPath", "type": [{ "type": "array",
"items": "string" },"null"] },
                    {"name": "application", "type" : ["string","null"]},
                    {"name": "class", "type" :  ["string","null"]},
                    {"name": "method", "type" :  ["string","null"]},
                    {"name": "lineNumber", "type" :  ["int","null"]},
                    {"name": "payload", "type": [{"type": "map", "values":
"string"},"null"] },
                    {"name": "components", "type": [{"type": "array",
"items": "TransactionStaticComponent"},"null"], "default": "null"}
                ]
              }
           }]
        }
    ]
}

--
View this message in context: http://apache-avro.679487.n3.nabble.com/Serializing-nested-records-tp4025992p4026005.html
Sent from the Avro - Users mailing list archive at Nabble.com.
+
Doug Cutting 2013-01-21, 22:04