#pragma once #include namespace DB { class SimpleMergeSelector : public IMergeSelector { public: struct Settings { /** Minimum ratio of size of one part to all parts in set of parts to merge (for usual cases). * For example, if all parts have equal size, it means, that at least 'base' number of parts should be merged. * If parts has non-uniform sizes, then minumum number of parts to merge is effectively increased. * This behaviour balances merge-tree workload. * It called 'base', because merge-tree depth could be estimated as logarithm with that base. */ double base = 8; /** Lower base by 1 after that time. * It will be lowered by 2 after that time * 2^1, * It will be lowered by 3 after that time * 2^2, * and so on, exponentially. */ time_t lower_base_after = 30; size_t lower_base_after_num_parts = 20; /// Zero means unlimited. size_t max_parts_to_merge_at_once = 100; }; SimpleMergeSelector(const Settings & settings) : settings(settings) {} PartsInPartition select( const Partitions & partitions, const size_t max_total_size_to_merge) override; private: const Settings settings; }; }