avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r982065 - in /avro/trunk: CHANGES.txt lang/java/src/java/org/apache/avro/generic/GenericDatumReader.java lang/java/src/java/org/apache/avro/io/DatumReader.java lang/java/src/java/org/apache/avro/specific/SpecificDatumReader.java
Date Tue, 03 Aug 2010 23:20:35 GMT
Author: cutting
Date: Tue Aug  3 23:20:35 2010
New Revision: 982065

URL: http://svn.apache.org/viewvc?rev=982065&view=rev
Log:
AVRO-603. Java: Add a constructor for SpecificDatumReader that accepts both reader's and writer's
schemas.  Also improve related javadoc.  Contributed by Stu Hood.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/src/java/org/apache/avro/generic/GenericDatumReader.java
    avro/trunk/lang/java/src/java/org/apache/avro/io/DatumReader.java
    avro/trunk/lang/java/src/java/org/apache/avro/specific/SpecificDatumReader.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=982065&r1=982064&r2=982065&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Tue Aug  3 23:20:35 2010
@@ -88,6 +88,10 @@ Avro 1.4.0 (unreleased)
     AVRO-583. Java: Improve error message when types not correctly
     nested. (cutting)
 
+    AVRO-603. Java: Add a constructor for SpecificDatumReader that
+    accepts both reader's and writer's schema.  Also improve javadoc
+    for related constructors and setters.  (Stu Hood via cutting)
+
   BUG FIXES
 
     AVRO-502. Memory leak from parsing JSON schema.

Modified: avro/trunk/lang/java/src/java/org/apache/avro/generic/GenericDatumReader.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/java/org/apache/avro/generic/GenericDatumReader.java?rev=982065&r1=982064&r2=982065&view=diff
==============================================================================
--- avro/trunk/lang/java/src/java/org/apache/avro/generic/GenericDatumReader.java (original)
+++ avro/trunk/lang/java/src/java/org/apache/avro/generic/GenericDatumReader.java Tue Aug
 3 23:20:35 2010
@@ -38,28 +38,30 @@ public class GenericDatumReader<D> imple
 
   public GenericDatumReader() {}
 
-  public GenericDatumReader(Schema actual) {
-    this.actual = actual;
-    this.expected = actual;
+  /** Construct where the writer's and reader's schemas are the same. */
+  public GenericDatumReader(Schema schema) {
+    this.actual = schema;
+    this.expected = schema;
   }
 
-  public GenericDatumReader(Schema actual, Schema expected)
-    throws IOException {
-    this.actual = actual;
-    this.expected = expected;
+  /** Construct given writer's and reader's schema. */
+  public GenericDatumReader(Schema writer, Schema reader) {
+    this.actual = writer;
+    this.expected = reader;
   }
 
   @Override
-  public void setSchema(Schema actual) {
-    this.actual = actual;
+  public void setSchema(Schema writer) {
+    this.actual = writer;
     if (expected == null) {
       expected = actual;
     }
     resolver = null;
   }
 
-  public void setExpected(Schema expected) throws IOException {
-    this.expected = expected;
+  /** Set the reader's schema. */
+  public void setExpected(Schema reader) throws IOException {
+    this.expected = reader;
   }
 
   @SuppressWarnings("unchecked")

Modified: avro/trunk/lang/java/src/java/org/apache/avro/io/DatumReader.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/java/org/apache/avro/io/DatumReader.java?rev=982065&r1=982064&r2=982065&view=diff
==============================================================================
--- avro/trunk/lang/java/src/java/org/apache/avro/io/DatumReader.java (original)
+++ avro/trunk/lang/java/src/java/org/apache/avro/io/DatumReader.java Tue Aug  3 23:20:35
2010
@@ -26,7 +26,7 @@ import org.apache.avro.Schema;
  */
 public interface DatumReader<D> {
 
-  /** Set the schema. */
+  /** Set the writer's schema. */
   void setSchema(Schema schema);
 
   /** Read a datum.  Traverse the schema, depth-first, reading all leaf values

Modified: avro/trunk/lang/java/src/java/org/apache/avro/specific/SpecificDatumReader.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/java/org/apache/avro/specific/SpecificDatumReader.java?rev=982065&r1=982064&r2=982065&view=diff
==============================================================================
--- avro/trunk/lang/java/src/java/org/apache/avro/specific/SpecificDatumReader.java (original)
+++ avro/trunk/lang/java/src/java/org/apache/avro/specific/SpecificDatumReader.java Tue Aug
 3 23:20:35 2010
@@ -32,10 +32,16 @@ public class SpecificDatumReader<T> exte
     this(SpecificData.get().getSchema(c));
   }
 
+  /** Construct where the writer's and reader's schemas are the same. */
   public SpecificDatumReader(Schema schema) {
     super(schema);
   }
 
+  /** Construct given writer's and reader's schema. */
+  public SpecificDatumReader(Schema writer, Schema reader) {
+    super(writer, reader);
+  }
+
   @Override
   protected Object newRecord(Object old, Schema schema) {
     Class c = SpecificData.get().getClass(schema);



Mime
View raw message