Apply linter changes

This commit is contained in:
Konstantin Bogdanov 2024-09-19 13:51:02 +02:00
parent ce4d88851a
commit 67c1e89d90
Signed by: thevar1able
GPG Key ID: DB399448D9FE52F1
802 changed files with 6604 additions and 7807 deletions

View File

@ -116,7 +116,6 @@ Checks: [
'-readability-avoid-unconditional-preprocessor-if', '-readability-avoid-unconditional-preprocessor-if',
'-readability-braces-around-statements', '-readability-braces-around-statements',
'-readability-convert-member-functions-to-static', '-readability-convert-member-functions-to-static',
'-readability-else-after-return',
'-readability-function-cognitive-complexity', '-readability-function-cognitive-complexity',
'-readability-function-size', '-readability-function-size',
'-readability-identifier-length', '-readability-identifier-length',

View File

@ -110,8 +110,7 @@ struct DecomposedFloat
{ {
if (!isNegative()) if (!isNegative())
return rhs > 0 ? -1 : 1; return rhs > 0 ? -1 : 1;
else return rhs >= 0 ? -1 : 1;
return rhs >= 0 ? -1 : 1;
} }
/// The case of the most negative integer /// The case of the most negative integer
@ -128,8 +127,7 @@ struct DecomposedFloat
if (mantissa() == 0) if (mantissa() == 0)
return 0; return 0;
else return -1;
return -1;
} }
} }
@ -169,9 +167,8 @@ struct DecomposedFloat
/// Float has no fractional part means that the numbers are equal. /// Float has no fractional part means that the numbers are equal.
if (large_and_always_integer || (mantissa() & ((1ULL << (Traits::mantissa_bits - normalizedExponent())) - 1)) == 0) if (large_and_always_integer || (mantissa() & ((1ULL << (Traits::mantissa_bits - normalizedExponent())) - 1)) == 0)
return 0; return 0;
else /// Float has fractional part means its abs value is larger.
/// Float has fractional part means its abs value is larger. return isNegative() ? -1 : 1;
return isNegative() ? -1 : 1;
} }

View File

@ -205,8 +205,7 @@ JSON::ElementType JSON::getType() const
Pos after_string = skipString(); Pos after_string = skipString();
if (after_string < ptr_end && *after_string == ':') if (after_string < ptr_end && *after_string == ':')
return TYPE_NAME_VALUE_PAIR; return TYPE_NAME_VALUE_PAIR;
else return TYPE_STRING;
return TYPE_STRING;
} }
default: default:
throw JSONException(std::string("JSON: unexpected char ") + *ptr_begin + ", expected one of '{[tfn-0123456789\"'"); throw JSONException(std::string("JSON: unexpected char ") + *ptr_begin + ", expected one of '{[tfn-0123456789\"'");
@ -474,8 +473,7 @@ JSON::Pos JSON::searchField(const char * data, size_t size) const
if (it == end()) if (it == end())
return nullptr; return nullptr;
else return it->data();
return it->data();
} }
@ -487,7 +485,7 @@ bool JSON::hasEscapes() const
if (*pos == '"') if (*pos == '"')
return false; return false;
else if (*pos == '\\') if (*pos == '\\')
return true; return true;
throw JSONException("JSON: unexpected end of data."); throw JSONException("JSON: unexpected end of data.");
} }
@ -503,7 +501,7 @@ bool JSON::hasSpecialChars() const
if (*pos == '"') if (*pos == '"')
return false; return false;
else if (pos < ptr_end) if (pos < ptr_end)
return true; return true;
throw JSONException("JSON: unexpected end of data."); throw JSONException("JSON: unexpected end of data.");
} }
@ -682,10 +680,9 @@ double JSON::toDouble() const
if (type == TYPE_NUMBER) if (type == TYPE_NUMBER)
return getDouble(); return getDouble();
else if (type == TYPE_STRING) if (type == TYPE_STRING)
return JSON(ptr_begin + 1, ptr_end, level + 1).getDouble(); return JSON(ptr_begin + 1, ptr_end, level + 1).getDouble();
else throw JSONException("JSON: cannot convert value to double.");
throw JSONException("JSON: cannot convert value to double.");
} }
Int64 JSON::toInt() const Int64 JSON::toInt() const
@ -694,10 +691,9 @@ Int64 JSON::toInt() const
if (type == TYPE_NUMBER) if (type == TYPE_NUMBER)
return getInt(); return getInt();
else if (type == TYPE_STRING) if (type == TYPE_STRING)
return JSON(ptr_begin + 1, ptr_end, level + 1).getInt(); return JSON(ptr_begin + 1, ptr_end, level + 1).getInt();
else throw JSONException("JSON: cannot convert value to signed integer.");
throw JSONException("JSON: cannot convert value to signed integer.");
} }
UInt64 JSON::toUInt() const UInt64 JSON::toUInt() const
@ -706,10 +702,9 @@ UInt64 JSON::toUInt() const
if (type == TYPE_NUMBER) if (type == TYPE_NUMBER)
return getUInt(); return getUInt();
else if (type == TYPE_STRING) if (type == TYPE_STRING)
return JSON(ptr_begin + 1, ptr_end, level + 1).getUInt(); return JSON(ptr_begin + 1, ptr_end, level + 1).getUInt();
else throw JSONException("JSON: cannot convert value to unsigned integer.");
throw JSONException("JSON: cannot convert value to unsigned integer.");
} }
std::string JSON::toString() const std::string JSON::toString() const
@ -718,11 +713,9 @@ std::string JSON::toString() const
if (type == TYPE_STRING) if (type == TYPE_STRING)
return getString(); return getString();
else
{ Pos pos = skipElement();
Pos pos = skipElement(); return std::string(ptr_begin, pos - ptr_begin);
return std::string(ptr_begin, pos - ptr_begin);
}
} }

View File

@ -203,9 +203,7 @@ T JSON::getWithDefault(const std::string & key, const T & default_) const
if (key_json.isType<T>()) if (key_json.isType<T>())
return key_json.get<T>(); return key_json.get<T>();
else
return default_;
}
else
return default_; return default_;
}
return default_;
} }

View File

@ -151,19 +151,19 @@ inline bool memequalWide(const char * p1, const char * p2, size_t size)
return unalignedLoad<uint64_t>(p1) == unalignedLoad<uint64_t>(p2) return unalignedLoad<uint64_t>(p1) == unalignedLoad<uint64_t>(p2)
&& unalignedLoad<uint64_t>(p1 + size - 8) == unalignedLoad<uint64_t>(p2 + size - 8); && unalignedLoad<uint64_t>(p1 + size - 8) == unalignedLoad<uint64_t>(p2 + size - 8);
} }
else if (size >= 4) if (size >= 4)
{ {
/// Chunks of 4..7 bytes. /// Chunks of 4..7 bytes.
return unalignedLoad<uint32_t>(p1) == unalignedLoad<uint32_t>(p2) return unalignedLoad<uint32_t>(p1) == unalignedLoad<uint32_t>(p2)
&& unalignedLoad<uint32_t>(p1 + size - 4) == unalignedLoad<uint32_t>(p2 + size - 4); && unalignedLoad<uint32_t>(p1 + size - 4) == unalignedLoad<uint32_t>(p2 + size - 4);
} }
else if (size >= 2) if (size >= 2)
{ {
/// Chunks of 2..3 bytes. /// Chunks of 2..3 bytes.
return unalignedLoad<uint16_t>(p1) == unalignedLoad<uint16_t>(p2) return unalignedLoad<uint16_t>(p1) == unalignedLoad<uint16_t>(p2)
&& unalignedLoad<uint16_t>(p1 + size - 2) == unalignedLoad<uint16_t>(p2 + size - 2); && unalignedLoad<uint16_t>(p1 + size - 2) == unalignedLoad<uint16_t>(p2 + size - 2);
} }
else if (size >= 1) if (size >= 1)
{ {
/// A single byte. /// A single byte.
return *p1 == *p2; return *p1 == *p2;

View File

@ -53,10 +53,9 @@ void argsToConfig(const Poco::Util::Application::ArgVec & argv,
key = arg.substr(key_start); key = arg.substr(key_start);
continue; continue;
} }
else
{ key = "";
key = "";
}
if (key_start == std::string::npos) if (key_start == std::string::npos)
continue; continue;

View File

@ -330,9 +330,8 @@ inline const char * find_first_symbols_dispatch(const char * begin, const char *
#if defined(__SSE4_2__) #if defined(__SSE4_2__)
if (sizeof...(symbols) >= 5) if (sizeof...(symbols) >= 5)
return find_first_symbols_sse42<positive, return_mode, sizeof...(symbols), symbols...>(begin, end); return find_first_symbols_sse42<positive, return_mode, sizeof...(symbols), symbols...>(begin, end);
else
#endif #endif
return find_first_symbols_sse2<positive, return_mode, symbols...>(begin, end); return find_first_symbols_sse2<positive, return_mode, symbols...>(begin, end);
} }
template <bool positive, ReturnMode return_mode> template <bool positive, ReturnMode return_mode>
@ -341,9 +340,8 @@ inline const char * find_first_symbols_dispatch(const std::string_view haystack,
#if defined(__SSE4_2__) #if defined(__SSE4_2__)
if (symbols.str.size() >= 5) if (symbols.str.size() >= 5)
return find_first_symbols_sse42<positive, return_mode>(haystack.begin(), haystack.end(), symbols); return find_first_symbols_sse42<positive, return_mode>(haystack.begin(), haystack.end(), symbols);
else
#endif #endif
return find_first_symbols_sse2<positive, return_mode>(haystack.begin(), haystack.end(), symbols.str.data(), symbols.str.size()); return find_first_symbols_sse2<positive, return_mode>(haystack.begin(), haystack.end(), symbols.str.data(), symbols.str.size());
} }
} }

View File

@ -33,8 +33,7 @@ std::optional<uint64_t> getCgroupsV2MemoryLimit()
uint64_t value; uint64_t value;
if (setting_file >> value) if (setting_file >> value)
return {value}; return {value};
else return {}; /// e.g. the cgroups default "max"
return {}; /// e.g. the cgroups default "max"
} }
current_cgroup = current_cgroup.parent_path(); current_cgroup = current_cgroup.parent_path();
} }

View File

@ -445,15 +445,13 @@ private:
shutdown = true; shutdown = true;
throw; throw;
} }
else
{
std::cerr << getCurrentExceptionMessage(print_stacktrace,
true /*check embedded stack trace*/) << std::endl;
size_t info_index = round_robin ? 0 : connection_index; std::cerr << getCurrentExceptionMessage(print_stacktrace,
++comparison_info_per_interval[info_index]->errors; true /*check embedded stack trace*/) << std::endl;
++comparison_info_total[info_index]->errors;
} size_t info_index = round_robin ? 0 : connection_index;
++comparison_info_per_interval[info_index]->errors;
++comparison_info_total[info_index]->errors;
} }
// Count failed queries toward executed, so that we'd reach // Count failed queries toward executed, so that we'd reach
// max_iterations even if every run fails. // max_iterations even if every run fails.

View File

@ -480,27 +480,23 @@ void Client::connect()
} }
catch (const Exception & e) catch (const Exception & e)
{ {
/// This problem can't be fixed with reconnection so it is not attempted
if (e.code() == DB::ErrorCodes::AUTHENTICATION_FAILED) if (e.code() == DB::ErrorCodes::AUTHENTICATION_FAILED)
{
/// This problem can't be fixed with reconnection so it is not attempted
throw; throw;
}
else
{
if (attempted_address_index == hosts_and_ports.size() - 1)
throw;
if (is_interactive) if (attempted_address_index == hosts_and_ports.size() - 1)
{ throw;
std::cerr << "Connection attempt to database at "
<< connection_parameters.host << ":" << connection_parameters.port if (is_interactive)
<< " resulted in failure" {
<< std::endl std::cerr << "Connection attempt to database at "
<< getExceptionMessage(e, false) << connection_parameters.host << ":" << connection_parameters.port
<< std::endl << " resulted in failure"
<< "Attempting connection to the next provided address" << std::endl
<< std::endl; << getExceptionMessage(e, false)
} << std::endl
<< "Attempting connection to the next provided address"
<< std::endl;
} }
} }
} }

View File

@ -46,7 +46,7 @@ public:
path_from, path_from,
disk_from.getDisk()->getName()); disk_from.getDisk()->getName());
} }
else if (disk_from.getDisk()->isFile(path_from)) if (disk_from.getDisk()->isFile(path_from))
{ {
auto target_location = getTargetLocation(path_from, disk_to, path_to); auto target_location = getTargetLocation(path_from, disk_to, path_to);
if (!disk_to.getDisk()->exists(target_location) || disk_to.getDisk()->isFile(target_location)) if (!disk_to.getDisk()->exists(target_location) || disk_to.getDisk()->isFile(target_location))
@ -77,7 +77,7 @@ public:
{ {
throw Exception(ErrorCodes::BAD_ARGUMENTS, "cannot overwrite non-directory {} with directory {}", path_to, target_location); throw Exception(ErrorCodes::BAD_ARGUMENTS, "cannot overwrite non-directory {} with directory {}", path_to, target_location);
} }
else if (!disk_to.getDisk()->exists(target_location)) if (!disk_to.getDisk()->exists(target_location))
{ {
disk_to.getDisk()->createDirectory(target_location); disk_to.getDisk()->createDirectory(target_location);
} }

View File

@ -72,13 +72,9 @@ private:
auto path = [&]() -> String auto path = [&]() -> String
{ {
if (relative_path.ends_with("/")) if (relative_path.ends_with("/"))
{
return relative_path + file_name; return relative_path + file_name;
}
else return relative_path + "/" + file_name;
{
return relative_path + "/" + file_name;
}
}(); }();
if (disk.isDirectory(path)) if (disk.isDirectory(path))
{ {

View File

@ -53,10 +53,8 @@ public:
{ {
throw Exception(ErrorCodes::BAD_ARGUMENTS, "cannot move '{}' to '{}': Directory not empty", path_from, target_location); throw Exception(ErrorCodes::BAD_ARGUMENTS, "cannot move '{}' to '{}': Directory not empty", path_from, target_location);
} }
else
{ disk.getDisk()->moveDirectory(path_from, target_location);
disk.getDisk()->moveDirectory(path_from, target_location);
}
} }
} }
else if (!disk.getDisk()->exists(path_from)) else if (!disk.getDisk()->exists(path_from))

View File

@ -32,16 +32,14 @@ public:
{ {
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Path {} on disk {} doesn't exist", path, disk.getDisk()->getName()); throw Exception(ErrorCodes::BAD_ARGUMENTS, "Path {} on disk {} doesn't exist", path, disk.getDisk()->getName());
} }
else if (disk.getDisk()->isDirectory(path)) if (disk.getDisk()->isDirectory(path))
{ {
if (!recursive) if (!recursive)
{ {
throw Exception(ErrorCodes::BAD_ARGUMENTS, "cannot remove '{}': Is a directory", path); throw Exception(ErrorCodes::BAD_ARGUMENTS, "cannot remove '{}': Is a directory", path);
} }
else
{ disk.getDisk()->removeRecursive(path);
disk.getDisk()->removeRecursive(path);
}
} }
else else
{ {

View File

@ -33,14 +33,10 @@ public:
auto in = [&]() -> std::unique_ptr<ReadBufferFromFileBase> auto in = [&]() -> std::unique_ptr<ReadBufferFromFileBase>
{ {
if (!path_from.has_value()) if (!path_from.has_value())
{
return std::make_unique<ReadBufferFromFileDescriptor>(STDIN_FILENO); return std::make_unique<ReadBufferFromFileDescriptor>(STDIN_FILENO);
}
else String relative_path_from = disk.getRelativeFromRoot(path_from.value());
{ return disk.getDisk()->readFile(relative_path_from, getReadSettings());
String relative_path_from = disk.getRelativeFromRoot(path_from.value());
return disk.getDisk()->readFile(relative_path_from, getReadSettings());
}
}(); }();
auto out = disk.getDisk()->writeFile(path_to); auto out = disk.getDisk()->writeFile(path_to);

View File

@ -127,68 +127,58 @@ std::vector<String> DisksApp::getCompletions(const String & prefix) const
} }
return getEmptyCompletion(command->command_name); return getEmptyCompletion(command->command_name);
} }
else if (arguments.size() == 1) if (arguments.size() == 1)
{ {
String command_prefix = arguments[0]; String command_prefix = arguments[0];
return getCommandsToComplete(command_prefix); return getCommandsToComplete(command_prefix);
} }
else
{
String last_token = arguments.back();
CommandPtr command;
try
{
command = getCommandByName(arguments[0]);
}
catch (...)
{
return {last_token};
}
std::vector<String> answer = {};
if (command->command_name == "help")
{
return getCommandsToComplete(last_token);
}
else
{
answer = [&]() -> std::vector<String>
{
if (multidisk_commands.contains(command->command_name))
{
return client->getAllFilesByPatternFromAllDisks(last_token);
}
else
{
return client->getCurrentDiskWithPath().getAllFilesByPattern(last_token);
}
}();
for (const auto & disk_name : client->getAllDiskNames()) String last_token = arguments.back();
{ CommandPtr command;
if (disk_name.starts_with(last_token)) try
{ {
answer.push_back(disk_name); command = getCommandByName(arguments[0]);
} }
} catch (...)
for (const auto & option : command->options_description.options()) {
{ return {last_token};
String option_sign = "--" + option->long_name(); }
if (option_sign.starts_with(last_token))
{ std::vector<String> answer = {};
answer.push_back(option_sign); if (command->command_name == "help")
} return getCommandsToComplete(last_token);
}
} answer = [&]() -> std::vector<String>
if (!answer.empty()) {
if (multidisk_commands.contains(command->command_name))
return client->getAllFilesByPatternFromAllDisks(last_token);
return client->getCurrentDiskWithPath().getAllFilesByPattern(last_token);
}();
for (const auto & disk_name : client->getAllDiskNames())
{
if (disk_name.starts_with(last_token))
{ {
std::sort(answer.begin(), answer.end()); answer.push_back(disk_name);
return answer;
}
else
{
return {last_token};
} }
} }
for (const auto & option : command->options_description.options())
{
String option_sign = "--" + option->long_name();
if (option_sign.starts_with(last_token))
{
answer.push_back(option_sign);
}
}
if (!answer.empty())
{
std::sort(answer.begin(), answer.end());
return answer;
}
return {last_token};
} }
bool DisksApp::processQueryText(const String & text) bool DisksApp::processQueryText(const String & text)
@ -210,11 +200,11 @@ bool DisksApp::processQueryText(const String & text)
catch (DB::Exception & err) catch (DB::Exception & err)
{ {
int code = getCurrentExceptionCode(); int code = getCurrentExceptionCode();
if (code == ErrorCodes::LOGICAL_ERROR) if (code == ErrorCodes::LOGICAL_ERROR)
{
throw std::move(err); throw std::move(err);
}
else if (code == ErrorCodes::BAD_ARGUMENTS) if (code == ErrorCodes::BAD_ARGUMENTS)
{ {
std::cerr << err.message() << "\n" std::cerr << err.message() << "\n"
<< "\n"; << "\n";

View File

@ -49,10 +49,8 @@ std::vector<String> DiskWithPath::listAllFilesByPath(const String & any_path) co
disk->listFiles(getRelativeFromRoot(any_path), file_names); disk->listFiles(getRelativeFromRoot(any_path), file_names);
return file_names; return file_names;
} }
else
{ return {};
return {};
}
} }
std::vector<String> DiskWithPath::getAllFilesByPattern(const String & pattern) const std::vector<String> DiskWithPath::getAllFilesByPattern(const String & pattern) const
@ -61,39 +59,30 @@ std::vector<String> DiskWithPath::getAllFilesByPattern(const String & pattern) c
{ {
auto slash_pos = pattern.find_last_of('/'); auto slash_pos = pattern.find_last_of('/');
if (slash_pos >= pattern.size()) if (slash_pos >= pattern.size())
{
return {"", pattern}; return {"", pattern};
}
else return {pattern.substr(0, slash_pos + 1), pattern.substr(slash_pos + 1, pattern.size() - slash_pos - 1)};
{
return {pattern.substr(0, slash_pos + 1), pattern.substr(slash_pos + 1, pattern.size() - slash_pos - 1)};
}
}(); }();
if (!isDirectory(path_before)) if (!isDirectory(path_before))
{
return {}; return {};
}
else std::vector<String> file_names = listAllFilesByPath(path_before);
std::vector<String> answer;
for (const auto & file_name : file_names)
{ {
std::vector<String> file_names = listAllFilesByPath(path_before); if (file_name.starts_with(path_after))
std::vector<String> answer;
for (const auto & file_name : file_names)
{ {
if (file_name.starts_with(path_after)) String file_pattern = path_before + file_name;
if (isDirectory(file_pattern))
{ {
String file_pattern = path_before + file_name; file_pattern = file_pattern + "/";
if (isDirectory(file_pattern))
{
file_pattern = file_pattern + "/";
}
answer.push_back(file_pattern);
} }
answer.push_back(file_pattern);
} }
return answer;
} }
return answer;
}; };
void DiskWithPath::setPath(const String & any_path) void DiskWithPath::setPath(const String & any_path)

View File

@ -39,13 +39,9 @@ DiskWithPath & ICommand::getDiskWithPath(DisksClient & client, const CommandLine
{ {
auto disk_name = getValueFromCommandLineOptionsWithOptional<String>(options, name); auto disk_name = getValueFromCommandLineOptionsWithOptional<String>(options, name);
if (disk_name.has_value()) if (disk_name.has_value())
{
return client.getDiskWithPath(disk_name.value()); return client.getDiskWithPath(disk_name.value());
}
else return client.getCurrentDiskWithPath();
{
return client.getCurrentDiskWithPath();
}
} }
} }

View File

@ -63,39 +63,27 @@ protected:
static T getValueFromCommandLineOptionsThrow(const CommandLineOptions & options, const String & name) static T getValueFromCommandLineOptionsThrow(const CommandLineOptions & options, const String & name)
{ {
if (options.count(name)) if (options.count(name))
{
return getValueFromCommandLineOptions<T>(options, name); return getValueFromCommandLineOptions<T>(options, name);
}
else throw DB::Exception(ErrorCodes::BAD_ARGUMENTS, "Mandatory argument '{}' is missing", name);
{
throw DB::Exception(ErrorCodes::BAD_ARGUMENTS, "Mandatory argument '{}' is missing", name);
}
} }
template <typename T> template <typename T>
static T getValueFromCommandLineOptionsWithDefault(const CommandLineOptions & options, const String & name, const T & default_value) static T getValueFromCommandLineOptionsWithDefault(const CommandLineOptions & options, const String & name, const T & default_value)
{ {
if (options.count(name)) if (options.count(name))
{
return getValueFromCommandLineOptions<T>(options, name); return getValueFromCommandLineOptions<T>(options, name);
}
else return default_value;
{
return default_value;
}
} }
template <typename T> template <typename T>
static std::optional<T> getValueFromCommandLineOptionsWithOptional(const CommandLineOptions & options, const String & name) static std::optional<T> getValueFromCommandLineOptionsWithOptional(const CommandLineOptions & options, const String & name)
{ {
if (options.count(name)) if (options.count(name))
{
return std::optional{getValueFromCommandLineOptions<T>(options, name)}; return std::optional{getValueFromCommandLineOptions<T>(options, name)};
}
else return std::nullopt;
{
return std::nullopt;
}
} }
DiskWithPath & getDiskWithPath(DisksClient & client, const CommandLineOptions & options, const String & name); DiskWithPath & getDiskWithPath(DisksClient & client, const CommandLineOptions & options, const String & name);

View File

@ -110,8 +110,8 @@ static auto executeScript(const std::string & command, bool throw_on_error = fal
sh->wait(); sh->wait();
return 0; return 0;
} }
else
return sh->tryWait(); return sh->tryWait();
} }
static bool ask(std::string question) static bool ask(std::string question)

View File

@ -26,17 +26,15 @@ CatBoostLibraryHandlerPtr CatBoostLibraryHandlerFactory::tryGetModel(const Strin
if (found) if (found)
return handler->second; return handler->second;
else
if (create_if_not_found)
{ {
if (create_if_not_found) auto new_handler = std::make_shared<CatBoostLibraryHandler>(library_path, model_path);
{ library_handlers.emplace(model_path, new_handler);
auto new_handler = std::make_shared<CatBoostLibraryHandler>(library_path, model_path); LOG_DEBUG(log, "Loaded catboost library handler for model path '{}'", model_path);
library_handlers.emplace(model_path, new_handler); return new_handler;
LOG_DEBUG(log, "Loaded catboost library handler for model path '{}'", model_path);
return new_handler;
}
return nullptr;
} }
return nullptr;
} }
void CatBoostLibraryHandlerFactory::removeModel(const String & model_path) void CatBoostLibraryHandlerFactory::removeModel(const String & model_path)

View File

@ -25,7 +25,7 @@ std::unique_ptr<HTTPRequestHandler> LibraryBridgeHandlerFactory::createRequestHa
{ {
if (uri.getPath() == "/extdict_ping") if (uri.getPath() == "/extdict_ping")
return std::make_unique<ExternalDictionaryLibraryBridgeExistsHandler>(getContext()); return std::make_unique<ExternalDictionaryLibraryBridgeExistsHandler>(getContext());
else if (uri.getPath() == "/catboost_ping") if (uri.getPath() == "/catboost_ping")
return std::make_unique<CatBoostLibraryBridgeExistsHandler>(getContext()); return std::make_unique<CatBoostLibraryBridgeExistsHandler>(getContext());
} }
@ -33,7 +33,7 @@ std::unique_ptr<HTTPRequestHandler> LibraryBridgeHandlerFactory::createRequestHa
{ {
if (uri.getPath() == "/extdict_request") if (uri.getPath() == "/extdict_request")
return std::make_unique<ExternalDictionaryLibraryBridgeRequestHandler>(getContext()); return std::make_unique<ExternalDictionaryLibraryBridgeRequestHandler>(getContext());
else if (uri.getPath() == "/catboost_request") if (uri.getPath() == "/catboost_request")
return std::make_unique<CatBoostLibraryBridgeRequestHandler>(getContext()); return std::make_unique<CatBoostLibraryBridgeRequestHandler>(getContext());
} }

View File

@ -158,11 +158,9 @@ void ExternalDictionaryLibraryBridgeRequestHandler::handleRequest(HTTPServerRequ
out.finalize(); out.finalize();
return; return;
} }
else
{ LOG_TRACE(log, "Cannot clone from dictionary with id: {}, will call extDict_libNew instead", from_dictionary_id);
LOG_TRACE(log, "Cannot clone from dictionary with id: {}, will call extDict_libNew instead", from_dictionary_id); lib_new = true;
lib_new = true;
}
} }
if (lib_new) if (lib_new)
{ {

View File

@ -231,8 +231,8 @@ static Int64 transformSigned(Int64 x, UInt64 seed)
{ {
if (x >= 0) if (x >= 0)
return transform(x, seed); return transform(x, seed);
else
return -transform(-x, seed); /// It works Ok even for minimum signed number. return -transform(-x, seed); /// It works Ok even for minimum signed number.
} }
@ -1105,8 +1105,8 @@ public:
{ {
if (isUInt(data_type)) if (isUInt(data_type))
return std::make_unique<UnsignedIntegerModel>(seed); return std::make_unique<UnsignedIntegerModel>(seed);
else
return std::make_unique<SignedIntegerModel>(seed); return std::make_unique<SignedIntegerModel>(seed);
} }
if (typeid_cast<const DataTypeFloat32 *>(&data_type)) if (typeid_cast<const DataTypeFloat32 *>(&data_type))

View File

@ -39,13 +39,13 @@ IdentifierQuotingStyle getQuotingStyle(nanodbc::ConnectionHolderPtr connection)
auto identifier_quote = getIdentifierQuote(connection); auto identifier_quote = getIdentifierQuote(connection);
if (identifier_quote.empty()) if (identifier_quote.empty())
return IdentifierQuotingStyle::Backticks; return IdentifierQuotingStyle::Backticks;
else if (identifier_quote[0] == '`') if (identifier_quote[0] == '`')
return IdentifierQuotingStyle::Backticks; return IdentifierQuotingStyle::Backticks;
else if (identifier_quote[0] == '"') if (identifier_quote[0] == '"')
return IdentifierQuotingStyle::DoubleQuotes; return IdentifierQuotingStyle::DoubleQuotes;
else
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Can not map quote identifier '{}' to IdentifierQuotingStyle value", identifier_quote); "Can not map quote identifier '{}' to IdentifierQuotingStyle value", identifier_quote);
} }
} }

View File

@ -127,8 +127,8 @@ std::string validateODBCConnectionString(const std::string & connection_string)
if (*pos == '{') if (*pos == '{')
return read_escaped_value(); return read_escaped_value();
else
return read_plain_value(); return read_plain_value();
}; };
std::map<std::string, std::string> parameters; std::map<std::string, std::string> parameters;
@ -206,12 +206,10 @@ std::string validateODBCConnectionString(const std::string & connection_string)
reconstructed_connection_string.append(value_pos, next_pos - value_pos); reconstructed_connection_string.append(value_pos, next_pos - value_pos);
break; break;
} }
else
{ reconstructed_connection_string.append(value_pos, next_pos - value_pos);
reconstructed_connection_string.append(value_pos, next_pos - value_pos); reconstructed_connection_string.append("}}");
reconstructed_connection_string.append("}}"); value_pos = next_pos + 1;
value_pos = next_pos + 1;
}
} }
reconstructed_connection_string += '}'; reconstructed_connection_string += '}';

View File

@ -116,16 +116,14 @@ namespace
reading_dependents = false; reading_dependents = false;
continue; continue;
} }
else if (line == "DEPENDENTS") if (line == "DEPENDENTS")
{ {
reading_dependents = true; reading_dependents = true;
reading_dependencies = false; reading_dependencies = false;
continue; continue;
} }
else if (line.empty()) if (line.empty())
{
continue; continue;
}
size_t separator1 = line.find('\t'); size_t separator1 = line.find('\t');
size_t separator2 = line.find('\t', separator1 + 1); size_t separator2 = line.find('\t', separator1 + 1);

View File

@ -134,8 +134,8 @@ public:
"' registered for user-defined settings", "' registered for user-defined settings",
String{setting_name}, boost::algorithm::join(registered_prefixes, "' or '")); String{setting_name}, boost::algorithm::join(registered_prefixes, "' or '"));
} }
else
throw Exception(ErrorCodes::UNKNOWN_SETTING, "Unknown setting '{}'", String{setting_name}); throw Exception(ErrorCodes::UNKNOWN_SETTING, "Unknown setting '{}'", String{setting_name});
} }
private: private:
@ -830,8 +830,7 @@ std::shared_ptr<const EnabledQuota> AccessControl::getAuthenticationQuota(
quota_key, quota_key,
throw_if_client_key_empty); throw_if_client_key_empty);
} }
else return nullptr;
return nullptr;
} }

View File

@ -1483,17 +1483,17 @@ bool AccessRights::isGrantedImplHelper(const AccessRightsElement & element) cons
{ {
if (element.anyParameter()) if (element.anyParameter())
return isGrantedImpl<grant_option, wildcard>(element.access_flags); return isGrantedImpl<grant_option, wildcard>(element.access_flags);
else
return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.parameter); return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.parameter);
} }
else if (element.anyDatabase()) if (element.anyDatabase())
return isGrantedImpl<grant_option, wildcard>(element.access_flags); return isGrantedImpl<grant_option, wildcard>(element.access_flags);
else if (element.anyTable()) if (element.anyTable())
return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.database); return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.database);
else if (element.anyColumn()) if (element.anyColumn())
return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.database, element.table); return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.database, element.table);
else
return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.database, element.table, element.columns); return isGrantedImpl<grant_option, wildcard>(element.access_flags, element.database, element.table, element.columns);
} }
template <bool grant_option, bool wildcard> template <bool grant_option, bool wildcard>
@ -1503,16 +1503,14 @@ bool AccessRights::isGrantedImpl(const AccessRightsElement & element) const
{ {
if (element.grant_option) if (element.grant_option)
return isGrantedImplHelper<true, true>(element); return isGrantedImplHelper<true, true>(element);
else
return isGrantedImplHelper<grant_option, true>(element); return isGrantedImplHelper<grant_option, true>(element);
}
else
{
if (element.grant_option)
return isGrantedImplHelper<true, wildcard>(element);
else
return isGrantedImplHelper<grant_option, wildcard>(element);
} }
if (element.grant_option)
return isGrantedImplHelper<true, wildcard>(element);
return isGrantedImplHelper<grant_option, wildcard>(element);
} }
template <bool grant_option, bool wildcard> template <bool grant_option, bool wildcard>

View File

@ -501,10 +501,9 @@ AuthenticationData AuthenticationData::fromAST(const ASTAuthenticationData & que
auth_data.setPasswordHashBinary(AuthenticationData::Util::stringToDigest(value)); auth_data.setPasswordHashBinary(AuthenticationData::Util::stringToDigest(value));
return auth_data; return auth_data;
} }
else
{ auth_data.setPasswordHashHex(value);
auth_data.setPasswordHashHex(value);
}
if (query.type == AuthenticationType::SHA256_PASSWORD && args_size == 2) if (query.type == AuthenticationType::SHA256_PASSWORD && args_size == 2)
{ {

View File

@ -247,8 +247,7 @@ namespace
const auto & unused_node = *(owned_nodes.begin()->second); const auto & unused_node = *(owned_nodes.begin()->second);
if (unused_node.node_type == UNKNOWN) if (unused_node.node_type == UNKNOWN)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Parent group '{}' not found", unused_node.keyword); throw Exception(ErrorCodes::LOGICAL_ERROR, "Parent group '{}' not found", unused_node.keyword);
else throw Exception(ErrorCodes::LOGICAL_ERROR, "Access type '{}' should have parent group", unused_node.keyword);
throw Exception(ErrorCodes::LOGICAL_ERROR, "Access type '{}' should have parent group", unused_node.keyword);
} }
} }

View File

@ -61,7 +61,7 @@ namespace
{ {
if (addr.family() == IPAddress::Family::IPv4 && addr_v6 == toIPv6(addr)) if (addr.family() == IPAddress::Family::IPv4 && addr_v6 == toIPv6(addr))
return true; return true;
else if (addr.family() == IPAddress::Family::IPv6 && addr_v6 == addr) if (addr.family() == IPAddress::Family::IPv6 && addr_v6 == addr)
return true; return true;
} }
@ -267,10 +267,9 @@ String AllowedClientHosts::IPSubnet::toString() const
unsigned int prefix_length = mask.prefixLength(); unsigned int prefix_length = mask.prefixLength();
if (isMaskAllBitsOne()) if (isMaskAllBitsOne())
return prefix.toString(); return prefix.toString();
else if (IPAddress{prefix_length, mask.family()} == mask) if (IPAddress{prefix_length, mask.family()} == mask)
return fs::path(prefix.toString()) / std::to_string(prefix_length); return fs::path(prefix.toString()) / std::to_string(prefix_length);
else return fs::path(prefix.toString()) / mask.toString();
return fs::path(prefix.toString()) / mask.toString();
} }
bool AllowedClientHosts::IPSubnet::isMaskAllBitsOne() const bool AllowedClientHosts::IPSubnet::isMaskAllBitsOne() const
@ -575,12 +574,11 @@ bool AllowedClientHosts::contains(const IPAddress & client_address) const
parseLikePattern(pattern, subnet, name, name_regexp); parseLikePattern(pattern, subnet, name, name_regexp);
if (subnet) if (subnet)
return check_subnet(*subnet); return check_subnet(*subnet);
else if (name) if (name)
return check_name(*name); return check_name(*name);
else if (name_regexp) if (name_regexp)
return check_name_regexp(*name_regexp); return check_name_regexp(*name_regexp);
else return false;
return false;
}; };
for (const String & like_pattern : like_patterns) for (const String & like_pattern : like_patterns)

View File

@ -28,16 +28,14 @@ String QuotaTypeInfo::valueToString(QuotaValue value) const
{ {
if (!(value % output_denominator)) if (!(value % output_denominator))
return std::to_string(value / output_denominator); return std::to_string(value / output_denominator);
else return toString(static_cast<double>(value) / output_denominator);
return toString(static_cast<double>(value) / output_denominator);
} }
QuotaValue QuotaTypeInfo::stringToValue(const String & str) const QuotaValue QuotaTypeInfo::stringToValue(const String & str) const
{ {
if (output_denominator == 1) if (output_denominator == 1)
return static_cast<QuotaValue>(parse<UInt64>(str)); return static_cast<QuotaValue>(parse<UInt64>(str));
else return static_cast<QuotaValue>(parse<Float64>(str) * output_denominator);
return static_cast<QuotaValue>(parse<Float64>(str) * output_denominator);
} }
String QuotaTypeInfo::valueToStringWithName(QuotaValue value) const String QuotaTypeInfo::valueToStringWithName(QuotaValue value) const

View File

@ -728,8 +728,7 @@ bool ContextAccess::checkAccessImplHelper(const ContextPtr & context, AccessFlag
"For queries over HTTP, method GET implies readonly. " "For queries over HTTP, method GET implies readonly. "
"You should use method POST for modifying queries"); "You should use method POST for modifying queries");
} }
else return access_denied(ErrorCodes::READONLY, "{}: Cannot execute query in readonly mode");
return access_denied(ErrorCodes::READONLY, "{}: Cannot execute query in readonly mode");
} }
} }
@ -770,17 +769,17 @@ bool ContextAccess::checkAccessImplHelper(const ContextPtr & context, const Acce
{ {
if (element.anyParameter()) if (element.anyParameter())
return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags); return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags);
else
return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.parameter); return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.parameter);
} }
else if (element.anyDatabase()) if (element.anyDatabase())
return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags); return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags);
else if (element.anyTable()) if (element.anyTable())
return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.database); return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.database);
else if (element.anyColumn()) if (element.anyColumn())
return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.database, element.table); return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.database, element.table);
else
return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.database, element.table, element.columns); return checkAccessImpl<throw_if_denied, grant_option, wildcard>(context, element.access_flags, element.database, element.table, element.columns);
} }
template <bool throw_if_denied, bool grant_option, bool wildcard> template <bool throw_if_denied, bool grant_option, bool wildcard>
@ -790,16 +789,14 @@ bool ContextAccess::checkAccessImpl(const ContextPtr & context, const AccessRigh
{ {
if (element.grant_option) if (element.grant_option)
return checkAccessImplHelper<throw_if_denied, true, true>(context, element); return checkAccessImplHelper<throw_if_denied, true, true>(context, element);
else
return checkAccessImplHelper<throw_if_denied, grant_option, true>(context, element); return checkAccessImplHelper<throw_if_denied, grant_option, true>(context, element);
}
else
{
if (element.grant_option)
return checkAccessImplHelper<throw_if_denied, true, wildcard>(context, element);
else
return checkAccessImplHelper<throw_if_denied, grant_option, wildcard>(context, element);
} }
if (element.grant_option)
return checkAccessImplHelper<throw_if_denied, true, wildcard>(context, element);
return checkAccessImplHelper<throw_if_denied, grant_option, wildcard>(context, element);
} }
template <bool throw_if_denied, bool grant_option, bool wildcard> template <bool throw_if_denied, bool grant_option, bool wildcard>

View File

@ -89,10 +89,9 @@ bool operator ==(const ContextAccessParams & left, const ContextAccessParams & r
{ {
if (!x) if (!x)
return !y; return !y;
else if (!y) if (!y)
return false; return false;
else return *x == *y;
return *x == *y;
} }
else else
{ {
@ -132,23 +131,21 @@ bool operator <(const ContextAccessParams & left, const ContextAccessParams & ri
{ {
if (!x) if (!x)
return y ? -1 : 0; return y ? -1 : 0;
else if (!y) if (!y)
return 1; return 1;
else if (*x == *y) if (*x == *y)
return 0; return 0;
else if (*x < *y) if (*x < *y)
return -1; return -1;
else return 1;
return 1;
} }
else else
{ {
if (x == y) if (x == y)
return 0; return 0;
else if (x < y) if (x < y)
return -1; return -1;
else return 1;
return 1;
} }
}; };

View File

@ -166,8 +166,7 @@ void KerberosInit::init(const String & keytab_file, const String & principal, co
ret = krb5_get_init_creds_keytab(k5.ctx, &my_creds, k5.me, keytab, 0, nullptr, options); ret = krb5_get_init_creds_keytab(k5.ctx, &my_creds, k5.me, keytab, 0, nullptr, options);
if (ret) if (ret)
throw Exception(ErrorCodes::KERBEROS_ERROR, "Error in getting initial credentials: {}", fmtError(ret)); throw Exception(ErrorCodes::KERBEROS_ERROR, "Error in getting initial credentials: {}", fmtError(ret));
else LOG_TRACE(log, "Got initial credentials");
LOG_TRACE(log,"Got initial credentials");
} }
else else
{ {

View File

@ -330,10 +330,7 @@ std::set<String> LDAPAccessStorage::mapExternalRolesNoLock(const LDAPClient::Sea
for (const auto & external_role : external_role_set) for (const auto & external_role : external_role_set)
{ {
if ( if (prefix.size() < external_role.size() && external_role.starts_with(prefix))
prefix.size() < external_role.size() &&
external_role.compare(0, prefix.size(), prefix) == 0
)
{ {
role_names.emplace(external_role, prefix.size()); role_names.emplace(external_role, prefix.size());
} }

View File

@ -62,8 +62,7 @@ String QuotaCache::QuotaInfo::calculateKey(const EnabledQuota & enabled, bool th
"Quota {} (for user {}) requires a client supplied key.", "Quota {} (for user {}) requires a client supplied key.",
quota->getName(), quota->getName(),
params.user_name); params.user_name);
else return ""; // Authentication quota has no client key at time of authentication.
return ""; // Authentication quota has no client key at time of authentication.
} }
case QuotaKeyType::CLIENT_KEY_OR_USER_NAME: case QuotaKeyType::CLIENT_KEY_OR_USER_NAME:
{ {

View File

@ -80,15 +80,13 @@ void RolesOrUsersSet::init(const ASTRolesOrUsersSet & ast, const AccessControl *
return *id; return *id;
return access_control->getID<Role>(name); return access_control->getID<Role>(name);
} }
else if (ast.allow_users) if (ast.allow_users)
{ {
return access_control->getID<User>(name); return access_control->getID<User>(name);
} }
else
{ assert(ast.allow_roles);
assert(ast.allow_roles); return access_control->getID<Role>(name);
return access_control->getID<Role>(name);
}
}; };
if (!ast.names.empty() && !all) if (!ast.names.empty() && !all)

View File

@ -28,7 +28,7 @@ SettingsAuthResponseParser::parse(const Poco::Net::HTTPResponse & response, std:
try try
{ {
Poco::Dynamic::Var json = parser.parse(*body_stream); Poco::Dynamic::Var json = parser.parse(*body_stream);
Poco::JSON::Object::Ptr obj = json.extract<Poco::JSON::Object::Ptr>(); const Poco::JSON::Object::Ptr & obj = json.extract<Poco::JSON::Object::Ptr>();
Poco::JSON::Object::Ptr settings_obj = obj->getObject(settings_key); Poco::JSON::Object::Ptr settings_obj = obj->getObject(settings_key);
if (settings_obj) if (settings_obj)

View File

@ -54,8 +54,7 @@ SettingSourceRestrictions getSettingSourceRestrictions(std::string_view name)
auto settingConstraintIter = SETTINGS_SOURCE_RESTRICTIONS.find(name); auto settingConstraintIter = SETTINGS_SOURCE_RESTRICTIONS.find(name);
if (settingConstraintIter != SETTINGS_SOURCE_RESTRICTIONS.end()) if (settingConstraintIter != SETTINGS_SOURCE_RESTRICTIONS.end())
return settingConstraintIter->second; return settingConstraintIter->second;
else return SettingSourceRestrictions(); // allows everything
return SettingSourceRestrictions(); // allows everything
} }
} }
@ -310,8 +309,7 @@ bool SettingsConstraints::Checker::check(SettingChange & change,
{ {
if (reaction == THROW_ON_VIOLATION) if (reaction == THROW_ON_VIOLATION)
throw Exception(explain, code); throw Exception(explain, code);
else return false;
return false;
} }
std::string_view setting_name = setting_name_resolver(change.name); std::string_view setting_name = setting_name_resolver(change.name);
@ -335,8 +333,7 @@ bool SettingsConstraints::Checker::check(SettingChange & change,
{ {
if (reaction == THROW_ON_VIOLATION) if (reaction == THROW_ON_VIOLATION)
throw Exception(ErrorCodes::SETTING_CONSTRAINT_VIOLATION, "Setting {} should not be changed", setting_name); throw Exception(ErrorCodes::SETTING_CONSTRAINT_VIOLATION, "Setting {} should not be changed", setting_name);
else return false;
return false;
} }
const auto & min_value = constraint.min_value; const auto & min_value = constraint.min_value;
@ -351,8 +348,7 @@ bool SettingsConstraints::Checker::check(SettingChange & change,
max_value, max_value,
min_value, min_value,
setting_name); setting_name);
else return false;
return false;
} }
if (!min_value.isNull() && less_or_cannot_compare(new_value, min_value)) if (!min_value.isNull() && less_or_cannot_compare(new_value, min_value))
@ -362,8 +358,7 @@ bool SettingsConstraints::Checker::check(SettingChange & change,
throw Exception(ErrorCodes::SETTING_CONSTRAINT_VIOLATION, "Setting {} shouldn't be less than {}", throw Exception(ErrorCodes::SETTING_CONSTRAINT_VIOLATION, "Setting {} shouldn't be less than {}",
setting_name, applyVisitor(FieldVisitorToString(), min_value)); setting_name, applyVisitor(FieldVisitorToString(), min_value));
} }
else change.value = min_value;
change.value = min_value;
} }
if (!max_value.isNull() && less_or_cannot_compare(max_value, new_value)) if (!max_value.isNull() && less_or_cannot_compare(max_value, new_value))
@ -373,16 +368,14 @@ bool SettingsConstraints::Checker::check(SettingChange & change,
throw Exception(ErrorCodes::SETTING_CONSTRAINT_VIOLATION, "Setting {} shouldn't be greater than {}", throw Exception(ErrorCodes::SETTING_CONSTRAINT_VIOLATION, "Setting {} shouldn't be greater than {}",
setting_name, applyVisitor(FieldVisitorToString(), max_value)); setting_name, applyVisitor(FieldVisitorToString(), max_value));
} }
else change.value = max_value;
change.value = max_value;
} }
if (!getSettingSourceRestrictions(setting_name).isSourceAllowed(source)) if (!getSettingSourceRestrictions(setting_name).isSourceAllowed(source))
{ {
if (reaction == THROW_ON_VIOLATION) if (reaction == THROW_ON_VIOLATION)
throw Exception(ErrorCodes::READONLY, "Setting {} is not allowed to be set by {}", setting_name, toString(source)); throw Exception(ErrorCodes::READONLY, "Setting {} is not allowed to be set by {}", setting_name, toString(source));
else return false;
return false;
} }
return true; return true;

View File

@ -649,8 +649,7 @@ namespace
{ {
if (users_without_row_policies_can_read_rows) if (users_without_row_policies_can_read_rows)
continue; continue;
else filter = "1";
filter = "1";
} }
auto policy = std::make_shared<RowPolicy>(); auto policy = std::make_shared<RowPolicy>();

View File

@ -157,13 +157,13 @@ public:
d.status = static_cast<Data::Status>(k); d.status = static_cast<Data::Status>(k);
if (d.status == Data::Status::NotSet) if (d.status == Data::Status::NotSet)
return; return;
else if (d.status == Data::Status::SetNull) if (d.status == Data::Status::SetNull)
{ {
if (!returns_nullable_type) if (!returns_nullable_type)
throw Exception(ErrorCodes::INCORRECT_DATA, "Incorrect type (NULL) in non-nullable {}State", getName()); throw Exception(ErrorCodes::INCORRECT_DATA, "Incorrect type (NULL) in non-nullable {}State", getName());
return; return;
} }
else if (d.status == Data::Status::SetOther) if (d.status == Data::Status::SetOther)
{ {
serialization->deserializeBinary(d.value, buf, {}); serialization->deserializeBinary(d.value, buf, {});
return; return;

View File

@ -148,9 +148,8 @@ AggregateFunctionPtr createAggregateFunctionDeltaSum(
if (isInteger(data_type) || isFloat(data_type)) if (isInteger(data_type) || isFloat(data_type))
return AggregateFunctionPtr(createWithNumericType<AggregationFunctionDeltaSum>( return AggregateFunctionPtr(createWithNumericType<AggregationFunctionDeltaSum>(
*data_type, arguments, params)); *data_type, arguments, params));
else throw Exception(
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument for aggregate function {}", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument for aggregate function {}", arguments[0]->getName(), name);
arguments[0]->getName(), name);
} }
} }

View File

@ -137,13 +137,12 @@ AggregateFunctionFactory::getAssociatedFunctionByNullsAction(const String & name
{ {
if (action == NullsAction::RESPECT_NULLS) if (action == NullsAction::RESPECT_NULLS)
{ {
if (auto it = respect_nulls.find(name); it == respect_nulls.end()) auto it = respect_nulls.find(name);
if (it == respect_nulls.end())
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Function {} does not support RESPECT NULLS", name); throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Function {} does not support RESPECT NULLS", name);
else if (auto associated_it = aggregate_functions.find(it->second); associated_it != aggregate_functions.end()) if (auto associated_it = aggregate_functions.find(it->second); associated_it != aggregate_functions.end())
return {associated_it->second}; return {associated_it->second};
else throw Exception(ErrorCodes::LOGICAL_ERROR, "Unable to find the function {} (equivalent to '{} RESPECT NULLS')", it->second, name);
throw Exception(
ErrorCodes::LOGICAL_ERROR, "Unable to find the function {} (equivalent to '{} RESPECT NULLS')", it->second, name);
} }
if (action == NullsAction::IGNORE_NULLS) if (action == NullsAction::IGNORE_NULLS)
@ -152,9 +151,8 @@ AggregateFunctionFactory::getAssociatedFunctionByNullsAction(const String & name
{ {
if (auto associated_it = aggregate_functions.find(it->second); associated_it != aggregate_functions.end()) if (auto associated_it = aggregate_functions.find(it->second); associated_it != aggregate_functions.end())
return {associated_it->second}; return {associated_it->second};
else throw Exception(
throw Exception( ErrorCodes::LOGICAL_ERROR, "Unable to find the function {} (equivalent to '{} IGNORE NULLS')", it->second, name);
ErrorCodes::LOGICAL_ERROR, "Unable to find the function {} (equivalent to '{} IGNORE NULLS')", it->second, name);
} }
/// We don't throw for IGNORE NULLS of other functions because that's the default in CH /// We don't throw for IGNORE NULLS of other functions because that's the default in CH
} }
@ -263,8 +261,7 @@ AggregateFunctionPtr AggregateFunctionFactory::getImpl(
if (!hints.empty()) if (!hints.empty())
throw Exception(ErrorCodes::UNKNOWN_AGGREGATE_FUNCTION, throw Exception(ErrorCodes::UNKNOWN_AGGREGATE_FUNCTION,
"Unknown aggregate function {}{}. Maybe you meant: {}", name, extra_info, toString(hints)); "Unknown aggregate function {}{}. Maybe you meant: {}", name, extra_info, toString(hints));
else throw Exception(ErrorCodes::UNKNOWN_AGGREGATE_FUNCTION, "Unknown aggregate function {}{}", name, extra_info);
throw Exception(ErrorCodes::UNKNOWN_AGGREGATE_FUNCTION, "Unknown aggregate function {}{}", name, extra_info);
} }
std::optional<AggregateFunctionProperties> AggregateFunctionFactory::tryGetProperties(String name, NullsAction action) const std::optional<AggregateFunctionProperties> AggregateFunctionFactory::tryGetProperties(String name, NullsAction action) const

View File

@ -328,21 +328,19 @@ struct AggregateFunctionFlameGraphData
list = list->next; list = list->next;
return entry; return entry;
} }
else
Entry * parent = list;
while (parent->next && parent->next->size != size)
parent = parent->next;
if (parent->next && parent->next->size == size)
{ {
Entry * parent = list; Entry * entry = parent->next;
while (parent->next && parent->next->size != size) parent->next = entry->next;
parent = parent->next; return entry;
if (parent->next && parent->next->size == size)
{
Entry * entry = parent->next;
parent->next = entry->next;
return entry;
}
return nullptr;
} }
return nullptr;
} }
void add(UInt64 ptr, Int64 size, const UInt64 * stack, size_t stack_size, Arena * arena) void add(UInt64 ptr, Int64 size, const UInt64 * stack, size_t stack_size, Arena * arena)

View File

