diff --git a/base/base/StringRef.h b/base/base/StringRef.h index 171861e9ba7..f300a2d63df 100644 --- a/base/base/StringRef.h +++ b/base/base/StringRef.h @@ -46,9 +46,9 @@ struct StringRef constexpr StringRef(const char * data_, size_t size_) : data(data_), size(size_) {} - StringRef(const std::string & s) : data(s.data()), size(s.size()) {} + StringRef(const std::string & s) : data(s.data()), size(s.size()) {} /// NOLINT constexpr explicit StringRef(std::string_view s) : data(s.data()), size(s.size()) {} - constexpr StringRef(const char * data_) : StringRef(std::string_view{data_}) {} + constexpr StringRef(const char * data_) : StringRef(std::string_view{data_}) {} /// NOLINT constexpr StringRef() = default; std::string toString() const { return std::string(data, size); } diff --git a/src/Access/AccessRights.h b/src/Access/AccessRights.h index e71b409b7b6..ef5995ad9a5 100644 --- a/src/Access/AccessRights.h +++ b/src/Access/AccessRights.h @@ -15,7 +15,7 @@ class AccessRights { public: AccessRights(); - AccessRights(const AccessFlags & access); + explicit AccessRights(const AccessFlags & access); ~AccessRights(); AccessRights(const AccessRights & src); AccessRights & operator =(const AccessRights & src); diff --git a/src/Access/Common/AccessFlags.h b/src/Access/Common/AccessFlags.h index 5a5452c50ea..51bf3cd19b0 100644 --- a/src/Access/Common/AccessFlags.h +++ b/src/Access/Common/AccessFlags.h @@ -15,17 +15,17 @@ using Strings = std::vector; class AccessFlags { public: - AccessFlags(AccessType type); + AccessFlags(AccessType type); /// NOLINT /// The same as AccessFlags(AccessType::NONE). AccessFlags() = default; /// Constructs from a string like "SELECT". - AccessFlags(const std::string_view & keyword); + AccessFlags(const std::string_view & keyword); /// NOLINT /// Constructs from a list of strings like "SELECT, UPDATE, INSERT". - AccessFlags(const std::vector & keywords); - AccessFlags(const Strings & keywords); + AccessFlags(const std::vector & keywords); /// NOLINT + AccessFlags(const Strings & keywords); /// NOLINT AccessFlags(const AccessFlags & src) = default; AccessFlags(AccessFlags && src) = default; @@ -109,7 +109,7 @@ private: using Flags = std::bitset; Flags flags; - AccessFlags(const Flags & flags_) : flags(flags_) {} + AccessFlags(const Flags & flags_) : flags(flags_) {} /// NOLINT }; AccessFlags operator |(AccessType left, AccessType right); diff --git a/src/Access/Common/AccessRightsElement.h b/src/Access/Common/AccessRightsElement.h index 4fb58b39185..e5bf76d0017 100644 --- a/src/Access/Common/AccessRightsElement.h +++ b/src/Access/Common/AccessRightsElement.h @@ -26,7 +26,7 @@ struct AccessRightsElement AccessRightsElement(AccessRightsElement &&) = default; AccessRightsElement & operator=(AccessRightsElement &&) = default; - AccessRightsElement(AccessFlags access_flags_) : access_flags(access_flags_) {} + explicit AccessRightsElement(AccessFlags access_flags_) : access_flags(access_flags_) {} AccessRightsElement(AccessFlags access_flags_, const std::string_view & database_); AccessRightsElement(AccessFlags access_flags_, const std::string_view & database_, const std::string_view & table_); diff --git a/src/Access/Common/AllowedClientHosts.h b/src/Access/Common/AllowedClientHosts.h index 6a6e3d73eef..ce32663da73 100644 --- a/src/Access/Common/AllowedClientHosts.h +++ b/src/Access/Common/AllowedClientHosts.h @@ -18,7 +18,7 @@ public: class IPSubnet { public: - IPSubnet() {} + IPSubnet() = default; IPSubnet(const IPAddress & prefix_, const IPAddress & mask_) { set(prefix_, mask_); } IPSubnet(const IPAddress & prefix_, size_t num_prefix_bits) { set(prefix_, num_prefix_bits); } explicit IPSubnet(const IPAddress & address) { set(address); } @@ -43,9 +43,9 @@ public: struct AnyHostTag {}; - AllowedClientHosts() {} - AllowedClientHosts(AnyHostTag) { addAnyHost(); } - ~AllowedClientHosts() {} + AllowedClientHosts() = default; + AllowedClientHosts(AnyHostTag) { addAnyHost(); } /// NOLINT + ~AllowedClientHosts() = default; AllowedClientHosts(const AllowedClientHosts & src) = default; AllowedClientHosts & operator =(const AllowedClientHosts & src) = default; diff --git a/src/Access/Common/AuthenticationData.h b/src/Access/Common/AuthenticationData.h index 3573d28d45e..0b4dad0509a 100644 --- a/src/Access/Common/AuthenticationData.h +++ b/src/Access/Common/AuthenticationData.h @@ -54,7 +54,7 @@ class AuthenticationData public: using Digest = std::vector; - AuthenticationData(AuthenticationType type_ = AuthenticationType::NO_PASSWORD) : type(type_) {} + explicit AuthenticationData(AuthenticationType type_ = AuthenticationType::NO_PASSWORD) : type(type_) {} AuthenticationData(const AuthenticationData & src) = default; AuthenticationData & operator =(const AuthenticationData & src) = default; AuthenticationData(AuthenticationData && src) = default; diff --git a/src/Access/ContextAccess.h b/src/Access/ContextAccess.h index 02cef3d0935..d0742e0c691 100644 --- a/src/Access/ContextAccess.h +++ b/src/Access/ContextAccess.h @@ -158,7 +158,7 @@ public: private: friend class AccessControl; - ContextAccess() {} + ContextAccess() {} /// NOLINT ContextAccess(const AccessControl & access_control_, const Params & params_); void initialize(); diff --git a/src/Access/Credentials.h b/src/Access/Credentials.h index d0c9efcfd8c..814382859b9 100644 --- a/src/Access/Credentials.h +++ b/src/Access/Credentials.h @@ -21,7 +21,6 @@ public: protected: [[noreturn]] static void throwNotReady(); -protected: bool is_ready = false; String user_name; }; diff --git a/src/Access/EnabledQuota.h b/src/Access/EnabledQuota.h index 88362c9193f..ed1e06fa1f2 100644 --- a/src/Access/EnabledQuota.h +++ b/src/Access/EnabledQuota.h @@ -60,8 +60,8 @@ public: private: friend class QuotaCache; - EnabledQuota(const Params & params_); - EnabledQuota() {} + explicit EnabledQuota(const Params & params_); + EnabledQuota() {} /// NOLINT const String & getUserName() const { return params.user_name; } diff --git a/src/Access/EnabledRoles.h b/src/Access/EnabledRoles.h index efec5833fca..28d1f9ea376 100644 --- a/src/Access/EnabledRoles.h +++ b/src/Access/EnabledRoles.h @@ -41,7 +41,7 @@ public: private: friend class RoleCache; - EnabledRoles(const Params & params_); + explicit EnabledRoles(const Params & params_); void setRolesInfo(const std::shared_ptr & info_, scope_guard & notifications); diff --git a/src/Access/EnabledRowPolicies.h b/src/Access/EnabledRowPolicies.h index 7fb4e707273..a3d3f009408 100644 --- a/src/Access/EnabledRowPolicies.h +++ b/src/Access/EnabledRowPolicies.h @@ -44,7 +44,7 @@ public: private: friend class RowPolicyCache; - EnabledRowPolicies(const Params & params_); + explicit EnabledRowPolicies(const Params & params_); struct MixedFiltersKey { diff --git a/src/Access/EnabledSettings.h b/src/Access/EnabledSettings.h index 35493ef01ab..94d2ec2952f 100644 --- a/src/Access/EnabledSettings.h +++ b/src/Access/EnabledSettings.h @@ -38,7 +38,7 @@ public: private: friend class SettingsProfilesCache; - EnabledSettings(const Params & params_); + explicit EnabledSettings(const Params & params_); void setInfo(const std::shared_ptr & info_); const Params params; diff --git a/src/Access/ExternalAuthenticators.h b/src/Access/ExternalAuthenticators.h index 8ece77cd9ef..0b3af4d0216 100644 --- a/src/Access/ExternalAuthenticators.h +++ b/src/Access/ExternalAuthenticators.h @@ -51,7 +51,6 @@ private: using LDAPCaches = std::map; // server name -> cache using LDAPParams = std::map; // server name -> params -private: mutable std::recursive_mutex mutex; LDAPParams ldap_client_params_blueprint; mutable LDAPCaches ldap_caches; diff --git a/src/Access/GSSAcceptor.h b/src/Access/GSSAcceptor.h index 4b57b575455..c128c78cb3a 100644 --- a/src/Access/GSSAcceptor.h +++ b/src/Access/GSSAcceptor.h @@ -47,7 +47,6 @@ private: void resetHandles() noexcept; void initHandles(); -private: const Params params; bool is_failed = false; diff --git a/src/Access/IAccessStorage.h b/src/Access/IAccessStorage.h index eb7c31050cb..3069e41b285 100644 --- a/src/Access/IAccessStorage.h +++ b/src/Access/IAccessStorage.h @@ -24,8 +24,8 @@ class ExternalAuthenticators; class IAccessStorage { public: - IAccessStorage(const String & storage_name_) : storage_name(storage_name_) {} - virtual ~IAccessStorage() {} + explicit IAccessStorage(const String & storage_name_) : storage_name(storage_name_) {} + virtual ~IAccessStorage() = default; /// Returns the name of this storage. const String & getStorageName() const { return storage_name; } diff --git a/src/Access/LDAPAccessStorage.h b/src/Access/LDAPAccessStorage.h index 4c2ec0fa31b..a86c2fcd35c 100644 --- a/src/Access/LDAPAccessStorage.h +++ b/src/Access/LDAPAccessStorage.h @@ -37,7 +37,7 @@ public: String getLDAPServerName() const; -public: // IAccessStorage implementations. + // IAccessStorage implementations. virtual const char * getStorageType() const override; virtual String getStorageParamsJSON() const override; virtual bool isReadOnly() const override { return true; } @@ -54,7 +54,6 @@ private: // IAccessStorage implementations. virtual scope_guard subscribeForChangesImpl(AccessEntityType type, const OnChangedHandler & handler) const override; virtual std::optional authenticateImpl(const Credentials & credentials, const Poco::Net::IPAddress & address, const ExternalAuthenticators & external_authenticators, bool throw_if_user_not_exists, bool allow_no_password, bool allow_plaintext_password) const override; -private: void setConfiguration(AccessControl * access_control_, const Poco::Util::AbstractConfiguration & config, const String & prefix); void processRoleChange(const UUID & id, const AccessEntityPtr & entity); diff --git a/src/Access/LDAPClient.cpp b/src/Access/LDAPClient.cpp index 1b1cac0800f..18f480954f1 100644 --- a/src/Access/LDAPClient.cpp +++ b/src/Access/LDAPClient.cpp @@ -153,7 +153,7 @@ namespace } -void LDAPClient::diag(const int rc, String text) +void LDAPClient::diag(int rc, String text) { std::scoped_lock lock(ldap_global_mutex); diff --git a/src/Access/LDAPClient.h b/src/Access/LDAPClient.h index 05f71993699..a975a0e1eb6 100644 --- a/src/Access/LDAPClient.h +++ b/src/Access/LDAPClient.h @@ -133,12 +133,11 @@ public: LDAPClient & operator= (LDAPClient &&) = delete; protected: - MAYBE_NORETURN void diag(const int rc, String text = ""); + MAYBE_NORETURN void diag(int rc, String text = ""); MAYBE_NORETURN bool openConnection(); void closeConnection() noexcept; SearchResults search(const SearchParams & search_params); -protected: const Params params; #if USE_LDAP LDAP * handle = nullptr; diff --git a/src/Access/MemoryAccessStorage.h b/src/Access/MemoryAccessStorage.h index 3e31f155ba7..f497067bd50 100644 --- a/src/Access/MemoryAccessStorage.h +++ b/src/Access/MemoryAccessStorage.h @@ -15,7 +15,7 @@ class MemoryAccessStorage : public IAccessStorage public: static constexpr char STORAGE_TYPE[] = "memory"; - MemoryAccessStorage(const String & storage_name_ = STORAGE_TYPE); + explicit MemoryAccessStorage(const String & storage_name_ = STORAGE_TYPE); const char * getStorageType() const override { return STORAGE_TYPE; } diff --git a/src/Access/MultipleAccessStorage.h b/src/Access/MultipleAccessStorage.h index da238ce54e8..3a47163af6f 100644 --- a/src/Access/MultipleAccessStorage.h +++ b/src/Access/MultipleAccessStorage.h @@ -17,7 +17,7 @@ public: using StoragePtr = std::shared_ptr; using ConstStoragePtr = std::shared_ptr; - MultipleAccessStorage(const String & storage_name_ = STORAGE_TYPE); + explicit MultipleAccessStorage(const String & storage_name_ = STORAGE_TYPE); ~MultipleAccessStorage() override; const char * getStorageType() const override { return STORAGE_TYPE; } diff --git a/src/Access/QuotaCache.h b/src/Access/QuotaCache.h index 7298acad415..883ddfe47a8 100644 --- a/src/Access/QuotaCache.h +++ b/src/Access/QuotaCache.h @@ -19,7 +19,7 @@ struct RolesOrUsersSet; class QuotaCache { public: - QuotaCache(const AccessControl & access_control_); + explicit QuotaCache(const AccessControl & access_control_); ~QuotaCache(); std::shared_ptr getEnabledQuota( diff --git a/src/Access/RoleCache.h b/src/Access/RoleCache.h index 42f4eec5b49..e9c731f1342 100644 --- a/src/Access/RoleCache.h +++ b/src/Access/RoleCache.h @@ -16,7 +16,7 @@ using RolePtr = std::shared_ptr; class RoleCache { public: - RoleCache(const AccessControl & access_control_); + explicit RoleCache(const AccessControl & access_control_); ~RoleCache(); std::shared_ptr getEnabledRoles( diff --git a/src/Access/RolesOrUsersSet.h b/src/Access/RolesOrUsersSet.h index 02313c2c424..43247057c86 100644 --- a/src/Access/RolesOrUsersSet.h +++ b/src/Access/RolesOrUsersSet.h @@ -26,13 +26,13 @@ struct RolesOrUsersSet RolesOrUsersSet & operator =(RolesOrUsersSet && src) noexcept; struct AllTag {}; - RolesOrUsersSet(AllTag); + RolesOrUsersSet(AllTag); /// NOLINT - RolesOrUsersSet(const UUID & id); - RolesOrUsersSet(const std::vector & ids_); + RolesOrUsersSet(const UUID & id); /// NOLINT + RolesOrUsersSet(const std::vector & ids_); /// NOLINT /// The constructor from AST requires the AccessControl if `ast.id_mode == false`. - RolesOrUsersSet(const ASTRolesOrUsersSet & ast); + RolesOrUsersSet(const ASTRolesOrUsersSet & ast); /// NOLINT RolesOrUsersSet(const ASTRolesOrUsersSet & ast, const std::optional & current_user_id); RolesOrUsersSet(const ASTRolesOrUsersSet & ast, const AccessControl & access_control); RolesOrUsersSet(const ASTRolesOrUsersSet & ast, const AccessControl & access_control, const std::optional & current_user_id); diff --git a/src/Access/RowPolicyCache.h b/src/Access/RowPolicyCache.h index dc416fe59f0..4fbf90d1a2d 100644 --- a/src/Access/RowPolicyCache.h +++ b/src/Access/RowPolicyCache.h @@ -18,7 +18,7 @@ using RowPolicyPtr = std::shared_ptr; class RowPolicyCache { public: - RowPolicyCache(const AccessControl & access_control_); + explicit RowPolicyCache(const AccessControl & access_control_); ~RowPolicyCache(); std::shared_ptr getEnabledRowPolicies(const UUID & user_id, const boost::container::flat_set & enabled_roles); @@ -26,7 +26,7 @@ public: private: struct PolicyInfo { - PolicyInfo(const RowPolicyPtr & policy_) { setPolicy(policy_); } + explicit PolicyInfo(const RowPolicyPtr & policy_) { setPolicy(policy_); } void setPolicy(const RowPolicyPtr & policy_); RowPolicyPtr policy; diff --git a/src/Access/SettingsConstraints.h b/src/Access/SettingsConstraints.h index 7439bad5d1a..f7bca1eafb3 100644 --- a/src/Access/SettingsConstraints.h +++ b/src/Access/SettingsConstraints.h @@ -51,7 +51,7 @@ class AccessControl; class SettingsConstraints { public: - SettingsConstraints(const AccessControl & access_control_); + explicit SettingsConstraints(const AccessControl & access_control_); SettingsConstraints(const SettingsConstraints & src); SettingsConstraints & operator=(const SettingsConstraints & src); SettingsConstraints(SettingsConstraints && src) noexcept; diff --git a/src/Access/SettingsConstraintsAndProfileIDs.h b/src/Access/SettingsConstraintsAndProfileIDs.h index c1f3f59af6b..6bd5fd168dc 100644 --- a/src/Access/SettingsConstraintsAndProfileIDs.h +++ b/src/Access/SettingsConstraintsAndProfileIDs.h @@ -15,7 +15,7 @@ struct SettingsConstraintsAndProfileIDs std::vector current_profiles; std::vector enabled_profiles; - SettingsConstraintsAndProfileIDs(const AccessControl & access_control_) : constraints(access_control_) {} + explicit SettingsConstraintsAndProfileIDs(const AccessControl & access_control_) : constraints(access_control_) {} }; } diff --git a/src/Access/SettingsProfileElement.h b/src/Access/SettingsProfileElement.h index aadc5fc9e3f..c9f6936c832 100644 --- a/src/Access/SettingsProfileElement.h +++ b/src/Access/SettingsProfileElement.h @@ -33,10 +33,10 @@ struct SettingsProfileElement friend bool operator <=(const SettingsProfileElement & lhs, const SettingsProfileElement & rhs) { return !(rhs < lhs); } friend bool operator >=(const SettingsProfileElement & lhs, const SettingsProfileElement & rhs) { return !(lhs < rhs); } - SettingsProfileElement() {} + SettingsProfileElement() = default; /// The constructor from AST requires the AccessControl if `ast.id_mode == false`. - SettingsProfileElement(const ASTSettingsProfileElement & ast); + SettingsProfileElement(const ASTSettingsProfileElement & ast); /// NOLINT SettingsProfileElement(const ASTSettingsProfileElement & ast, const AccessControl & access_control); std::shared_ptr toAST() const; std::shared_ptr toASTWithNames(const AccessControl & access_control) const; @@ -49,10 +49,10 @@ private: class SettingsProfileElements : public std::vector { public: - SettingsProfileElements() {} + SettingsProfileElements() = default; /// The constructor from AST requires the AccessControl if `ast.id_mode == false`. - SettingsProfileElements(const ASTSettingsProfileElements & ast); + SettingsProfileElements(const ASTSettingsProfileElements & ast); /// NOLINT SettingsProfileElements(const ASTSettingsProfileElements & ast, const AccessControl & access_control); std::shared_ptr toAST() const; std::shared_ptr toASTWithNames(const AccessControl & access_control) const; diff --git a/src/Access/SettingsProfilesCache.h b/src/Access/SettingsProfilesCache.h index da852275ff5..28914596ccc 100644 --- a/src/Access/SettingsProfilesCache.h +++ b/src/Access/SettingsProfilesCache.h @@ -18,7 +18,7 @@ struct SettingsProfilesInfo; class SettingsProfilesCache { public: - SettingsProfilesCache(const AccessControl & access_control_); + explicit SettingsProfilesCache(const AccessControl & access_control_); ~SettingsProfilesCache(); void setDefaultProfileName(const String & default_profile_name); diff --git a/src/Access/SettingsProfilesInfo.h b/src/Access/SettingsProfilesInfo.h index b7f9b1da28d..579125f7e04 100644 --- a/src/Access/SettingsProfilesInfo.h +++ b/src/Access/SettingsProfilesInfo.h @@ -29,7 +29,7 @@ struct SettingsProfilesInfo /// Names of all the profiles in `profiles`. std::unordered_map names_of_profiles; - SettingsProfilesInfo(const AccessControl & access_control_) : constraints(access_control_), access_control(access_control_) {} + explicit SettingsProfilesInfo(const AccessControl & access_control_) : constraints(access_control_), access_control(access_control_) {} std::shared_ptr getConstraintsAndProfileIDs( const std::shared_ptr & previous = nullptr) const; diff --git a/src/Access/UsersConfigAccessStorage.h b/src/Access/UsersConfigAccessStorage.h index 6eb052ffe8b..d7ce5d4ab9d 100644 --- a/src/Access/UsersConfigAccessStorage.h +++ b/src/Access/UsersConfigAccessStorage.h @@ -24,8 +24,9 @@ public: using IsNoPasswordFunction = std::function; using IsPlaintextPasswordFunction = std::function; - UsersConfigAccessStorage(const String & storage_name_ = STORAGE_TYPE, const CheckSettingNameFunction & check_setting_name_function_ = {}, const IsNoPasswordFunction & is_no_password_allowed_function_ ={}, const IsPlaintextPasswordFunction & is_plaintext_password_allowed_function_ = {}); - UsersConfigAccessStorage(const CheckSettingNameFunction & check_setting_name_function_, const IsNoPasswordFunction & is_no_password_allowed_function_, const IsPlaintextPasswordFunction & is_plaintext_password_allowed_function_); + UsersConfigAccessStorage(const String & storage_name_ = STORAGE_TYPE, const CheckSettingNameFunction & check_setting_name_function_ = {}, const IsNoPasswordFunction & is_no_password_allowed_function_ ={}, const IsPlaintextPasswordFunction & is_plaintext_password_allowed_function_ = {}); /// NOLINT + UsersConfigAccessStorage(const CheckSettingNameFunction & check_setting_name_function_, const IsNoPasswordFunction & is_no_password_allowed_function_, const IsPlaintextPasswordFunction & is_plaintext_password_allowed_function_); /// NOLINT + ~UsersConfigAccessStorage() override; const char * getStorageType() const override { return STORAGE_TYPE; } diff --git a/src/AggregateFunctions/AggregateFunctionBoundingRatio.h b/src/AggregateFunctions/AggregateFunctionBoundingRatio.h index 2b7540a9a55..34e3fa2f747 100644 --- a/src/AggregateFunctions/AggregateFunctionBoundingRatio.h +++ b/src/AggregateFunctions/AggregateFunctionBoundingRatio.h @@ -97,7 +97,7 @@ private: /** Calculates the slope of a line between leftmost and rightmost data points. * (y2 - y1) / (x2 - x1) */ - Float64 NO_SANITIZE_UNDEFINED getBoundingRatio(const AggregateFunctionBoundingRatioData & data) const + static Float64 NO_SANITIZE_UNDEFINED getBoundingRatio(const AggregateFunctionBoundingRatioData & data) { if (data.empty) return std::numeric_limits::quiet_NaN(); @@ -111,11 +111,11 @@ public: return "boundingRatio"; } - AggregateFunctionBoundingRatio(const DataTypes & arguments) + explicit AggregateFunctionBoundingRatio(const DataTypes & arguments) : IAggregateFunctionDataHelper(arguments, {}) { - const auto x_arg = arguments.at(0).get(); - const auto y_arg = arguments.at(1).get(); + const auto * x_arg = arguments.at(0).get(); + const auto * y_arg = arguments.at(1).get(); if (!x_arg->isValueRepresentedByNumber() || !y_arg->isValueRepresentedByNumber()) throw Exception("Illegal types of arguments of aggregate function " + getName() + ", must have number representation.", diff --git a/src/AggregateFunctions/AggregateFunctionCategoricalInformationValue.h b/src/AggregateFunctions/AggregateFunctionCategoricalInformationValue.h index 94ff5c10eac..cb945cc6ed9 100644 --- a/src/AggregateFunctions/AggregateFunctionCategoricalInformationValue.h +++ b/src/AggregateFunctions/AggregateFunctionCategoricalInformationValue.h @@ -63,12 +63,12 @@ public: void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override { - auto y_col = static_cast(columns[category_count]); + const auto * y_col = static_cast(columns[category_count]); bool y = y_col->getData()[row_num]; for (size_t i : collections::range(0, category_count)) { - auto x_col = static_cast(columns[i]); + const auto * x_col = static_cast(columns[i]); bool x = x_col->getData()[row_num]; if (x) @@ -104,7 +104,7 @@ public: ); } - void insertResultInto(AggregateDataPtr place, IColumn & to, Arena *) const override + void insertResultInto(AggregateDataPtr __restrict place, IColumn & to, Arena *) const override /// NOLINT { auto & col = static_cast(to); auto & data_col = static_cast(col.getData()); diff --git a/src/AggregateFunctions/AggregateFunctionCount.h b/src/AggregateFunctions/AggregateFunctionCount.h index ac8408177ce..922c475c1f8 100644 --- a/src/AggregateFunctions/AggregateFunctionCount.h +++ b/src/AggregateFunctions/AggregateFunctionCount.h @@ -37,7 +37,7 @@ namespace ErrorCodes class AggregateFunctionCount final : public IAggregateFunctionDataHelper { public: - AggregateFunctionCount(const DataTypes & argument_types_) : IAggregateFunctionDataHelper(argument_types_, {}) {} + explicit AggregateFunctionCount(const DataTypes & argument_types_) : IAggregateFunctionDataHelper(argument_types_, {}) {} String getName() const override { return "count"; } @@ -107,7 +107,7 @@ public: } /// Reset the state to specified value. This function is not the part of common interface. - void set(AggregateDataPtr __restrict place, UInt64 new_count) const + static void set(AggregateDataPtr __restrict place, UInt64 new_count) { data(place).count = new_count; } @@ -206,7 +206,7 @@ public: void addBatchSinglePlace( size_t batch_size, AggregateDataPtr place, const IColumn ** columns, Arena *, ssize_t if_argument_pos) const override { - auto & nc = assert_cast(*columns[0]); + const auto & nc = assert_cast(*columns[0]); if (if_argument_pos >= 0) { const auto & flags = assert_cast(*columns[if_argument_pos]).getData(); diff --git a/src/AggregateFunctions/AggregateFunctionEntropy.h b/src/AggregateFunctions/AggregateFunctionEntropy.h index 0be6d46225f..a51dd0537bf 100644 --- a/src/AggregateFunctions/AggregateFunctionEntropy.h +++ b/src/AggregateFunctions/AggregateFunctionEntropy.h @@ -91,7 +91,7 @@ private: size_t num_args; public: - AggregateFunctionEntropy(const DataTypes & argument_types_) + explicit AggregateFunctionEntropy(const DataTypes & argument_types_) : IAggregateFunctionDataHelper, AggregateFunctionEntropy>(argument_types_, {}) , num_args(argument_types_.size()) { diff --git a/src/AggregateFunctions/AggregateFunctionFactory.h b/src/AggregateFunctions/AggregateFunctionFactory.h index 97b22d25faa..ef5740733df 100644 --- a/src/AggregateFunctions/AggregateFunctionFactory.h +++ b/src/AggregateFunctions/AggregateFunctionFactory.h @@ -39,7 +39,7 @@ struct AggregateFunctionWithProperties AggregateFunctionWithProperties & operator = (const AggregateFunctionWithProperties &) = default; template > * = nullptr> - AggregateFunctionWithProperties(Creator creator_, AggregateFunctionProperties properties_ = {}) + AggregateFunctionWithProperties(Creator creator_, AggregateFunctionProperties properties_ = {}) /// NOLINT : creator(std::forward(creator_)), properties(std::move(properties_)) { } diff --git a/src/AggregateFunctions/AggregateFunctionGroupArray.h b/src/AggregateFunctions/AggregateFunctionGroupArray.h index f2af3ed1f3a..116a998ccc3 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupArray.h +++ b/src/AggregateFunctions/AggregateFunctionGroupArray.h @@ -144,7 +144,7 @@ public: } } - void create(AggregateDataPtr __restrict place) const override + void create(AggregateDataPtr __restrict place) const override /// NOLINT { [[maybe_unused]] auto a = new (place) Data; if constexpr (Trait::sampler == Sampler::RNG) @@ -447,7 +447,7 @@ public: } } - void create(AggregateDataPtr __restrict place) const override + void create(AggregateDataPtr __restrict place) const override /// NOLINT { [[maybe_unused]] auto a = new (place) Data; if constexpr (Trait::sampler == Sampler::RNG) diff --git a/src/AggregateFunctions/AggregateFunctionGroupArrayMoving.h b/src/AggregateFunctions/AggregateFunctionGroupArrayMoving.h index 9af70f94005..1fa568024af 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupArrayMoving.h +++ b/src/AggregateFunctions/AggregateFunctionGroupArrayMoving.h @@ -77,11 +77,11 @@ struct MovingAvgData : public MovingData }; -template +template class MovingImpl final - : public IAggregateFunctionDataHelper> + : public IAggregateFunctionDataHelper> { - static constexpr bool limit_num_elems = Tlimit_num_elems::value; + static constexpr bool limit_num_elems = LimitNumElements::value; UInt64 window_size; public: @@ -93,7 +93,7 @@ public: using ColumnResult = ColumnVectorOrDecimal; explicit MovingImpl(const DataTypePtr & data_type_, UInt64 window_size_ = std::numeric_limits::max()) - : IAggregateFunctionDataHelper>({data_type_}, {}) + : IAggregateFunctionDataHelper>({data_type_}, {}) , window_size(window_size_) {} String getName() const override { return Data::name; } diff --git a/src/AggregateFunctions/AggregateFunctionGroupBitmap.h b/src/AggregateFunctions/AggregateFunctionGroupBitmap.h index 94d64d47b51..fd8357e3ba8 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupBitmap.h +++ b/src/AggregateFunctions/AggregateFunctionGroupBitmap.h @@ -18,7 +18,7 @@ template class AggregateFunctionBitmap final : public IAggregateFunctionDataHelper> { public: - AggregateFunctionBitmap(const DataTypePtr & type) + explicit AggregateFunctionBitmap(const DataTypePtr & type) : IAggregateFunctionDataHelper>({type}, {}) { } @@ -55,9 +55,9 @@ template class AggregateFunctionBitmapL2 final : public IAggregateFunctionDataHelper> { private: - static constexpr auto STATE_VERSION_1_MIN_REVISION = 54455; + static constexpr size_t STATE_VERSION_1_MIN_REVISION = 54455; public: - AggregateFunctionBitmapL2(const DataTypePtr & type) + explicit AggregateFunctionBitmapL2(const DataTypePtr & type) : IAggregateFunctionDataHelper>({type}, {}) { } diff --git a/src/AggregateFunctions/AggregateFunctionGroupBitmapData.h b/src/AggregateFunctions/AggregateFunctionGroupBitmapData.h index 532e1ce50b3..21ba7cd7301 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupBitmapData.h +++ b/src/AggregateFunctions/AggregateFunctionGroupBitmapData.h @@ -151,7 +151,7 @@ public: /** * Computes the intersection between two bitmaps */ - void rb_and(const RoaringBitmapWithSmallSet & r1) + void rb_and(const RoaringBitmapWithSmallSet & r1) /// NOLINT { ValueBuffer buffer; if (isSmall() && r1.isSmall()) @@ -195,12 +195,12 @@ public: /** * Computes the union between two bitmaps. */ - void rb_or(const RoaringBitmapWithSmallSet & r1) { merge(r1); } + void rb_or(const RoaringBitmapWithSmallSet & r1) { merge(r1); } /// NOLINT /** * Computes the symmetric difference (xor) between two bitmaps. */ - void rb_xor(const RoaringBitmapWithSmallSet & r1) + void rb_xor(const RoaringBitmapWithSmallSet & r1) /// NOLINT { if (isSmall()) toLarge(); @@ -212,7 +212,7 @@ public: /** * Computes the difference (andnot) between two bitmaps */ - void rb_andnot(const RoaringBitmapWithSmallSet & r1) + void rb_andnot(const RoaringBitmapWithSmallSet & r1) /// NOLINT { ValueBuffer buffer; if (isSmall() && r1.isSmall()) @@ -256,7 +256,7 @@ public: /** * Computes the cardinality of the intersection between two bitmaps. */ - UInt64 rb_and_cardinality(const RoaringBitmapWithSmallSet & r1) const + UInt64 rb_and_cardinality(const RoaringBitmapWithSmallSet & r1) const /// NOLINT { UInt64 ret = 0; if (isSmall() && r1.isSmall()) @@ -283,8 +283,8 @@ public: /** * Computes the cardinality of the union between two bitmaps. - */ - UInt64 rb_or_cardinality(const RoaringBitmapWithSmallSet & r1) const + */ + UInt64 rb_or_cardinality(const RoaringBitmapWithSmallSet & r1) const /// NOLINT { UInt64 c1 = size(); UInt64 c2 = r1.size(); @@ -294,8 +294,8 @@ public: /** * Computes the cardinality of the symmetric difference (andnot) between two bitmaps. - */ - UInt64 rb_xor_cardinality(const RoaringBitmapWithSmallSet & r1) const + */ + UInt64 rb_xor_cardinality(const RoaringBitmapWithSmallSet & r1) const /// NOLINT { UInt64 c1 = size(); UInt64 c2 = r1.size(); @@ -306,7 +306,7 @@ public: /** * Computes the cardinality of the difference (andnot) between two bitmaps. */ - UInt64 rb_andnot_cardinality(const RoaringBitmapWithSmallSet & r1) const + UInt64 rb_andnot_cardinality(const RoaringBitmapWithSmallSet & r1) const /// NOLINT { UInt64 c1 = size(); UInt64 inter = rb_and_cardinality(r1); @@ -316,7 +316,7 @@ public: /** * Return 1 if the two bitmaps contain the same elements. */ - UInt8 rb_equals(const RoaringBitmapWithSmallSet & r1) + UInt8 rb_equals(const RoaringBitmapWithSmallSet & r1) /// NOLINT { if (isSmall()) toLarge(); @@ -329,7 +329,7 @@ public: * Check whether two bitmaps intersect. * Intersection with an empty set is always 0 (consistent with hasAny). */ - UInt8 rb_intersect(const RoaringBitmapWithSmallSet & r1) const + UInt8 rb_intersect(const RoaringBitmapWithSmallSet & r1) const /// NOLINT { if (isSmall()) { @@ -370,7 +370,7 @@ public: * Empty set is a subset of any other set (consistent with hasAll). * It's used in subset and currently only support comparing same type */ - UInt8 rb_is_subset(const RoaringBitmapWithSmallSet & r1) const + UInt8 rb_is_subset(const RoaringBitmapWithSmallSet & r1) const /// NOLINT { if (isSmall()) { @@ -420,7 +420,7 @@ public: /** * Check whether this bitmap contains the argument. */ - UInt8 rb_contains(UInt64 x) const + UInt8 rb_contains(UInt64 x) const /// NOLINT { if (!std::is_same_v && x > rb_max()) return 0; @@ -434,7 +434,7 @@ public: /** * Remove value */ - void rb_remove(UInt64 x) + void rb_remove(UInt64 x) /// NOLINT { if (!std::is_same_v && x > rb_max()) return; @@ -451,7 +451,7 @@ public: * range_end - range_start. * Areas outside the range are passed through unchanged. */ - void rb_flip(UInt64 begin, UInt64 end) + void rb_flip(UInt64 begin, UInt64 end) /// NOLINT { if (isSmall()) toLarge(); @@ -462,7 +462,7 @@ public: /** * returns the number of integers that are smaller or equal to offsetid. */ - UInt64 rb_rank(UInt64 x) + UInt64 rb_rank(UInt64 x) /// NOLINT { if (isSmall()) toLarge(); @@ -474,7 +474,7 @@ public: * Convert elements to integer array, return number of elements */ template - UInt64 rb_to_array(PaddedPODArray & res) const + UInt64 rb_to_array(PaddedPODArray & res) const /// NOLINT { UInt64 count = 0; if (isSmall()) @@ -500,7 +500,7 @@ public: * Return new set with specified range (not include the range_end) * It's used in subset and currently only support UInt32 */ - UInt64 rb_range(UInt64 range_start, UInt64 range_end, RoaringBitmapWithSmallSet & r1) const + UInt64 rb_range(UInt64 range_start, UInt64 range_end, RoaringBitmapWithSmallSet & r1) const /// NOLINT { UInt64 count = 0; if (range_start >= range_end) @@ -540,7 +540,7 @@ public: * Return new set of the smallest `limit` values in set which is no less than `range_start`. * It's used in subset and currently only support UInt32 */ - UInt64 rb_limit(UInt64 range_start, UInt64 limit, RoaringBitmapWithSmallSet & r1) const + UInt64 rb_limit(UInt64 range_start, UInt64 limit, RoaringBitmapWithSmallSet & r1) const /// NOLINT { if (limit == 0) return 0; @@ -586,7 +586,7 @@ public: } } - UInt64 rb_offset_limit(UInt64 offset, UInt64 limit, RoaringBitmapWithSmallSet & r1) const + UInt64 rb_offset_limit(UInt64 offset, UInt64 limit, RoaringBitmapWithSmallSet & r1) const /// NOLINT { if (limit == 0 || offset >= size()) return 0; @@ -617,7 +617,7 @@ public: } } - UInt64 rb_min() const + UInt64 rb_min() const /// NOLINT { if (isSmall()) { @@ -636,7 +636,7 @@ public: return rb->minimum(); } - UInt64 rb_max() const + UInt64 rb_max() const /// NOLINT { if (isSmall()) { @@ -659,7 +659,7 @@ public: * Replace value. * It's used in transform and currently can only support UInt32 */ - void rb_replace(const UInt64 * from_vals, const UInt64 * to_vals, size_t num) + void rb_replace(const UInt64 * from_vals, const UInt64 * to_vals, size_t num) /// NOLINT { if (isSmall()) toLarge(); diff --git a/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h b/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h index b55760c9cd1..93db1644bd4 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h +++ b/src/AggregateFunctions/AggregateFunctionGroupUniqArray.h @@ -37,11 +37,11 @@ struct AggregateFunctionGroupUniqArrayData /// Puts all values to the hash set. Returns an array of unique values. Implemented for numeric types. -template +template class AggregateFunctionGroupUniqArray - : public IAggregateFunctionDataHelper, AggregateFunctionGroupUniqArray> + : public IAggregateFunctionDataHelper, AggregateFunctionGroupUniqArray> { - static constexpr bool limit_num_elems = Tlimit_num_elem::value; + static constexpr bool limit_num_elems = LimitNumElems::value; UInt64 max_elems; private: @@ -50,7 +50,7 @@ private: public: AggregateFunctionGroupUniqArray(const DataTypePtr & argument_type, const Array & parameters_, UInt64 max_elems_ = std::numeric_limits::max()) : IAggregateFunctionDataHelper, - AggregateFunctionGroupUniqArray>({argument_type}, parameters_), + AggregateFunctionGroupUniqArray>({argument_type}, parameters_), max_elems(max_elems_) {} String getName() const override { return "groupUniqArray"; } @@ -139,21 +139,21 @@ static void deserializeAndInsertImpl(StringRef str, IColumn & data_to); /** Template parameter with true value should be used for columns that store their elements in memory continuously. * For such columns groupUniqArray() can be implemented more efficiently (especially for small numeric arrays). */ -template +template class AggregateFunctionGroupUniqArrayGeneric : public IAggregateFunctionDataHelper> + AggregateFunctionGroupUniqArrayGeneric> { DataTypePtr & input_data_type; - static constexpr bool limit_num_elems = Tlimit_num_elem::value; + static constexpr bool limit_num_elems = LimitNumElems::value; UInt64 max_elems; using State = AggregateFunctionGroupUniqArrayGenericData; public: AggregateFunctionGroupUniqArrayGeneric(const DataTypePtr & input_data_type_, const Array & parameters_, UInt64 max_elems_ = std::numeric_limits::max()) - : IAggregateFunctionDataHelper>({input_data_type_}, parameters_) + : IAggregateFunctionDataHelper>({input_data_type_}, parameters_) , input_data_type(this->argument_types[0]) , max_elems(max_elems_) {} diff --git a/src/AggregateFunctions/AggregateFunctionHistogram.h b/src/AggregateFunctions/AggregateFunctionHistogram.h index 047ddf1ddeb..9031eb73c09 100644 --- a/src/AggregateFunctions/AggregateFunctionHistogram.h +++ b/src/AggregateFunctions/AggregateFunctionHistogram.h @@ -54,13 +54,12 @@ private: Mean mean; Weight weight; - WeightedValue operator+ (const WeightedValue & other) + WeightedValue operator+(const WeightedValue & other) const { return {mean + other.weight * (other.mean - mean) / (other.weight + weight), other.weight + weight}; } }; -private: // quantity of stored weighted-values UInt32 size; @@ -71,7 +70,6 @@ private: // Weighted values representation of histogram. WeightedValue points[0]; -private: void sort() { ::sort(points, points + size, @@ -87,18 +85,18 @@ private: size_t size = 0; T * data_ptr; - PriorityQueueStorage(T * value) + explicit PriorityQueueStorage(T * value) : data_ptr(value) { } - void push_back(T val) + void push_back(T val) /// NOLINT { data_ptr[size] = std::move(val); ++size; } - void pop_back() { --size; } + void pop_back() { --size; } /// NOLINT T * begin() { return data_ptr; } T * end() const { return data_ptr + size; } bool empty() const { return size == 0; } diff --git a/src/AggregateFunctions/AggregateFunctionMLMethod.h b/src/AggregateFunctions/AggregateFunctionMLMethod.h index 455bd40a02a..705e689d347 100644 --- a/src/AggregateFunctions/AggregateFunctionMLMethod.h +++ b/src/AggregateFunctions/AggregateFunctionMLMethod.h @@ -333,7 +333,7 @@ public: return std::make_shared>(); } - void create(AggregateDataPtr __restrict place) const override + void create(AggregateDataPtr __restrict place) const override /// NOLINT { std::shared_ptr new_weights_updater; if (weights_updater_name == "SGD") diff --git a/src/AggregateFunctions/AggregateFunctionMannWhitney.h b/src/AggregateFunctions/AggregateFunctionMannWhitney.h index 3d6fd5ff0e7..887769dfbf5 100644 --- a/src/AggregateFunctions/AggregateFunctionMannWhitney.h +++ b/src/AggregateFunctions/AggregateFunctionMannWhitney.h @@ -149,7 +149,7 @@ public: if (params[0].getType() != Field::Types::String) throw Exception("Aggregate function " + getName() + " require first parameter to be a String", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); - auto param = params[0].get(); + const auto & param = params[0].get(); if (param == "two-sided") alternative = Alternative::TwoSided; else if (param == "less") diff --git a/src/AggregateFunctions/AggregateFunctionMinMaxAny.h b/src/AggregateFunctions/AggregateFunctionMinMaxAny.h index 88400b2054d..ef2f55b0b72 100644 --- a/src/AggregateFunctions/AggregateFunctionMinMaxAny.h +++ b/src/AggregateFunctions/AggregateFunctionMinMaxAny.h @@ -1130,7 +1130,7 @@ private: SerializationPtr serialization; public: - AggregateFunctionsSingleValue(const DataTypePtr & type) + explicit AggregateFunctionsSingleValue(const DataTypePtr & type) : IAggregateFunctionDataHelper>({type}, {}) , serialization(type->getDefaultSerialization()) { @@ -1188,7 +1188,7 @@ public: } } - void addBatchSinglePlaceNotNull( + void addBatchSinglePlaceNotNull( /// NOLINT size_t batch_size, AggregateDataPtr place, const IColumn ** columns, diff --git a/src/AggregateFunctions/AggregateFunctionNull.h b/src/AggregateFunctions/AggregateFunctionNull.h index a24c788f6fa..594073b0a02 100644 --- a/src/AggregateFunctions/AggregateFunctionNull.h +++ b/src/AggregateFunctions/AggregateFunctionNull.h @@ -77,7 +77,7 @@ protected: static bool getFlag(ConstAggregateDataPtr __restrict place) noexcept { - return result_is_nullable ? place[0] : 1; + return result_is_nullable ? place[0] : true; } public: @@ -148,7 +148,7 @@ public: void deserialize(AggregateDataPtr __restrict place, ReadBuffer & buf, std::optional version, Arena * arena) const override { - bool flag = 1; + bool flag = true; if constexpr (serialize_flag) readBinary(flag, buf); if (flag) @@ -306,7 +306,7 @@ public: } } - void addBatchSinglePlace( + void addBatchSinglePlace( /// NOLINT size_t batch_size, AggregateDataPtr place, const IColumn ** columns, Arena * arena, ssize_t if_argument_pos = -1) const override { const ColumnNullable * column = assert_cast(columns[0]); diff --git a/src/AggregateFunctions/AggregateFunctionOrFill.h b/src/AggregateFunctions/AggregateFunctionOrFill.h index 7d33b56adad..50151c373df 100644 --- a/src/AggregateFunctions/AggregateFunctionOrFill.h +++ b/src/AggregateFunctions/AggregateFunctionOrFill.h @@ -108,7 +108,7 @@ public: place[size_of_data] = 1; } - void addBatch( + void addBatch( /// NOLINT size_t batch_size, AggregateDataPtr * places, size_t place_offset, @@ -134,7 +134,7 @@ public: } } - void addBatchSinglePlace( + void addBatchSinglePlace( /// NOLINT size_t batch_size, AggregateDataPtr place, const IColumn ** columns, Arena * arena, ssize_t if_argument_pos = -1) const override { if (if_argument_pos >= 0) @@ -160,7 +160,7 @@ public: } } - void addBatchSinglePlaceNotNull( + void addBatchSinglePlaceNotNull( /// NOLINT size_t batch_size, AggregateDataPtr place, const IColumn ** columns, diff --git a/src/AggregateFunctions/AggregateFunctionRankCorrelation.h b/src/AggregateFunctions/AggregateFunctionRankCorrelation.h index dbfa96cf516..733416d4721 100644 --- a/src/AggregateFunctions/AggregateFunctionRankCorrelation.h +++ b/src/AggregateFunctions/AggregateFunctionRankCorrelation.h @@ -77,7 +77,7 @@ public: void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs, Arena * arena) const override { auto & a = this->data(place); - auto & b = this->data(rhs); + const auto & b = this->data(rhs); a.merge(b, arena); } diff --git a/src/AggregateFunctions/AggregateFunctionResample.h b/src/AggregateFunctions/AggregateFunctionResample.h index b5f7a4fe2c9..8f2138eb3a5 100644 --- a/src/AggregateFunctions/AggregateFunctionResample.h +++ b/src/AggregateFunctions/AggregateFunctionResample.h @@ -21,7 +21,7 @@ class AggregateFunctionResample final : public IAggregateFunctionHelper MAX_ELEMENTS) + if (total > max_elements) throw Exception("The range given in function " + getName() + " contains too many elements", ErrorCodes::ARGUMENT_OUT_OF_BOUND); diff --git a/src/AggregateFunctions/AggregateFunctionRetention.h b/src/AggregateFunctions/AggregateFunctionRetention.h index 029edf3da14..a949b5e93f6 100644 --- a/src/AggregateFunctions/AggregateFunctionRetention.h +++ b/src/AggregateFunctions/AggregateFunctionRetention.h @@ -75,12 +75,12 @@ public: return "retention"; } - AggregateFunctionRetention(const DataTypes & arguments) + explicit AggregateFunctionRetention(const DataTypes & arguments) : IAggregateFunctionDataHelper(arguments, {}) { for (const auto i : collections::range(0, arguments.size())) { - auto cond_arg = arguments[i].get(); + const auto * cond_arg = arguments[i].get(); if (!isUInt8(cond_arg)) throw Exception{"Illegal type " + cond_arg->getName() + " of argument " + toString(i) + " of aggregate function " + getName() + ", must be UInt8", diff --git a/src/AggregateFunctions/AggregateFunctionSequenceMatch.h b/src/AggregateFunctions/AggregateFunctionSequenceMatch.h index 248454bef02..8b0f7ccfbd1 100644 --- a/src/AggregateFunctions/AggregateFunctionSequenceMatch.h +++ b/src/AggregateFunctions/AggregateFunctionSequenceMatch.h @@ -37,7 +37,7 @@ struct ComparePairFirst final } }; -static constexpr auto max_events = 32; +static constexpr size_t max_events = 32; template struct AggregateFunctionSequenceMatchData final @@ -187,7 +187,7 @@ private: std::uint64_t extra; PatternAction() = default; - PatternAction(const PatternActionType type_, const std::uint64_t extra_ = 0) : type{type_}, extra{extra_} {} + explicit PatternAction(const PatternActionType type_, const std::uint64_t extra_ = 0) : type{type_}, extra{extra_} {} }; using PatternActions = PODArrayWithStackMemory; @@ -246,7 +246,7 @@ private: throw_exception("Unknown time condition"); UInt64 duration = 0; - auto prev_pos = pos; + const auto * prev_pos = pos; pos = tryReadIntText(duration, pos, end); if (pos == prev_pos) throw_exception("Could not parse number"); @@ -262,7 +262,7 @@ private: else { UInt64 event_number = 0; - auto prev_pos = pos; + const auto * prev_pos = pos; pos = tryReadIntText(event_number, pos, end); if (pos == prev_pos) throw_exception("Could not parse number"); @@ -580,7 +580,7 @@ private: struct DFAState { - DFAState(bool has_kleene_ = false) + explicit DFAState(bool has_kleene_ = false) : has_kleene{has_kleene_}, event{0}, transition{DFATransition::None} {} diff --git a/src/AggregateFunctions/AggregateFunctionSequenceNextNode.h b/src/AggregateFunctions/AggregateFunctionSequenceNextNode.h index 09e30f34433..f6c921aeef9 100644 --- a/src/AggregateFunctions/AggregateFunctionSequenceNextNode.h +++ b/src/AggregateFunctions/AggregateFunctionSequenceNextNode.h @@ -216,7 +216,7 @@ public: a.value.push_back(v->clone(arena), arena); } - void create(AggregateDataPtr place) const override + void create(AggregateDataPtr place) const override /// NOLINT { new (place) Data; } diff --git a/src/AggregateFunctions/AggregateFunctionSparkbar.h b/src/AggregateFunctions/AggregateFunctionSparkbar.h index 3228ae53a29..52377e7e569 100644 --- a/src/AggregateFunctions/AggregateFunctionSparkbar.h +++ b/src/AggregateFunctions/AggregateFunctionSparkbar.h @@ -185,18 +185,18 @@ private: std::optional max_y; std::optional new_y; - std::vector> newPoints; - newPoints.reserve(width); + std::vector> new_points; + new_points.reserve(width); std::pair bound{0, 0.0}; size_t cur_bucket_num = 0; // upper bound for bucket - auto upperBound = [&](size_t bucket_num) + auto upper_bound = [&](size_t bucket_num) { bound.second = (bucket_num + 1) * multiple_d; bound.first = std::floor(bound.second); }; - upperBound(cur_bucket_num); + upper_bound(cur_bucket_num); for (size_t i = 0; i <= (diff_x + 1); ++i) { if (i == bound.first) // is bound @@ -211,7 +211,7 @@ private: { Float64 avg_y = new_y.value() / multiple_d; - newPoints.emplace_back(avg_y); + new_points.emplace_back(avg_y); // If min_y has no value, or if the avg_y of the current bucket is less than min_y, update it. if (!min_y || avg_y < min_y) min_y = avg_y; @@ -220,12 +220,12 @@ private: } else { - newPoints.emplace_back(); + new_points.emplace_back(); } // next bucket new_y = found ? ((1 - proportion) * it->getMapped()) : std::optional(); - upperBound(++cur_bucket_num); + upper_bound(++cur_bucket_num); } else { @@ -240,19 +240,19 @@ private: Float64 diff_y = max_y.value() - min_y.value(); - auto getBars = [&] (const std::optional & point_y) + auto get_bars = [&] (const std::optional & point_y) { value += getBar(point_y ? std::round(((point_y.value() - min_y.value()) / diff_y) * 7) + 1 : 0); }; - auto getBarsForConstant = [&] (const std::optional & point_y) + auto get_bars_for_constant = [&] (const std::optional & point_y) { value += getBar(point_y ? 1 : 0); }; if (diff_y) - std::for_each(newPoints.begin(), newPoints.end(), getBars); + std::for_each(new_points.begin(), new_points.end(), get_bars); else - std::for_each(newPoints.begin(), newPoints.end(), getBarsForConstant); + std::for_each(new_points.begin(), new_points.end(), get_bars_for_constant); } return value; } diff --git a/src/AggregateFunctions/AggregateFunctionStatistics.h b/src/AggregateFunctions/AggregateFunctionStatistics.h index 85178bc2413..ad7177a32fa 100644 --- a/src/AggregateFunctions/AggregateFunctionStatistics.h +++ b/src/AggregateFunctions/AggregateFunctionStatistics.h @@ -114,7 +114,7 @@ class AggregateFunctionVariance final : public IAggregateFunctionDataHelper, AggregateFunctionVariance> { public: - AggregateFunctionVariance(const DataTypePtr & arg) + explicit AggregateFunctionVariance(const DataTypePtr & arg) : IAggregateFunctionDataHelper, AggregateFunctionVariance>({arg}, {}) {} String getName() const override { return Op::name; } @@ -249,7 +249,6 @@ protected: readBinary(right_m2, buf); } -protected: Float64 left_m2 = 0.0; Float64 right_m2 = 0.0; }; @@ -367,7 +366,7 @@ class AggregateFunctionCovariance final AggregateFunctionCovariance> { public: - AggregateFunctionCovariance(const DataTypes & args) : IAggregateFunctionDataHelper< + explicit AggregateFunctionCovariance(const DataTypes & args) : IAggregateFunctionDataHelper< CovarianceData, AggregateFunctionCovariance>(args, {}) {} diff --git a/src/AggregateFunctions/AggregateFunctionStatisticsSimple.h b/src/AggregateFunctions/AggregateFunctionStatisticsSimple.h index 5c1e45d052f..0d518e6ddc2 100644 --- a/src/AggregateFunctions/AggregateFunctionStatisticsSimple.h +++ b/src/AggregateFunctions/AggregateFunctionStatisticsSimple.h @@ -80,7 +80,7 @@ public: using ResultType = typename StatFunc::ResultType; using ColVecResult = ColumnVector; - AggregateFunctionVarianceSimple(const DataTypes & argument_types_) + explicit AggregateFunctionVarianceSimple(const DataTypes & argument_types_) : IAggregateFunctionDataHelper>(argument_types_, {}) , src_scale(0) {} diff --git a/src/AggregateFunctions/AggregateFunctionSum.h b/src/AggregateFunctions/AggregateFunctionSum.h index 8445a3a8050..a23f230cdb8 100644 --- a/src/AggregateFunctions/AggregateFunctionSum.h +++ b/src/AggregateFunctions/AggregateFunctionSum.h @@ -97,7 +97,7 @@ struct AggregateFunctionSumData template void NO_SANITIZE_UNDEFINED NO_INLINE - addManyConditional_internal(const Value * __restrict ptr, const UInt8 * __restrict condition_map, size_t count) + addManyConditionalInternal(const Value * __restrict ptr, const UInt8 * __restrict condition_map, size_t count) { const auto * end = ptr + count; @@ -124,7 +124,8 @@ struct AggregateFunctionSumData /// For floating point we use a similar trick as above, except that now we reinterpret the floating point number as an unsigned /// integer of the same size and use a mask instead (0 to discard, 0xFF..FF to keep) static_assert(sizeof(Value) == 4 || sizeof(Value) == 8); - typedef typename std::conditional_t equivalent_integer; + using equivalent_integer = typename std::conditional_t; + constexpr size_t unroll_count = 128 / sizeof(T); T partial_sums[unroll_count]{}; @@ -163,13 +164,13 @@ struct AggregateFunctionSumData template void ALWAYS_INLINE addManyNotNull(const Value * __restrict ptr, const UInt8 * __restrict null_map, size_t count) { - return addManyConditional_internal(ptr, null_map, count); + return addManyConditionalInternal(ptr, null_map, count); } template void ALWAYS_INLINE addManyConditional(const Value * __restrict ptr, const UInt8 * __restrict cond_map, size_t count) { - return addManyConditional_internal(ptr, cond_map, count); + return addManyConditionalInternal(ptr, cond_map, count); } void NO_SANITIZE_UNDEFINED merge(const AggregateFunctionSumData & rhs) @@ -248,7 +249,7 @@ struct AggregateFunctionSumKahanData } template - void NO_INLINE addManyConditional_internal(const Value * __restrict ptr, const UInt8 * __restrict condition_map, size_t count) + void NO_INLINE addManyConditionalInternal(const Value * __restrict ptr, const UInt8 * __restrict condition_map, size_t count) { constexpr size_t unroll_count = 4; T partial_sums[unroll_count]{}; @@ -281,13 +282,13 @@ struct AggregateFunctionSumKahanData template void ALWAYS_INLINE addManyNotNull(const Value * __restrict ptr, const UInt8 * __restrict null_map, size_t count) { - return addManyConditional_internal(ptr, null_map, count); + return addManyConditionalInternal(ptr, null_map, count); } template void ALWAYS_INLINE addManyConditional(const Value * __restrict ptr, const UInt8 * __restrict cond_map, size_t count) { - return addManyConditional_internal(ptr, cond_map, count); + return addManyConditionalInternal(ptr, cond_map, count); } void ALWAYS_INLINE mergeImpl(T & to_sum, T & to_compensation, T from_sum, T from_compensation) @@ -351,7 +352,7 @@ public: __builtin_unreachable(); } - AggregateFunctionSum(const DataTypes & argument_types_) + explicit AggregateFunctionSum(const DataTypes & argument_types_) : IAggregateFunctionDataHelper>(argument_types_, {}) , scale(0) {} diff --git a/src/AggregateFunctions/AggregateFunctionSumMap.h b/src/AggregateFunctions/AggregateFunctionSumMap.h index 295258cd8cf..4b039157eac 100644 --- a/src/AggregateFunctions/AggregateFunctionSumMap.h +++ b/src/AggregateFunctions/AggregateFunctionSumMap.h @@ -489,15 +489,15 @@ public: "Aggregate function '{}' requires exactly one parameter " "of Array type", getName()); - Array keys_to_keep_; - if (!params_.front().tryGet(keys_to_keep_)) + Array keys_to_keep_values; + if (!params_.front().tryGet(keys_to_keep_values)) throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Aggregate function {} requires an Array as a parameter", getName()); - keys_to_keep.reserve(keys_to_keep_.size()); + keys_to_keep.reserve(keys_to_keep_values.size()); - for (const Field & f : keys_to_keep_) + for (const Field & f : keys_to_keep_values) keys_to_keep.emplace(f.safeGet()); } diff --git a/src/AggregateFunctions/AggregateFunctionTTest.h b/src/AggregateFunctions/AggregateFunctionTTest.h index 40cf0023878..4c939121a72 100644 --- a/src/AggregateFunctions/AggregateFunctionTTest.h +++ b/src/AggregateFunctions/AggregateFunctionTTest.h @@ -64,7 +64,7 @@ namespace ErrorCodes * Both WelchTTest and StudentTTest have t-statistric with Student distribution but with different degrees of freedom. * So the procedure of computing p-value is the same. */ -static inline Float64 getPValue(Float64 degrees_of_freedom, Float64 t_stat2) +static inline Float64 getPValue(Float64 degrees_of_freedom, Float64 t_stat2) /// NOLINT { Float64 numerator = integrateSimpson(0, degrees_of_freedom / (t_stat2 + degrees_of_freedom), [degrees_of_freedom](double x) { return std::pow(x, degrees_of_freedom / 2 - 1) / std::sqrt(1 - x); }); @@ -92,7 +92,7 @@ public: AggregateFunctionTTest(const DataTypes & arguments, const Array & params) : IAggregateFunctionDataHelper>({arguments}, params) { - if (params.size() > 0) + if (!params.empty()) { need_confidence_interval = true; confidence_level = params.at(0).safeGet(); diff --git a/src/AggregateFunctions/AggregateFunctionWindowFunnel.h b/src/AggregateFunctions/AggregateFunctionWindowFunnel.h index 0aeadb4e51d..cce1c666faa 100644 --- a/src/AggregateFunctions/AggregateFunctionWindowFunnel.h +++ b/src/AggregateFunctions/AggregateFunctionWindowFunnel.h @@ -20,7 +20,7 @@ namespace ErrorCodes extern const int BAD_ARGUMENTS; } -static constexpr auto max_events = 32; +static constexpr size_t max_events = 32; template struct AggregateFunctionWindowFunnelData diff --git a/src/AggregateFunctions/CrossTab.h b/src/AggregateFunctions/CrossTab.h index e01ebcf71ed..1284c210886 100644 --- a/src/AggregateFunctions/CrossTab.h +++ b/src/AggregateFunctions/CrossTab.h @@ -117,7 +117,7 @@ template class AggregateFunctionCrossTab : public IAggregateFunctionDataHelper> { public: - AggregateFunctionCrossTab(const DataTypes & arguments) + explicit AggregateFunctionCrossTab(const DataTypes & arguments) : IAggregateFunctionDataHelper>({arguments}, {}) { } diff --git a/src/AggregateFunctions/Helpers.h b/src/AggregateFunctions/Helpers.h index e508bc0312d..77660c54d32 100644 --- a/src/AggregateFunctions/Helpers.h +++ b/src/AggregateFunctions/Helpers.h @@ -55,7 +55,7 @@ static IAggregateFunction * createWithNumericType(const IDataType & argument_typ { WhichDataType which(argument_type); #define DISPATCH(TYPE) \ - if (which.idx == TypeIndex::TYPE) return new AggregateFunctionTemplate>(std::forward(args)...); + if (which.idx == TypeIndex::TYPE) return new AggregateFunctionTemplate>(std::forward(args)...); /// NOLINT FOR_NUMERIC_TYPES(DISPATCH) #undef DISPATCH if (which.idx == TypeIndex::Enum8) return new AggregateFunctionTemplate>(std::forward(args)...); @@ -94,7 +94,7 @@ static IAggregateFunction * createWithNumericType(const IDataType & argument_typ { WhichDataType which(argument_type); #define DISPATCH(TYPE) \ - if (which.idx == TypeIndex::TYPE) return new AggregateFunctionTemplate>(std::forward(args)...); + if (which.idx == TypeIndex::TYPE) return new AggregateFunctionTemplate>(std::forward(args)...); /// NOLINT FOR_NUMERIC_TYPES(DISPATCH) #undef DISPATCH if (which.idx == TypeIndex::Enum8) return new AggregateFunctionTemplate>(std::forward(args)...); @@ -121,7 +121,7 @@ static IAggregateFunction * createWithBasicNumberOrDateOrDateTime(const IDataTyp WhichDataType which(argument_type); #define DISPATCH(TYPE) \ if (which.idx == TypeIndex::TYPE) \ - return new AggregateFunctionTemplate>(std::forward(args)...); + return new AggregateFunctionTemplate>(std::forward(args)...); /// NOLINT FOR_BASIC_NUMERIC_TYPES(DISPATCH) #undef DISPATCH diff --git a/src/AggregateFunctions/HelpersMinMaxAny.h b/src/AggregateFunctions/HelpersMinMaxAny.h index be00ff87ae0..1af51c3f8e6 100644 --- a/src/AggregateFunctions/HelpersMinMaxAny.h +++ b/src/AggregateFunctions/HelpersMinMaxAny.h @@ -25,7 +25,7 @@ static IAggregateFunction * createAggregateFunctionSingleValue(const String & na WhichDataType which(argument_type); #define DISPATCH(TYPE) \ - if (which.idx == TypeIndex::TYPE) return new AggregateFunctionTemplate>>(argument_type); + if (which.idx == TypeIndex::TYPE) return new AggregateFunctionTemplate>>(argument_type); /// NOLINT FOR_NUMERIC_TYPES(DISPATCH) #undef DISPATCH @@ -56,7 +56,7 @@ static IAggregateFunction * createAggregateFunctionArgMinMaxSecond(const DataTyp #define DISPATCH(TYPE) \ if (which.idx == TypeIndex::TYPE) \ - return new AggregateFunctionArgMinMax>>>(res_type, val_type); + return new AggregateFunctionArgMinMax>>>(res_type, val_type); /// NOLINT FOR_NUMERIC_TYPES(DISPATCH) #undef DISPATCH @@ -90,7 +90,7 @@ static IAggregateFunction * createAggregateFunctionArgMinMax(const String & name WhichDataType which(res_type); #define DISPATCH(TYPE) \ if (which.idx == TypeIndex::TYPE) \ - return createAggregateFunctionArgMinMaxSecond>(res_type, val_type); + return createAggregateFunctionArgMinMaxSecond>(res_type, val_type); /// NOLINT FOR_NUMERIC_TYPES(DISPATCH) #undef DISPATCH diff --git a/src/AggregateFunctions/IAggregateFunction.h b/src/AggregateFunctions/IAggregateFunction.h index fd2100cc334..315c2b4c807 100644 --- a/src/AggregateFunctions/IAggregateFunction.h +++ b/src/AggregateFunctions/IAggregateFunction.h @@ -127,10 +127,10 @@ public: virtual void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs, Arena * arena) const = 0; /// Serializes state (to transmit it over the network, for example). - virtual void serialize(ConstAggregateDataPtr __restrict place, WriteBuffer & buf, std::optional version = std::nullopt) const = 0; + virtual void serialize(ConstAggregateDataPtr __restrict place, WriteBuffer & buf, std::optional version = std::nullopt) const = 0; /// NOLINT /// Deserializes state. This function is called only for empty (just created) states. - virtual void deserialize(AggregateDataPtr __restrict place, ReadBuffer & buf, std::optional version = std::nullopt, Arena * arena = nullptr) const = 0; + virtual void deserialize(AggregateDataPtr __restrict place, ReadBuffer & buf, std::optional version = std::nullopt, Arena * arena = nullptr) const = 0; /// NOLINT /// Returns true if a function requires Arena to handle own states (see add(), merge(), deserialize()). virtual bool allocatesMemoryInArena() const = 0; @@ -174,7 +174,7 @@ public: /** Contains a loop with calls to "add" function. You can collect arguments into array "places" * and do a single call to "addBatch" for devirtualization and inlining. */ - virtual void addBatch( + virtual void addBatch( /// NOLINT size_t batch_size, AggregateDataPtr * places, size_t place_offset, @@ -198,7 +198,7 @@ public: /** The same for single place. */ - virtual void addBatchSinglePlace( + virtual void addBatchSinglePlace( /// NOLINT size_t batch_size, AggregateDataPtr place, const IColumn ** columns, Arena * arena, ssize_t if_argument_pos = -1) const = 0; /// The version of "addBatchSinglePlace", that handle sparse columns as arguments. @@ -208,7 +208,7 @@ public: /** The same for single place when need to aggregate only filtered data. * Instead of using an if-column, the condition is combined inside the null_map */ - virtual void addBatchSinglePlaceNotNull( + virtual void addBatchSinglePlaceNotNull( /// NOLINT size_t batch_size, AggregateDataPtr place, const IColumn ** columns, @@ -216,7 +216,7 @@ public: Arena * arena, ssize_t if_argument_pos = -1) const = 0; - virtual void addBatchSinglePlaceFromInterval( + virtual void addBatchSinglePlaceFromInterval( /// NOLINT size_t batch_begin, size_t batch_end, AggregateDataPtr place, const IColumn ** columns, Arena * arena, ssize_t if_argument_pos = -1) const = 0; @@ -354,7 +354,7 @@ public: AddFunc getAddressOfAddFunction() const override { return &addFree; } - void addBatch( + void addBatch( /// NOLINT size_t batch_size, AggregateDataPtr * places, size_t place_offset, @@ -407,7 +407,7 @@ public: static_cast(this)->merge(places[i] + place_offset, rhs[i], arena); } - void addBatchSinglePlace( + void addBatchSinglePlace( /// NOLINT size_t batch_size, AggregateDataPtr place, const IColumn ** columns, Arena * arena, ssize_t if_argument_pos = -1) const override { if (if_argument_pos >= 0) @@ -439,7 +439,7 @@ public: static_cast(this)->add(place, &values, offset_it.getValueIndex(), arena); } - void addBatchSinglePlaceNotNull( + void addBatchSinglePlaceNotNull( /// NOLINT size_t batch_size, AggregateDataPtr place, const IColumn ** columns, @@ -462,7 +462,7 @@ public: } } - void addBatchSinglePlaceFromInterval( + void addBatchSinglePlaceFromInterval( /// NOLINT size_t batch_begin, size_t batch_end, AggregateDataPtr place, const IColumn ** columns, Arena * arena, ssize_t if_argument_pos = -1) const override { @@ -586,7 +586,7 @@ public: IAggregateFunctionDataHelper(const DataTypes & argument_types_, const Array & parameters_) : IAggregateFunctionHelper(argument_types_, parameters_) {} - void create(AggregateDataPtr place) const override + void create(AggregateDataPtr place) const override /// NOLINT { new (place) Data; } diff --git a/src/AggregateFunctions/IAggregateFunctionCombinator.h b/src/AggregateFunctions/IAggregateFunctionCombinator.h index 37fcfe42c10..84e6b942c49 100644 --- a/src/AggregateFunctions/IAggregateFunctionCombinator.h +++ b/src/AggregateFunctions/IAggregateFunctionCombinator.h @@ -68,7 +68,7 @@ public: const DataTypes & arguments, const Array & params) const = 0; - virtual ~IAggregateFunctionCombinator() {} + virtual ~IAggregateFunctionCombinator() = default; }; using AggregateFunctionCombinatorPtr = std::shared_ptr; diff --git a/src/AggregateFunctions/ReservoirSampler.h b/src/AggregateFunctions/ReservoirSampler.h index 5f7ac13d908..24de1f84a43 100644 --- a/src/AggregateFunctions/ReservoirSampler.h +++ b/src/AggregateFunctions/ReservoirSampler.h @@ -65,7 +65,7 @@ template (index + 0.5); + size_t int_index = static_cast(index + 0.5); /// NOLINT int_index = std::max(0LU, std::min(samples.size() - 1, int_index)); return samples[int_index]; } @@ -190,7 +190,7 @@ public: } else { - for (double i = 0; i < sample_count; i += frequency) + for (double i = 0; i < sample_count; i += frequency) /// NOLINT samples[i] = b.samples[i]; } } diff --git a/src/AggregateFunctions/ReservoirSamplerDeterministic.h b/src/AggregateFunctions/ReservoirSamplerDeterministic.h index 2baeea76996..b92ba8cfd7b 100644 --- a/src/AggregateFunctions/ReservoirSamplerDeterministic.h +++ b/src/AggregateFunctions/ReservoirSamplerDeterministic.h @@ -67,7 +67,7 @@ private: } public: - ReservoirSamplerDeterministic(const size_t max_sample_size_ = detail::DEFAULT_MAX_SAMPLE_SIZE) + explicit ReservoirSamplerDeterministic(const size_t max_sample_size_ = detail::DEFAULT_MAX_SAMPLE_SIZE) : max_sample_size{max_sample_size_} { } @@ -103,7 +103,7 @@ public: sortIfNeeded(); double index = level * (samples.size() - 1); - size_t int_index = static_cast(index + 0.5); + size_t int_index = static_cast(index + 0.5); /// NOLINT int_index = std::max(0LU, std::min(samples.size() - 1, int_index)); return samples[int_index].first; } diff --git a/src/AggregateFunctions/ThetaSketchData.h b/src/AggregateFunctions/ThetaSketchData.h index bc583250002..cc35597ba56 100644 --- a/src/AggregateFunctions/ThetaSketchData.h +++ b/src/AggregateFunctions/ThetaSketchData.h @@ -6,6 +6,7 @@ #include #include +#include #include #include diff --git a/src/AggregateFunctions/UniquesHashSet.h b/src/AggregateFunctions/UniquesHashSet.h index b51bb6b988d..6837803c67d 100644 --- a/src/AggregateFunctions/UniquesHashSet.h +++ b/src/AggregateFunctions/UniquesHashSet.h @@ -105,8 +105,8 @@ private: } } - inline size_t buf_size() const { return 1ULL << size_degree; } - inline size_t max_fill() const { return 1ULL << (size_degree - 1); } + inline size_t buf_size() const { return 1ULL << size_degree; } /// NOLINT + inline size_t max_fill() const { return 1ULL << (size_degree - 1); } /// NOLINT inline size_t mask() const { return buf_size() - 1; } inline size_t place(HashValue x) const { return (x >> UNIQUES_HASH_BITS_FOR_SKIP) & mask(); } @@ -304,8 +304,11 @@ public: memcpy(buf, rhs.buf, buf_size() * sizeof(buf[0])); } - UniquesHashSet & operator= (const UniquesHashSet & rhs) + UniquesHashSet & operator=(const UniquesHashSet & rhs) { + if (&rhs == this) + return *this; + if (size_degree != rhs.size_degree) { free(); diff --git a/src/Backups/BackupEntryFromAppendOnlyFile.h b/src/Backups/BackupEntryFromAppendOnlyFile.h index 2bc0c6a68a0..c1de6930483 100644 --- a/src/Backups/BackupEntryFromAppendOnlyFile.h +++ b/src/Backups/BackupEntryFromAppendOnlyFile.h @@ -12,7 +12,7 @@ class BackupEntryFromAppendOnlyFile : public BackupEntryFromImmutableFile { public: /// The constructor is allowed to not set `file_size_` or `checksum_`, in that case it will be calculated from the data. - BackupEntryFromAppendOnlyFile( + explicit BackupEntryFromAppendOnlyFile( const String & file_path_, const std::optional & file_size_ = {}, const std::optional & checksum_ = {}, diff --git a/src/Backups/BackupEntryFromImmutableFile.h b/src/Backups/BackupEntryFromImmutableFile.h index 3be261c49ce..bc1d08aa180 100644 --- a/src/Backups/BackupEntryFromImmutableFile.h +++ b/src/Backups/BackupEntryFromImmutableFile.h @@ -16,7 +16,7 @@ class BackupEntryFromImmutableFile : public IBackupEntry { public: /// The constructor is allowed to not set `file_size_` or `checksum_`, in that case it will be calculated from the data. - BackupEntryFromImmutableFile( + explicit BackupEntryFromImmutableFile( const String & file_path_, const std::optional & file_size_ = {}, const std::optional & checksum_ = {}, diff --git a/src/Backups/BackupEntryFromMemory.h b/src/Backups/BackupEntryFromMemory.h index 3756c2ebfea..d497ff1b439 100644 --- a/src/Backups/BackupEntryFromMemory.h +++ b/src/Backups/BackupEntryFromMemory.h @@ -13,7 +13,7 @@ class BackupEntryFromMemory : public IBackupEntry public: /// The constructor is allowed to not set `checksum_`, in that case it will be calculated from the data. BackupEntryFromMemory(const void * data_, size_t size_, const std::optional & checksum_ = {}); - BackupEntryFromMemory(String data_, const std::optional & checksum_ = {}); + explicit BackupEntryFromMemory(String data_, const std::optional & checksum_ = {}); UInt64 getSize() const override { return data.size(); } std::optional getChecksum() const override { return checksum; } diff --git a/src/Backups/BackupEntryFromSmallFile.h b/src/Backups/BackupEntryFromSmallFile.h index ab2ba2ea042..298c4fa8f77 100644 --- a/src/Backups/BackupEntryFromSmallFile.h +++ b/src/Backups/BackupEntryFromSmallFile.h @@ -14,7 +14,7 @@ class BackupEntryFromSmallFile : public BackupEntryFromMemory { public: /// The constructor is allowed to not set `checksum_`, in that case it will be calculated from the data. - BackupEntryFromSmallFile( + explicit BackupEntryFromSmallFile( const String & file_path_, const std::optional & checksum_ = {}); diff --git a/src/Backups/IBackup.h b/src/Backups/IBackup.h index 2dbd0b6320b..0fd94a6d53c 100644 --- a/src/Backups/IBackup.h +++ b/src/Backups/IBackup.h @@ -16,7 +16,7 @@ using BackupEntryPtr = std::unique_ptr; class IBackup : public std::enable_shared_from_this, public TypePromotion { public: - IBackup() {} + IBackup() = default; virtual ~IBackup() = default; /// Name of the backup. @@ -44,7 +44,7 @@ public: /// before the terminator. For example, list("", "") returns names of all the entries /// in the backup; and list("data/", "/") return kind of a list of folders and /// files stored in the "data/" directory inside the backup. - virtual Strings listFiles(const String & prefix = "", const String & terminator = "/") const = 0; + virtual Strings listFiles(const String & prefix = "", const String & terminator = "/") const = 0; /// NOLINT /// Checks if an entry with a specified name exists. virtual bool fileExists(const String & file_name) const = 0; diff --git a/src/Client/ClientBase.h b/src/Client/ClientBase.h index e625d4a5c63..a902d320207 100644 --- a/src/Client/ClientBase.h +++ b/src/Client/ClientBase.h @@ -103,7 +103,6 @@ protected: const std::vector & hosts_and_ports_arguments) = 0; virtual void processConfig() = 0; -protected: bool processQueryText(const String & text); private: diff --git a/src/Client/ConnectionParameters.h b/src/Client/ConnectionParameters.h index dc509049c83..88c7ff3a001 100644 --- a/src/Client/ConnectionParameters.h +++ b/src/Client/ConnectionParameters.h @@ -22,8 +22,8 @@ struct ConnectionParameters Protocol::Compression compression = Protocol::Compression::Enable; ConnectionTimeouts timeouts; - ConnectionParameters() {} - ConnectionParameters(const Poco::Util::AbstractConfiguration & config); + ConnectionParameters() = default; + explicit ConnectionParameters(const Poco::Util::AbstractConfiguration & config); ConnectionParameters(const Poco::Util::AbstractConfiguration & config, std::string host, int port); static int getPortFromConfig(const Poco::Util::AbstractConfiguration & config); diff --git a/src/Client/ConnectionPool.h b/src/Client/ConnectionPool.h index 8f7bb2116d4..ec1233df1b5 100644 --- a/src/Client/ConnectionPool.h +++ b/src/Client/ConnectionPool.h @@ -25,12 +25,11 @@ class IConnectionPool : private boost::noncopyable public: using Entry = PoolBase::Entry; -public: virtual ~IConnectionPool() = default; /// Selects the connection to work. /// If force_connected is false, the client must manually ensure that returned connection is good. - virtual Entry get(const ConnectionTimeouts & timeouts, + virtual Entry get(const ConnectionTimeouts & timeouts, /// NOLINT const Settings * settings = nullptr, bool force_connected = true) = 0; @@ -76,7 +75,7 @@ public: { } - Entry get(const ConnectionTimeouts & timeouts, + Entry get(const ConnectionTimeouts & timeouts, /// NOLINT const Settings * settings = nullptr, bool force_connected = true) override { diff --git a/src/Client/ConnectionPoolWithFailover.h b/src/Client/ConnectionPoolWithFailover.h index ce70c27838b..4e47905aae6 100644 --- a/src/Client/ConnectionPoolWithFailover.h +++ b/src/Client/ConnectionPoolWithFailover.h @@ -109,7 +109,6 @@ private: GetPriorityFunc makeGetPriorityFunc(const Settings * settings); -private: std::vector hostname_differences; /// Distances from name of this host to the names of hosts of pools. size_t last_used = 0; /// Last used for round_robin policy. LoadBalancing default_load_balancing; diff --git a/src/Client/IConnections.cpp b/src/Client/IConnections.cpp index 1ab7ba6e5d8..9cc5a62ce12 100644 --- a/src/Client/IConnections.cpp +++ b/src/Client/IConnections.cpp @@ -22,7 +22,7 @@ struct PocoSocketWrapper : public Poco::Net::SocketImpl ~PocoSocketWrapper() override { reset(-1); } }; -void IConnections::DrainCallback::operator()(int fd, Poco::Timespan, const std::string fd_description) const +void IConnections::DrainCallback::operator()(int fd, Poco::Timespan, const std::string & fd_description) const { if (!PocoSocketWrapper(fd).poll(drain_timeout, Poco::Net::Socket::SELECT_READ)) { diff --git a/src/Client/IConnections.h b/src/Client/IConnections.h index 8dbd58c9598..9d695e6da92 100644 --- a/src/Client/IConnections.h +++ b/src/Client/IConnections.h @@ -16,7 +16,7 @@ public: struct DrainCallback { Poco::Timespan drain_timeout; - void operator()(int fd, Poco::Timespan, const std::string fd_description = "") const; + void operator()(int fd, Poco::Timespan, const std::string & fd_description = "") const; }; /// Send all scalars to replicas. diff --git a/src/Client/IServerConnection.h b/src/Client/IServerConnection.h index b7c6ae314e2..861630a942b 100644 --- a/src/Client/IServerConnection.h +++ b/src/Client/IServerConnection.h @@ -14,7 +14,6 @@ #include - #include diff --git a/src/Client/QueryFuzzer.cpp b/src/Client/QueryFuzzer.cpp index 71c0a399c09..703e6de82c6 100644 --- a/src/Client/QueryFuzzer.cpp +++ b/src/Client/QueryFuzzer.cpp @@ -546,7 +546,7 @@ void QueryFuzzer::fuzz(ASTPtr & ast) * small probability. Do this after we add this fuzzer to CI and fix all the * problems it can routinely find even in this boring version. */ -void QueryFuzzer::collectFuzzInfoMain(const ASTPtr ast) +void QueryFuzzer::collectFuzzInfoMain(ASTPtr ast) { collectFuzzInfoRecurse(ast); @@ -569,7 +569,7 @@ void QueryFuzzer::collectFuzzInfoMain(const ASTPtr ast) } } -void QueryFuzzer::addTableLike(const ASTPtr ast) +void QueryFuzzer::addTableLike(ASTPtr ast) { if (table_like_map.size() > 1000) { @@ -583,7 +583,7 @@ void QueryFuzzer::addTableLike(const ASTPtr ast) } } -void QueryFuzzer::addColumnLike(const ASTPtr ast) +void QueryFuzzer::addColumnLike(ASTPtr ast) { if (column_like_map.size() > 1000) { @@ -606,7 +606,7 @@ void QueryFuzzer::addColumnLike(const ASTPtr ast) } } -void QueryFuzzer::collectFuzzInfoRecurse(const ASTPtr ast) +void QueryFuzzer::collectFuzzInfoRecurse(ASTPtr ast) { if (auto * impl = dynamic_cast(ast.get())) { diff --git a/src/Client/QueryFuzzer.h b/src/Client/QueryFuzzer.h index 09d57f4161f..25bd7f0c88d 100644 --- a/src/Client/QueryFuzzer.h +++ b/src/Client/QueryFuzzer.h @@ -71,10 +71,10 @@ struct QueryFuzzer void fuzzWindowFrame(ASTWindowDefinition & def); void fuzz(ASTs & asts); void fuzz(ASTPtr & ast); - void collectFuzzInfoMain(const ASTPtr ast); - void addTableLike(const ASTPtr ast); - void addColumnLike(const ASTPtr ast); - void collectFuzzInfoRecurse(const ASTPtr ast); + void collectFuzzInfoMain(ASTPtr ast); + void addTableLike(ASTPtr ast); + void addColumnLike(ASTPtr ast); + void collectFuzzInfoRecurse(ASTPtr ast); }; } diff --git a/src/Columns/Collator.h b/src/Columns/Collator.h index 93748f21f7f..37dbe0d4347 100644 --- a/src/Columns/Collator.h +++ b/src/Columns/Collator.h @@ -33,7 +33,7 @@ public: private: AvailableCollationLocales(); -private: + AvailableLocalesMap locales_map; }; diff --git a/src/Columns/ColumnAggregateFunction.h b/src/Columns/ColumnAggregateFunction.h index dfdfc09c816..0089faa27c9 100644 --- a/src/Columns/ColumnAggregateFunction.h +++ b/src/Columns/ColumnAggregateFunction.h @@ -92,7 +92,7 @@ private: /// Create a new column that has another column as a source. MutablePtr createView() const; - ColumnAggregateFunction(const AggregateFunctionPtr & func_, std::optional version_ = std::nullopt); + explicit ColumnAggregateFunction(const AggregateFunctionPtr & func_, std::optional version_ = std::nullopt); ColumnAggregateFunction(const AggregateFunctionPtr & func_, const ConstArenas & arenas_); diff --git a/src/Columns/ColumnArray.h b/src/Columns/ColumnArray.h index f4127d6de75..cc80d1300ce 100644 --- a/src/Columns/ColumnArray.h +++ b/src/Columns/ColumnArray.h @@ -158,7 +158,7 @@ public: bool structureEquals(const IColumn & rhs) const override { - if (auto rhs_concrete = typeid_cast(&rhs)) + if (const auto * rhs_concrete = typeid_cast(&rhs)) return data->structureEquals(*rhs_concrete->data); return false; } diff --git a/src/Columns/ColumnCompressed.h b/src/Columns/ColumnCompressed.h index 23392410292..b80ad3067bc 100644 --- a/src/Columns/ColumnCompressed.h +++ b/src/Columns/ColumnCompressed.h @@ -126,7 +126,7 @@ protected: Lazy lazy; private: - [[noreturn]] void throwMustBeDecompressed() const + [[noreturn]] static void throwMustBeDecompressed() { throw Exception("ColumnCompressed must be decompressed before use", ErrorCodes::LOGICAL_ERROR); } diff --git a/src/Columns/ColumnConst.h b/src/Columns/ColumnConst.h index 57a8406ca12..fdee16a1dbb 100644 --- a/src/Columns/ColumnConst.h +++ b/src/Columns/ColumnConst.h @@ -163,7 +163,7 @@ public: const char * deserializeAndInsertFromArena(const char * pos) override { - auto res = data->deserializeAndInsertFromArena(pos); + const auto * res = data->deserializeAndInsertFromArena(pos); data->popBack(1); ++s; return res; @@ -242,7 +242,7 @@ public: bool structureEquals(const IColumn & rhs) const override { - if (auto rhs_concrete = typeid_cast(&rhs)) + if (const auto * rhs_concrete = typeid_cast(&rhs)) return data->structureEquals(*rhs_concrete->data); return false; } diff --git a/src/Columns/ColumnFixedString.h b/src/Columns/ColumnFixedString.h index 7f61a6fbce5..711db056ee6 100644 --- a/src/Columns/ColumnFixedString.h +++ b/src/Columns/ColumnFixedString.h @@ -41,9 +41,9 @@ private: using ComparatorEqual = ComparatorEqualImpl; /** Create an empty column of strings of fixed-length `n` */ - ColumnFixedString(size_t n_) : n(n_) {} + explicit ColumnFixedString(size_t n_) : n(n_) {} - ColumnFixedString(const ColumnFixedString & src) : chars(src.chars.begin(), src.chars.end()), n(src.n) {} + ColumnFixedString(const ColumnFixedString & src) : chars(src.chars.begin(), src.chars.end()), n(src.n) {} /// NOLINT public: std::string getName() const override { return "FixedString(" + std::to_string(n) + ")"; } @@ -190,7 +190,7 @@ public: bool structureEquals(const IColumn & rhs) const override { - if (auto rhs_concrete = typeid_cast(&rhs)) + if (const auto * rhs_concrete = typeid_cast(&rhs)) return n == rhs_concrete->n; return false; } diff --git a/src/Columns/ColumnFunction.cpp b/src/Columns/ColumnFunction.cpp index f4b7eeb771c..6350d7b0e61 100644 --- a/src/Columns/ColumnFunction.cpp +++ b/src/Columns/ColumnFunction.cpp @@ -24,7 +24,7 @@ namespace ErrorCodes } ColumnFunction::ColumnFunction(size_t size, FunctionBasePtr function_, const ColumnsWithTypeAndName & columns_to_capture, bool is_short_circuit_argument_, bool is_function_compiled_) - : size_(size), function(function_), is_short_circuit_argument(is_short_circuit_argument_), is_function_compiled(is_function_compiled_) + : elements_size(size), function(function_), is_short_circuit_argument(is_short_circuit_argument_), is_function_compiled(is_function_compiled_) { appendArguments(columns_to_capture); } @@ -40,15 +40,15 @@ MutableColumnPtr ColumnFunction::cloneResized(size_t size) const ColumnPtr ColumnFunction::replicate(const Offsets & offsets) const { - if (size_ != offsets.size()) + if (elements_size != offsets.size()) throw Exception("Size of offsets (" + toString(offsets.size()) + ") doesn't match size of column (" - + toString(size_) + ")", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); + + toString(elements_size) + ")", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); ColumnsWithTypeAndName capture = captured_columns; for (auto & column : capture) column.column = column.column->replicate(offsets); - size_t replicated_size = 0 == size_ ? 0 : offsets.back(); + size_t replicated_size = 0 == elements_size ? 0 : offsets.back(); return ColumnFunction::create(replicated_size, function, capture, is_short_circuit_argument, is_function_compiled); } @@ -75,7 +75,7 @@ void ColumnFunction::insertFrom(const IColumn & src, size_t n) captured_columns[i].column = std::move(mut_column); } - ++size_; + ++elements_size; } void ColumnFunction::insertRangeFrom(const IColumn & src, size_t start, size_t length) @@ -92,14 +92,14 @@ void ColumnFunction::insertRangeFrom(const IColumn & src, size_t start, size_t l captured_columns[i].column = std::move(mut_column); } - size_ += length; + elements_size += length; } ColumnPtr ColumnFunction::filter(const Filter & filt, ssize_t result_size_hint) const { - if (size_ != filt.size()) + if (elements_size != filt.size()) throw Exception("Size of filter (" + toString(filt.size()) + ") doesn't match size of column (" - + toString(size_) + ")", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); + + toString(elements_size) + ")", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); ColumnsWithTypeAndName capture = captured_columns; for (auto & column : capture) @@ -124,7 +124,7 @@ void ColumnFunction::expand(const Filter & mask, bool inverted) column.column->assumeMutable()->expand(mask, inverted); } - size_ = mask.size(); + elements_size = mask.size(); } ColumnPtr ColumnFunction::permute(const Permutation & perm, size_t limit) const @@ -150,9 +150,9 @@ ColumnPtr ColumnFunction::index(const IColumn & indexes, size_t limit) const std::vector ColumnFunction::scatter(IColumn::ColumnIndex num_columns, const IColumn::Selector & selector) const { - if (size_ != selector.size()) + if (elements_size != selector.size()) throw Exception("Size of selector (" + toString(selector.size()) + ") doesn't match size of column (" - + toString(size_) + ")", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); + + toString(elements_size) + ")", ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH); std::vector counts; if (captured_columns.empty()) @@ -266,7 +266,7 @@ ColumnWithTypeAndName ColumnFunction::reduce() const if (is_function_compiled) ProfileEvents::increment(ProfileEvents::CompiledFunctionExecute); - res.column = function->execute(columns, res.type, size_); + res.column = function->execute(columns, res.type, elements_size); return res; } diff --git a/src/Columns/ColumnFunction.h b/src/Columns/ColumnFunction.h index d1ce73fe1a4..a6fa715e7e4 100644 --- a/src/Columns/ColumnFunction.h +++ b/src/Columns/ColumnFunction.h @@ -37,7 +37,7 @@ public: MutableColumnPtr cloneResized(size_t size) const override; - size_t size() const override { return size_; } + size_t size() const override { return elements_size; } ColumnPtr cut(size_t start, size_t length) const override; ColumnPtr replicate(const Offsets & offsets) const override; @@ -178,7 +178,7 @@ public: DataTypePtr getResultType() const; private: - size_t size_; + size_t elements_size; FunctionBasePtr function; ColumnsWithTypeAndName captured_columns; diff --git a/src/Columns/ColumnLowCardinality.h b/src/Columns/ColumnLowCardinality.h index d8dcacc5bd3..4fa6a0be4ed 100644 --- a/src/Columns/ColumnLowCardinality.h +++ b/src/Columns/ColumnLowCardinality.h @@ -179,7 +179,7 @@ public: bool structureEquals(const IColumn & rhs) const override { - if (auto rhs_low_cardinality = typeid_cast(&rhs)) + if (const auto * rhs_low_cardinality = typeid_cast(&rhs)) return idx.getPositions()->structureEquals(*rhs_low_cardinality->idx.getPositions()) && dictionary.getColumnUnique().structureEquals(rhs_low_cardinality->dictionary.getColumnUnique()); return false; diff --git a/src/Columns/ColumnNothing.h b/src/Columns/ColumnNothing.h index c2738bb4cdc..eec63bc05bb 100644 --- a/src/Columns/ColumnNothing.h +++ b/src/Columns/ColumnNothing.h @@ -11,7 +11,7 @@ class ColumnNothing final : public COWHelper private: friend class COWHelper; - ColumnNothing(size_t s_) + explicit ColumnNothing(size_t s_) { s = s_; } diff --git a/src/Columns/ColumnNullable.h b/src/Columns/ColumnNullable.h index 1b033095917..41ad099818e 100644 --- a/src/Columns/ColumnNullable.h +++ b/src/Columns/ColumnNullable.h @@ -137,7 +137,7 @@ public: bool structureEquals(const IColumn & rhs) const override { - if (auto rhs_nullable = typeid_cast(&rhs)) + if (const auto * rhs_nullable = typeid_cast(&rhs)) return nested_column->structureEquals(*rhs_nullable->nested_column); return false; } diff --git a/src/Columns/ColumnSparse.h b/src/Columns/ColumnSparse.h index 7eb891077fd..0c35961bd18 100644 --- a/src/Columns/ColumnSparse.h +++ b/src/Columns/ColumnSparse.h @@ -40,7 +40,7 @@ public: template ::value>::type> static MutablePtr create(TColumnPtr && values_, TColumnPtr && offsets_, size_t size_) { - return Base::create(std::move(values_), std::move(offsets_), size_); + return Base::create(std::forward(values_), std::forward(offsets_), size_); } static Ptr create(const ColumnPtr & values_) @@ -230,7 +230,7 @@ private: /// Sorted offsets of non-default values in the full column. /// 'offsets[i]' corresponds to 'values[i + 1]'. WrappedPtr offsets; - size_t _size; + size_t _size; /// NOLINT }; ColumnPtr recursiveRemoveSparse(const ColumnPtr & column); diff --git a/src/Columns/ColumnUnique.h b/src/Columns/ColumnUnique.h index 492ace73848..33135224e11 100644 --- a/src/Columns/ColumnUnique.h +++ b/src/Columns/ColumnUnique.h @@ -317,7 +317,7 @@ size_t ColumnUnique::uniqueInsert(const Field & x) if (valuesHaveFixedSize()) return uniqueInsertData(&x.reinterpret(), size_of_value_if_fixed); - auto & val = x.get(); + const auto & val = x.get(); return uniqueInsertData(val.data(), val.size()); } @@ -327,7 +327,7 @@ size_t ColumnUnique::uniqueInsertFrom(const IColumn & src, size_t n) if (is_nullable && src.isNullAt(n)) return getNullValueIndex(); - if (auto * nullable = checkAndGetColumn(src)) + if (const auto * nullable = checkAndGetColumn(src)) return uniqueInsertFrom(nullable->getNestedColumn(), n); auto ref = src.getDataAt(n); @@ -354,7 +354,7 @@ StringRef ColumnUnique::serializeValueIntoArena(size_t n, Arena & ar { static constexpr auto s = sizeof(UInt8); - auto pos = arena.allocContinue(s, begin); + auto * pos = arena.allocContinue(s, begin); UInt8 flag = (n == getNullValueIndex() ? 1 : 0); unalignedStore(pos, flag); @@ -491,7 +491,7 @@ MutableColumnPtr ColumnUnique::uniqueInsertRangeImpl( return nullptr; }; - if (auto * nullable_column = checkAndGetColumn(src)) + if (const auto * nullable_column = checkAndGetColumn(src)) { src_column = typeid_cast(&nullable_column->getNestedColumn()); null_map = &nullable_column->getNullMapData(); @@ -555,7 +555,7 @@ MutableColumnPtr ColumnUnique::uniqueInsertRangeImpl( template MutableColumnPtr ColumnUnique::uniqueInsertRangeFrom(const IColumn & src, size_t start, size_t length) { - auto callForType = [this, &src, start, length](auto x) -> MutableColumnPtr + auto call_for_type = [this, &src, start, length](auto x) -> MutableColumnPtr { size_t size = getRawColumnPtr()->size(); @@ -571,13 +571,13 @@ MutableColumnPtr ColumnUnique::uniqueInsertRangeFrom(const IColumn & MutableColumnPtr positions_column; if (!positions_column) - positions_column = callForType(UInt8()); + positions_column = call_for_type(UInt8()); if (!positions_column) - positions_column = callForType(UInt16()); + positions_column = call_for_type(UInt16()); if (!positions_column) - positions_column = callForType(UInt32()); + positions_column = call_for_type(UInt32()); if (!positions_column) - positions_column = callForType(UInt64()); + positions_column = call_for_type(UInt64()); if (!positions_column) throw Exception("Can't find index type for ColumnUnique", ErrorCodes::LOGICAL_ERROR); @@ -598,7 +598,7 @@ IColumnUnique::IndexesWithOverflow ColumnUnique::uniqueInsertRangeWi if (!overflowed_keys_ptr) throw Exception("Invalid keys type for ColumnUnique.", ErrorCodes::LOGICAL_ERROR); - auto callForType = [this, &src, start, length, overflowed_keys_ptr, max_dictionary_size](auto x) -> MutableColumnPtr + auto call_for_type = [this, &src, start, length, overflowed_keys_ptr, max_dictionary_size](auto x) -> MutableColumnPtr { size_t size = getRawColumnPtr()->size(); @@ -617,13 +617,13 @@ IColumnUnique::IndexesWithOverflow ColumnUnique::uniqueInsertRangeWi MutableColumnPtr positions_column; if (!positions_column) - positions_column = callForType(UInt8()); + positions_column = call_for_type(UInt8()); if (!positions_column) - positions_column = callForType(UInt16()); + positions_column = call_for_type(UInt16()); if (!positions_column) - positions_column = callForType(UInt32()); + positions_column = call_for_type(UInt32()); if (!positions_column) - positions_column = callForType(UInt64()); + positions_column = call_for_type(UInt64()); if (!positions_column) throw Exception("Can't find index type for ColumnUnique", ErrorCodes::LOGICAL_ERROR); diff --git a/src/Columns/ColumnVector.h b/src/Columns/ColumnVector.h index 5641958aceb..ea9eae1881c 100644 --- a/src/Columns/ColumnVector.h +++ b/src/Columns/ColumnVector.h @@ -127,8 +127,8 @@ public: using Container = PaddedPODArray; private: - ColumnVector() {} - ColumnVector(const size_t n) : data(n) {} + ColumnVector() = default; + explicit ColumnVector(const size_t n) : data(n) {} ColumnVector(const size_t n, const ValueType x) : data(n, x) {} ColumnVector(const ColumnVector & src) : data(src.data.begin(), src.data.end()) {} diff --git a/src/Columns/ColumnsCommon.h b/src/Columns/ColumnsCommon.h index 0c307cac291..cce90f508ad 100644 --- a/src/Columns/ColumnsCommon.h +++ b/src/Columns/ColumnsCommon.h @@ -96,13 +96,13 @@ ColumnPtr selectIndexImpl(const Column & column, const IColumn & indexes, size_t throw Exception(ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH, "Size of indexes ({}) is less than required ({})", indexes.size(), limit); - if (auto * data_uint8 = detail::getIndexesData(indexes)) + if (const auto * data_uint8 = detail::getIndexesData(indexes)) return column.template indexImpl(*data_uint8, limit); - else if (auto * data_uint16 = detail::getIndexesData(indexes)) + else if (const auto * data_uint16 = detail::getIndexesData(indexes)) return column.template indexImpl(*data_uint16, limit); - else if (auto * data_uint32 = detail::getIndexesData(indexes)) + else if (const auto * data_uint32 = detail::getIndexesData(indexes)) return column.template indexImpl(*data_uint32, limit); - else if (auto * data_uint64 = detail::getIndexesData(indexes)) + else if (const auto * data_uint64 = detail::getIndexesData(indexes)) return column.template indexImpl(*data_uint64, limit); else throw Exception("Indexes column for IColumn::select must be ColumnUInt, got " + indexes.getName(), @@ -118,6 +118,7 @@ ColumnPtr permuteImpl(const Column & column, const IColumn::Permutation & perm, return column.indexImpl(perm, limit); } +/// NOLINTNEXTLINE #define INSTANTIATE_INDEX_IMPL(Column) \ template ColumnPtr Column::indexImpl(const PaddedPODArray & indexes, size_t limit) const; \ template ColumnPtr Column::indexImpl(const PaddedPODArray & indexes, size_t limit) const; \ diff --git a/src/Columns/IColumn.h b/src/Columns/IColumn.h index 81ccba38282..9bf5e067cce 100644 --- a/src/Columns/IColumn.h +++ b/src/Columns/IColumn.h @@ -413,7 +413,7 @@ public: /// Returns ration of values in column, that equal to default value of column. /// Checks only @sample_ratio ratio of rows. - virtual double getRatioOfDefaultRows(double sample_ratio = 1.0) const = 0; + virtual double getRatioOfDefaultRows(double sample_ratio = 1.0) const = 0; /// NOLINT /// Returns indices of values in column, that not equal to default value of column. virtual void getIndicesOfNonDefaultRows(Offsets & indices, size_t from, size_t limit) const = 0; diff --git a/src/Columns/IColumnDummy.h b/src/Columns/IColumnDummy.h index 34a2510e36c..5ef343bc578 100644 --- a/src/Columns/IColumnDummy.h +++ b/src/Columns/IColumnDummy.h @@ -24,9 +24,8 @@ class IColumnDummy : public IColumn { public: IColumnDummy() : s(0) {} - IColumnDummy(size_t s_) : s(s_) {} + explicit IColumnDummy(size_t s_) : s(s_) {} -public: virtual MutableColumnPtr cloneDummy(size_t s_) const = 0; MutableColumnPtr cloneResized(size_t s_) const override { return cloneDummy(s_); } diff --git a/src/Columns/ReverseIndex.h b/src/Columns/ReverseIndex.h index 1f49e2cb225..0b308a81084 100644 --- a/src/Columns/ReverseIndex.h +++ b/src/Columns/ReverseIndex.h @@ -17,300 +17,298 @@ namespace ErrorCodes extern const int LOGICAL_ERROR; } -namespace +template +struct ReverseIndexHashTableState; + +template +struct ReverseIndexHashTableState { - template - struct ReverseIndexHashTableState; + constexpr static bool with_saved_hash = false; + constexpr static bool has_base_index = false; - template - struct ReverseIndexHashTableState + ColumnType * index_column; +}; + +template +struct ReverseIndexHashTableState +{ + constexpr static bool with_saved_hash = false; + constexpr static bool has_base_index = true; + + ColumnType * index_column; + size_t base_index; +}; + +template +struct ReverseIndexHashTableState +{ + constexpr static bool with_saved_hash = true; + constexpr static bool has_base_index = false; + + ColumnType * index_column; + typename ColumnVector::Container * saved_hash_column; +}; + +template +struct ReverseIndexHashTableState +{ + constexpr static bool with_saved_hash = true; + constexpr static bool has_base_index = true; + + ColumnType * index_column; + typename ColumnVector::Container * saved_hash_column; + size_t base_index; +}; + + +struct ReverseIndexHash +{ + template + size_t operator()(T) const { - constexpr static bool with_saved_hash = false; - constexpr static bool has_base_index = false; - - ColumnType * index_column; - }; - - template - struct ReverseIndexHashTableState - { - constexpr static bool with_saved_hash = false; - constexpr static bool has_base_index = true; - - ColumnType * index_column; - size_t base_index; - }; - - template - struct ReverseIndexHashTableState - { - constexpr static bool with_saved_hash = true; - constexpr static bool has_base_index = false; - - ColumnType * index_column; - typename ColumnVector::Container * saved_hash_column; - }; - - template - struct ReverseIndexHashTableState - { - constexpr static bool with_saved_hash = true; - constexpr static bool has_base_index = true; - - ColumnType * index_column; - typename ColumnVector::Container * saved_hash_column; - size_t base_index; - }; - - - struct ReverseIndexHash - { - template - size_t operator()(T) const - { - throw Exception("operator()(key) is not implemented for ReverseIndexHash.", ErrorCodes::LOGICAL_ERROR); - } - }; - - template - struct ReverseIndexHashTableCell - : public HashTableCell> - { - using Base = HashTableCell>; - using State = typename Base::State; - using Base::Base; - using Base::key; - using Base::keyEquals; - using Base::isZero; - - template - static bool isZero(const T &, const State & /*state*/) - { - /// Careful: apparently this uses SFINAE to redefine isZero for all types - /// except the IndexType, for which the default ZeroTraits::isZero is used. - static_assert(!std::is_same_v::type, typename std::decay::type>); - return false; - } - - /// Special case when we want to compare with something not in index_column. - /// When we compare something inside column default keyEquals checks only that row numbers are equal. - bool keyEquals(const StringRef & object, size_t hash_ [[maybe_unused]], const State & state) const - { - auto index = key; - if constexpr (has_base_index) - index -= state.base_index; - - if constexpr (string_hash) - return hash_ == (*state.saved_hash_column)[index] && object == state.index_column->getDataAt(index); - else - return object == state.index_column->getDataAt(index); - } - - size_t getHash(const Hash & hash) const - { - auto index = key; - - /// Hack. HashTable is Hash itself. - const auto & state = static_cast(static_cast(hash)); - - if constexpr (has_base_index) - index -= state.base_index; - - if constexpr (string_hash) - return (*state.saved_hash_column)[index]; - else - { - using ValueType = typename ColumnType::ValueType; - ValueType value = unalignedLoad(state.index_column->getDataAt(index).data); - return DefaultHash()(value); - } - } - }; - - - /** - * ReverseIndexHashTableBase implements a special hash table interface for - * reverse index. - * - * The following requirements are different compared to a plain hash table: - * - * 1) Provide public access to 'hash table state' that contains - * additional data needed to calculate cell hashes. - * - * 2) Support emplace() and find() with a Key different from the resulting - * hash table key. This means emplace() accepts a different kind of object - * as a key, and then the real key can be read from the returned cell iterator. - * - * These requirements are unique to ReverseIndex and are in conflict with - * supporting hash tables that use alternative key storage, such as FixedHashMap - * or StringHashMap. Therefore, we implement an interface for ReverseIndex - * separately. - */ - template - class ReverseIndexHashTableBase : public HashTable, HashTableAllocator> - { - using State = typename Cell::State; - using Base = HashTable, HashTableAllocator>; - - public: - using Base::Base; - using iterator = typename Base::iterator; - using LookupResult = typename Base::LookupResult; - State & getState() { return *this; } - - - template - size_t ALWAYS_INLINE reverseIndexFindCell(const ObjectToCompareWith & x, - size_t hash_value, size_t place_value) const - { - while (!this->buf[place_value].isZero(*this) - && !this->buf[place_value].keyEquals(x, hash_value, *this)) - { - place_value = this->grower.next(place_value); - } - - return place_value; - } - - template - void ALWAYS_INLINE reverseIndexEmplaceNonZero(const Key & key, LookupResult & it, - bool & inserted, size_t hash_value, const ObjectToCompareWith & object) - { - size_t place_value = reverseIndexFindCell(object, hash_value, - this->grower.place(hash_value)); - // emplaceNonZeroImpl() might need to re-find the cell if the table grows, - // but it will find it correctly by the key alone, so we don't have to - // pass it the 'object'. - this->emplaceNonZeroImpl(place_value, key, it, inserted, hash_value); - } - - /// Searches position by object. - template - void ALWAYS_INLINE reverseIndexEmplace(Key key, iterator & it, bool & inserted, - size_t hash_value, const ObjectToCompareWith& object) - { - LookupResult impl_it = nullptr; - - if (!this->emplaceIfZero(key, impl_it, inserted, hash_value)) - { - reverseIndexEmplaceNonZero(key, impl_it, inserted, hash_value, object); - } - assert(impl_it != nullptr); - it = iterator(this, impl_it); - } - - template - iterator ALWAYS_INLINE reverseIndexFind(ObjectToCompareWith x, size_t hash_value) - { - if (Cell::isZero(x, *this)) - return this->hasZero() ? this->iteratorToZero() : this->end(); - - size_t place_value = reverseIndexFindCell(x, hash_value, - this->grower.place(hash_value)); - return !this->buf[place_value].isZero(*this) - ? iterator(this, &this->buf[place_value]) - : this->end(); - } - }; - - template - class ReverseIndexStringHashTable : public ReverseIndexHashTableBase< - IndexType, - ReverseIndexHashTableCell< - IndexType, - ReverseIndexHash, - ReverseIndexStringHashTable, - ColumnType, - true, - has_base_index>, - ReverseIndexHash> - { - using Base = ReverseIndexHashTableBase< - IndexType, - ReverseIndexHashTableCell< - IndexType, - ReverseIndexHash, - ReverseIndexStringHashTable, - ColumnType, - true, - has_base_index>, - ReverseIndexHash>; - public: - using Base::Base; - friend struct ReverseIndexHashTableCell< - IndexType, - ReverseIndexHash, - ReverseIndexStringHashTable, - ColumnType, - true, - has_base_index>; - }; - - template - class ReverseIndexNumberHashTable : public ReverseIndexHashTableBase< - IndexType, - ReverseIndexHashTableCell< - IndexType, - ReverseIndexHash, - ReverseIndexNumberHashTable, - ColumnType, - false, - has_base_index>, - ReverseIndexHash> - { - using Base = ReverseIndexHashTableBase< - IndexType, - ReverseIndexHashTableCell< - IndexType, - ReverseIndexHash, - ReverseIndexNumberHashTable, - ColumnType, - false, - has_base_index>, - ReverseIndexHash>; - public: - using Base::Base; - friend struct ReverseIndexHashTableCell< - IndexType, - ReverseIndexHash, - ReverseIndexNumberHashTable, - ColumnType, - false, - has_base_index>; - }; - - - template - struct SelectReverseIndexHashTable; - - template - struct SelectReverseIndexHashTable - { - using Type = ReverseIndexNumberHashTable; - }; - - template - struct SelectReverseIndexHashTable - { - using Type = ReverseIndexStringHashTable; - }; + throw Exception("operator()(key) is not implemented for ReverseIndexHash.", ErrorCodes::LOGICAL_ERROR); + } +}; +template +struct ReverseIndexHashTableCell + : public HashTableCell> +{ + using Base = HashTableCell>; + using State = typename Base::State; + using Base::Base; + using Base::isZero; + using Base::key; + using Base::keyEquals; template - constexpr bool isNumericColumn(const T *) { return false; } + static bool isZero(const T &, const State & /*state*/) + { + /// Careful: apparently this uses SFINAE to redefine isZero for all types + /// except the IndexType, for which the default ZeroTraits::isZero is used. + static_assert(!std::is_same_v::type, typename std::decay::type>); + return false; + } - template - constexpr bool isNumericColumn(const ColumnVector *) { return true; } + /// Special case when we want to compare with something not in index_column. + /// When we compare something inside column default keyEquals checks only that row numbers are equal. + bool keyEquals(const StringRef & object, size_t hash_ [[maybe_unused]], const State & state) const + { + auto index = key; + if constexpr (has_base_index) + index -= state.base_index; - static_assert(isNumericColumn(static_cast *>(nullptr))); - static_assert(!isNumericColumn(static_cast(nullptr))); + if constexpr (string_hash) + return hash_ == (*state.saved_hash_column)[index] && object == state.index_column->getDataAt(index); + else + return object == state.index_column->getDataAt(index); + } + + size_t getHash(const Hash & hash) const + { + auto index = key; + + /// Hack. HashTable is Hash itself. + const auto & state = static_cast(static_cast(hash)); + + if constexpr (has_base_index) + index -= state.base_index; + + if constexpr (string_hash) + return (*state.saved_hash_column)[index]; + else + { + using ValueType = typename ColumnType::ValueType; + ValueType value = unalignedLoad(state.index_column->getDataAt(index).data); + return DefaultHash()(value); + } + } +}; - template - using ReverseIndexHashTable = typename SelectReverseIndexHashTable(nullptr))>::Type; +/** + * ReverseIndexHashTableBase implements a special hash table interface for + * reverse index. + * + * The following requirements are different compared to a plain hash table: + * + * 1) Provide public access to 'hash table state' that contains + * additional data needed to calculate cell hashes. + * + * 2) Support emplace() and find() with a Key different from the resulting + * hash table key. This means emplace() accepts a different kind of object + * as a key, and then the real key can be read from the returned cell iterator. + * + * These requirements are unique to ReverseIndex and are in conflict with + * supporting hash tables that use alternative key storage, such as FixedHashMap + * or StringHashMap. Therefore, we implement an interface for ReverseIndex + * separately. + */ +template +class ReverseIndexHashTableBase : public HashTable, HashTableAllocator> +{ + using State = typename Cell::State; + using Base = HashTable, HashTableAllocator>; + +public: + using Base::Base; + using iterator = typename Base::iterator; + using LookupResult = typename Base::LookupResult; + State & getState() { return *this; } + + + template + size_t ALWAYS_INLINE reverseIndexFindCell(const ObjectToCompareWith & x, size_t hash_value, size_t place_value) const + { + while (!this->buf[place_value].isZero(*this) && !this->buf[place_value].keyEquals(x, hash_value, *this)) + { + place_value = this->grower.next(place_value); + } + + return place_value; + } + + template + void ALWAYS_INLINE + reverseIndexEmplaceNonZero(const Key & key, LookupResult & it, bool & inserted, size_t hash_value, const ObjectToCompareWith & object) + { + size_t place_value = reverseIndexFindCell(object, hash_value, this->grower.place(hash_value)); + // emplaceNonZeroImpl() might need to re-find the cell if the table grows, + // but it will find it correctly by the key alone, so we don't have to + // pass it the 'object'. + this->emplaceNonZeroImpl(place_value, key, it, inserted, hash_value); + } + + /// Searches position by object. + template + void ALWAYS_INLINE reverseIndexEmplace(Key key, iterator & it, bool & inserted, size_t hash_value, const ObjectToCompareWith & object) + { + LookupResult impl_it = nullptr; + + if (!this->emplaceIfZero(key, impl_it, inserted, hash_value)) + { + reverseIndexEmplaceNonZero(key, impl_it, inserted, hash_value, object); + } + assert(impl_it != nullptr); + it = iterator(this, impl_it); + } + + template + iterator ALWAYS_INLINE reverseIndexFind(ObjectToCompareWith x, size_t hash_value) + { + if (Cell::isZero(x, *this)) + return this->hasZero() ? this->iteratorToZero() : this->end(); + + size_t place_value = reverseIndexFindCell(x, hash_value, this->grower.place(hash_value)); + return !this->buf[place_value].isZero(*this) ? iterator(this, &this->buf[place_value]) : this->end(); + } +}; + +template +class ReverseIndexStringHashTable : public ReverseIndexHashTableBase< + IndexType, + ReverseIndexHashTableCell< + IndexType, + ReverseIndexHash, + ReverseIndexStringHashTable, + ColumnType, + true, + has_base_index>, + ReverseIndexHash> +{ + using Base = ReverseIndexHashTableBase< + IndexType, + ReverseIndexHashTableCell< + IndexType, + ReverseIndexHash, + ReverseIndexStringHashTable, + ColumnType, + true, + has_base_index>, + ReverseIndexHash>; + +public: + using Base::Base; + friend struct ReverseIndexHashTableCell< + IndexType, + ReverseIndexHash, + ReverseIndexStringHashTable, + ColumnType, + true, + has_base_index>; +}; + +template +class ReverseIndexNumberHashTable : public ReverseIndexHashTableBase< + IndexType, + ReverseIndexHashTableCell< + IndexType, + ReverseIndexHash, + ReverseIndexNumberHashTable, + ColumnType, + false, + has_base_index>, + ReverseIndexHash> +{ + using Base = ReverseIndexHashTableBase< + IndexType, + ReverseIndexHashTableCell< + IndexType, + ReverseIndexHash, + ReverseIndexNumberHashTable, + ColumnType, + false, + has_base_index>, + ReverseIndexHash>; + +public: + using Base::Base; + friend struct ReverseIndexHashTableCell< + IndexType, + ReverseIndexHash, + ReverseIndexNumberHashTable, + ColumnType, + false, + has_base_index>; +}; + + +template +struct SelectReverseIndexHashTable; + +template +struct SelectReverseIndexHashTable +{ + using Type = ReverseIndexNumberHashTable; +}; + +template +struct SelectReverseIndexHashTable +{ + using Type = ReverseIndexStringHashTable; +}; + + +template +constexpr bool isNumericColumn(const T *) +{ + return false; } +template +constexpr bool isNumericColumn(const ColumnVector *) +{ + return true; +} + +static_assert(isNumericColumn(static_cast *>(nullptr))); +static_assert(!isNumericColumn(static_cast(nullptr))); + + +template +using ReverseIndexHashTable = + typename SelectReverseIndexHashTable(nullptr))>::Type; + template class ReverseIndex diff --git a/src/Common/AlignedBuffer.h b/src/Common/AlignedBuffer.h index 0d9ecb61f2b..4682baa8f1c 100644 --- a/src/Common/AlignedBuffer.h +++ b/src/Common/AlignedBuffer.h @@ -21,9 +21,9 @@ private: void dealloc(); public: - AlignedBuffer() {} + AlignedBuffer() = default; AlignedBuffer(size_t size, size_t alignment); - AlignedBuffer(AlignedBuffer && old) { std::swap(buf, old.buf); } + AlignedBuffer(AlignedBuffer && old) noexcept { std::swap(buf, old.buf); } ~AlignedBuffer(); void reset(size_t size, size_t alignment); diff --git a/src/Common/AllocatorWithMemoryTracking.h b/src/Common/AllocatorWithMemoryTracking.h index e9597e4bf5a..815c326ed62 100644 --- a/src/Common/AllocatorWithMemoryTracking.h +++ b/src/Common/AllocatorWithMemoryTracking.h @@ -15,12 +15,12 @@ template struct AllocatorWithMemoryTracking { - typedef T value_type; + using value_type = T; AllocatorWithMemoryTracking() = default; template - constexpr AllocatorWithMemoryTracking(const AllocatorWithMemoryTracking &) noexcept + constexpr explicit AllocatorWithMemoryTracking(const AllocatorWithMemoryTracking &) noexcept { } diff --git a/src/Common/Arena.h b/src/Common/Arena.h index 4d14c15197d..4c7ee458ee4 100644 --- a/src/Common/Arena.h +++ b/src/Common/Arena.h @@ -69,8 +69,7 @@ private: Allocator::free(begin, size()); - if (prev) - delete prev; + delete prev; } size_t size() const { return end + pad_right - begin; } diff --git a/src/Common/ArenaUtils.h b/src/Common/ArenaUtils.h index 0a588692367..0c31b1b2533 100644 --- a/src/Common/ArenaUtils.h +++ b/src/Common/ArenaUtils.h @@ -11,10 +11,10 @@ template inline StringRef copyStringInArena(Arena & arena, StringRef value) { - size_t key_size = value.size; - char * place_for_key = arena.alloc(key_size); - memcpy(reinterpret_cast(place_for_key), reinterpret_cast(value.data), key_size); - StringRef result{place_for_key, key_size}; + size_t value_size = value.size; + char * place_for_key = arena.alloc(value_size); + memcpy(reinterpret_cast(place_for_key), reinterpret_cast(value.data), value_size); + StringRef result{place_for_key, value_size}; return result; } diff --git a/src/Common/ArenaWithFreeLists.h b/src/Common/ArenaWithFreeLists.h index 1284c3586c0..cd4c1bc9d8d 100644 --- a/src/Common/ArenaWithFreeLists.h +++ b/src/Common/ArenaWithFreeLists.h @@ -49,7 +49,7 @@ private: Block * free_lists[16] {}; public: - ArenaWithFreeLists( + explicit ArenaWithFreeLists( const size_t initial_size = 4096, const size_t growth_factor = 2, const size_t linear_growth_threshold = 128 * 1024 * 1024) : pool{initial_size, growth_factor, linear_growth_threshold} @@ -74,7 +74,7 @@ public: ASAN_UNPOISON_MEMORY_REGION(free_block_ptr, std::max(size, sizeof(Block))); - const auto res = free_block_ptr->data; + auto * const res = free_block_ptr->data; free_block_ptr = free_block_ptr->next; return res; } @@ -93,7 +93,7 @@ public: /// Insert the released block into the head of the list. auto & free_block_ptr = free_lists[list_idx]; - const auto old_head = free_block_ptr; + auto * const old_head = free_block_ptr; free_block_ptr = reinterpret_cast(ptr); free_block_ptr->next = old_head; diff --git a/src/Common/ArrayCache.h b/src/Common/ArrayCache.h index 19f775db31f..6efa5c92b5b 100644 --- a/src/Common/ArrayCache.h +++ b/src/Common/ArrayCache.h @@ -188,7 +188,7 @@ private: DB::throwFromErrno(fmt::format("Allocator: Cannot munmap {}.", ReadableSize(size)), DB::ErrorCodes::CANNOT_MUNMAP); } - Chunk(Chunk && other) : ptr(other.ptr), size(other.size) + Chunk(Chunk && other) noexcept : ptr(other.ptr), size(other.size) { other.ptr = nullptr; } @@ -261,7 +261,7 @@ private: /// Represents pending insertion attempt. struct InsertToken { - InsertToken(ArrayCache & cache_) : cache(cache_) {} + explicit InsertToken(ArrayCache & cache_) : cache(cache_) {} std::mutex mutex; bool cleaned_up = false; /// Protected by the token mutex @@ -535,7 +535,7 @@ private: public: - ArrayCache(size_t max_total_size_) : max_total_size(max_total_size_) + explicit ArrayCache(size_t max_total_size_) : max_total_size(max_total_size_) { } diff --git a/src/Common/BitHelpers.h b/src/Common/BitHelpers.h index 9c6071822f3..0e9e39cb1b2 100644 --- a/src/Common/BitHelpers.h +++ b/src/Common/BitHelpers.h @@ -39,7 +39,7 @@ inline size_t getLeadingZeroBitsUnsafe(T x) { return __builtin_clz(x); } - else if constexpr (sizeof(T) <= sizeof(unsigned long int)) + else if constexpr (sizeof(T) <= sizeof(unsigned long int)) /// NOLINT { return __builtin_clzl(x); } @@ -79,7 +79,7 @@ inline size_t getTrailingZeroBitsUnsafe(T x) { return __builtin_ctz(x); } - else if constexpr (sizeof(T) <= sizeof(unsigned long int)) + else if constexpr (sizeof(T) <= sizeof(unsigned long int)) /// NOLINT { return __builtin_ctzl(x); } diff --git a/src/Common/COW.h b/src/Common/COW.h index 23733a8635d..f958fe71824 100644 --- a/src/Common/COW.h +++ b/src/Common/COW.h @@ -81,7 +81,7 @@ private: protected: template - class mutable_ptr : public boost::intrusive_ptr + class mutable_ptr : public boost::intrusive_ptr /// NOLINT { private: using Base = boost::intrusive_ptr; @@ -96,16 +96,16 @@ protected: mutable_ptr(const mutable_ptr &) = delete; /// Move: ok. - mutable_ptr(mutable_ptr &&) = default; - mutable_ptr & operator=(mutable_ptr &&) = default; + mutable_ptr(mutable_ptr &&) = default; /// NOLINT + mutable_ptr & operator=(mutable_ptr &&) = default; /// NOLINT /// Initializing from temporary of compatible type. template - mutable_ptr(mutable_ptr && other) : Base(std::move(other)) {} + mutable_ptr(mutable_ptr && other) : Base(std::move(other)) {} /// NOLINT mutable_ptr() = default; - mutable_ptr(std::nullptr_t) {} + mutable_ptr(std::nullptr_t) {} /// NOLINT }; public: @@ -113,7 +113,7 @@ public: protected: template - class immutable_ptr : public boost::intrusive_ptr + class immutable_ptr : public boost::intrusive_ptr /// NOLINT { private: using Base = boost::intrusive_ptr; @@ -129,19 +129,19 @@ protected: immutable_ptr & operator=(const immutable_ptr &) = default; template - immutable_ptr(const immutable_ptr & other) : Base(other) {} + immutable_ptr(const immutable_ptr & other) : Base(other) {} /// NOLINT /// Move: ok. - immutable_ptr(immutable_ptr &&) = default; - immutable_ptr & operator=(immutable_ptr &&) = default; + immutable_ptr(immutable_ptr &&) = default; /// NOLINT + immutable_ptr & operator=(immutable_ptr &&) = default; /// NOLINT /// Initializing from temporary of compatible type. template - immutable_ptr(immutable_ptr && other) : Base(std::move(other)) {} + immutable_ptr(immutable_ptr && other) : Base(std::move(other)) {} /// NOLINT /// Move from mutable ptr: ok. template - immutable_ptr(mutable_ptr && other) : Base(std::move(other)) {} + immutable_ptr(mutable_ptr && other) : Base(std::move(other)) {} /// NOLINT /// Copy from mutable ptr: not possible. template @@ -149,7 +149,7 @@ protected: immutable_ptr() = default; - immutable_ptr(std::nullptr_t) {} + immutable_ptr(std::nullptr_t) {} /// NOLINT }; public: @@ -161,7 +161,6 @@ public: template static MutablePtr create(std::initializer_list && arg) { return create(std::forward>(arg)); } -public: Ptr getPtr() const { return static_cast(derived()); } MutablePtr getPtr() { return static_cast(derived()); } @@ -193,14 +192,14 @@ public: protected: /// It works as immutable_ptr if it is const and as mutable_ptr if it is non const. template - class chameleon_ptr + class chameleon_ptr /// NOLINT { private: immutable_ptr value; public: template - chameleon_ptr(Args &&... args) : value(std::forward(args)...) {} + chameleon_ptr(Args &&... args) : value(std::forward(args)...) {} /// NOLINT template chameleon_ptr(std::initializer_list && arg) : value(std::forward>(arg)) {} @@ -214,13 +213,13 @@ protected: const T & operator*() const { return *value; } T & operator*() { return value->assumeMutableRef(); } - operator const immutable_ptr & () const { return value; } - operator immutable_ptr & () { return value; } + operator const immutable_ptr & () const { return value; } /// NOLINT + operator immutable_ptr & () { return value; } /// NOLINT /// Get internal immutable ptr. Does not change internal use counter. immutable_ptr detach() && { return std::move(value); } - operator bool() const { return value != nullptr; } + operator bool() const { return value != nullptr; } /// NOLINT bool operator! () const { return value == nullptr; } bool operator== (const chameleon_ptr & rhs) const { return value == rhs.value; } diff --git a/src/Common/ColumnsHashing.h b/src/Common/ColumnsHashing.h index d84c5ef9b3e..c3a087c0a6e 100644 --- a/src/Common/ColumnsHashing.h +++ b/src/Common/ColumnsHashing.h @@ -44,7 +44,7 @@ struct HashMethodOneNumber vec = key_columns[0]->getRawData().data; } - HashMethodOneNumber(const IColumn * column) + explicit HashMethodOneNumber(const IColumn * column) { vec = column->getRawData().data; } @@ -233,7 +233,7 @@ struct HashMethodSingleLowCardinalityColumn : public SingleColumnMethod static const ColumnLowCardinality & getLowCardinalityColumn(const IColumn * column) { - auto low_cardinality_column = typeid_cast(column); + const auto * low_cardinality_column = typeid_cast(column); if (!low_cardinality_column) throw Exception("Invalid aggregation key type for HashMethodSingleLowCardinalityColumn method. " "Excepted LowCardinality, got " + column->getName(), ErrorCodes::LOGICAL_ERROR); @@ -244,7 +244,7 @@ struct HashMethodSingleLowCardinalityColumn : public SingleColumnMethod const ColumnRawPtrs & key_columns_low_cardinality, const Sizes & key_sizes, const HashMethodContextPtr & context) : Base({getLowCardinalityColumn(key_columns_low_cardinality[0]).getDictionary().getNestedNotNullableColumn().get()}, key_sizes, context) { - auto column = &getLowCardinalityColumn(key_columns_low_cardinality[0]); + const auto * column = &getLowCardinalityColumn(key_columns_low_cardinality[0]); if (!context) throw Exception("Cache wasn't created for HashMethodSingleLowCardinalityColumn", @@ -262,7 +262,7 @@ struct HashMethodSingleLowCardinalityColumn : public SingleColumnMethod } } - auto * dict = column->getDictionary().getNestedNotNullableColumn().get(); + const auto * dict = column->getDictionary().getNestedNotNullableColumn().get(); is_nullable = column->getDictionary().nestedColumnIsNullable(); key_columns = {dict}; bool is_shared_dict = column->isSharedDictionary(); @@ -504,7 +504,7 @@ struct HashMethodKeysFixed } HashMethodKeysFixed(const ColumnRawPtrs & key_columns, const Sizes & key_sizes_, const HashMethodContextPtr &) - : Base(key_columns), key_sizes(std::move(key_sizes_)), keys_size(key_columns.size()) + : Base(key_columns), key_sizes(key_sizes_), keys_size(key_columns.size()) { if constexpr (has_low_cardinality) { @@ -513,7 +513,7 @@ struct HashMethodKeysFixed low_cardinality_keys.position_sizes.resize(key_columns.size()); for (size_t i = 0; i < key_columns.size(); ++i) { - if (auto * low_cardinality_col = typeid_cast(key_columns[i])) + if (const auto * low_cardinality_col = typeid_cast(key_columns[i])) { low_cardinality_keys.nested_columns[i] = low_cardinality_col->getDictionary().getNestedColumn().get(); low_cardinality_keys.positions[i] = &low_cardinality_col->getIndexes(); diff --git a/src/Common/ColumnsHashingImpl.h b/src/Common/ColumnsHashingImpl.h index 40494497ba2..f5a732b275f 100644 --- a/src/Common/ColumnsHashingImpl.h +++ b/src/Common/ColumnsHashingImpl.h @@ -312,14 +312,14 @@ template class BaseStateKeysFixed { protected: - BaseStateKeysFixed(const ColumnRawPtrs & key_columns) + explicit BaseStateKeysFixed(const ColumnRawPtrs & key_columns) { null_maps.reserve(key_columns.size()); actual_columns.reserve(key_columns.size()); for (const auto & col : key_columns) { - if (auto * nullable_col = checkAndGetColumn(col)) + if (const auto * nullable_col = checkAndGetColumn(col)) { actual_columns.push_back(&nullable_col->getNestedColumn()); null_maps.push_back(&nullable_col->getNullMapColumn()); @@ -373,7 +373,7 @@ template class BaseStateKeysFixed { protected: - BaseStateKeysFixed(const ColumnRawPtrs & columns) : actual_columns(columns) {} + explicit BaseStateKeysFixed(const ColumnRawPtrs & columns) : actual_columns(columns) {} const ColumnRawPtrs & getActualColumns() const { return actual_columns; } diff --git a/src/Common/CombinedCardinalityEstimator.h b/src/Common/CombinedCardinalityEstimator.h index 8cf35436840..3f4b481dce9 100644 --- a/src/Common/CombinedCardinalityEstimator.h +++ b/src/Common/CombinedCardinalityEstimator.h @@ -314,7 +314,6 @@ private: address &= mask; } -private: Small small; union { diff --git a/src/Common/CompactArray.h b/src/Common/CompactArray.h index 89e2b43a943..629fa08aaaa 100644 --- a/src/Common/CompactArray.h +++ b/src/Common/CompactArray.h @@ -28,7 +28,6 @@ public: class Reader; class Locus; -public: CompactArray() = default; UInt8 ALWAYS_INLINE operator[](BucketIndex bucket_index) const @@ -67,7 +66,7 @@ template class CompactArray::Reader final { public: - Reader(ReadBuffer & in_) + explicit Reader(ReadBuffer & in_) : in(in_) { } @@ -160,7 +159,7 @@ class CompactArray::Locus final friend class CompactArray::Reader; public: - ALWAYS_INLINE operator UInt8() const + ALWAYS_INLINE operator UInt8() const /// NOLINT { if (content_l == content_r) return read(*content_l); @@ -194,7 +193,7 @@ public: private: Locus() = default; - Locus(BucketIndex bucket_index) + explicit Locus(BucketIndex bucket_index) { init(bucket_index); } @@ -230,7 +229,6 @@ private: | ((value_r & ((1 << offset_r) - 1)) << (8 - offset_l)); } -private: size_t index_l; size_t offset_l; size_t index_r; diff --git a/src/Common/Config/ConfigProcessor.h b/src/Common/Config/ConfigProcessor.h index 04278d72303..6c642690945 100644 --- a/src/Common/Config/ConfigProcessor.h +++ b/src/Common/Config/ConfigProcessor.h @@ -98,7 +98,6 @@ public: /// Set path of main config.xml. It will be cut from all configs placed to preprocessed_configs/ static void setConfigPath(const std::string & config_path); -public: using Files = std::vector; static Files getConfigMergeFiles(const std::string & config_path); @@ -122,7 +121,6 @@ private: Poco::AutoPtr name_pool; Poco::XML::DOMParser dom_parser; -private: using NodePtr = Poco::AutoPtr; void mergeRecursive(XMLDocumentPtr config, Poco::XML::Node * config_root, const Poco::XML::Node * with_root); diff --git a/src/Common/Config/ConfigReloader.h b/src/Common/Config/ConfigReloader.h index 841c0fe57e1..982e21c91e2 100644 --- a/src/Common/Config/ConfigReloader.h +++ b/src/Common/Config/ConfigReloader.h @@ -69,8 +69,6 @@ private: FilesChangesTracker getNewFileList() const; -private: - static constexpr auto reload_interval = std::chrono::seconds(2); Poco::Logger * log = &Poco::Logger::get("ConfigReloader"); diff --git a/src/Common/CounterInFile.h b/src/Common/CounterInFile.h index 343ef95dd26..c6ba355aac7 100644 --- a/src/Common/CounterInFile.h +++ b/src/Common/CounterInFile.h @@ -6,6 +6,7 @@ #include #include #include +#include #include @@ -28,6 +29,7 @@ namespace DB } } +namespace fs = std::filesystem; /** Stores a number in the file. * Designed for rare calls (not designed for performance). @@ -39,7 +41,7 @@ private: public: /// path - the name of the file, including the path - CounterInFile(const std::string & path_) : path(path_) {} + explicit CounterInFile(const std::string & path_) : path(path_) {} /** Add `delta` to the number in the file and return the new value. * If the `create_if_need` parameter is not set to true, then diff --git a/src/Common/CpuId.h b/src/Common/CpuId.h index e814442ef80..5037c687943 100644 --- a/src/Common/CpuId.h +++ b/src/Common/CpuId.h @@ -28,7 +28,7 @@ inline UInt64 our_xgetbv(UInt32 xcr) noexcept } #endif -inline bool cpuid(UInt32 op, UInt32 sub_op, UInt32 * res) noexcept +inline bool cpuid(UInt32 op, UInt32 sub_op, UInt32 * res) noexcept /// NOLINT { #if defined(__x86_64__) || defined(__i386__) __cpuid_count(op, sub_op, res[0], res[1], res[2], res[3]); @@ -43,7 +43,7 @@ inline bool cpuid(UInt32 op, UInt32 sub_op, UInt32 * res) noexcept #endif } -inline bool cpuid(UInt32 op, UInt32 * res) noexcept +inline bool cpuid(UInt32 op, UInt32 * res) noexcept /// NOLINT { #if defined(__x86_64__) || defined(__i386__) __cpuid(op, res[0], res[1], res[2], res[3]); @@ -106,7 +106,7 @@ union CpuInfo UInt32 edx; } registers; - inline CpuInfo(UInt32 op) noexcept { cpuid(op, info); } + inline explicit CpuInfo(UInt32 op) noexcept { cpuid(op, info); } inline CpuInfo(UInt32 op, UInt32 sub_op) noexcept { cpuid(op, sub_op, info); } }; diff --git a/src/Common/CurrentMetrics.h b/src/Common/CurrentMetrics.h index 21c3f704872..7508c26b0ae 100644 --- a/src/Common/CurrentMetrics.h +++ b/src/Common/CurrentMetrics.h @@ -72,7 +72,7 @@ namespace CurrentMetrics } public: - Increment(Metric metric, Value amount_ = 1) + explicit Increment(Metric metric, Value amount_ = 1) : Increment(&values[metric], amount_) {} ~Increment() @@ -81,12 +81,12 @@ namespace CurrentMetrics what->fetch_sub(amount, std::memory_order_relaxed); } - Increment(Increment && old) + Increment(Increment && old) noexcept { *this = std::move(old); } - Increment & operator= (Increment && old) + Increment & operator=(Increment && old) noexcept { what = old.what; amount = old.amount; diff --git a/src/Common/DNSResolver.h b/src/Common/DNSResolver.h index 3cefa37fd70..e26f46f44c7 100644 --- a/src/Common/DNSResolver.h +++ b/src/Common/DNSResolver.h @@ -17,7 +17,7 @@ namespace DB class DNSResolver : private boost::noncopyable { public: - typedef std::vector IPAddresses; + using IPAddresses = std::vector; static DNSResolver & instance(); diff --git a/src/Common/DateLUTImpl.h b/src/Common/DateLUTImpl.h index 5ca37448e36..a5b2bbedc8a 100644 --- a/src/Common/DateLUTImpl.h +++ b/src/Common/DateLUTImpl.h @@ -52,10 +52,10 @@ private: friend class DateLUT; explicit DateLUTImpl(const std::string & time_zone); - DateLUTImpl(const DateLUTImpl &) = delete; - DateLUTImpl & operator=(const DateLUTImpl &) = delete; - DateLUTImpl(const DateLUTImpl &&) = delete; - DateLUTImpl & operator=(const DateLUTImpl &&) = delete; + DateLUTImpl(const DateLUTImpl &) = delete; /// NOLINT + DateLUTImpl & operator=(const DateLUTImpl &) = delete; /// NOLINT + DateLUTImpl(const DateLUTImpl &&) = delete; /// NOLINT + DateLUTImpl & operator=(const DateLUTImpl &&) = delete; /// NOLINT // Normalized and bound-checked index of element in lut, // has to be a separate type to support overloading @@ -149,12 +149,12 @@ public: Int8 amount_of_offset_change_value; /// Usually -4 or 4, but look at Lord Howe Island. Multiply by OffsetChangeFactor UInt8 time_at_offset_change_value; /// In seconds from beginning of the day. Multiply by OffsetChangeFactor - inline Int32 amount_of_offset_change() const + inline Int32 amount_of_offset_change() const /// NOLINT { return static_cast(amount_of_offset_change_value) * OffsetChangeFactor; } - inline UInt32 time_at_offset_change() const + inline UInt32 time_at_offset_change() const /// NOLINT { return static_cast(time_at_offset_change_value) * OffsetChangeFactor; } @@ -230,12 +230,12 @@ private: return LUTIndex(guess ? guess - 1 : 0); } - inline LUTIndex toLUTIndex(DayNum d) const + static inline LUTIndex toLUTIndex(DayNum d) { return LUTIndex{(d + daynum_offset_epoch) & date_lut_mask}; } - inline LUTIndex toLUTIndex(ExtendedDayNum d) const + static inline LUTIndex toLUTIndex(ExtendedDayNum d) { return LUTIndex{static_cast(d + daynum_offset_epoch) & date_lut_mask}; } @@ -245,7 +245,7 @@ private: return findIndex(t); } - inline LUTIndex toLUTIndex(LUTIndex i) const + static inline LUTIndex toLUTIndex(LUTIndex i) { return i; } @@ -793,7 +793,7 @@ public: } /// Check and change mode to effective. - inline UInt8 check_week_mode(UInt8 mode) const + inline UInt8 check_week_mode(UInt8 mode) const /// NOLINT { UInt8 week_format = (mode & 7); if (!(week_format & static_cast(WeekModeFlag::MONDAY_FIRST))) @@ -805,7 +805,7 @@ public: * Returns 0 for monday, 1 for tuesday... */ template - inline unsigned calc_weekday(DateOrTime v, bool sunday_first_day_of_week) const + inline unsigned calc_weekday(DateOrTime v, bool sunday_first_day_of_week) const /// NOLINT { const LUTIndex i = toLUTIndex(v); if (!sunday_first_day_of_week) @@ -815,7 +815,7 @@ public: } /// Calculate days in one year. - inline unsigned calc_days_in_year(Int32 year) const + inline unsigned calc_days_in_year(Int32 year) const /// NOLINT { return ((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)) ? 366 : 365); } @@ -852,7 +852,7 @@ public: return toRelativeHourNum(lut[toLUTIndex(v)].date); } - inline Time toRelativeMinuteNum(Time t) const + inline Time toRelativeMinuteNum(Time t) const /// NOLINT { return (t + DATE_LUT_ADD) / 60 - (DATE_LUT_ADD / 60); } @@ -1057,12 +1057,12 @@ public: return values.year * 10000 + values.month * 100 + values.day_of_month; } - inline Time YYYYMMDDToDate(UInt32 num) const + inline Time YYYYMMDDToDate(UInt32 num) const /// NOLINT { return makeDate(num / 10000, num / 100 % 100, num % 100); } - inline ExtendedDayNum YYYYMMDDToDayNum(UInt32 num) const + inline ExtendedDayNum YYYYMMDDToDayNum(UInt32 num) const /// NOLINT { return makeDayNum(num / 10000, num / 100 % 100, num % 100); } @@ -1143,7 +1143,7 @@ public: + UInt64(components.date.year) * 10000000000; } - inline Time YYYYMMDDhhmmssToTime(UInt64 num) const + inline Time YYYYMMDDhhmmssToTime(UInt64 num) const /// NOLINT { return makeDateTime( num / 10000000000, diff --git a/src/Common/Dwarf.cpp b/src/Common/Dwarf.cpp index a85bbe818b5..ce8a0974870 100644 --- a/src/Common/Dwarf.cpp +++ b/src/Common/Dwarf.cpp @@ -103,7 +103,7 @@ Dwarf::Dwarf(const std::shared_ptr & elf) : elf_(elf) init(); } -Dwarf::Section::Section(std::string_view d) : is64Bit_(false), data_(d) +Dwarf::Section::Section(std::string_view d) : is64_bit(false), data(d) { } @@ -343,7 +343,7 @@ void Dwarf::Path::toString(std::string & dest) const // Next chunk in section bool Dwarf::Section::next(std::string_view & chunk) { - chunk = data_; + chunk = data; if (chunk.empty()) return false; @@ -351,11 +351,11 @@ bool Dwarf::Section::next(std::string_view & chunk) // a 96-bit value (0xffffffff followed by the 64-bit length) for a 64-bit // section. auto initial_length = read(chunk); - is64Bit_ = (initial_length == uint32_t(-1)); - auto length = is64Bit_ ? read(chunk) : initial_length; + is64_bit = (initial_length == uint32_t(-1)); + auto length = is64_bit ? read(chunk) : initial_length; SAFE_CHECK(length <= chunk.size(), "invalid DWARF section"); chunk = std::string_view(chunk.data(), length); - data_ = std::string_view(chunk.end(), data_.end() - chunk.end()); + data = std::string_view(chunk.end(), data.end() - chunk.end()); return true; } diff --git a/src/Common/Dwarf.h b/src/Common/Dwarf.h index 4712daad28c..e57e58e438a 100644 --- a/src/Common/Dwarf.h +++ b/src/Common/Dwarf.h @@ -112,9 +112,9 @@ public: // TODO(tudorb): Implement operator==, operator!=; not as easy as it // seems as the same path can be represented in multiple ways private: - std::string_view baseDir_; - std::string_view subDir_; - std::string_view file_; + std::string_view baseDir_; /// NOLINT + std::string_view subDir_; /// NOLINT + std::string_view file_; /// NOLINT }; // Indicates inline function `name` is called at `line@file`. @@ -173,7 +173,7 @@ private: void init(); - std::shared_ptr elf_; + std::shared_ptr elf_; /// NOLINT // DWARF section made up of chunks, each prefixed with a length header. // The length indicates whether the chunk is DWARF-32 or DWARF-64, which @@ -182,7 +182,7 @@ private: class Section { public: - Section() : is64Bit_(false) {} + Section() : is64_bit(false) {} explicit Section(std::string_view d); @@ -191,12 +191,12 @@ private: bool next(std::string_view & chunk); // Is the current chunk 64 bit? - bool is64Bit() const { return is64Bit_; } + bool is64Bit() const { return is64_bit; } private: // Yes, 32- and 64- bit sections may coexist. Yikes! - bool is64Bit_; - std::string_view data_; + bool is64_bit; + std::string_view data; }; // Abbreviation for a Debugging Information Entry. @@ -215,7 +215,7 @@ private: // provide a description of a corresponding entity in the source program. struct Die { - bool is64Bit; + bool is64Bit; /// NOLINT // Offset from start to first attribute uint8_t attr_offset; // Offset within debug info. @@ -241,7 +241,7 @@ private: struct CompilationUnit { - bool is64Bit; + bool is64Bit; /// NOLINT uint8_t version; uint8_t addr_size; // Offset in .debug_info of this compilation unit. @@ -311,10 +311,10 @@ private: struct FileName { - std::string_view relativeName; + std::string_view relativeName; /// NOLINT // 0 = current compilation directory // otherwise, 1-based index in the list of include directories - uint64_t directoryIndex; + uint64_t directoryIndex; /// NOLINT }; // Read one FileName object, remove_prefix program static bool readFileName(std::string_view & program, FileName & fn); @@ -332,37 +332,37 @@ private: bool nextDefineFile(std::string_view & program, FileName & fn) const; // Initialization - bool is64Bit_; - std::string_view data_; - std::string_view compilationDirectory_; + bool is64Bit_; /// NOLINT + std::string_view data_; /// NOLINT + std::string_view compilationDirectory_; /// NOLINT // Header - uint16_t version_; - uint8_t minLength_; - bool defaultIsStmt_; - int8_t lineBase_; - uint8_t lineRange_; - uint8_t opcodeBase_; - const uint8_t * standardOpcodeLengths_; + uint16_t version_; /// NOLINT + uint8_t minLength_; /// NOLINT + bool defaultIsStmt_; /// NOLINT + int8_t lineBase_; /// NOLINT + uint8_t lineRange_; /// NOLINT + uint8_t opcodeBase_; /// NOLINT + const uint8_t * standardOpcodeLengths_; /// NOLINT - std::string_view includeDirectories_; - size_t includeDirectoryCount_; + std::string_view includeDirectories_; /// NOLINT + size_t includeDirectoryCount_; /// NOLINT - std::string_view fileNames_; - size_t fileNameCount_; + std::string_view fileNames_; /// NOLINT + size_t fileNameCount_; /// NOLINT // State machine registers - uint64_t address_; - uint64_t file_; - uint64_t line_; - uint64_t column_; - bool isStmt_; - bool basicBlock_; - bool endSequence_; - bool prologueEnd_; - bool epilogueBegin_; - uint64_t isa_; - uint64_t discriminator_; + uint64_t address_; /// NOLINT + uint64_t file_; /// NOLINT + uint64_t line_; /// NOLINT + uint64_t column_; /// NOLINT + bool isStmt_; /// NOLINT + bool basicBlock_; /// NOLINT + bool endSequence_; /// NOLINT + bool prologueEnd_; /// NOLINT + bool epilogueBegin_; /// NOLINT + uint64_t isa_; /// NOLINT + uint64_t discriminator_; /// NOLINT }; /** @@ -439,12 +439,12 @@ private: // Finds the Compilation Unit starting at offset. static CompilationUnit findCompilationUnit(std::string_view info, uint64_t targetOffset); - std::string_view info_; // .debug_info - std::string_view abbrev_; // .debug_abbrev - std::string_view aranges_; // .debug_aranges - std::string_view line_; // .debug_line - std::string_view strings_; // .debug_str - std::string_view ranges_; // .debug_ranges + std::string_view info_; // .debug_info /// NOLINT + std::string_view abbrev_; // .debug_abbrev /// NOLINT + std::string_view aranges_; // .debug_aranges /// NOLINT + std::string_view line_; // .debug_line /// NOLINT + std::string_view strings_; // .debug_str /// NOLINT + std::string_view ranges_; // .debug_ranges /// NOLINT }; } diff --git a/src/Common/Exception.cpp b/src/Common/Exception.cpp index b2987cbd73f..8ba9ac782ca 100644 --- a/src/Common/Exception.cpp +++ b/src/Common/Exception.cpp @@ -555,19 +555,19 @@ std::string ParsingException::displayText() const { try { - if (line_number_ == -1) - formatted_message_ = message(); + if (line_number == -1) + formatted_message = message(); else - formatted_message_ = message() + fmt::format(": (at row {})\n", line_number_); + formatted_message = message() + fmt::format(": (at row {})\n", line_number); } catch (...) {} - if (!formatted_message_.empty()) + if (!formatted_message.empty()) { std::string result = name(); result.append(": "); - result.append(formatted_message_); + result.append(formatted_message); return result; } else diff --git a/src/Common/Exception.h b/src/Common/Exception.h index b6bc31a5821..fc4f6d1295d 100644 --- a/src/Common/Exception.h +++ b/src/Common/Exception.h @@ -96,7 +96,7 @@ public: void rethrow() const override { throw *this; } int getErrno() const { return saved_errno; } - const std::optional getPath() const { return path; } + std::optional getPath() const { return path; } private: int saved_errno; @@ -129,12 +129,12 @@ public: #endif ; - int getLineNumber() { return line_number_; } - void setLineNumber(int line_number) { line_number_ = line_number;} + int getLineNumber() const { return line_number; } + void setLineNumber(int line_number_) { line_number = line_number_;} private: - ssize_t line_number_{-1}; - mutable std::string formatted_message_; + ssize_t line_number{-1}; + mutable std::string formatted_message; const char * name() const throw() override { return "DB::ParsingException"; } const char * className() const throw() override { return "DB::ParsingException"; } @@ -209,7 +209,7 @@ std::enable_if_t, T> exception_cast(std::exception_ptr e) { try { - std::rethrow_exception(std::move(e)); + std::rethrow_exception(e); } catch (std::remove_pointer_t & concrete) { diff --git a/src/Common/ExponentiallySmoothedCounter.h b/src/Common/ExponentiallySmoothedCounter.h index 28d4e5e25c1..a552cfc20a4 100644 --- a/src/Common/ExponentiallySmoothedCounter.h +++ b/src/Common/ExponentiallySmoothedCounter.h @@ -43,9 +43,7 @@ struct ExponentiallySmoothedAverage double time = 0; - ExponentiallySmoothedAverage() - { - } + ExponentiallySmoothedAverage() = default; ExponentiallySmoothedAverage(double current_value, double current_time) : value(current_value), time(current_time) diff --git a/src/Common/FiberStack.h b/src/Common/FiberStack.h index f5baa1b92b3..29f84ee6d85 100644 --- a/src/Common/FiberStack.h +++ b/src/Common/FiberStack.h @@ -39,7 +39,7 @@ public: page_size = getPageSize(); } - boost::context::stack_context allocate() + boost::context::stack_context allocate() const { size_t num_pages = 1 + (stack_size - 1) / page_size; size_t num_bytes = (num_pages + 1) * page_size; /// Add one page at bottom that will be used as guard-page @@ -68,7 +68,7 @@ public: return sctx; } - void deallocate(boost::context::stack_context & sctx) + void deallocate(boost::context::stack_context & sctx) const { #if defined(BOOST_USE_VALGRIND) VALGRIND_STACK_DEREGISTER(sctx.valgrind_stack_id); diff --git a/src/Common/FieldVisitorHash.h b/src/Common/FieldVisitorHash.h index 7527e13ca20..82e831b961e 100644 --- a/src/Common/FieldVisitorHash.h +++ b/src/Common/FieldVisitorHash.h @@ -13,7 +13,7 @@ class FieldVisitorHash : public StaticVisitor<> private: SipHash & hash; public: - FieldVisitorHash(SipHash & hash_); + explicit FieldVisitorHash(SipHash & hash_); void operator() (const Null & x) const; void operator() (const UInt64 & x) const; diff --git a/src/Common/FileUpdatesTracker.h b/src/Common/FileUpdatesTracker.h index 9fe37c2a75d..e638aa89afc 100644 --- a/src/Common/FileUpdatesTracker.h +++ b/src/Common/FileUpdatesTracker.h @@ -5,7 +5,6 @@ #include #include -namespace fs = std::filesystem; class FileUpdatesTracker { @@ -14,7 +13,7 @@ private: Poco::Timestamp known_time; public: - FileUpdatesTracker(const std::string & path_) + explicit FileUpdatesTracker(const std::string & path_) : path(path_) , known_time(0) {} diff --git a/src/Common/HashTable/ClearableHashSet.h b/src/Common/HashTable/ClearableHashSet.h index 7da0469a99a..a14490c4551 100644 --- a/src/Common/HashTable/ClearableHashSet.h +++ b/src/Common/HashTable/ClearableHashSet.h @@ -44,7 +44,7 @@ struct ClearableHashTableCell : public BaseCell /// Do I need to store the zero key separately (that is, can a zero key be inserted into the hash table). static constexpr bool need_zero_value_storage = false; - ClearableHashTableCell() {} //-V730 + ClearableHashTableCell() {} //-V730 /// NOLINT ClearableHashTableCell(const Key & key_, const State & state) : BaseCell(key_, state), version(state.version) {} }; diff --git a/src/Common/HashTable/FixedClearableHashMap.h b/src/Common/HashTable/FixedClearableHashMap.h index 4c8c733446e..6be7fde88b5 100644 --- a/src/Common/HashTable/FixedClearableHashMap.h +++ b/src/Common/HashTable/FixedClearableHashMap.h @@ -16,11 +16,11 @@ struct FixedClearableHashMapCell UInt32 version; Mapped mapped; - FixedClearableHashMapCell() {} + FixedClearableHashMapCell() {} /// NOLINT FixedClearableHashMapCell(const Key &, const State & state) : version(state.version) {} FixedClearableHashMapCell(const value_type & value_, const State & state) : version(state.version), mapped(value_.second) {} - const VoidKey getKey() const { return {}; } + const VoidKey getKey() const { return {}; } /// NOLINT Mapped & getMapped() { return mapped; } const Mapped & getMapped() const { return mapped; } @@ -29,7 +29,7 @@ struct FixedClearableHashMapCell struct CellExt { - CellExt() {} + CellExt() {} /// NOLINT CellExt(Key && key_, FixedClearableHashMapCell * ptr_) : key(key_), ptr(ptr_) {} void update(Key && key_, FixedClearableHashMapCell * ptr_) { @@ -41,7 +41,7 @@ struct FixedClearableHashMapCell const Key & getKey() const { return key; } Mapped & getMapped() { return ptr->mapped; } const Mapped & getMapped() const { return *ptr->mapped; } - const value_type getValue() const { return {key, *ptr->mapped}; } + const value_type getValue() const { return {key, *ptr->mapped}; } /// NOLINT }; }; diff --git a/src/Common/HashTable/FixedClearableHashSet.h b/src/Common/HashTable/FixedClearableHashSet.h index 56c7afd250e..1faac136359 100644 --- a/src/Common/HashTable/FixedClearableHashSet.h +++ b/src/Common/HashTable/FixedClearableHashSet.h @@ -13,10 +13,10 @@ struct FixedClearableHashTableCell using mapped_type = VoidMapped; UInt32 version; - FixedClearableHashTableCell() {} //-V730 + FixedClearableHashTableCell() {} //-V730 /// NOLINT FixedClearableHashTableCell(const Key &, const State & state) : version(state.version) {} - const VoidKey getKey() const { return {}; } + const VoidKey getKey() const { return {}; } /// NOLINT VoidMapped getMapped() const { return {}; } bool isZero(const State & state) const { return version != state.version; } @@ -25,7 +25,7 @@ struct FixedClearableHashTableCell struct CellExt { Key key; - const VoidKey getKey() const { return {}; } + const VoidKey getKey() const { return {}; } /// NOLINT VoidMapped getMapped() const { return {}; } const value_type & getValue() const { return key; } void update(Key && key_, FixedClearableHashTableCell *) { key = key_; } diff --git a/src/Common/HashTable/FixedHashMap.h b/src/Common/HashTable/FixedHashMap.h index 37bd81c8b4f..64d932f7c2f 100644 --- a/src/Common/HashTable/FixedHashMap.h +++ b/src/Common/HashTable/FixedHashMap.h @@ -16,11 +16,11 @@ struct FixedHashMapCell bool full; Mapped mapped; - FixedHashMapCell() {} //-V730 + FixedHashMapCell() {} //-V730 /// NOLINT FixedHashMapCell(const Key &, const State &) : full(true) {} FixedHashMapCell(const value_type & value_, const State &) : full(true), mapped(value_.second) {} - const VoidKey getKey() const { return {}; } + const VoidKey getKey() const { return {}; } /// NOLINT Mapped & getMapped() { return mapped; } const Mapped & getMapped() const { return mapped; } @@ -31,7 +31,7 @@ struct FixedHashMapCell /// Note that we have to assemble a continuous layout for the value_type on each call of getValue(). struct CellExt { - CellExt() {} //-V730 + CellExt() {} //-V730 /// NOLINT CellExt(Key && key_, const FixedHashMapCell * ptr_) : key(key_), ptr(const_cast(ptr_)) {} void update(Key && key_, const FixedHashMapCell * ptr_) { @@ -44,7 +44,7 @@ struct FixedHashMapCell const Key & getKey() const { return key; } Mapped & getMapped() { return ptr->mapped; } const Mapped & getMapped() const { return ptr->mapped; } - const value_type getValue() const { return {key, ptr->mapped}; } + const value_type getValue() const { return {key, ptr->mapped}; } /// NOLINT }; }; @@ -61,11 +61,11 @@ struct FixedHashMapImplicitZeroCell Mapped mapped; - FixedHashMapImplicitZeroCell() {} + FixedHashMapImplicitZeroCell() {} /// NOLINT FixedHashMapImplicitZeroCell(const Key &, const State &) {} FixedHashMapImplicitZeroCell(const value_type & value_, const State &) : mapped(value_.second) {} - const VoidKey getKey() const { return {}; } + const VoidKey getKey() const { return {}; } /// NOLINT Mapped & getMapped() { return mapped; } const Mapped & getMapped() const { return mapped; } @@ -76,7 +76,7 @@ struct FixedHashMapImplicitZeroCell /// Note that we have to assemble a continuous layout for the value_type on each call of getValue(). struct CellExt { - CellExt() {} //-V730 + CellExt() {} //-V730 /// NOLINT CellExt(Key && key_, const FixedHashMapImplicitZeroCell * ptr_) : key(key_), ptr(const_cast(ptr_)) {} void update(Key && key_, const FixedHashMapImplicitZeroCell * ptr_) { @@ -89,7 +89,7 @@ struct FixedHashMapImplicitZeroCell const Key & getKey() const { return key; } Mapped & getMapped() { return ptr->mapped; } const Mapped & getMapped() const { return ptr->mapped; } - const value_type getValue() const { return {key, ptr->mapped}; } + const value_type getValue() const { return {key, ptr->mapped}; } /// NOLINT }; }; diff --git a/src/Common/HashTable/FixedHashTable.h b/src/Common/HashTable/FixedHashTable.h index c1d2c8fe6ee..6ca8b6c4b17 100644 --- a/src/Common/HashTable/FixedHashTable.h +++ b/src/Common/HashTable/FixedHashTable.h @@ -19,10 +19,10 @@ struct FixedHashTableCell using mapped_type = VoidMapped; bool full; - FixedHashTableCell() {} //-V730 + FixedHashTableCell() {} //-V730 /// NOLINT FixedHashTableCell(const Key &, const State &) : full(true) {} - const VoidKey getKey() const { return {}; } + const VoidKey getKey() const { return {}; } /// NOLINT VoidMapped getMapped() const { return {}; } bool isZero(const State &) const { return !full; } @@ -39,7 +39,7 @@ struct FixedHashTableCell { Key key; - const VoidKey getKey() const { return {}; } + const VoidKey getKey() const { return {}; } /// NOLINT VoidMapped getMapped() const { return {}; } const value_type & getValue() const { return key; } void update(Key && key_, FixedHashTableCell *) { key = key_; } @@ -138,7 +138,7 @@ protected: template - class iterator_base + class iterator_base /// NOLINT { using Container = std::conditional_t; using cell_type = std::conditional_t; @@ -149,7 +149,7 @@ protected: friend class FixedHashTable; public: - iterator_base() {} + iterator_base() {} /// NOLINT iterator_base(Container * container_, cell_type * ptr_) : container(container_), ptr(ptr_) { cell.update(ptr - container->buf, ptr); @@ -163,7 +163,7 @@ protected: ++ptr; /// Skip empty cells in the main buffer. - auto buf_end = container->buf + container->NUM_CELLS; + const auto * buf_end = container->buf + container->NUM_CELLS; while (ptr < buf_end && ptr->isZero(*container)) ++ptr; @@ -204,7 +204,7 @@ public: FixedHashTable() { alloc(); } - FixedHashTable(FixedHashTable && rhs) : buf(nullptr) { *this = std::move(rhs); } + FixedHashTable(FixedHashTable && rhs) noexcept : buf(nullptr) { *this = std::move(rhs); } /// NOLINT ~FixedHashTable() { @@ -212,7 +212,7 @@ public: free(); } - FixedHashTable & operator=(FixedHashTable && rhs) + FixedHashTable & operator=(FixedHashTable && rhs) noexcept { destroyElements(); free(); @@ -229,7 +229,7 @@ public: class Reader final : private Cell::State { public: - Reader(DB::ReadBuffer & in_) : in(in_) {} + explicit Reader(DB::ReadBuffer & in_) : in(in_) {} Reader(const Reader &) = delete; Reader & operator=(const Reader &) = delete; @@ -273,13 +273,13 @@ public: }; - class iterator : public iterator_base + class iterator : public iterator_base /// NOLINT { public: using iterator_base::iterator_base; }; - class const_iterator : public iterator_base + class const_iterator : public iterator_base /// NOLINT { public: using iterator_base::iterator_base; @@ -331,7 +331,6 @@ public: } -public: /// The last parameter is unused but exists for compatibility with HashTable interface. void ALWAYS_INLINE emplace(const Key & x, LookupResult & it, bool & inserted, size_t /* hash */ = 0) { diff --git a/src/Common/HashTable/HashTable.h b/src/Common/HashTable/HashTable.h index b0f16dfdb8b..5e439591ff2 100644 --- a/src/Common/HashTable/HashTable.h +++ b/src/Common/HashTable/HashTable.h @@ -157,7 +157,7 @@ struct HashTableCell Key key; - HashTableCell() {} + HashTableCell() {} /// NOLINT /// Create a cell with the given key / key and value. HashTableCell(const Key & key_, const State &) : key(key_) {} @@ -602,7 +602,7 @@ protected: template - class iterator_base + class iterator_base /// NOLINT { using Container = std::conditional_t; using cell_type = std::conditional_t; @@ -613,7 +613,7 @@ protected: friend class HashTable; public: - iterator_base() {} + iterator_base() {} /// NOLINT iterator_base(Container * container_, cell_type * ptr_) : container(container_), ptr(ptr_) {} bool operator== (const iterator_base & rhs) const { return ptr == rhs.ptr; } @@ -628,7 +628,7 @@ protected: ++ptr; /// Skip empty cells in the main buffer. - auto buf_end = container->buf + container->grower.bufSize(); + auto * buf_end = container->buf + container->grower.bufSize(); while (ptr < buf_end && ptr->isZero(*container)) ++ptr; @@ -661,7 +661,7 @@ protected: * compatibility with std find(). Unfortunately, now is not the time to * do this. */ - operator Cell * () const { return nullptr; } + operator Cell * () const { return nullptr; } /// NOLINT }; @@ -684,7 +684,7 @@ public: alloc(grower); } - HashTable(size_t reserve_for_num_elements) + HashTable(size_t reserve_for_num_elements) /// NOLINT { if (Cell::need_zero_value_storage) this->zeroValue()->setZero(); @@ -692,7 +692,7 @@ public: alloc(grower); } - HashTable(HashTable && rhs) + HashTable(HashTable && rhs) noexcept : buf(nullptr) { *this = std::move(rhs); @@ -704,7 +704,7 @@ public: free(); } - HashTable & operator= (HashTable && rhs) + HashTable & operator=(HashTable && rhs) noexcept { destroyElements(); free(); @@ -713,10 +713,10 @@ public: std::swap(m_size, rhs.m_size); std::swap(grower, rhs.grower); - Hash::operator=(std::move(rhs)); - Allocator::operator=(std::move(rhs)); - Cell::State::operator=(std::move(rhs)); - ZeroValueStorage::operator=(std::move(rhs)); + Hash::operator=(std::move(rhs)); ///NOLINT + Allocator::operator=(std::move(rhs)); ///NOLINT + Cell::State::operator=(std::move(rhs)); ///NOLINT + ZeroValueStorage::operator=(std::move(rhs)); ///NOLINT return *this; } @@ -724,7 +724,7 @@ public: class Reader final : private Cell::State { public: - Reader(DB::ReadBuffer & in_) + explicit Reader(DB::ReadBuffer & in_) : in(in_) { } @@ -771,13 +771,13 @@ public: }; - class iterator : public iterator_base + class iterator : public iterator_base /// NOLINT { public: using iterator_base::iterator_base; }; - class const_iterator : public iterator_base + class const_iterator : public iterator_base /// NOLINT { public: using iterator_base::iterator_base; @@ -811,7 +811,7 @@ public: return iteratorToZero(); Cell * ptr = buf; - auto buf_end = buf + grower.bufSize(); + auto * buf_end = buf + grower.bufSize(); while (ptr < buf_end && ptr->isZero(*this)) ++ptr; diff --git a/src/Common/HashTable/HashTableKeyHolder.h b/src/Common/HashTable/HashTableKeyHolder.h index e37c7512f96..41e0c01ffc6 100644 --- a/src/Common/HashTable/HashTableKeyHolder.h +++ b/src/Common/HashTable/HashTableKeyHolder.h @@ -1,5 +1,7 @@ #pragma once +#include + #include /** diff --git a/src/Common/HashTable/LRUHashMap.h b/src/Common/HashTable/LRUHashMap.h index 2f0c4cfc744..95ac5a1932e 100644 --- a/src/Common/HashTable/LRUHashMap.h +++ b/src/Common/HashTable/LRUHashMap.h @@ -71,10 +71,10 @@ struct LRUHashMapCellNodeTraits using node_ptr = LRUHashMapCell *; using const_node_ptr = const LRUHashMapCell *; - static node * get_next(const node * ptr) { return ptr->next; } - static void set_next(node * __restrict ptr, node * __restrict next) { ptr->next = next; } - static node * get_previous(const node * ptr) { return ptr->prev; } - static void set_previous(node * __restrict ptr, node * __restrict prev) { ptr->prev = prev; } + static node * get_next(const node * ptr) { return ptr->next; } /// NOLINT + static void set_next(node * __restrict ptr, node * __restrict next) { ptr->next = next; } /// NOLINT + static node * get_previous(const node * ptr) { return ptr->prev; } /// NOLINT + static void set_previous(node * __restrict ptr, node * __restrict prev) { ptr->prev = prev; } /// NOLINT }; template diff --git a/src/Common/HashTable/SmallTable.h b/src/Common/HashTable/SmallTable.h index 895d2adc83e..ad9537ff94a 100644 --- a/src/Common/HashTable/SmallTable.h +++ b/src/Common/HashTable/SmallTable.h @@ -79,7 +79,7 @@ public: class Reader final : private Cell::State { public: - Reader(DB::ReadBuffer & in_) + explicit Reader(DB::ReadBuffer & in_) : in(in_) { } @@ -129,7 +129,7 @@ public: bool is_initialized = false; }; - class iterator + class iterator /// NOLINT { Self * container = nullptr; Cell * ptr = nullptr; @@ -137,7 +137,7 @@ public: friend class SmallTable; public: - iterator() {} + iterator() {} /// NOLINT iterator(Self * container_, Cell * ptr_) : container(container_), ptr(ptr_) {} bool operator== (const iterator & rhs) const { return ptr == rhs.ptr; } @@ -156,7 +156,7 @@ public: }; - class const_iterator + class const_iterator /// NOLINT { const Self * container = nullptr; const Cell * ptr = nullptr; @@ -164,9 +164,9 @@ public: friend class SmallTable; public: - const_iterator() {} - const_iterator(const Self * container_, const Cell * ptr_) : container(container_), ptr(ptr_) {} - const_iterator(const iterator & rhs) : container(rhs.container), ptr(rhs.ptr) {} + const_iterator() = default; + const_iterator(const Self * container_, const Cell * ptr_) : container(container_), ptr(ptr_) {} /// NOLINT + const_iterator(const iterator & rhs) : container(rhs.container), ptr(rhs.ptr) {} /// NOLINT bool operator== (const const_iterator & rhs) const { return ptr == rhs.ptr; } bool operator!= (const const_iterator & rhs) const { return ptr != rhs.ptr; } diff --git a/src/Common/HashTable/StringHashMap.h b/src/Common/HashTable/StringHashMap.h index 298580dc837..a3b5c3e9ed0 100644 --- a/src/Common/HashTable/StringHashMap.h +++ b/src/Common/HashTable/StringHashMap.h @@ -12,7 +12,7 @@ struct StringHashMapCell : public HashMapCellvalue.first); } + const StringRef getKey() const { return toStringRef(this->value.first); } /// NOLINT // internal static const Key & getKey(const value_type & value_) { return value_.first; } }; @@ -32,7 +32,7 @@ struct StringHashMapCell : public HashMapCellvalue.first.items[1] = 0; } // external - const StringRef getKey() const { return toStringRef(this->value.first); } + const StringRef getKey() const { return toStringRef(this->value.first); } /// NOLINT // internal static const StringKey16 & getKey(const value_type & value_) { return value_.first; } }; @@ -53,7 +53,7 @@ struct StringHashMapCell : public HashMapCellvalue.first.c = 0; } // external - const StringRef getKey() const { return toStringRef(this->value.first); } + const StringRef getKey() const { return toStringRef(this->value.first); } /// NOLINT // internal static const StringKey24 & getKey(const value_type & value_) { return value_.first; } }; diff --git a/src/Common/HashTable/StringHashTable.h b/src/Common/HashTable/StringHashTable.h index 7d704e4bdc7..7e259d66cd0 100644 --- a/src/Common/HashTable/StringHashTable.h +++ b/src/Common/HashTable/StringHashTable.h @@ -160,16 +160,16 @@ template struct StringHashTableLookupResult { Mapped * mapped_ptr; - StringHashTableLookupResult() {} - StringHashTableLookupResult(Mapped * mapped_ptr_) : mapped_ptr(mapped_ptr_) {} - StringHashTableLookupResult(std::nullptr_t) {} - const VoidKey getKey() const { return {}; } + StringHashTableLookupResult() {} /// NOLINT + StringHashTableLookupResult(Mapped * mapped_ptr_) : mapped_ptr(mapped_ptr_) {} /// NOLINT + StringHashTableLookupResult(std::nullptr_t) {} /// NOLINT + const VoidKey getKey() const { return {}; } /// NOLINT auto & getMapped() { return *mapped_ptr; } auto & operator*() { return *this; } auto & operator*() const { return *this; } auto * operator->() { return this; } auto * operator->() const { return this; } - operator bool() const { return mapped_ptr; } + operator bool() const { return mapped_ptr; } /// NOLINT friend bool operator==(const StringHashTableLookupResult & a, const std::nullptr_t &) { return !a.mapped_ptr; } friend bool operator==(const std::nullptr_t &, const StringHashTableLookupResult & b) { return !b.mapped_ptr; } friend bool operator!=(const StringHashTableLookupResult & a, const std::nullptr_t &) { return a.mapped_ptr; } @@ -214,7 +214,7 @@ public: StringHashTable() = default; - StringHashTable(size_t reserve_for_num_elements) + explicit StringHashTable(size_t reserve_for_num_elements) : m1{reserve_for_num_elements / 4} , m2{reserve_for_num_elements / 4} , m3{reserve_for_num_elements / 4} @@ -222,7 +222,7 @@ public: { } - StringHashTable(StringHashTable && rhs) + StringHashTable(StringHashTable && rhs) noexcept : m1(std::move(rhs.m1)) , m2(std::move(rhs.m2)) , m3(std::move(rhs.m3)) @@ -232,7 +232,6 @@ public: ~StringHashTable() = default; -public: // Dispatch is written in a way that maximizes the performance: // 1. Always memcpy 8 times bytes // 2. Use switch case extension to generate fast dispatching table diff --git a/src/Common/HashTable/TwoLevelHashTable.h b/src/Common/HashTable/TwoLevelHashTable.h index 14afb91c071..290ce054b5e 100644 --- a/src/Common/HashTable/TwoLevelHashTable.h +++ b/src/Common/HashTable/TwoLevelHashTable.h @@ -92,11 +92,11 @@ public: Impl impls[NUM_BUCKETS]; - TwoLevelHashTable() {} + TwoLevelHashTable() = default; /// Copy the data from another (normal) hash table. It should have the same hash function. template - TwoLevelHashTable(const Source & src) + explicit TwoLevelHashTable(const Source & src) { typename Source::const_iterator it = src.begin(); @@ -117,7 +117,7 @@ public: } - class iterator + class iterator /// NOLINT { Self * container{}; size_t bucket{}; @@ -129,7 +129,7 @@ public: : container(container_), bucket(bucket_), current_it(current_it_) {} public: - iterator() {} + iterator() = default; bool operator== (const iterator & rhs) const { return bucket == rhs.bucket && current_it == rhs.current_it; } bool operator!= (const iterator & rhs) const { return !(*this == rhs); } @@ -154,7 +154,7 @@ public: }; - class const_iterator + class const_iterator /// NOLINT { Self * container{}; size_t bucket{}; @@ -166,8 +166,8 @@ public: : container(container_), bucket(bucket_), current_it(current_it_) {} public: - const_iterator() {} - const_iterator(const iterator & rhs) : container(rhs.container), bucket(rhs.bucket), current_it(rhs.current_it) {} + const_iterator() = default; + const_iterator(const iterator & rhs) : container(rhs.container), bucket(rhs.bucket), current_it(rhs.current_it) {} /// NOLINT bool operator== (const const_iterator & rhs) const { return bucket == rhs.bucket && current_it == rhs.current_it; } bool operator!= (const const_iterator & rhs) const { return !(*this == rhs); } diff --git a/src/Common/HashTable/TwoLevelStringHashTable.h b/src/Common/HashTable/TwoLevelStringHashTable.h index 871becc86a4..77acca5e707 100644 --- a/src/Common/HashTable/TwoLevelStringHashTable.h +++ b/src/Common/HashTable/TwoLevelStringHashTable.h @@ -27,7 +27,6 @@ public: /// NOTE Bad for hash tables with more than 2^32 cells. static size_t getBucketFromHash(size_t hash_value) { return (hash_value >> (32 - BITS_FOR_BUCKET)) & MAX_BUCKET; } -public: using key_type = typename Impl::key_type; using mapped_type = typename Impl::mapped_type; using value_type = typename Impl::value_type; @@ -38,10 +37,10 @@ public: Impl impls[NUM_BUCKETS]; - TwoLevelStringHashTable() {} + TwoLevelStringHashTable() = default; template - TwoLevelStringHashTable(const Source & src) + explicit TwoLevelStringHashTable(const Source & src) { if (src.m0.hasZero()) impls[0].m0.setHasZero(*src.m0.zeroValue()); diff --git a/src/Common/HyperLogLogCounter.h b/src/Common/HyperLogLogCounter.h index c840151bce9..70a83a481a4 100644 --- a/src/Common/HyperLogLogCounter.h +++ b/src/Common/HyperLogLogCounter.h @@ -123,12 +123,11 @@ private: using T = typename IntermediateDenominator::Type; public: - Denominator(DenominatorType initial_value) + Denominator(DenominatorType initial_value) /// NOLINT : denominator(initial_value) { } -public: inline void update(UInt8 cur_rank, UInt8 new_rank) { denominator -= static_cast(1.0) / (1ULL << cur_rank); @@ -164,7 +163,7 @@ class __attribute__((__packed__)) Denominator> { public: - Denominator(DenominatorType initial_value) + Denominator(DenominatorType initial_value) /// NOLINT { rank_count[0] = initial_value; } @@ -321,7 +320,7 @@ public: double final_estimate = fixRawEstimate(raw_estimate); - return static_cast(final_estimate + 0.5); + return static_cast(final_estimate + 0.5); /// NOLINT } void merge(const HyperLogLogCounter & rhs) @@ -513,7 +512,6 @@ private: return fixed_estimate; } -private: static constexpr int max_rank = sizeof(HashValueType) * 8 - precision + 1; RankStore rank_store; diff --git a/src/Common/IFactoryWithAliases.h b/src/Common/IFactoryWithAliases.h index f7da302a942..458adc4522f 100644 --- a/src/Common/IFactoryWithAliases.h +++ b/src/Common/IFactoryWithAliases.h @@ -125,7 +125,7 @@ public: return name; } - virtual ~IFactoryWithAliases() override {} + virtual ~IFactoryWithAliases() override = default; private: using InnerMap = std::unordered_map; // name -> creator diff --git a/src/Common/Increment.h b/src/Common/Increment.h index 45ef604ccd9..08cf631c0d2 100644 --- a/src/Common/Increment.h +++ b/src/Common/Increment.h @@ -10,7 +10,7 @@ class Increment { public: /// path - the name of the file, including the path - Increment(const std::string & path_) : counter(path_) {} + explicit Increment(const std::string & path_) : counter(path_) {} /** Get the next number. * If the `create_if_need` parameter is not set to true, then diff --git a/src/Common/IntervalKind.h b/src/Common/IntervalKind.h index f1b5dce0792..aab0bb79be5 100644 --- a/src/Common/IntervalKind.h +++ b/src/Common/IntervalKind.h @@ -21,8 +21,8 @@ struct IntervalKind }; Kind kind = Second; - IntervalKind(Kind kind_ = Second) : kind(kind_) {} - operator Kind() const { return kind; } + IntervalKind(Kind kind_ = Second) : kind(kind_) {} /// NOLINT + operator Kind() const { return kind; } /// NOLINT constexpr std::string_view toString() const { return magic_enum::enum_name(kind); } @@ -59,6 +59,7 @@ struct IntervalKind static bool tryParseString(const std::string & kind, IntervalKind::Kind & result); }; +/// NOLINTNEXTLINE #define FOR_EACH_INTERVAL_KIND(M) \ M(Second) \ M(Minute) \ diff --git a/src/Common/JSONBuilder.h b/src/Common/JSONBuilder.h index 8601320880a..fd4c66b4a9e 100644 --- a/src/Common/JSONBuilder.h +++ b/src/Common/JSONBuilder.h @@ -33,7 +33,7 @@ using ItemPtr = std::unique_ptr; class JSONString : public IItem { public: - JSONString(std::string_view value_) : value(value_) {} + explicit JSONString(std::string_view value_) : value(value_) {} void format(const FormatSettings & settings, FormatContext & context) override; private: diff --git a/src/Common/LRUCache.h b/src/Common/LRUCache.h index 480a03ab399..47c2308823b 100644 --- a/src/Common/LRUCache.h +++ b/src/Common/LRUCache.h @@ -39,7 +39,7 @@ public: /** Initialize LRUCache with max_size and max_elements_size. * max_elements_size == 0 means no elements size restrictions. */ - LRUCache(size_t max_size_, size_t max_elements_size_ = 0) + explicit LRUCache(size_t max_size_, size_t max_elements_size_ = 0) : max_size(std::max(static_cast(1), max_size_)) , max_elements_size(max_elements_size_) {} @@ -174,7 +174,7 @@ public: misses = 0; } - virtual ~LRUCache() {} + virtual ~LRUCache() = default; protected: using LRUQueue = std::list; diff --git a/src/Common/LocalDate.h b/src/Common/LocalDate.h index 6c847ceff0e..5d070e77647 100644 --- a/src/Common/LocalDate.h +++ b/src/Common/LocalDate.h @@ -20,7 +20,7 @@ class LocalDate { private: - unsigned short m_year; + unsigned short m_year; /// NOLINT unsigned char m_month; unsigned char m_day; @@ -61,7 +61,7 @@ public: init(time); } - LocalDate(DayNum day_num) + LocalDate(DayNum day_num) /// NOLINT { const auto & values = DateLUT::instance().getValues(day_num); m_year = values.year; @@ -77,7 +77,7 @@ public: m_day = values.day_of_month; } - LocalDate(unsigned short year_, unsigned char month_, unsigned char day_) + LocalDate(unsigned short year_, unsigned char month_, unsigned char day_) /// NOLINT : m_year(year_), m_month(month_), m_day(day_) { } @@ -111,16 +111,16 @@ public: return ExtendedDayNum (lut.makeDayNum(m_year, m_month, m_day).toUnderType()); } - operator DayNum() const + operator DayNum() const /// NOLINT { return getDayNum(); } - unsigned short year() const { return m_year; } + unsigned short year() const { return m_year; } /// NOLINT unsigned char month() const { return m_month; } unsigned char day() const { return m_day; } - void year(unsigned short x) { m_year = x; } + void year(unsigned short x) { m_year = x; } /// NOLINT void month(unsigned char x) { m_month = x; } void day(unsigned char x) { m_day = x; } diff --git a/src/Common/LocalDateTime.h b/src/Common/LocalDateTime.h index fa0a680d274..a002be17787 100644 --- a/src/Common/LocalDateTime.h +++ b/src/Common/LocalDateTime.h @@ -18,7 +18,7 @@ class LocalDateTime { private: - unsigned short m_year; + unsigned short m_year; /// NOLINT unsigned char m_month; unsigned char m_day; unsigned char m_hour; @@ -65,7 +65,7 @@ public: init(time, time_zone); } - LocalDateTime(unsigned short year_, unsigned char month_, unsigned char day_, + LocalDateTime(unsigned short year_, unsigned char month_, unsigned char day_, /// NOLINT unsigned char hour_, unsigned char minute_, unsigned char second_) : m_year(year_), m_month(month_), m_day(day_), m_hour(hour_), m_minute(minute_), m_second(second_) { @@ -91,14 +91,14 @@ public: LocalDateTime(const LocalDateTime &) noexcept = default; LocalDateTime & operator= (const LocalDateTime &) noexcept = default; - unsigned short year() const { return m_year; } + unsigned short year() const { return m_year; } /// NOLINT unsigned char month() const { return m_month; } unsigned char day() const { return m_day; } unsigned char hour() const { return m_hour; } unsigned char minute() const { return m_minute; } unsigned char second() const { return m_second; } - void year(unsigned short x) { m_year = x; } + void year(unsigned short x) { m_year = x; } /// NOLINT void month(unsigned char x) { m_month = x; } void day(unsigned char x) { m_day = x; } void hour(unsigned char x) { m_hour = x; } @@ -108,7 +108,7 @@ public: LocalDate toDate() const { return LocalDate(m_year, m_month, m_day); } LocalDateTime toStartOfDate() const { return LocalDateTime(m_year, m_month, m_day, 0, 0, 0); } - time_t to_time_t(const DateLUTImpl & time_zone = DateLUT::instance()) const + time_t to_time_t(const DateLUTImpl & time_zone = DateLUT::instance()) const /// NOLINT { return time_zone.makeDateTime(m_year, m_month, m_day, m_hour, m_minute, m_second); } diff --git a/src/Common/Macros.h b/src/Common/Macros.h index dea3a3851f0..6ef87dfd51a 100644 --- a/src/Common/Macros.h +++ b/src/Common/Macros.h @@ -63,7 +63,7 @@ public: Names expand(const Names & source_names, size_t level = 0) const; using MacroMap = std::map; - const MacroMap getMacroMap() const { return macros; } + MacroMap getMacroMap() const { return macros; } String getValue(const String & key) const; diff --git a/src/Common/MemorySanitizer.h b/src/Common/MemorySanitizer.h index a230fe22bb8..d1b8fd07f33 100644 --- a/src/Common/MemorySanitizer.h +++ b/src/Common/MemorySanitizer.h @@ -12,10 +12,10 @@ #undef __msan_print_shadow #undef __msan_unpoison_string -#define __msan_unpoison(X, Y) -#define __msan_test_shadow(X, Y) (false) -#define __msan_print_shadow(X, Y) -#define __msan_unpoison_string(X) +#define __msan_unpoison(X, Y) /// NOLINT +#define __msan_test_shadow(X, Y) (false) /// NOLINT +#define __msan_print_shadow(X, Y) /// NOLINT +#define __msan_unpoison_string(X) /// NOLINT #if defined(ch_has_feature) # if ch_has_feature(memory_sanitizer) diff --git a/src/Common/MemoryTracker.h b/src/Common/MemoryTracker.h index a606086ab1c..dbe0e7d08b3 100644 --- a/src/Common/MemoryTracker.h +++ b/src/Common/MemoryTracker.h @@ -16,12 +16,20 @@ #ifdef MEMORY_TRACKER_DEBUG_CHECKS #include extern thread_local bool memory_tracker_always_throw_logical_error_on_allocation; + +/// NOLINTNEXTLINE #define ALLOCATIONS_IN_SCOPE_IMPL_CONCAT(n, val) \ bool _allocations_flag_prev_val##n = memory_tracker_always_throw_logical_error_on_allocation; \ memory_tracker_always_throw_logical_error_on_allocation = val; \ SCOPE_EXIT({ memory_tracker_always_throw_logical_error_on_allocation = _allocations_flag_prev_val##n; }) + +/// NOLINTNEXTLINE #define ALLOCATIONS_IN_SCOPE_IMPL(n, val) ALLOCATIONS_IN_SCOPE_IMPL_CONCAT(n, val) + +/// NOLINTNEXTLINE #define DENY_ALLOCATIONS_IN_SCOPE ALLOCATIONS_IN_SCOPE_IMPL(__LINE__, true) + +/// NOLINTNEXTLINE #define ALLOW_ALLOCATIONS_IN_SCOPE ALLOCATIONS_IN_SCOPE_IMPL(__LINE__, false) #else #define DENY_ALLOCATIONS_IN_SCOPE static_assert(true) diff --git a/src/Common/MultiVersion.h b/src/Common/MultiVersion.h index 3014689f861..a36a1f8ca5f 100644 --- a/src/Common/MultiVersion.h +++ b/src/Common/MultiVersion.h @@ -30,7 +30,7 @@ public: /// Default initialization - by nullptr. MultiVersion() = default; - MultiVersion(std::unique_ptr && value) + explicit MultiVersion(std::unique_ptr && value) { set(std::move(value)); } diff --git a/src/Common/NamePrompter.h b/src/Common/NamePrompter.h index 74725ede08c..a88d4bdea8e 100644 --- a/src/Common/NamePrompter.h +++ b/src/Common/NamePrompter.h @@ -105,9 +105,9 @@ public: IHints() = default; IHints(const IHints &) = default; - IHints(IHints &&) = default; + IHints(IHints &&) noexcept = default; IHints & operator=(const IHints &) = default; - IHints & operator=(IHints &&) = default; + IHints & operator=(IHints &&) noexcept = default; virtual ~IHints() = default; diff --git a/src/Common/ObjectPool.h b/src/Common/ObjectPool.h index 01768bf1de5..ef07b8eed1b 100644 --- a/src/Common/ObjectPool.h +++ b/src/Common/ObjectPool.h @@ -34,7 +34,7 @@ protected: { SimpleObjectPool * parent; - Deleter(SimpleObjectPool * parent_ = nullptr) : parent{parent_} {} + Deleter(SimpleObjectPool * parent_ = nullptr) : parent{parent_} {} /// NOLINT void operator()(T * owning_ptr) const { diff --git a/src/Common/OpenTelemetryTraceContext.h b/src/Common/OpenTelemetryTraceContext.h index 9f2b5af9105..4d2fc656100 100644 --- a/src/Common/OpenTelemetryTraceContext.h +++ b/src/Common/OpenTelemetryTraceContext.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + namespace DB { diff --git a/src/Common/OptimizedRegularExpression.h b/src/Common/OptimizedRegularExpression.h index 09b0dbe5337..53f3a7d34b1 100644 --- a/src/Common/OptimizedRegularExpression.h +++ b/src/Common/OptimizedRegularExpression.h @@ -55,7 +55,7 @@ public: using RegexType = std::conditional_t; using StringPieceType = std::conditional_t; - OptimizedRegularExpressionImpl(const std::string & regexp_, int options = 0); + OptimizedRegularExpressionImpl(const std::string & regexp_, int options = 0); /// NOLINT bool match(const std::string & subject) const { diff --git a/src/Common/PODArray.h b/src/Common/PODArray.h index 9b15782a231..e4c1969383b 100644 --- a/src/Common/PODArray.h +++ b/src/Common/PODArray.h @@ -106,7 +106,7 @@ protected: char * c_end_of_storage = null; /// Does not include pad_right. /// The amount of memory occupied by the num_elements of the elements. - static size_t byte_size(size_t num_elements) + static size_t byte_size(size_t num_elements) /// NOLINT { size_t amount; if (__builtin_mul_overflow(num_elements, ELEMENT_SIZE, &amount)) @@ -115,9 +115,9 @@ protected: } /// Minimum amount of memory to allocate for num_elements, including padding. - static size_t minimum_memory_for_elements(size_t num_elements) { return byte_size(num_elements) + pad_right + pad_left; } + static size_t minimum_memory_for_elements(size_t num_elements) { return byte_size(num_elements) + pad_right + pad_left; } /// NOLINT - void alloc_for_num_elements(size_t num_elements) + void alloc_for_num_elements(size_t num_elements) /// NOLINT { alloc(minimum_memory_for_elements(num_elements)); } @@ -220,7 +220,7 @@ public: size_t capacity() const { return (c_end_of_storage - c_start) / ELEMENT_SIZE; } /// This method is safe to use only for information about memory usage. - size_t allocated_bytes() const { return c_end_of_storage - c_start + pad_right + pad_left; } + size_t allocated_bytes() const { return c_end_of_storage - c_start + pad_right + pad_left; } /// NOLINT void clear() { c_end = c_start; } @@ -235,7 +235,7 @@ public: } template - void reserve_exact(size_t n, TAllocatorParams &&... allocator_params) + void reserve_exact(size_t n, TAllocatorParams &&... allocator_params) /// NOLINT { if (n > capacity()) realloc(minimum_memory_for_elements(n), std::forward(allocator_params)...); @@ -249,24 +249,24 @@ public: } template - void resize_exact(size_t n, TAllocatorParams &&... allocator_params) + void resize_exact(size_t n, TAllocatorParams &&... allocator_params) /// NOLINT { reserve_exact(n, std::forward(allocator_params)...); resize_assume_reserved(n); } - void resize_assume_reserved(const size_t n) + void resize_assume_reserved(const size_t n) /// NOLINT { c_end = c_start + byte_size(n); } - const char * raw_data() const + const char * raw_data() const /// NOLINT { return c_start; } template - void push_back_raw(const void * ptr, TAllocatorParams &&... allocator_params) + void push_back_raw(const void * ptr, TAllocatorParams &&... allocator_params) /// NOLINT { size_t required_capacity = size() + ELEMENT_SIZE; if (unlikely(required_capacity > capacity())) @@ -317,11 +317,11 @@ class PODArray : public PODArrayBase; - T * t_start() { return reinterpret_cast(this->c_start); } - T * t_end() { return reinterpret_cast(this->c_end); } + T * t_start() { return reinterpret_cast(this->c_start); } /// NOLINT + T * t_end() { return reinterpret_cast(this->c_end); } /// NOLINT - const T * t_start() const { return reinterpret_cast(this->c_start); } - const T * t_end() const { return reinterpret_cast(this->c_end); } + const T * t_start() const { return reinterpret_cast(this->c_start); } /// NOLINT + const T * t_end() const { return reinterpret_cast(this->c_end); } /// NOLINT public: using value_type = T; @@ -335,7 +335,7 @@ public: PODArray() = default; - PODArray(size_t n) + explicit PODArray(size_t n) { this->alloc_for_num_elements(n); this->c_end += this->byte_size(n); @@ -363,12 +363,12 @@ public: } } - PODArray(PODArray && other) + PODArray(PODArray && other) noexcept { this->swap(other); } - PODArray & operator=(PODArray && other) + PODArray & operator=(PODArray && other) noexcept { this->swap(other); return *this; @@ -404,7 +404,7 @@ public: const_iterator cend() const { return t_end(); } /// Same as resize, but zeroes new elements. - void resize_fill(size_t n) + void resize_fill(size_t n) /// NOLINT { size_t old_size = this->size(); if (n > old_size) @@ -415,7 +415,7 @@ public: this->c_end = this->c_start + this->byte_size(n); } - void resize_fill(size_t n, const T & value) + void resize_fill(size_t n, const T & value) /// NOLINT { size_t old_size = this->size(); if (n > old_size) @@ -427,7 +427,7 @@ public: } template - void push_back(U && x, TAllocatorParams &&... allocator_params) + void push_back(U && x, TAllocatorParams &&... allocator_params) /// NOLINT { if (unlikely(this->c_end + sizeof(T) > this->c_end_of_storage)) this->reserveForNextSize(std::forward(allocator_params)...); @@ -440,7 +440,7 @@ public: * and it couldn't be used if Allocator requires custom parameters. */ template - void emplace_back(Args &&... args) + void emplace_back(Args &&... args) /// NOLINT { if (unlikely(this->c_end + sizeof(T) > this->c_end_of_storage)) this->reserveForNextSize(); @@ -449,7 +449,7 @@ public: this->c_end += this->byte_size(1); } - void pop_back() + void pop_back() /// NOLINT { this->c_end -= this->byte_size(1); } @@ -554,7 +554,7 @@ public: } template - void insert_assume_reserved(It1 from_begin, It2 from_end) + void insert_assume_reserved(It1 from_begin, It2 from_end) /// NOLINT { static_assert(memcpy_can_be_used_for_assignment, std::decay_t>); this->assertNotIntersects(from_begin, from_end); diff --git a/src/Common/PoolWithFailoverBase.h b/src/Common/PoolWithFailoverBase.h index ae14011834a..3cac939b385 100644 --- a/src/Common/PoolWithFailoverBase.h +++ b/src/Common/PoolWithFailoverBase.h @@ -395,8 +395,8 @@ void PoolWithFailoverBase::updateErrorCounts(PoolWithFailoverBase= 0) { - const UInt64 MAX_BITS = sizeof(UInt64) * CHAR_BIT; - size_t shift_amount = MAX_BITS; + const UInt64 max_bits = sizeof(UInt64) * CHAR_BIT; + size_t shift_amount = max_bits; /// Divide error counts by 2 every decrease_error_period seconds. if (decrease_error_period) shift_amount = delta / decrease_error_period; @@ -405,7 +405,7 @@ void PoolWithFailoverBase::updateErrorCounts(PoolWithFailoverBase= MAX_BITS) + if (shift_amount >= max_bits) { for (auto & state : states) { diff --git a/src/Common/ProcfsMetricsProvider.cpp b/src/Common/ProcfsMetricsProvider.cpp index ee8fb37c4c5..d652e5b05e6 100644 --- a/src/Common/ProcfsMetricsProvider.cpp +++ b/src/Common/ProcfsMetricsProvider.cpp @@ -92,7 +92,7 @@ bool ProcfsMetricsProvider::isAvailable() noexcept } -ProcfsMetricsProvider::ProcfsMetricsProvider(const pid_t /*tid*/) +ProcfsMetricsProvider::ProcfsMetricsProvider(pid_t /*tid*/) { thread_schedstat_fd = ::open(thread_schedstat, O_RDONLY | O_CLOEXEC); if (-1 == thread_schedstat_fd) diff --git a/src/Common/ProcfsMetricsProvider.h b/src/Common/ProcfsMetricsProvider.h index 60eb94bfcc5..785ee077fdc 100644 --- a/src/Common/ProcfsMetricsProvider.h +++ b/src/Common/ProcfsMetricsProvider.h @@ -13,7 +13,7 @@ namespace DB class ProcfsMetricsProvider : private boost::noncopyable { public: - ProcfsMetricsProvider(const pid_t /*tid*/); + explicit ProcfsMetricsProvider(pid_t /*tid*/); ~ProcfsMetricsProvider(); /// Updates only a part of taskstats struct's fields: @@ -31,13 +31,12 @@ private: void readParseAndSetThreadBlkIOStat(::taskstats & out_stats, char *, size_t) const; void readParseAndSetThreadIOStat(::taskstats & out_stats, char *, size_t) const; -private: int thread_schedstat_fd = -1; int thread_stat_fd = -1; int thread_io_fd = -1; /// This field is used for compatibility with TasksStatsCounters::incrementProfileEvents() - unsigned short stats_version = 1; + unsigned short stats_version = 1; /// NOLINT }; } diff --git a/src/Common/ProfileEvents.h b/src/Common/ProfileEvents.h index 22acfa8d519..14d134a14a0 100644 --- a/src/Common/ProfileEvents.h +++ b/src/Common/ProfileEvents.h @@ -35,10 +35,10 @@ namespace ProfileEvents VariableContext level = VariableContext::Thread; /// By default, any instance have to increment global counters - Counters(VariableContext level_ = VariableContext::Thread, Counters * parent_ = &global_counters); + explicit Counters(VariableContext level_ = VariableContext::Thread, Counters * parent_ = &global_counters); /// Global level static initializer - Counters(Counter * allocated_counters) noexcept + explicit Counters(Counter * allocated_counters) noexcept : counters(allocated_counters), parent(nullptr), level(VariableContext::Global) {} Counter & operator[] (Event event) diff --git a/src/Common/QueryProfiler.cpp b/src/Common/QueryProfiler.cpp index 1f305e30c33..d84d239184c 100644 --- a/src/Common/QueryProfiler.cpp +++ b/src/Common/QueryProfiler.cpp @@ -86,7 +86,7 @@ namespace ErrorCodes } template -QueryProfilerBase::QueryProfilerBase(const UInt64 thread_id, const int clock_type, UInt32 period, const int pause_signal_) +QueryProfilerBase::QueryProfilerBase(UInt64 thread_id, int clock_type, UInt32 period, int pause_signal_) : log(&Poco::Logger::get("QueryProfiler")) , pause_signal(pause_signal_) { @@ -199,7 +199,7 @@ void QueryProfilerBase::tryCleanup() template class QueryProfilerBase; template class QueryProfilerBase; -QueryProfilerReal::QueryProfilerReal(const UInt64 thread_id, const UInt32 period) +QueryProfilerReal::QueryProfilerReal(UInt64 thread_id, UInt32 period) : QueryProfilerBase(thread_id, CLOCK_MONOTONIC, period, SIGUSR1) {} @@ -212,7 +212,7 @@ void QueryProfilerReal::signalHandler(int sig, siginfo_t * info, void * context) writeTraceInfo(TraceType::Real, sig, info, context); } -QueryProfilerCPU::QueryProfilerCPU(const UInt64 thread_id, const UInt32 period) +QueryProfilerCPU::QueryProfilerCPU(UInt64 thread_id, UInt32 period) : QueryProfilerBase(thread_id, CLOCK_THREAD_CPUTIME_ID, period, SIGUSR2) {} diff --git a/src/Common/QueryProfiler.h b/src/Common/QueryProfiler.h index 5cd64ecb76d..e3938cbc5d6 100644 --- a/src/Common/QueryProfiler.h +++ b/src/Common/QueryProfiler.h @@ -31,7 +31,7 @@ template class QueryProfilerBase { public: - QueryProfilerBase(const UInt64 thread_id, const int clock_type, UInt32 period, const int pause_signal_); + QueryProfilerBase(UInt64 thread_id, int clock_type, UInt32 period, int pause_signal_); ~QueryProfilerBase(); private: @@ -52,7 +52,7 @@ private: class QueryProfilerReal : public QueryProfilerBase { public: - QueryProfilerReal(const UInt64 thread_id, const UInt32 period); + QueryProfilerReal(UInt64 thread_id, UInt32 period); /// NOLINT static void signalHandler(int sig, siginfo_t * info, void * context); }; @@ -61,7 +61,7 @@ public: class QueryProfilerCPU : public QueryProfilerBase { public: - QueryProfilerCPU(const UInt64 thread_id, const UInt32 period); + QueryProfilerCPU(UInt64 thread_id, UInt32 period); /// NOLINT static void signalHandler(int sig, siginfo_t * info, void * context); }; diff --git a/src/Common/RadixSort.h b/src/Common/RadixSort.h index b1e4d7d02f1..944ab860355 100644 --- a/src/Common/RadixSort.h +++ b/src/Common/RadixSort.h @@ -37,12 +37,12 @@ */ struct RadixSortAllocator { - void * allocate(size_t size) + static void * allocate(size_t size) { return ::operator new(size); } - void deallocate(void * ptr, size_t size) + static void deallocate(void * ptr, size_t size) { ::operator delete(ptr, size); } diff --git a/src/Common/SettingsChanges.h b/src/Common/SettingsChanges.h index 073af21c6cc..5f6a390d0d2 100644 --- a/src/Common/SettingsChanges.h +++ b/src/Common/SettingsChanges.h @@ -13,7 +13,7 @@ struct SettingChange String name; Field value; - SettingChange() {} + SettingChange() = default; SettingChange(const std::string_view & name_, const Field & value_) : name(name_), value(value_) {} SettingChange(const std::string_view & name_, Field && value_) : name(name_), value(std::move(value_)) {} diff --git a/src/Common/SharedBlockRowRef.h b/src/Common/SharedBlockRowRef.h index 46c35c6ac47..77dd0f1cc13 100644 --- a/src/Common/SharedBlockRowRef.h +++ b/src/Common/SharedBlockRowRef.h @@ -24,7 +24,7 @@ namespace detail ColumnRawPtrs all_columns; ColumnRawPtrs sort_columns; - SharedBlock(Block && block) : Block(std::move(block)) {} + explicit SharedBlock(Block && block) : Block(std::move(block)) {} }; } diff --git a/src/Common/ShellCommand.h b/src/Common/ShellCommand.h index 2d5af1f9a02..190b5bc664e 100644 --- a/src/Common/ShellCommand.h +++ b/src/Common/ShellCommand.h @@ -45,11 +45,11 @@ public: struct Config { - Config(const std::string & command_) + Config(const std::string & command_) /// NOLINT : command(command_) {} - Config(const char * command_) + Config(const char * command_) /// NOLINT : command(command_) {} diff --git a/src/Common/SipHash.h b/src/Common/SipHash.h index e0d0b5ed631..f9efd67e3e4 100644 --- a/src/Common/SipHash.h +++ b/src/Common/SipHash.h @@ -71,7 +71,7 @@ private: public: /// Arguments - seed. - SipHash(UInt64 k0 = 0, UInt64 k1 = 0) + SipHash(UInt64 k0 = 0, UInt64 k1 = 0) /// NOLINT { /// Initialize the state with some random bytes and seed. v0 = 0x736f6d6570736575ULL ^ k0; @@ -139,7 +139,7 @@ public: template void update(const T & x) { - update(reinterpret_cast(&x), sizeof(x)); + update(reinterpret_cast(&x), sizeof(x)); /// NOLINT } void update(const std::string & x) diff --git a/src/Common/SmallObjectPool.h b/src/Common/SmallObjectPool.h index 947942e3aaf..4d56a92a419 100644 --- a/src/Common/SmallObjectPool.h +++ b/src/Common/SmallObjectPool.h @@ -18,7 +18,7 @@ private: char * free_list = nullptr; public: - SmallObjectPool(size_t object_size_) + explicit SmallObjectPool(size_t object_size_) : object_size{std::max(object_size_, sizeof(char *))} { } diff --git a/src/Common/SpaceSaving.h b/src/Common/SpaceSaving.h index 03d2c9638a4..48817d8c926 100644 --- a/src/Common/SpaceSaving.h +++ b/src/Common/SpaceSaving.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -35,8 +36,8 @@ namespace DB template struct SpaceSavingArena { - SpaceSavingArena() {} - const TKey emplace(const TKey & key) { return key; } + SpaceSavingArena() = default; + TKey emplace(const TKey & key) { return key; } void free(const TKey & /*key*/) {} }; @@ -48,11 +49,9 @@ struct SpaceSavingArena template <> struct SpaceSavingArena { - const StringRef emplace(const StringRef & key) + StringRef emplace(const StringRef & key) { - auto ptr = arena.alloc(key.size); - std::copy(key.data, key.data + key.size, ptr); - return StringRef{ptr, key.size}; + return copyStringInArena(arena, key); } void free(const StringRef & key) @@ -78,8 +77,8 @@ private: // Round to nearest power of 2 for cheaper binning without modulo constexpr uint64_t nextAlphaSize(uint64_t x) { - constexpr uint64_t ALPHA_MAP_ELEMENTS_PER_COUNTER = 6; - return 1ULL << (sizeof(uint64_t) * 8 - __builtin_clzll(x * ALPHA_MAP_ELEMENTS_PER_COUNTER)); + constexpr uint64_t alpha_map_elements_per_counter = 6; + return 1ULL << (sizeof(uint64_t) * 8 - __builtin_clzll(x * alpha_map_elements_per_counter)); } public: @@ -89,7 +88,7 @@ public: { Counter() = default; //-V730 - Counter(const TKey & k, UInt64 c = 0, UInt64 e = 0, size_t h = 0) + explicit Counter(const TKey & k, UInt64 c = 0, UInt64 e = 0, size_t h = 0) : key(k), slot(0), hash(h), count(c), error(e) {} void write(WriteBuffer & wb) const @@ -119,7 +118,7 @@ public: UInt64 error; }; - SpaceSaving(size_t c = 10) : alpha_map(nextAlphaSize(c)), m_capacity(c) {} + explicit SpaceSaving(size_t c = 10) : alpha_map(nextAlphaSize(c)), m_capacity(c) {} ~SpaceSaving() { destroyElements(); } diff --git a/src/Common/StringSearcher.h b/src/Common/StringSearcher.h index c626231bc55..5cdbbc22e12 100644 --- a/src/Common/StringSearcher.h +++ b/src/Common/StringSearcher.h @@ -137,7 +137,7 @@ public: patu = _mm_set1_epi8(u); /// lower and uppercase vectors of first 16 octets of `needle` - auto needle_pos = needle; + const auto * needle_pos = needle; for (size_t i = 0; i < n;) { @@ -251,7 +251,7 @@ public: if (*pos == l || *pos == u) { pos += first_needle_symbol_is_ascii; - auto needle_pos = needle + first_needle_symbol_is_ascii; + const auto * needle_pos = needle + first_needle_symbol_is_ascii; if (compareTrivial(pos, haystack_end, needle_pos)) return true; @@ -325,7 +325,7 @@ public: if (*haystack == l || *haystack == u) { auto haystack_pos = haystack + first_needle_symbol_is_ascii; - auto needle_pos = needle + first_needle_symbol_is_ascii; + const auto * needle_pos = needle + first_needle_symbol_is_ascii; if (compareTrivial(haystack_pos, haystack_end, needle_pos)) return haystack; @@ -381,7 +381,7 @@ public: patl = _mm_set1_epi8(l); patu = _mm_set1_epi8(u); - auto needle_pos = needle; + const auto * needle_pos = needle; for (const auto i : collections::range(0, n)) { @@ -416,7 +416,7 @@ public: if (mask == cachemask) { pos += n; - auto needle_pos = needle + n; + const auto * needle_pos = needle + n; while (needle_pos < needle_end && std::tolower(*pos) == std::tolower(*needle_pos)) { @@ -438,7 +438,7 @@ public: if (*pos == l || *pos == u) { ++pos; - auto needle_pos = needle + 1; + const auto * needle_pos = needle + 1; while (needle_pos < needle_end && std::tolower(*pos) == std::tolower(*needle_pos)) { @@ -492,8 +492,8 @@ public: { if (mask_offset == cachemask) { - auto haystack_pos = haystack + n; - auto needle_pos = needle + n; + const auto * haystack_pos = haystack + n; + const auto * needle_pos = needle + n; while (haystack_pos < haystack_end && needle_pos < needle_end && std::tolower(*haystack_pos) == std::tolower(*needle_pos)) @@ -520,8 +520,8 @@ public: if (*haystack == l || *haystack == u) { - auto haystack_pos = haystack + 1; - auto needle_pos = needle + 1; + const auto * haystack_pos = haystack + 1; + const auto * needle_pos = needle + 1; while (haystack_pos < haystack_end && needle_pos < needle_end && std::tolower(*haystack_pos) == std::tolower(*needle_pos)) @@ -580,7 +580,7 @@ public: #ifdef __SSE4_1__ pattern = _mm_set1_epi8(first); - auto needle_pos = needle; + const auto * needle_pos = needle; for (const auto i : collections::range(0, n)) { @@ -611,7 +611,7 @@ public: if (mask == cachemask) { pos += n; - auto needle_pos = needle + n; + const auto * needle_pos = needle + n; while (needle_pos < needle_end && *pos == *needle_pos) ++pos, ++needle_pos; @@ -630,7 +630,7 @@ public: if (*pos == first) { ++pos; - auto needle_pos = needle + 1; + const auto * needle_pos = needle + 1; while (needle_pos < needle_end && *pos == *needle_pos) ++pos, ++needle_pos; @@ -680,8 +680,8 @@ public: { if (mask_offset == cachemask) { - auto haystack_pos = haystack + n; - auto needle_pos = needle + n; + const auto * haystack_pos = haystack + n; + const auto * needle_pos = needle + n; while (haystack_pos < haystack_end && needle_pos < needle_end && *haystack_pos == *needle_pos) @@ -705,8 +705,8 @@ public: if (*haystack == first) { - auto haystack_pos = haystack + 1; - auto needle_pos = needle + 1; + const auto * haystack_pos = haystack + 1; + const auto * needle_pos = needle + 1; while (haystack_pos < haystack_end && needle_pos < needle_end && *haystack_pos == *needle_pos) @@ -796,10 +796,7 @@ public: ALWAYS_INLINE static bool isTokenSeparator(const uint8_t c) { - if (isAlphaNumericASCII(c) || !isASCII(c)) - return false; - - return true; + return !(isAlphaNumericASCII(c) || !isASCII(c)); } }; @@ -829,7 +826,7 @@ struct LibCASCIICaseSensitiveStringSearcher : public StringSearcherBase template > const CharT * search(const CharT * haystack, const CharT * const haystack_end) const { - auto res = strstr(reinterpret_cast(haystack), reinterpret_cast(needle)); + const auto * res = strstr(reinterpret_cast(haystack), reinterpret_cast(needle)); if (!res) return haystack_end; return reinterpret_cast(res); @@ -853,7 +850,7 @@ struct LibCASCIICaseInsensitiveStringSearcher : public StringSearcherBase template > const CharT * search(const CharT * haystack, const CharT * const haystack_end) const { - auto res = strcasestr(reinterpret_cast(haystack), reinterpret_cast(needle)); + const auto * res = strcasestr(reinterpret_cast(haystack), reinterpret_cast(needle)); if (!res) return haystack_end; return reinterpret_cast(res); diff --git a/src/Common/SystemLogBase.h b/src/Common/SystemLogBase.h index 4b3ec5fe379..d354229dc1f 100644 --- a/src/Common/SystemLogBase.h +++ b/src/Common/SystemLogBase.h @@ -45,7 +45,7 @@ class ISystemLog public: virtual String getName() = 0; //// force -- force table creation (used for SYSTEM FLUSH LOGS) - virtual void flush(bool force = false) = 0; + virtual void flush(bool force = false) = 0; /// NOLINT virtual void prepareTable() = 0; /// Start the background thread. diff --git a/src/Common/TLDListsHolder.h b/src/Common/TLDListsHolder.h index 025954727c5..b41ad4e6f45 100644 --- a/src/Common/TLDListsHolder.h +++ b/src/Common/TLDListsHolder.h @@ -20,7 +20,7 @@ class TLDList public: using Container = StringHashSet<>; - TLDList(size_t size); + explicit TLDList(size_t size); /// Return true if the tld_container does not contains such element. bool insert(const StringRef & host); diff --git a/src/Common/TerminalSize.h b/src/Common/TerminalSize.h index d7eee417f46..b5fc6de7921 100644 --- a/src/Common/TerminalSize.h +++ b/src/Common/TerminalSize.h @@ -12,5 +12,5 @@ uint16_t getTerminalWidth(); /** Creates po::options_description with name and an appropriate size for option displaying * when program is called with option --help * */ -po::options_description createOptionsDescription(const std::string &caption, unsigned short terminal_width); +po::options_description createOptionsDescription(const std::string &caption, unsigned short terminal_width); /// NOLINT diff --git a/src/Common/ThreadPool.h b/src/Common/ThreadPool.h index c4421a5b374..93917f312d6 100644 --- a/src/Common/ThreadPool.h +++ b/src/Common/ThreadPool.h @@ -189,12 +189,12 @@ public: }); } - ThreadFromGlobalPool(ThreadFromGlobalPool && rhs) + ThreadFromGlobalPool(ThreadFromGlobalPool && rhs) noexcept { *this = std::move(rhs); } - ThreadFromGlobalPool & operator=(ThreadFromGlobalPool && rhs) + ThreadFromGlobalPool & operator=(ThreadFromGlobalPool && rhs) noexcept { if (joinable()) abort(); diff --git a/src/Common/ThreadProfileEvents.cpp b/src/Common/ThreadProfileEvents.cpp index 66cf5f49ab8..90a9d6ede23 100644 --- a/src/Common/ThreadProfileEvents.cpp +++ b/src/Common/ThreadProfileEvents.cpp @@ -71,7 +71,7 @@ bool TasksStatsCounters::checkIfAvailable() return findBestAvailableProvider() != MetricsProvider::None; } -std::unique_ptr TasksStatsCounters::create(const UInt64 tid) +std::unique_ptr TasksStatsCounters::create(UInt64 tid) { std::unique_ptr instance; if (checkIfAvailable()) diff --git a/src/Common/ThreadProfileEvents.h b/src/Common/ThreadProfileEvents.h index c1ff0df84f0..befd759c71b 100644 --- a/src/Common/ThreadProfileEvents.h +++ b/src/Common/ThreadProfileEvents.h @@ -177,7 +177,7 @@ class TasksStatsCounters { public: static bool checkIfAvailable(); - static std::unique_ptr create(const UInt64 tid); + static std::unique_ptr create(UInt64 tid); void reset(); void updateCounters(ProfileEvents::Counters & profile_events); @@ -193,8 +193,7 @@ private: Netlink }; -private: - explicit TasksStatsCounters(const UInt64 tid, const MetricsProvider provider); + explicit TasksStatsCounters(UInt64 tid, MetricsProvider provider); static MetricsProvider findBestAvailableProvider(); static void incrementProfileEvents(const ::taskstats & prev, const ::taskstats & curr, ProfileEvents::Counters & profile_events); diff --git a/src/Common/Throttler.h b/src/Common/Throttler.h index b2c704e5308..89a83bb23be 100644 --- a/src/Common/Throttler.h +++ b/src/Common/Throttler.h @@ -18,7 +18,7 @@ namespace DB class Throttler { public: - Throttler(size_t max_speed_, const std::shared_ptr & parent_ = nullptr) + explicit Throttler(size_t max_speed_, const std::shared_ptr & parent_ = nullptr) : max_speed(max_speed_), limit_exceeded_exception_message(""), parent(parent_) {} Throttler(size_t max_speed_, size_t limit_, const char * limit_exceeded_exception_message_, diff --git a/src/Common/TraceSender.h b/src/Common/TraceSender.h index 04c9286ad39..a93e605a6e7 100644 --- a/src/Common/TraceSender.h +++ b/src/Common/TraceSender.h @@ -4,11 +4,12 @@ #include class StackTrace; -class TraceCollector; namespace DB { +class TraceCollector; + enum class TraceType : uint8_t { Real, diff --git a/src/Common/UTF8Helpers.h b/src/Common/UTF8Helpers.h index 9641518de37..75cfd8fe070 100644 --- a/src/Common/UTF8Helpers.h +++ b/src/Common/UTF8Helpers.h @@ -55,11 +55,11 @@ inline size_t seqLength(const UInt8 first_octet) inline size_t countCodePoints(const UInt8 * data, size_t size) { size_t res = 0; - const auto end = data + size; + const auto * end = data + size; #ifdef __SSE2__ constexpr auto bytes_sse = sizeof(__m128i); - const auto src_end_sse = data + size / bytes_sse * bytes_sse; + const auto * src_end_sse = data + size / bytes_sse * bytes_sse; const auto threshold = _mm_set1_epi8(0xBF); diff --git a/src/Common/VersionNumber.h b/src/Common/VersionNumber.h index 389644266c4..13c35063632 100644 --- a/src/Common/VersionNumber.h +++ b/src/Common/VersionNumber.h @@ -19,15 +19,15 @@ struct VersionNumber VersionNumber(const std::initializer_list & init) : components(init) {} - VersionNumber(Int64 major, Int64 minor = 0, Int64 patch = 0) + VersionNumber(Int64 major, Int64 minor = 0, Int64 patch = 0) /// NOLINT : components{major, minor, patch} {} - VersionNumber(const std::vector & components_) + VersionNumber(const std::vector & components_) /// NOLINT : components(components_) {} /// Parse version number from string. - VersionNumber(std::string version); + explicit VersionNumber(std::string version); /// NOTE: operator<=> can be used once libc++ will be upgraded. bool operator<(const VersionNumber & rhs) const { return compare(rhs.components) < 0; } diff --git a/src/Common/Visitor.h b/src/Common/Visitor.h index d14f737ac77..5f7b9acb4d6 100644 --- a/src/Common/Visitor.h +++ b/src/Common/Visitor.h @@ -3,6 +3,7 @@ #include #include #include +#include /* Generic utils which are intended for visitor pattern implementation. * The original purpose is to provide possibility to get concrete template specialisation for type in list. diff --git a/src/Common/Volnitsky.h b/src/Common/Volnitsky.h index cbdaf7048eb..7eca0c0fe53 100644 --- a/src/Common/Volnitsky.h +++ b/src/Common/Volnitsky.h @@ -155,7 +155,7 @@ namespace VolnitskyTraits if (UTF8::isContinuationOctet(chars.c1)) { /// ngram is inside a sequence - auto seq_pos = pos; + const auto * seq_pos = pos; UTF8::syncBackward(seq_pos, begin); auto u32 = UTF8::convertUTF8ToCodePoint(seq_pos, end - seq_pos); @@ -205,7 +205,7 @@ namespace VolnitskyTraits { /// ngram is on the boundary of two sequences /// first sequence may start before u_pos if it is not ASCII - auto first_seq_pos = pos; + const auto * first_seq_pos = pos; UTF8::syncBackward(first_seq_pos, begin); /// where is the given ngram in respect to the start of first UTF-8 sequence? size_t seq_ngram_offset = pos - first_seq_pos; @@ -221,7 +221,7 @@ namespace VolnitskyTraits } /// second sequence always start immediately after u_pos - auto second_seq_pos = pos + 1; + const auto * second_seq_pos = pos + 1; auto second_u32 = UTF8::convertUTF8ToCodePoint(second_seq_pos, end - second_seq_pos); int second_l_u32 = 0; @@ -427,7 +427,7 @@ public: if (needle_size == 0) return haystack; - const auto haystack_end = haystack + haystack_size; + const auto * haystack_end = haystack + haystack_size; if (fallback || haystack_size <= needle_size || fallback_searcher.force_fallback) return fallback_searcher.search(haystack, haystack_end); @@ -441,7 +441,7 @@ public: cell_num = (cell_num + 1) % VolnitskyTraits::hash_size) { /// When found - compare bytewise, using the offset from the hash table. - const auto res = pos - (hash[cell_num] - 1); + const auto * res = pos - (hash[cell_num] - 1); /// pointer in the code is always padded array so we can use pagesafe semantics if (fallback_searcher.compare(haystack, haystack_end, res)) @@ -502,7 +502,7 @@ private: static constexpr size_t small_limit = VolnitskyTraits::hash_size / 8; public: - MultiVolnitskyBase(const std::vector & needles_) : needles{needles_}, step{0}, last{0} + explicit MultiVolnitskyBase(const std::vector & needles_) : needles{needles_}, step{0}, last{0} { fallback_searchers.reserve(needles.size()); hash = std::unique_ptr(new OffsetId[VolnitskyTraits::hash_size]); /// No zero initialization, it will be done later. diff --git a/src/Common/ZooKeeper/IKeeper.h b/src/Common/ZooKeeper/IKeeper.h index 65ebd8ee615..1e6239a7fa6 100644 --- a/src/Common/ZooKeeper/IKeeper.h +++ b/src/Common/ZooKeeper/IKeeper.h @@ -47,9 +47,9 @@ struct Stat int32_t version; int32_t cversion; int32_t aversion; - int64_t ephemeralOwner; - int32_t dataLength; - int32_t numChildren; + int64_t ephemeralOwner; /// NOLINT + int32_t dataLength; /// NOLINT + int32_t numChildren; /// NOLINT int64_t pzxid; }; @@ -387,12 +387,12 @@ class Exception : public DB::Exception { private: /// Delegate constructor, used to minimize repetition; last parameter used for overload resolution. - Exception(const std::string & msg, const Error code_, int); + Exception(const std::string & msg, const Error code_, int); /// NOLINT public: - explicit Exception(const Error code_); - Exception(const std::string & msg, const Error code_); - Exception(const Error code_, const std::string & path); + explicit Exception(const Error code_); /// NOLINT + Exception(const std::string & msg, const Error code_); /// NOLINT + Exception(const Error code_, const std::string & path); /// NOLINT Exception(const Exception & exc); const char * name() const throw() override { return "Coordination::Exception"; } diff --git a/src/Common/ZooKeeper/ZooKeeper.h b/src/Common/ZooKeeper/ZooKeeper.h index 371f93f6df3..6d0f8a438b1 100644 --- a/src/Common/ZooKeeper/ZooKeeper.h +++ b/src/Common/ZooKeeper/ZooKeeper.h @@ -53,14 +53,14 @@ public: using Ptr = std::shared_ptr; /// hosts_string -- comma separated [secure://]host:port list - ZooKeeper(const std::string & hosts_string, const std::string & identity_ = "", + explicit ZooKeeper(const std::string & hosts_string, const std::string & identity_ = "", int32_t session_timeout_ms_ = Coordination::DEFAULT_SESSION_TIMEOUT_MS, int32_t operation_timeout_ms_ = Coordination::DEFAULT_OPERATION_TIMEOUT_MS, const std::string & chroot_ = "", const std::string & implementation_ = "zookeeper", std::shared_ptr zk_log_ = nullptr); - ZooKeeper(const Strings & hosts_, const std::string & identity_ = "", + explicit ZooKeeper(const Strings & hosts_, const std::string & identity_ = "", int32_t session_timeout_ms_ = Coordination::DEFAULT_SESSION_TIMEOUT_MS, int32_t operation_timeout_ms_ = Coordination::DEFAULT_OPERATION_TIMEOUT_MS, const std::string & chroot_ = "", diff --git a/src/Common/ZooKeeper/ZooKeeperCommon.h b/src/Common/ZooKeeper/ZooKeeperCommon.h index 237c98d8497..80e38dd74d5 100644 --- a/src/Common/ZooKeeper/ZooKeeperCommon.h +++ b/src/Common/ZooKeeper/ZooKeeperCommon.h @@ -524,7 +524,6 @@ public: private: OpNumToRequest op_num_to_request; -private: ZooKeeperRequestFactory(); }; diff --git a/src/Common/ZooKeeper/ZooKeeperNodeCache.h b/src/Common/ZooKeeper/ZooKeeperNodeCache.h index c8e7cc9775d..2167b8bd11b 100644 --- a/src/Common/ZooKeeper/ZooKeeperNodeCache.h +++ b/src/Common/ZooKeeper/ZooKeeperNodeCache.h @@ -31,7 +31,7 @@ namespace zkutil class ZooKeeperNodeCache { public: - ZooKeeperNodeCache(GetZooKeeper get_zookeeper); + explicit ZooKeeperNodeCache(GetZooKeeper get_zookeeper); ZooKeeperNodeCache(const ZooKeeperNodeCache &) = delete; ZooKeeperNodeCache(ZooKeeperNodeCache &&) = default; diff --git a/src/Common/formatReadable.h b/src/Common/formatReadable.h index 1c46bd8af09..6cdc36b4ed2 100644 --- a/src/Common/formatReadable.h +++ b/src/Common/formatReadable.h @@ -36,10 +36,10 @@ struct ReadableSize template <> struct fmt::formatter { - constexpr auto parse(format_parse_context & ctx) + constexpr static auto parse(format_parse_context & ctx) { - auto it = ctx.begin(); - auto end = ctx.end(); + const auto * it = ctx.begin(); + const auto * end = ctx.end(); /// Only support {}. if (it != end && *it != '}') diff --git a/src/Common/mysqlxx/mysqlxx/Connection.h b/src/Common/mysqlxx/mysqlxx/Connection.h index 548e75a1fef..e5425aa8327 100644 --- a/src/Common/mysqlxx/mysqlxx/Connection.h +++ b/src/Common/mysqlxx/mysqlxx/Connection.h @@ -83,7 +83,7 @@ public: /// Creates connection. Can be used if Poco::Util::Application is using. /// All settings will be got from config_name section of configuration. - Connection(const std::string & config_name); + explicit Connection(const std::string & config_name); ~Connection(); diff --git a/src/Common/mysqlxx/mysqlxx/Exception.h b/src/Common/mysqlxx/mysqlxx/Exception.h index 48cd0997b94..f022335a9dd 100644 --- a/src/Common/mysqlxx/mysqlxx/Exception.h +++ b/src/Common/mysqlxx/mysqlxx/Exception.h @@ -10,7 +10,7 @@ namespace mysqlxx /// Common exception class for MySQL library. Functions code() and errnum() return error numbers from MySQL, for details see mysqld_error.h struct Exception : public Poco::Exception { - Exception(const std::string & msg, int code = 0) : Poco::Exception(msg, code) {} + explicit Exception(const std::string & msg, int code = 0) : Poco::Exception(msg, code) {} int errnum() const { return code(); } const char * name() const throw() override { return "mysqlxx::Exception"; } const char * className() const throw() override { return "mysqlxx::Exception"; } @@ -20,7 +20,7 @@ struct Exception : public Poco::Exception /// Cannot connect to MySQL server struct ConnectionFailed : public Exception { - ConnectionFailed(const std::string & msg, int code = 0) : Exception(msg, code) {} + explicit ConnectionFailed(const std::string & msg, int code = 0) : Exception(msg, code) {} const char * name() const throw() override { return "mysqlxx::ConnectionFailed"; } const char * className() const throw() override { return "mysqlxx::ConnectionFailed"; } }; @@ -29,7 +29,7 @@ struct ConnectionFailed : public Exception /// Connection to MySQL server was lost struct ConnectionLost : public Exception { - ConnectionLost(const std::string & msg, int code = 0) : Exception(msg, code) {} + explicit ConnectionLost(const std::string & msg, int code = 0) : Exception(msg, code) {} const char * name() const throw() override { return "mysqlxx::ConnectionLost"; } const char * className() const throw() override { return "mysqlxx::ConnectionLost"; } }; @@ -38,7 +38,7 @@ struct ConnectionLost : public Exception /// Erroneous query. struct BadQuery : public Exception { - BadQuery(const std::string & msg, int code = 0) : Exception(msg, code) {} + explicit BadQuery(const std::string & msg, int code = 0) : Exception(msg, code) {} const char * name() const throw() override { return "mysqlxx::BadQuery"; } const char * className() const throw() override { return "mysqlxx::BadQuery"; } }; @@ -47,7 +47,7 @@ struct BadQuery : public Exception /// Value parsing failure struct CannotParseValue : public Exception { - CannotParseValue(const std::string & msg, int code = 0) : Exception(msg, code) {} + explicit CannotParseValue(const std::string & msg, int code = 0) : Exception(msg, code) {} const char * name() const throw() override { return "mysqlxx::CannotParseValue"; } const char * className() const throw() override { return "mysqlxx::CannotParseValue"; } }; diff --git a/src/Common/mysqlxx/mysqlxx/Null.h b/src/Common/mysqlxx/mysqlxx/Null.h index b12e1e7f0bf..8448164f3aa 100644 --- a/src/Common/mysqlxx/mysqlxx/Null.h +++ b/src/Common/mysqlxx/mysqlxx/Null.h @@ -27,17 +27,17 @@ public: Null() : is_null(true) {} Null(const Null &) = default; Null(Null &&) noexcept = default; - Null(NullType) : is_null(true) {} + Null(NullType) : is_null(true) {} /// NOLINT explicit Null(const T & data_) : data(data_), is_null(false) {} - operator T & () + operator T & () /// NOLINT { if (is_null) throw Exception("Value is NULL"); return data; } - operator const T & () const + operator const T & () const /// NOLINT { if (is_null) throw Exception("Value is NULL"); diff --git a/src/Common/mysqlxx/mysqlxx/Pool.h b/src/Common/mysqlxx/mysqlxx/Pool.h index f542c3d3b76..5a436146f02 100644 --- a/src/Common/mysqlxx/mysqlxx/Pool.h +++ b/src/Common/mysqlxx/mysqlxx/Pool.h @@ -48,7 +48,7 @@ public: class Entry { public: - Entry() {} + Entry() {} /// NOLINT Entry(const Entry & src) : data(src.data), pool(src.pool) @@ -61,7 +61,7 @@ public: decrementRefCount(); } - Entry & operator= (const Entry & src) + Entry & operator= (const Entry & src) /// NOLINT { pool = src.pool; if (data) @@ -77,13 +77,13 @@ public: return data == nullptr; } - operator mysqlxx::Connection & () & + operator mysqlxx::Connection & () & /// NOLINT { forceConnected(); return data->conn; } - operator const mysqlxx::Connection & () const & + operator const mysqlxx::Connection & () const & /// NOLINT { forceConnected(); return data->conn; @@ -136,7 +136,7 @@ public: }; - Pool(const std::string & config_name, + explicit Pool(const std::string & config_name, unsigned default_connections_ = MYSQLXX_POOL_DEFAULT_START_CONNECTIONS, unsigned max_connections_ = MYSQLXX_POOL_DEFAULT_MAX_CONNECTIONS, const char * parent_config_name_ = nullptr) diff --git a/src/Common/mysqlxx/mysqlxx/PoolWithFailover.h b/src/Common/mysqlxx/mysqlxx/PoolWithFailover.h index 17870d141e1..513c0deba72 100644 --- a/src/Common/mysqlxx/mysqlxx/PoolWithFailover.h +++ b/src/Common/mysqlxx/mysqlxx/PoolWithFailover.h @@ -101,7 +101,7 @@ namespace mysqlxx * max_tries_ Max number of connection tries. * wait_timeout_ Timeout for waiting free connection. */ - PoolWithFailover( + explicit PoolWithFailover( const std::string & config_name_, unsigned default_connections_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_START_CONNECTIONS, unsigned max_connections_ = MYSQLXX_POOL_WITH_FAILOVER_DEFAULT_MAX_CONNECTIONS, diff --git a/src/Common/mysqlxx/mysqlxx/ResultBase.h b/src/Common/mysqlxx/mysqlxx/ResultBase.h index d08922a269c..7fd61c36788 100644 --- a/src/Common/mysqlxx/mysqlxx/ResultBase.h +++ b/src/Common/mysqlxx/mysqlxx/ResultBase.h @@ -27,7 +27,7 @@ public: Connection * getConnection() { return conn; } MYSQL_FIELDS getFields() { return fields; } - unsigned getNumFields() { return num_fields; } + unsigned getNumFields() const { return num_fields; } MYSQL_RES * getRes() { return res; } const Query * getQuery() const { return query; } diff --git a/src/Common/mysqlxx/mysqlxx/Row.h b/src/Common/mysqlxx/mysqlxx/Row.h index b11d7d628ef..6ef40ff2060 100644 --- a/src/Common/mysqlxx/mysqlxx/Row.h +++ b/src/Common/mysqlxx/mysqlxx/Row.h @@ -27,11 +27,11 @@ private: * @see http://www.artima.com/cppsource/safebool.html * Взято из mysql++. */ - typedef MYSQL_ROW Row::*private_bool_type; + typedef MYSQL_ROW Row::*private_bool_type; /// NOLINT public: /** Для возможности отложенной инициализации. */ - Row() + Row() /// NOLINT { } @@ -77,7 +77,7 @@ public: /** Преобразование в bool. * (Точнее - в тип, который преобразуется в bool, и с которым больше почти ничего нельзя сделать.) */ - operator private_bool_type() const { return row == nullptr ? nullptr : &Row::row; } + operator private_bool_type() const { return row == nullptr ? nullptr : &Row::row; } /// NOLINT enum enum_field_types getFieldType(size_t i); diff --git a/src/Common/mysqlxx/mysqlxx/Transaction.h b/src/Common/mysqlxx/mysqlxx/Transaction.h index 2b3a26ef63a..6efd40e0b39 100644 --- a/src/Common/mysqlxx/mysqlxx/Transaction.h +++ b/src/Common/mysqlxx/mysqlxx/Transaction.h @@ -14,7 +14,7 @@ namespace mysqlxx class Transaction : private boost::noncopyable { public: - Transaction(Connection & conn_) + explicit Transaction(Connection & conn_) : conn(conn_), finished(false) { conn.query("START TRANSACTION").execute(); diff --git a/src/Common/mysqlxx/mysqlxx/Types.h b/src/Common/mysqlxx/mysqlxx/Types.h index 6ad4eb7c355..883eb41989e 100644 --- a/src/Common/mysqlxx/mysqlxx/Types.h +++ b/src/Common/mysqlxx/mysqlxx/Types.h @@ -16,7 +16,7 @@ using MYSQL_ROW = char**; struct st_mysql_field; using MYSQL_FIELD = st_mysql_field; -enum struct enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, +enum struct enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, /// NOLINT MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG, MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE, MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP, diff --git a/src/Common/mysqlxx/mysqlxx/UseQueryResult.h b/src/Common/mysqlxx/mysqlxx/UseQueryResult.h index 37cbbd19669..14da5e1d727 100644 --- a/src/Common/mysqlxx/mysqlxx/UseQueryResult.h +++ b/src/Common/mysqlxx/mysqlxx/UseQueryResult.h @@ -30,7 +30,7 @@ public: Row fetch(); /// Для совместимости - Row fetch_row() { return fetch(); } + Row fetch_row() { return fetch(); } /// NOLINT }; } diff --git a/src/Common/mysqlxx/mysqlxx/Value.h b/src/Common/mysqlxx/mysqlxx/Value.h index 797a65a63f9..27845ac5c7d 100644 --- a/src/Common/mysqlxx/mysqlxx/Value.h +++ b/src/Common/mysqlxx/mysqlxx/Value.h @@ -115,7 +115,7 @@ public: } /// Для совместимости (используйте вместо этого метод isNull()) - bool is_null() const { return isNull(); } + bool is_null() const { return isNull(); } /// NOLINT /** Получить любой поддерживаемый тип (для шаблонного кода). * Поддерживаются основные типы, а также любые типы с конструктором от Value (для удобства расширения). @@ -123,7 +123,7 @@ public: template T get() const; /// Для совместимости. Не рекомендуется к использованию, так как неудобен (часто возникают неоднозначности). - template operator T() const { return get(); } + template operator T() const { return get(); } /// NOLINT const char * data() const { return m_data; } size_t length() const { return m_length; } @@ -166,7 +166,7 @@ private: else throwException("Cannot parse DateTime"); - return 0; /// avoid warning. + return 0; /// avoid warning. /// NOLINT } @@ -184,7 +184,7 @@ private: else throwException("Cannot parse Date"); - return 0; /// avoid warning. + return 0; /// avoid warning. /// NOLINT } @@ -240,14 +240,14 @@ template <> inline char Value::get() cons template <> inline signed char Value::get() const { return getInt(); } template <> inline unsigned char Value::get() const { return getUInt(); } template <> inline char8_t Value::get() const { return getUInt(); } -template <> inline short Value::get() const { return getInt(); } -template <> inline unsigned short Value::get() const { return getUInt(); } +template <> inline short Value::get() const { return getInt(); } /// NOLINT +template <> inline unsigned short Value::get() const { return getUInt(); } /// NOLINT template <> inline int Value::get() const { return getInt(); } template <> inline unsigned int Value::get() const { return getUInt(); } -template <> inline long Value::get() const { return getInt(); } -template <> inline unsigned long Value::get() const { return getUInt(); } -template <> inline long long Value::get() const { return getInt(); } -template <> inline unsigned long long Value::get() const { return getUInt(); } +template <> inline long Value::get() const { return getInt(); } /// NOLINT +template <> inline unsigned long Value::get() const { return getUInt(); } /// NOLINT +template <> inline long long Value::get() const { return getInt(); } /// NOLINT +template <> inline unsigned long long Value::get() const { return getUInt(); } /// NOLINT template <> inline float Value::get() const { return getDouble(); } template <> inline double Value::get() const { return getDouble(); } template <> inline std::string Value::get() const { return getString(); } diff --git a/src/Compression/CheckingCompressedReadBuffer.h b/src/Compression/CheckingCompressedReadBuffer.h index 7a1d1f7a600..fcb222eddc3 100644 --- a/src/Compression/CheckingCompressedReadBuffer.h +++ b/src/Compression/CheckingCompressedReadBuffer.h @@ -17,7 +17,7 @@ protected: bool nextImpl() override; public: - CheckingCompressedReadBuffer(ReadBuffer & in_, bool allow_different_codecs_ = false) + explicit CheckingCompressedReadBuffer(ReadBuffer & in_, bool allow_different_codecs_ = false) : CompressedReadBufferBase(&in_, allow_different_codecs_) , ReadBuffer(nullptr, 0) { diff --git a/src/Compression/CompressedReadBuffer.h b/src/Compression/CompressedReadBuffer.h index 3fa7347507c..4148f4fe4d4 100644 --- a/src/Compression/CompressedReadBuffer.h +++ b/src/Compression/CompressedReadBuffer.h @@ -16,7 +16,7 @@ private: bool nextImpl() override; public: - CompressedReadBuffer(ReadBuffer & in_, bool allow_different_codecs_ = false) + explicit CompressedReadBuffer(ReadBuffer & in_, bool allow_different_codecs_ = false) : CompressedReadBufferBase(&in_, allow_different_codecs_), BufferWithOwnMemory(0) { } diff --git a/src/Compression/CompressedWriteBuffer.h b/src/Compression/CompressedWriteBuffer.h index 16f0f5136d2..86c6762764b 100644 --- a/src/Compression/CompressedWriteBuffer.h +++ b/src/Compression/CompressedWriteBuffer.h @@ -16,7 +16,7 @@ namespace DB class CompressedWriteBuffer : public BufferWithOwnMemory { public: - CompressedWriteBuffer( + explicit CompressedWriteBuffer( WriteBuffer & out_, CompressionCodecPtr codec_ = CompressionCodecFactory::instance().getDefaultCodec(), size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE); diff --git a/src/Compression/CompressionFactory.cpp b/src/Compression/CompressionFactory.cpp index b665e898aa6..ca5e5176d13 100644 --- a/src/Compression/CompressionFactory.cpp +++ b/src/Compression/CompressionFactory.cpp @@ -98,7 +98,7 @@ CompressionCodecPtr CompressionCodecFactory::get( } -CompressionCodecPtr CompressionCodecFactory::get(const uint8_t byte_code) const +CompressionCodecPtr CompressionCodecFactory::get(uint8_t byte_code) const { const auto family_code_and_creator = family_code_with_codec.find(byte_code); diff --git a/src/Compression/CompressionFactory.h b/src/Compression/CompressionFactory.h index 2101dc28c65..a4451f9ed2e 100644 --- a/src/Compression/CompressionFactory.h +++ b/src/Compression/CompressionFactory.h @@ -63,7 +63,7 @@ public: } /// Get codec by method byte (no params available) - CompressionCodecPtr get(const uint8_t byte_code) const; + CompressionCodecPtr get(uint8_t byte_code) const; /// For backward compatibility with config settings CompressionCodecPtr get(const String & family_name, std::optional level) const; diff --git a/src/Compression/LZ4_decompress_faster.h b/src/Compression/LZ4_decompress_faster.h index c1b54cf20c9..c596ea6364b 100644 --- a/src/Compression/LZ4_decompress_faster.h +++ b/src/Compression/LZ4_decompress_faster.h @@ -130,8 +130,8 @@ struct PerformanceStatistics /** This method dispatch to one of different implementations depending on performance statistics. */ bool decompress( - const char * const source, - char * const dest, + const char * const source, /// NOLINT + char * const dest, /// NOLINT size_t source_size, size_t dest_size, PerformanceStatistics & statistics); @@ -156,8 +156,8 @@ struct StreamStatistics }; void statistics( - const char * const source, - char * const dest, + const char * const source, /// NOLINT + char * const dest, /// NOLINT size_t dest_size, StreamStatistics & stat); diff --git a/src/Coordination/Changelog.h b/src/Coordination/Changelog.h index fc34300c387..a8532f0ba1e 100644 --- a/src/Coordination/Changelog.h +++ b/src/Coordination/Changelog.h @@ -146,7 +146,6 @@ private: /// Clean useless log files in a background thread void cleanLogThread(); -private: const std::string changelogs_dir; const uint64_t rotate_interval; const bool force_sync; diff --git a/src/Coordination/Keeper4LWInfo.h b/src/Coordination/Keeper4LWInfo.h index 1c461582a8c..bf7267a68e2 100644 --- a/src/Coordination/Keeper4LWInfo.h +++ b/src/Coordination/Keeper4LWInfo.h @@ -2,6 +2,8 @@ #include +#include + namespace DB { diff --git a/src/Coordination/KeeperDispatcher.h b/src/Coordination/KeeperDispatcher.h index cc680f8d78f..5db1c4ddf36 100644 --- a/src/Coordination/KeeperDispatcher.h +++ b/src/Coordination/KeeperDispatcher.h @@ -77,7 +77,6 @@ private: /// Counter for new session_id requests. std::atomic internal_session_id_counter{0}; -private: /// Thread put requests to raft void requestThread(); /// Thread put responses for subscribed sessions diff --git a/src/Coordination/KeeperStateMachine.h b/src/Coordination/KeeperStateMachine.h index a6d116ca745..cd47c0dbded 100644 --- a/src/Coordination/KeeperStateMachine.h +++ b/src/Coordination/KeeperStateMachine.h @@ -30,10 +30,10 @@ public: /// Currently not supported nuraft::ptr pre_commit(const uint64_t /*log_idx*/, nuraft::buffer & /*data*/) override { return nullptr; } - nuraft::ptr commit(const uint64_t log_idx, nuraft::buffer & data) override; + nuraft::ptr commit(const uint64_t log_idx, nuraft::buffer & data) override; /// NOLINT /// Save new cluster config to our snapshot (copy of the config stored in StateManager) - void commit_config(const uint64_t log_idx, nuraft::ptr & new_conf) override; + void commit_config(const uint64_t log_idx, nuraft::ptr & new_conf) override; /// NOLINT /// Currently not supported void rollback(const uint64_t /*log_idx*/, nuraft::buffer & /*data*/) override {} diff --git a/src/Coordination/KeeperStateManager.h b/src/Coordination/KeeperStateManager.h index 66037d78a63..a56bafb6bae 100644 --- a/src/Coordination/KeeperStateManager.h +++ b/src/Coordination/KeeperStateManager.h @@ -71,9 +71,9 @@ public: int32_t server_id() override { return my_server_id; } - nuraft::ptr get_srv_config() const { return configuration_wrapper.config; } + nuraft::ptr get_srv_config() const { return configuration_wrapper.config; } /// NOLINT - void system_exit(const int exit_code) override; + void system_exit(const int exit_code) override; /// NOLINT int getPort() const { diff --git a/src/Coordination/KeeperStorage.h b/src/Coordination/KeeperStorage.h index cb218a0db15..89a42078bc9 100644 --- a/src/Coordination/KeeperStorage.h +++ b/src/Coordination/KeeperStorage.h @@ -93,7 +93,6 @@ public: using SessionAndAuth = std::unordered_map; using Watches = std::map; -public: int64_t session_id_counter{1}; SessionAndAuth session_and_auth; @@ -133,7 +132,6 @@ public: const String superdigest; -public: KeeperStorage(int64_t tick_time_ms, const String & superdigest_); /// Allocate new session id with the specified timeouts @@ -191,7 +189,7 @@ public: } /// Get all dead sessions - std::vector getDeadSessions() + std::vector getDeadSessions() const { return session_expiry_queue.getExpiredSessions(); } diff --git a/src/Coordination/SummingStateMachine.h b/src/Coordination/SummingStateMachine.h index bbb12834608..8e0dfdd7c61 100644 --- a/src/Coordination/SummingStateMachine.h +++ b/src/Coordination/SummingStateMachine.h @@ -17,9 +17,9 @@ public: nuraft::ptr pre_commit(const uint64_t /*log_idx*/, nuraft::buffer & /*data*/) override { return nullptr; } - nuraft::ptr commit(const uint64_t log_idx, nuraft::buffer & data) override; + nuraft::ptr commit(const uint64_t log_idx, nuraft::buffer & data) override; /// NOLINT - void rollback(const uint64_t /*log_idx*/, nuraft::buffer & /*data*/) override {} + void rollback(const uint64_t /*log_idx*/, nuraft::buffer & /*data*/) override {} /// NOLINT uint64_t last_commit_index() override { return last_committed_idx; } diff --git a/src/Core/BackgroundSchedulePool.h b/src/Core/BackgroundSchedulePool.h index 092824c069a..4886bab633a 100644 --- a/src/Core/BackgroundSchedulePool.h +++ b/src/Core/BackgroundSchedulePool.h @@ -161,7 +161,7 @@ public: task_info->deactivate(); } - operator bool() const { return task_info != nullptr; } + operator bool() const { return task_info != nullptr; } /// NOLINT BackgroundSchedulePoolTaskInfo * operator->() { return task_info.get(); } const BackgroundSchedulePoolTaskInfo * operator->() const { return task_info.get(); } diff --git a/src/Core/BaseSettings.h b/src/Core/BaseSettings.h index f6c63804059..a4ddc6571ed 100644 --- a/src/Core/BaseSettings.h +++ b/src/Core/BaseSettings.h @@ -38,12 +38,12 @@ enum class SettingsWriteFormat * mysettings.cpp: * IMPLEMENT_SETTINGS_TRAITS(MySettingsTraits, APPLY_FOR_MYSETTINGS) */ -template -class BaseSettings : public Traits_::Data +template +class BaseSettings : public TTraits::Data { using CustomSettingMap = std::unordered_map, SettingFieldCustom>>; public: - using Traits = Traits_; + using Traits = TTraits; void set(const std::string_view & name, const Field & value); Field get(const std::string_view & name) const; @@ -58,7 +58,7 @@ public: SettingsChanges changes() const; void applyChange(const SettingChange & change); void applyChanges(const SettingsChanges & changes); - void applyChanges(const BaseSettings & changes); + void applyChanges(const BaseSettings & changes); /// NOLINT /// Resets all the settings to their default values. void resetToDefault(); @@ -124,7 +124,7 @@ public: { public: Iterator & operator++(); - Iterator operator++(int); + Iterator operator++(int); /// NOLINT const SettingFieldRef & operator *() const { return field_ref; } bool operator ==(const Iterator & other) const; @@ -189,8 +189,8 @@ struct BaseSettingsHelpers static Flags readFlags(ReadBuffer & in); }; -template -void BaseSettings::set(const std::string_view & name, const Field & value) +template +void BaseSettings::set(const std::string_view & name, const Field & value) { const auto & accessor = Traits::Accessor::instance(); if (size_t index = accessor.find(name); index != static_cast(-1)) @@ -199,8 +199,8 @@ void BaseSettings::set(const std::string_view & name, const Field & val getCustomSetting(name) = value; } -template -Field BaseSettings::get(const std::string_view & name) const +template +Field BaseSettings::get(const std::string_view & name) const { const auto & accessor = Traits::Accessor::instance(); if (size_t index = accessor.find(name); index != static_cast(-1)) @@ -209,8 +209,8 @@ Field BaseSettings::get(const std::string_view & name) const return static_cast(getCustomSetting(name)); } -template -void BaseSettings::setString(const std::string_view & name, const String & value) +template +void BaseSettings::setString(const std::string_view & name, const String & value) { const auto & accessor = Traits::Accessor::instance(); if (size_t index = accessor.find(name); index != static_cast(-1)) @@ -219,8 +219,8 @@ void BaseSettings::setString(const std::string_view & name, const Strin getCustomSetting(name).parseFromString(value); } -template -String BaseSettings::getString(const std::string_view & name) const +template +String BaseSettings::getString(const std::string_view & name) const { const auto & accessor = Traits::Accessor::instance(); if (size_t index = accessor.find(name); index != static_cast(-1)) @@ -229,8 +229,8 @@ String BaseSettings::getString(const std::string_view & name) const return getCustomSetting(name).toString(); } -template -bool BaseSettings::tryGet(const std::string_view & name, Field & value) const +template +bool BaseSettings::tryGet(const std::string_view & name, Field & value) const { const auto & accessor = Traits::Accessor::instance(); if (size_t index = accessor.find(name); index != static_cast(-1)) @@ -246,8 +246,8 @@ bool BaseSettings::tryGet(const std::string_view & name, Field & value) return false; } -template -bool BaseSettings::tryGetString(const std::string_view & name, String & value) const +template +bool BaseSettings::tryGetString(const std::string_view & name, String & value) const { const auto & accessor = Traits::Accessor::instance(); if (size_t index = accessor.find(name); index != static_cast(-1)) @@ -263,8 +263,8 @@ bool BaseSettings::tryGetString(const std::string_view & name, String & return false; } -template -bool BaseSettings::isChanged(const std::string_view & name) const +template +bool BaseSettings::isChanged(const std::string_view & name) const { const auto & accessor = Traits::Accessor::instance(); if (size_t index = accessor.find(name); index != static_cast(-1)) @@ -272,8 +272,8 @@ bool BaseSettings::isChanged(const std::string_view & name) const return tryGetCustomSetting(name) != nullptr; } -template -SettingsChanges BaseSettings::changes() const +template +SettingsChanges BaseSettings::changes() const { SettingsChanges res; for (const auto & field : *this) @@ -281,28 +281,28 @@ SettingsChanges BaseSettings::changes() const return res; } -template -void BaseSettings::applyChange(const SettingChange & change) +template +void BaseSettings::applyChange(const SettingChange & change) { set(change.name, change.value); } -template -void BaseSettings::applyChanges(const SettingsChanges & changes) +template +void BaseSettings::applyChanges(const SettingsChanges & changes) { for (const auto & change : changes) applyChange(change); } -template -void BaseSettings::applyChanges(const BaseSettings & other_settings) +template +void BaseSettings::applyChanges(const BaseSettings & other_settings) { for (const auto & field : other_settings) set(field.getName(), field.getValue()); } -template -void BaseSettings::resetToDefault() +template +void BaseSettings::resetToDefault() { const auto & accessor = Traits::Accessor::instance(); for (size_t i : collections::range(accessor.size())) @@ -315,21 +315,21 @@ void BaseSettings::resetToDefault() custom_settings_map.clear(); } -template -bool BaseSettings::hasBuiltin(const std::string_view & name) +template +bool BaseSettings::hasBuiltin(const std::string_view & name) { const auto & accessor = Traits::Accessor::instance(); return (accessor.find(name) != static_cast(-1)); } -template -bool BaseSettings::hasCustom(const std::string_view & name) const +template +bool BaseSettings::hasCustom(const std::string_view & name) const { return tryGetCustomSetting(name); } -template -const char * BaseSettings::getTypeName(const std::string_view & name) const +template +const char * BaseSettings::getTypeName(const std::string_view & name) const { const auto & accessor = Traits::Accessor::instance(); if (size_t index = accessor.find(name); index != static_cast(-1)) @@ -340,8 +340,8 @@ const char * BaseSettings::getTypeName(const std::string_view & name) c BaseSettingsHelpers::throwSettingNotFound(name); } -template -const char * BaseSettings::getDescription(const std::string_view & name) const +template +const char * BaseSettings::getDescription(const std::string_view & name) const { const auto & accessor = Traits::Accessor::instance(); if (size_t index = accessor.find(name); index != static_cast(-1)) @@ -352,20 +352,20 @@ const char * BaseSettings::getDescription(const std::string_view & name BaseSettingsHelpers::throwSettingNotFound(name); } -template -void BaseSettings::checkCanSet(const std::string_view & name, const Field & value) +template +void BaseSettings::checkCanSet(const std::string_view & name, const Field & value) { castValueUtil(name, value); } -template -void BaseSettings::checkCanSetString(const std::string_view & name, const String & str) +template +void BaseSettings::checkCanSetString(const std::string_view & name, const String & str) { stringToValueUtil(name, str); } -template -Field BaseSettings::castValueUtil(const std::string_view & name, const Field & value) +template +Field BaseSettings::castValueUtil(const std::string_view & name, const Field & value) { const auto & accessor = Traits::Accessor::instance(); if (size_t index = accessor.find(name); index != static_cast(-1)) @@ -376,8 +376,8 @@ Field BaseSettings::castValueUtil(const std::string_view & name, const BaseSettingsHelpers::throwSettingNotFound(name); } -template -String BaseSettings::valueToStringUtil(const std::string_view & name, const Field & value) +template +String BaseSettings::valueToStringUtil(const std::string_view & name, const Field & value) { const auto & accessor = Traits::Accessor::instance(); if (size_t index = accessor.find(name); index != static_cast(-1)) @@ -388,8 +388,8 @@ String BaseSettings::valueToStringUtil(const std::string_view & name, c BaseSettingsHelpers::throwSettingNotFound(name); } -template -Field BaseSettings::stringToValueUtil(const std::string_view & name, const String & str) +template +Field BaseSettings::stringToValueUtil(const std::string_view & name, const String & str) { try { @@ -408,8 +408,8 @@ Field BaseSettings::stringToValueUtil(const std::string_view & name, co } } -template -void BaseSettings::write(WriteBuffer & out, SettingsWriteFormat format) const +template +void BaseSettings::write(WriteBuffer & out, SettingsWriteFormat format) const { const auto & accessor = Traits::Accessor::instance(); @@ -440,8 +440,8 @@ void BaseSettings::write(WriteBuffer & out, SettingsWriteFormat format) BaseSettingsHelpers::writeString(std::string_view{}, out); } -template -void BaseSettings::read(ReadBuffer & in, SettingsWriteFormat format) +template +void BaseSettings::read(ReadBuffer & in, SettingsWriteFormat format) { resetToDefault(); const auto & accessor = Traits::Accessor::instance(); @@ -488,8 +488,8 @@ void BaseSettings::read(ReadBuffer & in, SettingsWriteFormat format) } } -template -String BaseSettings::toString() const +template +String BaseSettings::toString() const { String res; for (const auto & field : *this) @@ -501,8 +501,8 @@ String BaseSettings::toString() const return res; } -template -bool operator==(const BaseSettings & left, const BaseSettings & right) +template +bool operator==(const BaseSettings & left, const BaseSettings & right) { auto l = left.begin(); for (const auto & r : right) @@ -514,14 +514,14 @@ bool operator==(const BaseSettings & left, const BaseSettings return l == left.end(); } -template -bool operator!=(const BaseSettings & left, const BaseSettings & right) +template +bool operator!=(const BaseSettings & left, const BaseSettings & right) { return !(left == right); } -template -SettingFieldCustom & BaseSettings::getCustomSetting(const std::string_view & name) +template +SettingFieldCustom & BaseSettings::getCustomSetting(const std::string_view & name) { if constexpr (Traits::allow_custom_settings) { @@ -536,8 +536,8 @@ SettingFieldCustom & BaseSettings::getCustomSetting(const std::string_v BaseSettingsHelpers::throwSettingNotFound(name); } -template -const SettingFieldCustom & BaseSettings::getCustomSetting(const std::string_view & name) const +template +const SettingFieldCustom & BaseSettings::getCustomSetting(const std::string_view & name) const { if constexpr (Traits::allow_custom_settings) { @@ -548,8 +548,8 @@ const SettingFieldCustom & BaseSettings::getCustomSetting(const std::st BaseSettingsHelpers::throwSettingNotFound(name); } -template -const SettingFieldCustom * BaseSettings::tryGetCustomSetting(const std::string_view & name) const +template +const SettingFieldCustom * BaseSettings::tryGetCustomSetting(const std::string_view & name) const { if constexpr (Traits::allow_custom_settings) { @@ -560,8 +560,8 @@ const SettingFieldCustom * BaseSettings::tryGetCustomSetting(const std: return nullptr; } -template -BaseSettings::Iterator::Iterator(const BaseSettings & settings_, const typename Traits::Accessor & accessor_, SkipFlags skip_flags_) +template +BaseSettings::Iterator::Iterator(const BaseSettings & settings_, const typename Traits::Accessor & accessor_, SkipFlags skip_flags_) : skip_flags(skip_flags_) { field_ref.settings = &settings_; @@ -603,8 +603,8 @@ BaseSettings::Iterator::Iterator(const BaseSettings & settings_, const setPointerToCustomSetting(); } -template -typename BaseSettings::Iterator & BaseSettings::Iterator::operator++() +template +typename BaseSettings::Iterator & BaseSettings::Iterator::operator++() { const auto & accessor = *field_ref.accessor; auto & index = field_ref.index; @@ -620,16 +620,16 @@ typename BaseSettings::Iterator & BaseSettings::Iterator::oper return *this; } -template -typename BaseSettings::Iterator BaseSettings::Iterator::operator++(int) +template +typename BaseSettings::Iterator BaseSettings::Iterator::operator++(int) /// NOLINT { auto res = *this; ++*this; return res; } -template -void BaseSettings::Iterator::doSkip() +template +void BaseSettings::Iterator::doSkip() { const auto & accessor = *field_ref.accessor; const auto & settings = *field_ref.settings; @@ -646,8 +646,8 @@ void BaseSettings::Iterator::doSkip() } } -template -void BaseSettings::Iterator::setPointerToCustomSetting() +template +void BaseSettings::Iterator::setPointerToCustomSetting() { if constexpr (Traits::allow_custom_settings) { @@ -661,10 +661,10 @@ void BaseSettings::Iterator::setPointerToCustomSetting() } } -template -bool BaseSettings::Iterator::operator ==(const typename BaseSettings::Iterator & other) const +template +bool BaseSettings::Iterator::operator ==(const typename BaseSettings::Iterator & other) const { - if constexpr (Traits_::allow_custom_settings) + if constexpr (TTraits::allow_custom_settings) { if (custom_settings_iterator != other.custom_settings_iterator) return false; @@ -672,8 +672,8 @@ bool BaseSettings::Iterator::operator ==(const typename BaseSettings -const String & BaseSettings::SettingFieldRef::getName() const +template +const String & BaseSettings::SettingFieldRef::getName() const { if constexpr (Traits::allow_custom_settings) { @@ -683,8 +683,8 @@ const String & BaseSettings::SettingFieldRef::getName() const return accessor->getName(index); } -template -Field BaseSettings::SettingFieldRef::getValue() const +template +Field BaseSettings::SettingFieldRef::getValue() const { if constexpr (Traits::allow_custom_settings) { @@ -694,8 +694,8 @@ Field BaseSettings::SettingFieldRef::getValue() const return accessor->getValue(*settings, index); } -template -String BaseSettings::SettingFieldRef::getValueString() const +template +String BaseSettings::SettingFieldRef::getValueString() const { if constexpr (Traits::allow_custom_settings) { @@ -705,8 +705,8 @@ String BaseSettings::SettingFieldRef::getValueString() const return accessor->getValueString(*settings, index); } -template -bool BaseSettings::SettingFieldRef::isValueChanged() const +template +bool BaseSettings::SettingFieldRef::isValueChanged() const { if constexpr (Traits::allow_custom_settings) { @@ -716,8 +716,8 @@ bool BaseSettings::SettingFieldRef::isValueChanged() const return accessor->isValueChanged(*settings, index); } -template -const char * BaseSettings::SettingFieldRef::getTypeName() const +template +const char * BaseSettings::SettingFieldRef::getTypeName() const { if constexpr (Traits::allow_custom_settings) { @@ -727,8 +727,8 @@ const char * BaseSettings::SettingFieldRef::getTypeName() const return accessor->getTypeName(index); } -template -const char * BaseSettings::SettingFieldRef::getDescription() const +template +const char * BaseSettings::SettingFieldRef::getDescription() const { if constexpr (Traits::allow_custom_settings) { @@ -738,8 +738,8 @@ const char * BaseSettings::SettingFieldRef::getDescription() const return accessor->getDescription(index); } -template -bool BaseSettings::SettingFieldRef::isCustom() const +template +bool BaseSettings::SettingFieldRef::isCustom() const { if constexpr (Traits::allow_custom_settings) return custom_setting != nullptr; @@ -747,8 +747,8 @@ bool BaseSettings::SettingFieldRef::isCustom() const return false; } -template -bool BaseSettings::SettingFieldRef::isObsolete() const +template +bool BaseSettings::SettingFieldRef::isObsolete() const { if constexpr (Traits::allow_custom_settings) { @@ -758,12 +758,15 @@ bool BaseSettings::SettingFieldRef::isObsolete() const return accessor->isObsolete(index); } +/// NOLINTNEXTLINE #define DECLARE_SETTINGS_TRAITS(SETTINGS_TRAITS_NAME, LIST_OF_SETTINGS_MACRO) \ DECLARE_SETTINGS_TRAITS_COMMON(SETTINGS_TRAITS_NAME, LIST_OF_SETTINGS_MACRO, 0) +/// NOLINTNEXTLINE #define DECLARE_SETTINGS_TRAITS_ALLOW_CUSTOM_SETTINGS(SETTINGS_TRAITS_NAME, LIST_OF_SETTINGS_MACRO) \ DECLARE_SETTINGS_TRAITS_COMMON(SETTINGS_TRAITS_NAME, LIST_OF_SETTINGS_MACRO, 1) +/// NOLINTNEXTLINE #define DECLARE_SETTINGS_TRAITS_COMMON(SETTINGS_TRAITS_NAME, LIST_OF_SETTINGS_MACRO, ALLOW_CUSTOM_SETTINGS) \ struct SETTINGS_TRAITS_NAME \ { \ @@ -822,9 +825,11 @@ bool BaseSettings::SettingFieldRef::isObsolete() const static constexpr bool allow_custom_settings = ALLOW_CUSTOM_SETTINGS; \ }; +/// NOLINTNEXTLINE #define DECLARE_SETTINGS_TRAITS_(TYPE, NAME, DEFAULT, DESCRIPTION, FLAGS) \ SettingField##TYPE NAME {DEFAULT}; +/// NOLINTNEXTLINE #define IMPLEMENT_SETTINGS_TRAITS(SETTINGS_TRAITS_NAME, LIST_OF_SETTINGS_MACRO) \ const SETTINGS_TRAITS_NAME::Accessor & SETTINGS_TRAITS_NAME::Accessor::instance() \ { \ @@ -857,10 +862,11 @@ bool BaseSettings::SettingFieldRef::isObsolete() const template class BaseSettings; //-V:IMPLEMENT_SETTINGS:501 +/// NOLINTNEXTLINE #define IMPLEMENT_SETTINGS_TRAITS_(TYPE, NAME, DEFAULT, DESCRIPTION, FLAGS) \ res.field_infos.emplace_back( \ - FieldInfo{#NAME, #TYPE, DESCRIPTION, FLAGS & IMPORTANT, \ - static_cast(FLAGS & BaseSettingsHelpers::Flags::OBSOLETE), \ + FieldInfo{#NAME, #TYPE, DESCRIPTION, (FLAGS) & IMPORTANT, \ + static_cast((FLAGS) & BaseSettingsHelpers::Flags::OBSOLETE), \ [](const Field & value) -> Field { return static_cast(SettingField##TYPE{value}); }, \ [](const Field & value) -> String { return SettingField##TYPE{value}.toString(); }, \ [](const String & str) -> Field { SettingField##TYPE temp; temp.parseFromString(str); return static_cast(temp); }, \ diff --git a/src/Core/Block.h b/src/Core/Block.h index 2a1e6113b73..d7b02f44f13 100644 --- a/src/Core/Block.h +++ b/src/Core/Block.h @@ -36,8 +36,8 @@ public: Block() = default; Block(std::initializer_list il); - Block(const ColumnsWithTypeAndName & data_); - Block(ColumnsWithTypeAndName && data_); + Block(const ColumnsWithTypeAndName & data_); /// NOLINT + Block(ColumnsWithTypeAndName && data_); /// NOLINT /// insert the column at the specified position void insert(size_t position, ColumnWithTypeAndName elem); @@ -107,8 +107,8 @@ public: /// Approximate number of allocated bytes in memory - for profiling and limits. size_t allocatedBytes() const; - operator bool() const { return !!columns(); } - bool operator!() const { return !this->operator bool(); } + operator bool() const { return !!columns(); } /// NOLINT + bool operator!() const { return !this->operator bool(); } /// NOLINT /** Get a list of column names separated by commas. */ std::string dumpNames() const; diff --git a/src/Core/ColumnWithTypeAndName.h b/src/Core/ColumnWithTypeAndName.h index 2ecc2df9b5a..592ad39d55a 100644 --- a/src/Core/ColumnWithTypeAndName.h +++ b/src/Core/ColumnWithTypeAndName.h @@ -22,7 +22,7 @@ struct ColumnWithTypeAndName DataTypePtr type; String name; - ColumnWithTypeAndName() {} + ColumnWithTypeAndName() = default; ColumnWithTypeAndName(const ColumnPtr & column_, const DataTypePtr & type_, const String & name_) : column(column_), type(type_), name(name_) {} diff --git a/src/Core/DecimalFunctions.h b/src/Core/DecimalFunctions.h index 59d88785f1b..f08527ee4d5 100644 --- a/src/Core/DecimalFunctions.h +++ b/src/Core/DecimalFunctions.h @@ -303,13 +303,13 @@ inline auto binaryOpResult(const DecimalType & tx, const DecimalType & ty) } template typename DecimalType> -inline const DataTypeDecimalTrait binaryOpResult(const DecimalType & tx, const DataTypeNumber &) +inline DataTypeDecimalTrait binaryOpResult(const DecimalType & tx, const DataTypeNumber &) { return DataTypeDecimalTrait(DecimalUtils::max_precision, tx.getScale()); } template typename DecimalType> -inline const DataTypeDecimalTrait binaryOpResult(const DataTypeNumber &, const DecimalType & ty) +inline DataTypeDecimalTrait binaryOpResult(const DataTypeNumber &, const DecimalType & ty) { return DataTypeDecimalTrait(DecimalUtils::max_precision, ty.getScale()); } diff --git a/src/Core/Field.h b/src/Core/Field.h index b525e3a83ab..9b830771c5f 100644 --- a/src/Core/Field.h +++ b/src/Core/Field.h @@ -100,12 +100,12 @@ template class DecimalField { public: - DecimalField(T value = {}, UInt32 scale_ = 0) + explicit DecimalField(T value = {}, UInt32 scale_ = 0) : dec(value), scale(scale_) {} - operator T() const { return dec; } + operator T() const { return dec; } /// NOLINT T getValue() const { return dec; } T getScaleMultiplier() const { return DecimalUtils::scaleMultiplier(scale); } UInt32 getScale() const { return scale; } @@ -191,10 +191,10 @@ template <> struct NearestFieldTypeImpl { using Type = Int64; }; /// long and long long are always different types that may behave identically or not. /// This is different on Linux and Mac. -template <> struct NearestFieldTypeImpl { using Type = Int64; }; -template <> struct NearestFieldTypeImpl { using Type = Int64; }; -template <> struct NearestFieldTypeImpl { using Type = UInt64; }; -template <> struct NearestFieldTypeImpl { using Type = UInt64; }; +template <> struct NearestFieldTypeImpl { using Type = Int64; }; /// NOLINT +template <> struct NearestFieldTypeImpl { using Type = Int64; }; /// NOLINT +template <> struct NearestFieldTypeImpl { using Type = UInt64; }; /// NOLINT +template <> struct NearestFieldTypeImpl { using Type = UInt64; }; /// NOLINT template <> struct NearestFieldTypeImpl { using Type = UInt256; }; template <> struct NearestFieldTypeImpl { using Type = Int256; }; @@ -291,7 +291,7 @@ public: template struct TypeToEnum; template struct EnumToType; - static bool IsDecimal(Types::Which which) + static bool isDecimal(Types::Which which) { return which == Types::Decimal32 || which == Types::Decimal64 @@ -316,24 +316,24 @@ public: create(rhs); } - Field(Field && rhs) + Field(Field && rhs) noexcept { create(std::move(rhs)); } template - Field(T && rhs, enable_if_not_field_or_bool_or_stringlike_t = nullptr); + Field(T && rhs, enable_if_not_field_or_bool_or_stringlike_t = nullptr); /// NOLINT - Field(bool rhs) : Field(castToNearestFieldType(rhs)) + Field(bool rhs) : Field(castToNearestFieldType(rhs)) /// NOLINT { which = Types::Bool; } /// Create a string inplace. - Field(const std::string_view & str) { create(str.data(), str.size()); } - Field(const String & str) { create(std::string_view{str}); } - Field(String && str) { create(std::move(str)); } - Field(const char * str) { create(std::string_view{str}); } + Field(const std::string_view & str) { create(str.data(), str.size()); } /// NOLINT + Field(const String & str) { create(std::string_view{str}); } /// NOLINT + Field(String && str) { create(std::move(str)); } /// NOLINT + Field(const char * str) { create(std::string_view{str}); } /// NOLINT template Field(const CharT * data, size_t size) @@ -356,7 +356,7 @@ public: return *this; } - Field & operator= (Field && rhs) + Field & operator= (Field && rhs) noexcept { if (this != &rhs) { @@ -377,7 +377,7 @@ public: /// 1. float <--> int needs explicit cast /// 2. customized types needs explicit cast template - enable_if_not_field_or_bool_or_stringlike_t & + enable_if_not_field_or_bool_or_stringlike_t & /// NOLINT operator=(T && rhs); Field & operator= (bool rhs) @@ -409,7 +409,7 @@ public: template const auto & get() const { - auto mutable_this = const_cast *>(this); + auto * mutable_this = const_cast *>(this); return mutable_this->get(); } @@ -422,7 +422,7 @@ public: template const T & reinterpret() const { - auto mutable_this = const_cast *>(this); + auto * mutable_this = const_cast *>(this); return mutable_this->reinterpret(); } @@ -887,7 +887,7 @@ Field::Field(T && rhs, enable_if_not_field_or_bool_or_stringlike_t) //-V730 } template -Field::enable_if_not_field_or_bool_or_stringlike_t & +Field::enable_if_not_field_or_bool_or_stringlike_t & /// NOLINT Field::operator=(T && rhs) { auto && val = castToNearestFieldType(std::forward(rhs)); @@ -986,10 +986,10 @@ String toString(const Field & x); template <> struct fmt::formatter { - constexpr auto parse(format_parse_context & ctx) + static constexpr auto parse(format_parse_context & ctx) { - auto it = ctx.begin(); - auto end = ctx.end(); + const auto * it = ctx.begin(); + const auto * end = ctx.end(); /// Only support {}. if (it != end && *it != '}') diff --git a/src/Core/MySQL/MySQLGtid.cpp b/src/Core/MySQL/MySQLGtid.cpp index bfd0bd02b45..43fa90b6160 100644 --- a/src/Core/MySQL/MySQLGtid.cpp +++ b/src/Core/MySQL/MySQLGtid.cpp @@ -21,7 +21,7 @@ void GTIDSet::tryMerge(size_t i) intervals.erase(intervals.begin() + i + 1, intervals.begin() + i + 1 + 1); } -void GTIDSets::parse(const String gtid_format) +void GTIDSets::parse(String gtid_format) { if (gtid_format.empty()) { diff --git a/src/Core/MySQL/MySQLGtid.h b/src/Core/MySQL/MySQLGtid.h index c8a571d2569..45eeaf02fa2 100644 --- a/src/Core/MySQL/MySQLGtid.h +++ b/src/Core/MySQL/MySQLGtid.h @@ -35,7 +35,7 @@ class GTIDSets public: std::vector sets; - void parse(const String gtid_format_); + void parse(String gtid_format_); void update(const GTID & other); String toString() const; diff --git a/src/Core/PostgreSQLProtocol.h b/src/Core/PostgreSQLProtocol.h index dd26bf41b4a..6ccdcb4d524 100644 --- a/src/Core/PostgreSQLProtocol.h +++ b/src/Core/PostgreSQLProtocol.h @@ -152,7 +152,7 @@ private: WriteBuffer * out; public: - MessageTransport(WriteBuffer * out_) : in(nullptr), out(out_) {} + explicit MessageTransport(WriteBuffer * out_) : in(nullptr), out(out_) {} MessageTransport(ReadBuffer * in_, WriteBuffer * out_): in(in_), out(out_) {} @@ -257,7 +257,7 @@ public: Int32 payload_size; FirstMessage() = delete; - FirstMessage(int payload_size_) : payload_size(payload_size_) {} + explicit FirstMessage(int payload_size_) : payload_size(payload_size_) {} }; class CancelRequest : public FirstMessage @@ -266,7 +266,7 @@ public: Int32 process_id = 0; Int32 secret_key = 0; - CancelRequest(int payload_size_) : FirstMessage(payload_size_) {} + explicit CancelRequest(int payload_size_) : FirstMessage(payload_size_) {} void deserialize(ReadBuffer & in) override { @@ -391,7 +391,7 @@ public: // includes username, may also include database and other runtime parameters std::unordered_map parameters; - StartupMessage(Int32 payload_size_) : FirstMessage(payload_size_) {} + explicit StartupMessage(Int32 payload_size_) : FirstMessage(payload_size_) {} void deserialize(ReadBuffer & in) override { @@ -643,7 +643,7 @@ private: const std::vector & fields_descr; public: - RowDescription(const std::vector & fields_descr_) : fields_descr(fields_descr_) {} + explicit RowDescription(const std::vector & fields_descr_) : fields_descr(fields_descr_) {} void serialize(WriteBuffer & out) const override { @@ -673,7 +673,7 @@ class StringField : public ISerializable private: String str; public: - StringField(String str_) : str(str_) {} + explicit StringField(String str_) : str(str_) {} void serialize(WriteBuffer & out) const override { @@ -703,7 +703,7 @@ private: const std::vector> & row; public: - DataRow(const std::vector> & row_) : row(row_) {} + explicit DataRow(const std::vector> & row_) : row(row_) {} void serialize(WriteBuffer & out) const override { @@ -886,7 +886,7 @@ private: std::unordered_map> type_to_method = {}; public: - AuthenticationManager(const std::vector> & auth_methods) + explicit AuthenticationManager(const std::vector> & auth_methods) { for (const std::shared_ptr & method : auth_methods) { diff --git a/src/Core/QualifiedTableName.h b/src/Core/QualifiedTableName.h index 4642465f461..3310130629d 100644 --- a/src/Core/QualifiedTableName.h +++ b/src/Core/QualifiedTableName.h @@ -72,7 +72,7 @@ struct QualifiedTableName QualifiedTableName name; if (pos == std::string::npos) { - name.table = std::move(maybe_qualified_name); + name.table = maybe_qualified_name; } else if (maybe_qualified_name.find('.', pos + 1) != std::string::npos) { @@ -119,7 +119,7 @@ namespace fmt template <> struct formatter { - constexpr auto parse(format_parse_context & ctx) + static constexpr auto parse(format_parse_context & ctx) { return ctx.begin(); } diff --git a/src/Core/SettingsFields.h b/src/Core/SettingsFields.h index b27763ad0d6..474786eb963 100644 --- a/src/Core/SettingsFields.h +++ b/src/Core/SettingsFields.h @@ -43,7 +43,7 @@ struct SettingFieldNumber SettingFieldNumber & operator=(Type x) { value = x; changed = true; return *this; } SettingFieldNumber & operator=(const Field & f); - operator Type() const { return value; } + operator Type() const { return value; } /// NOLINT explicit operator Field() const { return value; } String toString() const; @@ -75,7 +75,7 @@ struct SettingFieldMaxThreads SettingFieldMaxThreads & operator=(UInt64 x) { is_auto = !x; value = is_auto ? getAuto() : x; changed = true; return *this; } SettingFieldMaxThreads & operator=(const Field & f); - operator UInt64() const { return value; } + operator UInt64() const { return value; } /// NOLINT explicit operator Field() const { return value; } /// Writes "auto()" instead of simple "" if `is_auto==true`. @@ -118,10 +118,10 @@ struct SettingFieldTimespan SettingFieldTimespan & operator =(UInt64 x) { *this = Poco::Timespan{static_cast(x * microseconds_per_unit)}; return *this; } SettingFieldTimespan & operator =(const Field & f); - operator Poco::Timespan() const { return value; } + operator Poco::Timespan() const { return value; } /// NOLINT template > - operator std::chrono::duration() const { return std::chrono::duration_cast>(std::chrono::microseconds(value.totalMicroseconds())); } + operator std::chrono::duration() const { return std::chrono::duration_cast>(std::chrono::microseconds(value.totalMicroseconds())); } /// NOLINT explicit operator UInt64() const { return value.totalMicroseconds() / microseconds_per_unit; } explicit operator Field() const { return operator UInt64(); } @@ -158,7 +158,7 @@ struct SettingFieldString SettingFieldString & operator =(const char * str) { *this = std::string_view{str}; return *this; } SettingFieldString & operator =(const Field & f) { *this = f.safeGet(); return *this; } - operator const String &() const { return value; } + operator const String &() const { return value; } /// NOLINT explicit operator Field() const { return value; } const String & toString() const { return value; } @@ -181,7 +181,7 @@ public: SettingFieldChar & operator =(char c) { value = c; changed = true; return *this; } SettingFieldChar & operator =(const Field & f); - operator char() const { return value; } + operator char() const { return value; } /// NOLINT explicit operator Field() const { return toString(); } String toString() const { return String(&value, 1); } @@ -207,7 +207,7 @@ struct SettingFieldURI SettingFieldURI & operator =(const char * str) { *this = Poco::URI{str}; return *this; } SettingFieldURI & operator =(const Field & f) { *this = f.safeGet(); return *this; } - operator const Poco::URI &() const { return value; } + operator const Poco::URI &() const { return value; } /// NOLINT explicit operator String() const { return toString(); } explicit operator Field() const { return toString(); } @@ -244,7 +244,7 @@ struct SettingFieldEnum SettingFieldEnum & operator =(EnumType x) { value = x; changed = true; return *this; } SettingFieldEnum & operator =(const Field & f) { *this = Traits::fromString(f.safeGet()); return *this; } - operator EnumType() const { return value; } + operator EnumType() const { return value; } /// NOLINT explicit operator Field() const { return toString(); } String toString() const { return Traits::toString(value); } @@ -272,12 +272,15 @@ void SettingFieldEnum::readBinary(ReadBuffer & in) *this = Traits::fromString(SettingFieldEnumHelpers::readBinary(in)); } +/// NOLINTNEXTLINE #define DECLARE_SETTING_ENUM(ENUM_TYPE) \ DECLARE_SETTING_ENUM_WITH_RENAME(ENUM_TYPE, ENUM_TYPE) +/// NOLINTNEXTLINE #define IMPLEMENT_SETTING_ENUM(ENUM_TYPE, ERROR_CODE_FOR_UNEXPECTED_NAME, ...) \ IMPLEMENT_SETTING_ENUM_WITH_RENAME(ENUM_TYPE, ERROR_CODE_FOR_UNEXPECTED_NAME, __VA_ARGS__) +/// NOLINTNEXTLINE #define DECLARE_SETTING_ENUM_WITH_RENAME(NEW_NAME, ENUM_TYPE) \ struct SettingField##NEW_NAME##Traits \ { \ @@ -288,6 +291,7 @@ void SettingFieldEnum::readBinary(ReadBuffer & in) \ using SettingField##NEW_NAME = SettingFieldEnum; +/// NOLINTNEXTLINE #define IMPLEMENT_SETTING_ENUM_WITH_RENAME(NEW_NAME, ERROR_CODE_FOR_UNEXPECTED_NAME, ...) \ const String & SettingField##NEW_NAME##Traits::toString(typename SettingField##NEW_NAME::EnumType value) \ { \ @@ -346,7 +350,7 @@ struct SettingFieldMultiEnum explicit SettingFieldMultiEnum(StorageType s) : value(s) {} explicit SettingFieldMultiEnum(const Field & f) : value(parseValueFromString(f.safeGet())) {} - operator ValueType() const { return value; } + operator ValueType() const { return value; } /// NOLINT explicit operator StorageType() const { return value.getValue(); } explicit operator Field() const { return toString(); } @@ -368,7 +372,7 @@ struct SettingFieldMultiEnum } } - if (result.size() > 0) + if (!result.empty()) result.erase(result.size() - separator.size()); return result; @@ -415,9 +419,11 @@ void SettingFieldMultiEnum::readBinary(ReadBuffer & in) parseFromString(SettingFieldEnumHelpers::readBinary(in)); } +/// NOLINTNEXTLINE #define DECLARE_SETTING_MULTI_ENUM(ENUM_TYPE) \ DECLARE_SETTING_MULTI_ENUM_WITH_RENAME(ENUM_TYPE, ENUM_TYPE) +/// NOLINTNEXTLINE #define DECLARE_SETTING_MULTI_ENUM_WITH_RENAME(ENUM_TYPE, NEW_NAME) \ struct SettingField##NEW_NAME##Traits \ { \ @@ -429,9 +435,11 @@ void SettingFieldMultiEnum::readBinary(ReadBuffer & in) \ using SettingField##NEW_NAME = SettingFieldMultiEnum; +/// NOLINTNEXTLINE #define IMPLEMENT_SETTING_MULTI_ENUM(ENUM_TYPE, ERROR_CODE_FOR_UNEXPECTED_NAME, ...) \ IMPLEMENT_SETTING_MULTI_ENUM_WITH_RENAME(ENUM_TYPE, ERROR_CODE_FOR_UNEXPECTED_NAME, __VA_ARGS__) +/// NOLINTNEXTLINE #define IMPLEMENT_SETTING_MULTI_ENUM_WITH_RENAME(NEW_NAME, ERROR_CODE_FOR_UNEXPECTED_NAME, ...) \ IMPLEMENT_SETTING_ENUM_WITH_RENAME(NEW_NAME, ERROR_CODE_FOR_UNEXPECTED_NAME, __VA_ARGS__)\ size_t SettingField##NEW_NAME##Traits::getEnumSize() {\ diff --git a/src/Core/SortCursor.h b/src/Core/SortCursor.h index dd804bd4675..a5daba9fbee 100644 --- a/src/Core/SortCursor.h +++ b/src/Core/SortCursor.h @@ -53,7 +53,7 @@ struct SortCursorImpl */ IColumn::Permutation * permutation = nullptr; - SortCursorImpl() {} + SortCursorImpl() = default; SortCursorImpl(const Block & block, const SortDescription & desc_, size_t order_ = 0, IColumn::Permutation * perm = nullptr) : desc(desc_), sort_columns_size(desc.size()), order(order_), need_collation(desc.size()) @@ -140,7 +140,7 @@ struct SortCursorHelper const Derived & derived() const { return static_cast(*this); } - SortCursorHelper(SortCursorImpl * impl_) : impl(impl_) {} + explicit SortCursorHelper(SortCursorImpl * impl_) : impl(impl_) {} SortCursorImpl * operator-> () { return impl; } const SortCursorImpl * operator-> () const { return impl; } @@ -245,7 +245,7 @@ public: SortingHeap() = default; template - SortingHeap(Cursors & cursors) + explicit SortingHeap(Cursors & cursors) { size_t size = cursors.size(); queue.reserve(size); diff --git a/src/DataTypes/DataTypeArray.h b/src/DataTypes/DataTypeArray.h index 564dbba8503..122ac8e03a3 100644 --- a/src/DataTypes/DataTypeArray.h +++ b/src/DataTypes/DataTypeArray.h @@ -17,7 +17,7 @@ private: public: static constexpr bool is_parametric = true; - DataTypeArray(const DataTypePtr & nested_); + explicit DataTypeArray(const DataTypePtr & nested_); TypeIndex getTypeId() const override { return TypeIndex::Array; } diff --git a/src/DataTypes/DataTypeCustom.h b/src/DataTypes/DataTypeCustom.h index 55796e3cc7a..e8e4160af07 100644 --- a/src/DataTypes/DataTypeCustom.h +++ b/src/DataTypes/DataTypeCustom.h @@ -19,7 +19,7 @@ class IColumn; class IDataTypeCustomName { public: - virtual ~IDataTypeCustomName() {} + virtual ~IDataTypeCustomName() = default; virtual String getName() const = 0; }; @@ -33,7 +33,7 @@ struct DataTypeCustomDesc DataTypeCustomNamePtr name; SerializationPtr serialization; - DataTypeCustomDesc( + explicit DataTypeCustomDesc( DataTypeCustomNamePtr name_, SerializationPtr serialization_ = nullptr) : name(std::move(name_)) @@ -49,7 +49,7 @@ class DataTypeCustomFixedName : public IDataTypeCustomName private: String name; public: - DataTypeCustomFixedName(String name_) : name(name_) {} + explicit DataTypeCustomFixedName(String name_) : name(name_) {} String getName() const override { return name; } }; diff --git a/src/DataTypes/DataTypeCustomSimpleAggregateFunction.h b/src/DataTypes/DataTypeCustomSimpleAggregateFunction.h index dc054144e14..926dfd9cc82 100644 --- a/src/DataTypes/DataTypeCustomSimpleAggregateFunction.h +++ b/src/DataTypes/DataTypeCustomSimpleAggregateFunction.h @@ -34,7 +34,7 @@ public: DataTypeCustomSimpleAggregateFunction(const AggregateFunctionPtr & function_, const DataTypes & argument_types_, const Array & parameters_) : function(function_), argument_types(argument_types_), parameters(parameters_) {} - const AggregateFunctionPtr getFunction() const { return function; } + AggregateFunctionPtr getFunction() const { return function; } String getName() const override; static void checkSupportedFunctions(const AggregateFunctionPtr & function); }; diff --git a/src/DataTypes/DataTypeDecimalBase.h b/src/DataTypes/DataTypeDecimalBase.h index bdb39978825..9e37de8a35b 100644 --- a/src/DataTypes/DataTypeDecimalBase.h +++ b/src/DataTypes/DataTypeDecimalBase.h @@ -172,14 +172,14 @@ inline auto decimalResultType(const DecimalType & tx, const DecimalType & } template typename DecimalType> -inline const DecimalType decimalResultType(const DecimalType & tx, const DataTypeNumber & ty) +inline DecimalType decimalResultType(const DecimalType & tx, const DataTypeNumber & ty) { const auto result_trait = DecimalUtils::binaryOpResult(tx, ty); return DecimalType(result_trait.precision, result_trait.scale); } template typename DecimalType> -inline const DecimalType decimalResultType(const DataTypeNumber & tx, const DecimalType & ty) +inline DecimalType decimalResultType(const DataTypeNumber & tx, const DecimalType & ty) { const auto result_trait = DecimalUtils::binaryOpResult(tx, ty); return DecimalType(result_trait.precision, result_trait.scale); diff --git a/src/DataTypes/DataTypeFactory.h b/src/DataTypes/DataTypeFactory.h index 81d7d991bdc..e7b638b6d7b 100644 --- a/src/DataTypes/DataTypeFactory.h +++ b/src/DataTypes/DataTypeFactory.h @@ -51,7 +51,6 @@ public: private: const Value & findCreatorByName(const String & family_name) const; -private: DataTypesDictionary data_types; /// Case insensitive data types will be additionally added here with lowercased name. diff --git a/src/DataTypes/DataTypeFixedString.h b/src/DataTypes/DataTypeFixedString.h index a53fde42b29..7c089866b23 100644 --- a/src/DataTypes/DataTypeFixedString.h +++ b/src/DataTypes/DataTypeFixedString.h @@ -29,7 +29,7 @@ public: static constexpr bool is_parametric = true; static constexpr auto type_id = TypeIndex::FixedString; - DataTypeFixedString(size_t n_) : n(n_) + explicit DataTypeFixedString(size_t n_) : n(n_) { if (n == 0) throw Exception("FixedString size must be positive", ErrorCodes::ARGUMENT_OUT_OF_BOUND); diff --git a/src/DataTypes/DataTypeFunction.h b/src/DataTypes/DataTypeFunction.h index 489ed4545f4..888bcb6a775 100644 --- a/src/DataTypes/DataTypeFunction.h +++ b/src/DataTypes/DataTypeFunction.h @@ -19,7 +19,7 @@ public: bool isParametric() const override { return true; } /// Some types could be still unknown. - DataTypeFunction(const DataTypes & argument_types_ = DataTypes(), const DataTypePtr & return_type_ = nullptr) + explicit DataTypeFunction(const DataTypes & argument_types_ = DataTypes(), const DataTypePtr & return_type_ = nullptr) : argument_types(argument_types_), return_type(return_type_) {} std::string doGetName() const override; diff --git a/src/DataTypes/DataTypeInterval.h b/src/DataTypes/DataTypeInterval.h index 9ef6237ec41..83d89a73460 100644 --- a/src/DataTypes/DataTypeInterval.h +++ b/src/DataTypes/DataTypeInterval.h @@ -25,7 +25,7 @@ public: IntervalKind getKind() const { return kind; } - DataTypeInterval(IntervalKind kind_) : kind(kind_) {} + explicit DataTypeInterval(IntervalKind kind_) : kind(kind_) {} std::string doGetName() const override { return fmt::format("Interval{}", kind.toString()); } const char * getFamilyName() const override { return "Interval"; } diff --git a/src/DataTypes/DataTypeMap.h b/src/DataTypes/DataTypeMap.h index 04377f85cfb..65bdd93ca4d 100644 --- a/src/DataTypes/DataTypeMap.h +++ b/src/DataTypes/DataTypeMap.h @@ -23,7 +23,7 @@ private: public: static constexpr bool is_parametric = true; - DataTypeMap(const DataTypes & elems); + explicit DataTypeMap(const DataTypes & elems); DataTypeMap(const DataTypePtr & key_type_, const DataTypePtr & value_type_); TypeIndex getTypeId() const override { return TypeIndex::Map; } diff --git a/src/DataTypes/DataTypeTuple.h b/src/DataTypes/DataTypeTuple.h index c56e87ca22d..db122aae5df 100644 --- a/src/DataTypes/DataTypeTuple.h +++ b/src/DataTypes/DataTypeTuple.h @@ -26,7 +26,7 @@ private: public: static constexpr bool is_parametric = true; - DataTypeTuple(const DataTypes & elems); + explicit DataTypeTuple(const DataTypes & elems); DataTypeTuple(const DataTypes & elems, const Strings & names, bool serialize_names_ = true); static bool canBeCreatedWithNames(const Strings & names); diff --git a/src/DataTypes/DataTypesDecimal.h b/src/DataTypes/DataTypesDecimal.h index fb590dd1d4b..0ec29e3c5f4 100644 --- a/src/DataTypes/DataTypesDecimal.h +++ b/src/DataTypes/DataTypesDecimal.h @@ -60,26 +60,26 @@ inline const DataTypeDecimal * checkDecimal(const IDataType & data_type) inline UInt32 getDecimalScale(const IDataType & data_type, UInt32 default_value = std::numeric_limits::max()) { - if (auto * decimal_type = checkDecimal(data_type)) + if (const auto * decimal_type = checkDecimal(data_type)) return decimal_type->getScale(); - if (auto * decimal_type = checkDecimal(data_type)) + if (const auto * decimal_type = checkDecimal(data_type)) return decimal_type->getScale(); - if (auto * decimal_type = checkDecimal(data_type)) + if (const auto * decimal_type = checkDecimal(data_type)) return decimal_type->getScale(); - if (auto * decimal_type = checkDecimal(data_type)) + if (const auto * decimal_type = checkDecimal(data_type)) return decimal_type->getScale(); return default_value; } inline UInt32 getDecimalPrecision(const IDataType & data_type) { - if (auto * decimal_type = checkDecimal(data_type)) + if (const auto * decimal_type = checkDecimal(data_type)) return decimal_type->getPrecision(); - if (auto * decimal_type = checkDecimal(data_type)) + if (const auto * decimal_type = checkDecimal(data_type)) return decimal_type->getPrecision(); - if (auto * decimal_type = checkDecimal(data_type)) + if (const auto * decimal_type = checkDecimal(data_type)) return decimal_type->getPrecision(); - if (auto * decimal_type = checkDecimal(data_type)) + if (const auto * decimal_type = checkDecimal(data_type)) return decimal_type->getPrecision(); return 0; } diff --git a/src/DataTypes/IDataType.h b/src/DataTypes/IDataType.h index 5bc089e085f..36e1ce8ddd5 100644 --- a/src/DataTypes/IDataType.h +++ b/src/DataTypes/IDataType.h @@ -318,12 +318,12 @@ struct WhichDataType { TypeIndex idx; - constexpr WhichDataType(TypeIndex idx_ = TypeIndex::Nothing) : idx(idx_) {} - constexpr WhichDataType(const IDataType & data_type) : idx(data_type.getTypeId()) {} - constexpr WhichDataType(const IDataType * data_type) : idx(data_type->getTypeId()) {} + constexpr WhichDataType(TypeIndex idx_ = TypeIndex::Nothing) : idx(idx_) {} /// NOLINT + constexpr WhichDataType(const IDataType & data_type) : idx(data_type.getTypeId()) {} /// NOLINT + constexpr WhichDataType(const IDataType * data_type) : idx(data_type->getTypeId()) {} /// NOLINT // shared ptr -> is non-constexpr in gcc - WhichDataType(const DataTypePtr & data_type) : idx(data_type->getTypeId()) {} + WhichDataType(const DataTypePtr & data_type) : idx(data_type->getTypeId()) {} /// NOLINT constexpr bool isUInt8() const { return idx == TypeIndex::UInt8; } constexpr bool isUInt16() const { return idx == TypeIndex::UInt16; } diff --git a/src/DataTypes/Native.h b/src/DataTypes/Native.h index b72e479cb1d..3a635d2e240 100644 --- a/src/DataTypes/Native.h +++ b/src/DataTypes/Native.h @@ -201,7 +201,7 @@ static inline llvm::Value * nativeCast(llvm::IRBuilder<> & b, const DataTypePtr return nativeCast(b, from, value, n_to); } -static inline std::pair nativeCastToCommon(llvm::IRBuilder<> & b, const DataTypePtr & lhs_type, llvm::Value * lhs, const DataTypePtr & rhs_type, llvm::Value * rhs) +static inline std::pair nativeCastToCommon(llvm::IRBuilder<> & b, const DataTypePtr & lhs_type, llvm::Value * lhs, const DataTypePtr & rhs_type, llvm::Value * rhs) /// NOLINT { llvm::Type * common; diff --git a/src/DataTypes/Serializations/ISerialization.h b/src/DataTypes/Serializations/ISerialization.h index b1fd4d0a9da..86d4eab289a 100644 --- a/src/DataTypes/Serializations/ISerialization.h +++ b/src/DataTypes/Serializations/ISerialization.h @@ -145,7 +145,7 @@ public: /// Flag, that may help to traverse substream paths. mutable bool visited = false; - Substream(Type type_) : type(type_) {} + Substream(Type type_) : type(type_) {} /// NOLINT String toString() const; }; diff --git a/src/DataTypes/Serializations/SerializationArray.h b/src/DataTypes/Serializations/SerializationArray.h index cd8cac54881..3769f8a4513 100644 --- a/src/DataTypes/Serializations/SerializationArray.h +++ b/src/DataTypes/Serializations/SerializationArray.h @@ -11,7 +11,7 @@ private: SerializationPtr nested; public: - SerializationArray(const SerializationPtr & nested_) : nested(nested_) {} + explicit SerializationArray(const SerializationPtr & nested_) : nested(nested_) {} void serializeBinary(const Field & field, WriteBuffer & ostr) const override; void deserializeBinary(Field & field, ReadBuffer & istr) const override; @@ -71,7 +71,7 @@ private: { const ColumnPtr offsets; - SubcolumnCreator(const ColumnPtr & offsets_) : offsets(offsets_) {} + explicit SubcolumnCreator(const ColumnPtr & offsets_) : offsets(offsets_) {} DataTypePtr create(const DataTypePtr & prev) const override; SerializationPtr create(const SerializationPtr & prev) const override; diff --git a/src/DataTypes/Serializations/SerializationBool.h b/src/DataTypes/Serializations/SerializationBool.h index a9f4c6404b3..a5aa0ca80a2 100644 --- a/src/DataTypes/Serializations/SerializationBool.h +++ b/src/DataTypes/Serializations/SerializationBool.h @@ -10,7 +10,7 @@ namespace DB class SerializationBool final : public SerializationWrapper { public: - SerializationBool(const SerializationPtr & nested_); + explicit SerializationBool(const SerializationPtr & nested_); void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override; diff --git a/src/DataTypes/Serializations/SerializationCustomSimpleText.h b/src/DataTypes/Serializations/SerializationCustomSimpleText.h index ba7c712f86c..21d6f8af650 100644 --- a/src/DataTypes/Serializations/SerializationCustomSimpleText.h +++ b/src/DataTypes/Serializations/SerializationCustomSimpleText.h @@ -15,7 +15,7 @@ class IColumn; class SerializationCustomSimpleText : public SerializationWrapper { public: - SerializationCustomSimpleText(const SerializationPtr & nested_); + explicit SerializationCustomSimpleText(const SerializationPtr & nested_); // Methods that subclasses must override in order to get full serialization/deserialization support. virtual void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override = 0; diff --git a/src/DataTypes/Serializations/SerializationDateTime.h b/src/DataTypes/Serializations/SerializationDateTime.h index 75334592422..f4a142483e5 100644 --- a/src/DataTypes/Serializations/SerializationDateTime.h +++ b/src/DataTypes/Serializations/SerializationDateTime.h @@ -11,7 +11,7 @@ namespace DB class SerializationDateTime final : public SerializationNumber, public TimezoneMixin { public: - SerializationDateTime(const TimezoneMixin & time_zone_); + explicit SerializationDateTime(const TimezoneMixin & time_zone_); void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override; void deserializeWholeText(IColumn & column, ReadBuffer & istr, const FormatSettings & settings) const override; diff --git a/src/DataTypes/Serializations/SerializationEnum.h b/src/DataTypes/Serializations/SerializationEnum.h index dfa9e74c7a1..bdd769b59c5 100644 --- a/src/DataTypes/Serializations/SerializationEnum.h +++ b/src/DataTypes/Serializations/SerializationEnum.h @@ -14,7 +14,7 @@ public: using typename SerializationNumber::ColumnType; using typename EnumValues::Values; - SerializationEnum(const Values & values_) : EnumValues(values_) {} + explicit SerializationEnum(const Values & values_) : EnumValues(values_) {} void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override; void serializeTextEscaped(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override; diff --git a/src/DataTypes/Serializations/SerializationFixedString.h b/src/DataTypes/Serializations/SerializationFixedString.h index 82559d10800..c3c08b20419 100644 --- a/src/DataTypes/Serializations/SerializationFixedString.h +++ b/src/DataTypes/Serializations/SerializationFixedString.h @@ -12,7 +12,7 @@ private: size_t n; public: - SerializationFixedString(size_t n_) : n(n_) {} + explicit SerializationFixedString(size_t n_) : n(n_) {} size_t getN() const { return n; } void serializeBinary(const Field & field, WriteBuffer & ostr) const override; diff --git a/src/DataTypes/Serializations/SerializationIP.h b/src/DataTypes/Serializations/SerializationIP.h index a7bf1aeb2c6..282105b6b1e 100644 --- a/src/DataTypes/Serializations/SerializationIP.h +++ b/src/DataTypes/Serializations/SerializationIP.h @@ -8,7 +8,7 @@ namespace DB class SerializationIPv4 final : public SerializationCustomSimpleText { public: - SerializationIPv4(const SerializationPtr & nested_); + explicit SerializationIPv4(const SerializationPtr & nested_); void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override; void deserializeText(IColumn & column, ReadBuffer & istr, const FormatSettings & settings, bool whole) const override; @@ -17,7 +17,7 @@ public: class SerializationIPv6 : public SerializationCustomSimpleText { public: - SerializationIPv6(const SerializationPtr & nested_); + explicit SerializationIPv6(const SerializationPtr & nested_); void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override; void deserializeText(IColumn & column, ReadBuffer & istr, const FormatSettings & settings, bool whole) const override; diff --git a/src/DataTypes/Serializations/SerializationLowCardinality.h b/src/DataTypes/Serializations/SerializationLowCardinality.h index 5f8a2a95a25..0a3597e86c7 100644 --- a/src/DataTypes/Serializations/SerializationLowCardinality.h +++ b/src/DataTypes/Serializations/SerializationLowCardinality.h @@ -15,7 +15,7 @@ private: SerializationPtr dict_inner_serialization; public: - SerializationLowCardinality(const DataTypePtr & dictionary_type); + explicit SerializationLowCardinality(const DataTypePtr & dictionary_type); void enumerateStreams( SubstreamPath & path, diff --git a/src/DataTypes/Serializations/SerializationNothing.h b/src/DataTypes/Serializations/SerializationNothing.h index 4a062931ac2..2de93a29763 100644 --- a/src/DataTypes/Serializations/SerializationNothing.h +++ b/src/DataTypes/Serializations/SerializationNothing.h @@ -14,7 +14,7 @@ namespace ErrorCodes class SerializationNothing : public SimpleTextSerialization { private: - [[noreturn]] void throwNoSerialization() const + [[noreturn]] static void throwNoSerialization() { throw Exception("Serialization is not implemented", ErrorCodes::NOT_IMPLEMENTED); } diff --git a/src/DataTypes/Serializations/SerializationNullable.h b/src/DataTypes/Serializations/SerializationNullable.h index eb3e9bfb430..c22f2f57786 100644 --- a/src/DataTypes/Serializations/SerializationNullable.h +++ b/src/DataTypes/Serializations/SerializationNullable.h @@ -11,7 +11,7 @@ private: SerializationPtr nested; public: - SerializationNullable(const SerializationPtr & nested_) : nested(nested_) {} + explicit SerializationNullable(const SerializationPtr & nested_) : nested(nested_) {} void enumerateStreams( SubstreamPath & path, @@ -96,7 +96,7 @@ private: { const ColumnPtr null_map; - SubcolumnCreator(const ColumnPtr & null_map_) : null_map(null_map_) {} + explicit SubcolumnCreator(const ColumnPtr & null_map_) : null_map(null_map_) {} DataTypePtr create(const DataTypePtr & prev) const override; SerializationPtr create(const SerializationPtr & prev) const override; diff --git a/src/DataTypes/Serializations/SerializationSparse.h b/src/DataTypes/Serializations/SerializationSparse.h index 51d9df2cb5d..54ab4853360 100644 --- a/src/DataTypes/Serializations/SerializationSparse.h +++ b/src/DataTypes/Serializations/SerializationSparse.h @@ -23,7 +23,7 @@ namespace DB class SerializationSparse final : public ISerialization { public: - SerializationSparse(const SerializationPtr & nested_); + explicit SerializationSparse(const SerializationPtr & nested_); Kind getKind() const override { return Kind::SPARSE; } diff --git a/src/DataTypes/Serializations/SerializationWrapper.h b/src/DataTypes/Serializations/SerializationWrapper.h index 4cdcffc21a8..43fc7e9914a 100644 --- a/src/DataTypes/Serializations/SerializationWrapper.h +++ b/src/DataTypes/Serializations/SerializationWrapper.h @@ -14,7 +14,7 @@ protected: SerializationPtr nested_serialization; public: - SerializationWrapper(const SerializationPtr & nested_serialization_) : nested_serialization(nested_serialization_) {} + explicit SerializationWrapper(const SerializationPtr & nested_serialization_) : nested_serialization(nested_serialization_) {} const SerializationPtr & getNested() const { return nested_serialization; } diff --git a/src/Databases/DatabaseReplicatedWorker.h b/src/Databases/DatabaseReplicatedWorker.h index 773612e403c..6b957e567ff 100644 --- a/src/Databases/DatabaseReplicatedWorker.h +++ b/src/Databases/DatabaseReplicatedWorker.h @@ -30,7 +30,7 @@ public: void shutdown() override; static String enqueueQueryImpl(const ZooKeeperPtr & zookeeper, DDLLogEntry & entry, - DatabaseReplicated * const database, bool committed = false); + DatabaseReplicated * const database, bool committed = false); /// NOLINT private: bool initializeMainThread() override; diff --git a/src/Databases/IDatabase.h b/src/Databases/IDatabase.h index 9ad33bd228f..f95653feb20 100644 --- a/src/Databases/IDatabase.h +++ b/src/Databases/IDatabase.h @@ -51,8 +51,8 @@ public: /// - it maintains a list of tables but tables are loaded lazily). virtual const StoragePtr & table() const = 0; - IDatabaseTablesIterator(const String & database_name_) : database_name(database_name_) { } - IDatabaseTablesIterator(String && database_name_) : database_name(std::move(database_name_)) { } + explicit IDatabaseTablesIterator(const String & database_name_) : database_name(database_name_) { } + explicit IDatabaseTablesIterator(String && database_name_) : database_name(std::move(database_name_)) { } virtual ~IDatabaseTablesIterator() = default; @@ -61,7 +61,7 @@ public: const String & databaseName() const { assert(!database_name.empty()); return database_name; } protected: - const String database_name; + String database_name; }; /// Copies list of tables and iterates through such snapshot. @@ -72,7 +72,7 @@ private: Tables::iterator it; protected: - DatabaseTablesSnapshotIterator(DatabaseTablesSnapshotIterator && other) + DatabaseTablesSnapshotIterator(DatabaseTablesSnapshotIterator && other) noexcept : IDatabaseTablesIterator(std::move(other.database_name)) { size_t idx = std::distance(other.tables.begin(), other.it); @@ -118,7 +118,7 @@ class IDatabase : public std::enable_shared_from_this { public: IDatabase() = delete; - IDatabase(String database_name_) : database_name(std::move(database_name_)) {} + explicit IDatabase(String database_name_) : database_name(std::move(database_name_)) {} /// Get name of database engine. virtual String getEngineName() const = 0; @@ -129,7 +129,7 @@ public: /// Load a set of existing tables. /// You can call only once, right after the object is created. - virtual void loadStoredObjects( + virtual void loadStoredObjects( /// NOLINT ContextMutablePtr /*context*/, bool /*force_restore*/, bool /*force_attach*/ = false, @@ -175,7 +175,7 @@ public: /// Get an iterator that allows you to pass through all the tables. /// It is possible to have "hidden" tables that are not visible when passing through, but are visible if you get them by name using the functions above. - virtual DatabaseTablesIteratorPtr getTablesIterator(ContextPtr context, const FilterByNameFunction & filter_by_table_name = {}) const = 0; + virtual DatabaseTablesIteratorPtr getTablesIterator(ContextPtr context, const FilterByNameFunction & filter_by_table_name = {}) const = 0; /// NOLINT /// Is the database empty. virtual bool empty() const = 0; @@ -191,7 +191,7 @@ public: } /// Delete the table from the database, drop table and delete the metadata. - virtual void dropTable( + virtual void dropTable( /// NOLINT ContextPtr /*context*/, const String & /*name*/, [[maybe_unused]] bool no_delay = false) @@ -202,7 +202,7 @@ public: /// Add a table to the database, but do not add it to the metadata. The database may not support this method. /// /// Note: ATTACH TABLE statement actually uses createTable method. - virtual void attachTable(ContextPtr /* context */, const String & /*name*/, const StoragePtr & /*table*/, [[maybe_unused]] const String & relative_table_path = {}) + virtual void attachTable(ContextPtr /* context */, const String & /*name*/, const StoragePtr & /*table*/, [[maybe_unused]] const String & relative_table_path = {}) /// NOLINT { throw Exception("There is no ATTACH TABLE query for Database" + getEngineName(), ErrorCodes::NOT_IMPLEMENTED); } diff --git a/src/Databases/MySQL/MaterializedMySQLSyncThread.h b/src/Databases/MySQL/MaterializedMySQLSyncThread.h index c7781595a85..163a3732fb9 100644 --- a/src/Databases/MySQL/MaterializedMySQLSyncThread.h +++ b/src/Databases/MySQL/MaterializedMySQLSyncThread.h @@ -67,12 +67,12 @@ private: // USE MySQL ERROR CODE: // https://dev.mysql.com/doc/mysql-errors/5.7/en/server-error-reference.html - const int ER_ACCESS_DENIED_ERROR = 1045; - const int ER_DBACCESS_DENIED_ERROR = 1044; - const int ER_BAD_DB_ERROR = 1049; + const int ER_ACCESS_DENIED_ERROR = 1045; /// NOLINT + const int ER_DBACCESS_DENIED_ERROR = 1044; /// NOLINT + const int ER_BAD_DB_ERROR = 1049; /// NOLINT // https://dev.mysql.com/doc/mysql-errors/8.0/en/client-error-reference.html - const int CR_SERVER_LOST = 2013; + const int CR_SERVER_LOST = 2013; /// NOLINT struct Buffers { @@ -88,7 +88,7 @@ private: using BufferAndSortingColumnsPtr = std::shared_ptr; std::unordered_map data; - Buffers(const String & database_) : database(database_) {} + explicit Buffers(const String & database_) : database(database_) {} void commit(ContextPtr context); diff --git a/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp b/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp index 43506b004b6..ce1ed98b977 100644 --- a/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp +++ b/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp @@ -174,7 +174,7 @@ StoragePtr DatabasePostgreSQL::tryGetTable(const String & table_name, ContextPtr } -StoragePtr DatabasePostgreSQL::fetchTable(const String & table_name, ContextPtr, const bool table_checked) const +StoragePtr DatabasePostgreSQL::fetchTable(const String & table_name, ContextPtr, bool table_checked) const { if (!cache_tables || !cached_tables.count(table_name)) { diff --git a/src/Databases/PostgreSQL/DatabasePostgreSQL.h b/src/Databases/PostgreSQL/DatabasePostgreSQL.h index d41dbff1f54..3397dcc8076 100644 --- a/src/Databases/PostgreSQL/DatabasePostgreSQL.h +++ b/src/Databases/PostgreSQL/DatabasePostgreSQL.h @@ -81,7 +81,7 @@ private: bool checkPostgresTable(const String & table_name) const; - StoragePtr fetchTable(const String & table_name, ContextPtr context, const bool table_checked) const; + StoragePtr fetchTable(const String & table_name, ContextPtr context, bool table_checked) const; void removeOutdatedTables(); diff --git a/src/Dictionaries/CacheDictionaryUpdateQueue.h b/src/Dictionaries/CacheDictionaryUpdateQueue.h index 7725ce7588f..d6a195ca7b8 100644 --- a/src/Dictionaries/CacheDictionaryUpdateQueue.h +++ b/src/Dictionaries/CacheDictionaryUpdateQueue.h @@ -75,7 +75,7 @@ private: friend class CacheDictionaryUpdateQueue; std::atomic is_done{false}; - std::exception_ptr current_exception{nullptr}; + std::exception_ptr current_exception{nullptr}; /// NOLINT /// While UpdateUnit is alive, it is accounted in update_queue size. CurrentMetrics::Increment alive_batch{CurrentMetrics::CacheDictionaryUpdateQueueBatches}; diff --git a/src/Dictionaries/CassandraHelpers.h b/src/Dictionaries/CassandraHelpers.h index 30111e11686..3b90d46acdf 100644 --- a/src/Dictionaries/CassandraHelpers.h +++ b/src/Dictionaries/CassandraHelpers.h @@ -23,8 +23,8 @@ class ObjectHolder CassT * ptr = nullptr; public: template - ObjectHolder(Args &&... args) : ptr(Ctor(std::forward(args)...)) {} - ObjectHolder(CassT * ptr_) : ptr(ptr_) {} + ObjectHolder(Args &&... args) : ptr(Ctor(std::forward(args)...)) {} /// NOLINT + ObjectHolder(CassT * ptr_) : ptr(ptr_) {} /// NOLINT ObjectHolder(const ObjectHolder &) = delete; ObjectHolder & operator = (const ObjectHolder &) = delete; @@ -46,8 +46,8 @@ public: } /// For implicit conversion when passing object to driver library functions - operator CassT * () { return ptr; } - operator const CassT * () const { return ptr; } + operator CassT * () { return ptr; } /// NOLINT + operator const CassT * () const { return ptr; } /// NOLINT }; } diff --git a/src/Dictionaries/DictionaryHelpers.h b/src/Dictionaries/DictionaryHelpers.h index f2d7febfa8e..80b15eb2569 100644 --- a/src/Dictionaries/DictionaryHelpers.h +++ b/src/Dictionaries/DictionaryHelpers.h @@ -187,7 +187,7 @@ private: DataTypes dictionary_attributes_types; }; -static inline void insertDefaultValuesIntoColumns( +static inline void insertDefaultValuesIntoColumns( /// NOLINT MutableColumns & columns, const DictionaryStorageFetchRequest & fetch_request, size_t row_index) @@ -206,7 +206,7 @@ static inline void insertDefaultValuesIntoColumns( /// Deserialize column value and insert it in columns. /// Skip unnecessary columns that were not requested from deserialization. -static inline void deserializeAndInsertIntoColumns( +static inline void deserializeAndInsertIntoColumns( /// NOLINT MutableColumns & columns, const DictionaryStorageFetchRequest & fetch_request, const char * place_for_serialized_columns) diff --git a/src/Dictionaries/Embedded/GeodataProviders/HierarchiesProvider.h b/src/Dictionaries/Embedded/GeodataProviders/HierarchiesProvider.h index 198f13e0f32..c2e36f59e1e 100644 --- a/src/Dictionaries/Embedded/GeodataProviders/HierarchiesProvider.h +++ b/src/Dictionaries/Embedded/GeodataProviders/HierarchiesProvider.h @@ -14,7 +14,7 @@ private: FileUpdatesTracker updates_tracker; public: - RegionsHierarchyDataSource(const std::string & path_) : path(path_), updates_tracker(path_) {} + explicit RegionsHierarchyDataSource(const std::string & path_) : path(path_), updates_tracker(path_) {} bool isModified() const override; @@ -40,7 +40,7 @@ public: * For example, if /opt/geo/regions_hierarchy.txt is specified, * then the /opt/geo/regions_hierarchy_ua.txt file will also be loaded, if any, it will be accessible by the `ua` key. */ - RegionsHierarchiesDataProvider(const std::string & path_); + explicit RegionsHierarchiesDataProvider(const std::string & path_); std::vector listCustomHierarchies() const override; diff --git a/src/Dictionaries/Embedded/GeodataProviders/HierarchyFormatReader.h b/src/Dictionaries/Embedded/GeodataProviders/HierarchyFormatReader.h index 85dd8ce58b7..64f393ada62 100644 --- a/src/Dictionaries/Embedded/GeodataProviders/HierarchyFormatReader.h +++ b/src/Dictionaries/Embedded/GeodataProviders/HierarchyFormatReader.h @@ -11,7 +11,7 @@ private: DB::ReadBufferPtr input; public: - RegionsHierarchyFormatReader(DB::ReadBufferPtr input_) : input(std::move(input_)) {} + explicit RegionsHierarchyFormatReader(DB::ReadBufferPtr input_) : input(std::move(input_)) {} bool readNext(RegionEntry & entry) override; }; diff --git a/src/Dictionaries/Embedded/GeodataProviders/IHierarchiesProvider.h b/src/Dictionaries/Embedded/GeodataProviders/IHierarchiesProvider.h index 0606896c951..f7d51135440 100644 --- a/src/Dictionaries/Embedded/GeodataProviders/IHierarchiesProvider.h +++ b/src/Dictionaries/Embedded/GeodataProviders/IHierarchiesProvider.h @@ -27,7 +27,7 @@ public: virtual IRegionsHierarchyReaderPtr createReader() = 0; - virtual ~IRegionsHierarchyDataSource() {} + virtual ~IRegionsHierarchyDataSource() = default; }; using IRegionsHierarchyDataSourcePtr = std::shared_ptr; @@ -42,7 +42,7 @@ public: virtual IRegionsHierarchyDataSourcePtr getDefaultHierarchySource() const = 0; virtual IRegionsHierarchyDataSourcePtr getHierarchySource(const std::string & name) const = 0; - virtual ~IRegionsHierarchiesDataProvider() {} + virtual ~IRegionsHierarchiesDataProvider() = default; }; using IRegionsHierarchiesDataProviderPtr = std::shared_ptr; diff --git a/src/Dictionaries/Embedded/GeodataProviders/INamesProvider.h b/src/Dictionaries/Embedded/GeodataProviders/INamesProvider.h index 26de5d9116b..679c14d546b 100644 --- a/src/Dictionaries/Embedded/GeodataProviders/INamesProvider.h +++ b/src/Dictionaries/Embedded/GeodataProviders/INamesProvider.h @@ -10,7 +10,7 @@ class ILanguageRegionsNamesReader public: virtual bool readNext(RegionNameEntry & entry) = 0; - virtual ~ILanguageRegionsNamesReader() {} + virtual ~ILanguageRegionsNamesReader() = default; }; using ILanguageRegionsNamesReaderPtr = std::unique_ptr; @@ -32,7 +32,7 @@ public: virtual std::string getSourceName() const = 0; - virtual ~ILanguageRegionsNamesDataSource() {} + virtual ~ILanguageRegionsNamesDataSource() = default; }; using ILanguageRegionsNamesDataSourcePtr = std::unique_ptr; @@ -45,7 +45,7 @@ public: /// Returns nullptr if the language data does not exist. virtual ILanguageRegionsNamesDataSourcePtr getLanguageRegionsNamesSource(const std::string & language) const = 0; - virtual ~IRegionsNamesDataProvider() {} + virtual ~IRegionsNamesDataProvider() = default; }; using IRegionsNamesDataProviderPtr = std::unique_ptr; diff --git a/src/Dictionaries/Embedded/GeodataProviders/NamesFormatReader.h b/src/Dictionaries/Embedded/GeodataProviders/NamesFormatReader.h index 573569ab115..49d324d434e 100644 --- a/src/Dictionaries/Embedded/GeodataProviders/NamesFormatReader.h +++ b/src/Dictionaries/Embedded/GeodataProviders/NamesFormatReader.h @@ -11,7 +11,7 @@ private: DB::ReadBufferPtr input; public: - LanguageRegionsNamesFormatReader(DB::ReadBufferPtr input_) : input(std::move(input_)) {} + explicit LanguageRegionsNamesFormatReader(DB::ReadBufferPtr input_) : input(std::move(input_)) {} bool readNext(RegionNameEntry & entry) override; }; diff --git a/src/Dictionaries/Embedded/GeodataProviders/NamesProvider.h b/src/Dictionaries/Embedded/GeodataProviders/NamesProvider.h index c380fcb7d1d..2d49cceab86 100644 --- a/src/Dictionaries/Embedded/GeodataProviders/NamesProvider.h +++ b/src/Dictionaries/Embedded/GeodataProviders/NamesProvider.h @@ -39,7 +39,7 @@ private: std::string directory; public: - RegionsNamesDataProvider(const std::string & directory_); + explicit RegionsNamesDataProvider(const std::string & directory_); ILanguageRegionsNamesDataSourcePtr getLanguageRegionsNamesSource(const std::string & language) const override; diff --git a/src/Dictionaries/Embedded/RegionsHierarchies.h b/src/Dictionaries/Embedded/RegionsHierarchies.h index 9626a77216d..925b7b490ff 100644 --- a/src/Dictionaries/Embedded/RegionsHierarchies.h +++ b/src/Dictionaries/Embedded/RegionsHierarchies.h @@ -17,7 +17,7 @@ private: Container data; public: - RegionsHierarchies(IRegionsHierarchiesDataProviderPtr data_provider); + explicit RegionsHierarchies(IRegionsHierarchiesDataProviderPtr data_provider); /** Reloads, if necessary, all hierarchies of regions. */ diff --git a/src/Dictionaries/Embedded/RegionsHierarchy.h b/src/Dictionaries/Embedded/RegionsHierarchy.h index 45d6c5246ca..508bca0d1e1 100644 --- a/src/Dictionaries/Embedded/RegionsHierarchy.h +++ b/src/Dictionaries/Embedded/RegionsHierarchy.h @@ -49,7 +49,7 @@ private: IRegionsHierarchyDataSourcePtr data_source; public: - RegionsHierarchy(IRegionsHierarchyDataSourcePtr data_source_); + explicit RegionsHierarchy(IRegionsHierarchyDataSourcePtr data_source_); /// Reloads, if necessary, the hierarchy of regions. Not threadsafe. void reload(); diff --git a/src/Dictionaries/Embedded/RegionsNames.h b/src/Dictionaries/Embedded/RegionsNames.h index ff60c274401..ec06a0b1a33 100644 --- a/src/Dictionaries/Embedded/RegionsNames.h +++ b/src/Dictionaries/Embedded/RegionsNames.h @@ -40,7 +40,7 @@ class RegionsNames public: enum class Language : size_t { - #define M(NAME, FALLBACK, NUM) NAME = NUM, + #define M(NAME, FALLBACK, NUM) NAME = (NUM), FOR_EACH_LANGUAGE(M) #undef M }; @@ -78,7 +78,7 @@ private: static std::string dumpSupportedLanguagesNames(); public: - RegionsNames(IRegionsNamesDataProviderPtr data_provider); + explicit RegionsNames(IRegionsNamesDataProviderPtr data_provider); StringRef getRegionName(RegionID region_id, Language language) const { @@ -104,7 +104,7 @@ public: #define M(NAME, FALLBACK, NUM) \ if (0 == language.compare(#NAME)) \ return Language::NAME; - FOR_EACH_LANGUAGE(M) + FOR_EACH_LANGUAGE(M) /// NOLINT #undef M throw Poco::Exception("Unsupported language for region name. Supported languages are: " + dumpSupportedLanguagesNames() + "."); } diff --git a/src/Dictionaries/FlatDictionary.cpp b/src/Dictionaries/FlatDictionary.cpp index 26144821a0e..cb2419633bf 100644 --- a/src/Dictionaries/FlatDictionary.cpp +++ b/src/Dictionaries/FlatDictionary.cpp @@ -32,13 +32,11 @@ FlatDictionary::FlatDictionary( const StorageID & dict_id_, const DictionaryStructure & dict_struct_, DictionarySourcePtr source_ptr_, - const DictionaryLifetime dict_lifetime_, Configuration configuration_, BlockPtr update_field_loaded_block_) : IDictionary(dict_id_) , dict_struct(dict_struct_) , source_ptr{std::move(source_ptr_)} - , dict_lifetime(dict_lifetime_) , configuration(configuration_) , loaded_keys(configuration.initial_array_size, false) , update_field_loaded_block(std::move(update_field_loaded_block_)) @@ -604,18 +602,19 @@ void registerDictionaryFlat(DictionaryFactory & factory) static constexpr size_t default_max_array_size = 500000; String dictionary_layout_prefix = config_prefix + ".layout" + ".flat"; + const DictionaryLifetime dict_lifetime{config, config_prefix + ".lifetime"}; FlatDictionary::Configuration configuration { .initial_array_size = config.getUInt64(dictionary_layout_prefix + ".initial_array_size", default_initial_array_size), .max_array_size = config.getUInt64(dictionary_layout_prefix + ".max_array_size", default_max_array_size), - .require_nonempty = config.getBool(config_prefix + ".require_nonempty", false) + .require_nonempty = config.getBool(config_prefix + ".require_nonempty", false), + .dict_lifetime = dict_lifetime }; const auto dict_id = StorageID::fromDictionaryConfig(config, config_prefix); - const DictionaryLifetime dict_lifetime{config, config_prefix + ".lifetime"}; - return std::make_unique(dict_id, dict_struct, std::move(source_ptr), dict_lifetime, std::move(configuration)); + return std::make_unique(dict_id, dict_struct, std::move(source_ptr), std::move(configuration)); }; factory.registerLayout("flat", create_layout, false); diff --git a/src/Dictionaries/FlatDictionary.h b/src/Dictionaries/FlatDictionary.h index 2578fef3ecb..f342c38802d 100644 --- a/src/Dictionaries/FlatDictionary.h +++ b/src/Dictionaries/FlatDictionary.h @@ -26,13 +26,13 @@ public: size_t initial_array_size; size_t max_array_size; bool require_nonempty; + DictionaryLifetime dict_lifetime; }; FlatDictionary( const StorageID & dict_id_, const DictionaryStructure & dict_struct_, DictionarySourcePtr source_ptr_, - const DictionaryLifetime dict_lifetime_, Configuration configuration_, BlockPtr update_field_loaded_block_ = nullptr); @@ -58,12 +58,12 @@ public: std::shared_ptr clone() const override { - return std::make_shared(getDictionaryID(), dict_struct, source_ptr->clone(), dict_lifetime, configuration, update_field_loaded_block); + return std::make_shared(getDictionaryID(), dict_struct, source_ptr->clone(), configuration, update_field_loaded_block); } DictionarySourcePtr getSource() const override { return source_ptr; } - const DictionaryLifetime & getLifetime() const override { return dict_lifetime; } + const DictionaryLifetime & getLifetime() const override { return configuration.dict_lifetime; } const DictionaryStructure & getStructure() const override { return dict_struct; } @@ -159,7 +159,6 @@ private: const DictionaryStructure dict_struct; const DictionarySourcePtr source_ptr; - const DictionaryLifetime dict_lifetime; const Configuration configuration; std::vector attributes; diff --git a/src/Dictionaries/ICacheDictionaryStorage.h b/src/Dictionaries/ICacheDictionaryStorage.h index b094d76a9a7..a4990528a4e 100644 --- a/src/Dictionaries/ICacheDictionaryStorage.h +++ b/src/Dictionaries/ICacheDictionaryStorage.h @@ -22,7 +22,7 @@ struct KeyState , fetched_column_index(fetched_column_index_) {} - KeyState(State state_) + KeyState(State state_) /// NOLINT : state(state_) {} diff --git a/src/Dictionaries/IDictionary.h b/src/Dictionaries/IDictionary.h index 042153f0971..c18dbcfbea7 100644 --- a/src/Dictionaries/IDictionary.h +++ b/src/Dictionaries/IDictionary.h @@ -150,7 +150,7 @@ public: auto & key_column_to_cast = key_columns[key_attribute_type_index]; ColumnWithTypeAndName column_to_cast = {key_column_to_cast, key_type, ""}; - auto casted_column = castColumnAccurate(std::move(column_to_cast), key_attribute_type); + auto casted_column = castColumnAccurate(column_to_cast, key_attribute_type); key_column_to_cast = std::move(casted_column); key_type = key_attribute_type; } diff --git a/src/Dictionaries/IPAddressDictionary.h b/src/Dictionaries/IPAddressDictionary.h index 8dddc988caa..894af5ceb71 100644 --- a/src/Dictionaries/IPAddressDictionary.h +++ b/src/Dictionaries/IPAddressDictionary.h @@ -26,7 +26,7 @@ public: const StorageID & dict_id_, const DictionaryStructure & dict_struct_, DictionarySourcePtr source_ptr_, - const DictionaryLifetime dict_lifetime_, + const DictionaryLifetime dict_lifetime_, /// NOLINT bool require_nonempty_); std::string getKeyDescription() const { return key_description; } @@ -160,7 +160,7 @@ private: template static void createAttributeImpl(Attribute & attribute, const Field & null_value); - static Attribute createAttributeWithType(const AttributeUnderlyingType type, const Field & null_value); + static Attribute createAttributeWithType(const AttributeUnderlyingType type, const Field & null_value); /// NOLINT template void getItemsByTwoKeyColumnsImpl( @@ -177,7 +177,7 @@ private: DefaultValueExtractor & default_value_extractor) const; template - void setAttributeValueImpl(Attribute & attribute, const T value); + void setAttributeValueImpl(Attribute & attribute, const T value); /// NOLINT void setAttributeValue(Attribute & attribute, const Field & value); diff --git a/src/Dictionaries/PolygonDictionaryUtils.h b/src/Dictionaries/PolygonDictionaryUtils.h index 0aca7cd8af0..9d6d6ae0501 100644 --- a/src/Dictionaries/PolygonDictionaryUtils.h +++ b/src/Dictionaries/PolygonDictionaryUtils.h @@ -38,7 +38,7 @@ public: SlabsPolygonIndex() = default; /** Builds an index by splitting all edges with all points x coordinates. */ - SlabsPolygonIndex(const std::vector & polygons); + explicit SlabsPolygonIndex(const std::vector & polygons); /** Finds polygon id the same way as IPolygonIndex. */ bool find(const Point & point, size_t & id) const; @@ -179,7 +179,7 @@ class GridRoot : public ICell { public: GridRoot(size_t min_intersections_, size_t max_depth_, const std::vector & polygons_): - kMinIntersections(min_intersections_), kMaxDepth(max_depth_), polygons(polygons_) + k_min_intersections(min_intersections_), k_max_depth(max_depth_), polygons(polygons_) { setBoundingBox(); std::vector order(polygons.size()); @@ -209,8 +209,8 @@ private: std::unique_ptr> root = nullptr; Coord min_x = 0, min_y = 0; Coord max_x = 0, max_y = 0; - const size_t kMinIntersections; - const size_t kMaxDepth; + const size_t k_min_intersections; + const size_t k_max_depth; const std::vector & polygons; @@ -236,7 +236,7 @@ private: } #endif size_t intersections = possible_ids.size() - covered; - if (intersections <= kMinIntersections || depth++ == kMaxDepth) + if (intersections <= k_min_intersections || depth++ == k_max_depth) return std::make_unique(possible_ids, polygons, current_box, covered); auto x_shift = (current_max_x - current_min_x) / DividedCell::kSplit; auto y_shift = (current_max_y - current_min_y) / DividedCell::kSplit; diff --git a/src/Disks/DiskMemory.h b/src/Disks/DiskMemory.h index eef7b78502d..fe108f53c68 100644 --- a/src/Disks/DiskMemory.h +++ b/src/Disks/DiskMemory.h @@ -22,7 +22,7 @@ class WriteBufferFromFileBase; class DiskMemory : public IDisk { public: - DiskMemory(const String & name_) : name(name_), disk_path("memory://" + name_ + '/') {} + explicit DiskMemory(const String & name_) : name(name_), disk_path("memory://" + name_ + '/') {} const String & getName() const override { return name; } @@ -97,7 +97,6 @@ private: void createDirectoriesImpl(const String & path); void replaceFileImpl(const String & from_path, const String & to_path); -private: friend class WriteIndirectBuffer; enum class FileType @@ -112,7 +111,7 @@ private: String data; FileData(FileType type_, String data_) : type(type_), data(std::move(data_)) {} - explicit FileData(FileType type_) : type(type_), data("") {} + explicit FileData(FileType type_) : type(type_) {} }; using Files = std::unordered_map; /// file path -> file data diff --git a/src/Disks/DiskSelector.h b/src/Disks/DiskSelector.h index 0cd1267c6ef..a2fce4b14d1 100644 --- a/src/Disks/DiskSelector.h +++ b/src/Disks/DiskSelector.h @@ -19,7 +19,7 @@ class DiskSelector { public: DiskSelector(const Poco::Util::AbstractConfiguration & config, const String & config_prefix, ContextPtr context); - DiskSelector(const DiskSelector & from) : disks(from.disks) { } + DiskSelector(const DiskSelector & from) = default; DiskSelectorPtr updateFromConfig( const Poco::Util::AbstractConfiguration & config, diff --git a/src/Disks/DiskWebServer.h b/src/Disks/DiskWebServer.h index bda8c8adaad..e2da0b2a1e1 100644 --- a/src/Disks/DiskWebServer.h +++ b/src/Disks/DiskWebServer.h @@ -38,7 +38,7 @@ namespace ErrorCodes * * To get files for upload run: * clickhouse static-files-disk-uploader --metadata-path --output-dir - * (--metadata-path can be found in query: `select data_paths from system.tables where name='';`) + * (--metadata-path can be found in query: `select data_paths from system.tables where name='';`) /// NOLINT * * When loading files by they must be loaded into /store/ path, but config must conrain only . * diff --git a/src/Disks/IDisk.h b/src/Disks/IDisk.h index 5068ac5dde9..d7d94cd03d7 100644 --- a/src/Disks/IDisk.h +++ b/src/Disks/IDisk.h @@ -158,14 +158,14 @@ public: virtual void listFiles(const String & path, std::vector & file_names) = 0; /// Open the file for read and return ReadBufferFromFileBase object. - virtual std::unique_ptr readFile( + virtual std::unique_ptr readFile( /// NOLINT const String & path, const ReadSettings & settings = ReadSettings{}, std::optional read_hint = {}, std::optional file_size = {}) const = 0; /// Open the file for write and return WriteBufferFromFileBase object. - virtual std::unique_ptr writeFile( + virtual std::unique_ptr writeFile( /// NOLINT const String & path, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, WriteMode mode = WriteMode::Rewrite) = 0; @@ -354,7 +354,7 @@ public: virtual UInt64 getSize() const = 0; /// Get i-th disk where reservation take place. - virtual DiskPtr getDisk(size_t i = 0) const = 0; + virtual DiskPtr getDisk(size_t i = 0) const = 0; /// NOLINT /// Get all disks, used in reservation virtual Disks getDisks() const = 0; diff --git a/src/Disks/IDiskRemote.h b/src/Disks/IDiskRemote.h index 1d8da1aab14..82e76b8f68d 100644 --- a/src/Disks/IDiskRemote.h +++ b/src/Disks/IDiskRemote.h @@ -13,7 +13,6 @@ #include #include -namespace fs = std::filesystem; namespace CurrentMetrics { @@ -28,7 +27,7 @@ namespace DB class RemoteFSPathKeeper { public: - RemoteFSPathKeeper(size_t chunk_limit_) : chunk_limit(chunk_limit_) {} + explicit RemoteFSPathKeeper(size_t chunk_limit_) : chunk_limit(chunk_limit_) {} virtual ~RemoteFSPathKeeper() = default; diff --git a/src/Disks/LocalDirectorySyncGuard.h b/src/Disks/LocalDirectorySyncGuard.h index 34e4cb9e657..cb891461e85 100644 --- a/src/Disks/LocalDirectorySyncGuard.h +++ b/src/Disks/LocalDirectorySyncGuard.h @@ -17,8 +17,8 @@ class LocalDirectorySyncGuard final : public ISyncGuard public: /// NOTE: If you have already opened descriptor, it's preferred to use /// this constructor instead of constructor with path. - LocalDirectorySyncGuard(int fd_) : fd(fd_) {} - LocalDirectorySyncGuard(const String & full_path); + explicit LocalDirectorySyncGuard(int fd_) : fd(fd_) {} + explicit LocalDirectorySyncGuard(const String & full_path); ~LocalDirectorySyncGuard() override; private: diff --git a/src/Disks/TemporaryFileOnDisk.h b/src/Disks/TemporaryFileOnDisk.h index c854a600146..b82cb7d2254 100644 --- a/src/Disks/TemporaryFileOnDisk.h +++ b/src/Disks/TemporaryFileOnDisk.h @@ -15,7 +15,7 @@ using DiskPtr = std::shared_ptr; class TemporaryFileOnDisk { public: - TemporaryFileOnDisk(const DiskPtr & disk_, const String & prefix_ = "tmp"); + explicit TemporaryFileOnDisk(const DiskPtr & disk_, const String & prefix_ = "tmp"); ~TemporaryFileOnDisk(); DiskPtr getDisk() const { return disk; } diff --git a/src/Formats/CapnProtoUtils.h b/src/Formats/CapnProtoUtils.h index 51c152de17f..47fe3ada7cd 100644 --- a/src/Formats/CapnProtoUtils.h +++ b/src/Formats/CapnProtoUtils.h @@ -18,14 +18,14 @@ struct DestructorCatcher { T impl; template - DestructorCatcher(Arg && ... args) : impl(kj::fwd(args)...) {} + explicit DestructorCatcher(Arg && ... args) : impl(kj::fwd(args)...) {} ~DestructorCatcher() noexcept try { } catch (...) { return; } }; class CapnProtoSchemaParser : public DestructorCatcher { public: - CapnProtoSchemaParser() {} + CapnProtoSchemaParser() = default; capnp::StructSchema getMessageSchema(const FormatSchemaInfo & schema_info); }; diff --git a/src/Formats/JSONEachRowUtils.h b/src/Formats/JSONEachRowUtils.h index 6f71baa8b40..8d304e2ffd8 100644 --- a/src/Formats/JSONEachRowUtils.h +++ b/src/Formats/JSONEachRowUtils.h @@ -1,5 +1,7 @@ #pragma once +#include +#include #include #include #include diff --git a/src/Formats/MarkInCompressedFile.h b/src/Formats/MarkInCompressedFile.h index ceefde43615..1cd545e1a03 100644 --- a/src/Formats/MarkInCompressedFile.h +++ b/src/Formats/MarkInCompressedFile.h @@ -33,7 +33,7 @@ struct MarkInCompressedFile return "(" + DB::toString(offset_in_compressed_file) + "," + DB::toString(offset_in_decompressed_block) + ")"; } - String toStringWithRows(size_t rows_num) + String toStringWithRows(size_t rows_num) const { return "(" + DB::toString(offset_in_compressed_file) + "," + DB::toString(offset_in_decompressed_block) + "," + DB::toString(rows_num) + ")"; } @@ -43,7 +43,7 @@ struct MarkInCompressedFile class MarksInCompressedFile : public PODArray { public: - MarksInCompressedFile(size_t n) : PODArray(n) {} + explicit MarksInCompressedFile(size_t n) : PODArray(n) {} void read(ReadBuffer & buffer, size_t from, size_t count) { diff --git a/src/Formats/ParsedTemplateFormatString.h b/src/Formats/ParsedTemplateFormatString.h index c5617d0f0ef..5d7ee820f2f 100644 --- a/src/Formats/ParsedTemplateFormatString.h +++ b/src/Formats/ParsedTemplateFormatString.h @@ -28,7 +28,7 @@ struct ParsedTemplateFormatString /// For diagnostic info Strings column_names; - typedef std::function(const String &)> ColumnIdxGetter; + using ColumnIdxGetter = std::function(const String &)>; ParsedTemplateFormatString() = default; ParsedTemplateFormatString(const FormatSchemaInfo & schema, const ColumnIdxGetter & idx_by_name, bool allow_indexes = true); diff --git a/src/Formats/ProtobufReader.h b/src/Formats/ProtobufReader.h index 0df139eeacd..2e2a71a7d11 100644 --- a/src/Formats/ProtobufReader.h +++ b/src/Formats/ProtobufReader.h @@ -16,7 +16,7 @@ class ReadBuffer; class ProtobufReader { public: - ProtobufReader(ReadBuffer & in_); + explicit ProtobufReader(ReadBuffer & in_); void startMessage(bool with_length_delimiter_); void endMessage(bool ignore_errors); diff --git a/src/Formats/ProtobufWriter.h b/src/Formats/ProtobufWriter.h index c564db110cc..1dcc8f4ef7c 100644 --- a/src/Formats/ProtobufWriter.h +++ b/src/Formats/ProtobufWriter.h @@ -16,7 +16,7 @@ class WriteBuffer; class ProtobufWriter { public: - ProtobufWriter(WriteBuffer & out_); + explicit ProtobufWriter(WriteBuffer & out_); ~ProtobufWriter(); void startMessage(); diff --git a/src/Formats/RowInputMissingColumnsFiller.h b/src/Formats/RowInputMissingColumnsFiller.h index 0eaefd4e814..9785d8bed62 100644 --- a/src/Formats/RowInputMissingColumnsFiller.h +++ b/src/Formats/RowInputMissingColumnsFiller.h @@ -14,7 +14,7 @@ class RowInputMissingColumnsFiller { public: /// Makes a column filler which checks nested structures while adding default values to columns. - RowInputMissingColumnsFiller(const NamesAndTypesList & names_and_types); + explicit RowInputMissingColumnsFiller(const NamesAndTypesList & names_and_types); RowInputMissingColumnsFiller(const Names & names, const DataTypes & types); RowInputMissingColumnsFiller(size_t count, const std::string_view * names, const DataTypePtr * types); diff --git a/src/Functions/CountSubstringsImpl.h b/src/Functions/CountSubstringsImpl.h index 6668ca0a392..fc6e4a0e671 100644 --- a/src/Functions/CountSubstringsImpl.h +++ b/src/Functions/CountSubstringsImpl.h @@ -83,7 +83,7 @@ struct CountSubstringsImpl { res = 0; - if (needle.size() == 0) + if (needle.empty()) return; auto start = std::max(start_pos, UInt64(1)); diff --git a/src/Functions/DivisionUtils.h b/src/Functions/DivisionUtils.h index 2e601888ecc..c246f7fd31a 100644 --- a/src/Functions/DivisionUtils.h +++ b/src/Functions/DivisionUtils.h @@ -6,6 +6,7 @@ #include #include +#include "config_core.h" #include diff --git a/src/Functions/DummyJSONParser.h b/src/Functions/DummyJSONParser.h index c14aacece86..77b958d1429 100644 --- a/src/Functions/DummyJSONParser.h +++ b/src/Functions/DummyJSONParser.h @@ -2,6 +2,8 @@ #include #include +#include + namespace DB { @@ -22,25 +24,25 @@ struct DummyJSONParser class Element { public: - Element() {} - bool isInt64() const { return false; } - bool isUInt64() const { return false; } - bool isDouble() const { return false; } - bool isString() const { return false; } - bool isArray() const { return false; } - bool isObject() const { return false; } - bool isBool() const { return false; } - bool isNull() const { return false; } + Element() = default; + static bool isInt64() { return false; } + static bool isUInt64() { return false; } + static bool isDouble() { return false; } + static bool isString() { return false; } + static bool isArray() { return false; } + static bool isObject() { return false; } + static bool isBool() { return false; } + static bool isNull() { return false; } - Int64 getInt64() const { return 0; } - UInt64 getUInt64() const { return 0; } - double getDouble() const { return 0; } - bool getBool() const { return false; } - std::string_view getString() const { return {}; } - Array getArray() const { return {}; } - Object getObject() const { return {}; } + static Int64 getInt64() { return 0; } + static UInt64 getUInt64() { return 0; } + static double getDouble() { return 0; } + static bool getBool() { return false; } + static std::string_view getString() { return {}; } + static Array getArray() { return {}; } + static Object getObject() { return {}; } - Element getElement() { return {}; } + static Element getElement() { return {}; } }; /// References an array in a JSON document. @@ -52,14 +54,14 @@ struct DummyJSONParser public: Element operator*() const { return {}; } Iterator & operator++() { return *this; } - Iterator operator++(int) { return *this; } + Iterator operator++(int) { return *this; } /// NOLINT friend bool operator==(const Iterator &, const Iterator &) { return true; } friend bool operator!=(const Iterator &, const Iterator &) { return false; } }; - Iterator begin() const { return {}; } - Iterator end() const { return {}; } - size_t size() const { return 0; } + static Iterator begin() { return {}; } + static Iterator end() { return {}; } + static size_t size() { return 0; } Element operator[](size_t) const { return {}; } }; @@ -74,15 +76,15 @@ struct DummyJSONParser public: KeyValuePair operator*() const { return {}; } Iterator & operator++() { return *this; } - Iterator operator++(int) { return *this; } + Iterator operator++(int) { return *this; } /// NOLINT friend bool operator==(const Iterator &, const Iterator &) { return true; } friend bool operator!=(const Iterator &, const Iterator &) { return false; } }; - Iterator begin() const { return {}; } - Iterator end() const { return {}; } - size_t size() const { return 0; } - bool find(const std::string_view &, Element &) const { return false; } + static Iterator begin() { return {}; } + static Iterator end() { return {}; } + static size_t size() { return 0; } + bool find(const std::string_view &, Element &) const { return false; } /// NOLINT #if 0 /// Optional: Provides access to an object's element by index. @@ -91,7 +93,7 @@ struct DummyJSONParser }; /// Parses a JSON document, returns the reference to its root element if succeeded. - bool parse(const std::string_view &, Element &) { throw Exception{"Functions JSON* are not supported", ErrorCodes::NOT_IMPLEMENTED}; } + bool parse(const std::string_view &, Element &) { throw Exception{"Functions JSON* are not supported", ErrorCodes::NOT_IMPLEMENTED}; } /// NOLINT #if 0 /// Optional: Allocates memory to parse JSON documents faster. diff --git a/src/Functions/EmptyImpl.h b/src/Functions/EmptyImpl.h index 60daa66ea03..6f5c4f7a7dc 100644 --- a/src/Functions/EmptyImpl.h +++ b/src/Functions/EmptyImpl.h @@ -2,6 +2,7 @@ #include #include +#include #include diff --git a/src/Functions/FunctionBitTestMany.h b/src/Functions/FunctionBitTestMany.h index 808c3711631..e49af4c166f 100644 --- a/src/Functions/FunctionBitTestMany.h +++ b/src/Functions/FunctionBitTestMany.h @@ -5,6 +5,7 @@ #include #include #include +#include #include diff --git a/src/Functions/FunctionCustomWeekToSomething.h b/src/Functions/FunctionCustomWeekToSomething.h index 542062151ce..6ed751fd889 100644 --- a/src/Functions/FunctionCustomWeekToSomething.h +++ b/src/Functions/FunctionCustomWeekToSomething.h @@ -7,6 +7,7 @@ #include #include #include +#include namespace DB diff --git a/src/Functions/FunctionSQLJSON.h b/src/Functions/FunctionSQLJSON.h index d860da62b9d..56d29e0c776 100644 --- a/src/Functions/FunctionSQLJSON.h +++ b/src/Functions/FunctionSQLJSON.h @@ -242,7 +242,7 @@ public: GeneratorJSONPath generator_json_path(query_ptr); Element current_element = root; VisitorStatus status; - Element res; + while ((status = generator_json_path.getNextItem(current_element)) != VisitorStatus::Exhausted) { if (status == VisitorStatus::Ok) diff --git a/src/Functions/FunctionSnowflake.h b/src/Functions/FunctionSnowflake.h index 1ba15433e94..f4a62e509ed 100644 --- a/src/Functions/FunctionSnowflake.h +++ b/src/Functions/FunctionSnowflake.h @@ -24,7 +24,7 @@ namespace ErrorCodes * https://blog.twitter.com/engineering/en_us/a/2010/announcing-snowflake * https://ws-dl.blogspot.com/2019/08/2019-08-03-tweetedat-finding-tweet.html */ -static constexpr long snowflake_epoch = 1288834974657L; +static constexpr size_t snowflake_epoch = 1288834974657L; static constexpr int time_shift = 22; class FunctionDateTimeToSnowflake : public IFunction @@ -33,7 +33,7 @@ private: const char * name; public: - FunctionDateTimeToSnowflake(const char * name_) : name(name_) { } + explicit FunctionDateTimeToSnowflake(const char * name_) : name(name_) { } String getName() const override { return name; } size_t getNumberOfArguments() const override { return 1; } @@ -74,7 +74,7 @@ private: const char * name; public: - FunctionSnowflakeToDateTime(const char * name_) : name(name_) { } + explicit FunctionSnowflakeToDateTime(const char * name_) : name(name_) { } String getName() const override { return name; } size_t getNumberOfArguments() const override { return 0; } @@ -84,7 +84,7 @@ public: DataTypePtr getReturnTypeImpl(const ColumnsWithTypeAndName & arguments) const override { - if (arguments.size() < 1 || arguments.size() > 2) + if (arguments.empty() || arguments.size() > 2) throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Function {} takes one or two arguments", name); if (!typeid_cast(arguments[0].type.get())) @@ -122,7 +122,7 @@ private: const char * name; public: - FunctionDateTime64ToSnowflake(const char * name_) : name(name_) { } + explicit FunctionDateTime64ToSnowflake(const char * name_) : name(name_) { } String getName() const override { return name; } size_t getNumberOfArguments() const override { return 1; } @@ -163,7 +163,7 @@ private: const char * name; public: - FunctionSnowflakeToDateTime64(const char * name_) : name(name_) { } + explicit FunctionSnowflakeToDateTime64(const char * name_) : name(name_) { } String getName() const override { return name; } size_t getNumberOfArguments() const override { return 0; } @@ -173,7 +173,7 @@ public: DataTypePtr getReturnTypeImpl(const ColumnsWithTypeAndName & arguments) const override { - if (arguments.size() < 1 || arguments.size() > 2) + if (arguments.empty() || arguments.size() > 2) throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Function {} takes one or two arguments", name); if (!typeid_cast(arguments[0].type.get())) diff --git a/src/Functions/FunctionStringOrArrayToT.h b/src/Functions/FunctionStringOrArrayToT.h index 3bf1f0a5d34..cda5da5c177 100644 --- a/src/Functions/FunctionStringOrArrayToT.h +++ b/src/Functions/FunctionStringOrArrayToT.h @@ -9,6 +9,7 @@ #include #include #include +#include namespace DB diff --git a/src/Functions/FunctionsBitmap.h b/src/Functions/FunctionsBitmap.h index 775a39f4d08..1e48588892a 100644 --- a/src/Functions/FunctionsBitmap.h +++ b/src/Functions/FunctionsBitmap.h @@ -421,7 +421,7 @@ private: for (size_t i = 0; i < input_rows_count; ++i) { - const AggregateDataPtr data_ptr_0 = is_column_const[0] ? (*container0)[0] : (*container0)[i]; + AggregateDataPtr data_ptr_0 = is_column_const[0] ? (*container0)[0] : (*container0)[i]; const AggregateFunctionGroupBitmapData & bitmap_data_0 = *reinterpret_cast*>(data_ptr_0); const UInt64 range_start = is_column_const[1] ? (*container1)[0] : (*container1)[i]; @@ -615,7 +615,7 @@ private: size_t to_end; for (size_t i = 0; i < input_rows_count; ++i) { - const AggregateDataPtr data_ptr_0 = is_column_const[0] ? (*container0)[0] : (*container0)[i]; + AggregateDataPtr data_ptr_0 = is_column_const[0] ? (*container0)[0] : (*container0)[i]; const AggregateFunctionGroupBitmapData & bitmap_data_0 = *reinterpret_cast *>(data_ptr_0); if (is_column_const[1]) @@ -923,7 +923,7 @@ private: for (size_t i = 0; i < input_rows_count; ++i) { - const AggregateDataPtr data_ptr_0 = is_column_const[0] ? (*container0)[0] : (*container0)[i]; + AggregateDataPtr data_ptr_0 = is_column_const[0] ? (*container0)[0] : (*container0)[i]; const UInt64 data1 = is_column_const[1] ? (*container1)[0] : (*container1)[i]; const AggregateFunctionGroupBitmapData & bitmap_data_0 = *reinterpret_cast *>(data_ptr_0); @@ -1030,8 +1030,8 @@ private: for (size_t i = 0; i < input_rows_count; ++i) { - const AggregateDataPtr data_ptr_0 = is_column_const[0] ? container0[0] : container0[i]; - const AggregateDataPtr data_ptr_1 = is_column_const[1] ? container1[0] : container1[i]; + AggregateDataPtr data_ptr_0 = is_column_const[0] ? container0[0] : container0[i]; + AggregateDataPtr data_ptr_1 = is_column_const[1] ? container1[0] : container1[i]; const AggregateFunctionGroupBitmapData & bitmap_data_1 = *reinterpret_cast *>(data_ptr_0); const AggregateFunctionGroupBitmapData & bitmap_data_2 @@ -1178,8 +1178,8 @@ private: for (size_t i = 0; i < input_rows_count; ++i) { - const AggregateDataPtr data_ptr_0 = is_column_const[0] ? container0[0] : container0[i]; - const AggregateDataPtr data_ptr_1 = is_column_const[1] ? container1[0] : container1[i]; + AggregateDataPtr data_ptr_0 = is_column_const[0] ? container0[0] : container0[i]; + AggregateDataPtr data_ptr_1 = is_column_const[1] ? container1[0] : container1[i]; // bitmapAnd(RoaringBitMap, SmallSet) is slower than bitmapAnd(SmallSet, RoaringBitMap), so we can exchange the position of two arguments for the speed auto * bm_1 = reinterpret_cast *>(data_ptr_0); diff --git a/src/Functions/FunctionsComparison.h b/src/Functions/FunctionsComparison.h index a0c7fc643d2..0d0195eb2d7 100644 --- a/src/Functions/FunctionsComparison.h +++ b/src/Functions/FunctionsComparison.h @@ -137,7 +137,7 @@ struct NumComparisonImpl template struct StringComparisonImpl { - static void NO_INLINE string_vector_string_vector( + static void NO_INLINE string_vector_string_vector( /// NOLINT const ColumnString::Chars & a_data, const ColumnString::Offsets & a_offsets, const ColumnString::Chars & b_data, const ColumnString::Offsets & b_offsets, PaddedPODArray & c) @@ -157,7 +157,7 @@ struct StringComparisonImpl } } - static void NO_INLINE string_vector_fixed_string_vector( + static void NO_INLINE string_vector_fixed_string_vector( /// NOLINT const ColumnString::Chars & a_data, const ColumnString::Offsets & a_offsets, const ColumnString::Chars & b_data, ColumnString::Offset b_n, PaddedPODArray & c) @@ -175,7 +175,7 @@ struct StringComparisonImpl } } - static void NO_INLINE string_vector_constant( + static void NO_INLINE string_vector_constant( /// NOLINT const ColumnString::Chars & a_data, const ColumnString::Offsets & a_offsets, const ColumnString::Chars & b_data, ColumnString::Offset b_size, PaddedPODArray & c) @@ -193,7 +193,7 @@ struct StringComparisonImpl } } - static void fixed_string_vector_string_vector( + static void fixed_string_vector_string_vector( /// NOLINT const ColumnString::Chars & a_data, ColumnString::Offset a_n, const ColumnString::Chars & b_data, const ColumnString::Offsets & b_offsets, PaddedPODArray & c) @@ -201,7 +201,7 @@ struct StringComparisonImpl StringComparisonImpl::string_vector_fixed_string_vector(b_data, b_offsets, a_data, a_n, c); } - static void NO_INLINE fixed_string_vector_fixed_string_vector_16( + static void NO_INLINE fixed_string_vector_fixed_string_vector_16( /// NOLINT const ColumnString::Chars & a_data, const ColumnString::Chars & b_data, PaddedPODArray & c) @@ -212,7 +212,7 @@ struct StringComparisonImpl c[j] = Op::apply(memcmp16(&a_data[i], &b_data[i]), 0); } - static void NO_INLINE fixed_string_vector_constant_16( + static void NO_INLINE fixed_string_vector_constant_16( /// NOLINT const ColumnString::Chars & a_data, const ColumnString::Chars & b_data, PaddedPODArray & c) @@ -223,7 +223,7 @@ struct StringComparisonImpl c[j] = Op::apply(memcmp16(&a_data[i], &b_data[0]), 0); } - static void NO_INLINE fixed_string_vector_fixed_string_vector( + static void NO_INLINE fixed_string_vector_fixed_string_vector( /// NOLINT const ColumnString::Chars & a_data, ColumnString::Offset a_n, const ColumnString::Chars & b_data, ColumnString::Offset b_n, PaddedPODArray & c) @@ -250,7 +250,7 @@ struct StringComparisonImpl } } - static void NO_INLINE fixed_string_vector_constant( + static void NO_INLINE fixed_string_vector_constant( /// NOLINT const ColumnString::Chars & a_data, ColumnString::Offset a_n, const ColumnString::Chars & b_data, ColumnString::Offset b_size, PaddedPODArray & c) @@ -273,7 +273,7 @@ struct StringComparisonImpl } } - static void constant_string_vector( + static void constant_string_vector( /// NOLINT const ColumnString::Chars & a_data, ColumnString::Offset a_size, const ColumnString::Chars & b_data, const ColumnString::Offsets & b_offsets, PaddedPODArray & c) @@ -281,7 +281,7 @@ struct StringComparisonImpl StringComparisonImpl::string_vector_constant(b_data, b_offsets, a_data, a_size, c); } - static void constant_fixed_string_vector( + static void constant_fixed_string_vector( /// NOLINT const ColumnString::Chars & a_data, ColumnString::Offset a_size, const ColumnString::Chars & b_data, ColumnString::Offset b_n, PaddedPODArray & c) @@ -295,7 +295,7 @@ struct StringComparisonImpl template struct StringEqualsImpl { - static void NO_INLINE string_vector_string_vector( + static void NO_INLINE string_vector_string_vector( /// NOLINT const ColumnString::Chars & a_data, const ColumnString::Offsets & a_offsets, const ColumnString::Chars & b_data, const ColumnString::Offsets & b_offsets, PaddedPODArray & c) @@ -318,7 +318,7 @@ struct StringEqualsImpl } } - static void NO_INLINE string_vector_fixed_string_vector( + static void NO_INLINE string_vector_fixed_string_vector( /// NOLINT const ColumnString::Chars & a_data, const ColumnString::Offsets & a_offsets, const ColumnString::Chars & b_data, ColumnString::Offset b_n, PaddedPODArray & c) @@ -338,7 +338,7 @@ struct StringEqualsImpl } } - static void NO_INLINE string_vector_constant( + static void NO_INLINE string_vector_constant( /// NOLINT const ColumnString::Chars & a_data, const ColumnString::Offsets & a_offsets, const ColumnString::Chars & b_data, ColumnString::Offset b_size, PaddedPODArray & c) @@ -358,7 +358,7 @@ struct StringEqualsImpl } } - static void NO_INLINE fixed_string_vector_fixed_string_vector_16( + static void NO_INLINE fixed_string_vector_fixed_string_vector_16( /// NOLINT const ColumnString::Chars & a_data, const ColumnString::Chars & b_data, PaddedPODArray & c) @@ -371,7 +371,7 @@ struct StringEqualsImpl b_data.data() + i * 16); } - static void NO_INLINE fixed_string_vector_constant_16( + static void NO_INLINE fixed_string_vector_constant_16( /// NOLINT const ColumnString::Chars & a_data, const ColumnString::Chars & b_data, PaddedPODArray & c) @@ -384,7 +384,7 @@ struct StringEqualsImpl b_data.data()); } - static void NO_INLINE fixed_string_vector_fixed_string_vector( + static void NO_INLINE fixed_string_vector_fixed_string_vector( /// NOLINT const ColumnString::Chars & a_data, ColumnString::Offset a_n, const ColumnString::Chars & b_data, ColumnString::Offset b_n, PaddedPODArray & c) @@ -410,7 +410,7 @@ struct StringEqualsImpl } } - static void NO_INLINE fixed_string_vector_constant( + static void NO_INLINE fixed_string_vector_constant( /// NOLINT const ColumnString::Chars & a_data, ColumnString::Offset a_n, const ColumnString::Chars & b_data, ColumnString::Offset b_size, PaddedPODArray & c) @@ -427,7 +427,7 @@ struct StringEqualsImpl } } - static void fixed_string_vector_string_vector( + static void fixed_string_vector_string_vector( /// NOLINT const ColumnString::Chars & a_data, ColumnString::Offset a_n, const ColumnString::Chars & b_data, const ColumnString::Offsets & b_offsets, PaddedPODArray & c) @@ -435,7 +435,7 @@ struct StringEqualsImpl string_vector_fixed_string_vector(b_data, b_offsets, a_data, a_n, c); } - static void constant_string_vector( + static void constant_string_vector( /// NOLINT const ColumnString::Chars & a_data, ColumnString::Offset a_size, const ColumnString::Chars & b_data, const ColumnString::Offsets & b_offsets, PaddedPODArray & c) @@ -443,7 +443,7 @@ struct StringEqualsImpl string_vector_constant(b_data, b_offsets, a_data, a_size, c); } - static void constant_fixed_string_vector( + static void constant_fixed_string_vector( /// NOLINT const ColumnString::Chars & a_data, ColumnString::Offset a_size, const ColumnString::Chars & b_data, ColumnString::Offset b_n, PaddedPODArray & c) diff --git a/src/Functions/FunctionsConversion.h b/src/Functions/FunctionsConversion.h index f75d67032f2..5e11cab7e79 100644 --- a/src/Functions/FunctionsConversion.h +++ b/src/Functions/FunctionsConversion.h @@ -542,7 +542,7 @@ struct ToDateTime64TransformUnsigned const DateTime64::NativeType scale_multiplier = 1; - ToDateTime64TransformUnsigned(UInt32 scale = 0) + ToDateTime64TransformUnsigned(UInt32 scale = 0) /// NOLINT : scale_multiplier(DecimalUtils::scaleMultiplier(scale)) {} @@ -559,7 +559,7 @@ struct ToDateTime64TransformSigned const DateTime64::NativeType scale_multiplier = 1; - ToDateTime64TransformSigned(UInt32 scale = 0) + ToDateTime64TransformSigned(UInt32 scale = 0) /// NOLINT : scale_multiplier(DecimalUtils::scaleMultiplier(scale)) {} @@ -577,7 +577,7 @@ struct ToDateTime64TransformFloat const UInt32 scale = 1; - ToDateTime64TransformFloat(UInt32 scale_ = 0) + ToDateTime64TransformFloat(UInt32 scale_ = 0) /// NOLINT : scale(scale_) {} @@ -615,7 +615,7 @@ struct FromDateTime64Transform const DateTime64::NativeType scale_multiplier = 1; - FromDateTime64Transform(UInt32 scale) + FromDateTime64Transform(UInt32 scale) /// NOLINT : scale_multiplier(DecimalUtils::scaleMultiplier(scale)) {} @@ -639,7 +639,7 @@ struct ToDateTime64Transform const DateTime64::NativeType scale_multiplier = 1; - ToDateTime64Transform(UInt32 scale = 0) + ToDateTime64Transform(UInt32 scale = 0) /// NOLINT : scale_multiplier(DecimalUtils::scaleMultiplier(scale)) {} diff --git a/src/Functions/FunctionsExternalDictionaries.h b/src/Functions/FunctionsExternalDictionaries.h index 7e26de574aa..6a701d7b864 100644 --- a/src/Functions/FunctionsExternalDictionaries.h +++ b/src/Functions/FunctionsExternalDictionaries.h @@ -897,7 +897,9 @@ private: result = std::move(dictionary_get_result_column); } else - result = ColumnNullable::create(std::move(dictionary_get_result_column), std::move(is_key_in_dictionary_column_mutable)); + { + result = ColumnNullable::create(dictionary_get_result_column, std::move(is_key_in_dictionary_column_mutable)); + } } return result; diff --git a/src/Functions/FunctionsLogical.h b/src/Functions/FunctionsLogical.h index 7d4f5489e86..140981faf9f 100644 --- a/src/Functions/FunctionsLogical.h +++ b/src/Functions/FunctionsLogical.h @@ -7,6 +7,7 @@ #include #include #include +#include #if USE_EMBEDDED_COMPILER @@ -147,7 +148,6 @@ public: static constexpr auto name = Name::name; static FunctionPtr create(ContextPtr) { return std::make_shared(); } -public: String getName() const override { return name; @@ -189,7 +189,7 @@ public: result = Impl::apply(b, result, nativeBoolCast(b, types[i], values[i])); return b.CreateSelect(result, b.getInt8(1), b.getInt8(0)); } - constexpr bool breakOnTrue = Impl::isSaturatedValue(true); + constexpr bool break_on_true = Impl::isSaturatedValue(true); auto * next = b.GetInsertBlock(); auto * stop = llvm::BasicBlock::Create(next->getContext(), "", next->getParent()); b.SetInsertPoint(stop); @@ -205,7 +205,7 @@ public: if (i + 1 < types.size()) { next = llvm::BasicBlock::Create(next->getContext(), "", next->getParent()); - b.CreateCondBr(truth, breakOnTrue ? stop : next, breakOnTrue ? next : stop); + b.CreateCondBr(truth, break_on_true ? stop : next, break_on_true ? next : stop); } } b.CreateBr(stop); @@ -223,7 +223,6 @@ public: static constexpr auto name = Name::name; static FunctionPtr create(ContextPtr) { return std::make_shared(); } -public: String getName() const override { return name; diff --git a/src/Functions/FunctionsStringArray.h b/src/Functions/FunctionsStringArray.h index b1de017120c..a1256598f1b 100644 --- a/src/Functions/FunctionsStringArray.h +++ b/src/Functions/FunctionsStringArray.h @@ -93,7 +93,7 @@ public: } /// Returns the position of the argument, that is the column of strings - size_t getStringsArgumentPosition() + static size_t getStringsArgumentPosition() { return 0; } @@ -152,7 +152,7 @@ public: } /// Returns the position of the argument, that is the column of strings - size_t getStringsArgumentPosition() + static size_t getStringsArgumentPosition() { return 0; } @@ -211,7 +211,7 @@ public: } /// Returns the position of the argument, that is the column of strings - size_t getStringsArgumentPosition() + static size_t getStringsArgumentPosition() { return 0; } @@ -328,7 +328,7 @@ public: } /// Returns the position of the argument, that is the column of strings - size_t getStringsArgumentPosition() + static size_t getStringsArgumentPosition() { return 1; } @@ -399,7 +399,7 @@ public: } /// Returns the position of the argument that is the column of strings - size_t getStringsArgumentPosition() + static size_t getStringsArgumentPosition() { return 1; } @@ -482,7 +482,7 @@ public: } /// Returns the position of the argument that is the column of strings - size_t getStringsArgumentPosition() + static size_t getStringsArgumentPosition() { return 1; } @@ -567,7 +567,7 @@ public: } /// Returns the position of the argument that is the column of strings - size_t getStringsArgumentPosition() + static size_t getStringsArgumentPosition() { return 0; } diff --git a/src/Functions/GatherUtils/Algorithms.h b/src/Functions/GatherUtils/Algorithms.h index 2d4544b2167..d08248e71fc 100644 --- a/src/Functions/GatherUtils/Algorithms.h +++ b/src/Functions/GatherUtils/Algorithms.h @@ -203,7 +203,7 @@ void concat(const std::vector> & array_sources, Si size_t sources_num = array_sources.size(); std::vector is_const(sources_num); - auto checkAndGetSizeToReserve = [] (auto source, IArraySource * array_source) + auto check_and_get_size_to_reserve = [] (auto source, IArraySource * array_source) { if (source == nullptr) throw Exception("Concat function expected " + demangle(typeid(Source).name()) + " or " @@ -215,17 +215,17 @@ void concat(const std::vector> & array_sources, Si size_t size_to_reserve = 0; for (auto i : collections::range(0, sources_num)) { - auto & source = array_sources[i]; + const auto & source = array_sources[i]; is_const[i] = source->isConst(); if (is_const[i]) - size_to_reserve += checkAndGetSizeToReserve(typeid_cast *>(source.get()), source.get()); + size_to_reserve += check_and_get_size_to_reserve(typeid_cast *>(source.get()), source.get()); else - size_to_reserve += checkAndGetSizeToReserve(typeid_cast(source.get()), source.get()); + size_to_reserve += check_and_get_size_to_reserve(typeid_cast(source.get()), source.get()); } sink.reserve(size_to_reserve); - auto writeNext = [& sink] (auto source) + auto write_next = [& sink] (auto source) { writeSlice(source->getWhole(), sink); source->next(); @@ -235,11 +235,11 @@ void concat(const std::vector> & array_sources, Si { for (auto i : collections::range(0, sources_num)) { - auto & source = array_sources[i]; + const auto & source = array_sources[i]; if (is_const[i]) - writeNext(static_cast *>(source.get())); + write_next(static_cast *>(source.get())); else - writeNext(static_cast(source.get())); + write_next(static_cast(source.get())); } sink.next(); } @@ -576,31 +576,31 @@ bool sliceHasImplSubstr(const FirstSliceType & first, const SecondSliceType & se [](const SecondSliceType & pattern, size_t i, size_t j) { return isEqualUnary(pattern, i, j); }); } - size_t firstCur = 0; - size_t secondCur = 0; - while (firstCur < first.size && secondCur < second.size) + size_t first_cur = 0; + size_t second_cur = 0; + while (first_cur < first.size && second_cur < second.size) { - const bool is_first_null = has_first_null_map && first_null_map[firstCur]; - const bool is_second_null = has_second_null_map && second_null_map[secondCur]; + const bool is_first_null = has_first_null_map && first_null_map[first_cur]; + const bool is_second_null = has_second_null_map && second_null_map[second_cur]; const bool cond_both_null_match = is_first_null && is_second_null; const bool cond_both_not_null = !is_first_null && !is_second_null; - if (cond_both_null_match || (cond_both_not_null && isEqual(first, second, firstCur, secondCur))) + if (cond_both_null_match || (cond_both_not_null && isEqual(first, second, first_cur, second_cur))) { - ++firstCur; - ++secondCur; + ++first_cur; + ++second_cur; } - else if (secondCur > 0) + else if (second_cur > 0) { - secondCur = prefix_function[secondCur - 1]; + second_cur = prefix_function[second_cur - 1]; } else { - ++firstCur; + ++first_cur; } } - return secondCur == second.size; + return second_cur == second.size; } diff --git a/src/Functions/GatherUtils/Selectors.h b/src/Functions/GatherUtils/Selectors.h index bbe631a6a3a..5793701e93a 100644 --- a/src/Functions/GatherUtils/Selectors.h +++ b/src/Functions/GatherUtils/Selectors.h @@ -131,7 +131,7 @@ struct ArrayAndValueSourceSelectorBySink : public ArraySinkSelector).name()) + " but got " + demangle(typeid(*source_ptr).name()), ErrorCodes::LOGICAL_ERROR); }; - auto checkTypeAndCallConcat = [& sink, & checkType, & args ...] (auto array_source_ptr, auto value_source_ptr) + auto check_type_and_call_concat = [& sink, & check_type, & args ...] (auto array_source_ptr, auto value_source_ptr) { - checkType(array_source_ptr); - checkType(value_source_ptr); + check_type(array_source_ptr); + check_type(value_source_ptr); Base::selectArrayAndValueSourceBySink(*array_source_ptr, *value_source_ptr, sink, args ...); }; if (array_source.isConst() && value_source.isConst()) - checkTypeAndCallConcat(typeid_cast *>(&array_source), + check_type_and_call_concat(typeid_cast *>(&array_source), typeid_cast *>(&value_source)); else if (array_source.isConst()) - checkTypeAndCallConcat(typeid_cast *>(&array_source), + check_type_and_call_concat(typeid_cast *>(&array_source), typeid_cast(&value_source)); else if (value_source.isConst()) - checkTypeAndCallConcat(typeid_cast(&array_source), + check_type_and_call_concat(typeid_cast(&array_source), typeid_cast *>(&value_source)); else - checkTypeAndCallConcat(typeid_cast(&array_source), + check_type_and_call_concat(typeid_cast(&array_source), typeid_cast(&value_source)); } }; diff --git a/src/Functions/GatherUtils/Slices.h b/src/Functions/GatherUtils/Slices.h index 7951178497a..22f475adf59 100644 --- a/src/Functions/GatherUtils/Slices.h +++ b/src/Functions/GatherUtils/Slices.h @@ -26,7 +26,7 @@ struct NullableSlice : public Slice const UInt8 * null_map = nullptr; NullableSlice() = default; - NullableSlice(const Slice & base) : Slice(base) {} + NullableSlice(const Slice & base) : Slice(base) {} /// NOLINT }; template diff --git a/src/Functions/GeoHash.h b/src/Functions/GeoHash.h index d97eda31cef..071bc5072a4 100644 --- a/src/Functions/GeoHash.h +++ b/src/Functions/GeoHash.h @@ -37,8 +37,8 @@ struct GeohashesInBoxPreparedArgs }; GeohashesInBoxPreparedArgs geohashesInBoxPrepare( - const Float64 longitude_min, - const Float64 latitude_min, + Float64 longitude_min, + Float64 latitude_min, Float64 longitude_max, Float64 latitude_max, uint8_t precision); diff --git a/src/Functions/GregorianDate.h b/src/Functions/GregorianDate.h index b44b6c0dd13..ef2b9e6eede 100644 --- a/src/Functions/GregorianDate.h +++ b/src/Functions/GregorianDate.h @@ -32,13 +32,13 @@ namespace DB /** Construct from date in text form 'YYYY-MM-DD' by reading from * ReadBuffer. */ - GregorianDate(ReadBuffer & in); + explicit GregorianDate(ReadBuffer & in); /** Construct from Modified Julian Day. The type T is an * integral type which should be at least 32 bits wide, and * should preferably signed. */ - GregorianDate(is_integer auto mjd); + explicit GregorianDate(is_integer auto mjd); /** Convert to Modified Julian Day. The type T is an integral type * which should be at least 32 bits wide, and should preferably @@ -65,15 +65,15 @@ namespace DB return month_; } - uint8_t day_of_month() const noexcept + uint8_t day_of_month() const noexcept /// NOLINT { return day_of_month_; } private: - YearT year_; - uint8_t month_; - uint8_t day_of_month_; + YearT year_; /// NOLINT + uint8_t month_; /// NOLINT + uint8_t day_of_month_; /// NOLINT }; /** ISO 8601 Ordinal Date. YearT is an integral type which should @@ -89,7 +89,7 @@ namespace DB * integral type which should be at least 32 bits wide, and * should preferably signed. */ - OrdinalDate(is_integer auto mjd); + explicit OrdinalDate(is_integer auto mjd); /** Convert to Modified Julian Day. The type T is an integral * type which should be at least 32 bits wide, and should @@ -109,8 +109,8 @@ namespace DB } private: - YearT year_; - uint16_t day_of_year_; + YearT year_; /// NOLINT + uint16_t day_of_year_; /// NOLINT }; class MonthDay @@ -134,14 +134,14 @@ namespace DB return month_; } - uint8_t day_of_month() const noexcept + uint8_t day_of_month() const noexcept /// NOLINT { return day_of_month_; } private: - uint8_t month_; - uint8_t day_of_month_; + uint8_t month_; /// NOLINT + uint8_t day_of_month_; /// NOLINT }; } @@ -183,13 +183,13 @@ namespace gd template static inline constexpr I div(I x, J y) { - const auto y_ = static_cast(y); - if (x > 0 && y_ < 0) - return ((x - 1) / y_) - 1; - else if (x < 0 && y_ > 0) - return ((x + 1) / y_) - 1; + const auto y_cast = static_cast(y); + if (x > 0 && y_cast < 0) + return ((x - 1) / y_cast) - 1; + else if (x < 0 && y_cast > 0) + return ((x + 1) / y_cast) - 1; else - return x / y_; + return x / y_cast; } /** Integer modulus, satisfying div(x, y)*y + mod(x, y) == x. @@ -197,10 +197,10 @@ namespace gd template static inline constexpr I mod(I x, J y) { - const auto y_ = static_cast(y); - const auto r = x % y_; - if ((x > 0 && y_ < 0) || (x < 0 && y_ > 0)) - return r == 0 ? static_cast(0) : r + y_; + const auto y_cast = static_cast(y); + const auto r = x % y_cast; + if ((x > 0 && y_cast < 0) || (x < 0 && y_cast > 0)) + return r == 0 ? static_cast(0) : r + y_cast; else return r; } @@ -210,8 +210,8 @@ namespace gd template static inline constexpr I min(I x, J y) { - const auto y_ = static_cast(y); - return x < y_ ? x : y_; + const auto y_cast = static_cast(y); + return x < y_cast ? x : y_cast; } static inline char readDigit(ReadBuffer & in) diff --git a/src/Functions/IFunction.h b/src/Functions/IFunction.h index 71af6149774..7b272fef53d 100644 --- a/src/Functions/IFunction.h +++ b/src/Functions/IFunction.h @@ -120,7 +120,7 @@ public: virtual ~IFunctionBase() = default; - virtual ColumnPtr execute( + virtual ColumnPtr execute( /// NOLINT const ColumnsWithTypeAndName & arguments, const DataTypePtr & result_type, size_t input_rows_count, bool dry_run = false) const { return prepare(arguments)->execute(arguments, result_type, input_rows_count, dry_run); diff --git a/src/Functions/ITupleFunction.h b/src/Functions/ITupleFunction.h index 836e5d273fc..0dbbb81aab9 100644 --- a/src/Functions/ITupleFunction.h +++ b/src/Functions/ITupleFunction.h @@ -1,6 +1,11 @@ #pragma once +#include +#include #include +#include +#include + namespace DB { diff --git a/src/Functions/JSONPath/ASTs/ASTJSONPathMemberAccess.h b/src/Functions/JSONPath/ASTs/ASTJSONPathMemberAccess.h index 2c9482b665e..3a5e121b989 100644 --- a/src/Functions/JSONPath/ASTs/ASTJSONPathMemberAccess.h +++ b/src/Functions/JSONPath/ASTs/ASTJSONPathMemberAccess.h @@ -11,7 +11,6 @@ public: ASTPtr clone() const override { return std::make_shared(*this); } -public: /// Member name to lookup in json document (in path: $.some_key.another_key. ...) String member_name; }; diff --git a/src/Functions/JSONPath/ASTs/ASTJSONPathRange.h b/src/Functions/JSONPath/ASTs/ASTJSONPathRange.h index 746c6211f29..083d4b8e3ab 100644 --- a/src/Functions/JSONPath/ASTs/ASTJSONPathRange.h +++ b/src/Functions/JSONPath/ASTs/ASTJSONPathRange.h @@ -12,7 +12,6 @@ public: ASTPtr clone() const override { return std::make_shared(*this); } -public: /// Ranges to lookup in json array ($[0, 1, 2, 4 to 9]) /// Range is represented as /// Single index is represented as diff --git a/src/Functions/JSONPath/Generator/GeneratorJSONPath.h b/src/Functions/JSONPath/Generator/GeneratorJSONPath.h index 291150f6df4..fe00f06bbbf 100644 --- a/src/Functions/JSONPath/Generator/GeneratorJSONPath.h +++ b/src/Functions/JSONPath/Generator/GeneratorJSONPath.h @@ -25,7 +25,7 @@ public: * Traverses children ASTs of ASTJSONPathQuery and creates a vector of corresponding visitors * @param query_ptr_ pointer to ASTJSONPathQuery */ - GeneratorJSONPath(ASTPtr query_ptr_) + explicit GeneratorJSONPath(ASTPtr query_ptr_) { query_ptr = query_ptr_; const auto * path = query_ptr->as(); diff --git a/src/Functions/JSONPath/Generator/VisitorJSONPathMemberAccess.h b/src/Functions/JSONPath/Generator/VisitorJSONPathMemberAccess.h index 5fe35e75a84..8446e1ff3be 100644 --- a/src/Functions/JSONPath/Generator/VisitorJSONPathMemberAccess.h +++ b/src/Functions/JSONPath/Generator/VisitorJSONPathMemberAccess.h @@ -10,7 +10,7 @@ template class VisitorJSONPathMemberAccess : public IVisitor { public: - VisitorJSONPathMemberAccess(ASTPtr member_access_ptr_) + explicit VisitorJSONPathMemberAccess(ASTPtr member_access_ptr_) : member_access_ptr(member_access_ptr_->as()) { } const char * getName() const override { return "VisitorJSONPathMemberAccess"; } diff --git a/src/Functions/JSONPath/Generator/VisitorJSONPathRange.h b/src/Functions/JSONPath/Generator/VisitorJSONPathRange.h index 40d4f6ad95e..708a71f7cf4 100644 --- a/src/Functions/JSONPath/Generator/VisitorJSONPathRange.h +++ b/src/Functions/JSONPath/Generator/VisitorJSONPathRange.h @@ -10,7 +10,7 @@ template class VisitorJSONPathRange : public IVisitor { public: - VisitorJSONPathRange(ASTPtr range_ptr_) : range_ptr(range_ptr_->as()) + explicit VisitorJSONPathRange(ASTPtr range_ptr_) : range_ptr(range_ptr_->as()) { current_range = 0; current_index = range_ptr->ranges[current_range].first; @@ -20,7 +20,6 @@ public: VisitorStatus apply(typename JSONParser::Element & element) const override { - typename JSONParser::Element result; typename JSONParser::Array array = element.getArray(); element = array[current_index]; return VisitorStatus::Ok; diff --git a/src/Functions/JSONPath/Generator/VisitorJSONPathRoot.h b/src/Functions/JSONPath/Generator/VisitorJSONPathRoot.h index 5c48c12782f..71569d3c0a0 100644 --- a/src/Functions/JSONPath/Generator/VisitorJSONPathRoot.h +++ b/src/Functions/JSONPath/Generator/VisitorJSONPathRoot.h @@ -10,7 +10,7 @@ template class VisitorJSONPathRoot : public IVisitor { public: - VisitorJSONPathRoot(ASTPtr) { } + explicit VisitorJSONPathRoot(ASTPtr) { } const char * getName() const override { return "VisitorJSONPathRoot"; } diff --git a/src/Functions/JSONPath/Generator/VisitorJSONPathStar.h b/src/Functions/JSONPath/Generator/VisitorJSONPathStar.h index 4a54a76c199..0c297f64316 100644 --- a/src/Functions/JSONPath/Generator/VisitorJSONPathStar.h +++ b/src/Functions/JSONPath/Generator/VisitorJSONPathStar.h @@ -10,7 +10,7 @@ template class VisitorJSONPathStar : public IVisitor { public: - VisitorJSONPathStar(ASTPtr) + explicit VisitorJSONPathStar(ASTPtr) { current_index = 0; } @@ -19,7 +19,6 @@ public: VisitorStatus apply(typename JSONParser::Element & element) const override { - typename JSONParser::Element result; typename JSONParser::Array array = element.getArray(); element = array[current_index]; return VisitorStatus::Ok; diff --git a/src/Functions/LeftRight.h b/src/Functions/LeftRight.h index 054e76b7792..a82182a52e7 100644 --- a/src/Functions/LeftRight.h +++ b/src/Functions/LeftRight.h @@ -12,6 +12,7 @@ #include #include #include +#include namespace DB diff --git a/src/Functions/LowerUpperImpl.h b/src/Functions/LowerUpperImpl.h index cf614850e66..a7c38a7f904 100644 --- a/src/Functions/LowerUpperImpl.h +++ b/src/Functions/LowerUpperImpl.h @@ -31,7 +31,7 @@ private: #ifdef __SSE2__ const auto bytes_sse = sizeof(__m128i); - const auto src_end_sse = src_end - (src_end - src) % bytes_sse; + const auto * src_end_sse = src_end - (src_end - src) % bytes_sse; const auto v_not_case_lower_bound = _mm_set1_epi8(not_case_lower_bound - 1); const auto v_not_case_upper_bound = _mm_set1_epi8(not_case_upper_bound + 1); diff --git a/src/Functions/LowerUpperUTF8Impl.h b/src/Functions/LowerUpperUTF8Impl.h index 4c155034b3d..a7475870dab 100644 --- a/src/Functions/LowerUpperUTF8Impl.h +++ b/src/Functions/LowerUpperUTF8Impl.h @@ -16,61 +16,58 @@ namespace ErrorCodes extern const int BAD_ARGUMENTS; } -namespace +/// xor or do nothing +template +UInt8 xor_or_identity(const UInt8 c, const int mask) { - /// xor or do nothing - template - UInt8 xor_or_identity(const UInt8 c, const int mask) - { - return c ^ mask; - } + return c ^ mask; +} - template <> - inline UInt8 xor_or_identity(const UInt8 c, const int) - { - return c; - } +template <> +inline UInt8 xor_or_identity(const UInt8 c, const int) +{ + return c; +} - /// It is caller's responsibility to ensure the presence of a valid cyrillic sequence in array - template - inline void UTF8CyrillicToCase(const UInt8 *& src, UInt8 *& dst) +/// It is caller's responsibility to ensure the presence of a valid cyrillic sequence in array +template +inline void UTF8CyrillicToCase(const UInt8 *& src, UInt8 *& dst) +{ + if (src[0] == 0xD0u && (src[1] >= 0x80u && src[1] <= 0x8Fu)) { - if (src[0] == 0xD0u && (src[1] >= 0x80u && src[1] <= 0x8Fu)) - { - /// ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏ - *dst++ = xor_or_identity(*src++, 0x1); - *dst++ = xor_or_identity(*src++, 0x10); - } - else if (src[0] == 0xD1u && (src[1] >= 0x90u && src[1] <= 0x9Fu)) - { - /// ѐёђѓєѕіїјљњћќѝўџ - *dst++ = xor_or_identity(*src++, 0x1); - *dst++ = xor_or_identity(*src++, 0x10); - } - else if (src[0] == 0xD0u && (src[1] >= 0x90u && src[1] <= 0x9Fu)) - { - /// А-П - *dst++ = *src++; - *dst++ = xor_or_identity(*src++, 0x20); - } - else if (src[0] == 0xD0u && (src[1] >= 0xB0u && src[1] <= 0xBFu)) - { - /// а-п - *dst++ = *src++; - *dst++ = xor_or_identity(*src++, 0x20); - } - else if (src[0] == 0xD0u && (src[1] >= 0xA0u && src[1] <= 0xAFu)) - { - /// Р-Я - *dst++ = xor_or_identity(*src++, 0x1); - *dst++ = xor_or_identity(*src++, 0x20); - } - else if (src[0] == 0xD1u && (src[1] >= 0x80u && src[1] <= 0x8Fu)) - { - /// р-я - *dst++ = xor_or_identity(*src++, 0x1); - *dst++ = xor_or_identity(*src++, 0x20); - } + /// ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏ + *dst++ = xor_or_identity(*src++, 0x1); + *dst++ = xor_or_identity(*src++, 0x10); + } + else if (src[0] == 0xD1u && (src[1] >= 0x90u && src[1] <= 0x9Fu)) + { + /// ѐёђѓєѕіїјљњћќѝўџ + *dst++ = xor_or_identity(*src++, 0x1); + *dst++ = xor_or_identity(*src++, 0x10); + } + else if (src[0] == 0xD0u && (src[1] >= 0x90u && src[1] <= 0x9Fu)) + { + /// А-П + *dst++ = *src++; + *dst++ = xor_or_identity(*src++, 0x20); + } + else if (src[0] == 0xD0u && (src[1] >= 0xB0u && src[1] <= 0xBFu)) + { + /// а-п + *dst++ = *src++; + *dst++ = xor_or_identity(*src++, 0x20); + } + else if (src[0] == 0xD0u && (src[1] >= 0xA0u && src[1] <= 0xAFu)) + { + /// Р-Я + *dst++ = xor_or_identity(*src++, 0x1); + *dst++ = xor_or_identity(*src++, 0x20); + } + else if (src[0] == 0xD1u && (src[1] >= 0x80u && src[1] <= 0x8Fu)) + { + /// р-я + *dst++ = xor_or_identity(*src++, 0x1); + *dst++ = xor_or_identity(*src++, 0x20); } } @@ -171,7 +168,7 @@ private: { #ifdef __SSE2__ static constexpr auto bytes_sse = sizeof(__m128i); - auto src_end_sse = src + (src_end - src) / bytes_sse * bytes_sse; + const auto * src_end_sse = src + (src_end - src) / bytes_sse * bytes_sse; /// SSE2 packed comparison operate on signed types, hence compare (c < 0) instead of (c > 0x7f) const auto v_zero = _mm_setzero_si128(); @@ -216,7 +213,7 @@ private: else { /// UTF-8 - const auto expected_end = src + bytes_sse; + const auto * expected_end = src + bytes_sse; while (src < expected_end) toCase(src, src_end, dst); diff --git a/src/Functions/MultiMatchAllIndicesImpl.h b/src/Functions/MultiMatchAllIndicesImpl.h index c2e64671d1f..f3e67008707 100644 --- a/src/Functions/MultiMatchAllIndicesImpl.h +++ b/src/Functions/MultiMatchAllIndicesImpl.h @@ -3,6 +3,7 @@ #include #include #include +#include #include "Regexps.h" #include "config_functions.h" diff --git a/src/Functions/PerformanceAdaptors.h b/src/Functions/PerformanceAdaptors.h index 9ef6454d085..bcc195e988e 100644 --- a/src/Functions/PerformanceAdaptors.h +++ b/src/Functions/PerformanceAdaptors.h @@ -72,7 +72,7 @@ namespace detail return size() == 0; } - void emplace_back() + void emplace_back() /// NOLINT { data.emplace_back(); } @@ -198,7 +198,7 @@ class ImplementationSelector : WithContext public: using ImplementationPtr = std::shared_ptr; - ImplementationSelector(ContextPtr context_) : WithContext(context_) {} + explicit ImplementationSelector(ContextPtr context_) : WithContext(context_) {} /* Select the best implementation based on previous runs. * If FunctionInterface is IFunction, then "executeImpl" method of the implementation will be called diff --git a/src/Functions/PolygonUtils.h b/src/Functions/PolygonUtils.h index 1a340c517dc..de4bb2d48de 100644 --- a/src/Functions/PolygonUtils.h +++ b/src/Functions/PolygonUtils.h @@ -53,14 +53,14 @@ UInt64 getPolygonAllocatedBytes(const Polygon & polygon) using RingType = typename Polygon::ring_type; using ValueType = typename RingType::value_type; - auto sizeOfRing = [](const RingType & ring) { return sizeof(ring) + ring.capacity() * sizeof(ValueType); }; + auto size_of_ring = [](const RingType & ring) { return sizeof(ring) + ring.capacity() * sizeof(ValueType); }; - size += sizeOfRing(polygon.outer()); + size += size_of_ring(polygon.outer()); const auto & inners = polygon.inners(); size += sizeof(inners) + inners.capacity() * sizeof(RingType); for (auto & inner : inners) - size += sizeOfRing(inner); + size += size_of_ring(inner); return size; } diff --git a/src/Functions/RapidJSONParser.h b/src/Functions/RapidJSONParser.h index 0e791fe744f..2d8514868e5 100644 --- a/src/Functions/RapidJSONParser.h +++ b/src/Functions/RapidJSONParser.h @@ -23,8 +23,8 @@ struct RapidJSONParser class Element { public: - ALWAYS_INLINE Element() {} - ALWAYS_INLINE Element(const rapidjson::Value & value_) : ptr(&value_) {} + ALWAYS_INLINE Element() = default; + ALWAYS_INLINE Element(const rapidjson::Value & value_) : ptr(&value_) {} /// NOLINT ALWAYS_INLINE bool isInt64() const { return ptr->IsInt64(); } ALWAYS_INLINE bool isUInt64() const { return ptr->IsUint64(); } @@ -54,17 +54,17 @@ struct RapidJSONParser class Iterator { public: - ALWAYS_INLINE Iterator(const rapidjson::Value::ConstValueIterator & it_) : it(it_) {} - ALWAYS_INLINE Element operator*() const { return *it; } + ALWAYS_INLINE Iterator(const rapidjson::Value::ConstValueIterator & it_) : it(it_) {} /// NOLINT + ALWAYS_INLINE Element operator*() const { return *it; } /// NOLINT ALWAYS_INLINE Iterator & operator ++() { ++it; return *this; } - ALWAYS_INLINE Iterator operator ++(int) { auto res = *this; ++it; return res; } + ALWAYS_INLINE Iterator operator ++(int) { auto res = *this; ++it; return res; } /// NOLINT ALWAYS_INLINE friend bool operator ==(const Iterator & left, const Iterator & right) { return left.it == right.it; } ALWAYS_INLINE friend bool operator !=(const Iterator & left, const Iterator & right) { return !(left == right); } private: rapidjson::Value::ConstValueIterator it; }; - ALWAYS_INLINE Array(const rapidjson::Value & value_) : ptr(&value_) {} + ALWAYS_INLINE Array(const rapidjson::Value & value_) : ptr(&value_) {} /// NOLINT ALWAYS_INLINE Iterator begin() const { return ptr->Begin(); } ALWAYS_INLINE Iterator end() const { return ptr->End(); } ALWAYS_INLINE size_t size() const { return ptr->Size(); } @@ -83,17 +83,17 @@ struct RapidJSONParser class Iterator { public: - ALWAYS_INLINE Iterator(const rapidjson::Value::ConstMemberIterator & it_) : it(it_) {} + ALWAYS_INLINE Iterator(const rapidjson::Value::ConstMemberIterator & it_) : it(it_) {} /// NOLINT ALWAYS_INLINE KeyValuePair operator *() const { std::string_view key{it->name.GetString(), it->name.GetStringLength()}; return {key, it->value}; } ALWAYS_INLINE Iterator & operator ++() { ++it; return *this; } - ALWAYS_INLINE Iterator operator ++(int) { auto res = *this; ++it; return res; } + ALWAYS_INLINE Iterator operator ++(int) { auto res = *this; ++it; return res; } /// NOLINT ALWAYS_INLINE friend bool operator ==(const Iterator & left, const Iterator & right) { return left.it == right.it; } ALWAYS_INLINE friend bool operator !=(const Iterator & left, const Iterator & right) { return !(left == right); } private: rapidjson::Value::ConstMemberIterator it; }; - ALWAYS_INLINE Object(const rapidjson::Value & value_) : ptr(&value_) {} + ALWAYS_INLINE Object(const rapidjson::Value & value_) : ptr(&value_) {} /// NOLINT ALWAYS_INLINE Iterator begin() const { return ptr->MemberBegin(); } ALWAYS_INLINE Iterator end() const { return ptr->MemberEnd(); } ALWAYS_INLINE size_t size() const { return ptr->MemberCount(); } diff --git a/src/Functions/ReplaceRegexpImpl.h b/src/Functions/ReplaceRegexpImpl.h index ad0ce08d905..549edf70dff 100644 --- a/src/Functions/ReplaceRegexpImpl.h +++ b/src/Functions/ReplaceRegexpImpl.h @@ -33,8 +33,8 @@ struct ReplaceRegexpImpl /// Otherwise - paste this string verbatim. std::string literal; - Instruction(int substitution_num_) : substitution_num(substitution_num_) {} - Instruction(std::string literal_) : literal(std::move(literal_)) {} + Instruction(int substitution_num_) : substitution_num(substitution_num_) {} /// NOLINT + Instruction(std::string literal_) : literal(std::move(literal_)) {} /// NOLINT }; using Instructions = std::vector; diff --git a/src/Functions/SimdJSONParser.h b/src/Functions/SimdJSONParser.h index be85d74619b..3abeb85fb56 100644 --- a/src/Functions/SimdJSONParser.h +++ b/src/Functions/SimdJSONParser.h @@ -28,8 +28,8 @@ struct SimdJSONParser class Element { public: - ALWAYS_INLINE Element() {} - ALWAYS_INLINE Element(const simdjson::dom::element & element_) : element(element_) {} + ALWAYS_INLINE Element() {} /// NOLINT + ALWAYS_INLINE Element(const simdjson::dom::element & element_) : element(element_) {} /// NOLINT ALWAYS_INLINE bool isInt64() const { return element.type() == simdjson::dom::element_type::INT64; } ALWAYS_INLINE bool isUInt64() const { return element.type() == simdjson::dom::element_type::UINT64; } @@ -61,17 +61,17 @@ struct SimdJSONParser class Iterator { public: - ALWAYS_INLINE Iterator(const simdjson::dom::array::iterator & it_) : it(it_) {} + ALWAYS_INLINE Iterator(const simdjson::dom::array::iterator & it_) : it(it_) {} /// NOLINT ALWAYS_INLINE Element operator*() const { return *it; } ALWAYS_INLINE Iterator & operator++() { ++it; return *this; } - ALWAYS_INLINE Iterator operator++(int) { auto res = *this; ++it; return res; } + ALWAYS_INLINE Iterator operator++(int) { auto res = *this; ++it; return res; } /// NOLINT ALWAYS_INLINE friend bool operator!=(const Iterator & left, const Iterator & right) { return left.it != right.it; } ALWAYS_INLINE friend bool operator==(const Iterator & left, const Iterator & right) { return !(left != right); } private: simdjson::dom::array::iterator it; }; - ALWAYS_INLINE Array(const simdjson::dom::array & array_) : array(array_) {} + ALWAYS_INLINE Array(const simdjson::dom::array & array_) : array(array_) {} /// NOLINT ALWAYS_INLINE Iterator begin() const { return array.begin(); } ALWAYS_INLINE Iterator end() const { return array.end(); } ALWAYS_INLINE size_t size() const { return array.size(); } @@ -90,17 +90,17 @@ struct SimdJSONParser class Iterator { public: - ALWAYS_INLINE Iterator(const simdjson::dom::object::iterator & it_) : it(it_) {} + ALWAYS_INLINE Iterator(const simdjson::dom::object::iterator & it_) : it(it_) {} /// NOLINT ALWAYS_INLINE KeyValuePair operator*() const { const auto & res = *it; return {res.key, res.value}; } ALWAYS_INLINE Iterator & operator++() { ++it; return *this; } - ALWAYS_INLINE Iterator operator++(int) { auto res = *this; ++it; return res; } + ALWAYS_INLINE Iterator operator++(int) { auto res = *this; ++it; return res; } /// NOLINT ALWAYS_INLINE friend bool operator!=(const Iterator & left, const Iterator & right) { return left.it != right.it; } ALWAYS_INLINE friend bool operator==(const Iterator & left, const Iterator & right) { return !(left != right); } private: simdjson::dom::object::iterator it; }; - ALWAYS_INLINE Object(const simdjson::dom::object & object_) : object(object_) {} + ALWAYS_INLINE Object(const simdjson::dom::object & object_) : object(object_) {} /// NOLINT ALWAYS_INLINE Iterator begin() const { return object.begin(); } ALWAYS_INLINE Iterator end() const { return object.end(); } ALWAYS_INLINE size_t size() const { return object.size(); } diff --git a/src/Functions/TargetSpecific.h b/src/Functions/TargetSpecific.h index fa230a56fb7..d7fa55fbb08 100644 --- a/src/Functions/TargetSpecific.h +++ b/src/Functions/TargetSpecific.h @@ -89,6 +89,7 @@ String toString(TargetArch arch); #if ENABLE_MULTITARGET_CODE && defined(__GNUC__) && defined(__x86_64__) +/// NOLINTNEXTLINE #define USE_MULTITARGET_CODE 1 #if defined(__clang__) @@ -183,6 +184,7 @@ namespace TargetSpecific::Default { \ __VA_ARGS__ \ } +/// NOLINTNEXTLINE #define DECLARE_MULTITARGET_CODE(...) \ DECLARE_DEFAULT_CODE (__VA_ARGS__) \ DECLARE_SSE42_SPECIFIC_CODE (__VA_ARGS__) \ @@ -191,23 +193,23 @@ DECLARE_AVX2_SPECIFIC_CODE (__VA_ARGS__) \ DECLARE_AVX512F_SPECIFIC_CODE(__VA_ARGS__) DECLARE_DEFAULT_CODE( - constexpr auto BuildArch = TargetArch::Default; + constexpr auto BuildArch = TargetArch::Default; /// NOLINT ) // DECLARE_DEFAULT_CODE DECLARE_SSE42_SPECIFIC_CODE( - constexpr auto BuildArch = TargetArch::SSE42; + constexpr auto BuildArch = TargetArch::SSE42; /// NOLINT ) // DECLARE_SSE42_SPECIFIC_CODE DECLARE_AVX_SPECIFIC_CODE( - constexpr auto BuildArch = TargetArch::AVX; + constexpr auto BuildArch = TargetArch::AVX; /// NOLINT ) // DECLARE_AVX_SPECIFIC_CODE DECLARE_AVX2_SPECIFIC_CODE( - constexpr auto BuildArch = TargetArch::AVX2; + constexpr auto BuildArch = TargetArch::AVX2; /// NOLINT ) // DECLARE_AVX2_SPECIFIC_CODE DECLARE_AVX512F_SPECIFIC_CODE( - constexpr auto BuildArch = TargetArch::AVX512F; + constexpr auto BuildArch = TargetArch::AVX512F; /// NOLINT ) // DECLARE_AVX512F_SPECIFIC_CODE } diff --git a/src/Functions/TransformDateTime64.h b/src/Functions/TransformDateTime64.h index 4eab2a491c7..b05bdab65ad 100644 --- a/src/Functions/TransformDateTime64.h +++ b/src/Functions/TransformDateTime64.h @@ -44,7 +44,7 @@ public: static constexpr auto name = Transform::name; // non-explicit constructor to allow creating from scale value (or with no scale at all), indispensable in some contexts. - TransformDateTime64(UInt32 scale_ = 0) + TransformDateTime64(UInt32 scale_ = 0) /// NOLINT : scale_multiplier(DecimalUtils::scaleMultiplier(scale_)) {} diff --git a/src/Functions/URL/ExtractFirstSignificantSubdomain.h b/src/Functions/URL/ExtractFirstSignificantSubdomain.h index 4f9b1ec3c6c..70c9c25e4f3 100644 --- a/src/Functions/URL/ExtractFirstSignificantSubdomain.h +++ b/src/Functions/URL/ExtractFirstSignificantSubdomain.h @@ -49,11 +49,11 @@ struct ExtractFirstSignificantSubdomain res_data = tmp; res_size = domain_length; - auto begin = tmp; - auto end = begin + domain_length; + const auto * begin = tmp; + const auto * end = begin + domain_length; const char * last_3_periods[3]{}; - auto pos = find_first_symbols<'.'>(begin, end); + const auto * pos = find_first_symbols<'.'>(begin, end); while (pos < end) { last_3_periods[2] = last_3_periods[1]; @@ -74,7 +74,7 @@ struct ExtractFirstSignificantSubdomain if (!last_3_periods[2]) last_3_periods[2] = begin - 1; - auto end_of_level_domain = find_first_symbols<'/'>(last_3_periods[0], end); + const auto * end_of_level_domain = find_first_symbols<'/'>(last_3_periods[0], end); if (!end_of_level_domain) { end_of_level_domain = end; @@ -117,12 +117,12 @@ struct ExtractFirstSignificantSubdomain res_data = tmp; res_size = domain_length; - auto begin = tmp; - auto end = begin + domain_length; + const auto * begin = tmp; + const auto * end = begin + domain_length; const char * last_2_periods[2]{}; const char * prev = begin - 1; - auto pos = find_first_symbols<'.'>(begin, end); + const auto * pos = find_first_symbols<'.'>(begin, end); while (pos < end) { if (lookup(pos + 1, end - pos - 1)) diff --git a/src/Functions/URL/FirstSignificantSubdomainCustomImpl.h b/src/Functions/URL/FirstSignificantSubdomainCustomImpl.h index 8a76d52741b..5d78500c252 100644 --- a/src/Functions/URL/FirstSignificantSubdomainCustomImpl.h +++ b/src/Functions/URL/FirstSignificantSubdomainCustomImpl.h @@ -20,7 +20,7 @@ namespace ErrorCodes struct FirstSignificantSubdomainCustomLookup { const TLDList & tld_list; - FirstSignificantSubdomainCustomLookup(const std::string & tld_list_name) + explicit FirstSignificantSubdomainCustomLookup(const std::string & tld_list_name) : tld_list(TLDListsHolder::getInstance().getTldList(tld_list_name)) { } diff --git a/src/Functions/URL/domain.h b/src/Functions/URL/domain.h index d43be198043..18efe969216 100644 --- a/src/Functions/URL/domain.h +++ b/src/Functions/URL/domain.h @@ -8,9 +8,6 @@ namespace DB { -namespace -{ - inline StringRef checkAndReturnHost(const Pos & pos, const Pos & dot_pos, const Pos & start_of_host) { if (!dot_pos || start_of_host >= pos || pos - dot_pos == 1) @@ -23,8 +20,6 @@ inline StringRef checkAndReturnHost(const Pos & pos, const Pos & dot_pos, const return StringRef(start_of_host, pos - start_of_host); } -} - /// Extracts host from given url. /// /// @return empty StringRef if the host is not valid (i.e. it does not have dot, or there no symbol after dot). @@ -79,7 +74,7 @@ exloop: if ((scheme_end - pos) > 2 && *pos == ':' && *(pos + 1) == '/' && *(pos } Pos dot_pos = nullptr; - auto start_of_host = pos; + const auto * start_of_host = pos; for (; pos < end; ++pos) { switch (*pos) diff --git a/src/Functions/VectorExtension.h b/src/Functions/VectorExtension.h index cb4347e3031..fbcbae6b0b6 100644 --- a/src/Functions/VectorExtension.h +++ b/src/Functions/VectorExtension.h @@ -6,27 +6,27 @@ namespace DB::VectorExtension { -typedef UInt64 UInt64x2 __attribute__ ((vector_size (sizeof(UInt64) * 2))); -typedef UInt64 UInt64x4 __attribute__ ((vector_size (sizeof(UInt64) * 4))); -typedef UInt64 UInt64x8 __attribute__ ((vector_size (sizeof(UInt64) * 8))); +using UInt64x2 = UInt64 __attribute__ ((vector_size (sizeof(UInt64) * 2))); +using UInt64x4 = UInt64 __attribute__ ((vector_size (sizeof(UInt64) * 4))); +using UInt64x8 = UInt64 __attribute__ ((vector_size (sizeof(UInt64) * 8))); -typedef UInt32 UInt32x2 __attribute__ ((vector_size (sizeof(UInt32) * 2))); -typedef UInt32 UInt32x4 __attribute__ ((vector_size (sizeof(UInt32) * 4))); -typedef UInt32 UInt32x8 __attribute__ ((vector_size (sizeof(UInt32) * 8))); -typedef UInt32 UInt32x16 __attribute__ ((vector_size (sizeof(UInt32) * 16))); +using UInt32x2 = UInt32 __attribute__ ((vector_size (sizeof(UInt32) * 2))); +using UInt32x4 = UInt32 __attribute__ ((vector_size (sizeof(UInt32) * 4))); +using UInt32x8 = UInt32 __attribute__ ((vector_size (sizeof(UInt32) * 8))); +using UInt32x16 = UInt32 __attribute__ ((vector_size (sizeof(UInt32) * 16))); -typedef UInt16 UInt16x2 __attribute__ ((vector_size (sizeof(UInt16) * 2))); -typedef UInt16 UInt16x4 __attribute__ ((vector_size (sizeof(UInt16) * 4))); -typedef UInt16 UInt16x8 __attribute__ ((vector_size (sizeof(UInt16) * 8))); -typedef UInt16 UInt16x16 __attribute__ ((vector_size (sizeof(UInt16) * 16))); -typedef UInt16 UInt16x32 __attribute__ ((vector_size (sizeof(UInt16) * 32))); +using UInt16x2 = UInt16 __attribute__ ((vector_size (sizeof(UInt16) * 2))); +using UInt16x4 = UInt16 __attribute__ ((vector_size (sizeof(UInt16) * 4))); +using UInt16x8 = UInt16 __attribute__ ((vector_size (sizeof(UInt16) * 8))); +using UInt16x16 = UInt16 __attribute__ ((vector_size (sizeof(UInt16) * 16))); +using UInt16x32 = UInt16 __attribute__ ((vector_size (sizeof(UInt16) * 32))); -typedef UInt8 UInt8x2 __attribute__ ((vector_size (sizeof(UInt8) * 2))); -typedef UInt8 UInt8x4 __attribute__ ((vector_size (sizeof(UInt8) * 4))); -typedef UInt8 UInt8x8 __attribute__ ((vector_size (sizeof(UInt8) * 8))); -typedef UInt8 UInt8x16 __attribute__ ((vector_size (sizeof(UInt8) * 16))); -typedef UInt8 UInt8x32 __attribute__ ((vector_size (sizeof(UInt8) * 32))); -typedef UInt8 UInt8x64 __attribute__ ((vector_size (sizeof(UInt8) * 64))); +using UInt8x2 = UInt8 __attribute__ ((vector_size (sizeof(UInt8) * 2))); +using UInt8x4 = UInt8 __attribute__ ((vector_size (sizeof(UInt8) * 4))); +using UInt8x8 = UInt8 __attribute__ ((vector_size (sizeof(UInt8) * 8))); +using UInt8x16 = UInt8 __attribute__ ((vector_size (sizeof(UInt8) * 16))); +using UInt8x32 = UInt8 __attribute__ ((vector_size (sizeof(UInt8) * 32))); +using UInt8x64 = UInt8 __attribute__ ((vector_size (sizeof(UInt8) * 64))); namespace detail { diff --git a/src/Functions/array/arrayEnumerateRanked.h b/src/Functions/array/arrayEnumerateRanked.h index 4d03c52460f..d6a62a966ae 100644 --- a/src/Functions/array/arrayEnumerateRanked.h +++ b/src/Functions/array/arrayEnumerateRanked.h @@ -252,7 +252,7 @@ ColumnPtr FunctionArrayEnumerateRankedExtended::executeImpl( ColumnPtr result_nested_array = std::move(res_nested); for (ssize_t depth = arrays_depths.max_array_depth - 1; depth >= 0; --depth) - result_nested_array = ColumnArray::create(std::move(result_nested_array), offsetsptr_by_depth[depth]); + result_nested_array = ColumnArray::create(result_nested_array, offsetsptr_by_depth[depth]); return result_nested_array; } diff --git a/src/Functions/array/arrayIndex.h b/src/Functions/array/arrayIndex.h index c231ddbb373..35c731dfc78 100644 --- a/src/Functions/array/arrayIndex.h +++ b/src/Functions/array/arrayIndex.h @@ -432,7 +432,7 @@ public: const auto & map_array_column = map_column.getNestedColumn(); auto offsets = map_array_column.getOffsetsPtr(); auto keys = map_column.getNestedData().getColumnPtr(0); - auto array_column = ColumnArray::create(std::move(keys), std::move(offsets)); + auto array_column = ColumnArray::create(keys, offsets); const auto & type_map = assert_cast(*arguments[0].type); auto array_type = std::make_shared(type_map.getKeyType()); diff --git a/src/Functions/array/arrayScalarProduct.h b/src/Functions/array/arrayScalarProduct.h index 87161038d4c..4e3eab2faf8 100644 --- a/src/Functions/array/arrayScalarProduct.h +++ b/src/Functions/array/arrayScalarProduct.h @@ -5,6 +5,7 @@ #include #include #include +#include namespace DB diff --git a/src/Functions/array/hasAllAny.h b/src/Functions/array/hasAllAny.h index cd55fea3521..3ba8bb6156f 100644 --- a/src/Functions/array/hasAllAny.h +++ b/src/Functions/array/hasAllAny.h @@ -44,7 +44,7 @@ public: { for (auto i : collections::range(0, arguments.size())) { - auto array_type = typeid_cast(arguments[i].get()); + const auto * array_type = typeid_cast(arguments[i].get()); if (!array_type) throw Exception("Argument " + std::to_string(i) + " for function " + getName() + " must be an array but it has type " + arguments[i]->getName() + ".", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); diff --git a/src/Functions/extractAllGroups.h b/src/Functions/extractAllGroups.h index fa75e305af4..057dedab6e4 100644 --- a/src/Functions/extractAllGroups.h +++ b/src/Functions/extractAllGroups.h @@ -55,7 +55,7 @@ public: static constexpr auto Kind = Impl::Kind; static constexpr auto name = Impl::Name; - FunctionExtractAllGroups(ContextPtr context_) + explicit FunctionExtractAllGroups(ContextPtr context_) : context(context_) {} diff --git a/src/Functions/formatReadable.h b/src/Functions/formatReadable.h index 7c0d6c5c817..0378e1f82f2 100644 --- a/src/Functions/formatReadable.h +++ b/src/Functions/formatReadable.h @@ -7,6 +7,7 @@ #include #include #include +#include namespace DB diff --git a/src/Functions/toFixedString.h b/src/Functions/toFixedString.h index 129e3e0e8b2..cbd29784271 100644 --- a/src/Functions/toFixedString.h +++ b/src/Functions/toFixedString.h @@ -8,6 +8,7 @@ #include #include #include +#include namespace DB diff --git a/src/IO/AIO.h b/src/IO/AIO.h index b8609c8853c..202939638b7 100644 --- a/src/IO/AIO.h +++ b/src/IO/AIO.h @@ -26,17 +26,17 @@ int io_setup(unsigned nr, aio_context_t * ctxp); int io_destroy(aio_context_t ctx); /// last argument is an array of pointers technically speaking -int io_submit(aio_context_t ctx, long nr, struct iocb * iocbpp[]); +int io_submit(aio_context_t ctx, long nr, struct iocb * iocbpp[]); /// NOLINT -int io_getevents(aio_context_t ctx, long min_nr, long max_nr, io_event * events, struct timespec * timeout); +int io_getevents(aio_context_t ctx, long min_nr, long max_nr, io_event * events, struct timespec * timeout); /// NOLINT struct AIOContext : private boost::noncopyable { aio_context_t ctx = 0; - AIOContext() {} - AIOContext(unsigned int nr_events); + AIOContext() = default; + explicit AIOContext(unsigned int nr_events); ~AIOContext(); AIOContext(AIOContext && rhs) noexcept; AIOContext & operator=(AIOContext && rhs) noexcept; diff --git a/src/IO/Archives/IArchiveWriter.h b/src/IO/Archives/IArchiveWriter.h index 6879d470b62..3856d16fb89 100644 --- a/src/IO/Archives/IArchiveWriter.h +++ b/src/IO/Archives/IArchiveWriter.h @@ -29,7 +29,7 @@ public: /// Sets compression method and level. /// Changing them will affect next file in the archive. - virtual void setCompression(int /* compression_method */, int /* compression_level */ = kDefaultCompressionLevel) {} + virtual void setCompression(int /* compression_method */, int /* compression_level */ = kDefaultCompressionLevel) {} /// NOLINT /// Sets password. If the password is not empty it will enable encryption in the archive. virtual void setPassword(const String & /* password */) {} diff --git a/src/IO/AsynchronousReader.h b/src/IO/AsynchronousReader.h index e79e72f3bec..4583f594c37 100644 --- a/src/IO/AsynchronousReader.h +++ b/src/IO/AsynchronousReader.h @@ -32,7 +32,7 @@ public: struct LocalFileDescriptor : public IFileDescriptor { - LocalFileDescriptor(int fd_) : fd(fd_) {} + explicit LocalFileDescriptor(int fd_) : fd(fd_) {} int fd; }; diff --git a/src/IO/BitHelpers.h b/src/IO/BitHelpers.h index d15297637a3..b96f43bdeff 100644 --- a/src/IO/BitHelpers.h +++ b/src/IO/BitHelpers.h @@ -52,8 +52,7 @@ public: bits_count(0) {} - ~BitReader() - {} + ~BitReader() = default; // reads bits_to_read high-bits from bits_buffer inline UInt64 readBits(UInt8 bits_to_read) diff --git a/src/IO/BrotliReadBuffer.h b/src/IO/BrotliReadBuffer.h index 44a7dc7ddbd..cbb919e15ae 100644 --- a/src/IO/BrotliReadBuffer.h +++ b/src/IO/BrotliReadBuffer.h @@ -10,7 +10,7 @@ namespace DB class BrotliReadBuffer : public BufferWithOwnMemory { public: - BrotliReadBuffer( + explicit BrotliReadBuffer( std::unique_ptr in_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = nullptr, diff --git a/src/IO/Bzip2ReadBuffer.h b/src/IO/Bzip2ReadBuffer.h index de1e61ee388..cd5fadf9c82 100644 --- a/src/IO/Bzip2ReadBuffer.h +++ b/src/IO/Bzip2ReadBuffer.h @@ -10,7 +10,7 @@ namespace DB class Bzip2ReadBuffer : public BufferWithOwnMemory { public: - Bzip2ReadBuffer( + explicit Bzip2ReadBuffer( std::unique_ptr in_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = nullptr, diff --git a/src/IO/CascadeWriteBuffer.h b/src/IO/CascadeWriteBuffer.h index db0d1e7a5a8..ebd4f262aa2 100644 --- a/src/IO/CascadeWriteBuffer.h +++ b/src/IO/CascadeWriteBuffer.h @@ -31,7 +31,7 @@ public: using WriteBufferConstructor = std::function; using WriteBufferConstructors = std::vector; - CascadeWriteBuffer(WriteBufferPtrs && prepared_sources_, WriteBufferConstructors && lazy_sources_ = {}); + explicit CascadeWriteBuffer(WriteBufferPtrs && prepared_sources_, WriteBufferConstructors && lazy_sources_ = {}); void nextImpl() override; diff --git a/src/IO/DoubleConverter.h b/src/IO/DoubleConverter.h index 0896aca717e..75429967390 100644 --- a/src/IO/DoubleConverter.h +++ b/src/IO/DoubleConverter.h @@ -29,9 +29,6 @@ template <> struct DoubleToStringConverterFlags template class DoubleConverter : private boost::noncopyable { - DoubleConverter(const DoubleConverter &) = delete; - DoubleConverter & operator=(const DoubleConverter &) = delete; - DoubleConverter() = default; public: diff --git a/src/IO/FileEncryptionCommon.h b/src/IO/FileEncryptionCommon.h index 28d924e6d81..bb6c8d14893 100644 --- a/src/IO/FileEncryptionCommon.h +++ b/src/IO/FileEncryptionCommon.h @@ -56,7 +56,7 @@ public: /// Adds a specified offset to the counter. InitVector & operator++() { ++counter; return *this; } - InitVector operator++(int) { InitVector res = *this; ++counter; return res; } + InitVector operator++(int) { InitVector res = *this; ++counter; return res; } /// NOLINT InitVector & operator+=(size_t offset) { counter += offset; return *this; } InitVector operator+(size_t offset) const { InitVector res = *this; return res += offset; } diff --git a/src/IO/HashingWriteBuffer.h b/src/IO/HashingWriteBuffer.h index bd00a2b12da..bf636deeb07 100644 --- a/src/IO/HashingWriteBuffer.h +++ b/src/IO/HashingWriteBuffer.h @@ -17,7 +17,7 @@ class IHashingBuffer : public BufferWithOwnMemory public: using uint128 = CityHash_v1_0_2::uint128; - IHashingBuffer(size_t block_size_ = DBMS_DEFAULT_HASHING_BLOCK_SIZE) + explicit IHashingBuffer(size_t block_size_ = DBMS_DEFAULT_HASHING_BLOCK_SIZE) : BufferWithOwnMemory(block_size_), block_pos(0), block_size(block_size_), state(0, 0) { } @@ -66,7 +66,7 @@ private: } public: - HashingWriteBuffer( + explicit HashingWriteBuffer( WriteBuffer & out_, size_t block_size_ = DBMS_DEFAULT_HASHING_BLOCK_SIZE) : IHashingBuffer(block_size_), out(out_) diff --git a/src/IO/LZMAInflatingReadBuffer.h b/src/IO/LZMAInflatingReadBuffer.h index 2d676eeeeb3..920345ee09c 100644 --- a/src/IO/LZMAInflatingReadBuffer.h +++ b/src/IO/LZMAInflatingReadBuffer.h @@ -11,7 +11,7 @@ namespace DB class LZMAInflatingReadBuffer : public BufferWithOwnMemory { public: - LZMAInflatingReadBuffer( + explicit LZMAInflatingReadBuffer( std::unique_ptr in_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = nullptr, diff --git a/src/IO/Lz4DeflatingWriteBuffer.h b/src/IO/Lz4DeflatingWriteBuffer.h index a27cb42a6e7..68873b5f8ee 100644 --- a/src/IO/Lz4DeflatingWriteBuffer.h +++ b/src/IO/Lz4DeflatingWriteBuffer.h @@ -29,7 +29,7 @@ private: void finalizeBefore() override; void finalizeAfter() override; - LZ4F_preferences_t kPrefs; + LZ4F_preferences_t kPrefs; /// NOLINT LZ4F_compressionContext_t ctx; void * in_data; diff --git a/src/IO/Lz4InflatingReadBuffer.h b/src/IO/Lz4InflatingReadBuffer.h index d4d81f8765c..9921939d453 100644 --- a/src/IO/Lz4InflatingReadBuffer.h +++ b/src/IO/Lz4InflatingReadBuffer.h @@ -14,7 +14,7 @@ namespace DB class Lz4InflatingReadBuffer : public BufferWithOwnMemory { public: - Lz4InflatingReadBuffer( + explicit Lz4InflatingReadBuffer( std::unique_ptr in_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = nullptr, diff --git a/src/IO/MMapReadBufferFromFileDescriptor.h b/src/IO/MMapReadBufferFromFileDescriptor.h index 03718a61a6c..1715c2200fb 100644 --- a/src/IO/MMapReadBufferFromFileDescriptor.h +++ b/src/IO/MMapReadBufferFromFileDescriptor.h @@ -18,7 +18,7 @@ public: off_t seek(off_t off, int whence) override; protected: - MMapReadBufferFromFileDescriptor() {} + MMapReadBufferFromFileDescriptor() = default; void init(); MMappedFileDescriptor mapped; diff --git a/src/IO/MMappedFileCache.h b/src/IO/MMappedFileCache.h index adbb85a18cf..fe5e7e8e1f7 100644 --- a/src/IO/MMappedFileCache.h +++ b/src/IO/MMappedFileCache.h @@ -27,7 +27,7 @@ private: using Base = LRUCache; public: - MMappedFileCache(size_t max_size_in_bytes) + explicit MMappedFileCache(size_t max_size_in_bytes) : Base(max_size_in_bytes) {} /// Calculate key from path to file and offset. diff --git a/src/IO/MMappedFileDescriptor.h b/src/IO/MMappedFileDescriptor.h index 01dc7e1866c..2611093643f 100644 --- a/src/IO/MMappedFileDescriptor.h +++ b/src/IO/MMappedFileDescriptor.h @@ -22,7 +22,7 @@ public: MMappedFileDescriptor(int fd_, size_t offset_); /// Makes empty object that can be initialized with `set`. - MMappedFileDescriptor() {} + MMappedFileDescriptor() = default; virtual ~MMappedFileDescriptor(); @@ -40,10 +40,11 @@ public: void set(int fd_, size_t offset_, size_t length_); void set(int fd_, size_t offset_); -protected: MMappedFileDescriptor(const MMappedFileDescriptor &) = delete; MMappedFileDescriptor(MMappedFileDescriptor &&) = delete; +protected: + void init(); int fd = -1; diff --git a/src/IO/MemoryReadWriteBuffer.h b/src/IO/MemoryReadWriteBuffer.h index f9c11084f62..bcaf9a9a965 100644 --- a/src/IO/MemoryReadWriteBuffer.h +++ b/src/IO/MemoryReadWriteBuffer.h @@ -18,7 +18,7 @@ class MemoryWriteBuffer : public WriteBuffer, public IReadableWriteBuffer, boost public: /// Use max_total_size_ = 0 for unlimited storage - MemoryWriteBuffer( + explicit MemoryWriteBuffer( size_t max_total_size_ = 0, size_t initial_chunk_size_ = DBMS_DEFAULT_BUFFER_SIZE, double growth_rate_ = 2.0, diff --git a/src/IO/MySQLPacketPayloadWriteBuffer.h b/src/IO/MySQLPacketPayloadWriteBuffer.h index f54bec06dfb..d4ce8a8955e 100644 --- a/src/IO/MySQLPacketPayloadWriteBuffer.h +++ b/src/IO/MySQLPacketPayloadWriteBuffer.h @@ -13,7 +13,7 @@ class MySQLPacketPayloadWriteBuffer : public WriteBuffer public: MySQLPacketPayloadWriteBuffer(WriteBuffer & out_, size_t payload_length_, uint8_t & sequence_id_); - bool remainingPayloadSize() { return total_left; } + bool remainingPayloadSize() const { return total_left; } protected: void nextImpl() override; diff --git a/src/IO/NullWriteBuffer.h b/src/IO/NullWriteBuffer.h index 233268474d3..615a9bf5cef 100644 --- a/src/IO/NullWriteBuffer.h +++ b/src/IO/NullWriteBuffer.h @@ -11,7 +11,7 @@ namespace DB class NullWriteBuffer : public BufferWithOwnMemory, boost::noncopyable { public: - NullWriteBuffer(size_t buf_size = 16<<10, char * existing_memory = nullptr, size_t alignment = false); + explicit NullWriteBuffer(size_t buf_size = 16<<10, char * existing_memory = nullptr, size_t alignment = false); void nextImpl() override; }; diff --git a/src/IO/Progress.h b/src/IO/Progress.h index 77187aea8f9..4f1a3df0ffd 100644 --- a/src/IO/Progress.h +++ b/src/IO/Progress.h @@ -56,7 +56,7 @@ struct FileProgress size_t read_bytes; size_t total_bytes_to_read; - FileProgress(size_t read_bytes_, size_t total_bytes_to_read_ = 0) : read_bytes(read_bytes_), total_bytes_to_read(total_bytes_to_read_) {} + explicit FileProgress(size_t read_bytes_, size_t total_bytes_to_read_ = 0) : read_bytes(read_bytes_), total_bytes_to_read(total_bytes_to_read_) {} }; diff --git a/src/IO/ReadBufferFromEmptyFile.h b/src/IO/ReadBufferFromEmptyFile.h index 311aee1559b..0a14c07dd5c 100644 --- a/src/IO/ReadBufferFromEmptyFile.h +++ b/src/IO/ReadBufferFromEmptyFile.h @@ -1,6 +1,7 @@ #pragma once #include +#include namespace DB { diff --git a/src/IO/ReadBufferFromFile.h b/src/IO/ReadBufferFromFile.h index c82747392f2..52b18b94616 100644 --- a/src/IO/ReadBufferFromFile.h +++ b/src/IO/ReadBufferFromFile.h @@ -61,7 +61,7 @@ public: class ReadBufferFromFilePRead : public ReadBufferFromFile { public: - ReadBufferFromFilePRead( + explicit ReadBufferFromFilePRead( const std::string & file_name_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, int flags = -1, @@ -84,7 +84,7 @@ private: OpenedFileCache::OpenedFilePtr file; public: - ReadBufferFromFilePReadWithDescriptorsCache( + explicit ReadBufferFromFilePReadWithDescriptorsCache( const std::string & file_name_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, int flags = -1, diff --git a/src/IO/ReadBufferFromFileDescriptor.h b/src/IO/ReadBufferFromFileDescriptor.h index 188cdd709b5..ba1502fb9aa 100644 --- a/src/IO/ReadBufferFromFileDescriptor.h +++ b/src/IO/ReadBufferFromFileDescriptor.h @@ -27,7 +27,7 @@ protected: std::string getFileName() const override; public: - ReadBufferFromFileDescriptor( + explicit ReadBufferFromFileDescriptor( int fd_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = nullptr, @@ -70,7 +70,7 @@ private: class ReadBufferFromFileDescriptorPRead : public ReadBufferFromFileDescriptor { public: - ReadBufferFromFileDescriptorPRead( + explicit ReadBufferFromFileDescriptorPRead( int fd_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = nullptr, diff --git a/src/IO/ReadHelpers.h b/src/IO/ReadHelpers.h index 09aec3c3785..fd2c4218aef 100644 --- a/src/IO/ReadHelpers.h +++ b/src/IO/ReadHelpers.h @@ -106,7 +106,7 @@ inline void readChar(char & x, ReadBuffer & buf) template inline void readPODBinary(T & x, ReadBuffer & buf) { - buf.readStrict(reinterpret_cast(&x), sizeof(x)); + buf.readStrict(reinterpret_cast(&x), sizeof(x)); /// NOLINT } template @@ -611,7 +611,7 @@ void readStringUntilNewlineInto(Vector & s, ReadBuffer & buf); struct NullOutput { void append(const char *, size_t) {} - void push_back(char) {} + void push_back(char) {} /// NOLINT }; void parseUUID(const UInt8 * src36, UInt8 * dst16); @@ -1278,7 +1278,6 @@ inline void readTextWithSizeSuffix(T & x, ReadBuffer & buf) default: return; } - return; } /// Read something from text format and trying to parse the suffix. diff --git a/src/IO/S3/PocoHTTPClient.h b/src/IO/S3/PocoHTTPClient.h index 2647e254626..defd029f05a 100644 --- a/src/IO/S3/PocoHTTPClient.h +++ b/src/IO/S3/PocoHTTPClient.h @@ -49,13 +49,13 @@ class PocoHTTPResponse : public Aws::Http::Standard::StandardHttpResponse public: using SessionPtr = HTTPSessionPtr; - PocoHTTPResponse(const std::shared_ptr request) + explicit PocoHTTPResponse(const std::shared_ptr request) : Aws::Http::Standard::StandardHttpResponse(request) , body_stream(request->GetResponseStreamFactory()) { } - void SetResponseBody(Aws::IStream & incoming_stream, SessionPtr & session_) + void SetResponseBody(Aws::IStream & incoming_stream, SessionPtr & session_) /// NOLINT { body_stream = Aws::Utils::Stream::ResponseStream( Aws::New>("http result streambuf", session_, incoming_stream.rdbuf()) diff --git a/src/IO/S3Common.h b/src/IO/S3Common.h index 72774499445..97cb4f74f90 100644 --- a/src/IO/S3Common.h +++ b/src/IO/S3Common.h @@ -49,7 +49,6 @@ public: private: ClientFactory(); -private: Aws::SDKOptions aws_options; }; diff --git a/src/IO/UncompressedCache.h b/src/IO/UncompressedCache.h index 5826b7f020a..93ca1235a42 100644 --- a/src/IO/UncompressedCache.h +++ b/src/IO/UncompressedCache.h @@ -42,7 +42,7 @@ private: using Base = LRUCache; public: - UncompressedCache(size_t max_size_in_bytes) + explicit UncompressedCache(size_t max_size_in_bytes) : Base(max_size_in_bytes) {} /// Calculate key from path to file and offset. diff --git a/src/IO/VarInt.h b/src/IO/VarInt.h index 50fc158ba76..29c8a60c935 100644 --- a/src/IO/VarInt.h +++ b/src/IO/VarInt.h @@ -132,7 +132,7 @@ inline void readVarUIntImpl(UInt64 & x, ReadBuffer & istr) if (istr.eof()) throwReadAfterEOF(); - UInt64 byte = *istr.position(); + UInt64 byte = *istr.position(); /// NOLINT ++istr.position(); x |= (byte & 0x7F) << (7 * i); @@ -172,7 +172,7 @@ inline const char * readVarUInt(UInt64 & x, const char * istr, size_t size) if (istr == end) throwReadAfterEOF(); - UInt64 byte = *istr; + UInt64 byte = *istr; /// NOLINT ++istr; x |= (byte & 0x7F) << (7 * i); diff --git a/src/IO/WriteBufferFromFile.h b/src/IO/WriteBufferFromFile.h index 988b0be7d00..3363a568bac 100644 --- a/src/IO/WriteBufferFromFile.h +++ b/src/IO/WriteBufferFromFile.h @@ -28,7 +28,7 @@ protected: CurrentMetrics::Increment metric_increment{CurrentMetrics::OpenFileForWrite}; public: - WriteBufferFromFile( + explicit WriteBufferFromFile( const std::string & file_name_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, int flags = -1, @@ -37,7 +37,7 @@ public: size_t alignment = 0); /// Use pre-opened file descriptor. - WriteBufferFromFile( + explicit WriteBufferFromFile( int & fd, /// Will be set to -1 if constructor didn't throw and ownership of file descriptor is passed to the object. const std::string & original_file_name = {}, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, diff --git a/src/IO/WriteBufferFromFileDescriptor.h b/src/IO/WriteBufferFromFileDescriptor.h index b065e22cf95..cc69567932f 100644 --- a/src/IO/WriteBufferFromFileDescriptor.h +++ b/src/IO/WriteBufferFromFileDescriptor.h @@ -11,7 +11,7 @@ namespace DB class WriteBufferFromFileDescriptor : public WriteBufferFromFileBase { public: - WriteBufferFromFileDescriptor( + explicit WriteBufferFromFileDescriptor( int fd_ = -1, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = nullptr, diff --git a/src/IO/WriteBufferFromFileDescriptorDiscardOnFailure.h b/src/IO/WriteBufferFromFileDescriptorDiscardOnFailure.h index 53e01c3cb26..2803dd4e8bf 100644 --- a/src/IO/WriteBufferFromFileDescriptorDiscardOnFailure.h +++ b/src/IO/WriteBufferFromFileDescriptorDiscardOnFailure.h @@ -17,7 +17,7 @@ protected: public: using WriteBufferFromFileDescriptor::WriteBufferFromFileDescriptor; - ~WriteBufferFromFileDescriptorDiscardOnFailure() override {} + ~WriteBufferFromFileDescriptorDiscardOnFailure() override = default; }; } diff --git a/src/IO/WriteBufferFromOStream.h b/src/IO/WriteBufferFromOStream.h index ea3301fef18..f8b45c2fa59 100644 --- a/src/IO/WriteBufferFromOStream.h +++ b/src/IO/WriteBufferFromOStream.h @@ -12,7 +12,7 @@ namespace DB class WriteBufferFromOStream : public BufferWithOwnMemory { public: - WriteBufferFromOStream( + explicit WriteBufferFromOStream( std::ostream & ostr_, size_t size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = nullptr, @@ -21,7 +21,7 @@ public: ~WriteBufferFromOStream() override; protected: - WriteBufferFromOStream(size_t size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = nullptr, size_t alignment = 0); + explicit WriteBufferFromOStream(size_t size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = nullptr, size_t alignment = 0); void nextImpl() override; diff --git a/src/IO/WriteBufferFromPocoSocket.h b/src/IO/WriteBufferFromPocoSocket.h index 2fb203189f3..295ca16ecaf 100644 --- a/src/IO/WriteBufferFromPocoSocket.h +++ b/src/IO/WriteBufferFromPocoSocket.h @@ -14,7 +14,7 @@ namespace DB class WriteBufferFromPocoSocket : public BufferWithOwnMemory { public: - WriteBufferFromPocoSocket(Poco::Net::Socket & socket_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE); + explicit WriteBufferFromPocoSocket(Poco::Net::Socket & socket_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE); ~WriteBufferFromPocoSocket() override; diff --git a/src/IO/WriteBufferFromTemporaryFile.h b/src/IO/WriteBufferFromTemporaryFile.h index 642c36b9be6..06e2911db26 100644 --- a/src/IO/WriteBufferFromTemporaryFile.h +++ b/src/IO/WriteBufferFromTemporaryFile.h @@ -20,7 +20,7 @@ public: ~WriteBufferFromTemporaryFile() override; private: - WriteBufferFromTemporaryFile(std::unique_ptr && tmp_file); + explicit WriteBufferFromTemporaryFile(std::unique_ptr && tmp_file); std::shared_ptr getReadBufferImpl() override; diff --git a/src/IO/WriteBufferFromVector.h b/src/IO/WriteBufferFromVector.h index 23ae3a70ef3..d74b366b8e2 100644 --- a/src/IO/WriteBufferFromVector.h +++ b/src/IO/WriteBufferFromVector.h @@ -67,7 +67,7 @@ private: void finalizeImpl() override final { vector.resize( - ((position() - reinterpret_cast(vector.data())) + ((position() - reinterpret_cast(vector.data())) /// NOLINT + sizeof(typename VectorType::value_type) - 1) /// Align up. / sizeof(typename VectorType::value_type)); diff --git a/src/IO/WriteBufferValidUTF8.h b/src/IO/WriteBufferValidUTF8.h index 8b33593c930..daaf0427f88 100644 --- a/src/IO/WriteBufferValidUTF8.h +++ b/src/IO/WriteBufferValidUTF8.h @@ -16,7 +16,7 @@ class WriteBufferValidUTF8 final : public BufferWithOwnMemory public: static const size_t DEFAULT_SIZE; - WriteBufferValidUTF8( + explicit WriteBufferValidUTF8( WriteBuffer & output_buffer_, bool group_replacements_ = true, const char * replacement_ = "\xEF\xBF\xBD", diff --git a/src/IO/WriteHelpers.cpp b/src/IO/WriteHelpers.cpp index b41f621e0b9..9433d31027c 100644 --- a/src/IO/WriteHelpers.cpp +++ b/src/IO/WriteHelpers.cpp @@ -7,7 +7,7 @@ namespace DB { template -void formatHex(IteratorSrc src, IteratorDst dst, const size_t num_bytes) +void formatHex(IteratorSrc src, IteratorDst dst, size_t num_bytes) { size_t src_pos = 0; size_t dst_pos = 0; diff --git a/src/IO/WriteHelpers.h b/src/IO/WriteHelpers.h index ca2c202014c..447a3ed0480 100644 --- a/src/IO/WriteHelpers.h +++ b/src/IO/WriteHelpers.h @@ -80,7 +80,7 @@ inline void writeChar(char c, size_t n, WriteBuffer & buf) template inline void writePODBinary(const T & x, WriteBuffer & buf) { - buf.write(reinterpret_cast(&x), sizeof(x)); + buf.write(reinterpret_cast(&x), sizeof(x)); /// NOLINT } template @@ -663,7 +663,7 @@ inline void writeXMLStringForTextElement(const StringRef & s, WriteBuffer & buf) } template -void formatHex(IteratorSrc src, IteratorDst dst, const size_t num_bytes); +void formatHex(IteratorSrc src, IteratorDst dst, size_t num_bytes); void formatUUID(const UInt8 * src16, UInt8 * dst36); void formatUUID(std::reverse_iterator src16, UInt8 * dst36); diff --git a/src/IO/WriteIntText.h b/src/IO/WriteIntText.h index b8d2acc7d5d..c9a4cb0241a 100644 --- a/src/IO/WriteIntText.h +++ b/src/IO/WriteIntText.h @@ -5,22 +5,19 @@ #include -namespace -{ - template constexpr size_t max_int_width = 20; - template <> inline constexpr size_t max_int_width = 3; /// 255 - template <> inline constexpr size_t max_int_width = 4; /// -128 - template <> inline constexpr size_t max_int_width = 5; /// 65535 - template <> inline constexpr size_t max_int_width = 6; /// -32768 - template <> inline constexpr size_t max_int_width = 10; /// 4294967295 - template <> inline constexpr size_t max_int_width = 11; /// -2147483648 - template <> inline constexpr size_t max_int_width = 20; /// 18446744073709551615 - template <> inline constexpr size_t max_int_width = 20; /// -9223372036854775808 - template <> inline constexpr size_t max_int_width = 39; /// 340282366920938463463374607431768211455 - template <> inline constexpr size_t max_int_width = 40; /// -170141183460469231731687303715884105728 - template <> inline constexpr size_t max_int_width = 78; /// 115792089237316195423570985008687907853269984665640564039457584007913129639935 - template <> inline constexpr size_t max_int_width = 78; /// -57896044618658097711785492504343953926634992332820282019728792003956564819968 -} +template constexpr size_t max_int_width = 20; +template <> inline constexpr size_t max_int_width = 3; /// 255 +template <> inline constexpr size_t max_int_width = 4; /// -128 +template <> inline constexpr size_t max_int_width = 5; /// 65535 +template <> inline constexpr size_t max_int_width = 6; /// -32768 +template <> inline constexpr size_t max_int_width = 10; /// 4294967295 +template <> inline constexpr size_t max_int_width = 11; /// -2147483648 +template <> inline constexpr size_t max_int_width = 20; /// 18446744073709551615 +template <> inline constexpr size_t max_int_width = 20; /// -9223372036854775808 +template <> inline constexpr size_t max_int_width = 39; /// 340282366920938463463374607431768211455 +template <> inline constexpr size_t max_int_width = 40; /// -170141183460469231731687303715884105728 +template <> inline constexpr size_t max_int_width = 78; /// 115792089237316195423570985008687907853269984665640564039457584007913129639935 +template <> inline constexpr size_t max_int_width = 78; /// -57896044618658097711785492504343953926634992332820282019728792003956564819968 namespace DB diff --git a/src/IO/ZstdInflatingReadBuffer.h b/src/IO/ZstdInflatingReadBuffer.h index ec80b860e0e..7f246b02127 100644 --- a/src/IO/ZstdInflatingReadBuffer.h +++ b/src/IO/ZstdInflatingReadBuffer.h @@ -16,7 +16,7 @@ namespace ErrorCodes class ZstdInflatingReadBuffer : public BufferWithOwnMemory { public: - ZstdInflatingReadBuffer( + explicit ZstdInflatingReadBuffer( std::unique_ptr in_, size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE, char * existing_memory = nullptr, diff --git a/src/IO/readFloatText.h b/src/IO/readFloatText.h index 1c5b1cdb0c9..b6be7adbbee 100644 --- a/src/IO/readFloatText.h +++ b/src/IO/readFloatText.h @@ -154,7 +154,7 @@ ReturnType readFloatTextPreciseImpl(T & x, ReadBuffer & buf) if (likely(!buf.eof() && buf.position() + MAX_LENGTH <= buf.buffer().end())) { - auto initial_position = buf.position(); + auto * initial_position = buf.position(); auto res = fast_float::from_chars(initial_position, buf.buffer().end(), x); if (unlikely(res.ec != std::errc())) diff --git a/src/Interpreters/AddIndexConstraintsOptimizer.h b/src/Interpreters/AddIndexConstraintsOptimizer.h index 228d8d8ad1a..9ed4a8978c8 100644 --- a/src/Interpreters/AddIndexConstraintsOptimizer.h +++ b/src/Interpreters/AddIndexConstraintsOptimizer.h @@ -23,8 +23,7 @@ using StorageMetadataPtr = std::shared_ptr; class AddIndexConstraintsOptimizer final { public: - AddIndexConstraintsOptimizer( - const StorageMetadataPtr & metadata_snapshot); + explicit AddIndexConstraintsOptimizer(const StorageMetadataPtr & metadata_snapshot); void perform(CNFQuery & cnf_query); diff --git a/src/Interpreters/AggregationCommon.h b/src/Interpreters/AggregationCommon.h index 00d2f76f043..5904cc48084 100644 --- a/src/Interpreters/AggregationCommon.h +++ b/src/Interpreters/AggregationCommon.h @@ -42,9 +42,6 @@ using Sizes = std::vector; /// 2,1,1 /// -namespace -{ - template constexpr auto getBitmapSize() { @@ -62,8 +59,6 @@ constexpr auto getBitmapSize() 0))); } -} - template void fillFixedBatch(size_t num_rows, const T * source, T * dest) { @@ -255,7 +250,7 @@ static inline T ALWAYS_INLINE packFixed( /// Hash a set of keys into a UInt128 value. -static inline UInt128 ALWAYS_INLINE hash128( +static inline UInt128 ALWAYS_INLINE hash128( /// NOLINT size_t i, size_t keys_size, const ColumnRawPtrs & key_columns) { UInt128 key; @@ -269,29 +264,9 @@ static inline UInt128 ALWAYS_INLINE hash128( return key; } - -/// Copy keys to the pool. Then put into pool StringRefs to them and return the pointer to the first. -static inline StringRef * ALWAYS_INLINE placeKeysInPool( - size_t keys_size, StringRefs & keys, Arena & pool) -{ - for (size_t j = 0; j < keys_size; ++j) - { - char * place = pool.alloc(keys[j].size); - memcpySmallAllowReadWriteOverflow15(place, keys[j].data, keys[j].size); - keys[j].data = place; - } - - /// Place the StringRefs on the newly copied keys in the pool. - char * res = pool.alignedAlloc(keys_size * sizeof(StringRef), alignof(StringRef)); - memcpySmallAllowReadWriteOverflow15(res, keys.data(), keys_size * sizeof(StringRef)); - - return reinterpret_cast(res); -} - - /** Serialize keys into a continuous chunk of memory. */ -static inline StringRef ALWAYS_INLINE serializeKeysToPoolContiguous( +static inline StringRef ALWAYS_INLINE serializeKeysToPoolContiguous( /// NOLINT size_t i, size_t keys_size, const ColumnRawPtrs & key_columns, Arena & pool) { const char * begin = nullptr; diff --git a/src/Interpreters/Aggregator.h b/src/Interpreters/Aggregator.h index 3457e01f98f..f03bf45fbc6 100644 --- a/src/Interpreters/Aggregator.h +++ b/src/Interpreters/Aggregator.h @@ -660,7 +660,7 @@ struct AggregatedDataVariants : private boost::noncopyable case Type::without_key: break; #define M(NAME, IS_TWO_LEVEL) \ - case Type::NAME: NAME = std::make_unique(); break; + case Type::NAME: (NAME) = std::make_unique(); break; APPLY_FOR_AGGREGATED_VARIANTS(M) #undef M } @@ -677,7 +677,7 @@ struct AggregatedDataVariants : private boost::noncopyable case Type::without_key: return 1; #define M(NAME, IS_TWO_LEVEL) \ - case Type::NAME: return NAME->data.size() + (without_key != nullptr); + case Type::NAME: return (NAME)->data.size() + (without_key != nullptr); APPLY_FOR_AGGREGATED_VARIANTS(M) #undef M } @@ -694,7 +694,7 @@ struct AggregatedDataVariants : private boost::noncopyable case Type::without_key: return 1; #define M(NAME, IS_TWO_LEVEL) \ - case Type::NAME: return NAME->data.size(); + case Type::NAME: return (NAME)->data.size(); APPLY_FOR_AGGREGATED_VARIANTS(M) #undef M } @@ -753,6 +753,7 @@ struct AggregatedDataVariants : private boost::noncopyable M(low_cardinality_key_string) \ M(low_cardinality_key_fixed_string) \ + /// NOLINTNEXTLINE #define APPLY_FOR_VARIANTS_NOT_CONVERTIBLE_TO_TWO_LEVEL(M) \ M(key8) \ M(key16) \ @@ -766,6 +767,7 @@ struct AggregatedDataVariants : private boost::noncopyable M(low_cardinality_key8) \ M(low_cardinality_key16) \ + /// NOLINTNEXTLINE #define APPLY_FOR_VARIANTS_SINGLE_LEVEL(M) \ APPLY_FOR_VARIANTS_NOT_CONVERTIBLE_TO_TWO_LEVEL(M) \ APPLY_FOR_VARIANTS_CONVERTIBLE_TO_TWO_LEVEL(M) \ @@ -787,6 +789,7 @@ struct AggregatedDataVariants : private boost::noncopyable void convertToTwoLevel(); + /// NOLINTNEXTLINE #define APPLY_FOR_VARIANTS_TWO_LEVEL(M) \ M(key32_two_level) \ M(key64_two_level) \ @@ -1341,7 +1344,7 @@ private: template Method & getDataVariant(AggregatedDataVariants & variants); #define M(NAME, IS_TWO_LEVEL) \ - template <> inline decltype(AggregatedDataVariants::NAME)::element_type & getDataVariant(AggregatedDataVariants & variants) { return *variants.NAME; } + template <> inline decltype(AggregatedDataVariants::NAME)::element_type & getDataVariant(AggregatedDataVariants & variants) { return *variants.NAME; } /// NOLINT APPLY_FOR_AGGREGATED_VARIANTS(M) diff --git a/src/Interpreters/BloomFilter.h b/src/Interpreters/BloomFilter.h index 279ab6947ec..1fb9895cc27 100644 --- a/src/Interpreters/BloomFilter.h +++ b/src/Interpreters/BloomFilter.h @@ -31,7 +31,7 @@ public: using UnderType = UInt64; using Container = std::vector; - BloomFilter(const BloomFilterParameters & params); + explicit BloomFilter(const BloomFilterParameters & params); /// size -- size of filter in bytes. /// hashes -- number of used hash functions. /// seed -- random seed for hash functions generation. diff --git a/src/Interpreters/ClientInfo.cpp b/src/Interpreters/ClientInfo.cpp index 827e7d27409..75af25e842e 100644 --- a/src/Interpreters/ClientInfo.cpp +++ b/src/Interpreters/ClientInfo.cpp @@ -19,7 +19,7 @@ namespace ErrorCodes } -void ClientInfo::write(WriteBuffer & out, const UInt64 server_protocol_revision) const +void ClientInfo::write(WriteBuffer & out, UInt64 server_protocol_revision) const { if (server_protocol_revision < DBMS_MIN_REVISION_WITH_CLIENT_INFO) throw Exception("Logical error: method ClientInfo::write is called for unsupported server revision", ErrorCodes::LOGICAL_ERROR); @@ -99,7 +99,7 @@ void ClientInfo::write(WriteBuffer & out, const UInt64 server_protocol_revision) } -void ClientInfo::read(ReadBuffer & in, const UInt64 client_protocol_revision) +void ClientInfo::read(ReadBuffer & in, UInt64 client_protocol_revision) { if (client_protocol_revision < DBMS_MIN_REVISION_WITH_CLIENT_INFO) throw Exception("Logical error: method ClientInfo::read is called for unsupported client revision", ErrorCodes::LOGICAL_ERROR); diff --git a/src/Interpreters/ClientInfo.h b/src/Interpreters/ClientInfo.h index 3ce740c6436..0b40c78becc 100644 --- a/src/Interpreters/ClientInfo.h +++ b/src/Interpreters/ClientInfo.h @@ -119,8 +119,8 @@ public: * Only values that are not calculated automatically or passed separately are serialized. * Revisions are passed to use format that server will understand or client was used. */ - void write(WriteBuffer & out, const UInt64 server_protocol_revision) const; - void read(ReadBuffer & in, const UInt64 client_protocol_revision); + void write(WriteBuffer & out, UInt64 server_protocol_revision) const; + void read(ReadBuffer & in, UInt64 client_protocol_revision); /// Initialize parameters on client initiating query. void setInitialQuery(); diff --git a/src/Interpreters/Cluster.h b/src/Interpreters/Cluster.h index 248d212ebf0..e9f26c21089 100644 --- a/src/Interpreters/Cluster.h +++ b/src/Interpreters/Cluster.h @@ -63,7 +63,6 @@ public: /// is used to set a limit on the size of the timeout static Poco::Timespan saturate(Poco::Timespan v, Poco::Timespan limit); -public: using SlotToShard = std::vector; struct Address @@ -192,7 +191,6 @@ public: /// Name of directory for asynchronous write to StorageDistributed if has_internal_replication const std::string & insertPathForInternalReplication(bool prefer_localhost_replica, bool use_compact_format) const; - public: ShardInfoInsertPathForInternalReplication insert_path_for_internal_replication; /// Number of the shard, the indexation begins with 1 UInt32 shard_num = 0; diff --git a/src/Interpreters/ComparisonGraph.cpp b/src/Interpreters/ComparisonGraph.cpp index e236de67fdc..37d603b4923 100644 --- a/src/Interpreters/ComparisonGraph.cpp +++ b/src/Interpreters/ComparisonGraph.cpp @@ -159,7 +159,7 @@ ComparisonGraph::CompareResult ComparisonGraph::pathToCompareResult(Path path, b __builtin_unreachable(); } -std::optional ComparisonGraph::findPath(const size_t start, const size_t finish) const +std::optional ComparisonGraph::findPath(size_t start, size_t finish) const { const auto it = dists.find(std::make_pair(start, finish)); if (it == std::end(dists)) @@ -232,7 +232,7 @@ ComparisonGraph::CompareResult ComparisonGraph::compare(const ASTPtr & left, con return CompareResult::UNKNOWN; } -bool ComparisonGraph::isPossibleCompare(const CompareResult expected, const ASTPtr & left, const ASTPtr & right) const +bool ComparisonGraph::isPossibleCompare(CompareResult expected, const ASTPtr & left, const ASTPtr & right) const { const auto result = compare(left, right); @@ -267,7 +267,7 @@ bool ComparisonGraph::isPossibleCompare(const CompareResult expected, const ASTP return possible_pairs.contains({expected, result}); } -bool ComparisonGraph::isAlwaysCompare(const CompareResult expected, const ASTPtr & left, const ASTPtr & right) const +bool ComparisonGraph::isAlwaysCompare(CompareResult expected, const ASTPtr & left, const ASTPtr & right) const { const auto result = compare(left, right); @@ -324,12 +324,12 @@ std::optional ComparisonGraph::getComponentId(const ASTPtr & ast) const } } -bool ComparisonGraph::hasPath(const size_t left, const size_t right) const +bool ComparisonGraph::hasPath(size_t left, size_t right) const { return findPath(left, right) || findPath(right, left); } -ASTs ComparisonGraph::getComponent(const size_t id) const +ASTs ComparisonGraph::getComponent(size_t id) const { return graph.vertices[id].asts; } @@ -387,7 +387,7 @@ ComparisonGraph::CompareResult ComparisonGraph::functionNameToCompareResult(cons return it == std::end(relation_to_compare) ? CompareResult::UNKNOWN : it->second; } -ComparisonGraph::CompareResult ComparisonGraph::inverseCompareResult(const CompareResult result) +ComparisonGraph::CompareResult ComparisonGraph::inverseCompareResult(CompareResult result) { static const std::unordered_map inverse_relations = { @@ -486,7 +486,7 @@ std::vector ComparisonGraph::getVertices() const void ComparisonGraph::dfsComponents( const Graph & reversed_graph, size_t v, - OptionalIndices & components, const size_t component) + OptionalIndices & components, size_t component) { components[v] = component; for (const auto & edge : reversed_graph.edges[v]) diff --git a/src/Interpreters/ComparisonGraph.h b/src/Interpreters/ComparisonGraph.h index 20d6f135a0d..3891fbf51cf 100644 --- a/src/Interpreters/ComparisonGraph.h +++ b/src/Interpreters/ComparisonGraph.h @@ -17,7 +17,7 @@ class ComparisonGraph { public: /// atomic_formulas are extracted from constraints. - ComparisonGraph(const std::vector & atomic_formulas); + explicit ComparisonGraph(const std::vector & atomic_formulas); enum class CompareResult { @@ -32,15 +32,15 @@ public: static CompareResult atomToCompareResult(const CNFQuery::AtomicFormula & atom); static CompareResult functionNameToCompareResult(const std::string & name); - static CompareResult inverseCompareResult(const CompareResult result); + static CompareResult inverseCompareResult(CompareResult result); CompareResult compare(const ASTPtr & left, const ASTPtr & right) const; /// It's possible that left right - bool isPossibleCompare(const CompareResult expected, const ASTPtr & left, const ASTPtr & right) const; + bool isPossibleCompare(CompareResult expected, const ASTPtr & left, const ASTPtr & right) const; /// It's always true that left right - bool isAlwaysCompare(const CompareResult expected, const ASTPtr & left, const ASTPtr & right) const; + bool isAlwaysCompare(CompareResult expected, const ASTPtr & left, const ASTPtr & right) const; /// Returns all expressions from component to which @ast belongs if any. std::vector getEqual(const ASTPtr & ast) const; @@ -52,11 +52,11 @@ public: std::optional getComponentId(const ASTPtr & ast) const; /// Returns all expressions from component. - std::vector getComponent(const std::size_t id) const; + std::vector getComponent(size_t id) const; size_t getNumOfComponents() const { return graph.vertices.size(); } - bool hasPath(const size_t left, const size_t right) const; + bool hasPath(size_t left, size_t right) const; /// Find constants lessOrEqual and greaterOrEqual. /// For int and double linear programming can be applied here. @@ -131,7 +131,7 @@ private: /// Assigns index of component for each vertex. static void dfsComponents( const Graph & reversed_graph, size_t v, - OptionalIndices & components, const size_t component); + OptionalIndices & components, size_t component); enum class Path { @@ -140,7 +140,7 @@ private: }; static CompareResult pathToCompareResult(Path path, bool inverse); - std::optional findPath(const size_t start, const size_t finish) const; + std::optional findPath(size_t start, size_t finish) const; /// Calculate @dists. static std::map, Path> buildDistsFromGraph(const Graph & g); diff --git a/src/Interpreters/CrashLog.h b/src/Interpreters/CrashLog.h index 61503d95cee..930515c43ea 100644 --- a/src/Interpreters/CrashLog.h +++ b/src/Interpreters/CrashLog.h @@ -41,7 +41,7 @@ class CrashLog : public SystemLog public: static void initialize(std::shared_ptr crash_log_) { - crash_log = std::move(crash_log_); + crash_log = crash_log_; } }; diff --git a/src/Interpreters/DatabaseCatalog.h b/src/Interpreters/DatabaseCatalog.h index c2a46277015..34b42a3397c 100644 --- a/src/Interpreters/DatabaseCatalog.h +++ b/src/Interpreters/DatabaseCatalog.h @@ -107,7 +107,7 @@ struct TemporaryTableHolder : boost::noncopyable, WithContext StoragePtr getTable() const; - operator bool () const { return id != UUIDHelpers::Nil; } + operator bool () const { return id != UUIDHelpers::Nil; } /// NOLINT IDatabase * temporary_tables = nullptr; UUID id = UUIDHelpers::Nil; diff --git a/src/Interpreters/GetAggregatesVisitor.h b/src/Interpreters/GetAggregatesVisitor.h index 0eeab8348fd..3966653235a 100644 --- a/src/Interpreters/GetAggregatesVisitor.h +++ b/src/Interpreters/GetAggregatesVisitor.h @@ -2,6 +2,9 @@ #include #include +#include +#include +#include namespace DB { diff --git a/src/Interpreters/IInterpreterUnionOrSelectQuery.h b/src/Interpreters/IInterpreterUnionOrSelectQuery.h index 1f59dd36354..7906ab189fc 100644 --- a/src/Interpreters/IInterpreterUnionOrSelectQuery.h +++ b/src/Interpreters/IInterpreterUnionOrSelectQuery.h @@ -47,7 +47,7 @@ public: /// then we can cache the scalars forever (for any query that doesn't use the virtual storage either), but if it does use the virtual /// storage then we can only keep the scalar result around while we are working with that source block /// You can find more details about this under ExecuteScalarSubqueriesMatcher::visit - bool usesViewSource() { return uses_view_source; } + bool usesViewSource() const { return uses_view_source; } protected: ASTPtr query_ptr; diff --git a/src/Interpreters/IJoin.h b/src/Interpreters/IJoin.h index ba8367b57e3..2a3171adccd 100644 --- a/src/Interpreters/IJoin.h +++ b/src/Interpreters/IJoin.h @@ -25,7 +25,7 @@ public: /// Add block of data from right hand of JOIN. /// @returns false, if some limit was exceeded and you should not insert more data. - virtual bool addJoinedBlock(const Block & block, bool check_limits = true) = 0; + virtual bool addJoinedBlock(const Block & block, bool check_limits = true) = 0; /// NOLINT virtual void checkTypesOfKeys(const Block & block) const = 0; diff --git a/src/Interpreters/InJoinSubqueriesPreprocessor.h b/src/Interpreters/InJoinSubqueriesPreprocessor.h index d2166185d2b..e4ec3c81ed2 100644 --- a/src/Interpreters/InJoinSubqueriesPreprocessor.h +++ b/src/Interpreters/InJoinSubqueriesPreprocessor.h @@ -43,7 +43,7 @@ public: /// These methods could be overridden for the need of the unit test. virtual bool hasAtLeastTwoShards(const IStorage & table) const; virtual std::pair getRemoteDatabaseAndTableName(const IStorage & table) const; - virtual ~CheckShardsAndTables() {} + virtual ~CheckShardsAndTables() = default; }; InJoinSubqueriesPreprocessor( diff --git a/src/Interpreters/LogicalExpressionsOptimizer.h b/src/Interpreters/LogicalExpressionsOptimizer.h index 1a04b199a13..4991d31f8b1 100644 --- a/src/Interpreters/LogicalExpressionsOptimizer.h +++ b/src/Interpreters/LogicalExpressionsOptimizer.h @@ -29,7 +29,7 @@ class LogicalExpressionsOptimizer final { const UInt64 optimize_min_equality_disjunction_chain_length; - ExtractedSettings(UInt64 optimize_min_equality_disjunction_chain_length_) + explicit ExtractedSettings(UInt64 optimize_min_equality_disjunction_chain_length_) : optimize_min_equality_disjunction_chain_length(optimize_min_equality_disjunction_chain_length_) {} }; @@ -68,7 +68,6 @@ private: using DisjunctiveEqualityChainsMap = std::map; using DisjunctiveEqualityChain = DisjunctiveEqualityChainsMap::value_type; -private: /** Collect information about all the equations in the OR chains (not necessarily homogeneous). * This information is grouped by the expression that is on the left side of the equation. */ @@ -92,12 +91,10 @@ private: /// Restore the original column order after optimization. void reorderColumns(); -private: using ParentNodes = std::vector; using FunctionParentMap = std::unordered_map; using ColumnToPosition = std::unordered_map; -private: ASTSelectQuery * select_query; const ExtractedSettings settings; /// Information about the OR-chains inside the query. diff --git a/src/Interpreters/OpenTelemetrySpanLog.h b/src/Interpreters/OpenTelemetrySpanLog.h index f4b3a388b54..aa99a9f8e4b 100644 --- a/src/Interpreters/OpenTelemetrySpanLog.h +++ b/src/Interpreters/OpenTelemetrySpanLog.h @@ -25,7 +25,7 @@ struct OpenTelemetrySpan struct OpenTelemetrySpanLogElement : public OpenTelemetrySpan { OpenTelemetrySpanLogElement() = default; - OpenTelemetrySpanLogElement(const OpenTelemetrySpan & span) + explicit OpenTelemetrySpanLogElement(const OpenTelemetrySpan & span) : OpenTelemetrySpan(span) {} static std::string name() { return "OpenTelemetrySpanLog"; } @@ -44,7 +44,7 @@ public: struct OpenTelemetrySpanHolder : public OpenTelemetrySpan { - OpenTelemetrySpanHolder(const std::string & _operation_name); + explicit OpenTelemetrySpanHolder(const std::string & _operation_name); void addAttribute(const std::string& name, UInt64 value); void addAttribute(const std::string& name, const std::string& value); void addAttribute(const Exception & e); diff --git a/src/Interpreters/OptimizeIfWithConstantConditionVisitor.h b/src/Interpreters/OptimizeIfWithConstantConditionVisitor.h index 05d0330196b..ad98f92bafd 100644 --- a/src/Interpreters/OptimizeIfWithConstantConditionVisitor.h +++ b/src/Interpreters/OptimizeIfWithConstantConditionVisitor.h @@ -10,7 +10,7 @@ namespace DB class OptimizeIfWithConstantConditionVisitor { public: - OptimizeIfWithConstantConditionVisitor(Aliases & aliases_) + explicit OptimizeIfWithConstantConditionVisitor(Aliases & aliases_) : aliases(aliases_) {} diff --git a/src/Interpreters/ProcessList.h b/src/Interpreters/ProcessList.h index 493b2ba81a9..c90c271679c 100644 --- a/src/Interpreters/ProcessList.h +++ b/src/Interpreters/ProcessList.h @@ -216,7 +216,7 @@ struct ProcessListForUserInfo /// Data about queries for one user. struct ProcessListForUser { - ProcessListForUser(ProcessList * global_process_list); + explicit ProcessListForUser(ProcessList * global_process_list); /// query_id -> ProcessListElement(s). There can be multiple queries with the same query_id as long as all queries except one are cancelled. using QueryToElement = std::unordered_map; diff --git a/src/Interpreters/QueryNormalizer.h b/src/Interpreters/QueryNormalizer.h index eebcff62cde..f532d869789 100644 --- a/src/Interpreters/QueryNormalizer.h +++ b/src/Interpreters/QueryNormalizer.h @@ -25,7 +25,7 @@ class QueryNormalizer bool prefer_column_name_to_alias; template - ExtractedSettings(const T & settings) + ExtractedSettings(const T & settings) /// NOLINT : max_ast_depth(settings.max_ast_depth) , max_expanded_ast_elements(settings.max_expanded_ast_elements) , prefer_column_name_to_alias(settings.prefer_column_name_to_alias) diff --git a/src/Interpreters/RedundantFunctionsInOrderByVisitor.h b/src/Interpreters/RedundantFunctionsInOrderByVisitor.h index 09362ea6be2..60c9fcf2a24 100644 --- a/src/Interpreters/RedundantFunctionsInOrderByVisitor.h +++ b/src/Interpreters/RedundantFunctionsInOrderByVisitor.h @@ -4,6 +4,8 @@ #include #include #include +#include +#include namespace DB { diff --git a/src/Interpreters/ReplaceQueryParameterVisitor.h b/src/Interpreters/ReplaceQueryParameterVisitor.h index cb3d0f668d8..dd785cd768e 100644 --- a/src/Interpreters/ReplaceQueryParameterVisitor.h +++ b/src/Interpreters/ReplaceQueryParameterVisitor.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include namespace DB diff --git a/src/Interpreters/RowRefs.h b/src/Interpreters/RowRefs.h index cae20b98caf..baff903e121 100644 --- a/src/Interpreters/RowRefs.h +++ b/src/Interpreters/RowRefs.h @@ -26,7 +26,7 @@ struct RowRef const Block * block = nullptr; SizeT row_num = 0; - RowRef() {} + RowRef() {} /// NOLINT RowRef(const Block * block_, size_t row_num_) : block(block_), row_num(row_num_) {} }; @@ -42,7 +42,7 @@ struct RowRefList : RowRef Batch * next; RowRef row_refs[MAX_SIZE]; - Batch(Batch * parent) + explicit Batch(Batch * parent) : next(parent) {} @@ -52,7 +52,7 @@ struct RowRefList : RowRef { if (full()) { - auto batch = pool.alloc(); + auto * batch = pool.alloc(); *batch = Batch(this); batch->insert(std::move(row_ref), pool); return batch; @@ -66,7 +66,7 @@ struct RowRefList : RowRef class ForwardIterator { public: - ForwardIterator(const RowRefList * begin) + explicit ForwardIterator(const RowRefList * begin) : root(begin) , first(true) , batch(root->next) @@ -115,7 +115,7 @@ struct RowRefList : RowRef size_t position; }; - RowRefList() {} + RowRefList() {} /// NOLINT RowRefList(const Block * block_, size_t row_num_) : RowRef(block_, row_num_) {} ForwardIterator begin() const { return ForwardIterator(this); } @@ -221,7 +221,7 @@ public: T asof_value; RowRef row_ref; - Entry(T v) : asof_value(v) {} + explicit Entry(T v) : asof_value(v) {} Entry(T v, RowRef rr) : asof_value(v), row_ref(rr) {} }; @@ -241,8 +241,8 @@ public: Entry::LookupPtr, Entry::LookupPtr>; - AsofRowRefs() {} - AsofRowRefs(TypeIndex t); + AsofRowRefs() = default; + explicit AsofRowRefs(TypeIndex t); static std::optional getTypeSize(const IColumn & asof_column, size_t & type_size); diff --git a/src/Interpreters/StorageID.h b/src/Interpreters/StorageID.h index f1fcfde25c0..29ba24c2e4c 100644 --- a/src/Interpreters/StorageID.h +++ b/src/Interpreters/StorageID.h @@ -41,9 +41,9 @@ struct StorageID assertNotEmpty(); } - StorageID(const ASTQueryWithTableAndOutput & query); - StorageID(const ASTTableIdentifier & table_identifier_node); - StorageID(const ASTPtr & node); + StorageID(const ASTQueryWithTableAndOutput & query); /// NOLINT + StorageID(const ASTTableIdentifier & table_identifier_node); /// NOLINT + StorageID(const ASTPtr & node); /// NOLINT String getDatabaseName() const; diff --git a/src/Interpreters/TableJoin.h b/src/Interpreters/TableJoin.h index a3f6f7bf36b..f7c03ac6e1a 100644 --- a/src/Interpreters/TableJoin.h +++ b/src/Interpreters/TableJoin.h @@ -103,7 +103,7 @@ private: friend class TreeRewriter; - const SizeLimits size_limits; + SizeLimits size_limits; const size_t default_max_bytes = 0; const bool join_use_nulls = false; const size_t max_joined_block_rows = 0; @@ -114,7 +114,7 @@ private: const String temporary_files_codec = "LZ4"; /// the limit has no technical reasons, it supposed to improve safety - const size_t MAX_DISJUNCTS = 16; + const size_t MAX_DISJUNCTS = 16; /// NOLINT ASTs key_asts_left; ASTs key_asts_right; diff --git a/src/Interpreters/TraceCollector.h b/src/Interpreters/TraceCollector.h index 3a9edf676be..b3f11ca5756 100644 --- a/src/Interpreters/TraceCollector.h +++ b/src/Interpreters/TraceCollector.h @@ -18,7 +18,7 @@ class TraceLog; class TraceCollector { public: - TraceCollector(std::shared_ptr trace_log_); + explicit TraceCollector(std::shared_ptr trace_log_); ~TraceCollector(); static inline void collect(TraceType trace_type, const StackTrace & stack_trace, Int64 size) diff --git a/src/Interpreters/TranslateQualifiedNamesVisitor.cpp b/src/Interpreters/TranslateQualifiedNamesVisitor.cpp index 0d7d56058b9..6016d54c7dc 100644 --- a/src/Interpreters/TranslateQualifiedNamesVisitor.cpp +++ b/src/Interpreters/TranslateQualifiedNamesVisitor.cpp @@ -303,7 +303,7 @@ void TranslateQualifiedNamesMatcher::visit(ASTExpressionList & node, const ASTPt } /// 'select * from a join b using id' should result one 'id' column -void TranslateQualifiedNamesMatcher::extractJoinUsingColumns(const ASTPtr ast, Data & data) +void TranslateQualifiedNamesMatcher::extractJoinUsingColumns(ASTPtr ast, Data & data) { const auto & table_join = ast->as(); diff --git a/src/Interpreters/TranslateQualifiedNamesVisitor.h b/src/Interpreters/TranslateQualifiedNamesVisitor.h index 0f35d052ed2..9c46d926eca 100644 --- a/src/Interpreters/TranslateQualifiedNamesVisitor.h +++ b/src/Interpreters/TranslateQualifiedNamesVisitor.h @@ -52,7 +52,7 @@ private: static void visit(ASTExpressionList &, const ASTPtr &, Data &); static void visit(ASTFunction &, const ASTPtr &, Data &); - static void extractJoinUsingColumns(const ASTPtr ast, Data & data); + static void extractJoinUsingColumns(ASTPtr ast, Data & data); }; /// Visits AST for names qualification. diff --git a/src/Interpreters/TreeCNFConverter.h b/src/Interpreters/TreeCNFConverter.h index 0c090c8d56b..a5d42e6b989 100644 --- a/src/Interpreters/TreeCNFConverter.h +++ b/src/Interpreters/TreeCNFConverter.h @@ -36,7 +36,7 @@ public: using OrGroup = std::set; using AndGroup = std::set; - CNFQuery(AndGroup && statements_) : statements(std::move(statements_)) { } + CNFQuery(AndGroup && statements_) : statements(std::move(statements_)) { } /// NOLINT template CNFQuery & filterAlwaysTrueGroups(P predicate_is_unknown) /// delete always true groups @@ -91,7 +91,7 @@ public: CNFQuery & appendGroup(AndGroup&& and_group) { for (auto && or_group : and_group) - statements.emplace(std::move(or_group)); + statements.emplace(or_group); return *this; } diff --git a/src/Parsers/ASTAssignment.h b/src/Parsers/ASTAssignment.h index 88d4bb96c15..a37a31ae38e 100644 --- a/src/Parsers/ASTAssignment.h +++ b/src/Parsers/ASTAssignment.h @@ -28,6 +28,7 @@ public: protected: void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override { + settings.ostr << (settings.hilite ? hilite_identifier : ""); settings.writeIdentifier(column_name); settings.ostr << (settings.hilite ? hilite_none : ""); diff --git a/src/Parsers/ASTCreateQuery.h b/src/Parsers/ASTCreateQuery.h index a0070892b79..04755a02399 100644 --- a/src/Parsers/ASTCreateQuery.h +++ b/src/Parsers/ASTCreateQuery.h @@ -51,7 +51,7 @@ public: void formatImpl(const FormatSettings & s, FormatState & state, FormatStateStacked frame) const override; - bool empty() + bool empty() const { return (!columns || columns->children.empty()) && (!indices || indices->children.empty()) && (!constraints || constraints->children.empty()) && (!projections || projections->children.empty()); diff --git a/src/Parsers/ASTFunctionWithKeyValueArguments.h b/src/Parsers/ASTFunctionWithKeyValueArguments.h index 5820e8564ac..4b745e2c1a2 100644 --- a/src/Parsers/ASTFunctionWithKeyValueArguments.h +++ b/src/Parsers/ASTFunctionWithKeyValueArguments.h @@ -19,7 +19,6 @@ public: /// Value is closed in brackets (HOST '127.0.0.1') bool second_with_brackets; -public: explicit ASTPair(bool second_with_brackets_) : second_with_brackets(second_with_brackets_) { @@ -54,7 +53,6 @@ public: { } -public: String getID(char delim) const override; ASTPtr clone() const override; diff --git a/src/Parsers/ASTHelpers.h b/src/Parsers/ASTHelpers.h index 086b361bf85..0b3db8e02d5 100644 --- a/src/Parsers/ASTHelpers.h +++ b/src/Parsers/ASTHelpers.h @@ -6,7 +6,7 @@ namespace DB { -static inline bool isFunctionCast(const ASTFunction * function) +static inline bool isFunctionCast(const ASTFunction * function) /// NOLINT { if (function) return function->name == "CAST" || function->name == "_CAST"; diff --git a/src/Parsers/ASTProjectionSelectQuery.h b/src/Parsers/ASTProjectionSelectQuery.h index 71334c50868..d93c10b6e39 100644 --- a/src/Parsers/ASTProjectionSelectQuery.h +++ b/src/Parsers/ASTProjectionSelectQuery.h @@ -26,10 +26,10 @@ public: ASTPtr & refSelect() { return getExpression(Expression::SELECT); } - const ASTPtr with() const { return getExpression(Expression::WITH); } - const ASTPtr select() const { return getExpression(Expression::SELECT); } - const ASTPtr groupBy() const { return getExpression(Expression::GROUP_BY); } - const ASTPtr orderBy() const { return getExpression(Expression::ORDER_BY); } + ASTPtr with() const { return getExpression(Expression::WITH); } + ASTPtr select() const { return getExpression(Expression::SELECT); } + ASTPtr groupBy() const { return getExpression(Expression::GROUP_BY); } + ASTPtr orderBy() const { return getExpression(Expression::ORDER_BY); } /// Set/Reset/Remove expression. void setExpression(Expression expr, ASTPtr && ast); diff --git a/src/Parsers/ASTQueryWithOnCluster.h b/src/Parsers/ASTQueryWithOnCluster.h index b309ae5e847..c5daaa6ce37 100644 --- a/src/Parsers/ASTQueryWithOnCluster.h +++ b/src/Parsers/ASTQueryWithOnCluster.h @@ -17,7 +17,7 @@ public: /// new_database should be used by queries that refer to default db /// and default_database is specified for remote server - virtual ASTPtr getRewrittenASTWithoutOnCluster(const std::string & new_database = {}) const = 0; + virtual ASTPtr getRewrittenASTWithoutOnCluster(const std::string & new_database = {}) const = 0; /// NOLINT /// Returns a query prepared for execution on remote server std::string getRewrittenQueryWithoutOnCluster(const std::string & new_database = {}) const; diff --git a/src/Parsers/ASTSelectQuery.h b/src/Parsers/ASTSelectQuery.h index 1c631783fdb..9a8f1dbd2e7 100644 --- a/src/Parsers/ASTSelectQuery.h +++ b/src/Parsers/ASTSelectQuery.h @@ -91,21 +91,21 @@ public: ASTPtr & refWhere() { return getExpression(Expression::WHERE); } ASTPtr & refHaving() { return getExpression(Expression::HAVING); } - const ASTPtr with() const { return getExpression(Expression::WITH); } - const ASTPtr select() const { return getExpression(Expression::SELECT); } - const ASTPtr tables() const { return getExpression(Expression::TABLES); } - const ASTPtr prewhere() const { return getExpression(Expression::PREWHERE); } - const ASTPtr where() const { return getExpression(Expression::WHERE); } - const ASTPtr groupBy() const { return getExpression(Expression::GROUP_BY); } - const ASTPtr having() const { return getExpression(Expression::HAVING); } - const ASTPtr window() const { return getExpression(Expression::WINDOW); } - const ASTPtr orderBy() const { return getExpression(Expression::ORDER_BY); } - const ASTPtr limitByOffset() const { return getExpression(Expression::LIMIT_BY_OFFSET); } - const ASTPtr limitByLength() const { return getExpression(Expression::LIMIT_BY_LENGTH); } - const ASTPtr limitBy() const { return getExpression(Expression::LIMIT_BY); } - const ASTPtr limitOffset() const { return getExpression(Expression::LIMIT_OFFSET); } - const ASTPtr limitLength() const { return getExpression(Expression::LIMIT_LENGTH); } - const ASTPtr settings() const { return getExpression(Expression::SETTINGS); } + ASTPtr with() const { return getExpression(Expression::WITH); } + ASTPtr select() const { return getExpression(Expression::SELECT); } + ASTPtr tables() const { return getExpression(Expression::TABLES); } + ASTPtr prewhere() const { return getExpression(Expression::PREWHERE); } + ASTPtr where() const { return getExpression(Expression::WHERE); } + ASTPtr groupBy() const { return getExpression(Expression::GROUP_BY); } + ASTPtr having() const { return getExpression(Expression::HAVING); } + ASTPtr window() const { return getExpression(Expression::WINDOW); } + ASTPtr orderBy() const { return getExpression(Expression::ORDER_BY); } + ASTPtr limitByOffset() const { return getExpression(Expression::LIMIT_BY_OFFSET); } + ASTPtr limitByLength() const { return getExpression(Expression::LIMIT_BY_LENGTH); } + ASTPtr limitBy() const { return getExpression(Expression::LIMIT_BY); } + ASTPtr limitOffset() const { return getExpression(Expression::LIMIT_OFFSET); } + ASTPtr limitLength() const { return getExpression(Expression::LIMIT_LENGTH); } + ASTPtr settings() const { return getExpression(Expression::SETTINGS); } bool hasFiltration() const { return where() || prewhere() || having(); } diff --git a/src/Parsers/ASTTTLElement.h b/src/Parsers/ASTTTLElement.h index a396a4c54e0..9705cafbce3 100644 --- a/src/Parsers/ASTTTLElement.h +++ b/src/Parsers/ASTTTLElement.h @@ -37,8 +37,8 @@ public: ASTPtr clone() const override; - const ASTPtr ttl() const { return getExpression(ttl_expr_pos); } - const ASTPtr where() const { return getExpression(where_expr_pos); } + ASTPtr ttl() const { return getExpression(ttl_expr_pos); } + ASTPtr where() const { return getExpression(where_expr_pos); } void setTTL(ASTPtr && ast) { setExpression(ttl_expr_pos, std::forward(ast)); } void setWhere(ASTPtr && ast) { setExpression(where_expr_pos, std::forward(ast)); } @@ -50,7 +50,6 @@ private: int ttl_expr_pos; int where_expr_pos; -private: void setExpression(int & pos, ASTPtr && ast); ASTPtr getExpression(int pos, bool clone = false) const; }; diff --git a/src/Parsers/ASTTableOverrides.cpp b/src/Parsers/ASTTableOverrides.cpp index 8fc21db218f..0f34a9fb247 100644 --- a/src/Parsers/ASTTableOverrides.cpp +++ b/src/Parsers/ASTTableOverrides.cpp @@ -93,7 +93,7 @@ ASTPtr ASTTableOverrideList::tryGetTableOverride(const String & name) const return children[it->second]; } -void ASTTableOverrideList::setTableOverride(const String & name, const ASTPtr ast) +void ASTTableOverrideList::setTableOverride(const String & name, ASTPtr ast) { auto it = positions.find(name); if (it == positions.end()) diff --git a/src/Parsers/ASTTableOverrides.h b/src/Parsers/ASTTableOverrides.h index c0603f7a8e0..c47260789d8 100644 --- a/src/Parsers/ASTTableOverrides.h +++ b/src/Parsers/ASTTableOverrides.h @@ -40,7 +40,7 @@ public: String getID(char) const override { return "TableOverrideList"; } ASTPtr clone() const override; void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override; - void setTableOverride(const String & name, const ASTPtr ast); + void setTableOverride(const String & name, ASTPtr ast); void removeTableOverride(const String & name); ASTPtr tryGetTableOverride(const String & name) const; bool hasOverride(const String & name) const; diff --git a/src/Parsers/ASTUseQuery.h b/src/Parsers/ASTUseQuery.h index 4e4a13c2a7f..16d449f905f 100644 --- a/src/Parsers/ASTUseQuery.h +++ b/src/Parsers/ASTUseQuery.h @@ -25,7 +25,6 @@ protected: void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override { settings.ostr << (settings.hilite ? hilite_keyword : "") << "USE " << (settings.hilite ? hilite_none : "") << backQuoteIfNeed(database); - return; } }; diff --git a/src/Parsers/Access/ASTUserNameWithHost.h b/src/Parsers/Access/ASTUserNameWithHost.h index ada9bfb0673..bd28b42b48a 100644 --- a/src/Parsers/Access/ASTUserNameWithHost.h +++ b/src/Parsers/Access/ASTUserNameWithHost.h @@ -23,7 +23,7 @@ public: void concatParts(); ASTUserNameWithHost() = default; - ASTUserNameWithHost(const String & name_) : base_name(name_) {} + explicit ASTUserNameWithHost(const String & name_) : base_name(name_) {} String getID(char) const override { return "UserNameWithHost"; } ASTPtr clone() const override { return std::make_shared(*this); } void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override; @@ -39,7 +39,7 @@ public: auto begin() const { return names.begin(); } auto end() const { return names.end(); } auto front() const { return *begin(); } - void push_back(const String & name_) { names.push_back(std::make_shared(name_)); } + void push_back(const String & name_) { names.push_back(std::make_shared(name_)); } /// NOLINT Strings toStrings() const; void concatParts(); diff --git a/src/Parsers/CommonParsers.h b/src/Parsers/CommonParsers.h index 58fac2341cf..d2911754b24 100644 --- a/src/Parsers/CommonParsers.h +++ b/src/Parsers/CommonParsers.h @@ -33,7 +33,8 @@ class ParserToken : public IParserBase private: TokenType token_type; public: - ParserToken(TokenType token_type_) : token_type(token_type_) {} + ParserToken(TokenType token_type_) : token_type(token_type_) {} /// NOLINT + protected: const char * getName() const override { return "token"; } diff --git a/src/Parsers/ExpressionListParsers.h b/src/Parsers/ExpressionListParsers.h index 358fe778f91..86d0fd0f861 100644 --- a/src/Parsers/ExpressionListParsers.h +++ b/src/Parsers/ExpressionListParsers.h @@ -207,7 +207,7 @@ private: ParserPtr elem_parser; public: - ParserCastExpression(ParserPtr && elem_parser_) + explicit ParserCastExpression(ParserPtr && elem_parser_) : elem_parser(std::move(elem_parser_)) { } diff --git a/src/Parsers/IAST.h b/src/Parsers/IAST.h index fdf821c4a0b..bd8167c64fe 100644 --- a/src/Parsers/IAST.h +++ b/src/Parsers/IAST.h @@ -69,7 +69,7 @@ public: } /** Get the text that identifies this element. */ - virtual String getID(char delimiter = '_') const = 0; + virtual String getID(char delimiter = '_') const = 0; /// NOLINT ASTPtr ptr() { return shared_from_this(); } diff --git a/src/Parsers/ParserExplainQuery.h b/src/Parsers/ParserExplainQuery.h index a1865e30239..ba30e97a58f 100644 --- a/src/Parsers/ParserExplainQuery.h +++ b/src/Parsers/ParserExplainQuery.h @@ -14,7 +14,7 @@ protected: const char * getName() const override { return "EXPLAIN"; } bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override; public: - ParserExplainQuery(const char* end_) : end(end_) {} + explicit ParserExplainQuery(const char* end_) : end(end_) {} }; } diff --git a/src/Parsers/ParserQueryWithOutput.h b/src/Parsers/ParserQueryWithOutput.h index 854d5a74ffd..1fd7bec1eea 100644 --- a/src/Parsers/ParserQueryWithOutput.h +++ b/src/Parsers/ParserQueryWithOutput.h @@ -15,7 +15,7 @@ protected: const char * getName() const override { return "Query with output"; } bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override; public: - ParserQueryWithOutput(const char * end_) : end(end_) {} + explicit ParserQueryWithOutput(const char * end_) : end(end_) {} }; } diff --git a/src/Parsers/ParserTablesInSelectQuery.h b/src/Parsers/ParserTablesInSelectQuery.h index 9e5b591ccbe..772f1992f4d 100644 --- a/src/Parsers/ParserTablesInSelectQuery.h +++ b/src/Parsers/ParserTablesInSelectQuery.h @@ -21,7 +21,7 @@ protected: class ParserTablesInSelectQueryElement : public IParserBase { public: - ParserTablesInSelectQueryElement(bool is_first_) : is_first(is_first_) {} + explicit ParserTablesInSelectQueryElement(bool is_first_) : is_first(is_first_) {} protected: const char * getName() const override { return "table, table function, subquery or list of joined tables"; } diff --git a/src/Processors/Chunk.h b/src/Processors/Chunk.h index e70ba57a267..1c9240ba114 100644 --- a/src/Processors/Chunk.h +++ b/src/Processors/Chunk.h @@ -90,7 +90,7 @@ public: bool hasRows() const { return num_rows > 0; } bool hasColumns() const { return !columns.empty(); } bool empty() const { return !hasRows() && !hasColumns(); } - operator bool() const { return !empty(); } + operator bool() const { return !empty(); } /// NOLINT void addColumn(ColumnPtr column); void addColumn(size_t position, ColumnPtr column); diff --git a/src/Processors/Formats/ISchemaReader.h b/src/Processors/Formats/ISchemaReader.h index 67a8eb88d61..2d35809e26a 100644 --- a/src/Processors/Formats/ISchemaReader.h +++ b/src/Processors/Formats/ISchemaReader.h @@ -14,7 +14,7 @@ namespace DB class ISchemaReader { public: - ISchemaReader(ReadBuffer & in_) : in(in_) {} + explicit ISchemaReader(ReadBuffer & in_) : in(in_) {} virtual NamesAndTypesList readSchema() = 0; diff --git a/src/Processors/Formats/Impl/ArrowBufferedStreams.h b/src/Processors/Formats/Impl/ArrowBufferedStreams.h index d649c52557f..e06eab04f1b 100644 --- a/src/Processors/Formats/Impl/ArrowBufferedStreams.h +++ b/src/Processors/Formats/Impl/ArrowBufferedStreams.h @@ -44,7 +44,7 @@ class RandomAccessFileFromSeekableReadBuffer : public arrow::io::RandomAccessFil public: RandomAccessFileFromSeekableReadBuffer(SeekableReadBuffer & in_, off_t file_size_); - RandomAccessFileFromSeekableReadBuffer(SeekableReadBufferWithSize & in_); + explicit RandomAccessFileFromSeekableReadBuffer(SeekableReadBufferWithSize & in_); arrow::Result GetSize() override; diff --git a/src/Processors/Formats/Impl/AvroRowInputFormat.h b/src/Processors/Formats/Impl/AvroRowInputFormat.h index 1e8ee4aebb9..7a598de1f6a 100644 --- a/src/Processors/Formats/Impl/AvroRowInputFormat.h +++ b/src/Processors/Formats/Impl/AvroRowInputFormat.h @@ -61,7 +61,7 @@ private: , target_column_idx(target_column_idx_) , deserialize_fn(deserialize_fn_) {} - Action(SkipFn skip_fn_) + explicit Action(SkipFn skip_fn_) : type(Skip) , skip_fn(skip_fn_) {} diff --git a/src/Processors/Formats/Impl/CapnProtoRowOutputFormat.h b/src/Processors/Formats/Impl/CapnProtoRowOutputFormat.h index 288b36508ce..12dc5eda2b3 100644 --- a/src/Processors/Formats/Impl/CapnProtoRowOutputFormat.h +++ b/src/Processors/Formats/Impl/CapnProtoRowOutputFormat.h @@ -15,7 +15,7 @@ namespace DB class CapnProtoOutputStream : public kj::OutputStream { public: - CapnProtoOutputStream(WriteBuffer & out_); + explicit CapnProtoOutputStream(WriteBuffer & out_); void write(const void * buffer, size_t size) override; diff --git a/src/Processors/Formats/Impl/ConstantExpressionTemplate.h b/src/Processors/Formats/Impl/ConstantExpressionTemplate.h index 6659243df63..c5d4f033258 100644 --- a/src/Processors/Formats/Impl/ConstantExpressionTemplate.h +++ b/src/Processors/Formats/Impl/ConstantExpressionTemplate.h @@ -3,6 +3,8 @@ #include #include #include +#include +#include namespace DB { diff --git a/src/Processors/Formats/Impl/ORCBlockOutputFormat.h b/src/Processors/Formats/Impl/ORCBlockOutputFormat.h index 2ffee597e8f..f69fd1c0aab 100644 --- a/src/Processors/Formats/Impl/ORCBlockOutputFormat.h +++ b/src/Processors/Formats/Impl/ORCBlockOutputFormat.h @@ -17,7 +17,7 @@ class WriteBuffer; class ORCOutputStream : public orc::OutputStream { public: - ORCOutputStream(WriteBuffer & out_); + explicit ORCOutputStream(WriteBuffer & out_); uint64_t getLength() const override; uint64_t getNaturalWriteSize() const override; diff --git a/src/Processors/Formats/Impl/RegexpRowInputFormat.h b/src/Processors/Formats/Impl/RegexpRowInputFormat.h index 75c630d0607..04f24bbb3e4 100644 --- a/src/Processors/Formats/Impl/RegexpRowInputFormat.h +++ b/src/Processors/Formats/Impl/RegexpRowInputFormat.h @@ -22,7 +22,7 @@ class ReadBuffer; class RegexpFieldExtractor { public: - RegexpFieldExtractor(const FormatSettings & format_settings); + explicit RegexpFieldExtractor(const FormatSettings & format_settings); /// Return true if row was successfully parsed and row fields were extracted. bool parseRow(PeekableReadBuffer & buf); diff --git a/src/Processors/Formats/Impl/TabSeparatedRowInputFormat.h b/src/Processors/Formats/Impl/TabSeparatedRowInputFormat.h index ed67a8256bc..abab5b02c96 100644 --- a/src/Processors/Formats/Impl/TabSeparatedRowInputFormat.h +++ b/src/Processors/Formats/Impl/TabSeparatedRowInputFormat.h @@ -53,7 +53,7 @@ public: bool parseFieldDelimiterWithDiagnosticInfo(WriteBuffer & out) override; bool parseRowEndWithDiagnosticInfo(WriteBuffer & out) override; - FormatSettings::EscapingRule getEscapingRule() + FormatSettings::EscapingRule getEscapingRule() const { return is_raw ? FormatSettings::EscapingRule::Raw : FormatSettings::EscapingRule::Escaped; } diff --git a/src/Processors/Merges/Algorithms/FixedSizeDequeWithGaps.h b/src/Processors/Merges/Algorithms/FixedSizeDequeWithGaps.h index 35cfded4214..ff8f113d9a6 100644 --- a/src/Processors/Merges/Algorithms/FixedSizeDequeWithGaps.h +++ b/src/Processors/Merges/Algorithms/FixedSizeDequeWithGaps.h @@ -1,5 +1,7 @@ #pragma once +#include + namespace DB { diff --git a/src/Processors/Merges/Algorithms/Graphite.cpp b/src/Processors/Merges/Algorithms/Graphite.cpp index 2c6d08ed287..c0f595fa539 100644 --- a/src/Processors/Merges/Algorithms/Graphite.cpp +++ b/src/Processors/Merges/Algorithms/Graphite.cpp @@ -89,7 +89,7 @@ inline static const Patterns & selectPatternsForMetricType(const Graphite::Param Graphite::RollupRule selectPatternForPath( const Graphite::Params & params, - const StringRef path) + StringRef path) { const Graphite::Pattern * first_match = &undef_pattern; diff --git a/src/Processors/Merges/Algorithms/Graphite.h b/src/Processors/Merges/Algorithms/Graphite.h index dc39cb46386..05306ebe30f 100644 --- a/src/Processors/Merges/Algorithms/Graphite.h +++ b/src/Processors/Merges/Algorithms/Graphite.h @@ -147,7 +147,7 @@ struct Params using RollupRule = std::pair; -Graphite::RollupRule selectPatternForPath(const Graphite::Params & params, const StringRef path); +Graphite::RollupRule selectPatternForPath(const Graphite::Params & params, StringRef path); void setGraphitePatternsFromConfig(ContextPtr context, const String & config_element, Graphite::Params & params); diff --git a/src/Processors/Merges/Algorithms/MergedData.h b/src/Processors/Merges/Algorithms/MergedData.h index 9bf33d72f31..89da346980d 100644 --- a/src/Processors/Merges/Algorithms/MergedData.h +++ b/src/Processors/Merges/Algorithms/MergedData.h @@ -1,5 +1,11 @@ #pragma once +#include +#include +#include +#include + + namespace DB { diff --git a/src/Processors/Port.h b/src/Processors/Port.h index 9f27b440be5..7cb25f3930e 100644 --- a/src/Processors/Port.h +++ b/src/Processors/Port.h @@ -214,7 +214,7 @@ protected: public: using Data = State::Data; - Port(Block header_) : header(std::move(header_)) {} + Port(Block header_) : header(std::move(header_)) {} /// NOLINT Port(Block header_, IProcessor * processor_) : header(std::move(header_)), processor(processor_) {} void setUpdateInfo(UpdateInfo * info) { update_info = info; } @@ -303,12 +303,12 @@ public: Chunk ALWAYS_INLINE pull(bool set_not_needed = false) { - auto data_ = pullData(set_not_needed); + auto pull_data = pullData(set_not_needed); - if (data_.exception) - std::rethrow_exception(data_.exception); + if (pull_data.exception) + std::rethrow_exception(pull_data.exception); - return std::move(data_.chunk); + return std::move(pull_data.chunk); } bool ALWAYS_INLINE isFinished() const @@ -396,7 +396,7 @@ public: void ALWAYS_INLINE pushException(std::exception_ptr exception) { - pushData({.chunk = {}, .exception = std::move(exception)}); + pushData({.chunk = {}, .exception = exception}); } void ALWAYS_INLINE pushData(Data data_) diff --git a/src/Processors/QueueBuffer.h b/src/Processors/QueueBuffer.h index 826f4a22b8b..6856e214823 100644 --- a/src/Processors/QueueBuffer.h +++ b/src/Processors/QueueBuffer.h @@ -17,7 +17,7 @@ private: public: String getName() const override { return "QueueBuffer"; } - QueueBuffer(Block header) + explicit QueueBuffer(Block header) : IAccumulatingTransform(header, header) { } diff --git a/src/Processors/Transforms/AggregatingInOrderTransform.h b/src/Processors/Transforms/AggregatingInOrderTransform.h index 929ab98d6e6..e4c217a8f81 100644 --- a/src/Processors/Transforms/AggregatingInOrderTransform.h +++ b/src/Processors/Transforms/AggregatingInOrderTransform.h @@ -11,7 +11,7 @@ namespace DB struct ChunkInfoWithAllocatedBytes : public ChunkInfo { - ChunkInfoWithAllocatedBytes(Int64 allocated_bytes_) + explicit ChunkInfoWithAllocatedBytes(Int64 allocated_bytes_) : allocated_bytes(allocated_bytes_) {} Int64 allocated_bytes; }; diff --git a/src/Processors/Transforms/AggregatingTransform.h b/src/Processors/Transforms/AggregatingTransform.h index 01df264005b..d7917fc95a7 100644 --- a/src/Processors/Transforms/AggregatingTransform.h +++ b/src/Processors/Transforms/AggregatingTransform.h @@ -12,7 +12,7 @@ class AggregatedArenasChunkInfo : public ChunkInfo { public: Arenas arenas; - AggregatedArenasChunkInfo(Arenas arenas_) + explicit AggregatedArenasChunkInfo(Arenas arenas_) : arenas(std::move(arenas_)) {} }; diff --git a/src/Processors/Transforms/ColumnGathererTransform.h b/src/Processors/Transforms/ColumnGathererTransform.h index 2d013e596ce..da6dc877abf 100644 --- a/src/Processors/Transforms/ColumnGathererTransform.h +++ b/src/Processors/Transforms/ColumnGathererTransform.h @@ -20,7 +20,7 @@ struct RowSourcePart RowSourcePart() = default; - RowSourcePart(size_t source_num, bool skip_flag = false) + explicit RowSourcePart(size_t source_num, bool skip_flag = false) { static_assert(sizeof(*this) == 1, "Size of RowSourcePart is too big due to compiler settings"); setSourceNum(source_num); diff --git a/src/Processors/Transforms/PostgreSQLSource.cpp b/src/Processors/Transforms/PostgreSQLSource.cpp index 88f092a2533..a31cd879257 100644 --- a/src/Processors/Transforms/PostgreSQLSource.cpp +++ b/src/Processors/Transforms/PostgreSQLSource.cpp @@ -28,7 +28,7 @@ PostgreSQLSource::PostgreSQLSource( postgres::ConnectionHolderPtr connection_holder_, const std::string & query_str_, const Block & sample_block, - const UInt64 max_block_size_) + UInt64 max_block_size_) : SourceWithProgress(sample_block.cloneEmpty()) , query_str(query_str_) , max_block_size(max_block_size_) @@ -43,7 +43,7 @@ PostgreSQLSource::PostgreSQLSource( std::shared_ptr tx_, const std::string & query_str_, const Block & sample_block, - const UInt64 max_block_size_, + UInt64 max_block_size_, bool auto_commit_) : SourceWithProgress(sample_block.cloneEmpty()) , query_str(query_str_) diff --git a/src/Processors/Transforms/PostgreSQLSource.h b/src/Processors/Transforms/PostgreSQLSource.h index c7e55c09c32..bd6203042bb 100644 --- a/src/Processors/Transforms/PostgreSQLSource.h +++ b/src/Processors/Transforms/PostgreSQLSource.h @@ -24,7 +24,7 @@ public: postgres::ConnectionHolderPtr connection_holder_, const String & query_str_, const Block & sample_block, - const UInt64 max_block_size_); + UInt64 max_block_size_); String getName() const override { return "PostgreSQL"; } @@ -33,7 +33,7 @@ protected: std::shared_ptr tx_, const std::string & query_str_, const Block & sample_block, - const UInt64 max_block_size_, + UInt64 max_block_size_, bool auto_commit_); String query_str; diff --git a/src/Processors/Transforms/WindowTransform.h b/src/Processors/Transforms/WindowTransform.h index 077979e83b9..d536c8780d2 100644 --- a/src/Processors/Transforms/WindowTransform.h +++ b/src/Processors/Transforms/WindowTransform.h @@ -245,7 +245,6 @@ public: return RowNumber{first_block_number, 0}; } -public: /* * Data (formerly) inherited from ISimpleTransform, needed for the * implementation of the IProcessor interface. @@ -349,10 +348,10 @@ public: template <> struct fmt::formatter { - constexpr auto parse(format_parse_context & ctx) + static constexpr auto parse(format_parse_context & ctx) { - auto it = ctx.begin(); - auto end = ctx.end(); + const auto * it = ctx.begin(); + const auto * end = ctx.end(); /// Only support {}. if (it != end && *it != '}') diff --git a/src/QueryPipeline/SizeLimits.h b/src/QueryPipeline/SizeLimits.h index ce7e1795475..fc052714b0c 100644 --- a/src/QueryPipeline/SizeLimits.h +++ b/src/QueryPipeline/SizeLimits.h @@ -26,7 +26,7 @@ struct SizeLimits UInt64 max_bytes = 0; OverflowMode overflow_mode = OverflowMode::THROW; - SizeLimits() {} + SizeLimits() = default; SizeLimits(UInt64 max_rows_, UInt64 max_bytes_, OverflowMode overflow_mode_) : max_rows(max_rows_), max_bytes(max_bytes_), overflow_mode(overflow_mode_) {} diff --git a/src/Server/HTTPHandlerRequestFilter.h b/src/Server/HTTPHandlerRequestFilter.h index 078dcb04595..3236b35d5ae 100644 --- a/src/Server/HTTPHandlerRequestFilter.h +++ b/src/Server/HTTPHandlerRequestFilter.h @@ -40,7 +40,7 @@ static inline bool checkExpression(const StringRef & match_str, const std::pair< return match_str == expression.first; } -static inline auto methodsFilter(Poco::Util::AbstractConfiguration & config, const std::string & config_path) +static inline auto methodsFilter(Poco::Util::AbstractConfiguration & config, const std::string & config_path) /// NOLINT { std::vector methods; Poco::StringTokenizer tokenizer(config.getString(config_path), ","); @@ -64,7 +64,7 @@ static inline auto getExpression(const std::string & expression) return std::make_pair(expression, compiled_regex); } -static inline auto urlFilter(Poco::Util::AbstractConfiguration & config, const std::string & config_path) +static inline auto urlFilter(Poco::Util::AbstractConfiguration & config, const std::string & config_path) /// NOLINT { return [expression = getExpression(config.getString(config_path))](const HTTPServerRequest & request) { @@ -75,7 +75,7 @@ static inline auto urlFilter(Poco::Util::AbstractConfiguration & config, const s }; } -static inline auto headersFilter(Poco::Util::AbstractConfiguration & config, const std::string & prefix) +static inline auto headersFilter(Poco::Util::AbstractConfiguration & config, const std::string & prefix) /// NOLINT { std::unordered_map> headers_expression; Poco::Util::AbstractConfiguration::Keys headers_name; diff --git a/src/Server/ProtocolServerAdapter.h b/src/Server/ProtocolServerAdapter.h index b50ea9c3de3..90aec7471ee 100644 --- a/src/Server/ProtocolServerAdapter.h +++ b/src/Server/ProtocolServerAdapter.h @@ -52,7 +52,7 @@ private: class Impl { public: - virtual ~Impl() {} + virtual ~Impl() = default; virtual void start() = 0; virtual void stop() = 0; virtual bool isStopping() const = 0; diff --git a/src/Server/TCPHandler.h b/src/Server/TCPHandler.h index b6ce9fa7507..153b8c35ea4 100644 --- a/src/Server/TCPHandler.h +++ b/src/Server/TCPHandler.h @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include diff --git a/src/Server/TCPHandlerFactory.h b/src/Server/TCPHandlerFactory.h index 03b2592198d..6e27dfc93bd 100644 --- a/src/Server/TCPHandlerFactory.h +++ b/src/Server/TCPHandlerFactory.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include diff --git a/src/Storages/Cache/RemoteFileCachePolicy.h b/src/Storages/Cache/RemoteFileCachePolicy.h index 7d742d6ea14..5c212264bd2 100644 --- a/src/Storages/Cache/RemoteFileCachePolicy.h +++ b/src/Storages/Cache/RemoteFileCachePolicy.h @@ -1,6 +1,10 @@ #pragma once + +#include + namespace DB { + struct RemoteFileCacheWeightFunction { size_t operator()(const RemoteCacheController & cache) const { return cache.getFileSize(); } @@ -14,4 +18,5 @@ struct RemoteFileCacheReleaseFunction controller->close(); } }; + } diff --git a/src/Storages/CompressionCodecSelector.h b/src/Storages/CompressionCodecSelector.h index 746b3ce37ee..4c088924cdb 100644 --- a/src/Storages/CompressionCodecSelector.h +++ b/src/Storages/CompressionCodecSelector.h @@ -69,7 +69,7 @@ private: std::vector elements; public: - CompressionCodecSelector() {} /// Always returns the default method. + CompressionCodecSelector() = default; /// Always returns the default method. CompressionCodecSelector(const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix) { @@ -78,7 +78,7 @@ public: for (const auto & name : keys) { - if (!startsWith(name.data(), "case")) + if (!startsWith(name, "case")) throw Exception("Unknown element in config: " + config_prefix + "." + name + ", must be 'case'", ErrorCodes::UNKNOWN_ELEMENT_IN_CONFIG); elements.emplace_back(config, config_prefix + "." + name); diff --git a/src/Storages/Kafka/StorageKafka.cpp b/src/Storages/Kafka/StorageKafka.cpp index 30acbcdf62b..ae470cdccc9 100644 --- a/src/Storages/Kafka/StorageKafka.cpp +++ b/src/Storages/Kafka/StorageKafka.cpp @@ -405,7 +405,7 @@ ProducerBufferPtr StorageKafka::createWriteBuffer(const Block & header) } -ConsumerBufferPtr StorageKafka::createReadBuffer(const size_t consumer_number) +ConsumerBufferPtr StorageKafka::createReadBuffer(size_t consumer_number) { cppkafka::Configuration conf; diff --git a/src/Storages/Kafka/StorageKafka.h b/src/Storages/Kafka/StorageKafka.h index 62de3e5183d..03e90b1f6c3 100644 --- a/src/Storages/Kafka/StorageKafka.h +++ b/src/Storages/Kafka/StorageKafka.h @@ -120,7 +120,7 @@ private: HandleKafkaErrorMode handle_error_mode; SettingsChanges createSettingsAdjustments(); - ConsumerBufferPtr createReadBuffer(const size_t consumer_number); + ConsumerBufferPtr createReadBuffer(size_t consumer_number); /// If named_collection is specified. String collection_name; diff --git a/src/Storages/LiveView/LiveViewEventsSource.h b/src/Storages/LiveView/LiveViewEventsSource.h index 77ee06c702c..1f9f8bfb785 100644 --- a/src/Storages/LiveView/LiveViewEventsSource.h +++ b/src/Storages/LiveView/LiveViewEventsSource.h @@ -44,7 +44,7 @@ public: : SourceWithProgress({ColumnWithTypeAndName(ColumnUInt64::create(), std::make_shared(), "version")}), storage(std::move(storage_)), blocks_ptr(std::move(blocks_ptr_)), blocks_metadata_ptr(std::move(blocks_metadata_ptr_)), - active_ptr(std::move(active_ptr_)), has_limit(has_limit_), + active_ptr(active_ptr_), has_limit(has_limit_), limit(limit_), heartbeat_interval_usec(heartbeat_interval_sec_ * 1000000) { diff --git a/src/Storages/LiveView/LiveViewSource.h b/src/Storages/LiveView/LiveViewSource.h index ec726359581..8d63890f603 100644 --- a/src/Storages/LiveView/LiveViewSource.h +++ b/src/Storages/LiveView/LiveViewSource.h @@ -26,7 +26,7 @@ public: : SourceWithProgress(storage_->getHeader()) , storage(std::move(storage_)), blocks_ptr(std::move(blocks_ptr_)), blocks_metadata_ptr(std::move(blocks_metadata_ptr_)), - active_ptr(std::move(active_ptr_)), + active_ptr(active_ptr_), has_limit(has_limit_), limit(limit_), heartbeat_interval_usec(heartbeat_interval_sec_ * 1000000) { diff --git a/src/Storages/LiveView/StorageBlocks.h b/src/Storages/LiveView/StorageBlocks.h index b87d3f051d0..01293a1e5d7 100644 --- a/src/Storages/LiveView/StorageBlocks.h +++ b/src/Storages/LiveView/StorageBlocks.h @@ -18,9 +18,9 @@ public: QueryProcessingStage::Enum to_stage_) : IStorage(table_id_), pipes(std::move(pipes_)), to_stage(to_stage_) { - StorageInMemoryMetadata metadata_; - metadata_.setColumns(columns_); - setInMemoryMetadata(metadata_); + StorageInMemoryMetadata storage_metadata; + storage_metadata.setColumns(columns_); + setInMemoryMetadata(storage_metadata); } static StoragePtr createStorage(const StorageID & table_id, const ColumnsDescription & columns, Pipes pipes, QueryProcessingStage::Enum to_stage) diff --git a/src/Storages/LiveView/TemporaryLiveViewCleaner.h b/src/Storages/LiveView/TemporaryLiveViewCleaner.h index 3fe0079a46f..9cc5933eb89 100644 --- a/src/Storages/LiveView/TemporaryLiveViewCleaner.h +++ b/src/Storages/LiveView/TemporaryLiveViewCleaner.h @@ -31,7 +31,7 @@ public: private: friend std::unique_ptr::deleter_type; - TemporaryLiveViewCleaner(ContextMutablePtr global_context_); + explicit TemporaryLiveViewCleaner(ContextMutablePtr global_context_); ~TemporaryLiveViewCleaner(); void backgroundThreadFunc(); diff --git a/src/Storages/MarkCache.h b/src/Storages/MarkCache.h index 06143e954f8..a3f92650426 100644 --- a/src/Storages/MarkCache.h +++ b/src/Storages/MarkCache.h @@ -40,7 +40,7 @@ private: using Base = LRUCache; public: - MarkCache(size_t max_size_in_bytes) + explicit MarkCache(size_t max_size_in_bytes) : Base(max_size_in_bytes) {} /// Calculate key from path to file and offset. diff --git a/src/Storages/MergeTree/ActiveDataPartSet.h b/src/Storages/MergeTree/ActiveDataPartSet.h index 0b747ab83b9..8ab03625d5c 100644 --- a/src/Storages/MergeTree/ActiveDataPartSet.h +++ b/src/Storages/MergeTree/ActiveDataPartSet.h @@ -22,15 +22,14 @@ using Strings = std::vector; class ActiveDataPartSet { public: - ActiveDataPartSet(MergeTreeDataFormatVersion format_version_) : format_version(format_version_) {} + explicit ActiveDataPartSet(MergeTreeDataFormatVersion format_version_) : format_version(format_version_) {} ActiveDataPartSet(MergeTreeDataFormatVersion format_version_, const Strings & names); - ActiveDataPartSet(const ActiveDataPartSet & other) - : format_version(other.format_version) - , part_info_to_name(other.part_info_to_name) - {} + ActiveDataPartSet(const ActiveDataPartSet & other) = default; - ActiveDataPartSet(ActiveDataPartSet && other) noexcept { swap(other); } + ActiveDataPartSet & operator=(const ActiveDataPartSet & other) = default; + + ActiveDataPartSet(ActiveDataPartSet && other) noexcept = default; void swap(ActiveDataPartSet & other) noexcept { @@ -38,16 +37,6 @@ public: std::swap(part_info_to_name, other.part_info_to_name); } - ActiveDataPartSet & operator=(const ActiveDataPartSet & other) - { - if (&other != this) - { - ActiveDataPartSet tmp(other); - swap(tmp); - } - return *this; - } - /// Returns true if the part was actually added. If out_replaced_parts != nullptr, it will contain /// parts that were replaced from the set by the newly added part. bool add(const String & name, Strings * out_replaced_parts = nullptr); diff --git a/src/Storages/MergeTree/AllMergeSelector.cpp b/src/Storages/MergeTree/AllMergeSelector.cpp index 79080df1570..5e406c6e4f7 100644 --- a/src/Storages/MergeTree/AllMergeSelector.cpp +++ b/src/Storages/MergeTree/AllMergeSelector.cpp @@ -8,7 +8,7 @@ namespace DB AllMergeSelector::PartsRange AllMergeSelector::select( const PartsRanges & parts_ranges, - const size_t /*max_total_size_to_merge*/) + size_t /*max_total_size_to_merge*/) { size_t min_partition_size = 0; PartsRanges::const_iterator best_partition; diff --git a/src/Storages/MergeTree/AllMergeSelector.h b/src/Storages/MergeTree/AllMergeSelector.h index d3b399b2fc5..6cd3bb6f3fa 100644 --- a/src/Storages/MergeTree/AllMergeSelector.h +++ b/src/Storages/MergeTree/AllMergeSelector.h @@ -13,7 +13,7 @@ public: /// Parameter max_total_size_to_merge is ignored. PartsRange select( const PartsRanges & parts_ranges, - const size_t max_total_size_to_merge) override; + size_t max_total_size_to_merge) override; }; } diff --git a/src/Storages/MergeTree/BackgroundProcessList.h b/src/Storages/MergeTree/BackgroundProcessList.h index 81aded5e45c..baf3e281257 100644 --- a/src/Storages/MergeTree/BackgroundProcessList.h +++ b/src/Storages/MergeTree/BackgroundProcessList.h @@ -26,7 +26,7 @@ public: BackgroundProcessListEntry(const BackgroundProcessListEntry &) = delete; BackgroundProcessListEntry & operator=(const BackgroundProcessListEntry &) = delete; - BackgroundProcessListEntry(BackgroundProcessListEntry &&) = default; + BackgroundProcessListEntry(BackgroundProcessListEntry &&) noexcept = default; BackgroundProcessListEntry(BackgroundProcessList & list_, const typename container_t::iterator it_, const CurrentMetrics::Metric & metric) : list(list_), it{it_}, metric_increment{metric} diff --git a/src/Storages/MergeTree/BoolMask.h b/src/Storages/MergeTree/BoolMask.h index c26a0ed6c58..11f9238aa28 100644 --- a/src/Storages/MergeTree/BoolMask.h +++ b/src/Storages/MergeTree/BoolMask.h @@ -6,7 +6,7 @@ struct BoolMask bool can_be_true = false; bool can_be_false = false; - BoolMask() {} + BoolMask() = default; BoolMask(bool can_be_true_, bool can_be_false_) : can_be_true(can_be_true_), can_be_false(can_be_false_) {} BoolMask operator &(const BoolMask & m) const diff --git a/src/Storages/MergeTree/ColumnSizeEstimator.h b/src/Storages/MergeTree/ColumnSizeEstimator.h index 61c0ac64dbd..597dc80e525 100644 --- a/src/Storages/MergeTree/ColumnSizeEstimator.h +++ b/src/Storages/MergeTree/ColumnSizeEstimator.h @@ -1,6 +1,7 @@ #pragma once -#include "Storages/MergeTree/IMergeTreeDataPart.h" +#include +#include namespace DB diff --git a/src/Storages/MergeTree/KeyCondition.h b/src/Storages/MergeTree/KeyCondition.h index dee46ae52ce..afe4a9f3e20 100644 --- a/src/Storages/MergeTree/KeyCondition.h +++ b/src/Storages/MergeTree/KeyCondition.h @@ -31,7 +31,7 @@ struct FieldRef : public Field /// Create as explicit field without block. template - FieldRef(T && value) : Field(std::forward(value)) {} + FieldRef(T && value) : Field(std::forward(value)) {} /// NOLINT /// Create as reference to field in block. FieldRef(ColumnsWithTypeAndName * columns_, size_t row_idx_, size_t column_idx_) @@ -60,10 +60,10 @@ public: bool right_included = false; /// includes the right border /// The whole universe (not null). - Range() {} + Range() {} /// NOLINT /// One point. - Range(const FieldRef & point) + Range(const FieldRef & point) /// NOLINT : left(point), right(point), left_included(true), right_included(true) {} /// A bounded two-sided range. @@ -313,8 +313,8 @@ private: ALWAYS_TRUE, }; - RPNElement() {} - RPNElement(Function function_) : function(function_) {} + RPNElement() = default; + RPNElement(Function function_) : function(function_) {} /// NOLINT RPNElement(Function function_, size_t key_column_) : function(function_), key_column(key_column_) {} RPNElement(Function function_, size_t key_column_, const Range & range_) : function(function_), range(range_), key_column(key_column_) {} diff --git a/src/Storages/MergeTree/LeaderElection.h b/src/Storages/MergeTree/LeaderElection.h index b05026d52f9..6d3281c8c61 100644 --- a/src/Storages/MergeTree/LeaderElection.h +++ b/src/Storages/MergeTree/LeaderElection.h @@ -1,11 +1,13 @@ #pragma once +#include #include #include #include #include #include +namespace fs = std::filesystem; namespace zkutil { diff --git a/src/Storages/MergeTree/LevelMergeSelector.cpp b/src/Storages/MergeTree/LevelMergeSelector.cpp index 7bcfbf6160a..16947277463 100644 --- a/src/Storages/MergeTree/LevelMergeSelector.cpp +++ b/src/Storages/MergeTree/LevelMergeSelector.cpp @@ -105,7 +105,7 @@ void selectWithinPartition( LevelMergeSelector::PartsRange LevelMergeSelector::select( const PartsRanges & parts_ranges, - const size_t max_total_size_to_merge) + size_t max_total_size_to_merge) { Estimator estimator; diff --git a/src/Storages/MergeTree/LevelMergeSelector.h b/src/Storages/MergeTree/LevelMergeSelector.h index 5849b34e320..f4080c379c4 100644 --- a/src/Storages/MergeTree/LevelMergeSelector.h +++ b/src/Storages/MergeTree/LevelMergeSelector.h @@ -21,7 +21,7 @@ public: PartsRange select( const PartsRanges & parts_ranges, - const size_t max_total_size_to_merge) override; + size_t max_total_size_to_merge) override; private: const Settings settings; diff --git a/src/Storages/MergeTree/MergeSelector.h b/src/Storages/MergeTree/MergeSelector.h index aac805823a9..c55f738f879 100644 --- a/src/Storages/MergeTree/MergeSelector.h +++ b/src/Storages/MergeTree/MergeSelector.h @@ -63,7 +63,7 @@ public: */ virtual PartsRange select( const PartsRanges & parts_ranges, - const size_t max_total_size_to_merge) = 0; + size_t max_total_size_to_merge) = 0; virtual ~IMergeSelector() = default; }; diff --git a/src/Storages/MergeTree/MergeTreeBaseSelectProcessor.h b/src/Storages/MergeTree/MergeTreeBaseSelectProcessor.h index c462c34aa83..2e906ecfce0 100644 --- a/src/Storages/MergeTree/MergeTreeBaseSelectProcessor.h +++ b/src/Storages/MergeTree/MergeTreeBaseSelectProcessor.h @@ -86,7 +86,6 @@ protected: void initializeRangeReaders(MergeTreeReadTask & task); -protected: const MergeTreeData & storage; StorageMetadataPtr metadata_snapshot; diff --git a/src/Storages/MergeTree/MergeTreeBlockReadUtils.cpp b/src/Storages/MergeTree/MergeTreeBlockReadUtils.cpp index 07d51d25700..dadccd2f9dc 100644 --- a/src/Storages/MergeTree/MergeTreeBlockReadUtils.cpp +++ b/src/Storages/MergeTree/MergeTreeBlockReadUtils.cpp @@ -118,9 +118,9 @@ NameSet injectRequiredColumns(const MergeTreeData & storage, const StorageMetada MergeTreeReadTask::MergeTreeReadTask( - const MergeTreeData::DataPartPtr & data_part_, const MarkRanges & mark_ranges_, const size_t part_index_in_query_, + const MergeTreeData::DataPartPtr & data_part_, const MarkRanges & mark_ranges_, size_t part_index_in_query_, const Names & ordered_names_, const NameSet & column_name_set_, const NamesAndTypesList & columns_, - const NamesAndTypesList & pre_columns_, const bool remove_prewhere_column_, const bool should_reorder_, + const NamesAndTypesList & pre_columns_, bool remove_prewhere_column_, bool should_reorder_, MergeTreeBlockSizePredictorPtr && size_predictor_) : data_part{data_part_}, mark_ranges{mark_ranges_}, part_index_in_query{part_index_in_query_}, ordered_names{ordered_names_}, column_name_set{column_name_set_}, columns{columns_}, pre_columns{pre_columns_}, diff --git a/src/Storages/MergeTree/MergeTreeBlockReadUtils.h b/src/Storages/MergeTree/MergeTreeBlockReadUtils.h index b931a13c027..1f70ca72f39 100644 --- a/src/Storages/MergeTree/MergeTreeBlockReadUtils.h +++ b/src/Storages/MergeTree/MergeTreeBlockReadUtils.h @@ -55,9 +55,9 @@ struct MergeTreeReadTask bool isFinished() const { return mark_ranges.empty() && range_reader.isCurrentRangeFinished(); } MergeTreeReadTask( - const MergeTreeData::DataPartPtr & data_part_, const MarkRanges & mark_ranges_, const size_t part_index_in_query_, + const MergeTreeData::DataPartPtr & data_part_, const MarkRanges & mark_ranges_, size_t part_index_in_query_, const Names & ordered_names_, const NameSet & column_name_set_, const NamesAndTypesList & columns_, - const NamesAndTypesList & pre_columns_, const bool remove_prewhere_column_, const bool should_reorder_, + const NamesAndTypesList & pre_columns_, bool remove_prewhere_column_, bool should_reorder_, MergeTreeBlockSizePredictorPtr && size_predictor_); }; @@ -86,7 +86,7 @@ struct MergeTreeBlockSizePredictor void startBlock(); /// Updates statistic for more accurate prediction - void update(const Block & sample_block, const Columns & columns, size_t num_rows, double decay = DECAY()); + void update(const Block & sample_block, const Columns & columns, size_t num_rows, double decay = calculateDecay()); /// Return current block size (after update()) inline size_t getBlockSize() const @@ -112,7 +112,7 @@ struct MergeTreeBlockSizePredictor : 0; } - inline void updateFilteredRowsRation(size_t rows_was_read, size_t rows_was_filtered, double decay = DECAY()) + inline void updateFilteredRowsRation(size_t rows_was_read, size_t rows_was_filtered, double decay = calculateDecay()) { double alpha = std::pow(1. - decay, rows_was_read); double current_ration = rows_was_filtered / std::max(1.0, static_cast(rows_was_read)); @@ -125,7 +125,7 @@ struct MergeTreeBlockSizePredictor /// After n=NUM_UPDATES_TO_TARGET_WEIGHT updates v_{n} = (1 - TARGET_WEIGHT) * v_{0} + TARGET_WEIGHT * v_{target} static constexpr double TARGET_WEIGHT = 0.5; static constexpr size_t NUM_UPDATES_TO_TARGET_WEIGHT = 8192; - static double DECAY() { return 1. - std::pow(TARGET_WEIGHT, 1. / NUM_UPDATES_TO_TARGET_WEIGHT); } + static double calculateDecay() { return 1. - std::pow(TARGET_WEIGHT, 1. / NUM_UPDATES_TO_TARGET_WEIGHT); } protected: diff --git a/src/Storages/MergeTree/MergeTreeData.h b/src/Storages/MergeTree/MergeTreeData.h index 1e7f127c85b..d1c48b19985 100644 --- a/src/Storages/MergeTree/MergeTreeData.h +++ b/src/Storages/MergeTree/MergeTreeData.h @@ -244,7 +244,7 @@ public: class Transaction : private boost::noncopyable { public: - Transaction(MergeTreeData & data_) : data(data_) {} + explicit Transaction(MergeTreeData & data_) : data(data_) {} DataPartsVector commit(MergeTreeData::DataPartsLock * acquired_parts_lock = nullptr); @@ -877,7 +877,7 @@ public: /// Lock part in zookeeper for shared data in several nodes /// Overridden in StorageReplicatedMergeTree - virtual void lockSharedData(const IMergeTreeDataPart &, bool = false) const {} + virtual void lockSharedData(const IMergeTreeDataPart &, bool = false) const {} /// NOLINT /// Unlock shared data part in zookeeper /// Overridden in StorageReplicatedMergeTree diff --git a/src/Storages/MergeTree/MergeTreeDataMergerMutator.h b/src/Storages/MergeTree/MergeTreeDataMergerMutator.h index ae09e2c916c..e64c13ca6c3 100644 --- a/src/Storages/MergeTree/MergeTreeDataMergerMutator.h +++ b/src/Storages/MergeTree/MergeTreeDataMergerMutator.h @@ -176,7 +176,6 @@ private: bool need_remove_expired_values, const MergeTreeData::MergingParams & merging_params) const; -private: MergeTreeData & data; const size_t max_tasks_count; diff --git a/src/Storages/MergeTree/MergeTreeDataPartChecksum.h b/src/Storages/MergeTree/MergeTreeDataPartChecksum.h index 06f1fb06f25..15acb88aa0f 100644 --- a/src/Storages/MergeTree/MergeTreeDataPartChecksum.h +++ b/src/Storages/MergeTree/MergeTreeDataPartChecksum.h @@ -26,7 +26,7 @@ struct MergeTreeDataPartChecksum UInt64 uncompressed_size {}; uint128 uncompressed_hash {}; - MergeTreeDataPartChecksum() {} + MergeTreeDataPartChecksum() = default; MergeTreeDataPartChecksum(UInt64 file_size_, uint128 file_hash_) : file_size(file_size_), file_hash(file_hash_) {} MergeTreeDataPartChecksum(UInt64 file_size_, uint128 file_hash_, UInt64 uncompressed_size_, uint128 uncompressed_hash_) : file_size(file_size_), file_hash(file_hash_), is_compressed(true), diff --git a/src/Storages/MergeTree/MergeTreeDataPartType.h b/src/Storages/MergeTree/MergeTreeDataPartType.h index fecd9d00cdc..7cf23c7a045 100644 --- a/src/Storages/MergeTree/MergeTreeDataPartType.h +++ b/src/Storages/MergeTree/MergeTreeDataPartType.h @@ -25,7 +25,7 @@ public: }; MergeTreeDataPartType() : value(UNKNOWN) {} - MergeTreeDataPartType(Value value_) : value(value_) {} + MergeTreeDataPartType(Value value_) : value(value_) {} /// NOLINT bool operator==(const MergeTreeDataPartType & other) const { diff --git a/src/Storages/MergeTree/MergeTreeIndexConditionBloomFilter.cpp b/src/Storages/MergeTree/MergeTreeIndexConditionBloomFilter.cpp index 2057dec957e..7b194de8103 100644 --- a/src/Storages/MergeTree/MergeTreeIndexConditionBloomFilter.cpp +++ b/src/Storages/MergeTree/MergeTreeIndexConditionBloomFilter.cpp @@ -552,7 +552,7 @@ bool MergeTreeIndexConditionBloomFilter::traverseASTEquals( for (const auto & f : value_field.get()) { - if ((f.isNull() && !is_nullable) || f.IsDecimal(f.getType())) + if ((f.isNull() && !is_nullable) || f.isDecimal(f.getType())) return false; mutable_column->insert(convertFieldToType(f, *actual_type, value_type.get())); diff --git a/src/Storages/MergeTree/MergeTreeIndexConditionBloomFilter.h b/src/Storages/MergeTree/MergeTreeIndexConditionBloomFilter.h index 5c6559ba298..27fd701c67b 100644 --- a/src/Storages/MergeTree/MergeTreeIndexConditionBloomFilter.h +++ b/src/Storages/MergeTree/MergeTreeIndexConditionBloomFilter.h @@ -38,7 +38,7 @@ public: ALWAYS_TRUE, }; - RPNElement(Function function_ = FUNCTION_UNKNOWN) : function(function_) {} + RPNElement(Function function_ = FUNCTION_UNKNOWN) : function(function_) {} /// NOLINT Function function = FUNCTION_UNKNOWN; std::vector> predicate; diff --git a/src/Storages/MergeTree/MergeTreeIndexFullText.h b/src/Storages/MergeTree/MergeTreeIndexFullText.h index 1826719df0b..5f5956553dc 100644 --- a/src/Storages/MergeTree/MergeTreeIndexFullText.h +++ b/src/Storages/MergeTree/MergeTreeIndexFullText.h @@ -102,7 +102,7 @@ private: ALWAYS_TRUE, }; - RPNElement( + RPNElement( /// NOLINT Function function_ = FUNCTION_UNKNOWN, size_t key_column_ = 0, std::unique_ptr && const_bloom_filter_ = nullptr) : function(function_), key_column(key_column_), bloom_filter(std::move(const_bloom_filter_)) {} diff --git a/src/Storages/MergeTree/MergeTreeIndexHypothesis.cpp b/src/Storages/MergeTree/MergeTreeIndexHypothesis.cpp index 6658730b7c1..088029d9e8e 100644 --- a/src/Storages/MergeTree/MergeTreeIndexHypothesis.cpp +++ b/src/Storages/MergeTree/MergeTreeIndexHypothesis.cpp @@ -18,7 +18,7 @@ MergeTreeIndexGranuleHypothesis::MergeTreeIndexGranuleHypothesis(const String & { } -MergeTreeIndexGranuleHypothesis::MergeTreeIndexGranuleHypothesis(const String & index_name_, const bool met_) +MergeTreeIndexGranuleHypothesis::MergeTreeIndexGranuleHypothesis(const String & index_name_, bool met_) : index_name(index_name_), is_empty(false), met(met_) { } diff --git a/src/Storages/MergeTree/MergeTreeIndexHypothesis.h b/src/Storages/MergeTree/MergeTreeIndexHypothesis.h index 43b56d9559f..578bb6f3f7a 100644 --- a/src/Storages/MergeTree/MergeTreeIndexHypothesis.h +++ b/src/Storages/MergeTree/MergeTreeIndexHypothesis.h @@ -16,7 +16,7 @@ struct MergeTreeIndexGranuleHypothesis : public IMergeTreeIndexGranule MergeTreeIndexGranuleHypothesis( const String & index_name_, - const bool met_); + bool met_); void serializeBinary(WriteBuffer & ostr) const override; void deserializeBinary(ReadBuffer & istr, MergeTreeIndexVersion version) override; @@ -55,7 +55,7 @@ private: class MergeTreeIndexHypothesis : public IMergeTreeIndex { public: - MergeTreeIndexHypothesis( + explicit MergeTreeIndexHypothesis( const IndexDescription & index_) : IMergeTreeIndex(index_) {} diff --git a/src/Storages/MergeTree/MergeTreeIndexMinMax.h b/src/Storages/MergeTree/MergeTreeIndexMinMax.h index 0e05e25fb36..9f78c86a498 100644 --- a/src/Storages/MergeTree/MergeTreeIndexMinMax.h +++ b/src/Storages/MergeTree/MergeTreeIndexMinMax.h @@ -68,7 +68,7 @@ private: class MergeTreeIndexMinMax : public IMergeTreeIndex { public: - MergeTreeIndexMinMax(const IndexDescription & index_) + explicit MergeTreeIndexMinMax(const IndexDescription & index_) : IMergeTreeIndex(index_) {} @@ -83,7 +83,7 @@ public: bool mayBenefitFromIndexForIn(const ASTPtr & node) const override; const char* getSerializedFileExtension() const override { return ".idx2"; } - MergeTreeIndexFormat getDeserializedFormat(const DiskPtr disk, const std::string & path_prefix) const override; + MergeTreeIndexFormat getDeserializedFormat(const DiskPtr disk, const std::string & path_prefix) const override; /// NOLINT }; } diff --git a/src/Storages/MergeTree/MergeTreeIndices.h b/src/Storages/MergeTree/MergeTreeIndices.h index a761fc3124e..984a2bb7762 100644 --- a/src/Storages/MergeTree/MergeTreeIndices.h +++ b/src/Storages/MergeTree/MergeTreeIndices.h @@ -29,7 +29,7 @@ struct MergeTreeIndexFormat MergeTreeIndexVersion version; const char* extension; - operator bool() const { return version != 0; } + operator bool() const { return version != 0; } /// NOLINT }; /// Stores some info about a single block of data. @@ -122,7 +122,7 @@ using MergeTreeIndexMergedConditions = std::vector &, String * reason)>; public: - MergeTreePartsMover(MergeTreeData * data_) + explicit MergeTreePartsMover(MergeTreeData * data_) : data(data_) , log(&Poco::Logger::get("MergeTreePartsMover")) { @@ -59,7 +59,6 @@ public: /// merge or mutation. void swapClonedPart(const std::shared_ptr & cloned_parts) const; -public: /// Can stop background moves and moves from queries ActionBlocker moves_blocker; diff --git a/src/Storages/MergeTree/MergeTreeReadPool.cpp b/src/Storages/MergeTree/MergeTreeReadPool.cpp index c89affb5365..3c31ffa7c97 100644 --- a/src/Storages/MergeTree/MergeTreeReadPool.cpp +++ b/src/Storages/MergeTree/MergeTreeReadPool.cpp @@ -18,9 +18,9 @@ namespace ErrorCodes namespace DB { MergeTreeReadPool::MergeTreeReadPool( - const size_t threads_, - const size_t sum_marks_, - const size_t min_marks_for_concurrent_read_, + size_t threads_, + size_t sum_marks_, + size_t min_marks_for_concurrent_read_, RangesInDataParts && parts_, const MergeTreeData & data_, const StorageMetadataPtr & metadata_snapshot_, @@ -28,7 +28,7 @@ MergeTreeReadPool::MergeTreeReadPool( const Names & column_names_, const BackoffSettings & backoff_settings_, size_t preferred_block_size_bytes_, - const bool do_not_steal_tasks_) + bool do_not_steal_tasks_) : backoff_settings{backoff_settings_} , backoff_state{threads_} , data{data_} @@ -45,7 +45,7 @@ MergeTreeReadPool::MergeTreeReadPool( } -MergeTreeReadTaskPtr MergeTreeReadPool::getTask(const size_t min_marks_to_read, const size_t thread, const Names & ordered_names) +MergeTreeReadTaskPtr MergeTreeReadPool::getTask(size_t min_marks_to_read, size_t thread, const Names & ordered_names) { const std::lock_guard lock{mutex}; @@ -149,7 +149,7 @@ Block MergeTreeReadPool::getHeader() const return metadata_snapshot->getSampleBlockForColumns(column_names, data.getVirtuals(), data.getStorageID()); } -void MergeTreeReadPool::profileFeedback(const ReadBufferFromFileBase::ProfileInfo info) +void MergeTreeReadPool::profileFeedback(ReadBufferFromFileBase::ProfileInfo info) { if (backoff_settings.min_read_latency_ms == 0 || do_not_steal_tasks) return; @@ -232,8 +232,8 @@ std::vector MergeTreeReadPool::fillPerPartInfo(const RangesInDataParts & void MergeTreeReadPool::fillPerThreadInfo( - const size_t threads, const size_t sum_marks, std::vector per_part_sum_marks, - const RangesInDataParts & parts, const size_t min_marks_for_concurrent_read) + size_t threads, size_t sum_marks, std::vector per_part_sum_marks, + const RangesInDataParts & parts, size_t min_marks_for_concurrent_read) { threads_tasks.resize(threads); if (parts.empty()) diff --git a/src/Storages/MergeTree/MergeTreeReadPool.h b/src/Storages/MergeTree/MergeTreeReadPool.h index aac4d5016a2..4ab4393ef5a 100644 --- a/src/Storages/MergeTree/MergeTreeReadPool.h +++ b/src/Storages/MergeTree/MergeTreeReadPool.h @@ -40,7 +40,7 @@ public: size_t min_concurrency = 1; /// Constants above is just an example. - BackoffSettings(const Settings & settings) + explicit BackoffSettings(const Settings & settings) : min_read_latency_ms(settings.read_backoff_min_latency_ms.totalMilliseconds()), max_throughput(settings.read_backoff_max_throughput), min_interval_between_events_ms(settings.read_backoff_min_interval_between_events_ms.totalMilliseconds()), @@ -63,27 +63,27 @@ private: Stopwatch time_since_prev_event {CLOCK_MONOTONIC_COARSE}; size_t num_events = 0; - BackoffState(size_t threads) : current_threads(threads) {} + explicit BackoffState(size_t threads) : current_threads(threads) {} }; BackoffState backoff_state; public: MergeTreeReadPool( - const size_t threads_, const size_t sum_marks_, const size_t min_marks_for_concurrent_read_, + size_t threads_, size_t sum_marks_, size_t min_marks_for_concurrent_read_, RangesInDataParts && parts_, const MergeTreeData & data_, const StorageMetadataPtr & metadata_snapshot_, const PrewhereInfoPtr & prewhere_info_, const Names & column_names_, const BackoffSettings & backoff_settings_, size_t preferred_block_size_bytes_, - const bool do_not_steal_tasks_ = false); + bool do_not_steal_tasks_ = false); - MergeTreeReadTaskPtr getTask(const size_t min_marks_to_read, const size_t thread, const Names & ordered_names); + MergeTreeReadTaskPtr getTask(size_t min_marks_to_read, size_t thread, const Names & ordered_names); /** Each worker could call this method and pass information about read performance. * If read performance is too low, pool could decide to lower number of threads: do not assign more tasks to several threads. * This allows to overcome excessive load to disk subsystem, when reads are not from page cache. */ - void profileFeedback(const ReadBufferFromFileBase::ProfileInfo info); + void profileFeedback(ReadBufferFromFileBase::ProfileInfo info); Block getHeader() const; @@ -91,8 +91,8 @@ private: std::vector fillPerPartInfo(const RangesInDataParts & parts); void fillPerThreadInfo( - const size_t threads, const size_t sum_marks, std::vector per_part_sum_marks, - const RangesInDataParts & parts, const size_t min_marks_for_concurrent_read); + size_t threads, size_t sum_marks, std::vector per_part_sum_marks, + const RangesInDataParts & parts, size_t min_marks_for_concurrent_read); const MergeTreeData & data; StorageMetadataPtr metadata_snapshot; diff --git a/src/Storages/MergeTree/MergeTreeSequentialSource.h b/src/Storages/MergeTree/MergeTreeSequentialSource.h index 7eefdd9335b..a7405140c6d 100644 --- a/src/Storages/MergeTree/MergeTreeSequentialSource.h +++ b/src/Storages/MergeTree/MergeTreeSequentialSource.h @@ -58,7 +58,6 @@ private: /// current row at which we stop reading size_t current_row = 0; -private: /// Closes readers and unlock part locks void finish(); }; diff --git a/src/Storages/MergeTree/MergeTreeSettings.h b/src/Storages/MergeTree/MergeTreeSettings.h index 6861599a1ac..3eb59b25562 100644 --- a/src/Storages/MergeTree/MergeTreeSettings.h +++ b/src/Storages/MergeTree/MergeTreeSettings.h @@ -150,6 +150,7 @@ struct Settings; M(UInt64, replicated_max_parallel_fetches_for_table, 0, "Obsolete setting, does nothing.", 0) \ M(Bool, write_final_mark, true, "Obsolete setting, does nothing.", 0) /// Settings that should not change after the creation of a table. + /// NOLINTNEXTLINE #define APPLY_FOR_IMMUTABLE_MERGE_TREE_SETTINGS(M) \ M(index_granularity) diff --git a/src/Storages/MergeTree/MergeTreeThreadSelectProcessor.cpp b/src/Storages/MergeTree/MergeTreeThreadSelectProcessor.cpp index 6a44da06f1f..145d292138a 100644 --- a/src/Storages/MergeTree/MergeTreeThreadSelectProcessor.cpp +++ b/src/Storages/MergeTree/MergeTreeThreadSelectProcessor.cpp @@ -13,15 +13,15 @@ namespace ErrorCodes } MergeTreeThreadSelectProcessor::MergeTreeThreadSelectProcessor( - const size_t thread_, + size_t thread_, const MergeTreeReadPoolPtr & pool_, - const size_t min_marks_to_read_, - const UInt64 max_block_size_rows_, + size_t min_marks_to_read_, + UInt64 max_block_size_rows_, size_t preferred_block_size_bytes_, size_t preferred_max_column_in_block_size_bytes_, const MergeTreeData & storage_, const StorageMetadataPtr & metadata_snapshot_, - const bool use_uncompressed_cache_, + bool use_uncompressed_cache_, const PrewhereInfoPtr & prewhere_info_, ExpressionActionsSettings actions_settings, const MergeTreeReaderSettings & reader_settings_, diff --git a/src/Storages/MergeTree/MergeTreeThreadSelectProcessor.h b/src/Storages/MergeTree/MergeTreeThreadSelectProcessor.h index 110c4fa34e6..ae25ca2a88a 100644 --- a/src/Storages/MergeTree/MergeTreeThreadSelectProcessor.h +++ b/src/Storages/MergeTree/MergeTreeThreadSelectProcessor.h @@ -15,15 +15,15 @@ class MergeTreeThreadSelectProcessor final : public MergeTreeBaseSelectProcessor { public: MergeTreeThreadSelectProcessor( - const size_t thread_, + size_t thread_, const std::shared_ptr & pool_, - const size_t min_marks_to_read_, - const UInt64 max_block_size_, + size_t min_marks_to_read_, + UInt64 max_block_size_, size_t preferred_block_size_bytes_, size_t preferred_max_column_in_block_size_bytes_, const MergeTreeData & storage_, const StorageMetadataPtr & metadata_snapshot_, - const bool use_uncompressed_cache_, + bool use_uncompressed_cache_, const PrewhereInfoPtr & prewhere_info_, ExpressionActionsSettings actions_settings, const MergeTreeReaderSettings & reader_settings_, diff --git a/src/Storages/MergeTree/MergeTreeWhereOptimizer.h b/src/Storages/MergeTree/MergeTreeWhereOptimizer.h index 4aa7aa532a8..fa14fea94d1 100644 --- a/src/Storages/MergeTree/MergeTreeWhereOptimizer.h +++ b/src/Storages/MergeTree/MergeTreeWhereOptimizer.h @@ -79,8 +79,6 @@ private: /// Transform Conditions list to WHERE or PREWHERE expression. static ASTPtr reconstruct(const Conditions & conditions); - void optimizeConjunction(ASTSelectQuery & select, ASTFunction * const fun) const; - void optimizeArbitrary(ASTSelectQuery & select) const; UInt64 getIdentifiersColumnSize(const NameSet & identifiers) const; diff --git a/src/Storages/MergeTree/PartMovesBetweenShardsOrchestrator.h b/src/Storages/MergeTree/PartMovesBetweenShardsOrchestrator.h index 14ef91c0777..07c5c55d873 100644 --- a/src/Storages/MergeTree/PartMovesBetweenShardsOrchestrator.h +++ b/src/Storages/MergeTree/PartMovesBetweenShardsOrchestrator.h @@ -63,7 +63,7 @@ public: }; EntryState(): value(TODO) {} - EntryState(Value value_): value(value_) {} + EntryState(Value value_): value(value_) {} /// NOLINT Value value; @@ -173,7 +173,6 @@ private: void removePins(const Entry & entry, zkutil::ZooKeeperPtr zk); void syncStateFromZK(); -private: StorageReplicatedMergeTree & storage; String zookeeper_path; diff --git a/src/Storages/MergeTree/RPNBuilder.h b/src/Storages/MergeTree/RPNBuilder.h index d63781db67d..183808c9290 100644 --- a/src/Storages/MergeTree/RPNBuilder.h +++ b/src/Storages/MergeTree/RPNBuilder.h @@ -22,8 +22,8 @@ public: using AtomFromASTFunc = std::function< bool(const ASTPtr & node, ContextPtr context, Block & block_with_constants, RPNElement & out)>; - RPNBuilder(const SelectQueryInfo & query_info, ContextPtr context_, const AtomFromASTFunc & atomFromAST_) - : WithContext(context_), atomFromAST(atomFromAST_) + RPNBuilder(const SelectQueryInfo & query_info, ContextPtr context_, const AtomFromASTFunc & atom_from_ast_) + : WithContext(context_), atom_from_ast(atom_from_ast_) { /** Evaluation of expressions that depend only on constants. * For the index to be used, if it is written, for example `WHERE Date = toDate(now())`. @@ -79,7 +79,7 @@ private: } } - if (!atomFromAST(node, getContext(), block_with_constants, element)) + if (!atom_from_ast(node, getContext(), block_with_constants, element)) { element.function = RPNElement::FUNCTION_UNKNOWN; } @@ -114,7 +114,7 @@ private: return true; } - const AtomFromASTFunc & atomFromAST; + const AtomFromASTFunc & atom_from_ast; Block block_with_constants; RPN rpn; }; diff --git a/src/Storages/MergeTree/ReplicatedMergeTreeAltersSequence.h b/src/Storages/MergeTree/ReplicatedMergeTreeAltersSequence.h index e5d3dd0a737..aa58e16a716 100644 --- a/src/Storages/MergeTree/ReplicatedMergeTreeAltersSequence.h +++ b/src/Storages/MergeTree/ReplicatedMergeTreeAltersSequence.h @@ -29,7 +29,6 @@ private: bool data_finished = false; }; -private: /// alter_version -> AlterState. std::map queue_state; diff --git a/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.h b/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.h index 509b52ec07f..861de620926 100644 --- a/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.h +++ b/src/Storages/MergeTree/ReplicatedMergeTreeCleanupThread.h @@ -24,7 +24,7 @@ class StorageReplicatedMergeTree; class ReplicatedMergeTreeCleanupThread { public: - ReplicatedMergeTreeCleanupThread(StorageReplicatedMergeTree & storage_); + explicit ReplicatedMergeTreeCleanupThread(StorageReplicatedMergeTree & storage_); void start() { task->activateAndSchedule(); } diff --git a/src/Storages/MergeTree/ReplicatedMergeTreeMergeStrategyPicker.h b/src/Storages/MergeTree/ReplicatedMergeTreeMergeStrategyPicker.h index 70eacbee102..91f5824f8fc 100644 --- a/src/Storages/MergeTree/ReplicatedMergeTreeMergeStrategyPicker.h +++ b/src/Storages/MergeTree/ReplicatedMergeTreeMergeStrategyPicker.h @@ -42,7 +42,7 @@ struct ReplicatedMergeTreeLogEntryData; class ReplicatedMergeTreeMergeStrategyPicker: public boost::noncopyable { public: - ReplicatedMergeTreeMergeStrategyPicker(StorageReplicatedMergeTree & storage_); + explicit ReplicatedMergeTreeMergeStrategyPicker(StorageReplicatedMergeTree & storage_); /// triggers refreshing the cached state (list of replicas etc.) /// used when we get new merge event from the zookeeper queue ( see queueUpdatingTask() etc ) diff --git a/src/Storages/MergeTree/ReplicatedMergeTreePartCheckThread.h b/src/Storages/MergeTree/ReplicatedMergeTreePartCheckThread.h index a8ce4fedd6d..7c2c2401bf0 100644 --- a/src/Storages/MergeTree/ReplicatedMergeTreePartCheckThread.h +++ b/src/Storages/MergeTree/ReplicatedMergeTreePartCheckThread.h @@ -30,7 +30,7 @@ class StorageReplicatedMergeTree; class ReplicatedMergeTreePartCheckThread { public: - ReplicatedMergeTreePartCheckThread(StorageReplicatedMergeTree & storage_); + explicit ReplicatedMergeTreePartCheckThread(StorageReplicatedMergeTree & storage_); ~ReplicatedMergeTreePartCheckThread(); /// Processing of the queue to be checked is done in the background thread, which you must first start. @@ -42,12 +42,12 @@ public: { ReplicatedMergeTreePartCheckThread * parent; - TemporarilyStop(ReplicatedMergeTreePartCheckThread * parent_) : parent(parent_) + explicit TemporarilyStop(ReplicatedMergeTreePartCheckThread * parent_) : parent(parent_) { parent->stop(); } - TemporarilyStop(TemporarilyStop && old) : parent(old.parent) + TemporarilyStop(TemporarilyStop && old) noexcept : parent(old.parent) { old.parent = nullptr; } diff --git a/src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp b/src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp index f13bf0c8c56..5f805c39ae2 100644 --- a/src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp +++ b/src/Storages/MergeTree/ReplicatedMergeTreeQueue.cpp @@ -971,7 +971,7 @@ ReplicatedMergeTreeQueue::StringSet ReplicatedMergeTreeQueue::moveSiblingPartsFo return parts_for_merge; } -bool ReplicatedMergeTreeQueue::checkReplaceRangeCanBeRemoved(const MergeTreePartInfo & part_info, const LogEntryPtr entry_ptr, const ReplicatedMergeTreeLogEntryData & current) const +bool ReplicatedMergeTreeQueue::checkReplaceRangeCanBeRemoved(const MergeTreePartInfo & part_info, LogEntryPtr entry_ptr, const ReplicatedMergeTreeLogEntryData & current) const { if (entry_ptr->type != LogEntry::REPLACE_RANGE) return false; @@ -1515,7 +1515,7 @@ ReplicatedMergeTreeQueue::SelectedEntryPtr ReplicatedMergeTreeQueue::selectEntry bool ReplicatedMergeTreeQueue::processEntry( std::function get_zookeeper, LogEntryPtr & entry, - const std::function func) + std::function func) { std::exception_ptr saved_exception; diff --git a/src/Storages/MergeTree/ReplicatedMergeTreeQueue.h b/src/Storages/MergeTree/ReplicatedMergeTreeQueue.h index 208ce73e5f1..1d10c504b3c 100644 --- a/src/Storages/MergeTree/ReplicatedMergeTreeQueue.h +++ b/src/Storages/MergeTree/ReplicatedMergeTreeQueue.h @@ -184,7 +184,7 @@ private: /// Check that entry_ptr is REPLACE_RANGE entry and can be removed from queue because current entry covers it bool checkReplaceRangeCanBeRemoved( - const MergeTreePartInfo & part_info, const LogEntryPtr entry_ptr, const ReplicatedMergeTreeLogEntryData & current) const; + const MergeTreePartInfo & part_info, LogEntryPtr entry_ptr, const ReplicatedMergeTreeLogEntryData & current) const; /// Ensures that only one thread is simultaneously updating mutations. std::mutex update_mutations_mutex; @@ -366,7 +366,7 @@ public: * If there was an exception during processing, it saves it in `entry`. * Returns true if there were no exceptions during the processing. */ - bool processEntry(std::function get_zookeeper, LogEntryPtr & entry, const std::function func); + bool processEntry(std::function get_zookeeper, LogEntryPtr & entry, std::function func); /// Count the number of merges and mutations of single parts in the queue. OperationsInQueue countMergesAndPartMutations() const; diff --git a/src/Storages/MergeTree/ReplicatedMergeTreeQuorumEntry.h b/src/Storages/MergeTree/ReplicatedMergeTreeQuorumEntry.h index f560850a6c6..4cdcc936e21 100644 --- a/src/Storages/MergeTree/ReplicatedMergeTreeQuorumEntry.h +++ b/src/Storages/MergeTree/ReplicatedMergeTreeQuorumEntry.h @@ -23,8 +23,8 @@ struct ReplicatedMergeTreeQuorumEntry size_t required_number_of_replicas{}; std::set replicas; - ReplicatedMergeTreeQuorumEntry() {} - ReplicatedMergeTreeQuorumEntry(const String & str) + ReplicatedMergeTreeQuorumEntry() = default; + explicit ReplicatedMergeTreeQuorumEntry(const String & str) { fromString(str); } diff --git a/src/Storages/MergeTree/ReplicatedMergeTreeRestartingThread.h b/src/Storages/MergeTree/ReplicatedMergeTreeRestartingThread.h index e62cff4baf6..99e56ffb366 100644 --- a/src/Storages/MergeTree/ReplicatedMergeTreeRestartingThread.h +++ b/src/Storages/MergeTree/ReplicatedMergeTreeRestartingThread.h @@ -22,7 +22,7 @@ class StorageReplicatedMergeTree; class ReplicatedMergeTreeRestartingThread { public: - ReplicatedMergeTreeRestartingThread(StorageReplicatedMergeTree & storage_); + explicit ReplicatedMergeTreeRestartingThread(StorageReplicatedMergeTree & storage_); void start() { task->activateAndSchedule(); } diff --git a/src/Storages/MergeTree/SimpleMergeSelector.cpp b/src/Storages/MergeTree/SimpleMergeSelector.cpp index 0775e021c76..434d44022df 100644 --- a/src/Storages/MergeTree/SimpleMergeSelector.cpp +++ b/src/Storages/MergeTree/SimpleMergeSelector.cpp @@ -202,7 +202,7 @@ void selectWithinPartition( SimpleMergeSelector::PartsRange SimpleMergeSelector::select( const PartsRanges & parts_ranges, - const size_t max_total_size_to_merge) + size_t max_total_size_to_merge) { Estimator estimator; diff --git a/src/Storages/MergeTree/SimpleMergeSelector.h b/src/Storages/MergeTree/SimpleMergeSelector.h index 3e104d1319a..11ffe8b672a 100644 --- a/src/Storages/MergeTree/SimpleMergeSelector.h +++ b/src/Storages/MergeTree/SimpleMergeSelector.h @@ -152,7 +152,7 @@ public: PartsRange select( const PartsRanges & parts_ranges, - const size_t max_total_size_to_merge) override; + size_t max_total_size_to_merge) override; private: const Settings settings; diff --git a/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h b/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h index 729b545e9a0..1dc1bd1eca4 100644 --- a/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h +++ b/src/Storages/MergeTree/StorageFromMergeTreeDataPart.h @@ -80,7 +80,7 @@ public: protected: /// Used in part mutation. - StorageFromMergeTreeDataPart(const MergeTreeData::DataPartPtr & part_) + explicit StorageFromMergeTreeDataPart(const MergeTreeData::DataPartPtr & part_) : IStorage(getIDFromPart(part_)) , parts({part_}) , storage(part_->storage) diff --git a/src/Storages/MergeTree/TTLMergeSelector.cpp b/src/Storages/MergeTree/TTLMergeSelector.cpp index 6a42ce039ac..d5657aa680d 100644 --- a/src/Storages/MergeTree/TTLMergeSelector.cpp +++ b/src/Storages/MergeTree/TTLMergeSelector.cpp @@ -18,7 +18,7 @@ const String & getPartitionIdForPart(const ITTLMergeSelector::Part & part_info) IMergeSelector::PartsRange ITTLMergeSelector::select( const PartsRanges & parts_ranges, - const size_t max_total_size_to_merge) + size_t max_total_size_to_merge) { using Iterator = IMergeSelector::PartsRange::const_iterator; Iterator best_begin; diff --git a/src/Storages/MergeTree/TTLMergeSelector.h b/src/Storages/MergeTree/TTLMergeSelector.h index d41ba6f519d..88dc1fffee2 100644 --- a/src/Storages/MergeTree/TTLMergeSelector.h +++ b/src/Storages/MergeTree/TTLMergeSelector.h @@ -30,7 +30,7 @@ public: PartsRange select( const PartsRanges & parts_ranges, - const size_t max_total_size_to_merge) override; + size_t max_total_size_to_merge) override; /// Get TTL value for part, may depend on child type and some settings in /// constructor. diff --git a/src/Storages/PostgreSQL/MaterializedPostgreSQLConsumer.h b/src/Storages/PostgreSQL/MaterializedPostgreSQLConsumer.h index 41284b5b5a1..a01f9394190 100644 --- a/src/Storages/PostgreSQL/MaterializedPostgreSQLConsumer.h +++ b/src/Storages/PostgreSQL/MaterializedPostgreSQLConsumer.h @@ -126,7 +126,7 @@ private: static Int64 getLSNValue(const std::string & lsn) { UInt32 upper_half, lower_half; - std::sscanf(lsn.data(), "%X/%X", &upper_half, &lower_half); + std::sscanf(lsn.data(), "%X/%X", &upper_half, &lower_half); /// NOLINT return (static_cast(upper_half) << 32) + lower_half; } diff --git a/src/Storages/PostgreSQL/StorageMaterializedPostgreSQL.cpp b/src/Storages/PostgreSQL/StorageMaterializedPostgreSQL.cpp index 1d26b6027ae..582a568cb48 100644 --- a/src/Storages/PostgreSQL/StorageMaterializedPostgreSQL.cpp +++ b/src/Storages/PostgreSQL/StorageMaterializedPostgreSQL.cpp @@ -291,11 +291,11 @@ Pipe StorageMaterializedPostgreSQL::read( std::shared_ptr StorageMaterializedPostgreSQL::getMaterializedColumnsDeclaration( - const String name, const String type, UInt64 default_value) + String name, String type, UInt64 default_value) { auto column_declaration = std::make_shared(); - column_declaration->name = name; + column_declaration->name = std::move(name); column_declaration->type = makeASTFunction(type); column_declaration->default_specifier = "MATERIALIZED"; diff --git a/src/Storages/PostgreSQL/StorageMaterializedPostgreSQL.h b/src/Storages/PostgreSQL/StorageMaterializedPostgreSQL.h index ff9b95cad7c..e6ce3bbdf65 100644 --- a/src/Storages/PostgreSQL/StorageMaterializedPostgreSQL.h +++ b/src/Storages/PostgreSQL/StorageMaterializedPostgreSQL.h @@ -135,7 +135,7 @@ protected: private: static std::shared_ptr getMaterializedColumnsDeclaration( - const String name, const String type, UInt64 default_value); + String name, String type, UInt64 default_value); ASTPtr getColumnDeclaration(const DataTypePtr & data_type) const; diff --git a/src/Storages/RabbitMQ/RabbitMQHandler.h b/src/Storages/RabbitMQ/RabbitMQHandler.h index 8f355c4a0dc..25b32a29f58 100644 --- a/src/Storages/RabbitMQ/RabbitMQHandler.h +++ b/src/Storages/RabbitMQ/RabbitMQHandler.h @@ -7,6 +7,7 @@ #include #include #include +#include namespace DB { diff --git a/src/Storages/StorageMaterializedMySQL.h b/src/Storages/StorageMaterializedMySQL.h index 8ba98c3000f..ae874649b40 100644 --- a/src/Storages/StorageMaterializedMySQL.h +++ b/src/Storages/StorageMaterializedMySQL.h @@ -38,7 +38,7 @@ public: void drop() override { nested_storage->drop(); } private: - [[noreturn]] void throwNotAllowed() const + [[noreturn]] static void throwNotAllowed() { throw Exception("This method is not allowed for MaterializedMySQL", ErrorCodes::NOT_IMPLEMENTED); } diff --git a/src/Storages/StorageMongoDB.h b/src/Storages/StorageMongoDB.h index 16b85364c5c..0edfb558759 100644 --- a/src/Storages/StorageMongoDB.h +++ b/src/Storages/StorageMongoDB.h @@ -22,7 +22,7 @@ public: StorageMongoDB( const StorageID & table_id_, const std::string & host_, - short unsigned int port_, + uint16_t port_, const std::string & database_name_, const std::string & collection_name_, const std::string & username_, @@ -49,7 +49,7 @@ private: void connectIfNotConnected(); const std::string host; - const short unsigned int port; + const uint16_t port; /// NOLINT const std::string database_name; const std::string collection_name; const std::string username; diff --git a/src/Storages/StorageNull.h b/src/Storages/StorageNull.h index 5fef7f984e4..82baa98834d 100644 --- a/src/Storages/StorageNull.h +++ b/src/Storages/StorageNull.h @@ -61,11 +61,11 @@ protected: const StorageID & table_id_, ColumnsDescription columns_description_, ConstraintsDescription constraints_, const String & comment) : IStorage(table_id_) { - StorageInMemoryMetadata metadata_; - metadata_.setColumns(columns_description_); - metadata_.setConstraints(constraints_); - metadata_.setComment(comment); - setInMemoryMetadata(metadata_); + StorageInMemoryMetadata storage_metadata; + storage_metadata.setColumns(columns_description_); + storage_metadata.setConstraints(constraints_); + storage_metadata.setComment(comment); + setInMemoryMetadata(storage_metadata); } }; diff --git a/src/Storages/StorageReplicatedMergeTree.h b/src/Storages/StorageReplicatedMergeTree.h index 056671dc164..935bd048603 100644 --- a/src/Storages/StorageReplicatedMergeTree.h +++ b/src/Storages/StorageReplicatedMergeTree.h @@ -283,7 +283,7 @@ public: // Return table id, common for different replicas String getTableSharedID() const; - static const String getDefaultZooKeeperName() { return default_zookeeper_name; } + static String getDefaultZooKeeperName() { return default_zookeeper_name; } /// Check if there are new broken disks and enqueue part recovery tasks. void checkBrokenDisks(); @@ -837,6 +837,7 @@ String getPartNamePossiblyFake(MergeTreeDataFormatVersion format_version, const * PS. Perhaps it would be better to add a flag to the DataPart that a part is inserted into ZK. * But here it's too easy to get confused with the consistency of this flag. */ +/// NOLINTNEXTLINE #define MAX_AGE_OF_LOCAL_PART_THAT_WASNT_ADDED_TO_ZOOKEEPER (5 * 60) } diff --git a/src/Storages/StorageS3.cpp b/src/Storages/StorageS3.cpp index c685a542d13..ec506ad0cd0 100644 --- a/src/Storages/StorageS3.cpp +++ b/src/Storages/StorageS3.cpp @@ -233,7 +233,7 @@ StorageS3Source::StorageS3Source( const ColumnsDescription & columns_, UInt64 max_block_size_, UInt64 max_single_read_retries_, - const String compression_hint_, + String compression_hint_, const std::shared_ptr & client_, const String & bucket_, std::shared_ptr file_iterator_) @@ -245,7 +245,7 @@ StorageS3Source::StorageS3Source( , columns_desc(columns_) , max_block_size(max_block_size_) , max_single_read_retries(max_single_read_retries_) - , compression_hint(compression_hint_) + , compression_hint(std::move(compression_hint_)) , client(client_) , sample_block(sample_block_) , format_settings(format_settings_) diff --git a/src/Storages/StorageS3.h b/src/Storages/StorageS3.h index cecf7f50860..b2283687e2b 100644 --- a/src/Storages/StorageS3.h +++ b/src/Storages/StorageS3.h @@ -71,7 +71,7 @@ public: const ColumnsDescription & columns_, UInt64 max_block_size_, UInt64 max_single_read_retries_, - const String compression_hint_, + String compression_hint_, const std::shared_ptr & client_, const String & bucket, std::shared_ptr file_iterator_); diff --git a/src/Storages/StorageTableFunction.h b/src/Storages/StorageTableFunction.h index 0b7ab30fa24..8054762d389 100644 --- a/src/Storages/StorageTableFunction.h +++ b/src/Storages/StorageTableFunction.h @@ -6,6 +6,7 @@ #include #include #include +#include namespace DB @@ -148,7 +149,7 @@ public: if (nested) StorageProxy::renameInMemory(new_table_id); else - IStorage::renameInMemory(new_table_id); + IStorage::renameInMemory(new_table_id); /// NOLINT } bool isView() const override { return false; } diff --git a/src/Storages/StorageView.h b/src/Storages/StorageView.h index 5ca23434356..cd36a10aae7 100644 --- a/src/Storages/StorageView.h +++ b/src/Storages/StorageView.h @@ -40,7 +40,7 @@ public: size_t max_block_size, unsigned num_streams) override; - void replaceWithSubquery(ASTSelectQuery & select_query, ASTPtr & view_name, const StorageMetadataPtr & metadata_snapshot) const + static void replaceWithSubquery(ASTSelectQuery & select_query, ASTPtr & view_name, const StorageMetadataPtr & metadata_snapshot) { replaceWithSubquery(select_query, metadata_snapshot->getSelectQuery().inner_query->clone(), view_name); } diff --git a/src/Storages/System/IStorageSystemOneBlock.h b/src/Storages/System/IStorageSystemOneBlock.h index 33086498730..d78c8179a71 100644 --- a/src/Storages/System/IStorageSystemOneBlock.h +++ b/src/Storages/System/IStorageSystemOneBlock.h @@ -32,11 +32,11 @@ protected: virtual void fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo & query_info) const = 0; public: - IStorageSystemOneBlock(const StorageID & table_id_) : IStorage(table_id_) + explicit IStorageSystemOneBlock(const StorageID & table_id_) : IStorage(table_id_) { - StorageInMemoryMetadata metadata_; - metadata_.setColumns(ColumnsDescription(Self::getNamesAndTypes(), Self::getNamesAndAliases())); - setInMemoryMetadata(metadata_); + StorageInMemoryMetadata storage_metadata; + storage_metadata.setColumns(ColumnsDescription(Self::getNamesAndTypes(), Self::getNamesAndAliases())); + setInMemoryMetadata(storage_metadata); } Pipe read( diff --git a/src/Storages/System/StorageSystemDataSkippingIndices.h b/src/Storages/System/StorageSystemDataSkippingIndices.h index d86890f5e27..4af2398a04b 100644 --- a/src/Storages/System/StorageSystemDataSkippingIndices.h +++ b/src/Storages/System/StorageSystemDataSkippingIndices.h @@ -26,7 +26,7 @@ public: bool isSystemStorage() const override { return true; } protected: - StorageSystemDataSkippingIndices(const StorageID & table_id_); + explicit StorageSystemDataSkippingIndices(const StorageID & table_id_); }; } diff --git a/src/Storages/System/StorageSystemDetachedParts.h b/src/Storages/System/StorageSystemDetachedParts.h index ece9d495500..51ee93a2f15 100644 --- a/src/Storages/System/StorageSystemDetachedParts.h +++ b/src/Storages/System/StorageSystemDetachedParts.h @@ -29,8 +29,8 @@ protected: SelectQueryInfo & query_info, ContextPtr context, QueryProcessingStage::Enum /*processed_stage*/, - const size_t /*max_block_size*/, - const unsigned /*num_streams*/) override; + size_t /*max_block_size*/, + unsigned /*num_streams*/) override; }; } diff --git a/src/Storages/System/StorageSystemDisks.h b/src/Storages/System/StorageSystemDisks.h index 2541dedd8fc..1404d6023d4 100644 --- a/src/Storages/System/StorageSystemDisks.h +++ b/src/Storages/System/StorageSystemDisks.h @@ -32,7 +32,7 @@ public: bool isSystemStorage() const override { return true; } protected: - StorageSystemDisks(const StorageID & table_id_); + explicit StorageSystemDisks(const StorageID & table_id_); }; } diff --git a/src/Storages/System/StorageSystemPartsBase.h b/src/Storages/System/StorageSystemPartsBase.h index 87247f96b24..bf19771c940 100644 --- a/src/Storages/System/StorageSystemPartsBase.h +++ b/src/Storages/System/StorageSystemPartsBase.h @@ -23,7 +23,7 @@ struct StoragesInfo bool need_inactive_parts = false; MergeTreeData * data = nullptr; - operator bool() const { return storage != nullptr; } + operator bool() const { return storage != nullptr; } /// NOLINT MergeTreeData::DataPartsVector getParts(MergeTreeData::DataPartStateVector & state, bool has_state_column, bool require_projection_parts = false) const; }; diff --git a/src/Storages/System/StorageSystemPartsColumns.h b/src/Storages/System/StorageSystemPartsColumns.h index c3e3eaefcf7..b8c52ca16ef 100644 --- a/src/Storages/System/StorageSystemPartsColumns.h +++ b/src/Storages/System/StorageSystemPartsColumns.h @@ -21,7 +21,7 @@ public: std::string getName() const override { return "SystemPartsColumns"; } protected: - StorageSystemPartsColumns(const StorageID & table_id_); + explicit StorageSystemPartsColumns(const StorageID & table_id_); void processNextStorage( MutableColumns & columns, std::vector & columns_mask, const StoragesInfo & info, bool has_state_column) override; }; diff --git a/src/Storages/System/StorageSystemProjectionPartsColumns.h b/src/Storages/System/StorageSystemProjectionPartsColumns.h index 10e80877285..5679f5e9093 100644 --- a/src/Storages/System/StorageSystemProjectionPartsColumns.h +++ b/src/Storages/System/StorageSystemProjectionPartsColumns.h @@ -21,7 +21,7 @@ public: std::string getName() const override { return "SystemProjectionPartsColumns"; } protected: - StorageSystemProjectionPartsColumns(const StorageID & table_id_); + explicit StorageSystemProjectionPartsColumns(const StorageID & table_id_); void processNextStorage( MutableColumns & columns, std::vector & columns_mask, const StoragesInfo & info, bool has_state_column) override; }; diff --git a/src/Storages/System/StorageSystemReplicas.h b/src/Storages/System/StorageSystemReplicas.h index cf457efe250..500b4e97546 100644 --- a/src/Storages/System/StorageSystemReplicas.h +++ b/src/Storages/System/StorageSystemReplicas.h @@ -30,7 +30,7 @@ public: bool isSystemStorage() const override { return true; } protected: - StorageSystemReplicas(const StorageID & table_id_); + explicit StorageSystemReplicas(const StorageID & table_id_); }; } diff --git a/src/Storages/System/StorageSystemStackTrace.h b/src/Storages/System/StorageSystemStackTrace.h index a5827e32e6f..da4315d3ffa 100644 --- a/src/Storages/System/StorageSystemStackTrace.h +++ b/src/Storages/System/StorageSystemStackTrace.h @@ -27,7 +27,7 @@ public: String getName() const override { return "SystemStackTrace"; } static NamesAndTypesList getNamesAndTypes(); - StorageSystemStackTrace(const StorageID & table_id_); + explicit StorageSystemStackTrace(const StorageID & table_id_); protected: using IStorageSystemOneBlock::IStorageSystemOneBlock; diff --git a/src/Storages/System/StorageSystemStoragePolicies.h b/src/Storages/System/StorageSystemStoragePolicies.h index f202299db1f..28730ce33c4 100644 --- a/src/Storages/System/StorageSystemStoragePolicies.h +++ b/src/Storages/System/StorageSystemStoragePolicies.h @@ -32,7 +32,7 @@ public: bool isSystemStorage() const override { return true; } protected: - StorageSystemStoragePolicies(const StorageID & table_id_); + explicit StorageSystemStoragePolicies(const StorageID & table_id_); }; } diff --git a/src/Storages/System/StorageSystemTables.h b/src/Storages/System/StorageSystemTables.h index 808dc862e8d..23f3aedb164 100644 --- a/src/Storages/System/StorageSystemTables.h +++ b/src/Storages/System/StorageSystemTables.h @@ -30,7 +30,7 @@ public: bool isSystemStorage() const override { return true; } protected: - StorageSystemTables(const StorageID & table_id_); + explicit StorageSystemTables(const StorageID & table_id_); }; }