Read column index of a column chunk.
| 230 | |
| 231 | /// Read column index of a column chunk. |
| 232 | std::shared_ptr<ColumnIndex> GetColumnIndex(int32_t i) override { |
| 233 | if (i < 0 || i >= row_group_metadata_->num_columns()) { |
| 234 | throw ParquetException("Invalid column index at column ordinal ", i); |
| 235 | } |
| 236 | |
| 237 | auto col_chunk = row_group_metadata_->ColumnChunk(i); |
| 238 | auto column_index_location = col_chunk->GetColumnIndexLocation(); |
| 239 | if (!column_index_location.has_value()) { |
| 240 | return nullptr; |
| 241 | } |
| 242 | |
| 243 | CheckReadRangeOrThrow(*column_index_location, index_read_range_.column_index, |
| 244 | row_group_ordinal_); |
| 245 | |
| 246 | if (column_index_buffer_ == nullptr) { |
| 247 | column_index_buffer_ = |
| 248 | ReadIndexBuffer(index_read_range_.column_index->offset, |
| 249 | index_read_range_.column_index->length, "ColumnIndex"); |
| 250 | } |
| 251 | |
| 252 | int64_t buffer_offset = |
| 253 | column_index_location->offset - index_read_range_.column_index->offset; |
| 254 | // ColumnIndex::Make() requires the type of serialized thrift message to be |
| 255 | // uint32_t |
| 256 | uint32_t length = static_cast<uint32_t>(column_index_location->length); |
| 257 | auto descr = row_group_metadata_->schema()->Column(i); |
| 258 | |
| 259 | // Get decryptor of column index if encrypted. |
| 260 | std::unique_ptr<Decryptor> decryptor = |
| 261 | InternalFileDecryptor::GetColumnMetaDecryptorFactory( |
| 262 | file_decryptor_, col_chunk->crypto_metadata().get())(); |
| 263 | if (decryptor != nullptr) { |
| 264 | UpdateDecryptor(decryptor.get(), row_group_ordinal_, /*column_ordinal=*/i, |
| 265 | encryption::kColumnIndex); |
| 266 | } |
| 267 | |
| 268 | return ColumnIndex::Make(*descr, column_index_buffer_->data() + buffer_offset, length, |
| 269 | properties_, decryptor.get()); |
| 270 | } |
| 271 | |
| 272 | /// Read offset index of a column chunk. |
| 273 | std::shared_ptr<OffsetIndex> GetOffsetIndex(int32_t i) override { |
nothing calls this directly
no test coverage detected