@ -90,8 +90,7 @@ struct GroupArraySamplerData
/// With a large number of values, we will generate random numbers several times slower. /// With a large number of values, we will generate random numbers several times slower.
if (lim <= static_cast<UInt64>(pcg32_fast::max())) if (lim <= static_cast<UInt64>(pcg32_fast::max()))
return rng() % lim; return rng() % lim;
else return (static_cast<UInt64>(rng()) * (static_cast<UInt64>(pcg32::max()) + 1ULL) + static_cast<UInt64>(rng())) % lim;
return (static_cast<UInt64>(rng()) * (static_cast<UInt64>(pcg32::max()) + 1ULL) + static_cast<UInt64>(rng())) % lim;
} }
void randomShuffle() void randomShuffle()
@ -797,8 +796,8 @@ AggregateFunctionPtr createAggregateFunctionGroupArray(
throw Exception(ErrorCodes::BAD_ARGUMENTS, "groupArrayLast make sense only with max_elems (groupArrayLast(max_elems)())"); throw Exception(ErrorCodes::BAD_ARGUMENTS, "groupArrayLast make sense only with max_elems (groupArrayLast(max_elems)())");
return createAggregateFunctionGroupArrayImpl<GroupArrayTrait</* Thas_limit= */ false, Tlast, /* Tsampler= */ Sampler::NONE>>(argument_types[0], parameters, max_elems, std::nullopt); return createAggregateFunctionGroupArrayImpl<GroupArrayTrait</* Thas_limit= */ false, Tlast, /* Tsampler= */ Sampler::NONE>>(argument_types[0], parameters, max_elems, std::nullopt);
} }
else return createAggregateFunctionGroupArrayImpl<GroupArrayTrait</* Thas_limit= */ true, Tlast, /* Tsampler= */ Sampler::NONE>>(
return createAggregateFunctionGroupArrayImpl<GroupArrayTrait</* Thas_limit= */ true, Tlast, /* Tsampler= */ Sampler::NONE>>(argument_types[0], parameters, max_elems, std::nullopt); argument_types[0], parameters, max_elems, std::nullopt);
} }
AggregateFunctionPtr createAggregateFunctionGroupArraySample( AggregateFunctionPtr createAggregateFunctionGroupArraySample(

View File

@ -381,23 +381,22 @@ IAggregateFunction * createWithExtraTypes(const DataTypePtr & argument_type, con
{ {
WhichDataType which(argument_type); WhichDataType which(argument_type);
if (which.idx == TypeIndex::Date) return new AggregateFunctionGroupArrayIntersectDate(argument_type, parameters); if (which.idx == TypeIndex::Date) return new AggregateFunctionGroupArrayIntersectDate(argument_type, parameters);
else if (which.idx == TypeIndex::DateTime) return new AggregateFunctionGroupArrayIntersectDateTime(argument_type, parameters); if (which.idx == TypeIndex::DateTime)
else if (which.idx == TypeIndex::Date32) return new AggregateFunctionGroupArrayIntersectDate32(argument_type, parameters); return new AggregateFunctionGroupArrayIntersectDateTime(argument_type, parameters);
else if (which.idx == TypeIndex::DateTime64) if (which.idx == TypeIndex::Date32)
return new AggregateFunctionGroupArrayIntersectDate32(argument_type, parameters);
if (which.idx == TypeIndex::DateTime64)
{ {
const auto * datetime64_type = dynamic_cast<const DataTypeDateTime64 *>(argument_type.get()); const auto * datetime64_type = dynamic_cast<const DataTypeDateTime64 *>(argument_type.get());
const auto return_type = std::make_shared<DataTypeArray>(std::make_shared<DataTypeDateTime64>(datetime64_type->getScale())); const auto return_type = std::make_shared<DataTypeArray>(std::make_shared<DataTypeDateTime64>(datetime64_type->getScale()));
return new AggregateFunctionGroupArrayIntersectGeneric<true>(argument_type, parameters, return_type); return new AggregateFunctionGroupArrayIntersectGeneric<true>(argument_type, parameters, return_type);
} }
else
{ /// Check that we can use plain version of AggregateFunctionGroupArrayIntersectGeneric
/// Check that we can use plain version of AggregateFunctionGroupArrayIntersectGeneric if (argument_type->isValueUnambiguouslyRepresentedInContiguousMemoryRegion())
if (argument_type->isValueUnambiguouslyRepresentedInContiguousMemoryRegion()) return new AggregateFunctionGroupArrayIntersectGeneric<true>(argument_type, parameters);
return new AggregateFunctionGroupArrayIntersectGeneric<true>(argument_type, parameters); return new AggregateFunctionGroupArrayIntersectGeneric<false>(argument_type, parameters);
else
return new AggregateFunctionGroupArrayIntersectGeneric<false>(argument_type, parameters);
}
} }
inline AggregateFunctionPtr createAggregateFunctionGroupArrayIntersectImpl(const std::string & name, const DataTypePtr & argument_type, const Array & parameters) inline AggregateFunctionPtr createAggregateFunctionGroupArrayIntersectImpl(const std::string & name, const DataTypePtr & argument_type, const Array & parameters)

View File

@ -65,8 +65,7 @@ struct MovingSumData : public MovingData<T>
{ {
if (idx < window_size) if (idx < window_size)
return this->value[idx]; return this->value[idx];
else return this->value[idx] - this->value[idx - window_size];
return this->value[idx] - this->value[idx - window_size];
} }
}; };
@ -79,8 +78,7 @@ struct MovingAvgData : public MovingData<T>
{ {
if (idx < window_size) if (idx < window_size)
return this->value[idx] / T(window_size); return this->value[idx] / T(window_size);
else return (this->value[idx] - this->value[idx - window_size]) / T(window_size);
return (this->value[idx] - this->value[idx - window_size]) / T(window_size);
} }
}; };
@ -285,16 +283,12 @@ AggregateFunctionPtr createAggregateFunctionMoving(
{ {
if (isDecimal(argument_type)) if (isDecimal(argument_type))
return createAggregateFunctionMovingImpl<Function, std::false_type, std::true_type>(name, argument_type); return createAggregateFunctionMovingImpl<Function, std::false_type, std::true_type>(name, argument_type);
else return createAggregateFunctionMovingImpl<Function, std::false_type, std::false_type>(name, argument_type);
return createAggregateFunctionMovingImpl<Function, std::false_type, std::false_type>(name, argument_type);
}
else
{
if (isDecimal(argument_type))
return createAggregateFunctionMovingImpl<Function, std::true_type, std::true_type>(name, argument_type, max_elems);
else
return createAggregateFunctionMovingImpl<Function, std::true_type, std::false_type>(name, argument_type, max_elems);
} }
if (isDecimal(argument_type))
return createAggregateFunctionMovingImpl<Function, std::true_type, std::true_type>(name, argument_type, max_elems);
return createAggregateFunctionMovingImpl<Function, std::true_type, std::false_type>(name, argument_type, max_elems);
} }
} }

View File

@ -391,21 +391,20 @@ AggregateFunctionPtr createAggregateFunctionGroupArray(
{ {
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Parameter for aggregate function {} should have limit argument", name); throw Exception(ErrorCodes::BAD_ARGUMENTS, "Parameter for aggregate function {} should have limit argument", name);
} }
else if (parameters.size() == 1) if (parameters.size() == 1)
{ {
auto type = parameters[0].getType(); auto type = parameters[0].getType();
if (type != Field::Types::Int64 && type != Field::Types::UInt64) if (type != Field::Types::Int64 && type != Field::Types::UInt64)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Parameter for aggregate function {} should be positive number", name); throw Exception(ErrorCodes::BAD_ARGUMENTS, "Parameter for aggregate function {} should be positive number", name);
if ((type == Field::Types::Int64 && parameters[0].safeGet<Int64>() < 0) || if ((type == Field::Types::Int64 && parameters[0].safeGet<Int64>() < 0)
(type == Field::Types::UInt64 && parameters[0].safeGet<UInt64>() == 0)) || (type == Field::Types::UInt64 && parameters[0].safeGet<UInt64>() == 0))
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Parameter for aggregate function {} should be positive number", name); throw Exception(ErrorCodes::BAD_ARGUMENTS, "Parameter for aggregate function {} should be positive number", name);
max_elems = parameters[0].safeGet<UInt64>(); max_elems = parameters[0].safeGet<UInt64>();
} }
else else
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Function {} does not support this number of arguments", name);
"Function {} does not support this number of arguments", name);
if (max_elems > group_array_sorted_sort_strategy_max_elements_threshold) if (max_elems > group_array_sorted_sort_strategy_max_elements_threshold)
return createAggregateFunctionGroupArraySortedImpl<GroupArraySortedSort>(argument_types[0], parameters, max_elems); return createAggregateFunctionGroupArraySortedImpl<GroupArraySortedSort>(argument_types[0], parameters, max_elems);

View File

@ -133,8 +133,7 @@ public:
{ {
if (revision >= STATE_VERSION_1_MIN_REVISION) if (revision >= STATE_VERSION_1_MIN_REVISION)
return 1; return 1;
else return 0;
return 0;
} }
void serialize(ConstAggregateDataPtr __restrict place, WriteBuffer & buf, std::optional<size_t> version) const override void serialize(ConstAggregateDataPtr __restrict place, WriteBuffer & buf, std::optional<size_t> version) const override

View File

@ -88,8 +88,7 @@ public:
{ {
if (isSmall()) if (isSmall())
return small.size(); return small.size();
else return roaring_bitmap->cardinality();
return roaring_bitmap->cardinality();
} }
void merge(const RoaringBitmapWithSmallSet & r1) void merge(const RoaringBitmapWithSmallSet & r1)
@ -454,8 +453,7 @@ public:
if (isSmall()) if (isSmall())
return small.find(static_cast<T>(x)) != small.end(); return small.find(static_cast<T>(x)) != small.end();
else return roaring_bitmap->contains(static_cast<Value>(x));
return roaring_bitmap->contains(static_cast<Value>(x));
} }
/** /**
@ -554,24 +552,22 @@ public:
r1.add(elem); r1.add(elem);
return answer.size(); return answer.size();
} }
else
{
UInt64 count = 0;
for (auto it = roaring_bitmap->begin(); it != roaring_bitmap->end(); ++it)
{
if (*it < range_start)
continue;
if (count < limit) UInt64 count = 0;
{ for (auto it = roaring_bitmap->begin(); it != roaring_bitmap->end(); ++it)
r1.add(*it); {
++count; if (*it < range_start)
} continue;
else
break; if (count < limit)
{
r1.add(*it);
++count;
} }
return count; else
break;
} }
return count;
} }
UInt64 rb_offset_limit(UInt64 offset, UInt64 limit, RoaringBitmapWithSmallSet & r1) const /// NOLINT UInt64 rb_offset_limit(UInt64 offset, UInt64 limit, RoaringBitmapWithSmallSet & r1) const /// NOLINT
@ -591,18 +587,16 @@ public:
r1.add(it->getValue()); r1.add(it->getValue());
return count; return count;
} }
else
{
UInt64 count = 0;
UInt64 offset_count = 0;
auto it = roaring_bitmap->begin();
for (;it != roaring_bitmap->end() && offset_count < offset; ++it)
++offset_count;
for (;it != roaring_bitmap->end() && count < limit; ++it, ++count) UInt64 count = 0;
r1.add(*it); UInt64 offset_count = 0;
return count; auto it = roaring_bitmap->begin();
} for (; it != roaring_bitmap->end() && offset_count < offset; ++it)
++offset_count;
for (; it != roaring_bitmap->end() && count < limit; ++it, ++count)
r1.add(*it);
return count;
} }
UInt64 rb_min() const /// NOLINT UInt64 rb_min() const /// NOLINT
@ -620,8 +614,7 @@ public:
} }
return min_val; return min_val;
} }
else return roaring_bitmap->minimum();
return roaring_bitmap->minimum();
} }
UInt64 rb_max() const /// NOLINT UInt64 rb_max() const /// NOLINT
@ -639,8 +632,7 @@ public:
} }
return max_val; return max_val;
} }
else return roaring_bitmap->maximum();
return roaring_bitmap->maximum();
} }
/** /**

View File

@ -275,8 +275,7 @@ AggregateFunctionPtr createAggregateFunctionGroupConcat(
if (has_limit) if (has_limit)
return std::make_shared<GroupConcatImpl</* has_limit= */ true>>(argument_types[0], parameters, limit, delimiter); return std::make_shared<GroupConcatImpl</* has_limit= */ true>>(argument_types[0], parameters, limit, delimiter);
else return std::make_shared<GroupConcatImpl</* has_limit= */ false>>(argument_types[0], parameters, limit, delimiter);
return std::make_shared<GroupConcatImpl</* has_limit= */ false>>(argument_types[0], parameters, limit, delimiter);
} }
} }

View File

@ -276,16 +276,15 @@ IAggregateFunction * createWithExtraTypes(const DataTypePtr & argument_type, TAr
{ {
WhichDataType which(argument_type); WhichDataType which(argument_type);
if (which.idx == TypeIndex::Date) return new AggregateFunctionGroupUniqArrayDate<HasLimit>(argument_type, args...); if (which.idx == TypeIndex::Date) return new AggregateFunctionGroupUniqArrayDate<HasLimit>(argument_type, args...);
else if (which.idx == TypeIndex::DateTime) return new AggregateFunctionGroupUniqArrayDateTime<HasLimit>(argument_type, args...); if (which.idx == TypeIndex::DateTime)
else if (which.idx == TypeIndex::IPv4) return new AggregateFunctionGroupUniqArrayIPv4<HasLimit>(argument_type, args...); return new AggregateFunctionGroupUniqArrayDateTime<HasLimit>(argument_type, args...);
else if (which.idx == TypeIndex::IPv4)
{ return new AggregateFunctionGroupUniqArrayIPv4<HasLimit>(argument_type, args...);
/// Check that we can use plain version of AggregateFunctionGroupUniqArrayGeneric
if (argument_type->isValueUnambiguouslyRepresentedInContiguousMemoryRegion()) /// Check that we can use plain version of AggregateFunctionGroupUniqArrayGeneric
return new AggregateFunctionGroupUniqArrayGeneric<true, HasLimit>(argument_type, args...); if (argument_type->isValueUnambiguouslyRepresentedInContiguousMemoryRegion())
else return new AggregateFunctionGroupUniqArrayGeneric<true, HasLimit>(argument_type, args...);
return new AggregateFunctionGroupUniqArrayGeneric<false, HasLimit>(argument_type, args...); return new AggregateFunctionGroupUniqArrayGeneric<false, HasLimit>(argument_type, args...);
}
} }
template <typename HasLimit, typename ... TArgs> template <typename HasLimit, typename ... TArgs>
@ -336,8 +335,7 @@ AggregateFunctionPtr createAggregateFunctionGroupUniqArray(
if (!limit_size) if (!limit_size)
return createAggregateFunctionGroupUniqArrayImpl<std::false_type>(name, argument_types[0], parameters); return createAggregateFunctionGroupUniqArrayImpl<std::false_type>(name, argument_types[0], parameters);
else return createAggregateFunctionGroupUniqArrayImpl<std::true_type>(name, argument_types[0], parameters, max_elems);
return createAggregateFunctionGroupUniqArrayImpl<std::true_type>(name, argument_types[0], parameters, max_elems);
} }
} }

View File

@ -87,8 +87,7 @@ public:
{ {
if (kind_ == AggregateFunctionIntersectionsKind::Count) if (kind_ == AggregateFunctionIntersectionsKind::Count)
return std::make_shared<DataTypeUInt64>(); return std::make_shared<DataTypeUInt64>();
else return std::make_shared<DataTypeNumber<PointType>>();
return std::make_shared<DataTypeNumber<PointType>>();
} }
/// MaxIntersectionsData::Allocator uses the arena /// MaxIntersectionsData::Allocator uses the arena

View File

@ -138,7 +138,9 @@ public:
{ {
if (other.count == 0) if (other.count == 0)
return; return;
else if (count == 0)
/// NOLINTBEGIN(readability-else-after-return)
if (count == 0)
{ {
compress_threshold = other.compress_threshold; compress_threshold = other.compress_threshold;
relative_error = other.relative_error; relative_error = other.relative_error;
@ -237,6 +239,7 @@ public:
doCompress(2 * merged_relative_error * merged_count); doCompress(2 * merged_relative_error * merged_count);
compressed = true; compressed = true;
} }
/// NOLINTEND(readability-else-after-return)
} }
void write(WriteBuffer & buf) const void write(WriteBuffer & buf) const
@ -292,12 +295,10 @@ private:
Int64 max_rank = min_rank + curr_sample.delta; Int64 max_rank = min_rank + curr_sample.delta;
if (max_rank - target_error <= rank && rank <= min_rank + target_error) if (max_rank - target_error <= rank && rank <= min_rank + target_error)
return {i, min_rank, curr_sample.value}; return {i, min_rank, curr_sample.value};
else
{ ++i;
++i; curr_sample = sampled[i];
curr_sample = sampled[i]; min_rank += curr_sample.g;
min_rank += curr_sample.g;
}
} }
return {sampled.size() - 1, 0, sampled.back().value}; return {sampled.size() - 1, 0, sampled.back().value};
} }

View File

