@@ -60,53 +60,62 @@ class TestPrimitiveWriter : public PrimitiveTypedTest<TestType> {
6060
6161 Type::type type_num () { return TestType::type_num; }
6262
63- void BuildReader () {
63+ void BuildReader (Compression::type compression = Compression:: UNCOMPRESSED ) {
6464 auto buffer = sink_->GetBuffer ();
6565 std::unique_ptr<InMemoryInputStream> source (new InMemoryInputStream (buffer));
6666 std::unique_ptr<SerializedPageReader> page_reader (
67- new SerializedPageReader (std::move (source), Compression:: UNCOMPRESSED ));
67+ new SerializedPageReader (std::move (source), compression ));
6868 reader_.reset (new TypedColumnReader<TestType>(this ->descr_ , std::move (page_reader)));
6969 }
7070
7171 std::shared_ptr<TypedColumnWriter<TestType>> BuildWriter (
72- int64_t output_size = SMALL_SIZE , Encoding::type encoding = Encoding::PLAIN ) {
72+ int64_t output_size = SMALL_SIZE ,
73+ const ColumnProperties& column_properties = ColumnProperties()) {
7374 sink_.reset (new InMemoryOutputStream ());
7475 metadata_ = ColumnChunkMetaDataBuilder::Make (
7576 writer_properties_, this ->descr_ , reinterpret_cast <uint8_t *>(&thrift_metadata_));
76- std::unique_ptr<SerializedPageWriter> pager (new SerializedPageWriter (
77- sink_.get (), Compression:: UNCOMPRESSED , metadata_.get ()));
77+ std::unique_ptr<SerializedPageWriter> pager (
78+ new SerializedPageWriter ( sink_.get (), column_properties. codec , metadata_.get ()));
7879 WriterProperties::Builder wp_builder;
79- if (encoding == Encoding::PLAIN_DICTIONARY || encoding == Encoding::RLE_DICTIONARY ) {
80+ if (column_properties.encoding == Encoding::PLAIN_DICTIONARY ||
81+ column_properties.encoding == Encoding::RLE_DICTIONARY ) {
8082 wp_builder.enable_dictionary ();
8183 } else {
8284 wp_builder.disable_dictionary ();
83- wp_builder.encoding (encoding);
85+ wp_builder.encoding (column_properties. encoding );
8486 }
8587 writer_properties_ = wp_builder.build ();
8688 std::shared_ptr<ColumnWriter> writer = ColumnWriter::Make (
87- this -> descr_ , std::move (pager), output_size, writer_properties_.get ());
89+ metadata_. get () , std::move (pager), output_size, writer_properties_.get ());
8890 return std::static_pointer_cast<TypedColumnWriter<TestType>>(writer);
8991 }
9092
91- void ReadColumn () {
92- BuildReader ();
93+ void ReadColumn (Compression::type compression = Compression:: UNCOMPRESSED ) {
94+ BuildReader (compression );
9395 reader_->ReadBatch (this ->values_out_ .size (), definition_levels_out_.data (),
9496 repetition_levels_out_.data (), this ->values_out_ptr_ , &values_read_);
9597 this ->SyncValuesOut ();
9698 }
9799
98100 void TestRequiredWithEncoding (Encoding::type encoding) {
101+ return TestRequiredWithSettings (encoding, Compression::UNCOMPRESSED , false , false );
102+ }
103+
104+ void TestRequiredWithSettings (Encoding::type encoding, Compression::type compression,
105+ bool enable_dictionary, bool enable_statistics) {
99106 this ->GenerateData (SMALL_SIZE );
100107
101108 // Test case 1: required and non-repeated, so no definition or repetition levels
109+ ColumnProperties column_properties (
110+ encoding, compression, enable_dictionary, enable_statistics);
102111 std::shared_ptr<TypedColumnWriter<TestType>> writer =
103- this ->BuildWriter (SMALL_SIZE , encoding );
112+ this ->BuildWriter (SMALL_SIZE , column_properties );
104113 writer->WriteBatch (this ->values_ .size (), nullptr , nullptr , this ->values_ptr_ );
105114 // The behaviour should be independent from the number of Close() calls
106115 writer->Close ();
107116 writer->Close ();
108117
109- this ->ReadColumn ();
118+ this ->ReadColumn (compression );
110119 ASSERT_EQ (SMALL_SIZE , this ->values_read_ );
111120 ASSERT_EQ (this ->values_ , this ->values_out_ );
112121 }
@@ -115,17 +124,17 @@ class TestPrimitiveWriter : public PrimitiveTypedTest<TestType> {
115124 // Metadata accessor must be created lazily.
116125 // This is because the ColumnChunkMetaData semantics dictate the metadata object is
117126 // complete (no changes to the metadata buffer can be made after instantiation)
118- auto metadata_accessor =
119- ColumnChunkMetaData::Make ( reinterpret_cast <const uint8_t *>(&thrift_metadata_));
127+ auto metadata_accessor = ColumnChunkMetaData::Make (
128+ reinterpret_cast <const uint8_t *>(&thrift_metadata_), this -> descr_ );
120129 return metadata_accessor->num_values ();
121130 }
122131
123132 std::vector<Encoding::type> metadata_encodings () {
124133 // Metadata accessor must be created lazily.
125134 // This is because the ColumnChunkMetaData semantics dictate the metadata object is
126135 // complete (no changes to the metadata buffer can be made after instantiation)
127- auto metadata_accessor =
128- ColumnChunkMetaData::Make ( reinterpret_cast <const uint8_t *>(&thrift_metadata_));
136+ auto metadata_accessor = ColumnChunkMetaData::Make (
137+ reinterpret_cast <const uint8_t *>(&thrift_metadata_), this -> descr_ );
129138 return metadata_accessor->encodings ();
130139 }
131140
@@ -148,8 +157,7 @@ class TestPrimitiveWriter : public PrimitiveTypedTest<TestType> {
148157};
149158
150159typedef ::testing::Types<Int32Type, Int64Type, Int96Type, FloatType, DoubleType,
151- BooleanType, ByteArrayType, FLBAType>
152- TestTypes;
160+ BooleanType, ByteArrayType, FLBAType> TestTypes;
153161
154162TYPED_TEST_CASE (TestPrimitiveWriter, TestTypes);
155163
@@ -189,6 +197,26 @@ TYPED_TEST(TestPrimitiveWriter, RequiredRLEDictionary) {
189197}
190198*/
191199
200+ TYPED_TEST (TestPrimitiveWriter, RequiredPlainWithSnappyCompression) {
201+ this ->TestRequiredWithSettings (Encoding::PLAIN , Compression::SNAPPY , false , false );
202+ }
203+
204+ TYPED_TEST (TestPrimitiveWriter, RequiredPlainWithGzipCompression) {
205+ this ->TestRequiredWithSettings (Encoding::PLAIN , Compression::GZIP , false , false );
206+ }
207+
208+ TYPED_TEST (TestPrimitiveWriter, RequiredPlainWithStats) {
209+ this ->TestRequiredWithSettings (Encoding::PLAIN , Compression::UNCOMPRESSED , false , true );
210+ }
211+
212+ TYPED_TEST (TestPrimitiveWriter, RequiredPlainWithStatsAndSnappyCompression) {
213+ this ->TestRequiredWithSettings (Encoding::PLAIN , Compression::SNAPPY , false , true );
214+ }
215+
216+ TYPED_TEST (TestPrimitiveWriter, RequiredPlainWithStatsAndGzipCompression) {
217+ this ->TestRequiredWithSettings (Encoding::PLAIN , Compression::GZIP , false , true );
218+ }
219+
192220TYPED_TEST (TestPrimitiveWriter, Optional) {
193221 // Optional and non-repeated, with definition levels
194222 // but no repetition levels
0 commit comments