| 66 | } |
| 67 | |
| 68 | void SizeStatistics::Validate(const ColumnDescriptor* descr) const { |
| 69 | auto validate_histogram = [](const std::vector<int64_t>& histogram, int16_t max_level, |
| 70 | const std::string& name) { |
| 71 | if (histogram.empty()) { |
| 72 | // A levels histogram is always allowed to be missing. |
| 73 | return; |
| 74 | } |
| 75 | if (histogram.size() != static_cast<size_t>(max_level + 1)) { |
| 76 | std::stringstream ss; |
| 77 | ss << name << " level histogram size mismatch, size: " << histogram.size() |
| 78 | << ", expected: " << (max_level + 1); |
| 79 | throw ParquetException(ss.str()); |
| 80 | } |
| 81 | }; |
| 82 | validate_histogram(repetition_level_histogram, descr->max_repetition_level(), |
| 83 | "Repetition"); |
| 84 | validate_histogram(definition_level_histogram, descr->max_definition_level(), |
| 85 | "Definition"); |
| 86 | if (unencoded_byte_array_data_bytes.has_value() && |
| 87 | descr->physical_type() != Type::BYTE_ARRAY) { |
| 88 | throw ParquetException("Unencoded byte array data bytes does not support " + |
| 89 | TypeToString(descr->physical_type())); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | void SizeStatistics::Reset() { |
| 94 | repetition_level_histogram.assign(repetition_level_histogram.size(), 0); |
no test coverage detected