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

Method GetColumnPageReader

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

Callers

nothing calls this directly

Calls 15

ComputeColumnChunkRangeFunction · 0.85
ParquetExceptionFunction · 0.85
VersionLtMethod · 0.80
writer_versionMethod · 0.80
GetBitFunction · 0.50
ColumnChunkMethod · 0.45
ColumnMethod · 0.45
schemaMethod · 0.45
dataMethod · 0.45
GetStreamMethod · 0.45
crypto_metadataMethod · 0.45
num_valuesMethod · 0.45

Tested by

no test coverage detected