avro-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=905516&view=rev
Log:
AVRO-383. Optimizing ResolvingDecoder for default values ("skipping default values", which
was't handled correctly in the previous commit)

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

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=905516&r1=905515&r2=905516&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Tue Feb  2 05:04:56 2010
@@ -294,7 +294,7 @@
 
     AVRO-343. Minor fixes to Eclipse config after build re-org (philz)
 
-    AVRO-383. Optiminzing ResolvingDecoder for default values (thiru)
+    AVRO-383. Optimizing ResolvingDecoder for default values (thiru)
 
   BUG FIXES
  

Modified: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/ResolvingDecoder.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/ResolvingDecoder.java?rev=905516&r1=905515&r2=905516&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/ResolvingDecoder.java (original)
+++ hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/ResolvingDecoder.java Tue Feb
 2 05:04:56 2010
@@ -165,7 +165,7 @@
     } else if (top instanceof Symbol.DefaultStartAction) {
       Symbol.DefaultStartAction dsa = (Symbol.DefaultStartAction) top;
       backup = in;
-      in = (new BinaryDecoder(new ByteArrayInputStream(dsa.contents)));
+      in = new BinaryDecoder(new ByteArrayInputStream(dsa.contents));
     } else if (top == Symbol.DEFAULT_END_ACTION) {
       in = backup;
     } else {
@@ -189,7 +189,7 @@
     } else if (top instanceof Symbol.DefaultStartAction) {
       Symbol.DefaultStartAction dsa = (Symbol.DefaultStartAction) top;
       backup = in;
-      in = (new JsonDecoder(dsa.root, new ByteArrayInputStream(dsa.contents)));
+      in = new BinaryDecoder(new ByteArrayInputStream(dsa.contents));
     } else if (top == Symbol.DEFAULT_END_ACTION) {
       in = backup;
     }

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=905516&r1=905515&r2=905516&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:04:56 2010
@@ -264,9 +264,8 @@
         Field wf = wfields.get(fname);
         if (wf == null) {
           Field rf = rfe.getValue();
-          Symbol r = new JsonGrammarGenerator().generate(rf.schema());
           byte[] bb = getBinary(rf.schema(), rf.defaultValue());
-          production[--count] = new Symbol.DefaultStartAction(r, bb);
+          production[--count] = new Symbol.DefaultStartAction(bb);
           production[--count] = super.generate(rf.schema(), seen);
           production[--count] = Symbol.DEFAULT_END_ACTION;
         }

Modified: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/Symbol.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/Symbol.java?rev=905516&r1=905515&r2=905516&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/Symbol.java (original)
+++ hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/Symbol.java Tue Feb  2
05:04:56 2010
@@ -468,10 +468,8 @@
   }
 
   public static class DefaultStartAction extends ImplicitAction {
-    public final Symbol root;
     public final byte[] contents;
-    public DefaultStartAction(Symbol root, byte[] contents) {
-      this.root = root;
+    public DefaultStartAction(byte[] contents) {
       this.contents = contents;
     }
   }

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=905516&r1=905515&r2=905516&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:04:56 2010
@@ -115,6 +115,20 @@
                 + "{\"name\":\"f2\", \"type\":\"int\"}]}}, "
           + "{\"name\": \"g2\", \"type\": \"long\"}]}}", "IIL",
           new Object[] { 10, 101, 11L } },
+        { "{\"type\":\"record\",\"name\":\"r\",\"fields\":[]}", "",
+          new Object[] { },
+          "{\"type\":\"record\",\"name\":\"r\",\"fields\":["
+          + "{\"name\":\"f\", \"type\":{ \"type\": \"array\", \"items\": \"int\" }, "
+            + "\"default\": [100]}]}", "[c1sI]",
+          new Object[] { 100 } },
+        { "{ \"type\": \"array\", \"items\": {\"type\":\"record\","
+            + "\"name\":\"r\",\"fields\":[]} }", "[c1s]",
+            new Object[] { },
+          "{ \"type\": \"array\", \"items\": {\"type\":\"record\","
+            + "\"name\":\"r\",\"fields\":["
+            + "{\"name\":\"f\", \"type\":\"int\", \"default\": 100}]} }",
+            "[c1sI]",
+          new Object[] { 100 } },
     };
   }
 }



Mime
View raw message