You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by cu...@apache.org on 2010/08/23 22:52:09 UTC

svn commit: r988309 - in /avro/trunk: CHANGES.txt doc/src/content/xdocs/idl.xml lang/java/src/java/org/apache/avro/idl/idl.jj lang/java/src/test/idl/input/simple.avdl lang/java/src/test/idl/output/simple.avpr

Author: cutting
Date: Mon Aug 23 20:52:09 2010
New Revision: 988309

URL: http://svn.apache.org/viewvc?rev=988309&view=rev
Log:
AVRO-590. IDL: Fix order specifications.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/doc/src/content/xdocs/idl.xml
    avro/trunk/lang/java/src/java/org/apache/avro/idl/idl.jj
    avro/trunk/lang/java/src/test/idl/input/simple.avdl
    avro/trunk/lang/java/src/test/idl/output/simple.avpr

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=988309&r1=988308&r2=988309&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Mon Aug 23 20:52:09 2010
@@ -168,6 +168,8 @@ Avro 1.4.0 (unreleased)
 
     AVRO-612. Java: Preserve field documentation when writing schemas. (cutting)
 
+    AVRO-590. IDL: Fix order specifications. (cutting)
+
 Avro 1.3.3 (7 June 2010)
 
   IMPROVEMENTS

Modified: avro/trunk/doc/src/content/xdocs/idl.xml
URL: http://svn.apache.org/viewvc/avro/trunk/doc/src/content/xdocs/idl.xml?rev=988309&r1=988308&r2=988309&view=diff
==============================================================================
--- avro/trunk/doc/src/content/xdocs/idl.xml (original)
+++ avro/trunk/doc/src/content/xdocs/idl.xml Mon Aug 23 20:52:09 2010
@@ -316,21 +316,23 @@ void `error`();
       </section>
       <section id="minutiae_annotations">
         <title>Annotations for Ordering and Namespaces</title>
-        <p>
-          Java-style annotations may be used to add additional properties to types throughout
-          Avro IDL. For example, to specify the sort order of a field within a record, one may use
-          the <code>@order</code> annotation as follows:
-        </p>
+        <p>Java-style annotations may be used to add additional
+          properties to types and fields throughout Avro IDL.</p>
+
+	<p>For example, to specify the sort order of a field within
+          a record, one may use the <code>@order</code> annotation
+          before the field name as follows:</p>
         <source>
 record MyRecord {
-  @order("ascending")
-  string myAscendingSortField;
-
-  @order("descending")
-  string myDescendingField;
-
-  @order("ignore")
-  string myIgnoredField;
+  string @order("ascending") myAscendingSortField;
+  string @order("descending")  myDescendingField;
+  string @order("ignore") myIgnoredField;
+}
+        </source>
+        <p>A field's type may also be preceded by annotations, e.g.: </p>
+        <source>
+record MyRecord {
+  @java-class("java.util.ArrayList") array string myStrings;
 }
         </source>
         <p>Similarly, a <code>@namespace</code> annotation may be used to modify the namespace

Modified: avro/trunk/lang/java/src/java/org/apache/avro/idl/idl.jj
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/java/org/apache/avro/idl/idl.jj?rev=988309&r1=988308&r2=988309&view=diff
==============================================================================
--- avro/trunk/lang/java/src/java/org/apache/avro/idl/idl.jj (original)
+++ avro/trunk/lang/java/src/java/org/apache/avro/idl/idl.jj Mon Aug 23 20:52:09 2010
@@ -1209,14 +1209,25 @@ void VariableDeclarator(Schema type, Lis
 {
   String name;
   JsonNode defaultValue = null;
+  Map<String, String> props = new HashMap<String, String>();
 }
 {
+    ( SchemaProperty(props) )*
+    
   name = Identifier()
 
     [ <EQUALS> defaultValue=Json() ]
     
   {
-    fields.add(new Field(name, type, null, defaultValue));
+    Field.Order order = Field.Order.ASCENDING;
+    for (Map.Entry<String, String> prop : props.entrySet())
+      if ("order".equals(prop.getKey()))
+        order = Field.Order.valueOf(prop.getValue().toUpperCase());
+    Field field = new Field(name, type, null, defaultValue, order);
+    for (Map.Entry<String, String> prop : props.entrySet())
+      if (!"order".equals(prop.getKey()))
+        field.addProp(prop.getKey(), prop.getValue());
+    fields.add(field);
   }
 }
 

Modified: avro/trunk/lang/java/src/test/idl/input/simple.avdl
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/test/idl/input/simple.avdl?rev=988309&r1=988308&r2=988309&view=diff
==============================================================================
--- avro/trunk/lang/java/src/test/idl/input/simple.avdl (original)
+++ avro/trunk/lang/java/src/test/idl/input/simple.avdl Mon Aug 23 20:52:09 2010
@@ -30,13 +30,11 @@ protocol Simple {
   fixed MD5(16);
 
   record TestRecord {
-    @order("ignore")
-    string name = "foo";
+    string @order("ignore") name = "foo";
 
-    @order("descending")
-    Kind kind;
+    Kind @order("descending") kind;
 
-    MD5 hash;
+    @foo("bar") MD5 hash;
 
     union { MD5, null} nullableHash;
   }

Modified: avro/trunk/lang/java/src/test/idl/output/simple.avpr
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/test/idl/output/simple.avpr?rev=988309&r1=988308&r2=988309&view=diff
==============================================================================
--- avro/trunk/lang/java/src/test/idl/output/simple.avpr (original)
+++ avro/trunk/lang/java/src/test/idl/output/simple.avpr Mon Aug 23 20:52:09 2010
@@ -4,25 +4,24 @@
   "types" : [ {
     "type" : "enum",
     "name" : "Kind",
-    "symbols" : [ "FOO", "BAR", "BAZ" ],
-    "order" : "descending"
+    "symbols" : [ "FOO", "BAR", "BAZ" ]
   }, {
     "type" : "fixed",
     "name" : "MD5",
-    "size" : 16
+    "size" : 16,
+    "foo" : "bar"
   }, {
     "type" : "record",
     "name" : "TestRecord",
     "fields" : [ {
       "name" : "name",
-      "type" : {
-        "type" : "string",
-        "order" : "ignore"
-      },
-      "default" : "foo"
+      "type" : "string",
+      "default" : "foo",
+      "order" : "ignore"
     }, {
       "name" : "kind",
-      "type" : "Kind"
+      "type" : "Kind",
+      "order" : "descending"
     }, {
       "name" : "hash",
       "type" : "MD5"