Read definition and repetition levels. Also return the number of definition levels and number of values to read. This function is called before reading values. ReadLevels will throw exception when any num-levels read is not equal to the number of the levels can be read.
| 1001 | // ReadLevels will throw exception when any num-levels read is not equal to the number |
| 1002 | // of the levels can be read. |
| 1003 | void ReadLevels(int64_t batch_size, int16_t* def_levels, int16_t* rep_levels, |
| 1004 | int64_t* num_def_levels, int64_t* non_null_values_to_read) { |
| 1005 | batch_size = std::min(batch_size, this->available_values_current_page()); |
| 1006 | |
| 1007 | // If the field is required and non-repeated, there are no definition levels |
| 1008 | if (this->max_def_level_ > 0 && def_levels != nullptr) { |
| 1009 | *num_def_levels = this->ReadDefinitionLevels(batch_size, def_levels); |
| 1010 | if (ARROW_PREDICT_FALSE(*num_def_levels != batch_size)) { |
| 1011 | throw ParquetException(kErrorRepDefLevelNotMatchesNumValues); |
| 1012 | } |
| 1013 | // TODO(wesm): this tallying of values-to-decode can be performed with better |
| 1014 | // cache-efficiency if fused with the level decoding. |
| 1015 | *non_null_values_to_read += |
| 1016 | std::count(def_levels, def_levels + *num_def_levels, this->max_def_level_); |
| 1017 | } else { |
| 1018 | // Required field, read all values |
| 1019 | if (num_def_levels != nullptr) { |
| 1020 | *num_def_levels = 0; |
| 1021 | } |
| 1022 | *non_null_values_to_read = batch_size; |
| 1023 | } |
| 1024 | |
| 1025 | // Not present for non-repeated fields |
| 1026 | if (this->max_rep_level_ > 0 && rep_levels != nullptr) { |
| 1027 | int64_t num_rep_levels = this->ReadRepetitionLevels(batch_size, rep_levels); |
| 1028 | if (batch_size != num_rep_levels) { |
| 1029 | throw ParquetException(kErrorRepDefLevelNotMatchesNumValues); |
| 1030 | } |
| 1031 | } |
| 1032 | } |
| 1033 | }; |
| 1034 | |
| 1035 | template <typename DType> |
nothing calls this directly
no test coverage detected