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

Method SetData

cpp/src/parquet/column_reader.cc:128–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126LevelDecoder::~LevelDecoder() = default;
127
128int LevelDecoder::SetData(Encoding::type encoding, int16_t max_level,
129 int num_buffered_values, const uint8_t* data,
130 int32_t data_size) {
131 max_level_ = max_level;
132 num_values_remaining_ = num_buffered_values;
133 const int value_bit_width = bit_util::Log2(max_level + 1);
134
135 switch (encoding) {
136 case Encoding::RLE: {
137 if (data_size < 4) {
138 throw ParquetException("Received invalid levels (corrupt data page?)");
139 }
140 const auto num_bytes = ::arrow::util::SafeLoadAs<int32_t>(data);
141 if (num_bytes < 0 || num_bytes > data_size - 4) {
142 throw ParquetException("Received invalid number of bytes (corrupt data page?)");
143 }
144 this->impl_->decoder = Impl::RleBitPackedDecoder( //
145 /* data= */ data + 4,
146 /* data_size =*/num_bytes,
147 /* value_bit_width= */ value_bit_width);
148 return 4 + num_bytes;
149 }
150 case Encoding::BIT_PACKED: {
151 int num_bits = 0;
152 if (MultiplyWithOverflow(num_buffered_values, value_bit_width, &num_bits)) {
153 throw ParquetException(
154 "Number of buffered values too large (corrupt data page?)");
155 }
156 const auto num_bytes = static_cast<int32_t>(bit_util::BytesForBits(num_bits));
157 if (num_bytes < 0 || num_bytes > data_size) {
158 throw ParquetException("Received invalid number of bytes (corrupt data page?)");
159 }
160 // Also adding `value_count` so that the decoder also works with zero-width runs.
161 this->impl_->decoder = Impl::BitPackedDecoder( //
162 /* data= */ data,
163 /* data_size =*/num_bytes,
164 /* value_bit_width= */ value_bit_width,
165 /* value_count= */ num_buffered_values);
166 return num_bytes;
167 }
168 default:
169 throw ParquetException("Unknown encoding type for levels.");
170 }
171 return -1;
172}
173
174void LevelDecoder::SetDataV2(int32_t num_bytes, int16_t max_level,
175 int num_buffered_values, const uint8_t* data) {

Callers 3

ConfigureDictionaryMethod · 0.45
InitializeDataDecoderMethod · 0.45

Calls 6

ParquetExceptionFunction · 0.85
RleBitPackedDecoderClass · 0.85
MultiplyWithOverflowFunction · 0.85
BytesForBitsFunction · 0.85
BitPackedDecoderClass · 0.85
Log2Function · 0.50

Tested by

no test coverage detected