avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r787823 - in /hadoop/avro/trunk: CHANGES.txt src/doc/content/xdocs/spec.xml src/java/org/apache/avro/generic/GenericDatumReader.java src/test/java/org/apache/avro/TestSchema.java
Date Tue, 23 Jun 2009 20:29:29 GMT
Author: cutting
Date: Tue Jun 23 20:29:29 2009
New Revision: 787823

URL: http://svn.apache.org/viewvc?rev=787823&view=rev
Log:
AVRO-36. Correctly encode and decode binary default values.

Modified:
    hadoop/avro/trunk/CHANGES.txt
    hadoop/avro/trunk/src/doc/content/xdocs/spec.xml
    hadoop/avro/trunk/src/java/org/apache/avro/generic/GenericDatumReader.java
    hadoop/avro/trunk/src/test/java/org/apache/avro/TestSchema.java

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=787823&r1=787822&r2=787823&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Tue Jun 23 20:29:29 2009
@@ -67,6 +67,9 @@
 
     AVRO-56. Use Jackson to generate JSON from Java.  (cutting)
 
+    AVRO-36. Correctly encode and decode binary default values.
+    (cutting)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/avro/trunk/src/doc/content/xdocs/spec.xml
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/doc/content/xdocs/spec.xml?rev=787823&r1=787822&r2=787823&view=diff
==============================================================================
--- hadoop/avro/trunk/src/doc/content/xdocs/spec.xml (original)
+++ hadoop/avro/trunk/src/doc/content/xdocs/spec.xml Tue Jun 23 20:29:29 2009
@@ -113,7 +113,7 @@
 		    <caption>field default values</caption>
 		    <tr><th>avro type</th><th>json type</th><th>example</th></tr>
 		    <tr><td>string</td><td>string</td><td>"foo"</td></tr>
-		    <tr><td>bytes</td><td>base64</td><td>"YQo="</td></tr>
+		    <tr><td>bytes</td><td>string</td><td>"\u00FF"</td></tr>
 		    <tr><td>int,long</td><td>integer</td><td>1</td></tr>
 		    <tr><td>float,double</td><td>number</td><td>1.1</td></tr>
 		    <tr><td>boolean</td><td>boolean</td><td>true</td></tr>

Modified: hadoop/avro/trunk/src/java/org/apache/avro/generic/GenericDatumReader.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/java/org/apache/avro/generic/GenericDatumReader.java?rev=787823&r1=787822&r2=787823&view=diff
==============================================================================
--- hadoop/avro/trunk/src/java/org/apache/avro/generic/GenericDatumReader.java (original)
+++ hadoop/avro/trunk/src/java/org/apache/avro/generic/GenericDatumReader.java Tue Jun 23
20:29:29 2009
@@ -192,7 +192,8 @@
   
   /** Called by the default implementation of {@link #readRecord} to construct
       a default value for a field. */
-  protected Object defaultFieldValue(Object old, Schema schema, JsonNode json) {
+  protected Object defaultFieldValue(Object old, Schema schema, JsonNode json)
+    throws IOException {
     switch (schema.getType()) {
     case RECORD:
       Object record = newRecord(old, schema);
@@ -229,7 +230,7 @@
     case UNION:   return defaultFieldValue(old, schema.getTypes().get(0), json);
     case FIXED:   return createFixed(old,json.getTextValue().getBytes(),schema);
     case STRING:  return createString(json.getTextValue());
-    case BYTES:   return createBytes(json.getTextValue().getBytes());
+    case BYTES:  return createBytes(json.getTextValue().getBytes("ISO-8859-1"));
     case INT:     return json.getIntValue();
     case LONG:    return json.getLongValue();
     case FLOAT:   return (float)json.getDoubleValue();

Modified: hadoop/avro/trunk/src/test/java/org/apache/avro/TestSchema.java
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/test/java/org/apache/avro/TestSchema.java?rev=787823&r1=787822&r2=787823&view=diff
==============================================================================
--- hadoop/avro/trunk/src/test/java/org/apache/avro/TestSchema.java (original)
+++ hadoop/avro/trunk/src/test/java/org/apache/avro/TestSchema.java Tue Jun 23 20:29:29 2009
@@ -59,7 +59,8 @@
 
   @Test
   public void testBytes() throws Exception {
-    check("\"bytes\"", "\"\"", ByteBuffer.allocate(0));
+    check("\"bytes\"", "\"\\u0000ABC\\u00FF\"",
+          ByteBuffer.wrap(new byte[]{0,65,66,67,-1}));
   }
 
   @Test



Mime
View raw message