You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by cu...@apache.org on 2011/07/28 21:53:44 UTC

svn commit: r1151988 - in /avro/branches/branch-1.5: ./ lang/java/ lang/java/avro/src/main/java/org/apache/avro/file/ lang/java/avro/src/main/java/org/apache/avro/reflect/ lang/java/mapred/src/test/java/org/apache/avro/mapred/ lang/py/

Author: cutting
Date: Thu Jul 28 19:53:43 2011
New Revision: 1151988

URL: http://svn.apache.org/viewvc?rev=1151988&view=rev
Log:
Merge AVRO-833, AVRO-856, AVRO-845 and AVRO-864 to 1.5 branch.

Added:
    avro/branches/branch-1.5/lang/java/mapred/src/test/java/org/apache/avro/mapred/TestGenericJob.java
      - copied unchanged from r1151660, avro/trunk/lang/java/mapred/src/test/java/org/apache/avro/mapred/TestGenericJob.java
Modified:
    avro/branches/branch-1.5/   (props changed)
    avro/branches/branch-1.5/CHANGES.txt
    avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/file/SnappyCodec.java
    avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
    avro/branches/branch-1.5/lang/java/pom.xml
    avro/branches/branch-1.5/lang/py/setup.py

Propchange: avro/branches/branch-1.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul 28 19:53:43 2011
@@ -1 +1 @@
-/avro/trunk:1075938,1075993,1078917,1079055,1079060,1079063,1079680,1083246,1085921,1086727,1086730,1086866,1087076,1087129,1087136,1087439-1087440,1087463,1087472,1087792,1089128,1089131,1089550,1094812,1095206-1095208,1095493,1095529,1095548,1095550,1096798,1097916,1097927,1097968,1097974,1099257,1102332,1102335,1124127,1124971,1129053,1129071,1129697-1129706,1129729,1130503,1136342,1141677,1141685,1141979-1141980,1142057,1142063
+/avro/trunk:1075938,1075993,1078917,1079055,1079060,1079063,1079680,1083246,1085921,1086727,1086730,1086866,1087076,1087129,1087136,1087439-1087440,1087463,1087472,1087792,1089128,1089131,1089550,1094812,1095206-1095208,1095493,1095529,1095548,1095550,1096798,1097916,1097927,1097968,1097974,1099257,1102332,1102335,1124127,1124971,1129053,1129071,1129697-1129706,1129729,1129856,1130503,1136342,1141619,1141677,1141685,1141979-1141980,1142057,1142063,1151660,1151983

Modified: avro/branches/branch-1.5/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.5/CHANGES.txt?rev=1151988&r1=1151987&r2=1151988&view=diff
==============================================================================
--- avro/branches/branch-1.5/CHANGES.txt (original)
+++ avro/branches/branch-1.5/CHANGES.txt Thu Jul 28 19:53:43 2011
@@ -32,6 +32,14 @@ Avro 1.5.2 (4 July 2011)
 
     AVRO-810: C#: Add strong naming to assemblies. (Eric Hauser)
 
+    AVRO-833. Python: Don't require simplejson for python >= 2.6.
+    (Miki Tebeka via philz)
+
+    AVRO-845. Python: setup.py uses Python2.7+ specific code
+    (Miki Tebeka via philz)
+
+    AVRO-856. Java: Update Snappy to 1.0.3-rc4. (cutting)
+
   BUG FIXES
 
     AVRO-818. C: Fix data file corruption bug in C library (dcreager)
@@ -55,6 +63,9 @@ Avro 1.5.2 (4 July 2011)
 
     AVRO-825: C++: Fix bugs in codegen with recursive schemas. (thiru)
 
+    AVRO-864. Java: Fix reflect to be able to write unions containing
+    generic and/or specific records.  (Isabel Drost & cutting)
+
 Avro 1.5.1 (3 May 2011)
 
   NEW FEATURES

Modified: avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/file/SnappyCodec.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/file/SnappyCodec.java?rev=1151988&r1=1151987&r2=1151988&view=diff
==============================================================================
--- avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/file/SnappyCodec.java (original)
+++ avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/file/SnappyCodec.java Thu Jul 28 19:53:43 2011
@@ -22,7 +22,6 @@ import java.nio.ByteBuffer;
 import java.util.zip.CRC32;
 
 import org.xerial.snappy.Snappy;