@ -747,7 +747,7 @@ AggregateFunctionPtr createAggregateFunctionSequenceBase(
WhichDataType which(argument_types.front().get()); WhichDataType which(argument_types.front().get());
if (which.isDateTime()) if (which.isDateTime())
return std::make_shared<AggregateFunction<DataTypeDateTime::FieldType, Data<DataTypeDateTime::FieldType>>>(argument_types, params, pattern); return std::make_shared<AggregateFunction<DataTypeDateTime::FieldType, Data<DataTypeDateTime::FieldType>>>(argument_types, params, pattern);
else if (which.isDate()) if (which.isDate())
return std::make_shared<AggregateFunction<DataTypeDate::FieldType, Data<DataTypeDate::FieldType>>>(argument_types, params, pattern); return std::make_shared<AggregateFunction<DataTypeDate::FieldType, Data<DataTypeDate::FieldType>>>(argument_types, params, pattern);
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,

View File

@ -124,8 +124,7 @@ private:
{ {
if (count < 2) if (count < 2)
return std::numeric_limits<Float64>::infinity(); return std::numeric_limits<Float64>::infinity();
else return m2 / (count - 1);
return m2 / (count - 1);
} }
static Float64 getStddevSamp(Float64 m2, UInt64 count) static Float64 getStddevSamp(Float64 m2, UInt64 count)
@ -137,10 +136,9 @@ private:
{ {
if (count == 0) if (count == 0)
return std::numeric_limits<Float64>::infinity(); return std::numeric_limits<Float64>::infinity();
else if (count == 1) if (count == 1)
return 0.0; return 0.0;
else return m2 / count;
return m2 / count;
} }
static Float64 getStddevPop(Float64 m2, UInt64 count) static Float64 getStddevPop(Float64 m2, UInt64 count)
@ -363,26 +361,23 @@ private:
{ {
if (count < 2) if (count < 2)
return std::numeric_limits<Float64>::infinity(); return std::numeric_limits<Float64>::infinity();
else return co_moment / (count - 1);
return co_moment / (count - 1);
} }
static Float64 getCovarPop(Float64 co_moment, UInt64 count) static Float64 getCovarPop(Float64 co_moment, UInt64 count)
{ {
if (count == 0) if (count == 0)
return std::numeric_limits<Float64>::infinity(); return std::numeric_limits<Float64>::infinity();
else if (count == 1) if (count == 1)
return 0.0; return 0.0;
else return co_moment / count;
return co_moment / count;
} }
static Float64 getCorr(Float64 co_moment, Float64 left_m2, Float64 right_m2, UInt64 count) static Float64 getCorr(Float64 co_moment, Float64 left_m2, Float64 right_m2, UInt64 count)
{ {
if (count < 2) if (count < 2)
return std::numeric_limits<Float64>::infinity(); return std::numeric_limits<Float64>::infinity();
else return co_moment / sqrt(left_m2 * right_m2);
return co_moment / sqrt(left_m2 * right_m2);
} }
Float64 getResult(ConstAggregateDataPtr __restrict place) const Float64 getResult(ConstAggregateDataPtr __restrict place) const

View File

@ -112,8 +112,7 @@ public:
{ {
if (revision >= STATE_VERSION_1_MIN_REVISION) if (revision >= STATE_VERSION_1_MIN_REVISION)
return 1; return 1;
else return 0;
return 0;
} }
static DataTypePtr createResultType( static DataTypePtr createResultType(
@ -764,8 +763,7 @@ void registerAggregateFunctionSumMap(AggregateFunctionFactory & factory)
auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments); auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments);
if (tuple_argument) if (tuple_argument)
return std::make_shared<AggregateFunctionSumMap<false, true>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionSumMap<false, true>>(keys_type, values_types, arguments, params);
else return std::make_shared<AggregateFunctionSumMap<false, false>>(keys_type, values_types, arguments, params);
return std::make_shared<AggregateFunctionSumMap<false, false>>(keys_type, values_types, arguments, params);
}); });
factory.registerFunction("minMappedArrays", [](const std::string & name, const DataTypes & arguments, const Array & params, const Settings *) -> AggregateFunctionPtr factory.registerFunction("minMappedArrays", [](const std::string & name, const DataTypes & arguments, const Array & params, const Settings *) -> AggregateFunctionPtr
@ -773,8 +771,7 @@ void registerAggregateFunctionSumMap(AggregateFunctionFactory & factory)
auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments); auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments);
if (tuple_argument) if (tuple_argument)
return std::make_shared<AggregateFunctionMinMap<true>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionMinMap<true>>(keys_type, values_types, arguments, params);
else return std::make_shared<AggregateFunctionMinMap<false>>(keys_type, values_types, arguments, params);
return std::make_shared<AggregateFunctionMinMap<false>>(keys_type, values_types, arguments, params);
}); });
factory.registerFunction("maxMappedArrays", [](const std::string & name, const DataTypes & arguments, const Array & params, const Settings *) -> AggregateFunctionPtr factory.registerFunction("maxMappedArrays", [](const std::string & name, const DataTypes & arguments, const Array & params, const Settings *) -> AggregateFunctionPtr
@ -782,8 +779,7 @@ void registerAggregateFunctionSumMap(AggregateFunctionFactory & factory)
auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments); auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments);
if (tuple_argument) if (tuple_argument)
return std::make_shared<AggregateFunctionMaxMap<true>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionMaxMap<true>>(keys_type, values_types, arguments, params);
else return std::make_shared<AggregateFunctionMaxMap<false>>(keys_type, values_types, arguments, params);
return std::make_shared<AggregateFunctionMaxMap<false>>(keys_type, values_types, arguments, params);
}); });
// these functions could be renamed to *MappedArrays too, but it would // these functions could be renamed to *MappedArrays too, but it would
@ -793,8 +789,7 @@ void registerAggregateFunctionSumMap(AggregateFunctionFactory & factory)
auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments); auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments);
if (tuple_argument) if (tuple_argument)
return std::make_shared<AggregateFunctionSumMap<true, true>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionSumMap<true, true>>(keys_type, values_types, arguments, params);
else return std::make_shared<AggregateFunctionSumMap<true, false>>(keys_type, values_types, arguments, params);
return std::make_shared<AggregateFunctionSumMap<true, false>>(keys_type, values_types, arguments, params);
}); });
factory.registerFunction("sumMapFiltered", [](const std::string & name, const DataTypes & arguments, const Array & params, const Settings *) -> AggregateFunctionPtr factory.registerFunction("sumMapFiltered", [](const std::string & name, const DataTypes & arguments, const Array & params, const Settings *) -> AggregateFunctionPtr
@ -802,8 +797,7 @@ void registerAggregateFunctionSumMap(AggregateFunctionFactory & factory)
auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments); auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments);
if (tuple_argument) if (tuple_argument)
return std::make_shared<AggregateFunctionSumMapFiltered<false, true>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionSumMapFiltered<false, true>>(keys_type, values_types, arguments, params);
else return std::make_shared<AggregateFunctionSumMapFiltered<false, false>>(keys_type, values_types, arguments, params);
return std::make_shared<AggregateFunctionSumMapFiltered<false, false>>(keys_type, values_types, arguments, params);
}); });
factory.registerFunction("sumMapFilteredWithOverflow", [](const std::string & name, const DataTypes & arguments, const Array & params, const Settings *) -> AggregateFunctionPtr factory.registerFunction("sumMapFilteredWithOverflow", [](const std::string & name, const DataTypes & arguments, const Array & params, const Settings *) -> AggregateFunctionPtr
@ -811,8 +805,7 @@ void registerAggregateFunctionSumMap(AggregateFunctionFactory & factory)
auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments); auto [keys_type, values_types, tuple_argument] = parseArguments(name, arguments);
if (tuple_argument) if (tuple_argument)
return std::make_shared<AggregateFunctionSumMapFiltered<true, true>>(keys_type, values_types, arguments, params); return std::make_shared<AggregateFunctionSumMapFiltered<true, true>>(keys_type, values_types, arguments, params);
else return std::make_shared<AggregateFunctionSumMapFiltered<true, false>>(keys_type, values_types, arguments, params);
return std::make_shared<AggregateFunctionSumMapFiltered<true, false>>(keys_type, values_types, arguments, params);
}); });
} }

View File

@ -96,25 +96,18 @@ public:
std::move(names) std::move(names)
); );
} }
else
{
DataTypes types
{
std::make_shared<DataTypeNumber<Float64>>(),
std::make_shared<DataTypeNumber<Float64>>(),
};
Strings names DataTypes types{
{ std::make_shared<DataTypeNumber<Float64>>(),
"t_statistic", std::make_shared<DataTypeNumber<Float64>>(),
"p_value", };
};
return std::make_shared<DataTypeTuple>( Strings names{
std::move(types), "t_statistic",
std::move(names) "p_value",
); };
}
return std::make_shared<DataTypeTuple>(std::move(types), std::move(names));
} }
bool allocatesMemoryInArena() const override { return false; } bool allocatesMemoryInArena() const override { return false; }

View File

@ -79,8 +79,7 @@ public:
{ {
if (is_approx_top_k) if (is_approx_top_k)
return is_weighted ? "approx_top_sum" : "approx_top_k"; return is_weighted ? "approx_top_sum" : "approx_top_k";
else return is_weighted ? "topKWeighted" : "topK";
return is_weighted ? "topKWeighted" : "topK";
} }
static DataTypePtr createResultType(const DataTypes & argument_types_, bool include_counts_) static DataTypePtr createResultType(const DataTypes & argument_types_, bool include_counts_)
@ -106,8 +105,7 @@ public:
std::move(names) std::move(names)
)); ));
} }
else return std::make_shared<DataTypeArray>(argument_types_[0]);
return std::make_shared<DataTypeArray>(argument_types_[0]);
} }
bool allocatesMemoryInArena() const override { return false; } bool allocatesMemoryInArena() const override { return false; }
@ -226,8 +224,7 @@ public:
{ {
if (is_approx_top_k) if (is_approx_top_k)
return is_weighted ? "approx_top_sum" : "approx_top_k"; return is_weighted ? "approx_top_sum" : "approx_top_k";
else return is_weighted ? "topKWeighted" : "topK";
return is_weighted ? "topKWeighted" : "topK";
} }
static DataTypePtr createResultType(const DataTypes & argument_types_, bool include_counts_) static DataTypePtr createResultType(const DataTypes & argument_types_, bool include_counts_)
@ -253,10 +250,8 @@ public:
std::move(names) std::move(names)
)); ));
} else
{
return std::make_shared<DataTypeArray>(argument_types_[0]);
} }
return std::make_shared<DataTypeArray>(argument_types_[0]);
} }
bool allocatesMemoryInArena() const override bool allocatesMemoryInArena() const override
@ -440,8 +435,8 @@ IAggregateFunction * createWithExtraTypes(const DataTypes & argument_types, UInt
/// Check that we can use plain version of AggregateFunctionTopKGeneric /// Check that we can use plain version of AggregateFunctionTopKGeneric
if (argument_types[0]->isValueUnambiguouslyRepresentedInContiguousMemoryRegion()) if (argument_types[0]->isValueUnambiguouslyRepresentedInContiguousMemoryRegion())
return new AggregateFunctionTopKGeneric<true, is_weighted>(threshold, reserved, include_counts, is_approx_top_k, argument_types, params); return new AggregateFunctionTopKGeneric<true, is_weighted>(threshold, reserved, include_counts, is_approx_top_k, argument_types, params);
else return new AggregateFunctionTopKGeneric<false, is_weighted>(
return new AggregateFunctionTopKGeneric<false, is_weighted>(threshold, reserved, include_counts, is_approx_top_k, argument_types, params); threshold, reserved, include_counts, is_approx_top_k, argument_types, params);
} }

View File

@ -54,34 +54,32 @@ createAggregateFunctionUniq(const std::string & name, const DataTypes & argument
WhichDataType which(argument_type); WhichDataType which(argument_type);
if (res) if (res)
return res; return res;
else if (which.isDate()) if (which.isDate())
return std::make_shared<AggregateFunctionUniq<DataTypeDate::FieldType, Data>>(argument_types); return std::make_shared<AggregateFunctionUniq<DataTypeDate::FieldType, Data>>(argument_types);
else if (which.isDate32()) if (which.isDate32())
return std::make_shared<AggregateFunctionUniq<DataTypeDate32::FieldType, Data>>(argument_types); return std::make_shared<AggregateFunctionUniq<DataTypeDate32::FieldType, Data>>(argument_types);
else if (which.isDateTime()) if (which.isDateTime())
return std::make_shared<AggregateFunctionUniq<DataTypeDateTime::FieldType, Data>>(argument_types); return std::make_shared<AggregateFunctionUniq<DataTypeDateTime::FieldType, Data>>(argument_types);
else if (which.isStringOrFixedString()) if (which.isStringOrFixedString())
return std::make_shared<AggregateFunctionUniq<String, Data>>(argument_types); return std::make_shared<AggregateFunctionUniq<String, Data>>(argument_types);
else if (which.isUUID()) if (which.isUUID())
return std::make_shared<AggregateFunctionUniq<DataTypeUUID::FieldType, Data>>(argument_types); return std::make_shared<AggregateFunctionUniq<DataTypeUUID::FieldType, Data>>(argument_types);
else if (which.isIPv4()) if (which.isIPv4())
return std::make_shared<AggregateFunctionUniq<DataTypeIPv4::FieldType, Data>>(argument_types); return std::make_shared<AggregateFunctionUniq<DataTypeIPv4::FieldType, Data>>(argument_types);
else if (which.isIPv6()) if (which.isIPv6())
return std::make_shared<AggregateFunctionUniq<DataTypeIPv6::FieldType, Data>>(argument_types); return std::make_shared<AggregateFunctionUniq<DataTypeIPv6::FieldType, Data>>(argument_types);
else if (which.isTuple()) if (which.isTuple())
{ {
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, true>>>(argument_types); return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, true>>>(argument_types);
else return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, true>>>(argument_types);
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, true>>>(argument_types);
} }
} }
/// "Variadic" method also works as a fallback generic case for single argument. /// "Variadic" method also works as a fallback generic case for single argument.
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, false>>>(argument_types); return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, false>>>(argument_types);
else return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, false>>>(argument_types);
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, false>>>(argument_types);
} }
template <bool is_exact, template <typename, bool> typename Data, template <bool, bool, bool> typename DataForVariadic, bool is_able_to_parallelize_merge> template <bool is_exact, template <typename, bool> typename Data, template <bool, bool, bool> typename DataForVariadic, bool is_able_to_parallelize_merge>
@ -107,34 +105,46 @@ createAggregateFunctionUniq(const std::string & name, const DataTypes & argument
WhichDataType which(argument_type); WhichDataType which(argument_type);
if (res) if (res)
return res; return res;
else if (which.isDate()) if (which.isDate())
return std::make_shared<AggregateFunctionUniq<DataTypeDate::FieldType, Data<DataTypeDate::FieldType, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<
else if (which.isDate32()) AggregateFunctionUniq<DataTypeDate::FieldType, Data<DataTypeDate::FieldType, is_able_to_parallelize_merge>>>(
return std::make_shared<AggregateFunctionUniq<DataTypeDate32::FieldType, Data<DataTypeDate32::FieldType, is_able_to_parallelize_merge>>>(argument_types); argument_types);
else if (which.isDateTime()) if (which.isDate32())
return std::make_shared<AggregateFunctionUniq<DataTypeDateTime::FieldType, Data<DataTypeDateTime::FieldType, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<
else if (which.isStringOrFixedString()) AggregateFunctionUniq<DataTypeDate32::FieldType, Data<DataTypeDate32::FieldType, is_able_to_parallelize_merge>>>(
argument_types);
if (which.isDateTime())
return std::make_shared<
AggregateFunctionUniq<DataTypeDateTime::FieldType, Data<DataTypeDateTime::FieldType, is_able_to_parallelize_merge>>>(
argument_types);
if (which.isStringOrFixedString())
return std::make_shared<AggregateFunctionUniq<String, Data<String, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<AggregateFunctionUniq<String, Data<String, is_able_to_parallelize_merge>>>(argument_types);
else if (which.isUUID()) if (which.isUUID())
return std::make_shared<AggregateFunctionUniq<DataTypeUUID::FieldType, Data<DataTypeUUID::FieldType, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<
else if (which.isIPv4()) AggregateFunctionUniq<DataTypeUUID::FieldType, Data<DataTypeUUID::FieldType, is_able_to_parallelize_merge>>>(
return std::make_shared<AggregateFunctionUniq<DataTypeIPv4::FieldType, Data<DataTypeIPv4::FieldType, is_able_to_parallelize_merge>>>(argument_types); argument_types);
else if (which.isIPv6()) if (which.isIPv4())
return std::make_shared<AggregateFunctionUniq<DataTypeIPv6::FieldType, Data<DataTypeIPv6::FieldType, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<
else if (which.isTuple()) AggregateFunctionUniq<DataTypeIPv4::FieldType, Data<DataTypeIPv4::FieldType, is_able_to_parallelize_merge>>>(
argument_types);
if (which.isIPv6())
return std::make_shared<
AggregateFunctionUniq<DataTypeIPv6::FieldType, Data<DataTypeIPv6::FieldType, is_able_to_parallelize_merge>>>(
argument_types);
if (which.isTuple())
{ {
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, true, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, true, is_able_to_parallelize_merge>>>(
else argument_types);
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, true, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, true, is_able_to_parallelize_merge>>>(
argument_types);
} }
} }
/// "Variadic" method also works as a fallback generic case for single argument. /// "Variadic" method also works as a fallback generic case for single argument.
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, false, is_able_to_parallelize_merge>>>(argument_types); return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<true, false, is_able_to_parallelize_merge>>>(argument_types);
else return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, false, is_able_to_parallelize_merge>>>(argument_types);
return std::make_shared<AggregateFunctionUniqVariadic<DataForVariadic<false, false, is_able_to_parallelize_merge>>>(argument_types);
} }
} }
@ -155,9 +165,11 @@ void registerAggregateFunctionsUniq(AggregateFunctionFactory & factory)
if (settings && (*settings)[Setting::max_threads] > 1) if (settings && (*settings)[Setting::max_threads] > 1)
return createAggregateFunctionUniq< return createAggregateFunctionUniq<
true, AggregateFunctionUniqExactData, AggregateFunctionUniqExactDataForVariadic, true /* is_able_to_parallelize_merge */>(name, argument_types, params, settings); true, AggregateFunctionUniqExactData, AggregateFunctionUniqExactDataForVariadic, true /* is_able_to_parallelize_merge */>(name, argument_types, params, settings);
else return createAggregateFunctionUniq<
return createAggregateFunctionUniq< true,
true, AggregateFunctionUniqExactData, AggregateFunctionUniqExactDataForVariadic, false /* is_able_to_parallelize_merge */>(name, argument_types, params, settings); AggregateFunctionUniqExactData,
AggregateFunctionUniqExactDataForVariadic,
false /* is_able_to_parallelize_merge */>(name, argument_types, params, settings);
}; };
factory.registerFunction("uniqExact", {assign_bool_param, properties}); factory.registerFunction("uniqExact", {assign_bool_param, properties});

View File

@ -235,34 +235,40 @@ AggregateFunctionPtr createAggregateFunctionWithK(const DataTypes & argument_typ
WhichDataType which(argument_type); WhichDataType which(argument_type);
if (res) if (res)
return res; return res;
else if (which.isDate()) if (which.isDate())
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeDate::FieldType>>(argument_types, params); return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeDate::FieldType>>(
else if (which.isDate32()) argument_types, params);
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeDate32::FieldType>>(argument_types, params); if (which.isDate32())
else if (which.isDateTime()) return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeDate32::FieldType>>(
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeDateTime::FieldType>>(argument_types, params); argument_types, params);
else if (which.isStringOrFixedString()) if (which.isDateTime())
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeDateTime::FieldType>>(
argument_types, params);
if (which.isStringOrFixedString())
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<String>>(argument_types, params); return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<String>>(argument_types, params);
else if (which.isUUID()) if (which.isUUID())
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeUUID::FieldType>>(argument_types, params); return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeUUID::FieldType>>(
else if (which.isIPv4()) argument_types, params);
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeIPv4::FieldType>>(argument_types, params); if (which.isIPv4())
else if (which.isIPv6()) return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeIPv4::FieldType>>(
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeIPv6::FieldType>>(argument_types, params); argument_types, params);
else if (which.isTuple()) if (which.isIPv6())
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunction<DataTypeIPv6::FieldType>>(
argument_types, params);
if (which.isTuple())
{ {
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<true, true>>(argument_types, params); return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<true, true>>(
else argument_types, params);
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<false, true>>(argument_types, params); return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<false, true>>(
argument_types, params);
} }
} }
/// "Variadic" method also works as a fallback generic case for a single argument. /// "Variadic" method also works as a fallback generic case for a single argument.
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<true, false>>(argument_types, params); return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<true, false>>(argument_types, params);
else return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<false, false>>(argument_types, params);
return std::make_shared<typename WithK<K, HashValueType>::template AggregateFunctionVariadic<false, false>>(argument_types, params);
} }
template <UInt8 K> template <UInt8 K>
@ -270,8 +276,7 @@ AggregateFunctionPtr createAggregateFunctionWithHashType(bool use_64_bit_hash, c
{ {
if (use_64_bit_hash) if (use_64_bit_hash)
return createAggregateFunctionWithK<K, UInt64>(argument_types, params); return createAggregateFunctionWithK<K, UInt64>(argument_types, params);
else return createAggregateFunctionWithK<K, UInt32>(argument_types, params);
return createAggregateFunctionWithK<K, UInt32>(argument_types, params);
} }
/// Let's instantiate these templates in separate translation units, /// Let's instantiate these templates in separate translation units,

View File

@ -324,30 +324,28 @@ AggregateFunctionPtr createAggregateFunctionUniqUpTo(const std::string & name, c
WhichDataType which(argument_type); WhichDataType which(argument_type);
if (res) if (res)
return res; return res;
else if (which.isDate()) if (which.isDate())
return std::make_shared<AggregateFunctionUniqUpTo<DataTypeDate::FieldType>>(threshold, argument_types, params); return std::make_shared<AggregateFunctionUniqUpTo<DataTypeDate::FieldType>>(threshold, argument_types, params);
else if (which.isDate32()) if (which.isDate32())
return std::make_shared<AggregateFunctionUniqUpTo<DataTypeDate32::FieldType>>(threshold, argument_types, params); return std::make_shared<AggregateFunctionUniqUpTo<DataTypeDate32::FieldType>>(threshold, argument_types, params);
else if (which.isDateTime()) if (which.isDateTime())
return std::make_shared<AggregateFunctionUniqUpTo<DataTypeDateTime::FieldType>>(threshold, argument_types, params); return std::make_shared<AggregateFunctionUniqUpTo<DataTypeDateTime::FieldType>>(threshold, argument_types, params);
else if (which.isStringOrFixedString()) if (which.isStringOrFixedString())
return std::make_shared<AggregateFunctionUniqUpTo<String>>(threshold, argument_types, params); return std::make_shared<AggregateFunctionUniqUpTo<String>>(threshold, argument_types, params);
else if (which.isUUID()) if (which.isUUID())
return std::make_shared<AggregateFunctionUniqUpTo<DataTypeUUID::FieldType>>(threshold, argument_types, params); return std::make_shared<AggregateFunctionUniqUpTo<DataTypeUUID::FieldType>>(threshold, argument_types, params);
else if (which.isTuple()) if (which.isTuple())
{ {
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<AggregateFunctionUniqUpToVariadic<true, true>>(argument_types, params, threshold); return std::make_shared<AggregateFunctionUniqUpToVariadic<true, true>>(argument_types, params, threshold);
else return std::make_shared<AggregateFunctionUniqUpToVariadic<false, true>>(argument_types, params, threshold);
return std::make_shared<AggregateFunctionUniqUpToVariadic<false, true>>(argument_types, params, threshold);
} }
} }
/// "Variadic" method also works as a fallback generic case for single argument. /// "Variadic" method also works as a fallback generic case for single argument.
if (use_exact_hash_function) if (use_exact_hash_function)
return std::make_shared<AggregateFunctionUniqUpToVariadic<true, false>>(argument_types, params, threshold); return std::make_shared<AggregateFunctionUniqUpToVariadic<true, false>>(argument_types, params, threshold);
else return std::make_shared<AggregateFunctionUniqUpToVariadic<false, false>>(argument_types, params, threshold);
return std::make_shared<AggregateFunctionUniqUpToVariadic<false, false>>(argument_types, params, threshold);
} }
} }

View File

@ -180,10 +180,9 @@ private:
{ {
if (first_event) if (first_event)
break; break;
else continue;
continue;
} }
else if (event_idx == 0) if (event_idx == 0)
{ {
events_timestamp[0] = std::make_pair(timestamp, timestamp); events_timestamp[0] = std::make_pair(timestamp, timestamp);
first_event = true; first_event = true;
@ -326,10 +325,11 @@ createAggregateFunctionWindowFunnel(const std::string & name, const DataTypes &
WhichDataType which(arguments.front().get()); WhichDataType which(arguments.front().get());
if (res) if (res)
return res; return res;
else if (which.isDate()) if (which.isDate())
return std::make_shared<AggregateFunctionWindowFunnel<DataTypeDate::FieldType, Data<DataTypeDate::FieldType>>>(arguments, params); return std::make_shared<AggregateFunctionWindowFunnel<DataTypeDate::FieldType, Data<DataTypeDate::FieldType>>>(arguments, params);
else if (which.isDateTime()) if (which.isDateTime())
return std::make_shared<AggregateFunctionWindowFunnel<DataTypeDateTime::FieldType, Data<DataTypeDateTime::FieldType>>>(arguments, params); return std::make_shared<AggregateFunctionWindowFunnel<DataTypeDateTime::FieldType, Data<DataTypeDateTime::FieldType>>>(
arguments, params);
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Illegal type {} of first argument of aggregate function {}, must " "Illegal type {} of first argument of aggregate function {}, must "

View File

@ -50,10 +50,8 @@ public:
return std::make_shared< return std::make_shared<
AggregateFunctionDistinct< AggregateFunctionDistinct<
AggregateFunctionDistinctSingleGenericData<true>>>(nested_function, arguments, params); AggregateFunctionDistinctSingleGenericData<true>>>(nested_function, arguments, params);
else return std::make_shared<AggregateFunctionDistinct<AggregateFunctionDistinctSingleGenericData<false>>>(
return std::make_shared< nested_function, arguments, params);
AggregateFunctionDistinct<
AggregateFunctionDistinctSingleGenericData<false>>>(nested_function, arguments, params);
} }
return std::make_shared<AggregateFunctionDistinct<AggregateFunctionDistinctMultipleGenericData>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionDistinct<AggregateFunctionDistinctMultipleGenericData>>(nested_function, arguments, params);

View File

@ -473,28 +473,20 @@ AggregateFunctionPtr AggregateFunctionIf::getOwnNullAdapter(
{ {
return std::make_shared<AggregateFunctionIfNullUnary<true, true>>(nested_function->getName(), nested_func, arguments, params); return std::make_shared<AggregateFunctionIfNullUnary<true, true>>(nested_function->getName(), nested_func, arguments, params);
} }
else
{ if (need_to_serialize_flag)
if (need_to_serialize_flag) return std::make_shared<AggregateFunctionIfNullUnary<false, true>>(nested_function->getName(), nested_func, arguments, params);
return std::make_shared<AggregateFunctionIfNullUnary<false, true>>(nested_function->getName(), nested_func, arguments, params); return std::make_shared<AggregateFunctionIfNullUnary<false, false>>(nested_function->getName(), nested_func, arguments, params);
else
return std::make_shared<AggregateFunctionIfNullUnary<false, false>>(nested_function->getName(), nested_func, arguments, params);
}
} }
else
if (return_type_is_nullable)
{ {
if (return_type_is_nullable) return std::make_shared<AggregateFunctionIfNullVariadic<true, true>>(nested_function, arguments, params);
{
return std::make_shared<AggregateFunctionIfNullVariadic<true, true>>(nested_function, arguments, params);
}
else
{
if (need_to_serialize_flag)
return std::make_shared<AggregateFunctionIfNullVariadic<false, true>>(nested_function, arguments, params);
else
return std::make_shared<AggregateFunctionIfNullVariadic<false, false>>(nested_function, arguments, params);
}
} }
if (need_to_serialize_flag)
return std::make_shared<AggregateFunctionIfNullVariadic<false, true>>(nested_function, arguments, params);
return std::make_shared<AggregateFunctionIfNullVariadic<false, false>>(nested_function, arguments, params);
} }
void registerAggregateFunctionCombinatorIf(AggregateFunctionCombinatorFactory & factory) void registerAggregateFunctionCombinatorIf(AggregateFunctionCombinatorFactory & factory)

View File

@ -450,9 +450,8 @@ public:
auto action = NullsAction::EMPTY; auto action = NullsAction::EMPTY;
return aggr_func_factory.get(nested_func_name + "MappedArrays", action, arguments, params, out_properties); return aggr_func_factory.get(nested_func_name + "MappedArrays", action, arguments, params, out_properties);
} }
else throw Exception(
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Aggregation '{}Map' is not implemented for mapped arrays", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Aggregation '{}Map' is not implemented for mapped arrays", nested_func_name);
nested_func_name);
} }
} }
}; };

View File

@ -112,8 +112,7 @@ public:
*/ */
if (properties.returns_default_when_only_null) if (properties.returns_default_when_only_null)
return std::make_shared<AggregateFunctionNothingUInt64>(arguments, params); return std::make_shared<AggregateFunctionNothingUInt64>(arguments, params);
else return std::make_shared<AggregateFunctionNothingNull>(arguments, params);
return std::make_shared<AggregateFunctionNothingNull>(arguments, params);
} }
assert(nested_function); assert(nested_function);
@ -137,23 +136,18 @@ public:
{ {
return std::make_shared<AggregateFunctionNullUnary<true, true>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionNullUnary<true, true>>(nested_function, arguments, params);
} }
else
{ if (serialize_flag)
if (serialize_flag) return std::make_shared<AggregateFunctionNullUnary<false, true>>(nested_function, arguments, params);
return std::make_shared<AggregateFunctionNullUnary<false, true>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionNullUnary<false, false>>(nested_function, arguments, params);
else
return std::make_shared<AggregateFunctionNullUnary<false, false>>(nested_function, arguments, params);
}
} }
else
if (return_type_is_nullable)
{ {
if (return_type_is_nullable) return std::make_shared<AggregateFunctionNullVariadic<true, true>>(nested_function, arguments, params);
{ }
return std::make_shared<AggregateFunctionNullVariadic<true, true>>(nested_function, arguments, params);
} return std::make_shared<AggregateFunctionNullVariadic<false, true>>(nested_function, arguments, params);
else
{
return std::make_shared<AggregateFunctionNullVariadic<false, true>>(nested_function, arguments, params);
#if 0 #if 0
if (serialize_flag) if (serialize_flag)
return std::make_shared<AggregateFunctionNullVariadic<false, true>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionNullVariadic<false, true>>(nested_function, arguments, params);
@ -164,8 +158,6 @@ public:
return std::make_shared<AggregateFunctionNullVariadic<false, true>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionNullVariadic<false, true>>(nested_function, arguments, params);
} }
#endif #endif
}
}
} }
}; };

View File

@ -37,8 +37,7 @@ public:
{ {
if (kind == Kind::OrNull) if (kind == Kind::OrNull)
return std::make_shared<AggregateFunctionOrFill<true>>(nested_function, arguments, params); return std::make_shared<AggregateFunctionOrFill<true>>(nested_function, arguments, params);
else return std::make_shared<AggregateFunctionOrFill<false>>(nested_function, arguments, params);
return std::make_shared<AggregateFunctionOrFill<false>>(nested_function, arguments, params);
} }
}; };

View File

@ -120,11 +120,9 @@ public:
this->merge(new_sketch); this->merge(new_sketch);
return; return;
} }
else
{ DDSketchDenseLogarithmic new_sketch = changeMapping(other.mapping->getGamma());
DDSketchDenseLogarithmic new_sketch = changeMapping(other.mapping->getGamma()); copy(new_sketch);
copy(new_sketch);
}
} }
// If the other sketch is empty, do nothing // If the other sketch is empty, do nothing

View File

@ -694,7 +694,7 @@ class IAggregateFunctionDataHelper : public IAggregateFunctionHelper<Derived>
protected: protected:
using Data = T; using Data = T;
static Data & data(AggregateDataPtr __restrict place) { return *reinterpret_cast<Data *>(place); } static Data & data(const AggregateDataPtr __restrict place) { return *reinterpret_cast<Data *>(place); }
static const Data & data(ConstAggregateDataPtr __restrict place) { return *reinterpret_cast<const Data *>(place); } static const Data & data(ConstAggregateDataPtr __restrict place) { return *reinterpret_cast<const Data *>(place); }
public: public:

View File

@ -146,7 +146,7 @@ struct QuantileExactExclusive : public QuantileExact<Value>
if (n >= array.size()) if (n >= array.size())
return static_cast<Float64>(*std::max_element(array.begin(), array.end())); return static_cast<Float64>(*std::max_element(array.begin(), array.end()));
else if (n < 1) if (n < 1)
return static_cast<Float64>(*std::min_element(array.begin(), array.end())); return static_cast<Float64>(*std::min_element(array.begin(), array.end()));
::nth_element(array.begin(), array.begin() + n - 1, array.end()); ::nth_element(array.begin(), array.begin() + n - 1, array.end());
@ -211,7 +211,7 @@ struct QuantileExactInclusive : public QuantileExact<Value>
if (n >= array.size()) if (n >= array.size())
return static_cast<Float64>(*std::max_element(array.begin(), array.end())); return static_cast<Float64>(*std::max_element(array.begin(), array.end()));
else if (n < 1) if (n < 1)
return static_cast<Float64>(*std::min_element(array.begin(), array.end())); return static_cast<Float64>(*std::min_element(array.begin(), array.end()));
::nth_element(array.begin(), array.begin() + n - 1, array.end()); ::nth_element(array.begin(), array.begin() + n - 1, array.end());
auto * nth_elem = std::min_element(array.begin() + n, array.end()); auto * nth_elem = std::min_element(array.begin() + n, array.end());

View File

@ -416,15 +416,10 @@ public:
if (x <= left) if (x <= left)
return checkOverflow<ResultType>(prev_mean); return checkOverflow<ResultType>(prev_mean);
else if (x >= right) if (x >= right)
return checkOverflow<ResultType>(c.mean); return checkOverflow<ResultType>(c.mean);
else return checkOverflow<ResultType>(
return checkOverflow<ResultType>(interpolate( interpolate(static_cast<Value>(x), static_cast<Value>(left), prev_mean, static_cast<Value>(right), c.mean));
static_cast<Value>(x),
static_cast<Value>(left),
prev_mean,
static_cast<Value>(right),
c.mean));
} }
sum += c.count; sum += c.count;

View File

@ -736,14 +736,12 @@ public:
tiny.prepare(); tiny.prepare();
return tiny.get(level); return tiny.get(level);
} }
else if (kind == Kind::Medium) if (kind == Kind::Medium)
{ {
return medium.get(level); return medium.get(level);
} }
else
{ return large->get(level);
return large->get(level);
}
} }
/// Get the size values of the quantiles of the `levels` levels. Record `size` results starting with `result` address. /// Get the size values of the quantiles of the `levels` levels. Record `size` results starting with `result` address.

View File

@ -260,8 +260,7 @@ private:
/// With a large number of values, we will generate random numbers several times slower. /// With a large number of values, we will generate random numbers several times slower.
if (limit <= static_cast<UInt64>(pcg32_fast::max())) if (limit <= static_cast<UInt64>(pcg32_fast::max()))
return rng() % limit; return rng() % limit;
else return (static_cast<UInt64>(rng()) * (static_cast<UInt64>(pcg32_fast::max()) + 1ULL) + static_cast<UInt64>(rng())) % limit;
return (static_cast<UInt64>(rng()) * (static_cast<UInt64>(pcg32_fast::max()) + 1ULL) + static_cast<UInt64>(rng())) % limit;
} }
void sortIfNeeded() void sortIfNeeded()
@ -277,7 +276,6 @@ private:
{ {
if (OnEmpty == ReservoirSamplerOnEmpty::THROW) if (OnEmpty == ReservoirSamplerOnEmpty::THROW)
throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Quantile of empty ReservoirSampler"); throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Quantile of empty ReservoirSampler");
else return NanLikeValueConstructor<ResultType, std::is_floating_point_v<ResultType>>::getValue();
return NanLikeValueConstructor<ResultType, std::is_floating_point_v<ResultType>>::getValue();
} }
}; };

