avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r899471 - in /hadoop/avro/trunk: ./ lang/c++/api/ lang/c++/impl/ lang/java/src/java/org/apache/avro/io/ lang/java/src/java/org/apache/avro/io/parsing/ lang/java/src/java/org/apache/avro/io/parsing/doc-files/ lang/java/src/test/java/org/apac...
Date Thu, 14 Jan 2010 23:32:25 GMT
Author: cutting
Date: Thu Jan 14 23:32:24 2010
New Revision: 899471

URL: http://svn.apache.org/viewvc?rev=899471&view=rev
Log:
Reverting AVRO-313 and AVRO-316, since they cause the test-java target to fail.

Modified:
    hadoop/avro/trunk/CHANGES.txt
    hadoop/avro/trunk/lang/c++/api/ValidatingReader.hh   (props changed)
    hadoop/avro/trunk/lang/c++/impl/ValidatingReader.cc   (props changed)
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/BinaryDecoder.java   (props changed)
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/BinaryEncoder.java   (props changed)
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/BlockingBinaryEncoder.java   (props
changed)
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/JsonDecoder.java
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/JsonEncoder.java
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/ResolvingDecoder.java
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/ValidatingDecoder.java
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/ValidatingEncoder.java
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/JsonGrammarGenerator.java
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/Parser.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/SkipParser.java
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/Symbol.java
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/ValidatingGrammarGenerator.java
    hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/doc-files/   (props changed)
    hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/Perf.java
    hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/TestBinaryDecoder.java  
(props changed)
    hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/TestResolvingIOResolving.java
  (contents, props changed)
    hadoop/avro/trunk/share/test/schemas/interop.avsc   (props changed)
    hadoop/avro/trunk/share/test/schemas/simple.avpr   (props changed)

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=899471&r1=899470&r2=899471&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Thu Jan 14 23:32:24 2010
@@ -224,8 +224,6 @@
 
     AVRO-315. Performance improvements to BinaryDecoder (thiru)
 
-    AVRO-316. Optiminzing inner loop functions of Avro io (thiru)
-
   BUG FIXES
  
     AVRO-176. Safeguard against bad istreams before reading. (sbanacho)

Propchange: hadoop/avro/trunk/lang/c++/api/ValidatingReader.hh
            ('svn:mergeinfo' removed)

Propchange: hadoop/avro/trunk/lang/c++/impl/ValidatingReader.cc
            ('svn:mergeinfo' removed)

Propchange: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/BinaryDecoder.java
            ('svn:mergeinfo' removed)

Propchange: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/BinaryEncoder.java
            ('svn:mergeinfo' removed)

Propchange: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/BlockingBinaryEncoder.java
            ('svn:mergeinfo' removed)

Modified: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/JsonDecoder.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/JsonDecoder.java?rev=899471&r1=899470&r2=899471&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/JsonDecoder.java (original)
+++ hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/JsonDecoder.java Thu Jan 14 23:32:24
2010
@@ -389,7 +389,7 @@
         String fn = in.getCurrentName();
         if (fa.fname.equals(fn)) {
           in.nextToken();
-          return null;
+          return Symbol.CONTINUE;
         } else {
           throw new AvroTypeException("Expected field name " + fa.fname +
               " got " + in.getCurrentName());
@@ -410,7 +410,7 @@
     } else {
       throw new AvroTypeException("Unknown action symbol " + top);
     }
-    return null;
+    return Symbol.CONTINUE;
   }
 
   private AvroTypeException error(String type) {

Modified: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/JsonEncoder.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/JsonEncoder.java?rev=899471&r1=899470&r2=899471&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/JsonEncoder.java (original)
+++ hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/JsonEncoder.java Thu Jan 14 23:32:24
2010
@@ -53,7 +53,7 @@
 
   @Override
   public void flush() throws IOException {
-    parser.processTrailingImplicitActions();
+    parser.processImplicitActions();
     out.flush();
   }
 
@@ -233,7 +233,7 @@
     } else {
       throw new AvroTypeException("Unknown action symbol " + top);
     }
