@@ -60,53 +60,61 @@ 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 ColumnSettings& settings = ColumnSettings()) {
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 (), settings. codec , metadata_.get ()));
7879 WriterProperties::Builder wp_builder;
79- if (encoding == Encoding::PLAIN_DICTIONARY || encoding == Encoding::RLE_DICTIONARY ) {
80+ if (settings.encoding == Encoding::PLAIN_DICTIONARY ||
81+ settings.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 (settings. 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 );
102+ }
103+
104+ void TestRequiredWithSettings (
105+ Encoding::type encoding, Compression::type compression, bool compute_statistics) {
99106 this ->GenerateData (SMALL_SIZE );
100107
101108 // Test case 1: required and non-repeated, so no definition or repetition levels
109+ ColumnSettings settings (encoding, compression, compute_statistics);
102110 std::shared_ptr<TypedColumnWriter<TestType>> writer =
103- this ->BuildWriter (SMALL_SIZE , encoding );
111+ this ->BuildWriter (SMALL_SIZE , settings );
104112 writer->WriteBatch (this ->values_ .size (), nullptr , nullptr , this ->values_ptr_ );
105113 // The behaviour should be independent from the number of Close() calls
106114 writer->Close ();
107115 writer->Close ();
108116
109- this ->ReadColumn ();
117+ this ->ReadColumn (compression );
110118 ASSERT_EQ (SMALL_SIZE , this ->values_read_ );
111119 ASSERT_EQ (this ->values_ , this ->values_out_ );
112120 }
@@ -115,17 +123,17 @@ class TestPrimitiveWriter : public PrimitiveTypedTest<TestType> {
115123 // Metadata accessor must be created lazily.
116124 // This is because the ColumnChunkMetaData semantics dictate the metadata object is
117125 // 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_));
126+ auto metadata_accessor = ColumnChunkMetaData::Make (
127+ reinterpret_cast <const uint8_t *>(&thrift_metadata_), this -> descr_ );
120128 return metadata_accessor->num_values ();
121129 }
122130
123131 std::vector<Encoding::type> metadata_encodings () {
124132 // Metadata accessor must be created lazily.
125133 // This is because the ColumnChunkMetaData semantics dictate the metadata object is
126134 // 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_));
135+ auto metadata_accessor = ColumnChunkMetaData::Make (
136+ reinterpret_cast <const uint8_t *>(&thrift_metadata_), this -> descr_ );
129137 return metadata_accessor->encodings ();
130138 }
131139
@@ -148,8 +156,7 @@ class TestPrimitiveWriter : public PrimitiveTypedTest<TestType> {
148156};
149157
150158typedef ::testing::Types<Int32Type, Int64Type, Int96Type, FloatType, DoubleType,
151- BooleanType, ByteArrayType, FLBAType>
152- TestTypes;
159+ BooleanType, ByteArrayType, FLBAType> TestTypes;
153160
154161TYPED_TEST_CASE (TestPrimitiveWriter, TestTypes);
155162
@@ -189,6 +196,26 @@ TYPED_TEST(TestPrimitiveWriter, RequiredRLEDictionary) {
189196}
190197*/
191198
199+ TYPED_TEST (TestPrimitiveWriter, RequiredPlainWithSnappyCompression) {
200+ this ->TestRequiredWithSettings (Encoding::PLAIN , Compression::SNAPPY , false );
201+ }
202+
203+ TYPED_TEST (TestPrimitiveWriter, RequiredPlainWithGzipCompression) {
204+ this ->TestRequiredWithSettings (Encoding::PLAIN , Compression::GZIP , false );
205+ }
206+
207+ TYPED_TEST (TestPrimitiveWriter, RequiredPlainWithStats) {
208+ this ->TestRequiredWithSettings (Encoding::PLAIN , Compression::UNCOMPRESSED , true );
209+ }
210+
211+ TYPED_TEST (TestPrimitiveWriter, RequiredPlainWithStatsAndSnappyCompression) {
212+ this ->TestRequiredWithSettings (Encoding::PLAIN , Compression::SNAPPY , true );
213+ }
214+
215+ TYPED_TEST (TestPrimitiveWriter, RequiredPlainWithStatsAndGzipCompression) {
216+ this ->TestRequiredWithSettings (Encoding::PLAIN , Compression::GZIP , true );
217+ }
218+
192219TYPED_TEST (TestPrimitiveWriter, Optional) {
193220 // Optional and non-repeated, with definition levels
194221 // but no repetition levels
0 commit comments