MCPcopy Create free account
hub / github.com/apache/arrow / ReadLevels

Method ReadLevels

cpp/src/parquet/column_reader.cc:1018–1047  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

1016 // ReadLevels will throw exception when any num-levels read is not equal to the number
1017 // of the levels can be read.
1018 void ReadLevels(int64_t batch_size, int16_t* def_levels, int16_t* rep_levels,
1019 int64_t* num_def_levels, int64_t* non_null_values_to_read) {
1020 batch_size = std::min(batch_size, this->available_values_current_page());
1021
1022 // If the field is required and non-repeated, there are no definition levels
1023 if (this->max_def_level_ > 0 && def_levels != nullptr) {
1024 *num_def_levels = this->ReadDefinitionLevels(batch_size, def_levels);
1025 if (ARROW_PREDICT_FALSE(*num_def_levels != batch_size)) {
1026 throw ParquetException(kErrorRepDefLevelNotMatchesNumValues);
1027 }
1028 // TODO(wesm): this tallying of values-to-decode can be performed with better
1029 // cache-efficiency if fused with the level decoding.
1030 *non_null_values_to_read +=
1031 std::count(def_levels, def_levels + *num_def_levels, this->max_def_level_);
1032 } else {
1033 // Required field, read all values
1034 if (num_def_levels != nullptr) {
1035 *num_def_levels = 0;
1036 }
1037 *non_null_values_to_read = batch_size;
1038 }
1039
1040 // Not present for non-repeated fields
1041 if (this->max_rep_level_ > 0 && rep_levels != nullptr) {
1042 int64_t num_rep_levels = this->ReadRepetitionLevels(batch_size, rep_levels);
1043 if (batch_size != num_rep_levels) {
1044 throw ParquetException(kErrorRepDefLevelNotMatchesNumValues);
1045 }
1046 }
1047 }
1048};
1049
1050template <typename DType>

Callers

nothing calls this directly

Calls 5

ParquetExceptionFunction · 0.85
countFunction · 0.85
ReadDefinitionLevelsMethod · 0.80
ReadRepetitionLevelsMethod · 0.80

Tested by

no test coverage detected