| 375 | } |
| 376 | |
| 377 | void TopicChunkBuilder::computeBulkStringStats(std::size_t col_index, std::size_t first_row, std::size_t count) { |
| 378 | if (count == 0) { |
| 379 | return; |
| 380 | } |
| 381 | |
| 382 | auto& cs = stats_.column_stats[col_index]; |
| 383 | const auto& col = columns_[col_index]; |
| 384 | const bool has_validity = col.hasNulls(); |
| 385 | |
| 386 | std::optional<std::string_view> last_valid; |
| 387 | |
| 388 | if (first_row > 0 && cs.run_count > 0) { |
| 389 | for (std::size_t j = first_row; j > 0; --j) { |
| 390 | if (!has_validity || col.isValid(j - 1)) { |
| 391 | last_valid = col.readString(j - 1); |
| 392 | break; |
| 393 | } |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | for (std::size_t i = 0; i < count; ++i) { |
| 398 | const std::size_t row = first_row + i; |
| 399 | if (has_validity && !col.isValid(row)) { |
| 400 | cs.null_count++; |
| 401 | continue; |
| 402 | } |
| 403 | |
| 404 | std::string_view current = col.readString(row); |
| 405 | if (!last_valid.has_value()) { |
| 406 | cs.run_count = 1; |
| 407 | } else if (current != *last_valid) { |
| 408 | cs.is_constant = false; |
| 409 | cs.run_count++; |
| 410 | } |
| 411 | last_valid = current; |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | bool TopicChunkBuilder::isFull() const noexcept { |
| 416 | return rowCount() >= max_rows_; |
nothing calls this directly
no test coverage detected