Repository: parquet-cpp Updated Branches: refs/heads/master 5902c55ea -> 45ca7bab9
PARQUET-620: Ensure metadata is written only once Author: Uwe L. Korn <[email protected]> Closes #108 from xhochy/parquet-620 and squashes the following commits: da122ad [Uwe L. Korn] Ensure metadata is written only 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/45ca7bab Tree: http://git-wip-us.apache.org/repos/asf/parquet-cpp/tree/45ca7bab Diff: http://git-wip-us.apache.org/repos/asf/parquet-cpp/diff/45ca7bab Branch: refs/heads/master Commit: 45ca7bab9c32e48ccda84ab041f10d019c72daec Parents: 5902c55 Author: Uwe L. Korn <[email protected]> Authored: Tue May 17 19:12:08 2016 -0700 Committer: Wes McKinney <[email protected]> Committed: Tue May 17 19:12:08 2016 -0700 ---------------------------------------------------------------------- src/parquet/file/writer-internal.cc | 19 +++++++++++++------ src/parquet/file/writer-internal.h | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/45ca7bab/src/parquet/file/writer-internal.cc ---------------------------------------------------------------------- diff --git a/src/parquet/file/writer-internal.cc b/src/parquet/file/writer-internal.cc index d87d521..aae7000 100644 --- a/src/parquet/file/writer-internal.cc +++ b/src/parquet/file/writer-internal.cc @@ -173,13 +173,16 @@ std::unique_ptr<ParquetFileWriter::Contents> FileSerializer::Open( } void FileSerializer::Close() { - if (row_group_writer_) { row_group_writer_->Close(); } - row_group_writer_.reset(); + if (is_open_) { + if (row_group_writer_) { row_group_writer_->Close(); } + row_group_writer_.reset(); - // Write magic bytes and metadata - WriteMetaData(); + // Write magic bytes and metadata + WriteMetaData(); - sink_->Close(); + sink_->Close(); + is_open_ = false; + } } int FileSerializer::num_columns() const { @@ -238,7 +241,11 @@ void FileSerializer::WriteMetaData() { FileSerializer::FileSerializer(std::shared_ptr<OutputStream> sink, std::shared_ptr<GroupNode>& schema, MemoryAllocator* allocator = default_allocator()) - : sink_(sink), allocator_(allocator), num_row_groups_(0), num_rows_(0) { + : sink_(sink), + allocator_(allocator), + num_row_groups_(0), + num_rows_(0), + is_open_(true) { schema_.Init(schema); StartFile(); } http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/45ca7bab/src/parquet/file/writer-internal.h ---------------------------------------------------------------------- diff --git a/src/parquet/file/writer-internal.h b/src/parquet/file/writer-internal.h index 8c5db68..53c6b71 100644 --- a/src/parquet/file/writer-internal.h +++ b/src/parquet/file/writer-internal.h @@ -130,6 +130,7 @@ class FileSerializer : public ParquetFileWriter::Contents { MemoryAllocator* allocator_; int num_row_groups_; int num_rows_; + bool is_open_; std::unique_ptr<RowGroupWriter> row_group_writer_; void StartFile();
