avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbana...@apache.org
Subject svn commit: r835508 - in /hadoop/avro/trunk: CHANGES.txt src/c++/api/Reader.hh src/c++/api/Writer.hh src/c++/api/Zigzag.hh src/c++/impl/Zigzag.cc src/c++/test/unittest.cc
Date Thu, 12 Nov 2009 19:19:03 GMT
Author: sbanacho
Date: Thu Nov 12 19:19:02 2009
New Revision: 835508

URL: http://svn.apache.org/viewvc?rev=835508&view=rev
Log:
AVRO-194. C++ varint encoding buffer too small.

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

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=835508&r1=835507&r2=835508&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Thu Nov 12 19:19:02 2009
@@ -68,6 +68,8 @@
 
   BUG FIXES
  
+    AVRO-194. C++ varint encoding buffer too small. (sbanacho)
+
     AVRO-191. Explicitly include stdint.h for C++. (cutting via sbanacho)
 
     AVRO-176. Safeguard against bad istreams before reading. (sbanacho)

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=835508&r1=835507&r2=835508&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c++/api/Reader.hh (original)
+++ hadoop/avro/trunk/src/c++/api/Reader.hh Thu Nov 12 19:19:02 2009
@@ -146,7 +146,7 @@
         int shift = 0;
         do {
             in_.readByte(val);
-            uint64_t newbits = (val & 0x7f) << shift;
+            uint64_t newbits = static_cast<uint64_t>(val & 0x7f) << shift;
             encoded |= newbits;
             shift += 7;
         } while (val & 0x80);

Modified: hadoop/avro/trunk/src/c++/api/Writer.hh
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c%2B%2B/api/Writer.hh?rev=835508&r1=835507&r2=835508&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c++/api/Writer.hh (original)
+++ hadoop/avro/trunk/src/c++/api/Writer.hh Thu Nov 12 19:19:02 2009
@@ -52,7 +52,7 @@
     }
 
     void writeValue(int64_t val) {
-        boost::array<uint8_t, 9> bytes;
+        boost::array<uint8_t, 10> bytes;
         size_t size = encodeInt64(val, bytes);
         out_.writeBytes(bytes.data(), size);
     }

Modified: hadoop/avro/trunk/src/c++/api/Zigzag.hh
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c%2B%2B/api/Zigzag.hh?rev=835508&r1=835507&r2=835508&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c++/api/Zigzag.hh (original)
+++ hadoop/avro/trunk/src/c++/api/Zigzag.hh Thu Nov 12 19:19:02 2009
@@ -34,7 +34,7 @@
 int32_t decodeZigzag32(uint32_t input);
 
 size_t encodeInt32(int32_t input, boost::array<uint8_t, 5> &output);
-size_t encodeInt64(int64_t input, boost::array<uint8_t, 9> &output);
+size_t encodeInt64(int64_t input, boost::array<uint8_t, 10> &output);
 
 } // namespace avro
 

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=835508&r1=835507&r2=835508&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c++/impl/Zigzag.cc (original)
+++ hadoop/avro/trunk/src/c++/impl/Zigzag.cc Thu Nov 12 19:19:02 2009
@@ -46,7 +46,7 @@
 }
 
 size_t 
-encodeInt64(int64_t input, boost::array<uint8_t, 9> &output)
+encodeInt64(int64_t input, boost::array<uint8_t, 10> &output)
 {
     // get the zigzag encoding 
     uint64_t val = encodeZigzag64(input);

Modified: hadoop/avro/trunk/src/c++/test/unittest.cc
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/src/c%2B%2B/test/unittest.cc?rev=835508&r1=835507&r2=835508&view=diff
==============================================================================
--- hadoop/avro/trunk/src/c++/test/unittest.cc (original)
+++ hadoop/avro/trunk/src/c++/test/unittest.cc Thu Nov 12 19:19:02 2009
@@ -80,6 +80,7 @@
         record.addField("mybool", BoolSchema());
         FixedSchema fixed(16, "fixed16");
         record.addField("myfixed", fixed);
+        record.addField("mylong", LongSchema());
         record.addField("anotherint", intSchema);
 
         schema_.setSchema(record);
@@ -149,6 +150,9 @@
         
         s.writeFixed(fixeddata);
 
+        std::cout << "Long\n";
+        s.writeLong(7010728798977672067LL);
+
         std::cout << "Int\n";
         s.writeInt(-3456);
     }
@@ -290,6 +294,11 @@
         readFixed(p);
 
         printNext(p);
+        longval = p.readLong();
+        std::cout << longval << '\n';
+        BOOST_CHECK_EQUAL(longval, 7010728798977672067LL);
+
+        printNext(p);
         int32_t intval = p.readInt();
         std::cout << intval << '\n';
         BOOST_CHECK_EQUAL(intval, -3456);



Mime
View raw message