| 1 | #pragma once |
| 2 | |
| 3 | #include <Storages/MergeTree/MergeSelector.h> |
| 4 | |
| 5 | |
| 6 | namespace DB |
| 7 | { |
| 8 | |
| 9 | /** Merge selector, which is used to remove values with expired ttl. |
| 10 | * It selects parts to merge by greedy algorithm: |
| 11 | * 1. Finds part with the most earliest expired ttl and includes it to result. |
| 12 | * 2. Tries to find the longest range of parts with expired ttl, that includes part from step 1. |
| 13 | */ |
| 14 | class TTLMergeSelector : public IMergeSelector |
| 15 | { |
| 16 | public: |
| 17 | explicit TTLMergeSelector(time_t current_time_, bool only_drop_parts_) : current_time(current_time_), only_drop_parts(only_drop_parts_) {} |
| 18 | |
| 19 | PartsInPartition select( |
| 20 | const Partitions & partitions, |
| 21 | const size_t max_total_size_to_merge) override; |
| 22 | private: |
| 23 | time_t current_time; |
| 24 | bool only_drop_parts; |
| 25 | }; |
| 26 | |
| 27 | } |
| 28 | |