| 635 | } |
| 636 | |
| 637 | std::optional<int64_t> MergeDistinctCount( |
| 638 | std::optional<int64_t> initial, |
| 639 | const std::vector<std::optional<int64_t>>& subsequent) { |
| 640 | EncodedStatistics encoded_statistics; |
| 641 | if (initial) { |
| 642 | encoded_statistics.has_distinct_count = true; |
| 643 | encoded_statistics.distinct_count = *initial; |
| 644 | } |
| 645 | std::shared_ptr<TypedStatistics<TestType>> statistics = |
| 646 | std::dynamic_pointer_cast<TypedStatistics<TestType>>( |
| 647 | Statistics::Make(this->schema_.Column(0), &encoded_statistics, |
| 648 | /*num_values=*/1000)); |
| 649 | for (const auto& distinct_count : subsequent) { |
| 650 | EncodedStatistics next_encoded_statistics; |
| 651 | if (distinct_count) { |
| 652 | next_encoded_statistics.has_distinct_count = true; |
| 653 | next_encoded_statistics.distinct_count = *distinct_count; |
| 654 | } |
| 655 | std::shared_ptr<TypedStatistics<TestType>> next_statistics = |
| 656 | std::dynamic_pointer_cast<TypedStatistics<TestType>>( |
| 657 | Statistics::Make(this->schema_.Column(0), &next_encoded_statistics, |
| 658 | /*num_values=*/1000)); |
| 659 | statistics->Merge(*next_statistics); |
| 660 | } |
| 661 | EncodedStatistics final_statistics = statistics->Encode(); |
| 662 | EXPECT_EQ(statistics->HasDistinctCount(), final_statistics.has_distinct_count); |
| 663 | if (statistics->HasDistinctCount()) { |
| 664 | EXPECT_EQ(statistics->distinct_count(), final_statistics.distinct_count); |
| 665 | return statistics->distinct_count(); |
| 666 | } |
| 667 | return std::nullopt; |
| 668 | } |
| 669 | |
| 670 | std::shared_ptr<TypedStatistics<TestType>> MergedStatistics( |
| 671 | const TypedStatistics<TestType>& stats1, const TypedStatistics<TestType>& stats2) { |
nothing calls this directly
no test coverage detected