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

Method WriteLevels

cpp/src/parquet/column_writer.cc:1670–1708  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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