avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1577673 - in /avro/trunk: CHANGES.txt doc/src/content/xdocs/spec.xml
Date Fri, 14 Mar 2014 19:41:32 GMT
Author: cutting
Date: Fri Mar 14 19:41:32 2014
New Revision: 1577673

URL: http://svn.apache.org/r1577673
Log:
AVRO-1482. In specification, place null first in unions as best practice.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/doc/src/content/xdocs/spec.xml

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1577673&r1=1577672&r2=1577673&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Fri Mar 14 19:41:32 2014
@@ -33,6 +33,9 @@ Trunk (not yet released)
     AVRO-1465. Java: Improve the error message when union dispatch fails.
     (Gabriel Reid via cutting)
 
+    AVRO-1482. In specification, place "null" first in unions as best practice.
+    (cutting)
+
   BUG FIXES
 
     AVRO-1446. C#: Correctly handle system errors in RPC.

Modified: avro/trunk/doc/src/content/xdocs/spec.xml
URL: http://svn.apache.org/viewvc/avro/trunk/doc/src/content/xdocs/spec.xml?rev=1577673&r1=1577672&r2=1577673&view=diff
==============================================================================
--- avro/trunk/doc/src/content/xdocs/spec.xml (original)
+++ avro/trunk/doc/src/content/xdocs/spec.xml Fri Mar 14 19:41:32 2014
@@ -150,7 +150,7 @@
   "aliases": ["LinkedLongs"],                      // old name for this
   "fields" : [
     {"name": "value", "type": "long"},             // each element has a long
-    {"name": "next", "type": ["LongList", "null"]} // optional next element
+    {"name": "next", "type": ["null", "LongList"]} // optional next element
   ]
 }
 	  </source>
@@ -210,8 +210,14 @@
         <section>
           <title>Unions</title>
           <p>Unions, as mentioned above, are represented using JSON
-          arrays.  For example, <code>["string", "null"]</code>
-          declares a schema which may be either a string or null.</p>
+          arrays.  For example, <code>["null", "string"]</code>
+          declares a schema which may be either a null or string.</p>
+          <p>(Note that when a <a href="#schema_record">default
+          value</a> is specified for a record field whose type is a
+          union, the type of the default value must match the
+          <em>first</em> element of the union.  Thus, for unions
+          containing "null", the "null" is usually listed first, since
+          the default value of such unions is typically null.)</p>
 	  <p>Unions may not contain more than one schema with the same
 	  type, except for the named types record, fixed and enum.  For
 	  example, unions containing two array types or two map types
@@ -497,14 +503,14 @@
               union of the schema of its value.  The value is then
               encoded per the indicated schema within the union.</p>
             <p>For example, the union
-              schema <code>["string","null"]</code> would encode:</p>
+              schema <code>["null","string"]</code> would encode:</p>
             <ul>
-              <li><code>null</code> as the integer 1 (the index of
-                "null" in the union, encoded as
-                hex <code>02</code>): <source>02</source></li>
-              <li>the string <code>"a"</code> as zero (the index of
-                "string" in the union), followed by the serialized string:
-                <source>00 02 61</source></li>
+              <li><code>null</code> as zero (the index of "null" in the
union):
+                <source>00</source></li>
+              <li>the string <code>"a"</code> as one (the index of
+                "string" in the union, encoded as hex <code>02</code>),
+                followed by the serialized string:
+                <source>02 02 61</source></li>
             </ul>
           </section>
 



Mime
View raw message