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

Method GetColumnPageReader

cpp/src/parquet/file_reader.cc:239–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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_;

Callers

nothing calls this directly

Calls 13

ComputeColumnChunkRangeFunction · 0.85
ParquetExceptionFunction · 0.85
VersionLtMethod · 0.80
writer_versionMethod · 0.80
GetBitFunction · 0.50
ColumnChunkMethod · 0.45
dataMethod · 0.45
GetStreamMethod · 0.45
crypto_metadataMethod · 0.45
num_valuesMethod · 0.45
compressionMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected