avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r817760 - in /hadoop/avro/trunk: CHANGES.txt src/c++/api/Reader.hh src/c++/impl/Zigzag.cc
Date Tue, 22 Sep 2009 18:47:54 GMT
Author: cutting
Date: Tue Sep 22 18:47:46 2009
New Revision: 817760

URL: http://svn.apache.org/viewvc?rev=817760&view=rev
Log:
AVRO-113.  Fix endian bug with C++ integer/long varint codec.  Contributed by Scott Banachowski.

Modified:
    hadoop/avro/trunk/CHANGES.txt
    hadoop/avro/trunk/src/c++/api/Reader.hh
    hadoop/avro/trunk/src/c++/impl/Zigzag.cc

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=817760&r1=817759&r2=817760&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Tue Sep 22 18:47:46 2009
@@ -15,6 +15,9 @@
 
   BUG FIXES
 
+    AVRO-113.  Fix endian bug with C++ integer/long varint codec.
+    (Scott Banachowski via cutting)
+
 Avro 1.1.0 (8 September 2009)
 
   INCOMPATIBLE CHANGES

Modified: hadoop/avro/trunk/src/c++/api/Reader.hh
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c%2B%2B/api/Reader.hh?rev=817760&r1=817759&r2=817760&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c++/api/Reader.hh (original)
+++ hadoop/avro/trunk/src/c++/api/Reader.hh Tue Sep 22 18:47:46 2009
@@ -147,11 +147,12 @@
     uint64_t getVarInt() {
         uint64_t encoded = 0;
         uint8_t val = 0;
+        int shift = 0;
         do {
-            encoded <<= 7;
             in_.getByte(val);
-            encoded |= (val & 0x7F);
-
+            uint64_t newbits = (val & 0x7f) << shift;
+            encoded |= newbits;
+            shift += 7;
         } while (val & 0x80);
 
         return encoded;

Modified: hadoop/avro/trunk/src/c++/impl/Zigzag.cc
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c%2B%2B/impl/Zigzag.cc?rev=817760&r1=817759&r2=817760&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c++/impl/Zigzag.cc (original)
+++ hadoop/avro/trunk/src/c++/impl/Zigzag.cc Tue Sep 22 18:47:46 2009
@@ -56,14 +56,8 @@
     output[0] = val & mask;
     size_t bytesOut = 1;
     while( val >>=7 ) {
-        output[bytesOut++] = (val & mask) | 0x80;
-    }
-
-    // arrange array so msb is first
-    int head = 0;
-    int tail = bytesOut - 1;
-    while(head < tail) {
-        std::swap(output[head++], output[tail--]);
+        output[bytesOut-1] |= 0x80;
+        output[bytesOut++] = (val & mask);
     }
 
     return bytesOut;
@@ -80,14 +74,8 @@
     output[0] = val & mask;
     size_t bytesOut = 1;
     while( val >>=7 ) {
-        output[bytesOut++] = (val & mask) | 0x80;
-    }
-
-    // arrange array so msb is first
-    int head = 0;
-    int tail = bytesOut - 1;
-    while(head < tail) {
-        std::swap(output[head++], output[tail--]);
+        output[bytesOut-1] |= 0x80;
+        output[bytesOut++] = (val & mask);
     }
 
     return bytesOut;



Mime
View raw message