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

Method BuildDataPageV1

cpp/src/parquet/column_writer.cc:1005–1049  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1003}
1004
1005void ColumnWriterImpl::BuildDataPageV1(int64_t definition_levels_rle_size,
1006 int64_t repetition_levels_rle_size,
1007 int64_t uncompressed_size,
1008 const std::shared_ptr<Buffer>& values) {
1009 // Use Arrow::Buffer::shrink_to_fit = false
1010 // underlying buffer only keeps growing. Resize to a smaller size does not reallocate.
1011 PARQUET_THROW_NOT_OK(uncompressed_data_->Resize(uncompressed_size, false));
1012 ConcatenateBuffers(definition_levels_rle_size, repetition_levels_rle_size, values,
1013 uncompressed_data_->mutable_data());
1014 auto [page_stats, page_size_stats] = GetPageStatistics();
1015 page_stats.ApplyStatSizeLimits(properties_->max_statistics_size(descr_->path()));
1016 page_stats.set_is_signed(SortOrder::SIGNED == descr_->sort_order());
1017 ResetPageStatistics();
1018
1019 std::shared_ptr<Buffer> compressed_data;
1020 if (pager_->has_compressor()) {
1021 pager_->Compress(*(uncompressed_data_.get()), compressor_temp_buffer_.get());
1022 compressed_data = compressor_temp_buffer_;
1023 } else {
1024 compressed_data = uncompressed_data_;
1025 }
1026
1027 int32_t num_values = static_cast<int32_t>(num_buffered_values_);
1028 int64_t first_row_index = rows_written_ - num_buffered_rows_;
1029
1030 // Write the page to OutputStream eagerly if there is no dictionary or
1031 // if dictionary encoding has fallen back to PLAIN
1032 if (has_dictionary_ && !fallback_) { // Save pages until end of dictionary encoding
1033 PARQUET_ASSIGN_OR_THROW(
1034 auto compressed_data_copy,
1035 compressed_data->CopySlice(0, compressed_data->size(), allocator_));
1036 std::unique_ptr<DataPage> page_ptr = std::make_unique<DataPageV1>(
1037 compressed_data_copy, num_values, encoding_, Encoding::RLE, Encoding::RLE,
1038 uncompressed_size, std::move(page_stats), first_row_index,
1039 std::move(page_size_stats));
1040 total_compressed_bytes_ += page_ptr->size() + sizeof(format::PageHeader);
1041
1042 data_pages_.push_back(std::move(page_ptr));
1043 } else { // Eagerly write pages
1044 DataPageV1 page(compressed_data, num_values, encoding_, Encoding::RLE, Encoding::RLE,
1045 uncompressed_size, std::move(page_stats), first_row_index,
1046 std::move(page_size_stats));
1047 WriteDataPage(page);
1048 }
1049}
1050
1051void ColumnWriterImpl::BuildDataPageV2(int64_t definition_levels_rle_size,
1052 int64_t repetition_levels_rle_size,

Callers

nothing calls this directly

Calls 10

ConcatenateBuffersFunction · 0.85
push_backMethod · 0.80
ResizeMethod · 0.45
mutable_dataMethod · 0.45
pathMethod · 0.45
sort_orderMethod · 0.45
has_compressorMethod · 0.45
CompressMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected