Skip to content

Commit 9eecaaf

Browse files
used std::map instead of std::unordered_map to store num_data_pages
1 parent 6822fc6 commit 9eecaaf

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

cpp/src/parquet/column_writer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#include <algorithm>
2121
#include <cstdint>
2222
#include <cstring>
23+
#include <map>
2324
#include <memory>
2425
#include <string>
25-
#include <unordered_map>
2626
#include <utility>
2727
#include <vector>
2828

@@ -406,7 +406,7 @@ class SerializedPageWriter : public PageWriter {
406406
std::shared_ptr<ResizableBuffer> encryption_buffer_;
407407

408408
int32_t num_dict_pages_;
409-
std::unordered_map<Encoding::type, int32_t> num_data_pages_;
409+
std::map<Encoding::type, int32_t> num_data_pages_;
410410
};
411411

412412
// This implementation of the PageWriter writes to the final sink on Close .

cpp/src/parquet/metadata.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ class ColumnChunkMetaDataBuilder::ColumnChunkMetaDataBuilderImpl {
983983
int64_t index_page_offset, int64_t data_page_offset,
984984
int64_t compressed_size, int64_t uncompressed_size, bool has_dictionary,
985985
bool dictionary_fallback, int32_t num_dict_pages,
986-
std::unordered_map<Encoding::type, int32_t>& num_data_pages,
986+
std::map<Encoding::type, int32_t>& num_data_pages,
987987
const std::shared_ptr<Encryptor>& encryptor) {
988988
if (dictionary_page_offset > 0) {
989989
column_chunk_->meta_data.__set_dictionary_page_offset(dictionary_page_offset);
@@ -1174,12 +1174,14 @@ void ColumnChunkMetaDataBuilder::set_file_path(const std::string& path) {
11741174
impl_->set_file_path(path);
11751175
}
11761176

1177-
void ColumnChunkMetaDataBuilder::Finish(
1178-
int64_t num_values, int64_t dictionary_page_offset, int64_t index_page_offset,
1179-
int64_t data_page_offset, int64_t compressed_size, int64_t uncompressed_size,
1180-
bool has_dictionary, bool dictionary_fallback, int32_t num_dict_pages,
1181-
std::unordered_map<Encoding::type, int32_t> num_data_pages,
1182-
const std::shared_ptr<Encryptor>& encryptor) {
1177+
void ColumnChunkMetaDataBuilder::Finish(int64_t num_values,
1178+
int64_t dictionary_page_offset,
1179+
int64_t index_page_offset,
1180+
int64_t data_page_offset, int64_t compressed_size,
1181+
int64_t uncompressed_size, bool has_dictionary,
1182+
bool dictionary_fallback, int32_t num_dict_pages,
1183+
std::map<Encoding::type, int32_t> num_data_pages,
1184+
const std::shared_ptr<Encryptor>& encryptor) {
11831185
impl_->Finish(num_values, dictionary_page_offset, index_page_offset, data_page_offset,
11841186
compressed_size, uncompressed_size, has_dictionary, dictionary_fallback,
11851187
num_dict_pages, num_data_pages, encryptor);

cpp/src/parquet/metadata.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <map>
2323
#include <memory>
2424
#include <string>
25-
#include <unordered_map>
2625
#include <utility>
2726
#include <vector>
2827

@@ -324,7 +323,7 @@ class PARQUET_EXPORT ColumnChunkMetaDataBuilder {
324323
int64_t index_page_offset, int64_t data_page_offset,
325324
int64_t compressed_size, int64_t uncompressed_size, bool has_dictionary,
326325
bool dictionary_fallback, int32_t num_dict_pages,
327-
std::unordered_map<Encoding::type, int32_t>,
326+
std::map<Encoding::type, int32_t>,
328327
const std::shared_ptr<Encryptor>& encryptor = NULLPTR);
329328

330329
// The metadata contents, suitable for passing to ColumnChunkMetaData::Make

cpp/src/parquet/metadata_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ std::unique_ptr<parquet::FileMetaData> GenerateTableMetaData(
4040
auto col1_builder = rg1_builder->NextColumnChunk();
4141
auto col2_builder = rg1_builder->NextColumnChunk();
4242
// column metadata
43-
std::unordered_map<Encoding::type, int32_t> encoding_stats = {
44-
{Encoding::RLE_DICTIONARY, 1}, {Encoding::PLAIN, 1}, {Encoding::RLE, 1}};
43+
std::map<Encoding::type, int32_t> encoding_stats(
44+
{{Encoding::RLE_DICTIONARY, 1}, {Encoding::PLAIN, 1}, {Encoding::RLE, 1}});
4545
stats_int.set_is_signed(true);
4646
col1_builder->SetStatistics(stats_int);
4747
stats_float.set_is_signed(true);

0 commit comments

Comments
 (0)