2019-10-10 16:30:30 +00:00
|
|
|
#pragma once
|
2019-12-18 16:41:11 +00:00
|
|
|
#include <cstddef>
|
2019-11-07 11:11:38 +00:00
|
|
|
#include <Core/Settings.h>
|
2020-12-07 12:47:51 +00:00
|
|
|
#include <Storages/MergeTree/MergeTreeSettings.h>
|
2022-03-21 11:30:25 +00:00
|
|
|
#include <IO/WriteSettings.h>
|
2022-08-29 17:09:58 +00:00
|
|
|
#include <Parsers/ExpressionElementParsers.h>
|
|
|
|
#include <Parsers/parseQuery.h>
|
2019-10-10 16:30:30 +00:00
|
|
|
|
2021-03-28 01:10:30 +00:00
|
|
|
|
2019-10-10 16:30:30 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2019-11-07 11:11:38 +00:00
|
|
|
|
2021-03-28 19:24:28 +00:00
|
|
|
class MMappedFileCache;
|
|
|
|
using MMappedFileCachePtr = std::shared_ptr<MMappedFileCache>;
|
2021-03-28 01:10:30 +00:00
|
|
|
|
|
|
|
|
2019-12-18 15:54:45 +00:00
|
|
|
struct MergeTreeReaderSettings
|
2019-11-05 11:53:22 +00:00
|
|
|
{
|
2021-08-24 21:45:58 +00:00
|
|
|
/// Common read settings.
|
|
|
|
ReadSettings read_settings;
|
2020-06-25 19:15:41 +00:00
|
|
|
/// If save_marks_in_cache is false, then, if marks are not in cache,
|
2020-01-16 16:15:01 +00:00
|
|
|
/// we will load them but won't save in the cache, to avoid evicting other data.
|
2019-11-05 11:53:22 +00:00
|
|
|
bool save_marks_in_cache = false;
|
2021-01-25 20:29:04 +00:00
|
|
|
/// Validate checksums on reading (should be always enabled in production).
|
|
|
|
bool checksum_on_read = true;
|
2022-03-22 14:30:40 +00:00
|
|
|
/// True if we read in order of sorting key.
|
|
|
|
bool read_in_order = false;
|
2022-07-21 07:32:29 +00:00
|
|
|
/// Deleted mask is applied to all reads except internal select from mutate some part columns.
|
|
|
|
bool apply_deleted_mask = true;
|
2019-11-05 11:53:22 +00:00
|
|
|
};
|
|
|
|
|
2019-12-18 15:54:45 +00:00
|
|
|
struct MergeTreeWriterSettings
|
2019-11-05 11:53:22 +00:00
|
|
|
{
|
2020-04-14 19:47:19 +00:00
|
|
|
MergeTreeWriterSettings() = default;
|
|
|
|
|
2020-12-07 12:47:51 +00:00
|
|
|
MergeTreeWriterSettings(
|
|
|
|
const Settings & global_settings,
|
2022-03-21 11:30:25 +00:00
|
|
|
const WriteSettings & query_write_settings_,
|
2020-12-07 12:47:51 +00:00
|
|
|
const MergeTreeSettingsPtr & storage_settings,
|
|
|
|
bool can_use_adaptive_granularity_,
|
2020-12-11 08:41:02 +00:00
|
|
|
bool rewrite_primary_key_,
|
2020-12-07 12:47:51 +00:00
|
|
|
bool blocks_are_granules_size_ = false)
|
|
|
|
: min_compress_block_size(
|
|
|
|
storage_settings->min_compress_block_size ? storage_settings->min_compress_block_size : global_settings.min_compress_block_size)
|
|
|
|
, max_compress_block_size(
|
|
|
|
storage_settings->max_compress_block_size ? storage_settings->max_compress_block_size
|
|
|
|
: global_settings.max_compress_block_size)
|
2022-05-29 07:28:02 +00:00
|
|
|
, marks_compression_codec(storage_settings->marks_compression_codec)
|
|
|
|
, marks_compress_block_size(storage_settings->marks_compress_block_size)
|
2022-08-28 02:19:14 +00:00
|
|
|
, compress_primary_key(storage_settings->compress_primary_key)
|
2022-05-29 07:28:02 +00:00
|
|
|
, primary_key_compression_codec(storage_settings->primary_key_compression_codec)
|
|
|
|
, primary_key_compress_block_size(storage_settings->primary_key_compress_block_size)
|
2019-11-05 11:53:22 +00:00
|
|
|
, can_use_adaptive_granularity(can_use_adaptive_granularity_)
|
2020-12-09 18:19:49 +00:00
|
|
|
, rewrite_primary_key(rewrite_primary_key_)
|
2020-12-07 12:47:51 +00:00
|
|
|
, blocks_are_granules_size(blocks_are_granules_size_)
|
2022-03-21 11:30:25 +00:00
|
|
|
, query_write_settings(query_write_settings_)
|
2020-12-07 12:47:51 +00:00
|
|
|
{
|
|
|
|
}
|
2019-11-05 11:53:22 +00:00
|
|
|
|
2022-08-29 17:09:58 +00:00
|
|
|
CompressionCodecPtr getMarksCompressionCodec() const
|
|
|
|
{
|
|
|
|
ParserCodec codec_parser;
|
|
|
|
auto ast = parseQuery(codec_parser, "(" + Poco::toUpper(marks_compression_codec) + ")", 0, DBMS_DEFAULT_MAX_PARSER_DEPTH);
|
|
|
|
return CompressionCodecFactory::instance().get(ast, nullptr);
|
|
|
|
}
|
|
|
|
|
2019-11-05 11:53:22 +00:00
|
|
|
size_t min_compress_block_size;
|
|
|
|
size_t max_compress_block_size;
|
2022-05-29 07:28:02 +00:00
|
|
|
|
|
|
|
String marks_compression_codec;
|
|
|
|
size_t marks_compress_block_size;
|
|
|
|
|
2022-08-28 02:19:14 +00:00
|
|
|
bool compress_primary_key;
|
2022-05-29 07:28:02 +00:00
|
|
|
String primary_key_compression_codec;
|
|
|
|
size_t primary_key_compress_block_size;
|
|
|
|
|
2019-11-05 11:53:22 +00:00
|
|
|
bool can_use_adaptive_granularity;
|
2020-12-09 18:19:49 +00:00
|
|
|
bool rewrite_primary_key;
|
2019-11-05 11:53:22 +00:00
|
|
|
bool blocks_are_granules_size;
|
2022-03-21 11:30:25 +00:00
|
|
|
WriteSettings query_write_settings;
|
2019-11-05 11:53:22 +00:00
|
|
|
};
|
2020-04-14 19:47:19 +00:00
|
|
|
|
2019-10-10 16:30:30 +00:00
|
|
|
}
|