| 1 | #pragma once | 
|---|
| 2 |  | 
|---|
| 3 | #include <optional> | 
|---|
| 4 | #include <Core/Types.h> | 
|---|
| 5 |  | 
|---|
| 6 | namespace DB | 
|---|
| 7 | { | 
|---|
| 8 |  | 
|---|
| 9 | class MergeTreeData; | 
|---|
| 10 | /// Meta information about index granularity | 
|---|
| 11 | struct MergeTreeIndexGranularityInfo | 
|---|
| 12 | { | 
|---|
| 13 | public: | 
|---|
| 14 | /// Marks file extension '.mrk' or '.mrk2' | 
|---|
| 15 | String marks_file_extension; | 
|---|
| 16 |  | 
|---|
| 17 | /// Size of one mark in file two or three size_t numbers | 
|---|
| 18 | UInt8 mark_size_in_bytes; | 
|---|
| 19 |  | 
|---|
| 20 | /// Is stride in rows between marks non fixed? | 
|---|
| 21 | bool is_adaptive; | 
|---|
| 22 |  | 
|---|
| 23 | /// Fixed size in rows of one granule if index_granularity_bytes is zero | 
|---|
| 24 | size_t fixed_index_granularity; | 
|---|
| 25 |  | 
|---|
| 26 | /// Approximate bytes size of one granule | 
|---|
| 27 | size_t index_granularity_bytes; | 
|---|
| 28 |  | 
|---|
| 29 | MergeTreeIndexGranularityInfo( | 
|---|
| 30 | const MergeTreeData & storage); | 
|---|
| 31 |  | 
|---|
| 32 | void changeGranularityIfRequired(const std::string & path_to_part); | 
|---|
| 33 |  | 
|---|
| 34 | String getMarksFilePath(const String & column_path) const | 
|---|
| 35 | { | 
|---|
| 36 | return column_path + marks_file_extension; | 
|---|
| 37 | } | 
|---|
| 38 | private: | 
|---|
| 39 |  | 
|---|
| 40 | void setAdaptive(size_t index_granularity_bytes_); | 
|---|
| 41 | void setNonAdaptive(); | 
|---|
| 42 | std::optional<std::string> getMrkExtensionFromFS(const std::string & path_to_table) const; | 
|---|
| 43 | }; | 
|---|
| 44 |  | 
|---|
| 45 | constexpr inline auto getNonAdaptiveMrkExtension() { return ".mrk"; } | 
|---|
| 46 | constexpr inline auto getAdaptiveMrkExtension() { return ".mrk2"; } | 
|---|
| 47 | constexpr inline auto getNonAdaptiveMrkSize() { return sizeof(UInt64) * 2; } | 
|---|
| 48 | constexpr inline auto getAdaptiveMrkSize() { return sizeof(UInt64) * 3; } | 
|---|
| 49 |  | 
|---|
| 50 | } | 
|---|
| 51 |  | 
|---|