avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1444297 - in /avro/trunk: ./ lang/java/avro/src/main/java/org/apache/avro/io/parsing/
Date Sat, 09 Feb 2013 00:22:05 GMT
Author: cutting
Date: Sat Feb  9 00:22:05 2013
New Revision: 1444297

URL: http://svn.apache.org/r1444297
Log:
AVRO-1220. Java: Fix a deadlock when reading by replacing parser symbol constructors with
factory methods.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/JsonGrammarGenerator.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ResolvingGrammarGenerator.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/Symbol.java
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ValidatingGrammarGenerator.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1444297&r1=1444296&r2=1444297&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Sat Feb  9 00:22:05 2013
@@ -49,6 +49,9 @@ Trunk (not yet released)
     AVRO-1242. Java: Fix AvroTrevniOutputFormat to correctly get file
     metadata from JobConf. (Ted Malaska via cutting)
 
+    AVRO-1220. Java: Fix a deadlock when reading by replacing parser
+    symbol constructors with factory methods. (cutting)
+
 Avro 1.7.3 (6 December 2012)
 
   NEW FEATURES

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/JsonGrammarGenerator.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/JsonGrammarGenerator.java?rev=1444297&r1=1444296&r2=1444297&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/JsonGrammarGenerator.java
(original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/JsonGrammarGenerator.java
Sat Feb  9 00:22:05 2013
@@ -61,7 +61,7 @@ public class JsonGrammarGenerator extend
     case UNION:
       return super.generate(sc, seen);
     case ENUM:
-      return Symbol.seq(new Symbol.EnumLabelsAction(sc.getEnumSymbols()),
+      return Symbol.seq(Symbol.enumLabelsAction(sc.getEnumSymbols()),
           Symbol.ENUM);
     case ARRAY:
       return Symbol.seq(Symbol.repeat(Symbol.ARRAY_END,
@@ -84,7 +84,7 @@ public class JsonGrammarGenerator extend
         int n = 0;
         production[--i] = Symbol.RECORD_START;
         for (Field f : sc.getFields()) {
-          production[--i] = new Symbol.FieldAdjustAction(n, f.name());
+          production[--i] = Symbol.fieldAdjustAction(n, f.name());
           production[--i] = generate(f.schema(), seen);
           production[--i] = Symbol.FIELD_END;
           n++;

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ResolvingGrammarGenerator.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ResolvingGrammarGenerator.java?rev=1444297&r1=1444296&r2=1444297&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ResolvingGrammarGenerator.java
(original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ResolvingGrammarGenerator.java
Sat Feb  9 00:22:05 2013
@@ -90,7 +90,7 @@ public class ResolvingGrammarGenerator e
       case FIXED:
         if (writer.getFullName().equals(reader.getFullName())
             && writer.getFixedSize() == reader.getFixedSize()) {
-          return Symbol.seq(new Symbol.IntCheckAction(writer.getFixedSize()),
+          return Symbol.seq(Symbol.intCheckAction(writer.getFixedSize()),
               Symbol.FIXED);
         }
         break;
@@ -155,7 +155,7 @@ public class ResolvingGrammarGenerator e
         int j = bestBranch(reader, writer);
         if (j >= 0) {
           Symbol s = generate(writer, reader.getTypes().get(j), seen);
-          return Symbol.seq(new Symbol.UnionAdjustAction(j, s), Symbol.UNION);
+          return Symbol.seq(Symbol.unionAdjustAction(j, s), Symbol.UNION);
         }
         break;
       case NULL:
@@ -194,7 +194,7 @@ public class ResolvingGrammarGenerator e
       i++;
     }
     return Symbol.seq(Symbol.alt(symbols, labels),
-        new Symbol.WriterUnionAction());
+                      Symbol.writerUnionAction());
   }
 
   private Symbol resolveRecords(Schema writer, Schema reader,
@@ -234,7 +234,7 @@ public class ResolvingGrammarGenerator e
       }
 
       Symbol[] production = new Symbol[count];
-      production[--count] = new Symbol.FieldOrderAction(reordered);
+      production[--count] = Symbol.fieldOrderAction(reordered);
 
       /**
        * We construct a symbol without filling the array. Please see
@@ -256,7 +256,7 @@ public class ResolvingGrammarGenerator e
         Field rf = reader.getField(fname);
         if (rf == null) {
           production[--count] =
-            new Symbol.SkipAction(generate(wf.schema(), wf.schema(), seen));
+            Symbol.skipAction(generate(wf.schema(), wf.schema(), seen));
         } else {
           production[--count] =
             generate(wf.schema(), rf.schema(), seen);
@@ -269,7 +269,7 @@ public class ResolvingGrammarGenerator e
         Field wf = writer.getField(fname);
         if (wf == null) {
           byte[] bb = getBinary(rf.schema(), rf.defaultValue());
-          production[--count] = new Symbol.DefaultStartAction(bb);
+          production[--count] = Symbol.defaultStartAction(bb);
           production[--count] = generate(rf.schema(), rf.schema(), seen);
           production[--count] = Symbol.DEFAULT_END_ACTION;
         }
@@ -409,7 +409,7 @@ public class ResolvingGrammarGenerator e
       adjustments[i] = (j == -1 ? "No match for " + wsymbols.get(i)
                                 : new Integer(j));
     }
-    return new Symbol.EnumAdjustAction(rsymbols.size(), adjustments);
+    return Symbol.enumAdjustAction(rsymbols.size(), adjustments);
   }
 
   private static int bestBranch(Schema r, Schema w) {

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/Symbol.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/Symbol.java?rev=1444297&r1=1444296&r2=1444297&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/Symbol.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/Symbol.java Sat Feb
 9 00:22:05 2013
@@ -401,23 +401,36 @@ public abstract class Symbol {
     }
   }
 
+  public static IntCheckAction intCheckAction(int size) {
+    return new IntCheckAction(size);
+  }
+
   public static class IntCheckAction extends Symbol {
     public final int size;
-    public IntCheckAction(int size) {
+    @Deprecated public IntCheckAction(int size) {
       super(Kind.EXPLICIT_ACTION);
       this.size = size;
     }
   }
 
+  public static EnumAdjustAction enumAdjustAction(int rsymCount, Object[] adj) {
+    return new EnumAdjustAction(rsymCount, adj);
+  }
+  
   public static class EnumAdjustAction extends IntCheckAction {
     public final Object[] adjustments;
-    public EnumAdjustAction(int rsymCount, Object[] adjustments) {
+    @Deprecated public EnumAdjustAction(int rsymCount, Object[] adjustments) {
       super(rsymCount);
       this.adjustments = adjustments;
     }
   }
 
+  public static WriterUnionAction writerUnionAction() {
+    return new WriterUnionAction();
+  }
+
   public static class WriterUnionAction extends ImplicitAction {
+    private WriterUnionAction() {}
   }
 
   public static class ResolvingAction extends ImplicitAction {
@@ -437,9 +450,13 @@ public abstract class Symbol {
 
   }
   
+  public static SkipAction skipAction(Symbol symToSkip) {
+    return new SkipAction(symToSkip);
+  }
+
   public static class SkipAction extends ImplicitAction {
     public final Symbol symToSkip;
-    public SkipAction(Symbol symToSkip) {
+    @Deprecated public SkipAction(Symbol symToSkip) {
       super(true);
       this.symToSkip = symToSkip;
     }
@@ -452,33 +469,49 @@ public abstract class Symbol {
 
   }
 
+  public static FieldAdjustAction fieldAdjustAction(int rindex, String fname) {
+    return new FieldAdjustAction(rindex, fname);
+  }
+  
   public static class FieldAdjustAction extends ImplicitAction {
     public final int rindex;
     public final String fname;
-    public FieldAdjustAction(int rindex, String fname) {
+    @Deprecated public FieldAdjustAction(int rindex, String fname) {
       this.rindex = rindex;
       this.fname = fname;
     }
   }
   
+  public static FieldOrderAction fieldOrderAction(Schema.Field[] fields) {
+    return new FieldOrderAction(fields);
+  }
+
   public static final class FieldOrderAction extends ImplicitAction {
     public final Schema.Field[] fields;
-    public FieldOrderAction(Schema.Field[] fields) {
+    @Deprecated public FieldOrderAction(Schema.Field[] fields) {
       this.fields = fields;
     }
   }
 
+  public static DefaultStartAction defaultStartAction(byte[] contents) {
+    return new DefaultStartAction(contents);
+  }
+
   public static class DefaultStartAction extends ImplicitAction {
     public final byte[] contents;
-    public DefaultStartAction(byte[] contents) {
+    @Deprecated public DefaultStartAction(byte[] contents) {
       this.contents = contents;
     }
   }
 
+  public static UnionAdjustAction unionAdjustAction(int rindex, Symbol sym) {
+    return new UnionAdjustAction(rindex, sym);
+  }
+
   public static class UnionAdjustAction extends ImplicitAction {
     public final int rindex;
     public final Symbol symToParse;
-    public UnionAdjustAction(int rindex, Symbol symToParse) {
+    @Deprecated public UnionAdjustAction(int rindex, Symbol symToParse) {
       this.rindex = rindex;
       this.symToParse = symToParse;
     }
@@ -492,9 +525,13 @@ public abstract class Symbol {
   }
 
   /** For JSON. */
+  public static EnumLabelsAction enumLabelsAction(List<String> symbols) {
+    return new EnumLabelsAction(symbols);
+  }
+
   public static class EnumLabelsAction extends IntCheckAction {
     public final List<String> symbols;
-    public EnumLabelsAction(List<String> symbols) {
+    @Deprecated public EnumLabelsAction(List<String> symbols) {
       super(symbols.size());
       this.symbols = symbols;
     }

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ValidatingGrammarGenerator.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ValidatingGrammarGenerator.java?rev=1444297&r1=1444296&r2=1444297&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ValidatingGrammarGenerator.java
(original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/io/parsing/ValidatingGrammarGenerator.java
Sat Feb  9 00:22:05 2013
@@ -65,10 +65,10 @@ public class ValidatingGrammarGenerator 
     case BYTES:
       return Symbol.BYTES;
     case FIXED:
-      return Symbol.seq(new Symbol.IntCheckAction(sc.getFixedSize()),
+      return Symbol.seq(Symbol.intCheckAction(sc.getFixedSize()),
           Symbol.FIXED);
     case ENUM:
-      return Symbol.seq(new Symbol.IntCheckAction(sc.getEnumSymbols().size()),
+      return Symbol.seq(Symbol.intCheckAction(sc.getEnumSymbols().size()),
           Symbol.ENUM);
     case ARRAY:
       return Symbol.seq(Symbol.repeat(Symbol.ARRAY_END, generate(sc.getElementType(), seen)),



Mime
View raw message