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

Method GetInternal

cpp/src/parquet/decoder.cc:1653–1733  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1651 }
1652
1653 int GetInternal(T* buffer, int max_values) {
1654 max_values = static_cast<int>(std::min<int64_t>(max_values, total_values_remaining_));
1655 if (max_values == 0) {
1656 return 0;
1657 }
1658
1659 int i = 0;
1660
1661 if (ARROW_PREDICT_FALSE(!first_block_initialized_)) {
1662 // This is the first time we decode this data page, first output the
1663 // last value and initialize the first block.
1664 buffer[i++] = last_value_;
1665 if (ARROW_PREDICT_FALSE(i == max_values)) {
1666 // When i reaches max_values here we have two different possibilities:
1667 // 1. total_value_count_ == 1, which means that the page may have only
1668 // one value (encoded in the header), and we should not initialize
1669 // any block, nor should we skip any padding bits below.
1670 // 2. total_value_count_ != 1, which means we should initialize the
1671 // incoming block for subsequent reads.
1672 if (total_value_count_ != 1) {
1673 InitBlock();
1674 }
1675 total_values_remaining_ -= max_values;
1676 this->num_values_ -= max_values;
1677 return max_values;
1678 }
1679 InitBlock();
1680 }
1681
1682 DCHECK(first_block_initialized_);
1683 while (i < max_values) {
1684 // Ensure we have an initialized mini-block
1685 if (ARROW_PREDICT_FALSE(values_remaining_current_mini_block_ == 0)) {
1686 ++mini_block_idx_;
1687 if (mini_block_idx_ < mini_blocks_per_block_) {
1688 InitMiniBlock(delta_bit_widths_->data()[mini_block_idx_]);
1689 } else {
1690 InitBlock();
1691 }
1692 }
1693
1694 int values_decode = std::min(values_remaining_current_mini_block_,
1695 static_cast<uint32_t>(max_values - i));
1696 if (delta_bit_width_ == 0) {
1697 // Fast path that avoids a back-to-back dependency between two consecutive
1698 // computations: we know all deltas decode to zero. We actually don't
1699 // even need to decode them.
1700 for (int j = 0; j < values_decode; ++j) {
1701 buffer[i + j] = static_cast<UT>(last_value_) +
1702 static_cast<UT>(j + 1) * static_cast<UT>(min_delta_);
1703 }
1704 last_value_ += static_cast<UT>(values_decode) * static_cast<UT>(min_delta_);
1705 } else {
1706 if (decoder_->GetBatch(delta_bit_width_, buffer + i, values_decode) !=
1707 values_decode) {
1708 ParquetException::EofException();
1709 }
1710 for (int j = 0; j < values_decode; ++j) {

Callers

nothing calls this directly

Calls 3

dataMethod · 0.45
GetBatchMethod · 0.45
AdvanceMethod · 0.45

Tested by

no test coverage detected