| 61 | |
| 62 | namespace { |
| 63 | bool IsColumnChunkFullyDictionaryEncoded(const ColumnChunkMetaData& col) { |
| 64 | // Check the encoding_stats to see if all data pages are dictionary encoded. |
| 65 | const std::vector<PageEncodingStats>& encoding_stats = col.encoding_stats(); |
| 66 | if (encoding_stats.empty()) { |
| 67 | // Some parquet files may have empty encoding_stats. In this case we are |
| 68 | // not sure whether all data pages are dictionary encoded. |
| 69 | return false; |
| 70 | } |
| 71 | // The 1st page should be the dictionary page. |
| 72 | if (encoding_stats[0].page_type != PageType::DICTIONARY_PAGE || |
| 73 | (encoding_stats[0].encoding != Encoding::PLAIN && |
| 74 | encoding_stats[0].encoding != Encoding::PLAIN_DICTIONARY)) { |
| 75 | return false; |
| 76 | } |
| 77 | // The following pages should be dictionary encoded data pages. |
| 78 | for (size_t idx = 1; idx < encoding_stats.size(); ++idx) { |
| 79 | if (!IsDictionaryIndexEncoding(encoding_stats[idx].encoding) || |
| 80 | (encoding_stats[idx].page_type != PageType::DATA_PAGE && |
| 81 | encoding_stats[idx].page_type != PageType::DATA_PAGE_V2)) { |
| 82 | // Return false if any following page is not a dictionary encoded data |
| 83 | // page. |
| 84 | return false; |
| 85 | } |
| 86 | } |
| 87 | return true; |
| 88 | } |
| 89 | } // namespace |
| 90 | |
| 91 | static constexpr uint32_t kFooterSize = 8; |
no test coverage detected