| 702 | } |
| 703 | |
| 704 | std::optional<int64_t> MergeDistinctCount( |
| 705 | std::optional<int64_t> initial, |
| 706 | const std::vector<std::optional<int64_t>>& subsequent) { |
| 707 | EncodedStatistics encoded_statistics; |
| 708 | if (initial) { |
| 709 | encoded_statistics.has_distinct_count = true; |
| 710 | encoded_statistics.distinct_count = *initial; |
| 711 | } |
| 712 | std::shared_ptr<TypedStatistics<TestType>> statistics = |
| 713 | std::dynamic_pointer_cast<TypedStatistics<TestType>>( |
| 714 | Statistics::Make(this->schema_.Column(0), &encoded_statistics, |
| 715 | /*num_values=*/1000)); |
| 716 | for (const auto& distinct_count : subsequent) { |
| 717 | EncodedStatistics next_encoded_statistics; |
| 718 | if (distinct_count) { |
| 719 | next_encoded_statistics.has_distinct_count = true; |
| 720 | next_encoded_statistics.distinct_count = *distinct_count; |
| 721 | } |
| 722 | std::shared_ptr<TypedStatistics<TestType>> next_statistics = |
| 723 | std::dynamic_pointer_cast<TypedStatistics<TestType>>( |
| 724 | Statistics::Make(this->schema_.Column(0), &next_encoded_statistics, |
| 725 | /*num_values=*/1000)); |
| 726 | statistics->Merge(*next_statistics); |
| 727 | } |
| 728 | EncodedStatistics final_statistics = statistics->Encode(); |
| 729 | EXPECT_EQ(statistics->HasDistinctCount(), final_statistics.has_distinct_count); |
| 730 | if (statistics->HasDistinctCount()) { |
| 731 | EXPECT_EQ(statistics->distinct_count(), final_statistics.distinct_count); |
| 732 | return statistics->distinct_count(); |
| 733 | } |
| 734 | return std::nullopt; |
| 735 | } |
| 736 | |
| 737 | std::shared_ptr<TypedStatistics<TestType>> MergedStatistics( |
| 738 | const TypedStatistics<TestType>& stats1, const TypedStatistics<TestType>& stats2) { |
nothing calls this directly
no test coverage detected