ClickHouse/dbms/Storages/MergeTree/MergeTreeIndexGranularityInfo.h

55 lines
1.6 KiB
C++
Raw Normal View History

2019-06-19 10:07:56 +00:00
#pragma once
#include <optional>
#include <Core/Types.h>
2020-01-14 13:23:51 +00:00
#include <Storages/MergeTree/MergeTreeDataPartType.h>
#include <Disks/IDisk.h>
2019-06-19 10:07:56 +00:00
namespace DB
{
2019-06-19 14:46:06 +00:00
class MergeTreeData;
2019-10-11 15:37:16 +00:00
2019-06-19 10:07:56 +00:00
/// Meta information about index granularity
struct MergeTreeIndexGranularityInfo
{
public:
/// Marks file extension '.mrk' or '.mrk2'
String marks_file_extension;
/// Is stride in rows between marks non fixed?
2019-11-21 16:10:22 +00:00
bool is_adaptive = false;
2019-06-19 10:07:56 +00:00
/// Fixed size in rows of one granule if index_granularity_bytes is zero
2019-11-21 16:10:22 +00:00
size_t fixed_index_granularity = 0;
2019-06-19 10:07:56 +00:00
/// Approximate bytes size of one granule
2019-11-21 16:10:22 +00:00
size_t index_granularity_bytes = 0;
2020-01-14 13:23:51 +00:00
MergeTreeIndexGranularityInfo(const MergeTreeData & storage, MergeTreeDataPartType type_);
2019-11-21 16:10:22 +00:00
void changeGranularityIfRequired(const DiskPtr & disk, const String & path_to_part);
2019-06-19 10:07:56 +00:00
2019-10-11 15:37:16 +00:00
String getMarksFilePath(const String & path_prefix) const
2019-06-19 10:07:56 +00:00
{
2019-10-11 15:37:16 +00:00
return path_prefix + marks_file_extension;
2019-06-19 10:07:56 +00:00
}
2020-01-14 13:23:51 +00:00
size_t getMarkSizeInBytes(size_t columns_num = 1) const;
2020-03-10 14:39:30 +00:00
static std::optional<std::string> getMarksExtensionFromFilesystem(const DiskPtr & disk, const String & path_to_part);
2019-11-21 16:10:22 +00:00
private:
2020-01-14 13:23:51 +00:00
MergeTreeDataPartType type;
void setAdaptive(size_t index_granularity_bytes_);
2019-06-19 10:07:56 +00:00
void setNonAdaptive();
};
constexpr inline auto getNonAdaptiveMrkExtension() { return ".mrk"; }
2020-01-14 13:23:51 +00:00
constexpr inline auto getNonAdaptiveMrkSizeWide() { return sizeof(UInt64) * 2; }
constexpr inline auto getAdaptiveMrkSizeWide() { return sizeof(UInt64) * 3; }
2020-02-03 12:08:40 +00:00
inline size_t getAdaptiveMrkSizeCompact(size_t columns_num);
std::string getAdaptiveMrkExtension(MergeTreeDataPartType part_type);
2019-06-19 10:07:56 +00:00
}