mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Added even more clang-tidy checks
This commit is contained in:
parent
c20853eecc
commit
93466ce097
37
.clang-tidy
37
.clang-tidy
@ -1,9 +1,14 @@
|
||||
Checks: '-*,
|
||||
google-readability-avoid-underscore-in-googletest-name,
|
||||
|
||||
misc-throw-by-value-catch-by-reference,
|
||||
misc-misplaced-const,
|
||||
misc-unconventional-assign-operator,
|
||||
misc-redundant-expression,
|
||||
misc-static-assert,
|
||||
misc-unconventional-assign-operator,
|
||||
misc-uniqueptr-reset-release,
|
||||
misc-unused-alias-decls,
|
||||
misc-unused-parameters,
|
||||
misc-unused-using-decls,
|
||||
|
||||
modernize-avoid-bind,
|
||||
modernize-loop-convert,
|
||||
@ -21,6 +26,13 @@ Checks: '-*,
|
||||
|
||||
performance-faster-string-find,
|
||||
performance-for-range-copy,
|
||||
performance-implicit-conversion-in-loop,
|
||||
performance-inefficient-algorithm,
|
||||
performance-inefficient-vector-operation,
|
||||
performance-move-constructor-init,
|
||||
performance-no-automatic-move,
|
||||
performance-trivially-destructible,
|
||||
performance-unnecessary-copy-initialization,
|
||||
|
||||
readability-avoid-const-params-in-decls,
|
||||
readability-const-return-type,
|
||||
@ -90,6 +102,27 @@ Checks: '-*,
|
||||
bugprone-use-after-move,
|
||||
bugprone-virtual-near-miss,
|
||||
|
||||
cert-dcl21-cpp,
|
||||
cert-dcl50-cpp,
|
||||
cert-env33-c,
|
||||
cert-err34-c,
|
||||
cert-err52-cpp,
|
||||
cert-flp30-c,
|
||||
cert-mem57-cpp,
|
||||
cert-msc50-cpp,
|
||||
cert-oop58-cpp,
|
||||
|
||||
google-build-explicit-make-pair,
|
||||
google-build-namespaces,
|
||||
google-default-arguments,
|
||||
google-explicit-constructor,
|
||||
google-readability-casting,
|
||||
google-readability-avoid-underscore-in-googletest-name,
|
||||
google-runtime-int,
|
||||
google-runtime-operator,
|
||||
|
||||
hicpp-exception-baseclass,
|
||||
|
||||
boost-use-to-string,
|
||||
'
|
||||
WarningsAsErrors: '*'
|
||||
|
@ -776,7 +776,7 @@ JSON::iterator & JSON::iterator::operator++()
|
||||
return *this;
|
||||
}
|
||||
|
||||
JSON::iterator JSON::iterator::operator++(int)
|
||||
JSON::iterator JSON::iterator::operator++(int) // NOLINT
|
||||
{
|
||||
iterator copy(*this);
|
||||
++*this;
|
||||
|
@ -69,13 +69,13 @@ uint64_t getMemoryAmountOrZero()
|
||||
|
||||
#elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
|
||||
/* FreeBSD, Linux, OpenBSD, and Solaris. -------------------- */
|
||||
return (uint64_t)sysconf(_SC_PHYS_PAGES)
|
||||
* (uint64_t)sysconf(_SC_PAGESIZE);
|
||||
return uint64_t(sysconf(_SC_PHYS_PAGES))
|
||||
*uint64_t(sysconf(_SC_PAGESIZE));
|
||||
|
||||
#elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGE_SIZE)
|
||||
/* Legacy. -------------------------------------------------- */
|
||||
return (uint64_t)sysconf(_SC_PHYS_PAGES)
|
||||
* (uint64_t)sysconf(_SC_PAGE_SIZE);
|
||||
return uint64_t(sysconf(_SC_PHYS_PAGES))
|
||||
* uint64_t(sysconf(_SC_PAGE_SIZE));
|
||||
|
||||
#elif defined(CTL_HW) && (defined(HW_PHYSMEM) || defined(HW_REALMEM))
|
||||
/* DragonFly BSD, FreeBSD, NetBSD, OpenBSD, and OSX. -------- */
|
||||
|
@ -43,7 +43,7 @@ void loop(time_t begin, time_t end, int step)
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
int main(int, char **)
|
||||
{
|
||||
loop(orderedIdentifierToDate(20101031), orderedIdentifierToDate(20101101), 15 * 60);
|
||||
loop(orderedIdentifierToDate(20100328), orderedIdentifierToDate(20100330), 15 * 60);
|
||||
|
@ -53,7 +53,7 @@ void loop(time_t begin, time_t end, int step)
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
int main(int, char **)
|
||||
{
|
||||
loop(orderedIdentifierToDate(20101031), orderedIdentifierToDate(20101101), 15 * 60);
|
||||
loop(orderedIdentifierToDate(20100328), orderedIdentifierToDate(20100330), 15 * 60);
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <common/DateLUT.h>
|
||||
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
int main(int, char **)
|
||||
{
|
||||
/** В DateLUT был глюк - для времён из дня 1970-01-01, возвращался номер часа больше 23. */
|
||||
static const time_t TIME = 66130;
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <common/DateLUT.h>
|
||||
#include <Poco/Exception.h>
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
int main(int, char **)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <common/DateLUT.h>
|
||||
|
||||
/// Позволяет проверить время инициализации DateLUT.
|
||||
int main(int argc, char ** argv)
|
||||
int main(int, char **)
|
||||
{
|
||||
DateLUT::instance();
|
||||
return 0;
|
||||
|
@ -54,7 +54,7 @@ TEST(StrongTypedefSuite, NoDefaultCtor)
|
||||
{
|
||||
struct NoDefaultCtor
|
||||
{
|
||||
NoDefaultCtor(int i) {}
|
||||
NoDefaultCtor(int) {} // NOLINT
|
||||
};
|
||||
|
||||
STRONG_TYPEDEF(NoDefaultCtor, MyStruct);
|
||||
|
@ -99,12 +99,12 @@ static void writeSignalIDtoSignalPipe(int sig)
|
||||
}
|
||||
|
||||
/** Signal handler for HUP / USR1 */
|
||||
static void closeLogsSignalHandler(int sig, siginfo_t * info, void * context)
|
||||
static void closeLogsSignalHandler(int sig, siginfo_t *, void *)
|
||||
{
|
||||
writeSignalIDtoSignalPipe(sig);
|
||||
}
|
||||
|
||||
static void terminateRequestedSignalHandler(int sig, siginfo_t * info, void * context)
|
||||
static void terminateRequestedSignalHandler(int sig, siginfo_t *, void *)
|
||||
{
|
||||
writeSignalIDtoSignalPipe(sig);
|
||||
}
|
||||
@ -404,7 +404,7 @@ std::string instructionFailToString(InstructionFail fail)
|
||||
|
||||
sigjmp_buf jmpbuf;
|
||||
|
||||
void sigIllCheckHandler(int sig, siginfo_t * info, void * context)
|
||||
void sigIllCheckHandler(int, siginfo_t *, void *)
|
||||
{
|
||||
siglongjmp(jmpbuf, 1);
|
||||
}
|
||||
|
@ -1181,7 +1181,7 @@ String ClusterCopier::getRemoteCreateTable(const DatabaseAndTableName & table, C
|
||||
ASTPtr ClusterCopier::getCreateTableForPullShard(const ConnectionTimeouts & timeouts, TaskShard & task_shard)
|
||||
{
|
||||
/// Fetch and parse (possibly) new definition
|
||||
auto connection_entry = task_shard.info.pool->get(timeouts, &task_cluster->settings_pull);
|
||||
auto connection_entry = task_shard.info.pool->get(timeouts, &task_cluster->settings_pull, true);
|
||||
String create_query_pull_str = getRemoteCreateTable(
|
||||
task_shard.task_table.table_pull,
|
||||
*connection_entry,
|
||||
|
@ -114,8 +114,7 @@ protected:
|
||||
Connection & connection,
|
||||
const Settings * settings = nullptr);
|
||||
|
||||
ASTPtr getCreateTableForPullShard(const ConnectionTimeouts & timeouts,
|
||||
TaskShard & task_shard);
|
||||
ASTPtr getCreateTableForPullShard(const ConnectionTimeouts & timeouts, TaskShard & task_shard);
|
||||
|
||||
void createShardInternalTables(const ConnectionTimeouts & timeouts,
|
||||
TaskShard & task_shard,
|
||||
|
@ -181,7 +181,7 @@ private:
|
||||
UInt64 seed;
|
||||
|
||||
public:
|
||||
UnsignedIntegerModel(UInt64 seed_) : seed(seed_) {}
|
||||
explicit UnsignedIntegerModel(UInt64 seed_) : seed(seed_) {}
|
||||
|
||||
void train(const IColumn &) override {}
|
||||
void finalize() override {}
|
||||
@ -222,7 +222,7 @@ private:
|
||||
UInt64 seed;
|
||||
|
||||
public:
|
||||
SignedIntegerModel(UInt64 seed_) : seed(seed_) {}
|
||||
explicit SignedIntegerModel(UInt64 seed_) : seed(seed_) {}
|
||||
|
||||
void train(const IColumn &) override {}
|
||||
void finalize() override {}
|
||||
@ -271,7 +271,7 @@ private:
|
||||
Float res_prev_value = 0;
|
||||
|
||||
public:
|
||||
FloatModel(UInt64 seed_) : seed(seed_) {}
|
||||
explicit FloatModel(UInt64 seed_) : seed(seed_) {}
|
||||
|
||||
void train(const IColumn &) override {}
|
||||
void finalize() override {}
|
||||
@ -372,7 +372,7 @@ private:
|
||||
UInt64 seed;
|
||||
|
||||
public:
|
||||
FixedStringModel(UInt64 seed_) : seed(seed_) {}
|
||||
explicit FixedStringModel(UInt64 seed_) : seed(seed_) {}
|
||||
|
||||
void train(const IColumn &) override {}
|
||||
void finalize() override {}
|
||||
@ -414,7 +414,7 @@ private:
|
||||
const DateLUTImpl & date_lut;
|
||||
|
||||
public:
|
||||
DateTimeModel(UInt64 seed_) : seed(seed_), date_lut(DateLUT::instance()) {}
|
||||
explicit DateTimeModel(UInt64 seed_) : seed(seed_), date_lut(DateLUT::instance()) {}
|
||||
|
||||
void train(const IColumn &) override {}
|
||||
void finalize() override {}
|
||||
@ -567,7 +567,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
MarkovModel(MarkovModelParameters params_)
|
||||
explicit MarkovModel(MarkovModelParameters params_)
|
||||
: params(std::move(params_)), code_points(params.order, BEGIN) {}
|
||||
|
||||
void consume(const char * data, size_t size)
|
||||
@ -836,7 +836,7 @@ private:
|
||||
ModelPtr nested_model;
|
||||
|
||||
public:
|
||||
ArrayModel(ModelPtr nested_model_) : nested_model(std::move(nested_model_)) {}
|
||||
explicit ArrayModel(ModelPtr nested_model_) : nested_model(std::move(nested_model_)) {}
|
||||
|
||||
void train(const IColumn & column) override
|
||||
{
|
||||
@ -874,7 +874,7 @@ private:
|
||||
ModelPtr nested_model;
|
||||
|
||||
public:
|
||||
NullableModel(ModelPtr nested_model_) : nested_model(std::move(nested_model_)) {}
|
||||
explicit NullableModel(ModelPtr nested_model_) : nested_model(std::move(nested_model_)) {}
|
||||
|
||||
void train(const IColumn & column) override
|
||||
{
|
||||
|
@ -52,8 +52,6 @@ void waitQuery(Connection & connection)
|
||||
}
|
||||
}
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
PerformanceTest::PerformanceTest(
|
||||
const XMLConfigurationPtr & config_,
|
||||
Connection & connection_,
|
||||
|
@ -119,7 +119,7 @@ std::string ReportBuilder::buildFullReport(
|
||||
if (statistics.sampler.size() != 0)
|
||||
{
|
||||
JSONString quantiles(4); /// here, 4 is the size of \t padding
|
||||
for (double percent = 10; percent <= 90; percent += 10)
|
||||
for (int percent = 10; percent <= 90; percent += 10)
|
||||
{
|
||||
std::string quantile_key = std::to_string(percent / 100.0);
|
||||
while (quantile_key.back() == '0')
|
||||
|
@ -17,9 +17,9 @@ std::string TestStats::getStatisticByName(const std::string & statistic_name)
|
||||
{
|
||||
std::string result = "\n";
|
||||
|
||||
for (double percent = 10; percent <= 90; percent += 10)
|
||||
for (int percent = 10; percent <= 90; percent += 10)
|
||||
{
|
||||
result += FOUR_SPACES + std::to_string((percent / 100));
|
||||
result += FOUR_SPACES + std::to_string((percent / 100.0));
|
||||
result += ": " + std::to_string(sampler.quantileInterpolated(percent / 100.0));
|
||||
result += "\n";
|
||||
}
|
||||
|
@ -25,7 +25,8 @@ template <typename has_limit>
|
||||
class AggregateFunctionGroupUniqArrayDate : public AggregateFunctionGroupUniqArray<DataTypeDate::FieldType, has_limit>
|
||||
{
|
||||
public:
|
||||
AggregateFunctionGroupUniqArrayDate(const DataTypePtr & argument_type, UInt64 max_elems_ = std::numeric_limits<UInt64>::max()) : AggregateFunctionGroupUniqArray<DataTypeDate::FieldType, has_limit>(argument_type, max_elems_) {}
|
||||
explicit AggregateFunctionGroupUniqArrayDate(const DataTypePtr & argument_type, UInt64 max_elems_ = std::numeric_limits<UInt64>::max())
|
||||
: AggregateFunctionGroupUniqArray<DataTypeDate::FieldType, has_limit>(argument_type, max_elems_) {}
|
||||
DataTypePtr getReturnType() const override { return std::make_shared<DataTypeArray>(std::make_shared<DataTypeDate>()); }
|
||||
};
|
||||
|
||||
@ -33,7 +34,8 @@ template <typename has_limit>
|
||||
class AggregateFunctionGroupUniqArrayDateTime : public AggregateFunctionGroupUniqArray<DataTypeDateTime::FieldType, has_limit>
|
||||
{
|
||||
public:
|
||||
AggregateFunctionGroupUniqArrayDateTime(const DataTypePtr & argument_type, UInt64 max_elems_ = std::numeric_limits<UInt64>::max()) : AggregateFunctionGroupUniqArray<DataTypeDateTime::FieldType, has_limit>(argument_type, max_elems_) {}
|
||||
explicit AggregateFunctionGroupUniqArrayDateTime(const DataTypePtr & argument_type, UInt64 max_elems_ = std::numeric_limits<UInt64>::max())
|
||||
: AggregateFunctionGroupUniqArray<DataTypeDateTime::FieldType, has_limit>(argument_type, max_elems_) {}
|
||||
DataTypePtr getReturnType() const override { return std::make_shared<DataTypeArray>(std::make_shared<DataTypeDateTime>()); }
|
||||
};
|
||||
|
||||
|
@ -44,8 +44,8 @@ public:
|
||||
|
||||
/** Allocates connection to work. */
|
||||
Entry get(const ConnectionTimeouts & timeouts,
|
||||
const Settings * settings = nullptr,
|
||||
bool force_connected = true) override; /// From IConnectionPool
|
||||
const Settings * settings,
|
||||
bool force_connected) override; /// From IConnectionPool
|
||||
|
||||
/** Allocates up to the specified number of connections to work.
|
||||
* Connections provide access to different replicas of one shard.
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include <Client/MultiplexedConnections.h>
|
||||
#include <IO/ConnectionTimeouts.h>
|
||||
#include <Common/thread_local_rng.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -308,10 +310,10 @@ MultiplexedConnections::ReplicaState & MultiplexedConnections::getReplicaForRead
|
||||
throw Exception("Timeout exceeded while reading from " + dumpAddressesUnlocked(), ErrorCodes::TIMEOUT_EXCEEDED);
|
||||
}
|
||||
|
||||
/// TODO Absolutely wrong code: read_list could be empty; rand() is not thread safe and has low quality; motivation of rand is unclear.
|
||||
/// TODO Absolutely wrong code: read_list could be empty; motivation of rand is unclear.
|
||||
/// This code path is disabled by default.
|
||||
|
||||
auto & socket = read_list[rand() % read_list.size()];
|
||||
auto & socket = read_list[thread_local_rng() % read_list.size()];
|
||||
if (fd_to_replica_state_idx.empty())
|
||||
{
|
||||
fd_to_replica_state_idx.reserve(replica_states.size());
|
||||
|
@ -294,7 +294,7 @@ void ConfigProcessor::doIncludesRecursive(
|
||||
|
||||
auto process_include = [&](const Node * include_attr, const std::function<const Node * (const std::string &)> & get_node, const char * error_msg)
|
||||
{
|
||||
std::string name = include_attr->getNodeValue();
|
||||
const std::string & name = include_attr->getNodeValue();
|
||||
const Node * node_to_include = get_node(name);
|
||||
if (!node_to_include)
|
||||
{
|
||||
|
@ -170,8 +170,8 @@ bool DNSResolver::updateCache()
|
||||
{
|
||||
{
|
||||
std::lock_guard lock(impl->drop_mutex);
|
||||
for (auto & host : impl->new_hosts)
|
||||
impl->known_hosts.insert(std::move(host));
|
||||
for (const auto & host : impl->new_hosts)
|
||||
impl->known_hosts.insert(host);
|
||||
impl->new_hosts.clear();
|
||||
|
||||
impl->host_name.emplace(Poco::Net::DNS::hostName());
|
||||
|
@ -273,7 +273,7 @@ void tryLogException(std::exception_ptr e, const char * log_name, const std::str
|
||||
{
|
||||
try
|
||||
{
|
||||
std::rethrow_exception(std::move(e));
|
||||
std::rethrow_exception(std::move(e)); // NOLINT
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@ -285,7 +285,7 @@ void tryLogException(std::exception_ptr e, Poco::Logger * logger, const std::str
|
||||
{
|
||||
try
|
||||
{
|
||||
std::rethrow_exception(std::move(e));
|
||||
std::rethrow_exception(std::move(e)); // NOLINT
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@ -327,7 +327,7 @@ std::string getExceptionMessage(std::exception_ptr e, bool with_stacktrace)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::rethrow_exception(std::move(e));
|
||||
std::rethrow_exception(std::move(e)); // NOLINT
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ String getOpenSSLErrors()
|
||||
SCOPE_EXIT(BIO_free(mem));
|
||||
ERR_print_errors(mem);
|
||||
char * buf = nullptr;
|
||||
long size = BIO_get_mem_data(mem, &buf);
|
||||
size_t size = BIO_get_mem_data(mem, &buf);
|
||||
return String(buf, size);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace ProfileEvents
|
||||
Counters(VariableContext level_ = VariableContext::Thread, Counters * parent_ = &global_counters);
|
||||
|
||||
/// Global level static initializer
|
||||
Counters(Counter * allocated_counters)
|
||||
Counters(Counter * allocated_counters) noexcept
|
||||
: counters(allocated_counters), parent(nullptr), level(VariableContext::Global) {}
|
||||
|
||||
Counter & operator[] (Event event)
|
||||
|
@ -186,7 +186,7 @@ void collectSymbolsFromProgramHeaders(dl_phdr_info * info,
|
||||
symbol.address_begin = reinterpret_cast<const void *>(info->dlpi_addr + elf_sym[sym_index].st_value);
|
||||
symbol.address_end = reinterpret_cast<const void *>(info->dlpi_addr + elf_sym[sym_index].st_value + elf_sym[sym_index].st_size);
|
||||
symbol.name = sym_name;
|
||||
symbols.push_back(std::move(symbol));
|
||||
symbols.push_back(symbol);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -227,7 +227,7 @@ void collectSymbolsFromELFSymbolTable(
|
||||
symbol.address_begin = reinterpret_cast<const void *>(info->dlpi_addr + symbol_table_entry->st_value);
|
||||
symbol.address_end = reinterpret_cast<const void *>(info->dlpi_addr + symbol_table_entry->st_value + symbol_table_entry->st_size);
|
||||
symbol.name = symbol_name;
|
||||
symbols.push_back(std::move(symbol));
|
||||
symbols.push_back(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,11 +257,11 @@ template class ThreadPoolImpl<std::thread>;
|
||||
template class ThreadPoolImpl<ThreadFromGlobalPool>;
|
||||
|
||||
|
||||
void ExceptionHandler::setException(std::exception_ptr && exception)
|
||||
void ExceptionHandler::setException(std::exception_ptr exception)
|
||||
{
|
||||
std::unique_lock lock(mutex);
|
||||
if (!first_exception)
|
||||
first_exception = std::move(exception);
|
||||
first_exception = std::move(exception); // NOLINT
|
||||
}
|
||||
|
||||
void ExceptionHandler::throwIfException()
|
||||
|
@ -221,7 +221,7 @@ using ThreadPool = ThreadPoolImpl<ThreadFromGlobalPool>;
|
||||
class ExceptionHandler
|
||||
{
|
||||
public:
|
||||
void setException(std::exception_ptr && exception);
|
||||
void setException(std::exception_ptr exception);
|
||||
void throwIfException();
|
||||
|
||||
private:
|
||||
|
@ -67,7 +67,7 @@ static void processWatchesImpl(const String & path, TestKeeper::Watches & watche
|
||||
struct TestKeeperCreateRequest final : CreateRequest, TestKeeperRequest
|
||||
{
|
||||
TestKeeperCreateRequest() = default;
|
||||
TestKeeperCreateRequest(const CreateRequest & base) : CreateRequest(base) {}
|
||||
explicit TestKeeperCreateRequest(const CreateRequest & base) : CreateRequest(base) {}
|
||||
ResponsePtr createResponse() const override;
|
||||
ResponsePtr process(TestKeeper::Container & container, int64_t zxid) const override;
|
||||
|
||||
@ -80,7 +80,7 @@ struct TestKeeperCreateRequest final : CreateRequest, TestKeeperRequest
|
||||
struct TestKeeperRemoveRequest final : RemoveRequest, TestKeeperRequest
|
||||
{
|
||||
TestKeeperRemoveRequest() = default;
|
||||
TestKeeperRemoveRequest(const RemoveRequest & base) : RemoveRequest(base) {}
|
||||
explicit TestKeeperRemoveRequest(const RemoveRequest & base) : RemoveRequest(base) {}
|
||||
bool isMutable() const override { return true; }
|
||||
ResponsePtr createResponse() const override;
|
||||
ResponsePtr process(TestKeeper::Container & container, int64_t zxid) const override;
|
||||
@ -107,7 +107,7 @@ struct TestKeeperGetRequest final : GetRequest, TestKeeperRequest
|
||||
struct TestKeeperSetRequest final : SetRequest, TestKeeperRequest
|
||||
{
|
||||
TestKeeperSetRequest() = default;
|
||||
TestKeeperSetRequest(const SetRequest & base) : SetRequest(base) {}
|
||||
explicit TestKeeperSetRequest(const SetRequest & base) : SetRequest(base) {}
|
||||
bool isMutable() const override { return true; }
|
||||
ResponsePtr createResponse() const override;
|
||||
ResponsePtr process(TestKeeper::Container & container, int64_t zxid) const override;
|
||||
@ -127,14 +127,14 @@ struct TestKeeperListRequest final : ListRequest, TestKeeperRequest
|
||||
struct TestKeeperCheckRequest final : CheckRequest, TestKeeperRequest
|
||||
{
|
||||
TestKeeperCheckRequest() = default;
|
||||
TestKeeperCheckRequest(const CheckRequest & base) : CheckRequest(base) {}
|
||||
explicit TestKeeperCheckRequest(const CheckRequest & base) : CheckRequest(base) {}
|
||||
ResponsePtr createResponse() const override;
|
||||
ResponsePtr process(TestKeeper::Container & container, int64_t zxid) const override;
|
||||
};
|
||||
|
||||
struct TestKeeperMultiRequest final : MultiRequest, TestKeeperRequest
|
||||
{
|
||||
TestKeeperMultiRequest(const Requests & generic_requests)
|
||||
explicit TestKeeperMultiRequest(const Requests & generic_requests)
|
||||
{
|
||||
requests.reserve(generic_requests.size());
|
||||
|
||||
|
@ -481,7 +481,7 @@ struct ZooKeeperCloseResponse final : ZooKeeperResponse
|
||||
struct ZooKeeperCreateRequest final : CreateRequest, ZooKeeperRequest
|
||||
{
|
||||
ZooKeeperCreateRequest() = default;
|
||||
ZooKeeperCreateRequest(const CreateRequest & base) : CreateRequest(base) {}
|
||||
explicit ZooKeeperCreateRequest(const CreateRequest & base) : CreateRequest(base) {}
|
||||
|
||||
ZooKeeper::OpNum getOpNum() const override { return 1; }
|
||||
void writeImpl(WriteBuffer & out) const override
|
||||
@ -513,7 +513,7 @@ struct ZooKeeperCreateResponse final : CreateResponse, ZooKeeperResponse
|
||||
struct ZooKeeperRemoveRequest final : RemoveRequest, ZooKeeperRequest
|
||||
{
|
||||
ZooKeeperRemoveRequest() = default;
|
||||
ZooKeeperRemoveRequest(const RemoveRequest & base) : RemoveRequest(base) {}
|
||||
explicit ZooKeeperRemoveRequest(const RemoveRequest & base) : RemoveRequest(base) {}
|
||||
|
||||
ZooKeeper::OpNum getOpNum() const override { return 2; }
|
||||
void writeImpl(WriteBuffer & out) const override
|
||||
@ -571,7 +571,7 @@ struct ZooKeeperGetResponse final : GetResponse, ZooKeeperResponse
|
||||
struct ZooKeeperSetRequest final : SetRequest, ZooKeeperRequest
|
||||
{
|
||||
ZooKeeperSetRequest() = default;
|
||||
ZooKeeperSetRequest(const SetRequest & base) : SetRequest(base) {}
|
||||
explicit ZooKeeperSetRequest(const SetRequest & base) : SetRequest(base) {}
|
||||
|
||||
ZooKeeper::OpNum getOpNum() const override { return 5; }
|
||||
void writeImpl(WriteBuffer & out) const override
|
||||
@ -614,7 +614,7 @@ struct ZooKeeperListResponse final : ListResponse, ZooKeeperResponse
|
||||
struct ZooKeeperCheckRequest final : CheckRequest, ZooKeeperRequest
|
||||
{
|
||||
ZooKeeperCheckRequest() = default;
|
||||
ZooKeeperCheckRequest(const CheckRequest & base) : CheckRequest(base) {}
|
||||
explicit ZooKeeperCheckRequest(const CheckRequest & base) : CheckRequest(base) {}
|
||||
|
||||
ZooKeeper::OpNum getOpNum() const override { return 13; }
|
||||
void writeImpl(WriteBuffer & out) const override
|
||||
@ -710,7 +710,7 @@ struct ZooKeeperMultiRequest final : MultiRequest, ZooKeeperRequest
|
||||
|
||||
struct ZooKeeperMultiResponse final : MultiResponse, ZooKeeperResponse
|
||||
{
|
||||
ZooKeeperMultiResponse(const Requests & requests)
|
||||
explicit ZooKeeperMultiResponse(const Requests & requests)
|
||||
{
|
||||
responses.reserve(requests.size());
|
||||
|
||||
|
@ -24,6 +24,7 @@ try
|
||||
while (true)
|
||||
{
|
||||
std::vector<std::future<Coordination::GetResponse>> futures;
|
||||
futures.reserve(nodes.size());
|
||||
for (auto & node : nodes)
|
||||
futures.push_back(zookeeper.asyncGet("/tmp/" + node));
|
||||
|
||||
|
@ -4,9 +4,6 @@ if(OPENSSL_CRYPTO_LIBRARY)
|
||||
target_link_libraries (hashes_test PRIVATE ${OPENSSL_CRYPTO_LIBRARY})
|
||||
endif()
|
||||
|
||||
add_executable (sip_hash sip_hash.cpp)
|
||||
target_link_libraries (sip_hash PRIVATE clickhouse_common_io)
|
||||
|
||||
add_executable (sip_hash_perf sip_hash_perf.cpp)
|
||||
target_link_libraries (sip_hash_perf PRIVATE clickhouse_common_io)
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
|
||||
#include <pcg_random.hpp>
|
||||
#include <Core/Field.h>
|
||||
#include <Common/HashTable/HashMap.h>
|
||||
#include <Common/AutoArray.h>
|
||||
@ -12,6 +13,8 @@
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
pcg64 rng;
|
||||
|
||||
{
|
||||
size_t n = 10;
|
||||
using T = std::string;
|
||||
@ -63,7 +66,7 @@ int main(int argc, char ** argv)
|
||||
{
|
||||
Arr key(n);
|
||||
for (size_t j = 0; j < n; ++j)
|
||||
key[j] = DB::toString(rand());
|
||||
key[j] = DB::toString(rng());
|
||||
|
||||
map[std::move(key)] = "Hello, world! " + DB::toString(i);
|
||||
}
|
||||
@ -107,7 +110,7 @@ int main(int argc, char ** argv)
|
||||
{
|
||||
Arr key(n);
|
||||
for (size_t j = 0; j < n; ++j)
|
||||
key[j] = DB::toString(rand());
|
||||
key[j] = DB::toString(rng());
|
||||
|
||||
vec.push_back(std::move(key));
|
||||
}
|
||||
@ -152,7 +155,7 @@ int main(int argc, char ** argv)
|
||||
Map::LookupResult it;
|
||||
bool inserted;
|
||||
|
||||
map.emplace(rand(), it, inserted);
|
||||
map.emplace(rng(), it, inserted);
|
||||
if (inserted)
|
||||
{
|
||||
new (&it->getMapped()) Arr(n);
|
||||
|
@ -28,7 +28,7 @@ private:
|
||||
friend class COWHelper<IColumn, ConcreteColumn>;
|
||||
|
||||
int data;
|
||||
ConcreteColumn(int data_) : data(data_) {}
|
||||
explicit ConcreteColumn(int data_) : data(data_) {}
|
||||
ConcreteColumn(const ConcreteColumn &) = default;
|
||||
|
||||
MutableColumnPtr test() const override
|
||||
|
@ -30,7 +30,7 @@ private:
|
||||
friend class COWHelper<IColumn, ConcreteColumn>;
|
||||
|
||||
int data;
|
||||
ConcreteColumn(int data_) : data(data_) {}
|
||||
explicit ConcreteColumn(int data_) : data(data_) {}
|
||||
ConcreteColumn(const ConcreteColumn &) = default;
|
||||
|
||||
public:
|
||||
@ -45,7 +45,7 @@ private:
|
||||
|
||||
ConcreteColumn::WrappedPtr wrapped;
|
||||
|
||||
ColumnComposition(int data) : wrapped(ConcreteColumn::create(data)) {}
|
||||
explicit ColumnComposition(int data) : wrapped(ConcreteColumn::create(data)) {}
|
||||
ColumnComposition(const ColumnComposition &) = default;
|
||||
|
||||
IColumn::MutablePtr deepMutate() const override
|
||||
|
@ -63,7 +63,7 @@ TEST(Common, SensitiveDataMasker)
|
||||
#ifndef NDEBUG
|
||||
// simple benchmark
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
constexpr unsigned long int iterations = 200000;
|
||||
static constexpr size_t iterations = 200000;
|
||||
for (int i = 0; i < iterations; ++i)
|
||||
{
|
||||
std::string query2 = "SELECT id FROM mysql('localhost:3308', 'database', 'table', 'root', 'qwerty123') WHERE ssn='123-45-6789' or "
|
||||
|
@ -273,8 +273,8 @@ static inline void test(size_t n, const UInt64 * data, const char * name)
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
size_t n = (atoi(argv[1]) + (BUF_SIZE - 1)) / BUF_SIZE * BUF_SIZE;
|
||||
size_t method = argc <= 2 ? 0 : atoi(argv[2]);
|
||||
size_t n = (std::stol(argv[1]) + (BUF_SIZE - 1)) / BUF_SIZE * BUF_SIZE;
|
||||
size_t method = argc <= 2 ? 0 : std::stol(argv[2]);
|
||||
|
||||
std::cerr << std::fixed << std::setprecision(2);
|
||||
|
||||
|
@ -343,8 +343,8 @@ int main(int argc, char ** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t n = atoi(argv[1]);
|
||||
// size_t m = atoi(argv[2]);
|
||||
size_t n = std::stol(argv[1]);
|
||||
// size_t m = std::stol(argv[2]);
|
||||
|
||||
std::cerr << std::fixed << std::setprecision(3);
|
||||
|
||||
|
@ -246,9 +246,9 @@ void aggregate5(Map & local_map, MapSmallLocks & global_map, Source::const_itera
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
size_t n = atoi(argv[1]);
|
||||
size_t num_threads = atoi(argv[2]);
|
||||
size_t method = argc <= 3 ? 0 : atoi(argv[3]);
|
||||
size_t n = std::stol(argv[1]);
|
||||
size_t num_threads = std::stol(argv[2]);
|
||||
size_t method = argc <= 3 ? 0 : std::stol(argv[3]);
|
||||
|
||||
std::cerr << std::fixed << std::setprecision(2);
|
||||
|
||||
|
@ -285,9 +285,9 @@ struct Merger
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
size_t n = atoi(argv[1]);
|
||||
size_t num_threads = atoi(argv[2]);
|
||||
size_t method = argc <= 3 ? 0 : atoi(argv[3]);
|
||||
size_t n = std::stol(argv[1]);
|
||||
size_t num_threads = std::stol(argv[2]);
|
||||
size_t method = argc <= 3 ? 0 : std::stol(argv[3]);
|
||||
|
||||
std::cerr << std::fixed << std::setprecision(2);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#if !defined(__APPLE__) && !defined(__FreeBSD__)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <pcg_random.hpp>
|
||||
#include <ext/bit_cast.h>
|
||||
#include <Common/RadixSort.h>
|
||||
#include <Common/Stopwatch.h>
|
||||
@ -31,6 +32,8 @@ static void NO_INLINE sort3(Key * data, size_t size)
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
pcg64 rng;
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
std::cerr << "Usage: program n method\n";
|
||||
@ -48,7 +51,7 @@ int main(int argc, char ** argv)
|
||||
Stopwatch watch;
|
||||
|
||||
for (auto & elem : data)
|
||||
elem = rand();
|
||||
elem = rng();
|
||||
|
||||
watch.stop();
|
||||
double elapsed = watch.elapsedSeconds();
|
||||
|
@ -1,154 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
#include <Common/SipHash.h>
|
||||
|
||||
/// Adapted version https://www.131002.net/siphash/siphash24.c
|
||||
|
||||
/*
|
||||
SipHash-2-4 output with
|
||||
k = 00 01 02 ...
|
||||
and
|
||||
in = (empty string)
|
||||
in = 00 (1 byte)
|
||||
in = 00 01 (2 bytes)
|
||||
in = 00 01 02 (3 bytes)
|
||||
...
|
||||
in = 00 01 02 ... 3e (63 bytes)
|
||||
*/
|
||||
uint8_t vectors[64][8] =
|
||||
{
|
||||
{ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, },
|
||||
{ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, },
|
||||
{ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, },
|
||||
{ 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85, },
|
||||
{ 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf, },
|
||||
{ 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18, },
|
||||
{ 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb, },
|
||||
{ 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab, },
|
||||
{ 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93, },
|
||||
{ 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e, },
|
||||
{ 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a, },
|
||||
{ 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4, },
|
||||
{ 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75, },
|
||||
{ 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14, },
|
||||
{ 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7, },
|
||||
{ 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1, },
|
||||
{ 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f, },
|
||||
{ 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69, },
|
||||
{ 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b, },
|
||||
{ 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb, },
|
||||
{ 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe, },
|
||||
{ 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0, },
|
||||
{ 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93, },
|
||||
{ 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8, },
|
||||
{ 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8, },
|
||||
{ 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc, },
|
||||
{ 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17, },
|
||||
{ 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f, },
|
||||
{ 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde, },
|
||||
{ 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6, },
|
||||
{ 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad, },
|
||||
{ 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32, },
|
||||
{ 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71, },
|
||||
{ 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7, },
|
||||
{ 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12, },
|
||||
{ 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15, },
|
||||
{ 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31, },
|
||||
{ 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02, },
|
||||
{ 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca, },
|
||||
{ 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a, },
|
||||
{ 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e, },
|
||||
{ 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad, },
|
||||
{ 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18, },
|
||||
{ 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4, },
|
||||
{ 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9, },
|
||||
{ 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9, },
|
||||
{ 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb, },
|
||||
{ 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0, },
|
||||
{ 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6, },
|
||||
{ 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7, },
|
||||
{ 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee, },
|
||||
{ 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1, },
|
||||
{ 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a, },
|
||||
{ 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81, },
|
||||
{ 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f, },
|
||||
{ 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24, },
|
||||
{ 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7, },
|
||||
{ 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea, },
|
||||
{ 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60, },
|
||||
{ 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66, },
|
||||
{ 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c, },
|
||||
{ 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f, },
|
||||
{ 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5, },
|
||||
{ 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, }
|
||||
};
|
||||
|
||||
|
||||
static int test_vectors()
|
||||
{
|
||||
#define MAXLEN 64
|
||||
char in[MAXLEN];
|
||||
|
||||
union
|
||||
{
|
||||
char out[16];
|
||||
uint64_t out64[2];
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
char k[16];
|
||||
uint64_t k64[2];
|
||||
};
|
||||
|
||||
int i;
|
||||
int ok = 1;
|
||||
|
||||
for (i = 0; i < 16; ++i)
|
||||
k[i] = i;
|
||||
|
||||
for (i = 0; i < MAXLEN; ++i)
|
||||
{
|
||||
in[i] = i;
|
||||
|
||||
size_t part = i == 0 ? 0 : (rand() % i);
|
||||
|
||||
SipHash hash(k64[0], k64[1]);
|
||||
|
||||
hash.update(in, part);
|
||||
hash.update(in + part, i - part);
|
||||
|
||||
hash.get128(out);
|
||||
|
||||
uint64_t test_vector;
|
||||
memcpy(&test_vector, vectors[i], 8);
|
||||
|
||||
if ((out64[0] ^ out64[1]) != test_vector)
|
||||
{
|
||||
std::cerr << "test vector failed for " << i << " bytes" << std::endl;
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
int main(int, char **)
|
||||
{
|
||||
size_t n = 100000;
|
||||
|
||||
size_t i = 0;
|
||||
for (; i < n; ++i)
|
||||
if (!test_vectors())
|
||||
break;
|
||||
|
||||
if (i == n)
|
||||
std::cerr << "test vectors ok" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
@ -98,7 +98,7 @@ void CompressionCodecMultiple::doDecompressData(const char * source, UInt32 sour
|
||||
/// Insert all data into compressed buf
|
||||
source_size -= (compression_methods_size + 1);
|
||||
|
||||
for (long idx = compression_methods_size - 1; idx >= 0; --idx)
|
||||
for (int idx = compression_methods_size - 1; idx >= 0; --idx)
|
||||
{
|
||||
UInt8 compression_method = source[idx + 1];
|
||||
const auto codec = CompressionCodecFactory::instance().get(compression_method);
|
||||
|
@ -95,7 +95,7 @@ std::string bin(const T & value, size_t bits = sizeof(T)*8)
|
||||
static const uint8_t MAX_BITS = sizeof(T)*8;
|
||||
assert(bits <= MAX_BITS);
|
||||
|
||||
return std::bitset<sizeof(T) * 8>(static_cast<unsigned long long>(value))
|
||||
return std::bitset<sizeof(T) * 8>(static_cast<uint64_t>(value))
|
||||
.to_string().substr(MAX_BITS - bits, bits);
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator bool() const
|
||||
explicit operator bool() const
|
||||
{
|
||||
return ItemsLeft() > 0;
|
||||
}
|
||||
@ -706,9 +706,9 @@ typename std::conditional_t<std::is_floating_point_v<T>, std::uniform_real_distr
|
||||
|
||||
|
||||
template <typename T = Int32>
|
||||
struct MonotonicGenerator
|
||||
struct MonotonicGenerator // NOLINT
|
||||
{
|
||||
MonotonicGenerator(T stride_ = 1, T max_step = 10)
|
||||
explicit MonotonicGenerator(T stride_ = 1, T max_step = 10) // NOLINT
|
||||
: prev_value(0),
|
||||
stride(stride_),
|
||||
random_engine(0),
|
||||
@ -732,7 +732,7 @@ private:
|
||||
template <typename T>
|
||||
struct RandomGenerator
|
||||
{
|
||||
RandomGenerator(T seed = 0, T value_min = std::numeric_limits<T>::min(), T value_max = std::numeric_limits<T>::max())
|
||||
explicit RandomGenerator(T seed = 0, T value_min = std::numeric_limits<T>::min(), T value_max = std::numeric_limits<T>::max())
|
||||
: random_engine(seed),
|
||||
distribution(value_min, value_max)
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ int main(int argc, char ** argv)
|
||||
std::ofstream devnull("/dev/null");
|
||||
|
||||
DB::ReadBufferFromFileDescriptor in(STDIN_FILENO);
|
||||
size_t n = atoi(argv[1]);
|
||||
size_t n = std::stol(argv[1]);
|
||||
size_t elems_show = 1;
|
||||
|
||||
using Vec = std::vector<std::string>;
|
||||
|
@ -54,7 +54,7 @@ static void mixNumberColumns(
|
||||
const ColumnPtr & col_defaults,
|
||||
const BlockMissingValues::RowsBitMask & defaults_mask)
|
||||
{
|
||||
auto call = [&](const auto & types) -> bool
|
||||
auto call = [&](const auto & types)
|
||||
{
|
||||
using Types = std::decay_t<decltype(types)>;
|
||||
using DataType = typename Types::LeftType;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <pcg_random.hpp>
|
||||
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <Columns/ColumnsNumber.h>
|
||||
@ -11,6 +12,7 @@
|
||||
|
||||
#include <Interpreters/sortBlock.h>
|
||||
|
||||
|
||||
using namespace DB;
|
||||
|
||||
namespace DB
|
||||
@ -24,12 +26,12 @@ namespace DB
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
srand(123456);
|
||||
pcg64 rng;
|
||||
|
||||
try
|
||||
{
|
||||
size_t m = argc >= 2 ? atoi(argv[1]) : 2;
|
||||
size_t n = argc >= 3 ? atoi(argv[2]) : 10;
|
||||
size_t m = argc >= 2 ? std::stol(argv[1]) : 2;
|
||||
size_t n = argc >= 3 ? std::stol(argv[2]) : 10;
|
||||
|
||||
Blocks blocks;
|
||||
for (size_t t = 0; t < m; ++t)
|
||||
@ -46,7 +48,7 @@ int main(int argc, char ** argv)
|
||||
vec.resize(n);
|
||||
|
||||
for (size_t j = 0; j < n; ++j)
|
||||
vec[j] = rand() % 10;
|
||||
vec[j] = rng() % 10;
|
||||
|
||||
column.column = std::move(col);
|
||||
block.insert(column);
|
||||
|
@ -77,7 +77,7 @@ struct KeysSerializationVersion
|
||||
throw Exception("Invalid version for DataTypeLowCardinality key column.", ErrorCodes::LOGICAL_ERROR);
|
||||
}
|
||||
|
||||
KeysSerializationVersion(UInt64 version) : value(static_cast<Value>(version)) { checkVersion(version); }
|
||||
explicit KeysSerializationVersion(UInt64 version) : value(static_cast<Value>(version)) { checkVersion(version); }
|
||||
};
|
||||
|
||||
/// Version is stored at the start of each granule. It's used to store indexes type and flags.
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
const Context & context,
|
||||
const String & table_name) const override;
|
||||
|
||||
DatabaseTablesIteratorPtr getTablesIterator(const Context & context, const FilterByNameFunction & filter_by_table_name = {}) override;
|
||||
DatabaseTablesIteratorPtr getTablesIterator(const Context & context, const FilterByNameFunction & filter_by_table_name) override;
|
||||
|
||||
bool empty(const Context & context) const override;
|
||||
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
|
||||
bool empty(const Context & context) const override;
|
||||
|
||||
DatabaseTablesIteratorPtr getTablesIterator(const Context & context, const FilterByNameFunction & filter_by_table_name = {}) override;
|
||||
DatabaseTablesIteratorPtr getTablesIterator(const Context & context, const FilterByNameFunction & filter_by_table_name) override;
|
||||
|
||||
void attachTable(const String & table_name, const StoragePtr & table) override;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
|
||||
bool empty(const Context & context) const override;
|
||||
|
||||
DatabaseTablesIteratorPtr getTablesIterator(const Context & context, const FilterByNameFunction & filter_by_table_name = {}) override;
|
||||
DatabaseTablesIteratorPtr getTablesIterator(const Context & context, const FilterByNameFunction & filter_by_table_name) override;
|
||||
|
||||
ASTPtr getCreateDatabaseQuery(const Context & /*context*/) const override;
|
||||
|
||||
|
@ -20,9 +20,9 @@ public:
|
||||
|
||||
StoragePtr tryGetTable(const Context & context, const String & table_name) const override;
|
||||
|
||||
DatabaseTablesIteratorPtr getTablesWithDictionaryTablesIterator(const Context & context, const FilterByNameFunction & filter_by_dictionary_name = {}) override;
|
||||
DatabaseTablesIteratorPtr getTablesWithDictionaryTablesIterator(const Context & context, const FilterByNameFunction & filter_by_dictionary_name) override;
|
||||
|
||||
DatabaseDictionariesIteratorPtr getDictionariesIterator(const Context & context, const FilterByNameFunction & filter_by_dictionary_name = {}) override;
|
||||
DatabaseDictionariesIteratorPtr getDictionariesIterator(const Context & context, const FilterByNameFunction & filter_by_dictionary_name) override;
|
||||
|
||||
bool isDictionaryExist(const Context & context, const String & dictionary_name) const override;
|
||||
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
|
||||
StoragePtr detachTable(const String & table_name) override;
|
||||
|
||||
DatabaseTablesIteratorPtr getTablesIterator(const Context & context, const FilterByNameFunction & filter_by_table_name = {}) override;
|
||||
DatabaseTablesIteratorPtr getTablesIterator(const Context & context, const FilterByNameFunction & filter_by_table_name) override;
|
||||
|
||||
void shutdown() override;
|
||||
|
||||
|
@ -50,9 +50,9 @@ namespace DB
|
||||
using ValueType = ExternalResultDescription::ValueType;
|
||||
|
||||
template <typename T>
|
||||
inline void insert(IColumn & column, const String & stringValue)
|
||||
inline void insert(IColumn & column, const String & string_value)
|
||||
{
|
||||
assert_cast<ColumnVector<T> &>(column).insertValue(parse<T>(stringValue));
|
||||
assert_cast<ColumnVector<T> &>(column).insertValue(parse<T>(string_value));
|
||||
}
|
||||
|
||||
void insertValue(IColumn & column, const ValueType type, const Poco::Redis::BulkString & bulk_string)
|
||||
@ -60,50 +60,50 @@ namespace DB
|
||||
if (bulk_string.isNull())
|
||||
throw Exception{"Type mismatch, expected not Null String", ErrorCodes::TYPE_MISMATCH};
|
||||
|
||||
String stringValue = bulk_string.value();
|
||||
const String & string_value = bulk_string.value();
|
||||
switch (type)
|
||||
{
|
||||
case ValueType::vtUInt8:
|
||||
insert<UInt8>(column, stringValue);
|
||||
insert<UInt8>(column, string_value);
|
||||
break;
|
||||
case ValueType::vtUInt16:
|
||||
insert<UInt16>(column, stringValue);
|
||||
insert<UInt16>(column, string_value);
|
||||
break;
|
||||
case ValueType::vtUInt32:
|
||||
insert<UInt32>(column, stringValue);
|
||||
insert<UInt32>(column, string_value);
|
||||
break;
|
||||
case ValueType::vtUInt64:
|
||||
insert<UInt64>(column, stringValue);
|
||||
insert<UInt64>(column, string_value);
|
||||
break;
|
||||
case ValueType::vtInt8:
|
||||
insert<Int8>(column, stringValue);
|
||||
insert<Int8>(column, string_value);
|
||||
break;
|
||||
case ValueType::vtInt16:
|
||||
insert<Int16>(column, stringValue);
|
||||
insert<Int16>(column, string_value);
|
||||
break;
|
||||
case ValueType::vtInt32:
|
||||
insert<Int32>(column, stringValue);
|
||||
insert<Int32>(column, string_value);
|
||||
break;
|
||||
case ValueType::vtInt64:
|
||||
insert<Int64>(column, stringValue);
|
||||
insert<Int64>(column, string_value);
|
||||
break;
|
||||
case ValueType::vtFloat32:
|
||||
insert<Float32>(column, stringValue);
|
||||
insert<Float32>(column, string_value);
|
||||
break;
|
||||
case ValueType::vtFloat64:
|
||||
insert<Float64>(column, stringValue);
|
||||
insert<Float64>(column, string_value);
|
||||
break;
|
||||
case ValueType::vtString:
|
||||
assert_cast<ColumnString &>(column).insert(parse<String>(stringValue));
|
||||
assert_cast<ColumnString &>(column).insert(parse<String>(string_value));
|
||||
break;
|
||||
case ValueType::vtDate:
|
||||
assert_cast<ColumnUInt16 &>(column).insertValue(parse<LocalDate>(stringValue).getDayNum());
|
||||
assert_cast<ColumnUInt16 &>(column).insertValue(parse<LocalDate>(string_value).getDayNum());
|
||||
break;
|
||||
case ValueType::vtDateTime:
|
||||
assert_cast<ColumnUInt32 &>(column).insertValue(static_cast<UInt32>(parse<LocalDateTime>(stringValue)));
|
||||
assert_cast<ColumnUInt32 &>(column).insertValue(static_cast<UInt32>(parse<LocalDateTime>(string_value)));
|
||||
break;
|
||||
case ValueType::vtUUID:
|
||||
assert_cast<ColumnUInt128 &>(column).insertValue(parse<UUID>(stringValue));
|
||||
assert_cast<ColumnUInt128 &>(column).insertValue(parse<UUID>(string_value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -71,17 +71,17 @@ public:
|
||||
|
||||
std::unique_ptr<ReadBufferFromFileBase> readFile(
|
||||
const String & path,
|
||||
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
|
||||
size_t estimated_size = 0,
|
||||
size_t aio_threshold = 0,
|
||||
size_t mmap_threshold = 0) const override;
|
||||
size_t buf_size,
|
||||
size_t estimated_size,
|
||||
size_t aio_threshold,
|
||||
size_t mmap_threshold) const override;
|
||||
|
||||
std::unique_ptr<WriteBufferFromFileBase> writeFile(
|
||||
const String & path,
|
||||
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
|
||||
WriteMode mode = WriteMode::Rewrite,
|
||||
size_t estimated_size = 0,
|
||||
size_t aio_threshold = 0) override;
|
||||
size_t buf_size,
|
||||
WriteMode mode,
|
||||
size_t estimated_size,
|
||||
size_t aio_threshold) override;
|
||||
|
||||
void remove(const String & path) override;
|
||||
|
||||
|
@ -64,17 +64,17 @@ public:
|
||||
|
||||
std::unique_ptr<ReadBufferFromFileBase> readFile(
|
||||
const String & path,
|
||||
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
|
||||
size_t estimated_size = 0,
|
||||
size_t aio_threshold = 0,
|
||||
size_t mmap_threshold = 0) const override;
|
||||
size_t buf_size,
|
||||
size_t estimated_size,
|
||||
size_t aio_threshold,
|
||||
size_t mmap_threshold) const override;
|
||||
|
||||
std::unique_ptr<WriteBufferFromFileBase> writeFile(
|
||||
const String & path,
|
||||
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
|
||||
WriteMode mode = WriteMode::Rewrite,
|
||||
size_t estimated_size = 0,
|
||||
size_t aio_threshold = 0) override;
|
||||
size_t buf_size,
|
||||
WriteMode mode,
|
||||
size_t estimated_size,
|
||||
size_t aio_threshold) override;
|
||||
|
||||
void remove(const String & path) override;
|
||||
|
||||
|
@ -648,24 +648,29 @@ DiskS3Reservation::~DiskS3Reservation()
|
||||
}
|
||||
}
|
||||
|
||||
inline void checkWriteAccess(std::shared_ptr<DiskS3> & disk)
|
||||
namespace
|
||||
{
|
||||
auto file = disk->writeFile("test_acl", DBMS_DEFAULT_BUFFER_SIZE, WriteMode::Rewrite);
|
||||
|
||||
void checkWriteAccess(IDisk & disk)
|
||||
{
|
||||
auto file = disk.writeFile("test_acl", DBMS_DEFAULT_BUFFER_SIZE, WriteMode::Rewrite);
|
||||
file->write("test", 4);
|
||||
}
|
||||
|
||||
inline void checkReadAccess(const String & disk_name, std::shared_ptr<DiskS3> & disk)
|
||||
void checkReadAccess(const String & disk_name, IDisk & disk)
|
||||
{
|
||||
auto file = disk->readFile("test_acl", DBMS_DEFAULT_BUFFER_SIZE);
|
||||
auto file = disk.readFile("test_acl", DBMS_DEFAULT_BUFFER_SIZE);
|
||||
String buf(4, '0');
|
||||
file->readStrict(buf.data(), 4);
|
||||
if (buf != "test")
|
||||
throw Exception("No read access to S3 bucket in disk " + disk_name, ErrorCodes::PATH_ACCESS_DENIED);
|
||||
}
|
||||
|
||||
inline void checkRemoveAccess(std::shared_ptr<DiskS3> & disk)
|
||||
void checkRemoveAccess(IDisk & disk)
|
||||
{
|
||||
disk->remove("test_acl");
|
||||
disk.remove("test_acl");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void registerDiskS3(DiskFactory & factory)
|
||||
@ -692,9 +697,9 @@ void registerDiskS3(DiskFactory & factory)
|
||||
= std::make_shared<DiskS3>(name, client, uri.bucket, uri.key, metadata_path, context.getSettingsRef().s3_min_upload_part_size);
|
||||
|
||||
/// This code is used only to check access to the corresponding disk.
|
||||
checkWriteAccess(s3disk);
|
||||
checkReadAccess(name, s3disk);
|
||||
checkRemoveAccess(s3disk);
|
||||
checkWriteAccess(*s3disk);
|
||||
checkReadAccess(name, *s3disk);
|
||||
checkRemoveAccess(*s3disk);
|
||||
|
||||
return s3disk;
|
||||
};
|
||||
|
@ -71,17 +71,17 @@ public:
|
||||
|
||||
std::unique_ptr<ReadBufferFromFileBase> readFile(
|
||||
const String & path,
|
||||
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
|
||||
size_t estimated_size = 0,
|
||||
size_t aio_threshold = 0,
|
||||
size_t mmap_threshold = 0) const override;
|
||||
size_t buf_size,
|
||||
size_t estimated_size,
|
||||
size_t aio_threshold,
|
||||
size_t mmap_threshold) const override;
|
||||
|
||||
std::unique_ptr<WriteBufferFromFileBase> writeFile(
|
||||
const String & path,
|
||||
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
|
||||
WriteMode mode = WriteMode::Rewrite,
|
||||
size_t estimated_size = 0,
|
||||
size_t aio_threshold = 0) override;
|
||||
size_t buf_size,
|
||||
WriteMode mode,
|
||||
size_t estimated_size,
|
||||
size_t aio_threshold) override;
|
||||
|
||||
void remove(const String & path) override;
|
||||
|
||||
|
@ -24,7 +24,7 @@ ProtobufSchemas & ProtobufSchemas::instance()
|
||||
class ProtobufSchemas::ImporterWithSourceTree : public google::protobuf::compiler::MultiFileErrorCollector
|
||||
{
|
||||
public:
|
||||
ImporterWithSourceTree(const String & schema_directory) : importer(&disk_source_tree, this)
|
||||
explicit ImporterWithSourceTree(const String & schema_directory) : importer(&disk_source_tree, this)
|
||||
{
|
||||
disk_source_tree.MapPath("", schema_directory);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ template <class T>
|
||||
struct CRCBase
|
||||
{
|
||||
T tab[256];
|
||||
CRCBase(T polynomial)
|
||||
explicit CRCBase(T polynomial)
|
||||
{
|
||||
for (size_t i = 0; i < 256; ++i)
|
||||
{
|
||||
|
@ -167,7 +167,7 @@ void validateFunctionArgumentTypes(const IFunction & func,
|
||||
{
|
||||
if (arguments.size() < mandatory_args.size() || arguments.size() > mandatory_args.size() + optional_args.size())
|
||||
{
|
||||
auto joinArgumentTypes = [](const auto & args, const String sep = ", ") -> String
|
||||
auto joinArgumentTypes = [](const auto & args, const String sep = ", ")
|
||||
{
|
||||
String result;
|
||||
for (const auto & a : args)
|
||||
|
@ -152,7 +152,7 @@ class AssociativeApplierImpl
|
||||
|
||||
public:
|
||||
/// Remembers the last N columns from `in`.
|
||||
AssociativeApplierImpl(const UInt8ColumnPtrs & in)
|
||||
explicit AssociativeApplierImpl(const UInt8ColumnPtrs & in)
|
||||
: vec(in[in.size() - N]->getData()), next(in) {}
|
||||
|
||||
/// Returns a combination of values in the i-th row of all columns stored in the constructor.
|
||||
@ -176,7 +176,7 @@ class AssociativeApplierImpl<Op, 1>
|
||||
using ResultValueType = typename Op::ResultType;
|
||||
|
||||
public:
|
||||
AssociativeApplierImpl(const UInt8ColumnPtrs & in)
|
||||
explicit AssociativeApplierImpl(const UInt8ColumnPtrs & in)
|
||||
: vec(in[in.size() - 1]->getData()) {}
|
||||
|
||||
inline ResultValueType apply(const size_t i) const { return vec[i]; }
|
||||
@ -239,7 +239,7 @@ class AssociativeGenericApplierImpl
|
||||
|
||||
public:
|
||||
/// Remembers the last N columns from `in`.
|
||||
AssociativeGenericApplierImpl(const ColumnRawPtrs & in)
|
||||
explicit AssociativeGenericApplierImpl(const ColumnRawPtrs & in)
|
||||
: val_getter{ValueGetterBuilder::build(in[in.size() - N])}, next{in} {}
|
||||
|
||||
/// Returns a combination of values in the i-th row of all columns stored in the constructor.
|
||||
@ -265,7 +265,7 @@ class AssociativeGenericApplierImpl<Op, 1>
|
||||
|
||||
public:
|
||||
/// Remembers the last N columns from `in`.
|
||||
AssociativeGenericApplierImpl(const ColumnRawPtrs & in)
|
||||
explicit AssociativeGenericApplierImpl(const ColumnRawPtrs & in)
|
||||
: val_getter{ValueGetterBuilder::build(in[in.size() - 1])} {}
|
||||
|
||||
inline ResultValueType apply(const size_t i) const { return val_getter(i); }
|
||||
|
@ -306,8 +306,8 @@ struct MultiMatchAnyImpl
|
||||
MultiRegexps::ScratchPtr smart_scratch(scratch);
|
||||
|
||||
auto on_match = []([[maybe_unused]] unsigned int id,
|
||||
unsigned long long /* from */,
|
||||
unsigned long long /* to */,
|
||||
unsigned long long /* from */, // NOLINT
|
||||
unsigned long long /* to */, // NOLINT
|
||||
unsigned int /* flags */,
|
||||
void * context) -> int
|
||||
{
|
||||
@ -407,8 +407,8 @@ struct MultiMatchAllIndicesImpl
|
||||
MultiRegexps::ScratchPtr smart_scratch(scratch);
|
||||
|
||||
auto on_match = [](unsigned int id,
|
||||
unsigned long long /* from */,
|
||||
unsigned long long /* to */,
|
||||
unsigned long long /* from */, // NOLINT
|
||||
unsigned long long /* to */, // NOLINT
|
||||
unsigned int /* flags */,
|
||||
void * context) -> int
|
||||
{
|
||||
|
@ -319,9 +319,9 @@ UInt64 geohashesInBox(const GeohashesInBoxPreparedArgs & args, char * out)
|
||||
}
|
||||
|
||||
UInt64 items = 0;
|
||||
for (auto lon = args.longitude_min; lon < args.longitude_max; lon += args.longitude_step)
|
||||
for (auto lon = args.longitude_min; lon < args.longitude_max; lon += args.longitude_step) // NOLINT
|
||||
{
|
||||
for (auto lat = args.latitude_min; lat < args.latitude_max; lat += args.latitude_step)
|
||||
for (auto lat = args.latitude_min; lat < args.latitude_max; lat += args.latitude_step) // NOLINT
|
||||
{
|
||||
assert(items <= args.items_count);
|
||||
|
||||
|
@ -19,7 +19,7 @@ public:
|
||||
return std::make_shared<FunctionArray>(context);
|
||||
}
|
||||
|
||||
FunctionArray(const Context & context_)
|
||||
explicit FunctionArray(const Context & context_)
|
||||
: context(context_)
|
||||
{
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class FunctionArrayConcat : public IFunction
|
||||
public:
|
||||
static constexpr auto name = "arrayConcat";
|
||||
static FunctionPtr create(const Context & context) { return std::make_shared<FunctionArrayConcat>(context); }
|
||||
FunctionArrayConcat(const Context & context_) : context(context_) {}
|
||||
explicit FunctionArrayConcat(const Context & context_) : context(context_) {}
|
||||
|
||||
String getName() const override { return name; }
|
||||
|
||||
|
@ -95,7 +95,7 @@ namespace ArrayImpl
|
||||
class NullMapBuilder
|
||||
{
|
||||
public:
|
||||
operator bool() const { return src_null_map; }
|
||||
explicit operator bool() const { return src_null_map; }
|
||||
bool operator!() const { return !src_null_map; }
|
||||
|
||||
void initSource(const UInt8 * src_null_map_)
|
||||
|
@ -39,7 +39,7 @@ class FunctionArrayIntersect : public IFunction
|
||||
public:
|
||||
static constexpr auto name = "arrayIntersect";
|
||||
static FunctionPtr create(const Context & context) { return std::make_shared<FunctionArrayIntersect>(context); }
|
||||
FunctionArrayIntersect(const Context & context_) : context(context_) {}
|
||||
explicit FunctionArrayIntersect(const Context & context_) : context(context_) {}
|
||||
|
||||
String getName() const override { return name; }
|
||||
|
||||
|
@ -10,7 +10,7 @@ class FunctionArrayPushBack : public FunctionArrayPush
|
||||
public:
|
||||
static constexpr auto name = "arrayPushBack";
|
||||
static FunctionPtr create(const Context & context) { return std::make_shared<FunctionArrayPushBack>(context); }
|
||||
FunctionArrayPushBack(const Context & context_) : FunctionArrayPush(context_, false, name) {}
|
||||
explicit FunctionArrayPushBack(const Context & context_) : FunctionArrayPush(context_, false, name) {}
|
||||
};
|
||||
|
||||
void registerFunctionArrayPushBack(FunctionFactory & factory)
|
||||
|
@ -11,7 +11,7 @@ class FunctionArrayPushFront : public FunctionArrayPush
|
||||
public:
|
||||
static constexpr auto name = "arrayPushFront";
|
||||
static FunctionPtr create(const Context & context) { return std::make_shared<FunctionArrayPushFront>(context); }
|
||||
FunctionArrayPushFront(const Context & context_) : FunctionArrayPush(context_, true, name) {}
|
||||
explicit FunctionArrayPushFront(const Context & context_) : FunctionArrayPush(context_, true, name) {}
|
||||
};
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ class FunctionArrayResize : public IFunction
|
||||
public:
|
||||
static constexpr auto name = "arrayResize";
|
||||
static FunctionPtr create(const Context & context) { return std::make_shared<FunctionArrayResize>(context); }
|
||||
FunctionArrayResize(const Context & context_) : context(context_) {}
|
||||
explicit FunctionArrayResize(const Context & context_) : context(context_) {}
|
||||
|
||||
String getName() const override { return name; }
|
||||
|
||||
|
@ -23,7 +23,7 @@ struct ArraySortImpl
|
||||
{
|
||||
const IColumn & column;
|
||||
|
||||
Less(const IColumn & column_) : column(column_) {}
|
||||
explicit Less(const IColumn & column_) : column(column_) {}
|
||||
|
||||
bool operator()(size_t lhs, size_t rhs) const
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ class FunctionArrayHasAll : public FunctionArrayHasAllAny
|
||||
public:
|
||||
static constexpr auto name = "hasAll";
|
||||
static FunctionPtr create(const Context & context) { return std::make_shared<FunctionArrayHasAll>(context); }
|
||||
FunctionArrayHasAll(const Context & context_) : FunctionArrayHasAllAny(context_, true, name) {}
|
||||
explicit FunctionArrayHasAll(const Context & context_) : FunctionArrayHasAllAny(context_, true, name) {}
|
||||
};
|
||||
|
||||
void registerFunctionHasAll(FunctionFactory & factory)
|
||||
|
@ -10,7 +10,7 @@ class FunctionArrayHasAny : public FunctionArrayHasAllAny
|
||||
public:
|
||||
static constexpr auto name = "hasAny";
|
||||
static FunctionPtr create(const Context & context) { return std::make_shared<FunctionArrayHasAny>(context); }
|
||||
FunctionArrayHasAny(const Context & context_) : FunctionArrayHasAllAny(context_, false, name) {}
|
||||
explicit FunctionArrayHasAny(const Context & context_) : FunctionArrayHasAllAny(context_, false, name) {}
|
||||
};
|
||||
|
||||
void registerFunctionHasAny(FunctionFactory & factory)
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
static constexpr auto name = "range";
|
||||
static constexpr size_t max_elements = 100'000'000;
|
||||
static FunctionPtr create(const Context & context_) { return std::make_shared<FunctionRange>(context_); }
|
||||
FunctionRange(const Context & context_) : context(context_) {}
|
||||
explicit FunctionRange(const Context & context_) : context(context_) {}
|
||||
|
||||
private:
|
||||
const Context & context;
|
||||
|
@ -26,7 +26,7 @@ struct BitCountImpl
|
||||
if constexpr (std::is_same_v<A, Int8>)
|
||||
return __builtin_popcount(static_cast<UInt8>(a));
|
||||
else
|
||||
return __builtin_popcountll(ext::bit_cast<unsigned long long>(a));
|
||||
return __builtin_popcountll(ext::bit_cast<uint64_t>(a));
|
||||
}
|
||||
|
||||
#if USE_EMBEDDED_COMPILER
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
static FunctionPtr create(const Context & context_) { return std::make_shared<FunctionCaseWithExpression>(context_); }
|
||||
|
||||
public:
|
||||
FunctionCaseWithExpression(const Context & context_) : context(context_) {}
|
||||
explicit FunctionCaseWithExpression(const Context & context_) : context(context_) {}
|
||||
bool isVariadic() const override { return true; }
|
||||
size_t getNumberOfArguments() const override { return 0; }
|
||||
String getName() const override { return name; }
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
return std::make_shared<FunctionCoalesce>(context);
|
||||
}
|
||||
|
||||
FunctionCoalesce(const Context & context_) : context(context_) {}
|
||||
explicit FunctionCoalesce(const Context & context_) : context(context_) {}
|
||||
|
||||
std::string getName() const override
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ class ConcatImpl : public IFunction
|
||||
{
|
||||
public:
|
||||
static constexpr auto name = Name::name;
|
||||
ConcatImpl(const Context & context_) : context(context_) {}
|
||||
explicit ConcatImpl(const Context & context_) : context(context_) {}
|
||||
static FunctionPtr create(const Context & context) { return std::make_shared<ConcatImpl>(context); }
|
||||
|
||||
String getName() const override { return name; }
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
{
|
||||
return std::make_shared<FunctionEvalMLMethod>(context);
|
||||
}
|
||||
FunctionEvalMLMethod(const Context & context_) : context(context_)
|
||||
explicit FunctionEvalMLMethod(const Context & context_) : context(context_)
|
||||
{}
|
||||
|
||||
String getName() const override
|
||||
|
@ -93,7 +93,7 @@ private:
|
||||
Func func;
|
||||
size_t shift;
|
||||
|
||||
Action(Func func_, size_t shift_ = 0) : func(func_), shift(shift_) {}
|
||||
explicit Action(Func func_, size_t shift_ = 0) : func(func_), shift(shift_) {}
|
||||
|
||||
void perform(char *& target, Time source, const DateLUTImpl & timezone)
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
return std::make_shared<FunctionGetMacro>(context.getMacros());
|
||||
}
|
||||
|
||||
FunctionGetMacro(MultiVersion<Macros>::Version macros_) : macros(std::move(macros_)) {}
|
||||
explicit FunctionGetMacro(MultiVersion<Macros>::Version macros_) : macros(std::move(macros_)) {}
|
||||
|
||||
String getName() const override
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
return std::make_shared<FunctionGetScalar>(context);
|
||||
}
|
||||
|
||||
FunctionGetScalar(const Context & context_) : context(context_) {}
|
||||
explicit FunctionGetScalar(const Context & context_) : context(context_) {}
|
||||
|
||||
String getName() const override
|
||||
{
|
||||
|
@ -173,7 +173,7 @@ class FunctionIf : public FunctionIfBase</*null_is_false=*/false>
|
||||
public:
|
||||
static constexpr auto name = "if";
|
||||
static FunctionPtr create(const Context & context) { return std::make_shared<FunctionIf>(context); }
|
||||
FunctionIf(const Context & context_) : context(context_) {}
|
||||
explicit FunctionIf(const Context & context_) : context(context_) {}
|
||||
|
||||
private:
|
||||
template <typename T0, typename T1>
|
||||
|
@ -15,7 +15,7 @@ class FunctionIfNotFinite : public IFunction
|
||||
public:
|
||||
static constexpr auto name = "ifNotFinite";
|
||||
|
||||
FunctionIfNotFinite(const Context & context_) : context(context_) {}
|
||||
explicit FunctionIfNotFinite(const Context & context_) : context(context_) {}
|
||||
|
||||
static FunctionPtr create(const Context & context)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ class FunctionIfNull : public IFunction
|
||||
public:
|
||||
static constexpr auto name = "ifNull";
|
||||
|
||||
FunctionIfNull(const Context & context_) : context(context_) {}
|
||||
explicit FunctionIfNull(const Context & context_) : context(context_) {}
|
||||
|
||||
static FunctionPtr create(const Context & context)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ class FunctionMultiIf final : public FunctionIfBase</*null_is_false=*/true>
|
||||
public:
|
||||
static constexpr auto name = "multiIf";
|
||||
static FunctionPtr create(const Context & context) { return std::make_shared<FunctionMultiIf>(context); }
|
||||
FunctionMultiIf(const Context & context_) : context(context_) {}
|
||||
explicit FunctionMultiIf(const Context & context_) : context(context_) {}
|
||||
|
||||
public:
|
||||
String getName() const override { return name; }
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
static constexpr auto name = "neighbor";
|
||||
static FunctionPtr create(const Context & context) { return std::make_shared<FunctionNeighbor>(context); }
|
||||
|
||||
FunctionNeighbor(const Context & context_) : context(context_) {}
|
||||
explicit FunctionNeighbor(const Context & context_) : context(context_) {}
|
||||
|
||||
/// Get the name of the function.
|
||||
String getName() const override { return name; }
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
return std::make_shared<FunctionNullIf>(context);
|
||||
}
|
||||
|
||||
FunctionNullIf(const Context & context_) : context(context_) {}
|
||||
explicit FunctionNullIf(const Context & context_) : context(context_) {}
|
||||
|
||||
std::string getName() const override
|
||||
{
|
||||
|
@ -30,12 +30,12 @@ int io_destroy(aio_context_t ctx)
|
||||
return syscall(__NR_io_destroy, ctx);
|
||||
}
|
||||
|
||||
int io_submit(aio_context_t ctx, long nr, struct iocb * iocbpp[])
|
||||
int io_submit(aio_context_t ctx, long nr, struct iocb * iocbpp[]) // NOLINT
|
||||
{
|
||||
return syscall(__NR_io_submit, ctx, nr, iocbpp);
|
||||
}
|
||||
|
||||
int io_getevents(aio_context_t ctx, long min_nr, long max_nr, io_event * events, struct timespec * timeout)
|
||||
int io_getevents(aio_context_t ctx, long min_nr, long max_nr, io_event * events, struct timespec * timeout) // NOLINT
|
||||
{
|
||||
return syscall(__NR_io_getevents, ctx, min_nr, max_nr, events, timeout);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ struct ReadBufferFromHDFS::ReadBufferFromHDFSImpl
|
||||
HDFSBuilderPtr builder;
|
||||
HDFSFSPtr fs;
|
||||
|
||||
ReadBufferFromHDFSImpl(const std::string & hdfs_name_)
|
||||
explicit ReadBufferFromHDFSImpl(const std::string & hdfs_name_)
|
||||
: hdfs_uri(hdfs_name_)
|
||||
, builder(createHDFSBuilder(hdfs_uri))
|
||||
, fs(createHDFSFS(builder.get()))
|
||||
|
@ -752,9 +752,9 @@ ReturnType readDateTextFallback(LocalDate & date, ReadBuffer & buf)
|
||||
|
||||
UInt16 year = 0;
|
||||
if (!append_digit(year)
|
||||
|| !append_digit(year)
|
||||
|| !append_digit(year)
|
||||
|| !append_digit(year))
|
||||
|| !append_digit(year) // NOLINT
|
||||
|| !append_digit(year) // NOLINT
|
||||
|| !append_digit(year)) // NOLINT
|
||||
return error();
|
||||
|
||||
if (!ignore_delimiter())
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
|
||||
Aws::Utils::Logging::LogLevel GetLogLevel() const final { return Aws::Utils::Logging::LogLevel::Trace; }
|
||||
|
||||
void Log(Aws::Utils::Logging::LogLevel log_level, const char * tag, const char * format_str, ...) final
|
||||
void Log(Aws::Utils::Logging::LogLevel log_level, const char * tag, const char * format_str, ...) final // NOLINT
|
||||
{
|
||||
auto & [level, prio] = convertLogLevel(log_level);
|
||||
LOG_SIMPLE(log, std::string(tag) + ": " + format_str, level, prio);
|
||||
|
@ -26,7 +26,7 @@ struct WriteBufferFromHDFS::WriteBufferFromHDFSImpl
|
||||
HDFSBuilderPtr builder;
|
||||
HDFSFSPtr fs;
|
||||
|
||||
WriteBufferFromHDFSImpl(const std::string & hdfs_name_)
|
||||
explicit WriteBufferFromHDFSImpl(const std::string & hdfs_name_)
|
||||
: hdfs_uri(hdfs_name_)
|
||||
, builder(createHDFSBuilder(hdfs_uri))
|
||||
, fs(createHDFSFS(builder.get()))
|
||||
|
@ -5,9 +5,11 @@
|
||||
#include <Core/Defines.h>
|
||||
#include <unistd.h>
|
||||
#include <IO/ReadBufferAIO.h>
|
||||
#include <Common/randomSeed.h>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
std::string createTmpFileForEOFtest()
|
||||
@ -21,7 +23,7 @@ std::string createTmpFileForEOFtest()
|
||||
{
|
||||
/// We have no tmp in docker
|
||||
/// So we have to use root
|
||||
std::string almost_rand_dir = std::string{"/"} + std::to_string(rand()) + "foo";
|
||||
std::string almost_rand_dir = std::string{"/"} + std::to_string(randomSeed()) + "foo";
|
||||
return almost_rand_dir;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ std::string bin(const T & value, size_t bits = sizeof(T) * 8)
|
||||
static const uint8_t MAX_BITS = sizeof(T)*8;
|
||||
assert(bits <= MAX_BITS);
|
||||
|
||||
return std::bitset<sizeof(T) * 8>(static_cast<unsigned long long>(value))
|
||||
return std::bitset<sizeof(T) * 8>(static_cast<uint64_t>(value))
|
||||
.to_string().substr(MAX_BITS - bits, bits);
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ struct TestCaseParameter
|
||||
std::vector<std::pair<uint8_t, UInt64>> bits_and_vals;
|
||||
std::string expected_buffer_binary;
|
||||
|
||||
TestCaseParameter(std::vector<std::pair<uint8_t, UInt64>> vals, std::string binary = std::string{})
|
||||
TestCaseParameter(std::vector<std::pair<uint8_t, UInt64>> vals, std::string binary = std::string{}) // NOLINT
|
||||
: bits_and_vals(std::move(vals)),
|
||||
expected_buffer_binary(binary)
|
||||
{}
|
||||
|
@ -3,14 +3,18 @@
|
||||
#include <IO/WriteBufferFromOStream.h>
|
||||
#include "hashing_buffer.h"
|
||||
#include <iostream>
|
||||
#include <pcg_random.hpp>
|
||||
|
||||
|
||||
static void test(size_t data_size)
|
||||
{
|
||||
pcg64 rng;
|
||||
|
||||
std::vector<char> vec(data_size);
|
||||
char * data = vec.data();
|
||||
|
||||
for (size_t i = 0; i < data_size; ++i)
|
||||
data[i] = rand() & 255;
|
||||
data[i] = rng() & 255;
|
||||
|
||||
CityHash_v1_0_2::uint128 reference = referenceHash(data, data_size);
|
||||
|
||||
|
@ -1,15 +1,18 @@
|
||||
#include <IO/HashingWriteBuffer.h>
|
||||
#include <IO/WriteBufferFromFile.h>
|
||||
#include <pcg_random.hpp>
|
||||
|
||||
#include "hashing_buffer.h"
|
||||
|
||||
static void test(size_t data_size)
|
||||
{
|
||||
pcg64 rng;
|
||||
|
||||
std::vector<char> vec(data_size);
|
||||
char * data = vec.data();
|
||||
|
||||
for (size_t i = 0; i < data_size; ++i)
|
||||
data[i] = rand() & 255;
|
||||
data[i] = rng() & 255;
|
||||
|
||||
CityHash_v1_0_2::uint128 reference = referenceHash(data, data_size);
|
||||
|
||||
@ -20,14 +23,14 @@ static void test(size_t data_size)
|
||||
|
||||
for (size_t pos = 0; pos < data_size;)
|
||||
{
|
||||
size_t len = std::min(static_cast<size_t>(rand() % 10000 + 1), data_size - pos);
|
||||
size_t len = std::min(static_cast<size_t>(rng() % 10000 + 1), data_size - pos);
|
||||
buf.write(data + pos, len);
|
||||
buf.next();
|
||||
pos += len;
|
||||
}
|
||||
|
||||
if (buf.getHash() != reference)
|
||||
FAIL("failed on data size " << data_size << " writing random chunks of up to 10000 bytes");
|
||||
FAIL("failed on data size " << data_size << " writing rngom chunks of up to 10000 bytes");
|
||||
}
|
||||
|
||||
{
|
||||
@ -35,14 +38,14 @@ static void test(size_t data_size)
|
||||
|
||||
for (size_t pos = 0; pos < data_size;)
|
||||
{
|
||||
size_t len = std::min(static_cast<size_t>(rand() % 5 + 1), data_size - pos);
|
||||
size_t len = std::min(static_cast<size_t>(rng() % 5 + 1), data_size - pos);
|
||||
buf.write(data + pos, len);
|
||||
buf.next();
|
||||
pos += len;
|
||||
}
|
||||
|
||||
if (buf.getHash() != reference)
|
||||
FAIL("failed on data size " << data_size << " writing random chunks of up to 5 bytes");
|
||||
FAIL("failed on data size " << data_size << " writing rngom chunks of up to 5 bytes");
|
||||
}
|
||||
|
||||
{
|
||||
@ -50,14 +53,14 @@ static void test(size_t data_size)
|
||||
|
||||
for (size_t pos = 0; pos < data_size;)
|
||||
{
|
||||
size_t len = std::min(static_cast<size_t>(2048 + rand() % 3 - 1), data_size - pos);
|
||||
size_t len = std::min(static_cast<size_t>(2048 + rng() % 3 - 1), data_size - pos);
|
||||
buf.write(data + pos, len);
|
||||
buf.next();
|
||||
pos += len;
|
||||
}
|
||||
|
||||
if (buf.getHash() != reference)
|
||||
FAIL("failed on data size " << data_size << " writing random chunks of 2048 +-1 bytes");
|
||||
FAIL("failed on data size " << data_size << " writing rngom chunks of 2048 +-1 bytes");
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ int main(int argc, char ** argv)
|
||||
|
||||
using T = UInt8;
|
||||
|
||||
size_t n = atoi(argv[1]);
|
||||
size_t n = std::stol(argv[1]);
|
||||
std::vector<T> data(n);
|
||||
std::vector<T> data2(n);
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
struct DecomposedFloat64
|
||||
{
|
||||
DecomposedFloat64(double x)
|
||||
explicit DecomposedFloat64(double x)
|
||||
{
|
||||
memcpy(&x_uint, &x, sizeof(x));
|
||||
}
|
||||
@ -43,7 +43,7 @@ struct DecomposedFloat64
|
||||
|
||||
struct DecomposedFloat32
|
||||
{
|
||||
DecomposedFloat32(float x)
|
||||
explicit DecomposedFloat32(float x)
|
||||
{
|
||||
memcpy(&x_uint, &x, sizeof(x));
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ int main(int argc, char ** argv)
|
||||
{
|
||||
int repeats = 1;
|
||||
if (argc >= 2)
|
||||
repeats = atoi(argv[1]);
|
||||
repeats = std::stol(argv[1]);
|
||||
|
||||
std::string text((std::istreambuf_iterator<char>(std::cin)),
|
||||
std::istreambuf_iterator<char>());
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user