avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From th...@apache.org
Subject svn commit: r1377567 - in /avro/trunk: CHANGES.txt lang/c++/impl/FileStream.cc lang/c++/test/DataFileTests.cc
Date Mon, 27 Aug 2012 04:53:02 GMT
Author: thiru
Date: Mon Aug 27 04:53:02 2012
New Revision: 1377567

URL: http://svn.apache.org/viewvc?rev=1377567&view=rev
Log:
AVRO-1141. Avro data files are created without O_TRUNC

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/c++/impl/FileStream.cc
    avro/trunk/lang/c++/test/DataFileTests.cc

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1377567&r1=1377566&r2=1377567&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Mon Aug 27 04:53:02 2012
@@ -21,6 +21,8 @@ Avro 1.7.2 (unreleased)
 
     AVRO-1140. Buffer.hh includes Config.hh without "../" (Jan van der Lugt via thiru)
 
+    AVRO-1141. Avro data files are created without O_TRUNC (Martin Nagy via thiru)
+
 Avro 1.7.1 (16 July 2012)
 
   NEW FEATURES

Modified: avro/trunk/lang/c++/impl/FileStream.cc
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/impl/FileStream.cc?rev=1377567&r1=1377566&r2=1377567&view=diff
==============================================================================
--- avro/trunk/lang/c++/impl/FileStream.cc (original)
+++ avro/trunk/lang/c++/impl/FileStream.cc Mon Aug 27 04:53:02 2012
@@ -236,7 +236,7 @@ struct FileBufferCopyOut : public Buffer
     const int fd_;
 
     FileBufferCopyOut(const char* filename) :
-        fd_(::open(filename, O_WRONLY | O_CREAT | O_BINARY, 0644)) {
+        fd_(::open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644)) {
 
         if (fd_ < 0) {
             throw Exception(boost::format("Cannot open file: %1%") %

Modified: avro/trunk/lang/c++/test/DataFileTests.cc
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c%2B%2B/test/DataFileTests.cc?rev=1377567&r1=1377566&r2=1377567&view=diff
==============================================================================
--- avro/trunk/lang/c++/test/DataFileTests.cc (original)
+++ avro/trunk/lang/c++/test/DataFileTests.cc Mon Aug 27 04:53:02 2012
@@ -188,6 +188,17 @@ public:
         df.close();
     }
 
+    void testTruncate() {
+        testWriteDouble();
+        uintmax_t size = boost::filesystem::file_size(filename);
+        {
+            avro::DataFileWriter<Pair> df(filename, writerSchema, 100);
+            df.close();
+        }
+        uintmax_t new_size = boost::filesystem::file_size(filename);
+        BOOST_CHECK(size > new_size);
+    }
+
     void testReadFull() {
         avro::DataFileReader<ComplexInteger> df(filename, writerSchema);
         int i = 0;
@@ -364,5 +375,10 @@ init_unit_test_suite( int argc, char* ar
     ts->add(BOOST_CLASS_TEST_CASE(&DataFileTest::testReadDoubleTwoStepProject,
         t3));
     ts->add(BOOST_CLASS_TEST_CASE(&DataFileTest::testCleanup, t3));
+
+    shared_ptr<DataFileTest> t4(new DataFileTest("test4.df", dsch, dblsch));
+    ts->add(BOOST_CLASS_TEST_CASE(&DataFileTest::testTruncate, t4));
+    ts->add(BOOST_CLASS_TEST_CASE(&DataFileTest::testCleanup, t4));
+
     return ts;
 }



Mime
View raw message