| 1109 | } |
| 1110 | |
| 1111 | int64_t ColumnWriterImpl::Close() { |
| 1112 | if (!closed_) { |
| 1113 | closed_ = true; |
| 1114 | if (has_dictionary_ && !fallback_) { |
| 1115 | WriteDictionaryPage(); |
| 1116 | } |
| 1117 | |
| 1118 | FlushBufferedDataPages(); |
| 1119 | |
| 1120 | auto [chunk_statistics, chunk_size_statistics] = GetChunkStatistics(); |
| 1121 | chunk_statistics.ApplyStatSizeLimits( |
| 1122 | properties_->max_statistics_size(descr_->path())); |
| 1123 | chunk_statistics.set_is_signed(SortOrder::SIGNED == descr_->sort_order()); |
| 1124 | |
| 1125 | // Write stats only if the column has at least one row written |
| 1126 | if (rows_written_ > 0 && chunk_statistics.is_set()) { |
| 1127 | metadata_->SetStatistics(chunk_statistics); |
| 1128 | } |
| 1129 | |
| 1130 | if (rows_written_ > 0 && chunk_size_statistics.is_set()) { |
| 1131 | metadata_->SetSizeStatistics(chunk_size_statistics); |
| 1132 | } |
| 1133 | |
| 1134 | if (descr_->logical_type() != nullptr && descr_->logical_type()->is_geometry()) { |
| 1135 | std::optional<geospatial::EncodedGeoStatistics> geo_stats = GetChunkGeoStatistics(); |
| 1136 | if (geo_stats) { |
| 1137 | metadata_->SetGeoStatistics(std::move(*geo_stats)); |
| 1138 | } |
| 1139 | } |
| 1140 | |
| 1141 | metadata_->SetKeyValueMetadata(key_value_metadata_); |
| 1142 | pager_->Close(has_dictionary_, fallback_); |
| 1143 | } |
| 1144 | |
| 1145 | return total_bytes_written_; |
| 1146 | } |
| 1147 | |
| 1148 | void ColumnWriterImpl::FlushBufferedDataPages() { |
| 1149 | // Write all outstanding data to a new page |
nothing calls this directly
no test coverage detected