parquet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject parquet-cpp git commit: PARQUET-629: RowGroupSerializer should only close itself once
Date Wed, 08 Jun 2016 23:15:34 GMT
Repository: parquet-cpp
Updated Branches:
  refs/heads/master 9b28c8f21 -> dd555cdfe


PARQUET-629: RowGroupSerializer should only close itself once

Author: Uwe L. Korn <uwelk@xhochy.com>

Closes #117 from xhochy/parquet-629 and squashes the following commits:

8f8c9f1 [Uwe L. Korn] PARQUET-629: RowGroupSerializer should only close itself once


Project: http://git-wip-us.apache.org/repos/asf/parquet-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/parquet-cpp/commit/dd555cdf
Tree: http://git-wip-us.apache.org/repos/asf/parquet-cpp/tree/dd555cdf
Diff: http://git-wip-us.apache.org/repos/asf/parquet-cpp/diff/dd555cdf

Branch: refs/heads/master
Commit: dd555cdfedf5006f935749dce562202b0e0e1c4a
Parents: 9b28c8f
Author: Uwe L. Korn <uwelk@xhochy.com>
Authored: Wed Jun 8 16:15:26 2016 -0700
Committer: Wes McKinney <wesm@apache.org>
Committed: Wed Jun 8 16:15:26 2016 -0700

----------------------------------------------------------------------
 src/parquet/file/writer-internal.cc | 21 ++++++++++++---------
 src/parquet/file/writer-internal.h  |  2 ++
 2 files changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/dd555cdf/src/parquet/file/writer-internal.cc
----------------------------------------------------------------------
diff --git a/src/parquet/file/writer-internal.cc b/src/parquet/file/writer-internal.cc
index aae7000..27e8d62 100644
--- a/src/parquet/file/writer-internal.cc
+++ b/src/parquet/file/writer-internal.cc
@@ -148,16 +148,19 @@ ColumnWriter* RowGroupSerializer::NextColumn() {
 }
 
 void RowGroupSerializer::Close() {
-  if (current_column_index_ != schema_->num_columns() - 1) {
-    throw ParquetException("Not all column were written in the current rowgroup.");
+  if (!closed_) {
+    closed_ = true;
+    if (current_column_index_ != schema_->num_columns() - 1) {
+      throw ParquetException("Not all column were written in the current rowgroup.");
+    }
+
+    if (current_column_writer_) {
+      total_bytes_written_ += current_column_writer_->Close();
+      current_column_writer_.reset();
+    }
+
+    metadata_->__set_total_byte_size(total_bytes_written_);
   }
-
-  if (current_column_writer_) {
-    total_bytes_written_ += current_column_writer_->Close();
-    current_column_writer_.reset();
-  }
-
-  metadata_->__set_total_byte_size(total_bytes_written_);
 }
 
 // ----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/dd555cdf/src/parquet/file/writer-internal.h
----------------------------------------------------------------------
diff --git a/src/parquet/file/writer-internal.h b/src/parquet/file/writer-internal.h
index 53c6b71..dd595a9 100644
--- a/src/parquet/file/writer-internal.h
+++ b/src/parquet/file/writer-internal.h
@@ -74,6 +74,7 @@ class RowGroupSerializer : public RowGroupWriter::Contents {
         metadata_(metadata),
         allocator_(allocator),
         total_bytes_written_(0),
+        closed_(false),
         current_column_index_(-1) {
     metadata_->__set_num_rows(num_rows_);
     metadata_->columns.resize(schema->num_columns());
@@ -96,6 +97,7 @@ class RowGroupSerializer : public RowGroupWriter::Contents {
   format::RowGroup* metadata_;
   MemoryAllocator* allocator_;
   int64_t total_bytes_written_;
+  bool closed_;
 
   int64_t current_column_index_;
   std::shared_ptr<ColumnWriter> current_column_writer_;


Mime
View raw message