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

Method BuildDataPageV1

cpp/src/parquet/column_writer.cc:1004–1048  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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