| 237 | const ReaderProperties* properties() const override { return &properties_; } |
| 238 | |
| 239 | std::unique_ptr<PageReader> GetColumnPageReader(int i) override { |
| 240 | // Read column chunk from the file |
| 241 | auto col = row_group_metadata_->ColumnChunk(i); |
| 242 | |
| 243 | ::arrow::io::ReadRange col_range = |
| 244 | ComputeColumnChunkRange(file_metadata_, source_size_, row_group_ordinal_, i); |
| 245 | std::shared_ptr<ArrowInputStream> stream; |
| 246 | if (cached_source_ && prebuffered_column_chunks_bitmap_ != nullptr && |
| 247 | ::arrow::bit_util::GetBit(prebuffered_column_chunks_bitmap_->data(), i)) { |
| 248 | // PARQUET-1698: if read coalescing is enabled, read from pre-buffered |
| 249 | // segments. |
| 250 | PARQUET_ASSIGN_OR_THROW(auto buffer, cached_source_->Read(col_range)); |
| 251 | stream = std::make_shared<::arrow::io::BufferReader>(buffer); |
| 252 | } else { |
| 253 | stream = properties_.GetStream(source_, col_range.offset, col_range.length); |
| 254 | } |
| 255 | |
| 256 | std::unique_ptr<ColumnCryptoMetaData> crypto_metadata = col->crypto_metadata(); |
| 257 | |
| 258 | // Prior to Arrow 3.0.0, is_compressed was always set to false in column headers, |
| 259 | // even if compression was used. See ARROW-17100. |
| 260 | bool always_compressed = file_metadata_->writer_version().VersionLt( |
| 261 | ApplicationVersion::PARQUET_CPP_10353_FIXED_VERSION()); |
| 262 | |
| 263 | // Column is encrypted only if crypto_metadata exists. |
| 264 | if (!crypto_metadata) { |
| 265 | return PageReader::Open(stream, col->num_values(), col->compression(), properties_, |
| 266 | always_compressed); |
| 267 | } |
| 268 | |
| 269 | // The column is encrypted |
| 270 | auto* file_decryptor = file_metadata_->file_decryptor().get(); |
| 271 | auto meta_decryptor_factory = InternalFileDecryptor::GetColumnMetaDecryptorFactory( |
| 272 | file_decryptor, crypto_metadata.get()); |
| 273 | auto data_decryptor_factory = InternalFileDecryptor::GetColumnDataDecryptorFactory( |
| 274 | file_decryptor, crypto_metadata.get()); |
| 275 | |
| 276 | constexpr auto kEncryptedOrdinalLimit = 32767; |
| 277 | if (ARROW_PREDICT_FALSE(row_group_ordinal_ > kEncryptedOrdinalLimit)) { |
| 278 | throw ParquetException("Encrypted files cannot contain more than 32767 row groups"); |
| 279 | } |
| 280 | if (ARROW_PREDICT_FALSE(i > kEncryptedOrdinalLimit)) { |
| 281 | throw ParquetException("Encrypted files cannot contain more than 32767 columns"); |
| 282 | } |
| 283 | |
| 284 | CryptoContext ctx{col->has_dictionary_page(), |
| 285 | static_cast<int16_t>(row_group_ordinal_), static_cast<int16_t>(i), |
| 286 | std::move(meta_decryptor_factory), |
| 287 | std::move(data_decryptor_factory)}; |
| 288 | return PageReader::Open(stream, col->num_values(), col->compression(), properties_, |
| 289 | always_compressed, &ctx); |
| 290 | } |
| 291 | |
| 292 | private: |
| 293 | std::shared_ptr<ArrowInputFile> source_; |
nothing calls this directly
no test coverage detected