View File

@ -271,8 +271,7 @@ private:
{ {
if (OnEmpty == ReservoirSamplerDeterministicOnEmpty::THROW) if (OnEmpty == ReservoirSamplerDeterministicOnEmpty::THROW)
throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Quantile of empty ReservoirSamplerDeterministic"); throw DB::Exception(DB::ErrorCodes::LOGICAL_ERROR, "Quantile of empty ReservoirSamplerDeterministic");
else return NanLikeValueConstructor<ResultType, std::is_floating_point_v<ResultType>>::getValue();
return NanLikeValueConstructor<ResultType, std::is_floating_point_v<ResultType>>::getValue();
} }
}; };

View File

@ -50,15 +50,13 @@ std::optional<size_t> SingleValueDataBase::getSmallestIndex(const IColumn & colu
index = i; index = i;
return {index}; return {index};
} }
else
{ constexpr IColumn::PermutationSortDirection direction = IColumn::PermutationSortDirection::Ascending;
constexpr IColumn::PermutationSortDirection direction = IColumn::PermutationSortDirection::Ascending; constexpr IColumn::PermutationSortStability stability = IColumn::PermutationSortStability::Unstable;
constexpr IColumn::PermutationSortStability stability = IColumn::PermutationSortStability::Unstable; IColumn::Permutation permutation;
IColumn::Permutation permutation; constexpr UInt64 limit = 1;
constexpr UInt64 limit = 1; column.getPermutation(direction, stability, limit, nan_null_direction_hint, permutation);
column.getPermutation(direction, stability, limit, nan_null_direction_hint, permutation); return {permutation[0]};
return {permutation[0]};
}
} }
std::optional<size_t> SingleValueDataBase::getGreatestIndex(const IColumn & column, size_t row_begin, size_t row_end) const std::optional<size_t> SingleValueDataBase::getGreatestIndex(const IColumn & column, size_t row_begin, size_t row_end) const
@ -77,15 +75,13 @@ std::optional<size_t> SingleValueDataBase::getGreatestIndex(const IColumn & colu
index = i; index = i;
return {index}; return {index};
} }
else
{ constexpr IColumn::PermutationSortDirection direction = IColumn::PermutationSortDirection::Descending;
constexpr IColumn::PermutationSortDirection direction = IColumn::PermutationSortDirection::Descending; constexpr IColumn::PermutationSortStability stability = IColumn::PermutationSortStability::Unstable;
constexpr IColumn::PermutationSortStability stability = IColumn::PermutationSortStability::Unstable; IColumn::Permutation permutation;
IColumn::Permutation permutation; constexpr UInt64 limit = 1;
constexpr UInt64 limit = 1; column.getPermutation(direction, stability, limit, nan_null_direction_hint, permutation);
column.getPermutation(direction, stability, limit, nan_null_direction_hint, permutation); return {permutation[0]};
return {permutation[0]};
}
} }
std::optional<size_t> SingleValueDataBase::getSmallestIndexNotNullIf( std::optional<size_t> SingleValueDataBase::getSmallestIndexNotNullIf(
@ -247,8 +243,7 @@ bool SingleValueDataFixed<T>::setIfSmaller(const SingleValueDataFixed<T> & to, A
set(to, arena); set(to, arena);
return true; return true;
} }
else return false;
return false;
} }
template <typename T> template <typename T>
@ -259,8 +254,7 @@ bool SingleValueDataFixed<T>::setIfGreater(const SingleValueDataFixed<T> & to, A
set(to, arena); set(to, arena);
return true; return true;
} }
else return false;
return false;
} }
template <typename T> template <typename T>
@ -271,8 +265,7 @@ bool SingleValueDataFixed<T>::setIfSmaller(const IColumn & column, size_t row_nu
set(column, row_num, arena); set(column, row_num, arena);
return true; return true;
} }
else return false;
return false;
} }
template <typename T> template <typename T>
@ -283,8 +276,7 @@ bool SingleValueDataFixed<T>::setIfGreater(const IColumn & column, size_t row_nu
set(column, row_num, arena); set(column, row_num, arena);
return true; return true;
} }
else return false;
return false;
} }
template <typename T> template <typename T>
@ -544,7 +536,7 @@ std::optional<size_t> SingleValueDataFixed<T>::getGreatestIndexNotNullIf(
} }
return opt; return opt;
} }
else if (!null_map) if (!null_map)
{ {
opt = findExtremeMaxIf(vec.getData().data(), if_map, row_begin, row_end); opt = findExtremeMaxIf(vec.getData().data(), if_map, row_begin, row_end);
if (!opt.has_value()) if (!opt.has_value())
@ -556,18 +548,17 @@ std::optional<size_t> SingleValueDataFixed<T>::getGreatestIndexNotNullIf(
} }
return opt; return opt;
} }
else
auto final_flags = mergeIfAndNullFlags(null_map, if_map, row_begin, row_end);
opt = findExtremeMaxIf(vec.getData().data(), final_flags.get(), row_begin, row_end);
if (!opt.has_value())
return std::nullopt;
for (size_t i = row_begin; i < row_end; i++)
{ {
auto final_flags = mergeIfAndNullFlags(null_map, if_map, row_begin, row_end); if (final_flags[i] && vec[i] == *opt)
opt = findExtremeMaxIf(vec.getData().data(), final_flags.get(), row_begin, row_end); return {i};
if (!opt.has_value())
return std::nullopt;
for (size_t i = row_begin; i < row_end; i++)
{
if (final_flags[i] && vec[i] == *opt)
return {i};
}
} }
UNREACHABLE(); UNREACHABLE();
} }
else else
@ -1218,8 +1209,7 @@ bool SingleValueDataString::setIfSmaller(const IColumn & column, size_t row_num,
set(column, row_num, arena); set(column, row_num, arena);
return true; return true;
} }
else return false;
return false;
} }
bool SingleValueDataString::setIfSmaller(const SingleValueDataBase & other, Arena * arena) bool SingleValueDataString::setIfSmaller(const SingleValueDataBase & other, Arena * arena)
@ -1230,8 +1220,7 @@ bool SingleValueDataString::setIfSmaller(const SingleValueDataBase & other, Aren
changeImpl(to.getStringRef(), arena); changeImpl(to.getStringRef(), arena);
return true; return true;
} }
else return false;
return false;
} }
@ -1243,8 +1232,7 @@ bool SingleValueDataString::setIfGreater(const IColumn & column, size_t row_num,
set(column, row_num, arena); set(column, row_num, arena);
return true; return true;
} }
else return false;
return false;
} }
bool SingleValueDataString::setIfGreater(const SingleValueDataBase & other, Arena * arena) bool SingleValueDataString::setIfGreater(const SingleValueDataBase & other, Arena * arena)
@ -1255,8 +1243,7 @@ bool SingleValueDataString::setIfGreater(const SingleValueDataBase & other, Aren
changeImpl(to.getStringRef(), arena); changeImpl(to.getStringRef(), arena);
return true; return true;
} }
else return false;
return false;
} }
void SingleValueDataGeneric::insertResultInto(IColumn & to) const void SingleValueDataGeneric::insertResultInto(IColumn & to) const
@ -1317,18 +1304,15 @@ bool SingleValueDataGeneric::setIfSmaller(const IColumn & column, size_t row_num
set(column, row_num, arena); set(column, row_num, arena);
return true; return true;
} }
else
Field new_value;
column.get(row_num, new_value);
if (new_value < value)
{ {
Field new_value; value = new_value;
column.get(row_num, new_value); return true;
if (new_value < value)
{
value = new_value;
return true;
}
else
return false;
} }
return false;
} }
bool SingleValueDataGeneric::setIfSmaller(const SingleValueDataBase & other, Arena *) bool SingleValueDataGeneric::setIfSmaller(const SingleValueDataBase & other, Arena *)
@ -1339,8 +1323,7 @@ bool SingleValueDataGeneric::setIfSmaller(const SingleValueDataBase & other, Are
value = to.value; value = to.value;
return true; return true;
} }
else return false;
return false;
} }
bool SingleValueDataGeneric::setIfGreater(const IColumn & column, size_t row_num, Arena * arena) bool SingleValueDataGeneric::setIfGreater(const IColumn & column, size_t row_num, Arena * arena)
@ -1350,18 +1333,15 @@ bool SingleValueDataGeneric::setIfGreater(const IColumn & column, size_t row_num
set(column, row_num, arena); set(column, row_num, arena);
return true; return true;
} }
else
Field new_value;
column.get(row_num, new_value);
if (new_value > value)
{ {
Field new_value; value = new_value;
column.get(row_num, new_value); return true;
if (new_value > value)
{
value = new_value;
return true;
}
else
return false;
} }
return false;
} }
bool SingleValueDataGeneric::setIfGreater(const SingleValueDataBase & other, Arena *) bool SingleValueDataGeneric::setIfGreater(const SingleValueDataBase & other, Arena *)
@ -1372,8 +1352,7 @@ bool SingleValueDataGeneric::setIfGreater(const SingleValueDataBase & other, Are
value = to.value; value = to.value;
return true; return true;
} }
else return false;
return false;
} }
void generateSingleValueFromTypeIndex(TypeIndex idx, SingleValueDataBaseMemoryBlock & data) void generateSingleValueFromTypeIndex(TypeIndex idx, SingleValueDataBaseMemoryBlock & data)

View File

@ -60,10 +60,9 @@ public:
{ {
if (sk_union) if (sk_union)
return static_cast<UInt64>(sk_union->get_result().get_estimate()); return static_cast<UInt64>(sk_union->get_result().get_estimate());
else if (sk_update) if (sk_update)
return static_cast<UInt64>(sk_update->get_estimate()); return static_cast<UInt64>(sk_update->get_estimate());
else return 0;
return 0;
} }
void merge(const ThetaSketchData & rhs) void merge(const ThetaSketchData & rhs)

View File

@ -26,8 +26,7 @@ bool isAllArgumentsContiguousInMemory(const DataTypes & argument_types)
if (single_argument_as_tuple) if (single_argument_as_tuple)
return check_all_arguments_are_contiguous_in_memory(single_argument_as_tuple->getElements()); return check_all_arguments_are_contiguous_in_memory(single_argument_as_tuple->getElements());
else return check_all_arguments_are_contiguous_in_memory(argument_types);
return check_all_arguments_are_contiguous_in_memory(argument_types);
} }
} }

View File

@ -163,18 +163,16 @@ void ExceptColumnTransformerNode::dumpTreeImpl(WriteBuffer & buffer, FormatState
buffer << ", pattern: " << column_matcher->pattern(); buffer << ", pattern: " << column_matcher->pattern();
return; return;
} }
else
buffer << ", identifiers: ";
size_t except_column_names_size = except_column_names.size();
for (size_t i = 0; i < except_column_names_size; ++i)
{ {
buffer << ", identifiers: "; buffer << except_column_names[i];
size_t except_column_names_size = except_column_names.size(); if (i + 1 != except_column_names_size)
for (size_t i = 0; i < except_column_names_size; ++i) buffer << ", ";
{
buffer << except_column_names[i];
if (i + 1 != except_column_names_size)
buffer << ", ";
}
} }
} }
@ -190,9 +188,9 @@ bool ExceptColumnTransformerNode::isEqualImpl(const IQueryTreeNode & rhs, Compar
if (!column_matcher && !rhs_column_matcher) if (!column_matcher && !rhs_column_matcher)
return true; return true;
else if (column_matcher && !rhs_column_matcher) if (column_matcher && !rhs_column_matcher)
return false; return false;
else if (!column_matcher && rhs_column_matcher) if (!column_matcher && rhs_column_matcher)
return false; return false;
return column_matcher->pattern() == rhs_column_matcher->pattern(); return column_matcher->pattern() == rhs_column_matcher->pattern();

View File

@ -173,9 +173,9 @@ bool FunctionNode::isEqualImpl(const IQueryTreeNode & rhs, CompareOptions compar
if (lhs_result_type && rhs_result_type && !lhs_result_type->equals(*rhs_result_type)) if (lhs_result_type && rhs_result_type && !lhs_result_type->equals(*rhs_result_type))
return false; return false;
else if (lhs_result_type && !rhs_result_type) if (lhs_result_type && !rhs_result_type)
return false; return false;
else if (!lhs_result_type && rhs_result_type) if (!lhs_result_type && rhs_result_type)
return false; return false;
return true; return true;

View File

@ -127,9 +127,9 @@ bool IQueryTreeNode::isEqual(const IQueryTreeNode & rhs, CompareOptions compare_
if (!lhs_child && !rhs_child) if (!lhs_child && !rhs_child)
continue; continue;
else if (lhs_child && !rhs_child) if (lhs_child && !rhs_child)
return false; return false;
else if (!lhs_child && rhs_child) if (!lhs_child && rhs_child)
return false; return false;
nodes_to_process.emplace_back(lhs_child.get(), rhs_child.get()); nodes_to_process.emplace_back(lhs_child.get(), rhs_child.get());
@ -150,9 +150,9 @@ bool IQueryTreeNode::isEqual(const IQueryTreeNode & rhs, CompareOptions compare_
if (!lhs_strong_pointer && !rhs_strong_pointer) if (!lhs_strong_pointer && !rhs_strong_pointer)
continue; continue;
else if (lhs_strong_pointer && !rhs_strong_pointer) if (lhs_strong_pointer && !rhs_strong_pointer)
return false; return false;
else if (!lhs_strong_pointer && rhs_strong_pointer) if (!lhs_strong_pointer && rhs_strong_pointer)
return false; return false;
nodes_to_process.emplace_back(lhs_strong_pointer.get(), rhs_strong_pointer.get()); nodes_to_process.emplace_back(lhs_strong_pointer.get(), rhs_strong_pointer.get());

View File

@ -202,8 +202,7 @@ private:
} }
return; return;
} }
else visit(child);
visit(child);
} }
void visitChildren(VisitQueryTreeNodeType & expression) void visitChildren(VisitQueryTreeNodeType & expression)

View File

@ -173,9 +173,9 @@ bool MatcherNode::isEqualImpl(const IQueryTreeNode & rhs, CompareOptions) const
if (!columns_matcher && !rhs_columns_matcher) if (!columns_matcher && !rhs_columns_matcher)
return true; return true;
else if (columns_matcher && !rhs_columns_matcher) if (columns_matcher && !rhs_columns_matcher)
return false; return false;
else if (!columns_matcher && rhs_columns_matcher) if (!columns_matcher && rhs_columns_matcher)
return false; return false;
return columns_matcher->pattern() == rhs_columns_matcher->pattern(); return columns_matcher->pattern() == rhs_columns_matcher->pattern();

View File

@ -118,10 +118,9 @@ public:
{ {
if (aggregate_function_name == "min") if (aggregate_function_name == "min")
return "max"; return "max";
else if (aggregate_function_name == "max") if (aggregate_function_name == "max")
return "min"; return "min";
else return aggregate_function_name;
return aggregate_function_name;
}; };
size_t arithmetic_function_argument_index = 0; size_t arithmetic_function_argument_index = 0;

View File

@ -486,8 +486,7 @@ CNF & CNF::reduce()
statements = filterCNFSubsets(statements); statements = filterCNFSubsets(statements);
return *this; return *this;
} }
else statements = new_statements;
statements = new_statements;
} }
} }

View File

@ -184,7 +184,7 @@ StorageSnapshotPtr getStorageSnapshot(const QueryTreeNodePtr & node)
StorageSnapshotPtr storage_snapshot{nullptr}; StorageSnapshotPtr storage_snapshot{nullptr};
if (auto * table_node = node->as<TableNode>()) if (auto * table_node = node->as<TableNode>())
return table_node->getStorageSnapshot(); return table_node->getStorageSnapshot();
else if (auto * table_function_node = node->as<TableFunctionNode>()) if (auto * table_function_node = node->as<TableFunctionNode>())
return table_function_node->getStorageSnapshot(); return table_function_node->getStorageSnapshot();
return nullptr; return nullptr;

View File

@ -43,8 +43,7 @@ DataTypePtr getEnumType(const std::set<std::string> & string_values)
{ {
if (string_values.size() >= 255) if (string_values.size() >= 255)
return getDataEnumType<DataTypeEnum16>(string_values); return getDataEnumType<DataTypeEnum16>(string_values);
else return getDataEnumType<DataTypeEnum8>(string_values);
return getDataEnumType<DataTypeEnum8>(string_values);
} }
/// if(arg1, arg2, arg3) will be transformed to if(arg1, _CAST(arg2, Enum...), _CAST(arg3, Enum...)) /// if(arg1, arg2, arg3) will be transformed to if(arg1, _CAST(arg2, Enum...), _CAST(arg3, Enum...))

View File

