Repository: parquet-cpp Updated Branches: refs/heads/master 06d4280e7 -> 32e8175d5
PARQUET-616: WriteBatch should accept const arrays Author: Uwe L. Korn <[email protected]> Closes #105 from xhochy/parquet-616 and squashes the following commits: eb614c5 [Uwe L. Korn] PARQUET-616: WriteBatch should accept const arrays Project: http://git-wip-us.apache.org/repos/asf/parquet-cpp/repo Commit: http://git-wip-us.apache.org/repos/asf/parquet-cpp/commit/32e8175d Tree: http://git-wip-us.apache.org/repos/asf/parquet-cpp/tree/32e8175d Diff: http://git-wip-us.apache.org/repos/asf/parquet-cpp/diff/32e8175d Branch: refs/heads/master Commit: 32e8175d52bd2928c39cb8cde5be5eb2cb4809a3 Parents: 06d4280 Author: Uwe L. Korn <[email protected]> Authored: Fri May 13 13:36:16 2016 -0700 Committer: Wes McKinney <[email protected]> Committed: Fri May 13 13:36:16 2016 -0700 ---------------------------------------------------------------------- src/parquet/column/writer.cc | 8 ++++---- src/parquet/column/writer.h | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/32e8175d/src/parquet/column/writer.cc ---------------------------------------------------------------------- diff --git a/src/parquet/column/writer.cc b/src/parquet/column/writer.cc index a23610c..c57e0ad 100644 --- a/src/parquet/column/writer.cc +++ b/src/parquet/column/writer.cc @@ -49,14 +49,14 @@ void ColumnWriter::InitSinks() { values_sink_.reset(new InMemoryOutputStream()); } -void ColumnWriter::WriteDefinitionLevels(int64_t num_levels, int16_t* levels) { +void ColumnWriter::WriteDefinitionLevels(int64_t num_levels, const int16_t* levels) { definition_levels_sink_->Write( - reinterpret_cast<uint8_t*>(levels), sizeof(int16_t) * num_levels); + reinterpret_cast<const uint8_t*>(levels), sizeof(int16_t) * num_levels); } -void ColumnWriter::WriteRepetitionLevels(int64_t num_levels, int16_t* levels) { +void ColumnWriter::WriteRepetitionLevels(int64_t num_levels, const int16_t* levels) { repetition_levels_sink_->Write( - reinterpret_cast<uint8_t*>(levels), sizeof(int16_t) * num_levels); + reinterpret_cast<const uint8_t*>(levels), sizeof(int16_t) * num_levels); } std::shared_ptr<Buffer> ColumnWriter::RleEncodeLevels( http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/32e8175d/src/parquet/column/writer.h ---------------------------------------------------------------------- diff --git a/src/parquet/column/writer.h b/src/parquet/column/writer.h index 32d0712..24f647a 100644 --- a/src/parquet/column/writer.h +++ b/src/parquet/column/writer.h @@ -52,10 +52,10 @@ class ColumnWriter { void WriteNewPage(); // Write multiple definition levels - void WriteDefinitionLevels(int64_t num_levels, int16_t* levels); + void WriteDefinitionLevels(int64_t num_levels, const int16_t* levels); // Write multiple repetition levels - void WriteRepetitionLevels(int64_t num_levels, int16_t* levels); + void WriteRepetitionLevels(int64_t num_levels, const int16_t* levels); std::shared_ptr<Buffer> RleEncodeLevels( const std::shared_ptr<Buffer>& buffer, int16_t max_level); @@ -107,14 +107,14 @@ class TypedColumnWriter : public ColumnWriter { // Write a batch of repetition levels, definition levels, and values to the // column. - void WriteBatch( - int64_t num_values, int16_t* def_levels, int16_t* rep_levels, T* values); + void WriteBatch(int64_t num_values, const int16_t* def_levels, + const int16_t* rep_levels, const T* values); private: typedef Encoder<DType> EncoderType; // Write values to a temporary buffer before they are encoded into pages - void WriteValues(int64_t num_values, T* values); + void WriteValues(int64_t num_values, const T* values); // Map of encoding type to the respective encoder object. For example, a // column chunk's data pages may include both dictionary-encoded and @@ -131,8 +131,8 @@ class TypedColumnWriter : public ColumnWriter { const int64_t PAGE_VALUE_COUNT = 1000; template <typename DType> -inline void TypedColumnWriter<DType>::WriteBatch( - int64_t num_values, int16_t* def_levels, int16_t* rep_levels, T* values) { +inline void TypedColumnWriter<DType>::WriteBatch(int64_t num_values, + const int16_t* def_levels, const int16_t* rep_levels, const T* values) { int64_t values_to_write = 0; // If the field is required and non-repeated, there are no definition levels @@ -175,7 +175,7 @@ inline void TypedColumnWriter<DType>::WriteBatch( } template <typename DType> -void TypedColumnWriter<DType>::WriteValues(int64_t num_values, T* values) { +void TypedColumnWriter<DType>::WriteValues(int64_t num_values, const T* values) { current_encoder_->Encode(values, num_values, values_sink_.get()); }