-    return null;
+    return Symbol.CONTINUE;
   }
 }
 

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=899471&r1=899470&r2=899471&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 Thu Jan
14 23:32:24 2010
@@ -157,7 +157,7 @@
   @Override
   public Symbol doAction(Symbol input, Symbol top) throws IOException {
     if (top instanceof Symbol.FieldAdjustAction) {
-      return input == Symbol.FIELD_ACTION ? top : null;
+      return input == Symbol.FIELD_ACTION ? top : Symbol.CONTINUE;
     } if (top instanceof Symbol.ResolvingAction) {
       Symbol.ResolvingAction t = (Symbol.ResolvingAction) top;
       if (t.reader != input) {
@@ -183,7 +183,7 @@
     } else {
       throw new AvroTypeException("Unknown action: " + top);
     }
-    return null;
+    return Symbol.CONTINUE;
   }
 
   @Override
@@ -198,12 +198,6 @@
       parser.pushSymbol(branches.getSymbol(in.readIndex()));
     } else if (top instanceof Symbol.ErrorAction) {
       throw new AvroTypeException(((Symbol.ErrorAction) top).msg);
-    } else if (top instanceof Symbol.DefaultStartAction) {
-      Symbol.DefaultStartAction dsa = (Symbol.DefaultStartAction) top;
-      backup = in;
-      in = (new JsonDecoder(dsa.root, 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/ValidatingDecoder.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/ValidatingDecoder.java?rev=899471&r1=899470&r2=899471&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/ValidatingDecoder.java (original)
+++ hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/ValidatingDecoder.java Thu Jan
14 23:32:24 2010
@@ -164,7 +164,6 @@
 
   @Override
   public long arrayNext() throws IOException {
-    parser.processTrailingImplicitActions();
     long result = in.arrayNext();
     if (result == 0) {
       parser.advance(Symbol.ARRAY_END);
@@ -196,7 +195,6 @@
 
   @Override
   public long mapNext() throws IOException {
-    parser.processTrailingImplicitActions();
     long result = in.mapNext();
     if (result == 0) {
       parser.advance(Symbol.MAP_END);
@@ -226,7 +224,7 @@
   }
   
   public Symbol doAction(Symbol input, Symbol top) throws IOException {
-    return null;
+    return Symbol.CONTINUE;
   }
 }
 

Modified: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/ValidatingEncoder.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/ValidatingEncoder.java?rev=899471&r1=899470&r2=899471&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/ValidatingEncoder.java (original)
+++ hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/ValidatingEncoder.java Thu Jan
14 23:32:24 2010
@@ -192,7 +192,7 @@
 
   @Override
   public Symbol doAction(Symbol input, Symbol top) throws IOException {
-    return null;
+    return Symbol.CONTINUE;
   }
 
   /** Have we written at least one item into the current collection? */

Modified: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/JsonGrammarGenerator.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/JsonGrammarGenerator.java?rev=899471&r1=899470&r2=899471&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/JsonGrammarGenerator.java
(original)
+++ hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/JsonGrammarGenerator.java
Thu Jan 14 23:32:24 2010
@@ -64,11 +64,13 @@
       return Symbol.seq(new Symbol.EnumLabelsAction(sc.getEnumSymbols()),
           Symbol.ENUM);
     case ARRAY:
-      return Symbol.seq(Symbol.repeat(Symbol.ARRAY_END,
+      return Symbol.seq(Symbol.ARRAY_END,
+          Symbol.repeat(Symbol.ARRAY_END,
               Symbol.ITEM_END, generate(sc.getElementType(), seen)),
           Symbol.ARRAY_START);
     case MAP:
-      return Symbol.seq(Symbol.repeat(Symbol.MAP_END,
+      return Symbol.seq(Symbol.MAP_END,
+          Symbol.repeat(Symbol.MAP_END,
               Symbol.ITEM_END, generate(sc.getValueType(), seen),
               Symbol.MAP_KEY_MARKER, Symbol.STRING),
           Symbol.MAP_START);

Modified: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/Parser.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/Parser.java?rev=899471&r1=899470&r2=899471&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/Parser.java (original)
+++ hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/Parser.java Thu Jan 14
23:32:24 2010
@@ -21,7 +21,6 @@
 import java.util.Arrays;
 
 import org.apache.avro.AvroTypeException;
-import org.apache.avro.io.parsing.Symbol.ImplicitAction;
 
 /**
  * Parser is the class that maintains the stack for parsing. This class
@@ -35,16 +34,6 @@
    * provide this help.
    */
   public interface ActionHandler {
-    /**
-     * Handle the action symbol <tt>top</tt> when the <tt>input</tt>
is
-     * sought to be taken off the stack.
-     * @param input The input symbol from the caller of advance
-     * @param top The symbol at the top the stack.
-     * @return  <tt>null</tt> if advance() is to continue processing the
-     * stack. If not <tt>null</tt> the return value will be returned
-     * by advance().
-     * @throws IOException
-     */
     Symbol doAction(Symbol input, Symbol top) throws IOException;
   }
 
@@ -80,39 +69,40 @@
   public final Symbol advance(Symbol input) throws IOException {
     for (; ;) {
       Symbol top = stack[--pos];
-      if (top == input) {
-        return top; // A common case
-      }
-
-      Symbol.Kind k = top.kind;
-      if (k == Symbol.Kind.IMPLICIT_ACTION) {
-        Symbol result = symbolHandler.doAction(input, top);
-        if (result != null) {
-          return result;
+      if (top.kind == Symbol.Kind.TERMINAL) {
+        if (top == input) {
+          return top; // A common case
+        } else {
+          throw new AvroTypeException("Attempt to process a "
+              + input + " when a "
+              + top + " was expected.");
         }
-      } else if (k == Symbol.Kind.TERMINAL) {
-        throw new AvroTypeException("Attempt to process a "
-                + input + " when a "
-                + top + " was expected.");
-      } else if (k == Symbol.Kind.REPEATER
-          && input == ((Symbol.Repeater) top).end) {
-        return input;
+      } else if (top.kind == Symbol.Kind.IMPLICIT_ACTION) {
+          Symbol result = symbolHandler.doAction(input, top);
+          if (result != Symbol.CONTINUE) {
+            return result;
+          }
       } else {
-        pushProduction(top);
+        pushProduction(input, top);
       }
     }
   }
   
   /**
-   * Performs any "trailing" implicit actions at the top the stack. 
+   * Performs any implicit actions at the top the stack, expanding any
+   * production (other than the root) that may be encountered.
+   * This method will fail if there are any repeaters on the stack.
+   * @throws IOException
    */
-  public final void processTrailingImplicitActions() throws IOException {
-    while (pos >= 1) {
+  public final void processImplicitActions() throws IOException {
+     while (pos > 1) {
       Symbol top = stack[pos - 1];
-      if (top.kind == Symbol.Kind.IMPLICIT_ACTION 
-        && ((Symbol.ImplicitAction) top).isTrailing) {
+      if (top.kind == Symbol.Kind.IMPLICIT_ACTION) {
         pos--;
         symbolHandler.doAction(null, top);
+      } else if (top.kind != Symbol.Kind.TERMINAL) {
+        pos--;
+        pushProduction(null, top);
       } else {
         break;
       }
@@ -126,13 +116,16 @@
    * @param input
    * @param sym
    */
-  public final void pushProduction(Symbol sym) {
-    Symbol[] p = sym.production;
-    while (pos + p.length > stack.length) {
-      expandStack();
+  public final void pushProduction(Symbol input, Symbol sym) {
+    if (sym.kind != Symbol.Kind.REPEATER ||
+        input != ((Symbol.Repeater) sym).end) {
+      Symbol[] p = sym.production;
+      while (pos + p.length > stack.length) {
+        expandStack();
+      }
+      System.arraycopy(p, 0, stack, pos, p.length);
+      pos += p.length;
     }
-    System.arraycopy(p, 0, stack, pos, p.length);
-    pos += p.length;
   }
 
   /**

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=899471&r1=899470&r2=899471&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
Thu Jan 14 23:32:24 2010
@@ -98,13 +98,15 @@
         break;
 
       case ARRAY:
-        return Symbol.seq(Symbol.repeat(Symbol.ARRAY_END,
+        return Symbol.seq(Symbol.ARRAY_END,
+            Symbol.repeat(Symbol.ARRAY_END,
                 generate(writer.getElementType(),
                 reader.getElementType(), seen)),
             Symbol.ARRAY_START);
       
       case MAP:
-        return Symbol.seq(Symbol.repeat(Symbol.MAP_END,
+        return Symbol.seq(Symbol.MAP_END,
+            Symbol.repeat(Symbol.MAP_END,
                 generate(writer.getValueType(),
                 reader.getValueType(), seen), Symbol.STRING),
             Symbol.MAP_START);

Modified: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/SkipParser.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/SkipParser.java?rev=899471&r1=899470&r2=899471&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/SkipParser.java (original)
+++ hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/SkipParser.java Thu Jan
14 23:32:24 2010
@@ -55,7 +55,6 @@
    * parser stack reaches the target level.
    */
   public final void skipTo(int target) throws IOException {
-    outer:
     while (target < pos) {
       Symbol top = stack[pos - 1];
       while (top.kind != Symbol.Kind.TERMINAL) {
@@ -64,9 +63,9 @@
           skipHandler.skipAction();
         } else {
           --pos;
-          pushProduction(top);
+          pushProduction(null, top);
         }
-        continue outer;
+        top = stack[pos - 1];
       }
       skipHandler.skipTopSymbol();
     }
@@ -79,7 +78,7 @@
     int target = pos;
     Symbol repeater = stack[--pos];
     assert repeater.kind == Symbol.Kind.REPEATER;
-    pushProduction(repeater);
+    pushProduction(null, repeater);
     skipTo(target);
   }
 

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=899471&r1=899470&r2=899471&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 Thu Jan 14
23:32:24 2010
@@ -143,21 +143,9 @@
     public String toString() { return printName; }
   }
 
-  public static class ImplicitAction extends Symbol {
-    /**
-     * Set to <tt>true</tt> if and only if this implicit action is 
-     * a trailing action. That is, it is an action that follows
-     * real symbol. E.g {@link Symbol#DEFAULT_END_ACTION}.
-     */
-    public final boolean isTrailing;
-
+  private static class ImplicitAction extends Symbol {
     private ImplicitAction() {
-      this(false);
-    }
-    
-    private ImplicitAction(boolean isTrailing) {
       super(Kind.IMPLICIT_ACTION);
-      this.isTrailing = isTrailing;
     }
   }
   
@@ -379,14 +367,15 @@
   public static final Symbol ITEM_END = new Symbol.Terminal("item-end");
 
   /* a pseudo terminal used by parsers */
+  public static final Symbol CONTINUE = new Symbol.Terminal("continue");
   public static final Symbol FIELD_ACTION =
     new Symbol.Terminal("field-action");
 
-  public static final Symbol RECORD_START = new ImplicitAction(false);
-  public static final Symbol RECORD_END = new ImplicitAction(true);
-  public static final Symbol UNION_END = new ImplicitAction(true);
+  public static final Symbol RECORD_START = new ImplicitAction();
+  public static final Symbol RECORD_END = new ImplicitAction();
+  public static final Symbol UNION_END = new ImplicitAction();
   
-  public static final Symbol DEFAULT_END_ACTION = new ImplicitAction(true);
+  public static final Symbol DEFAULT_END_ACTION = new ImplicitAction();
   public static final Symbol MAP_KEY_MARKER =
     new Symbol.Terminal("map-key-marker");
 }

Modified: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/ValidatingGrammarGenerator.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/ValidatingGrammarGenerator.java?rev=899471&r1=899470&r2=899471&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/ValidatingGrammarGenerator.java
(original)
+++ hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/ValidatingGrammarGenerator.java
Thu Jan 14 23:32:24 2010
@@ -71,10 +71,12 @@
       return Symbol.seq(new Symbol.IntCheckAction(sc.getEnumSymbols().size()),
           Symbol.ENUM);
     case ARRAY:
-      return Symbol.seq(Symbol.repeat(Symbol.ARRAY_END, generate(sc.getElementType(), seen)),
+      return Symbol.seq(Symbol.ARRAY_END,
+          Symbol.repeat(Symbol.ARRAY_END, generate(sc.getElementType(), seen)),
           Symbol.ARRAY_START);
     case MAP:
-      return Symbol.seq(Symbol.repeat(Symbol.MAP_END,
+      return Symbol.seq(Symbol.MAP_END,
+          Symbol.repeat(Symbol.MAP_END,
               generate(sc.getValueType(), seen), Symbol.STRING),
           Symbol.MAP_START);
     case RECORD: {

Propchange: hadoop/avro/trunk/lang/java/src/java/org/apache/avro/io/parsing/doc-files/
            ('svn:mergeinfo' removed)

Modified: hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/Perf.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/Perf.java?rev=899471&r1=899470&r2=899471&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/Perf.java (original)
+++ hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/Perf.java Thu Jan 14 23:32:24
2010
@@ -20,13 +20,8 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
 import java.util.Random;
 
-import junit.extensions.RepeatedTest;
-
 import org.apache.avro.Schema;
 
 /**
@@ -39,45 +34,39 @@
   
   
   public static void main(String[] args) throws IOException {
-    List<Test> tests = new ArrayList<Test>();
-    for (String arg : args) {
-      if (arg.equals("-i")) {
-        tests.add(new ReadInt());
-      } else if (arg.equals("-f")) {
-        tests.add(new ReadFloat());
-      } else if (arg.equals("-d")) {
-        tests.add(new ReadDouble());
-      } else if (arg.equals("-l")) {
-        tests.add(new ReadLong());
-      } else if (arg.equals("-R")) {
-        tests.add(new RepeaterTest());
-      } else {
-        usage();
-      }
-    }
-    if (tests.isEmpty()) {
-      tests.addAll(Arrays.asList(new Test[] {
-         new ReadInt(), new ReadLong(), new ReadFloat(), new ReadDouble(),
-         new RepeaterTest(),
-      }));
+    Test[] tests = null;
+    if (args.length == 0) {
+      tests = new Test[] { new ReadInt(),
+          new ReadLong(), new ReadFloat(), new ReadDouble() };
+    } else if (args.length == 1) {
+      if (args[0].equals("-i")) {
+        tests = new Test[] { new ReadInt() };
+      } else if (args[0].equals("-f")) {
+        tests = new Test[] { new ReadFloat() };
+      } else if (args[0].equals("-d")) {
+        tests = new Test[] { new ReadDouble() };
+      } else if (args[0].equals("-l")) {
+        tests = new Test[] { new ReadLong() };
+      }
+    } else {
+      usage();
+      System.exit(1);
     }
     
     for (Test t : tests) {
-      // warmup JVM
-      // System.out.println("Warming up...");
+      // warmup JVM 
       for (int i = 0; i < CYCLES; i++) {
-        t.test();
+        t.read();
       }
       // test
       long s = 0;
       for (int i = 0; i < CYCLES; i++) {
-        long l = t.test();
+        long l = t.read();
         // System.out.println("** " + l);
         s += l;
       }
-      s /= 1000;
-      System.out.println(t.name + "(" + t.schema + "): " + s/1000 + " ms, "
-          +  ((CYCLES * (double)COUNT) / s) + " million numbers decoded/sec" );
+       s /= 1000;
+      System.out.println(t.name + "(" + t.schema + "): " + s/1000 + " ms, " +  (CYCLES *
(double)COUNT)/s + " million numbers decoded /sec" );
     }
   }
   
@@ -85,7 +74,6 @@
     public final String name;
     public final Schema schema;
     protected byte[] data;
-    
     public Test(String name, String json) throws IOException {
       this.name = name;
       this.schema = Schema.parse(json);
@@ -94,9 +82,8 @@
       genData(e);
       data = bao.toByteArray();
     }
-    
-    public final long test() throws IOException {
-      Decoder d = getDecoder();
+    public final long read() throws IOException {
+      Decoder d = new BinaryDecoder(new ByteArrayInputStream(data));
       long t = System.nanoTime();
       for (long l = d.readArrayStart(); l > 0; l = d.arrayNext()) {
         for (int j = 0; j < l; j++) {
@@ -105,22 +92,13 @@
       }
       return (System.nanoTime() - t);
     }
-
-    protected Decoder getDecoder() throws IOException {
-      return new BinaryDecoder(new ByteArrayInputStream(data));
-    }
-
     abstract void genData(Encoder e) throws IOException;
     abstract void readInternal(Decoder d) throws IOException;
   }
   
   private static class ReadInt extends Test {
     public ReadInt() throws IOException {
-      this("ReadInt", "{ \"type\": \"array\", \"items\": \"int\"} ");
-    }
-
-    public ReadInt(String name, String json) throws IOException {
-      super(name, json);
+      super("ReadInt", "{ \"type\": \"array\", \"items\": \"int\"} ");
     }
     @Override void genData(Encoder e) throws IOException {
       e.writeArrayStart();
@@ -201,26 +179,11 @@
       d.readDouble();
     }
   }
-  
-  private static class RepeaterTest extends ReadInt {
-      public RepeaterTest() throws IOException {
-        super("RepeaterTest",
-            "{ \"type\": \"array\", \"items\": \"int\"} ");
-      }
-
-      @Override
-      public Decoder getDecoder() throws IOException {
-        return new ValidatingDecoder(schema, super.getDecoder());
-      }
-    }
-
   private static void usage() {
     System.out.println("Usage: Perf { -i | -l | -f | -d }");
     System.out.println("    -i      measures readInt() performance");
     System.out.println("    -l      measures readLong() performance");
     System.out.println("    -f      measures readFloat() performance");
     System.out.println("    -d      measures readDouble() performance");
-    System.out.println("    -R      measures repeater performance in "
-        + "validating encoder");
   }
 }

Propchange: hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/TestBinaryDecoder.java
            ('svn:mergeinfo' removed)

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=899471&r1=899470&r2=899471&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
Thu Jan 14 23:32:24 2010
@@ -95,13 +95,6 @@
           "{\"type\":\"record\",\"name\":\"r\",\"fields\":["
           + "{\"name\":\"f\", \"type\":\"int\", \"default\": 100}]}", "I",
           new Object[] { 100 } },
-        // default string value
-        { "{\"type\":\"record\",\"name\":\"r\",\"fields\":[]}", "",
-            new Object[] { },
-            "{\"type\":\"record\",\"name\":\"r\",\"fields\":["
-            + "{\"name\":\"f\", \"type\":\"string\", \"default\": \"hello\"}]}",
-            "S50",
-            new Object[] { "hello" } },
         { "{\"type\":\"record\",\"name\":\"r\",\"fields\":["
             + "{\"name\":\"f2\", \"type\":\"int\"}]}", "I",
           new Object[] { 10 },
@@ -110,36 +103,18 @@
           + "{\"name\":\"f2\", \"type\":\"int\"}]}", "II",
           new Object[] { 10, 101 } },
         { "{\"type\":\"record\",\"name\":\"outer\",\"fields\":["
-            + "{\"name\": \"g1\", "
-            + "\"type\":{\"type\":\"record\",\"name\":\"inner\",\"fields\":["
-            + "{\"name\":\"f2\", \"type\":\"int\"}]}}, "
+            + "{\"name\": \"g1\", " +
+                        "\"type\":{\"type\":\"record\",\"name\":\"inner\",\"fields\":["
+                + "{\"name\":\"f2\", \"type\":\"int\"}]}}, "
             + "{\"name\": \"g2\", \"type\": \"long\"}]}", "IL",
           new Object[] { 10, 11L },
           "{\"type\":\"record\",\"name\":\"outer\",\"fields\":["
-            + "{\"name\": \"g1\", "
-            + "\"type\":{\"type\":\"record\",\"name\":\"inner\",\"fields\":["
-            + "{\"name\":\"f1\", \"type\":\"int\", \"default\": 101},"
-            + "{\"name\":\"f2\", \"type\":\"int\"}]}}, "
+            + "{\"name\": \"g1\", " +
+                        "\"type\":{\"type\":\"record\",\"name\":\"inner\",\"fields\":["
+                + "{\"name\":\"f1\", \"type\":\"int\", \"default\": 101},"
+                + "{\"name\":\"f2\", \"type\":\"int\"}]}}, "
           + "{\"name\": \"g2\", \"type\": \"long\"}]}}", "IIL",
           new Object[] { 10, 101, 11L } },
-        // Default + array
-        { "{\"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 } },
-        // Default + map
-        { "{\"type\": \"map\", \"values\":" +
-            "{\"type\":\"record\",\"name\":\"r\",\"fields\":[]}}", "{c1sS10}",
-          new Object[] { "key" },
-          "{\"type\": \"map\", \"values\":"
-            + "{\"type\":\"record\",\"name\":\"r\",\"fields\":["
-            + "{\"name\":\"f\", \"type\":\"int\", \"default\": 100}]}}",
-          "{c1sS10I}",
-          new Object[] { "key", 100 } },
     };
   }
 }

Propchange: hadoop/avro/trunk/lang/java/src/test/java/org/apache/avro/io/TestResolvingIOResolving.java
            ('svn:mergeinfo' removed)

Propchange: hadoop/avro/trunk/share/test/schemas/interop.avsc
            ('svn:mergeinfo' removed)

Propchange: hadoop/avro/trunk/share/test/schemas/simple.avpr
            ('svn:mergeinfo' removed)



Mime
View raw message