avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From th...@apache.org
Subject svn commit: r905520 - in /hadoop/avro/trunk: ./ lang/java/src/java/org/apache/avro/io/parsing/ lang/java/src/test/java/org/apache/avro/io/
Date Tue, 02 Feb 2010 05:34:22 GMT
Author: thiru
Date: Tue Feb  2 05:34:17 2010
New Revision: 905520

URL: http://svn.apache.org/viewvc?rev=905520&view=rev
Log:
AVRO-390. ResolvingDecoder does not handle default values for records well

Modified:
    hadoop/avro/trunk/CHANGES.txt
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/ResolvingGrammarGenerator.java
    hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/TestResolvingIOResolving.java
    hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/TestValidatingIO.java

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=905520&r1=905519&r2=905520&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Tue Feb  2 05:34:17 2010
@@ -405,6 +405,8 @@
     
     AVRO-389. ResolvingDecoder does not resolve enum well (thiru)
 
+    AVRO-390. ResolvingDecoder does not handle default values for records well (thiru)
+
 Avro 1.2.0 (14 October 2009)
 
   INCOMPATIBLE CHANGES

Modified: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/ResolvingGrammarGenerator.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/ResolvingGrammarGenerator.java?rev=905520&r1=905519&r2=905520&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/ResolvingGrammarGenerator.java
(original)
+++ hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/ResolvingGrammarGenerator.java
Tue Feb  2 05:34:17 2010
@@ -266,7 +266,7 @@
           Field rf = rfe.getValue();
           byte[] bb = getBinary(rf.schema(), rf.defaultValue());
           production[--count] = new Symbol.DefaultStartAction(bb);
-          production[--count] = super.generate(rf.schema(), seen);
+          production[--count] = generate(rf.schema(), rf.schema(), seen);
           production[--count] = Symbol.DEFAULT_END_ACTION;
         }
       }

Modified: hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/TestResolvingIOResolving.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/TestResolvingIOResolving.java?rev=905520&r1=905519&r2=905520&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/TestResolvingIOResolving.java
(original)
+++ hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/TestResolvingIOResolving.java
Tue Feb  2 05:34:17 2010
@@ -86,21 +86,21 @@
           new Object[] { 10, "hello" },
           "{\"type\":\"record\",\"name\":\"r\",\"fields\":["
           + "{\"name\":\"f2\", \"type\":\"string\" },"
-          + "{\"name\":\"f1\", \"type\":\"long\"}]}", "LS10",
+          + "{\"name\":\"f1\", \"type\":\"long\"}]}", "RLS10",
           new Object[] { 10L, "hello" } },
 
         // Default values
         { "{\"type\":\"record\",\"name\":\"r\",\"fields\":[]}", "",
           new Object[] { },
           "{\"type\":\"record\",\"name\":\"r\",\"fields\":["
-          + "{\"name\":\"f\", \"type\":\"int\", \"default\": 100}]}", "I",
+          + "{\"name\":\"f\", \"type\":\"int\", \"default\": 100}]}", "RI",
           new Object[] { 100 } },
         { "{\"type\":\"record\",\"name\":\"r\",\"fields\":["
             + "{\"name\":\"f2\", \"type\":\"int\"}]}", "I",
           new Object[] { 10 },
           "{\"type\":\"record\",\"name\":\"r\",\"fields\":["
           + "{\"name\":\"f1\", \"type\":\"int\", \"default\": 101},"
-          + "{\"name\":\"f2\", \"type\":\"int\"}]}", "II",
+          + "{\"name\":\"f2\", \"type\":\"int\"}]}", "RII",
           new Object[] { 10, 101 } },
         { "{\"type\":\"record\",\"name\":\"outer\",\"fields\":["
             + "{\"name\": \"g1\", " +
@@ -113,8 +113,20 @@
                         "\"type\":{\"type\":\"record\",\"name\":\"inner\",\"fields\":["
                 + "{\"name\":\"f1\", \"type\":\"int\", \"default\": 101},"
                 + "{\"name\":\"f2\", \"type\":\"int\"}]}}, "
-          + "{\"name\": \"g2\", \"type\": \"long\"}]}}", "IIL",
+          + "{\"name\": \"g2\", \"type\": \"long\"}]}}", "RRIIL",
           new Object[] { 10, 101, 11L } },
+        // Default value for a record.
+        { "{\"type\":\"record\",\"name\":\"outer\",\"fields\":["
+            + "{\"name\": \"g2\", \"type\": \"long\"}]}", "L",
+          new Object[] { 11L },
+          "{\"type\":\"record\",\"name\":\"outer\",\"fields\":["
+            + "{\"name\": \"g1\", " +
+                "\"type\":{\"type\":\"record\",\"name\":\"inner\",\"fields\":["
+              + "{\"name\":\"f1\", \"type\":\"int\" },"
+              + "{\"name\":\"f2\", \"type\":\"int\"}] }, "
+              + "\"default\": { \"f1\": 10, \"f2\": 101 } }, "
+            + "{\"name\": \"g2\", \"type\": \"long\"}]}", "RLRII",
+          new Object[] { 11L, 10, 101} },
         { "{\"type\":\"record\",\"name\":\"r\",\"fields\":[]}", "",
           new Object[] { },
           "{\"type\":\"record\",\"name\":\"r\",\"fields\":["

Modified: hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/TestValidatingIO.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/TestValidatingIO.java?rev=905520&r1=905519&r2=905520&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/TestValidatingIO.java (original)
+++ hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/TestValidatingIO.java Tue
Feb  2 05:34:17 2010
@@ -460,6 +460,9 @@
           assertEquals(idx, vi.readIndex());
           continue;
         }
+      case 'R':
+          ((ResolvingDecoder) vi).readFieldOrder();
+          continue;
       default:
         fail();
       }



Mime
View raw message