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

Method WriteLevels

cpp/src/parquet/column_writer.cc:1671–1709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1669 std::shared_ptr<::arrow::Array> preserved_dictionary_;
1670
1671 int64_t WriteLevels(int64_t num_levels, const int16_t* def_levels,
1672 const int16_t* rep_levels) {
1673 // Update histograms now, to maximize cache efficiency.
1674 UpdateLevelHistogram(num_levels, def_levels, rep_levels);
1675
1676 int64_t values_to_write = 0;
1677 // If the field is required and non-repeated, there are no definition levels
1678 if (descr_->max_definition_level() > 0) {
1679 for (int64_t i = 0; i < num_levels; ++i) {
1680 if (def_levels[i] == descr_->max_definition_level()) {
1681 ++values_to_write;
1682 }
1683 }
1684
1685 WriteDefinitionLevels(num_levels, def_levels);
1686 } else {
1687 // Required field, write all values
1688 values_to_write = num_levels;
1689 }
1690
1691 // Not present for non-repeated fields
1692 if (descr_->max_repetition_level() > 0) {
1693 // A row could include more than one value
1694 // Count the occasions where we start a new row
1695 for (int64_t i = 0; i < num_levels; ++i) {
1696 if (rep_levels[i] == 0) {
1697 rows_written_++;
1698 num_buffered_rows_++;
1699 }
1700 }
1701
1702 WriteRepetitionLevels(num_levels, rep_levels);
1703 } else {
1704 // Each value is exactly one row
1705 rows_written_ += num_levels;
1706 num_buffered_rows_ += num_levels;
1707 }
1708 return values_to_write;
1709 }
1710
1711 // This method will always update the three output parameters,
1712 // out_values_to_write, out_spaced_values_to_write and null_count. Additionally

Callers

nothing calls this directly

Calls 1

UpdateLevelHistogramFunction · 0.85

Tested by

no test coverage detected