2019-04-15 09:30:45 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Storages/MergeTree/MergeSelector.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
/** Merge selector, which is used to remove values with expired ttl.
|
|
|
|
* It selects parts to merge by greedy algorithm:
|
|
|
|
* 1. Finds part with the most earliest expired ttl and includes it to result.
|
|
|
|
* 2. Tries to find the longest range of parts with expired ttl, that includes part from step 1.
|
|
|
|
*/
|
|
|
|
class TTLMergeSelector : public IMergeSelector
|
|
|
|
{
|
|
|
|
public:
|
2019-07-28 10:30:46 +00:00
|
|
|
explicit TTLMergeSelector(time_t current_time_, bool only_drop_parts_) : current_time(current_time_), only_drop_parts(only_drop_parts_) {}
|
2019-04-15 09:30:45 +00:00
|
|
|
|
|
|
|
PartsInPartition select(
|
|
|
|
const Partitions & partitions,
|
|
|
|
const size_t max_total_size_to_merge) override;
|
|
|
|
private:
|
|
|
|
time_t current_time;
|
2019-07-28 10:30:46 +00:00
|
|
|
bool only_drop_parts;
|
2019-04-15 09:30:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|