-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Expand file tree
/
Copy pathSettings.h
More file actions
180 lines (159 loc) · 6.4 KB
/
Settings.h
File metadata and controls
180 lines (159 loc) · 6.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#pragma once
#include <Core/BaseSettingsFwdMacros.h>
#include <Core/Field.h>
#include <Core/SettingsEnums.h>
#include <Core/SettingsFields.h>
#include <Core/SettingsTierType.h>
#include <Core/SettingsWriteFormat.h>
#include <base/types.h>
#include <Common/SettingsChanges.h>
#include <string_view>
#include <unordered_map>
#include <vector>
namespace boost
{
namespace program_options
{
class options_description;
class variables_map;
}
}
namespace Poco
{
namespace Util
{
class AbstractConfiguration;
class LayeredConfiguration;
}
}
using NameToNameMap = std::unordered_map<std::string, std::string>;
namespace DB
{
class IColumn;
struct MutableColumnsAndConstraints;
class ReadBuffer;
struct SettingsImpl;
class WriteBuffer;
/// List of available types supported in Settings object (!= MergeTreeSettings, MySQLSettings, etc)
#define COMMON_SETTINGS_SUPPORTED_TYPES(CLASS_NAME, M) \
M(CLASS_NAME, AggregateFunctionInputFormat) \
M(CLASS_NAME, ArrowCompression) \
M(CLASS_NAME, ArrowFlightDescriptorType) \
M(CLASS_NAME, Bool) \
M(CLASS_NAME, BoolAuto) \
M(CLASS_NAME, CapnProtoEnumComparingMode) \
M(CLASS_NAME, Char) \
M(CLASS_NAME, DateTimeInputFormat) \
M(CLASS_NAME, DateTimeOutputFormat) \
M(CLASS_NAME, DateTimeOverflowBehavior) \
M(CLASS_NAME, DefaultDatabaseEngine) \
M(CLASS_NAME, DefaultTableEngine) \
M(CLASS_NAME, Dialect) \
M(CLASS_NAME, DistributedCacheLogMode) /* Cloud only */ \
M(CLASS_NAME, DistributedCachePoolBehaviourOnLimit) /* Cloud only */ \
M(CLASS_NAME, DistributedDDLOutputMode) \
M(CLASS_NAME, DistributedProductMode) \
M(CLASS_NAME, Double) \
M(CLASS_NAME, EscapingRule) \
M(CLASS_NAME, Float) \
M(CLASS_NAME, FloatAuto) \
M(CLASS_NAME, IcebergMetadataLogLevel) \
M(CLASS_NAME, IdentifierQuotingRule) \
M(CLASS_NAME, IdentifierQuotingStyle) \
M(CLASS_NAME, Int32) \
M(CLASS_NAME, Int64) \
M(CLASS_NAME, IntervalOutputFormat) \
M(CLASS_NAME, JoinAlgorithm) \
M(CLASS_NAME, JoinStrictness) \
M(CLASS_NAME, JemallocProfileFormat) \
M(CLASS_NAME, LightweightMutationProjectionMode) \
M(CLASS_NAME, LightweightDeleteMode) \
M(CLASS_NAME, AlterUpdateMode) \
M(CLASS_NAME, UpdateParallelMode) \
M(CLASS_NAME, LoadBalancing) \
M(CLASS_NAME, LocalFSReadMethod) \
M(CLASS_NAME, LogQueriesType) \
M(CLASS_NAME, LogsLevel) \
M(CLASS_NAME, Map) \
M(CLASS_NAME, MaxThreads) \
M(CLASS_NAME, Milliseconds) \
M(CLASS_NAME, MsgPackUUIDRepresentation) \
M(CLASS_NAME, MySQLDataTypesSupport) \
M(CLASS_NAME, NonZeroUInt64) \
M(CLASS_NAME, ORCCompression) \
M(CLASS_NAME, OverflowMode) \
M(CLASS_NAME, OverflowModeGroupBy) \
M(CLASS_NAME, ParallelReplicasMode) \
M(CLASS_NAME, ParallelReplicasCustomKeyFilterType) \
M(CLASS_NAME, ParquetCompression) \
M(CLASS_NAME, ParquetVersion) \
M(CLASS_NAME, QueryResultCacheNondeterministicFunctionHandling) \
M(CLASS_NAME, QueryResultCacheSystemTableHandling) \
M(CLASS_NAME, SchemaInferenceMode) \
M(CLASS_NAME, Seconds) \
M(CLASS_NAME, SetOperationMode) \
M(CLASS_NAME, ShortCircuitFunctionEvaluation) \
M(CLASS_NAME, SQLSecurityType) \
M(CLASS_NAME, StreamingHandleErrorMode) \
M(CLASS_NAME, String) \
M(CLASS_NAME, Timezone) \
M(CLASS_NAME, TotalsMode) \
M(CLASS_NAME, TransactionsWaitCSNMode) \
M(CLASS_NAME, UInt64) \
M(CLASS_NAME, UInt64Auto) \
M(CLASS_NAME, URI) \
M(CLASS_NAME, VectorSearchFilterStrategy) \
M(CLASS_NAME, GeoToH3ArgumentOrder) \
M(CLASS_NAME, ObjectStorageGranularityLevel) \
M(CLASS_NAME, DecorrelationJoinKind) \
M(CLASS_NAME, JoinOrderAlgorithm) \
M(CLASS_NAME, DeduplicateInsertSelectMode) \
M(CLASS_NAME, DeduplicateInsertMode) \
COMMON_SETTINGS_SUPPORTED_TYPES(Settings, DECLARE_SETTING_TRAIT)
struct Settings
{
Settings();
Settings(const Settings & settings);
Settings(Settings && settings) noexcept;
~Settings();
Settings & operator=(const Settings & other);
bool operator==(const Settings & other) const;
COMMON_SETTINGS_SUPPORTED_TYPES(Settings, DECLARE_SETTING_SUBSCRIPT_OPERATOR)
/// General API as needed
bool has(std::string_view name) const;
bool isChanged(std::string_view name) const;
SettingsTierType getTier(std::string_view name) const;
bool tryGet(std::string_view name, Field & value) const;
Field get(std::string_view name) const;
void set(std::string_view name, const Field & value);
void setDefaultValue(std::string_view name);
std::vector<String> getHints(const String & name) const;
String toString() const;
SettingsChanges changes() const;
void applyChanges(const SettingsChanges & changes);
std::vector<std::string_view> getAllRegisteredNames() const;
std::vector<std::string_view> getAllAliasNames() const;
std::vector<std::string_view> getChangedAndObsoleteNames() const;
std::vector<std::string_view> getUnchangedNames() const;
void dumpToSystemSettingsColumns(MutableColumnsAndConstraints & params) const;
void dumpToMapColumn(IColumn * column, bool changed_only = true) const;
NameToNameMap toNameToNameMap() const;
void write(WriteBuffer & out, SettingsWriteFormat format = SettingsWriteFormat::DEFAULT) const;
void read(ReadBuffer & in, SettingsWriteFormat format = SettingsWriteFormat::DEFAULT);
/// Equivalent to Settings().write(out, <any format>) but faster.
static void writeEmpty(WriteBuffer & out);
void addToProgramOptions(boost::program_options::options_description & options);
void addToProgramOptions(std::string_view setting_name, boost::program_options::options_description & options);
void addToProgramOptionsAsMultitokens(boost::program_options::options_description & options) const;
void addToClientOptions(
Poco::Util::LayeredConfiguration & config, const boost::program_options::variables_map & options, bool repeated_settings) const;
static Field castValueUtil(std::string_view name, const Field & value);
static String valueToStringUtil(std::string_view name, const Field & value);
static Field stringToValueUtil(std::string_view name, const String & str);
static bool hasBuiltin(std::string_view name);
static std::string_view resolveName(std::string_view name);
static void checkNoSettingNamesAtTopLevel(const Poco::Util::AbstractConfiguration & config, const String & config_path);
private:
std::unique_ptr<SettingsImpl> impl;
};
}