-import org.xerial.snappy.SnappyException;
 
 /** * Implements Snappy compression and decompression. */
 class SnappyCodec extends Codec {
@@ -41,41 +40,33 @@ class SnappyCodec extends Codec {
 
   @Override
   ByteBuffer compress(ByteBuffer in) throws IOException {
-    try { 
-      ByteBuffer out =
-        ByteBuffer.allocate(Snappy.maxCompressedLength(in.remaining())+4);
-      int size = Snappy.compress(in.array(), in.position(), in.remaining(),
-                                 out.array(), 0);
-      crc32.reset();
-      crc32.update(in.array(), in.position(), in.remaining());
-      out.putInt(size, (int)crc32.getValue());
-
-      out.limit(size+4);
-
-      return out;
-    } catch (SnappyException e) {
-      throw new IOException(e);
-    }
+    ByteBuffer out =
+      ByteBuffer.allocate(Snappy.maxCompressedLength(in.remaining())+4);
+    int size = Snappy.compress(in.array(), in.position(), in.remaining(),
+                               out.array(), 0);
+    crc32.reset();
+    crc32.update(in.array(), in.position(), in.remaining());
+    out.putInt(size, (int)crc32.getValue());
+
+    out.limit(size+4);
+
+    return out;
   }
 
   @Override
   ByteBuffer decompress(ByteBuffer in) throws IOException {
-    try { 
-      ByteBuffer out = ByteBuffer.allocate
-        (Snappy.uncompressedLength(in.array(),in.position(),in.remaining()-4));
-      int size = Snappy.uncompress(in.array(),in.position(),in.remaining()-4,
-                                   out.array(), 0);
-      out.limit(size);
-
-      crc32.reset();
-      crc32.update(out.array(), 0, size);
-      if (in.getInt(in.limit()-4) != (int)crc32.getValue())
-        throw new IOException("Checksum failure");
-
-      return out;
-    } catch (SnappyException e) {
-      throw new IOException(e);
-    }
+    ByteBuffer out = ByteBuffer.allocate
+      (Snappy.uncompressedLength(in.array(),in.position(),in.remaining()-4));
+    int size = Snappy.uncompress(in.array(),in.position(),in.remaining()-4,
+                                 out.array(), 0);
+    out.limit(size);
+    
+    crc32.reset();
+    crc32.update(out.array(), 0, size);
+    if (in.getInt(in.limit()-4) != (int)crc32.getValue())
+      throw new IOException("Checksum failure");
+    
+    return out;
   }
   
   @Override public int hashCode() { return getName().hashCode(); }

Modified: avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java?rev=1151988&r1=1151987&r2=1151988&view=diff
==============================================================================
--- avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java (original)
+++ avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java Thu Jul 28 19:53:43 2011
@@ -41,6 +41,7 @@ import org.apache.avro.Schema;
 import org.apache.avro.Protocol.Message;
 import org.apache.avro.generic.IndexedRecord;
 import org.apache.avro.generic.GenericFixed;
+import org.apache.avro.generic.GenericContainer;
 import org.apache.avro.specific.SpecificData;
 import org.apache.avro.specific.FixedSize;
 import org.apache.avro.io.BinaryData;
@@ -101,6 +102,7 @@ public class ReflectData extends Specifi
   @Override
   protected boolean isRecord(Object datum) {
     if (datum == null) return false;
+    if (super.isRecord(datum)) return true;
     return getSchema(datum.getClass()).getType() == Schema.Type.RECORD;
   }
 
@@ -120,6 +122,8 @@ public class ReflectData extends Specifi
 
   @Override
   protected Schema getRecordSchema(Object record) {
+    if (record instanceof GenericContainer)
+      return super.getRecordSchema(record);
     return getSchema(record.getClass());
   }
 

Modified: avro/branches/branch-1.5/lang/java/pom.xml
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.5/lang/java/pom.xml?rev=1151988&r1=1151987&r2=1151988&view=diff
==============================================================================
--- avro/branches/branch-1.5/lang/java/pom.xml (original)
+++ avro/branches/branch-1.5/lang/java/pom.xml Thu Jul 28 19:53:43 2011
@@ -45,7 +45,7 @@
     <jetty-version>6.1.26</jetty-version>
     <netty-version>3.2.4.Final</netty-version> 
     <jopt-simple-version>3.2</jopt-simple-version>
-    <snappy-version>1.0.1-rc3</snappy-version>
+    <snappy-version>1.0.3-rc4</snappy-version>
   </properties>
 
   <issueManagement>

Modified: avro/branches/branch-1.5/lang/py/setup.py
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.5/lang/py/setup.py?rev=1151988&r1=1151987&r2=1151988&view=diff
==============================================================================
--- avro/branches/branch-1.5/lang/py/setup.py (original)
+++ avro/branches/branch-1.5/lang/py/setup.py Thu Jul 28 19:53:43 2011
@@ -20,6 +20,12 @@ try:
 except ImportError:
   from distutils.core import setup
 
+from sys import version_info
+if version_info[:2] > (2, 5):
+    install_requires = []
+else:
+    install_requires = ['simplejson >= 2.0.9']
+
 setup(
   name = 'avro',
   version = '@AVRO_VERSION@',
@@ -28,7 +34,7 @@ setup(
 
   # Project uses simplejson, so ensure that it gets installed or upgraded
   # on the target machine
-  install_requires = ['simplejson >= 2.0.9'],
+  install_requires = install_requires,
 
   # metadata for upload to PyPI
   author = 'Apache Avro',