@ -165,27 +165,26 @@ private:
createFunctionNode("greaterOrEquals", column_node, std::make_shared<ConstantNode>(start_date_or_date_time)), createFunctionNode("greaterOrEquals", column_node, std::make_shared<ConstantNode>(start_date_or_date_time)),
createFunctionNode("less", column_node, std::make_shared<ConstantNode>(end_date_or_date_time))); createFunctionNode("less", column_node, std::make_shared<ConstantNode>(end_date_or_date_time)));
} }
else if (comparator == "notEquals") if (comparator == "notEquals")
{ {
return createFunctionNode( return createFunctionNode(
"or", "or",
createFunctionNode("less", column_node, std::make_shared<ConstantNode>(start_date_or_date_time)), createFunctionNode("less", column_node, std::make_shared<ConstantNode>(start_date_or_date_time)),
createFunctionNode("greaterOrEquals", column_node, std::make_shared<ConstantNode>(end_date_or_date_time))); createFunctionNode("greaterOrEquals", column_node, std::make_shared<ConstantNode>(end_date_or_date_time)));
} }
else if (comparator == "greater") if (comparator == "greater")
{ {
return createFunctionNode("greaterOrEquals", column_node, std::make_shared<ConstantNode>(end_date_or_date_time)); return createFunctionNode("greaterOrEquals", column_node, std::make_shared<ConstantNode>(end_date_or_date_time));
} }
else if (comparator == "lessOrEquals") if (comparator == "lessOrEquals")
{ {
return createFunctionNode("less", column_node, std::make_shared<ConstantNode>(end_date_or_date_time)); return createFunctionNode("less", column_node, std::make_shared<ConstantNode>(end_date_or_date_time));
} }
else if (comparator == "less" || comparator == "greaterOrEquals") if (comparator == "less" || comparator == "greaterOrEquals")
{ {
return createFunctionNode(comparator, column_node, std::make_shared<ConstantNode>(start_date_or_date_time)); return createFunctionNode(comparator, column_node, std::make_shared<ConstantNode>(start_date_or_date_time));
} }
else [[unlikely]] [[unlikely]] {
{
throw Exception( throw Exception(
ErrorCodes::LOGICAL_ERROR, ErrorCodes::LOGICAL_ERROR,
"Expected equals, notEquals, less, lessOrEquals, greater, greaterOrEquals. Actual {}", "Expected equals, notEquals, less, lessOrEquals, greater, greaterOrEquals. Actual {}",

View File

@ -552,9 +552,9 @@ QueryTreeNodePtr IdentifierResolver::tryResolveIdentifierFromExpressionArguments
auto node_type = it->second->getNodeType(); auto node_type = it->second->getNodeType();
if (identifier_lookup.isExpressionLookup() && !isExpressionNodeType(node_type)) if (identifier_lookup.isExpressionLookup() && !isExpressionNodeType(node_type))
return {}; return {};
else if (identifier_lookup.isTableExpressionLookup() && !isTableExpressionNodeType(node_type)) if (identifier_lookup.isTableExpressionLookup() && !isTableExpressionNodeType(node_type))
return {}; return {};
else if (identifier_lookup.isFunctionLookup() && !isFunctionExpressionNodeType(node_type)) if (identifier_lookup.isFunctionLookup() && !isFunctionExpressionNodeType(node_type))
return {}; return {};
if (!resolve_full_identifier && identifier_lookup.identifier.isCompound() && identifier_lookup.isExpressionLookup()) if (!resolve_full_identifier && identifier_lookup.identifier.isCompound() && identifier_lookup.isExpressionLookup())
@ -638,10 +638,9 @@ bool IdentifierResolver::tryBindIdentifierToTableExpression(const IdentifierLook
if (parts_size == 1 && path_start == table_name) if (parts_size == 1 && path_start == table_name)
return true; return true;
else if (parts_size == 2 && path_start == database_name && identifier[1] == table_name) if (parts_size == 2 && path_start == database_name && identifier[1] == table_name)
return true; return true;
else return false;
return false;
} }
if (table_expression_data.hasFullIdentifierName(IdentifierView(identifier)) || table_expression_data.canBindIdentifier(IdentifierView(identifier))) if (table_expression_data.hasFullIdentifierName(IdentifierView(identifier)) || table_expression_data.canBindIdentifier(IdentifierView(identifier)))
@ -910,10 +909,9 @@ QueryTreeNodePtr IdentifierResolver::tryResolveIdentifierFromTableExpression(con
if (parts_size == 1 && path_start == table_name) if (parts_size == 1 && path_start == table_name)
return table_expression_node; return table_expression_node;
else if (parts_size == 2 && path_start == database_name && identifier[1] == table_name) if (parts_size == 2 && path_start == database_name && identifier[1] == table_name)
return table_expression_node; return table_expression_node;
else return {};
return {};
} }
/** If identifier first part binds to some column start or table has full identifier name. Then we can try to find whole identifier in table. /** If identifier first part binds to some column start or table has full identifier name. Then we can try to find whole identifier in table.

View File

@ -1219,9 +1219,10 @@ QueryTreeNodePtr QueryAnalyzer::tryResolveIdentifierFromAliases(const Identifier
scope, scope,
identifier_resolve_settings.allow_to_check_join_tree /* can_be_not_found */); identifier_resolve_settings.allow_to_check_join_tree /* can_be_not_found */);
} }
else if (identifier_lookup.isFunctionLookup() || identifier_lookup.isTableExpressionLookup()) if (identifier_lookup.isFunctionLookup() || identifier_lookup.isTableExpressionLookup())
{ {
throw Exception(ErrorCodes::BAD_ARGUMENTS, throw Exception(
ErrorCodes::BAD_ARGUMENTS,
"Compound identifier '{}' cannot be resolved as {}. In scope {}", "Compound identifier '{}' cannot be resolved as {}. In scope {}",
identifier_lookup.identifier.getFullName(), identifier_lookup.identifier.getFullName(),
identifier_lookup.isFunctionLookup() ? "function" : "table expression", identifier_lookup.isFunctionLookup() ? "function" : "table expression",
@ -1307,7 +1308,7 @@ IdentifierResolveResult QueryAnalyzer::tryResolveIdentifierInParentScopes(const
{ {
return lookup_result; return lookup_result;
} }
else if (auto * resolved_function = resolved_identifier->as<FunctionNode>()) if (auto * resolved_function = resolved_identifier->as<FunctionNode>())
{ {
/// Special case: scalar subquery was executed and replaced by __getScalar function. /// Special case: scalar subquery was executed and replaced by __getScalar function.
/// Handle it as a constant. /// Handle it as a constant.
@ -3173,14 +3174,14 @@ ProjectionNames QueryAnalyzer::resolveFunction(QueryTreeNodePtr & node, Identifi
node = std::move(result_list); node = std::move(result_list);
return result_projection_names; return result_projection_names;
} }
else if (function_name == "grouping") if (function_name == "grouping")
{ {
/// It is responsibility of planner to perform additional handling of grouping function /// It is responsibility of planner to perform additional handling of grouping function
if (function_arguments_size == 0) if (function_arguments_size == 0)
throw Exception(ErrorCodes::TOO_FEW_ARGUMENTS_FOR_FUNCTION, throw Exception(ErrorCodes::TOO_FEW_ARGUMENTS_FOR_FUNCTION, "Function GROUPING expects at least one argument");
"Function GROUPING expects at least one argument"); if (function_arguments_size > 64)
else if (function_arguments_size > 64) throw Exception(
throw Exception(ErrorCodes::TOO_MANY_ARGUMENTS_FOR_FUNCTION, ErrorCodes::TOO_MANY_ARGUMENTS_FOR_FUNCTION,
"Function GROUPING can have up to 64 arguments, but {} provided", "Function GROUPING can have up to 64 arguments, but {} provided",
function_arguments_size); function_arguments_size);
checkFunctionNodeHasEmptyNullsAction(function_node); checkFunctionNodeHasEmptyNullsAction(function_node);
@ -3744,11 +3745,11 @@ ProjectionNames QueryAnalyzer::resolveExpressionNode(
resolved_expression_it = resolved_expressions.find(node); resolved_expression_it = resolved_expressions.find(node);
if (resolved_expression_it != resolved_expressions.end()) if (resolved_expression_it != resolved_expressions.end())
return resolved_expression_it->second; return resolved_expression_it->second;
else throw Exception(
throw Exception(ErrorCodes::LOGICAL_ERROR, ErrorCodes::LOGICAL_ERROR,
"Identifier '{}' resolve into list node and list node projection names are not initialized. In scope {}", "Identifier '{}' resolve into list node and list node projection names are not initialized. In scope {}",
unresolved_identifier.getFullName(), unresolved_identifier.getFullName(),
scope.scope_node->formatASTForErrorMessage()); scope.scope_node->formatASTForErrorMessage());
} }
if (result_projection_names.empty()) if (result_projection_names.empty())
@ -4212,7 +4213,7 @@ NamesAndTypes QueryAnalyzer::resolveProjectionExpressionNodeList(QueryTreeNodePt
for (size_t i = 0; i < projection_nodes_size; ++i) for (size_t i = 0; i < projection_nodes_size; ++i)
{ {
auto projection_node = projection_nodes[i]; const auto & projection_node = projection_nodes[i];
if (!IdentifierResolver::isExpressionNodeType(projection_node->getNodeType())) if (!IdentifierResolver::isExpressionNodeType(projection_node->getNodeType()))
throw Exception(ErrorCodes::UNSUPPORTED_METHOD, throw Exception(ErrorCodes::UNSUPPORTED_METHOD,
@ -4628,10 +4629,7 @@ void QueryAnalyzer::resolveTableFunction(QueryTreeNodePtr & table_function_node,
"Unknown table function {}. Maybe you meant: {}", "Unknown table function {}. Maybe you meant: {}",
table_function_name, table_function_name,
DB::toString(hints)); DB::toString(hints));
else throw Exception(ErrorCodes::UNKNOWN_FUNCTION, "Unknown table function {}", table_function_name);
throw Exception(ErrorCodes::UNKNOWN_FUNCTION,
"Unknown table function {}",
table_function_name);
} }
QueryTreeNodes result_table_function_arguments; QueryTreeNodes result_table_function_arguments;
@ -4667,7 +4665,7 @@ void QueryAnalyzer::resolveTableFunction(QueryTreeNodePtr & table_function_node,
continue; continue;
} }
else if (auto * table_function_argument_function = table_function_argument->as<FunctionNode>()) if (auto * table_function_argument_function = table_function_argument->as<FunctionNode>())
{ {
const auto & table_function_argument_function_name = table_function_argument_function->getFunctionName(); const auto & table_function_argument_function_name = table_function_argument_function->getFunctionName();
if (TableFunctionFactory::instance().isTableFunctionName(table_function_argument_function_name)) if (TableFunctionFactory::instance().isTableFunctionName(table_function_argument_function_name))

View File

@ -50,7 +50,7 @@ public:
updateAliasesIfNeeded(child, true /*is_lambda_node*/); updateAliasesIfNeeded(child, true /*is_lambda_node*/);
return false; return false;
} }
else if (auto * query_tree_node = child->as<QueryNode>()) if (auto * query_tree_node = child->as<QueryNode>())
{ {
if (query_tree_node->isCTE()) if (query_tree_node->isCTE())
return false; return false;
@ -58,7 +58,7 @@ public:
updateAliasesIfNeeded(child, false /*is_lambda_node*/); updateAliasesIfNeeded(child, false /*is_lambda_node*/);
return false; return false;
} }
else if (auto * union_node = child->as<UnionNode>()) if (auto * union_node = child->as<UnionNode>())
{ {
if (union_node->isCTE()) if (union_node->isCTE())
return false; return false;

View File

@ -81,9 +81,9 @@ bool SortNode::isEqualImpl(const IQueryTreeNode & rhs, CompareOptions) const
if (!collator && !rhs_typed.collator) if (!collator && !rhs_typed.collator)
return true; return true;
else if (collator && !rhs_typed.collator) if (collator && !rhs_typed.collator)
return false; return false;
else if (!collator && rhs_typed.collator) if (!collator && rhs_typed.collator)
return false; return false;
return collator->getLocale() == rhs_typed.collator->getLocale(); return collator->getLocale() == rhs_typed.collator->getLocale();

View File

@ -170,7 +170,7 @@ bool UnionNode::isEqualImpl(const IQueryTreeNode & rhs, CompareOptions) const
if (recursive_cte_table && rhs_typed.recursive_cte_table && if (recursive_cte_table && rhs_typed.recursive_cte_table &&
recursive_cte_table->getStorageID() != rhs_typed.recursive_cte_table->getStorageID()) recursive_cte_table->getStorageID() != rhs_typed.recursive_cte_table->getStorageID())
return false; return false;
else if ((recursive_cte_table && !rhs_typed.recursive_cte_table) || (!recursive_cte_table && rhs_typed.recursive_cte_table)) if ((recursive_cte_table && !rhs_typed.recursive_cte_table) || (!recursive_cte_table && rhs_typed.recursive_cte_table))
return false; return false;
return is_subquery == rhs_typed.is_subquery && is_cte == rhs_typed.is_cte && is_recursive_cte == rhs_typed.is_recursive_cte return is_subquery == rhs_typed.is_subquery && is_cte == rhs_typed.is_cte && is_recursive_cte == rhs_typed.is_recursive_cte

View File

@ -156,19 +156,19 @@ std::string getGlobalInFunctionNameForLocalInFunctionName(const std::string & fu
{ {
if (function_name == "in") if (function_name == "in")
return "globalIn"; return "globalIn";
else if (function_name == "notIn") if (function_name == "notIn")
return "globalNotIn"; return "globalNotIn";
else if (function_name == "nullIn") if (function_name == "nullIn")
return "globalNullIn"; return "globalNullIn";
else if (function_name == "notNullIn") if (function_name == "notNullIn")
return "globalNotNullIn"; return "globalNotNullIn";
else if (function_name == "inIgnoreSet") if (function_name == "inIgnoreSet")
return "globalInIgnoreSet"; return "globalInIgnoreSet";
else if (function_name == "notInIgnoreSet") if (function_name == "notInIgnoreSet")
return "globalNotInIgnoreSet"; return "globalNotInIgnoreSet";
else if (function_name == "nullInIgnoreSet") if (function_name == "nullInIgnoreSet")
return "globalNullInIgnoreSet"; return "globalNullInIgnoreSet";
else if (function_name == "notNullInIgnoreSet") if (function_name == "notNullInIgnoreSet")
return "globalNotNullInIgnoreSet"; return "globalNotNullInIgnoreSet";
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Invalid local IN function name {}", function_name); throw Exception(ErrorCodes::BAD_ARGUMENTS, "Invalid local IN function name {}", function_name);

View File

@ -173,9 +173,9 @@ private:
if (!lhs_child && !rhs_child) if (!lhs_child && !rhs_child)
continue; continue;
else if (lhs_child && !rhs_child) if (lhs_child && !rhs_child)
return false; return false;
else if (!lhs_child && rhs_child) if (!lhs_child && rhs_child)
return false; return false;
nodes_to_process.emplace_back(lhs_child.get(), rhs_child.get()); nodes_to_process.emplace_back(lhs_child.get(), rhs_child.get());

View File

@ -182,17 +182,15 @@ Strings BackupEntriesCollector::setStage(const String & new_stage, const String
{ {
return backup_coordination->waitForStage(new_stage, on_cluster_first_sync_timeout); return backup_coordination->waitForStage(new_stage, on_cluster_first_sync_timeout);
} }
else if (new_stage.starts_with(Stage::GATHERING_METADATA)) if (new_stage.starts_with(Stage::GATHERING_METADATA))
{ {
auto current_time = std::chrono::steady_clock::now(); auto current_time = std::chrono::steady_clock::now();
auto end_of_timeout = std::max(current_time, collect_metadata_end_time); auto end_of_timeout = std::max(current_time, collect_metadata_end_time);
return backup_coordination->waitForStage( return backup_coordination->waitForStage(
new_stage, std::chrono::duration_cast<std::chrono::milliseconds>(end_of_timeout - current_time)); new_stage, std::chrono::duration_cast<std::chrono::milliseconds>(end_of_timeout - current_time));
} }
else
{ return backup_coordination->waitForStage(new_stage);
return backup_coordination->waitForStage(new_stage);
}
} }
void BackupEntriesCollector::checkIsQueryCancelled() const void BackupEntriesCollector::checkIsQueryCancelled() const
@ -716,23 +714,20 @@ bool BackupEntriesCollector::compareWithPrevious(String & mismatch_description)
{ {
if (mismatch->first == p_mismatch->first) if (mismatch->first == p_mismatch->first)
return {MismatchType::CHANGED, mismatch->first}; return {MismatchType::CHANGED, mismatch->first};
else if (mismatch->first < p_mismatch->first) if (mismatch->first < p_mismatch->first)
return {MismatchType::ADDED, mismatch->first}; return {MismatchType::ADDED, mismatch->first};
else return {MismatchType::REMOVED, mismatch->first};
return {MismatchType::REMOVED, mismatch->first};
} }
else if (mismatch != metadata.end()) if (mismatch != metadata.end())
{ {
return {MismatchType::ADDED, mismatch->first}; return {MismatchType::ADDED, mismatch->first};
} }
else if (p_mismatch != previous_metadata.end()) if (p_mismatch != previous_metadata.end())
{ {
return {MismatchType::REMOVED, p_mismatch->first}; return {MismatchType::REMOVED, p_mismatch->first};
} }
else
{ return {MismatchType::NONE, {}};
return {MismatchType::NONE, {}};
}
}; };
/// Databases must be the same as during the previous scan. /// Databases must be the same as during the previous scan.

View File

@ -14,10 +14,9 @@ namespace
{ {
if (!unencrypted_file_size) if (!unencrypted_file_size)
return copy_encrypted ? disk->getEncryptedFileSize(file_path) : disk->getFileSize(file_path); return copy_encrypted ? disk->getEncryptedFileSize(file_path) : disk->getFileSize(file_path);
else if (copy_encrypted) if (copy_encrypted)
return disk->getEncryptedFileSize(*unencrypted_file_size); return disk->getEncryptedFileSize(*unencrypted_file_size);
else return *unencrypted_file_size;
return *unencrypted_file_size;
} }
} }

View File

@ -39,8 +39,7 @@ std::unique_ptr<SeekableReadBuffer> BackupEntryFromImmutableFile::getReadBuffer(
{ {
if (copy_encrypted) if (copy_encrypted)
return disk->readEncryptedFile(file_path, read_settings); return disk->readEncryptedFile(file_path, read_settings);
else return disk->readFile(file_path, read_settings);
return disk->readFile(file_path, read_settings);
} }
UInt64 BackupEntryFromImmutableFile::getSize() const UInt64 BackupEntryFromImmutableFile::getSize() const

Some files were not shown because too many files have changed in this diff Show More