This commit is contained in:
Odin Hultgren Van Der Horst 2019-01-09 15:27:11 +00:00
commit ffdf565528
280 changed files with 1429 additions and 2804 deletions

View File

@ -79,7 +79,11 @@ endif()
function(llvm_libs_all REQUIRED_LLVM_LIBRARIES)
llvm_map_components_to_libnames (result all)
list (REMOVE_ITEM result "LTO" "LLVM")
if (USE_STATIC_LIBRARIES OR NOT "LLVM" IN_LIST result)
list (REMOVE_ITEM result "LTO" "LLVM")
else()
set (result "LLVM")
endif ()
if (TERMCAP_LIBRARY)
list (APPEND result ${TERMCAP_LIBRARY})
endif ()

View File

@ -1,7 +1,7 @@
# Third-party libraries may have substandard code.
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-result -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-format -Wno-misleading-indentation -Wno-stringop-overflow")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-result -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-format -Wno-misleading-indentation -Wno-stringop-overflow -Wno-implicit-function-declaration -Wno-return-type -Wno-array-bounds -Wno-bool-compare -Wno-int-conversion -Wno-switch")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-old-style-cast -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-result -Wno-deprecated-declarations -Wno-non-virtual-dtor -Wno-maybe-uninitialized -Wno-format -Wno-misleading-indentation -Wno-implicit-fallthrough -Wno-class-memaccess -Wno-sign-compare -std=c++1z")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-unused-variable -Wno-unused-result -Wno-deprecated-declarations -Wno-format -Wno-parentheses-equality -Wno-tautological-constant-compare -Wno-tautological-constant-out-of-range-compare -Wno-implicit-function-declaration -Wno-return-type -Wno-pointer-bool-conversion -Wno-enum-conversion -Wno-int-conversion -Wno-switch")

View File

@ -1,48 +0,0 @@
# Check prereqs
FIND_PROGRAM(GCOV_PATH gcov)
FIND_PROGRAM(LCOV_PATH lcov)
FIND_PROGRAM(GENHTML_PATH genhtml)
IF(NOT GCOV_PATH)
MESSAGE(FATAL_ERROR "gcov not found! Aborting...")
ENDIF(NOT GCOV_PATH)
IF(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
MESSAGE(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading")
ENDIF(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
#Setup compiler options
ADD_DEFINITIONS(-fprofile-arcs -ftest-coverage)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs ")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs ")
IF(NOT LCOV_PATH)
MESSAGE(FATAL_ERROR "lcov not found! Aborting...")
ENDIF(NOT LCOV_PATH)
IF(NOT GENHTML_PATH)
MESSAGE(FATAL_ERROR "genhtml not found! Aborting...")
ENDIF(NOT GENHTML_PATH)
#Setup target
ADD_CUSTOM_TARGET(ShowCoverage
#Capturing lcov counters and generating report
COMMAND ${LCOV_PATH} --directory . --capture --output-file CodeCoverage.info
COMMAND ${LCOV_PATH} --remove CodeCoverage.info '${CMAKE_CURRENT_BINARY_DIR}/*' 'test/*' 'mock/*' '/usr/*' '/opt/*' '*ext/rhel5_x86_64*' '*ext/osx*' --output-file CodeCoverage.info.cleaned
COMMAND ${GENHTML_PATH} -o CodeCoverageReport CodeCoverage.info.cleaned
)
ADD_CUSTOM_TARGET(ShowAllCoverage
#Capturing lcov counters and generating report
COMMAND ${LCOV_PATH} -a CodeCoverage.info.cleaned -a CodeCoverage.info.cleaned_withoutHA -o AllCodeCoverage.info
COMMAND sed -e 's|/.*/src|${CMAKE_SOURCE_DIR}/src|' -ig AllCodeCoverage.info
COMMAND ${GENHTML_PATH} -o AllCodeCoverageReport AllCodeCoverage.info
)
ADD_CUSTOM_TARGET(ResetCoverage
#Cleanup lcov
COMMAND ${LCOV_PATH} --directory . --zerocounters
)

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +1,15 @@
OPTION(ENABLE_COVERAGE "enable code coverage" OFF)
OPTION(ENABLE_DEBUG "enable debug build" OFF)
OPTION(ENABLE_SSE "enable SSE4.2 buildin function" ON)
OPTION(ENABLE_FRAME_POINTER "enable frame pointer on 64bit system with flag -fno-omit-frame-pointer, on 32bit system, it is always enabled" ON)
OPTION(ENABLE_LIBCPP "using libc++ instead of libstdc++, only valid for clang compiler" OFF)
OPTION(ENABLE_BOOST "using boost instead of native compiler c++0x support" OFF)
INCLUDE (CheckFunctionExists)
CHECK_FUNCTION_EXISTS(dladdr HAVE_DLADDR)
CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
IF(ENABLE_DEBUG STREQUAL ON)
SET(CMAKE_BUILD_TYPE Debug CACHE
STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0" CACHE STRING "compiler flags for debug" FORCE)
SET(CMAKE_C_FLAGS_DEBUG "-g -O0" CACHE STRING "compiler flags for debug" FORCE)
ELSE(ENABLE_DEBUG STREQUAL ON)
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE
STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF(ENABLE_DEBUG STREQUAL ON)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing")
IF(ENABLE_COVERAGE STREQUAL ON)
INCLUDE(CodeCoverage)
ENDIF(ENABLE_COVERAGE STREQUAL ON)
IF(ENABLE_FRAME_POINTER STREQUAL ON)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
ENDIF(ENABLE_FRAME_POINTER STREQUAL ON)
IF(ENABLE_SSE STREQUAL ON)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
ENDIF(ENABLE_SSE STREQUAL ON)
ENDIF(ENABLE_SSE STREQUAL ON)
IF(NOT TEST_HDFS_PREFIX)
SET(TEST_HDFS_PREFIX "./" CACHE STRING "default directory prefix used for test." FORCE)
@ -41,76 +18,7 @@ ENDIF(NOT TEST_HDFS_PREFIX)
ADD_DEFINITIONS(-DTEST_HDFS_PREFIX="${TEST_HDFS_PREFIX}")
ADD_DEFINITIONS(-D__STDC_FORMAT_MACROS)
ADD_DEFINITIONS(-D_GNU_SOURCE)
IF(OS_MACOSX AND CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-bind_at_load")
ENDIF(OS_MACOSX AND CMAKE_COMPILER_IS_GNUCXX)
IF(OS_LINUX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--export-dynamic")
ENDIF(OS_LINUX)
SET(BOOST_ROOT ${CMAKE_PREFIX_PATH})
IF(ENABLE_BOOST STREQUAL ON)
MESSAGE(STATUS "using boost instead of native compiler c++0x support.")
FIND_PACKAGE(Boost 1.50 REQUIRED)
SET(NEED_BOOST true CACHE INTERNAL "boost is required")
ELSE(ENABLE_BOOST STREQUAL ON)
SET(NEED_BOOST false CACHE INTERNAL "boost is required")
ENDIF(ENABLE_BOOST STREQUAL ON)
IF(CMAKE_COMPILER_IS_GNUCXX)
IF(ENABLE_LIBCPP STREQUAL ON)
MESSAGE(FATAL_ERROR "Unsupport using GCC compiler with libc++")
ENDIF(ENABLE_LIBCPP STREQUAL ON)
IF((GCC_COMPILER_VERSION_MAJOR EQUAL 4) AND (GCC_COMPILER_VERSION_MINOR EQUAL 4) AND OS_MACOSX)
SET(NEED_GCCEH true CACHE INTERNAL "Explicitly link with gcc_eh")
MESSAGE(STATUS "link with -lgcc_eh for TLS")
ENDIF((GCC_COMPILER_VERSION_MAJOR EQUAL 4) AND (GCC_COMPILER_VERSION_MINOR EQUAL 4) AND OS_MACOSX)
IF((GCC_COMPILER_VERSION_MAJOR LESS 4) OR ((GCC_COMPILER_VERSION_MAJOR EQUAL 4) AND (GCC_COMPILER_VERSION_MINOR LESS 4)))
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
IF(NOT ENABLE_BOOST STREQUAL ON)
MESSAGE(STATUS "gcc version is older than 4.6.0, boost is required.")
FIND_PACKAGE(Boost 1.50 REQUIRED)
SET(NEED_BOOST true CACHE INTERNAL "boost is required")
ENDIF(NOT ENABLE_BOOST STREQUAL ON)
ELSEIF((GCC_COMPILER_VERSION_MAJOR EQUAL 4) AND (GCC_COMPILER_VERSION_MINOR LESS 7))
IF(NOT ENABLE_BOOST STREQUAL ON)
MESSAGE(STATUS "gcc version is older than 4.6.0, boost is required.")
FIND_PACKAGE(Boost 1.50 REQUIRED)
SET(NEED_BOOST true CACHE INTERNAL "boost is required")
ENDIF(NOT ENABLE_BOOST STREQUAL ON)
MESSAGE(STATUS "adding c++0x support for gcc compiler")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
ELSE((GCC_COMPILER_VERSION_MAJOR LESS 4) OR ((GCC_COMPILER_VERSION_MAJOR EQUAL 4) AND (GCC_COMPILER_VERSION_MINOR LESS 4)))
MESSAGE(STATUS "adding c++0x support for gcc compiler")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
ENDIF((GCC_COMPILER_VERSION_MAJOR LESS 4) OR ((GCC_COMPILER_VERSION_MAJOR EQUAL 4) AND (GCC_COMPILER_VERSION_MINOR LESS 4)))
IF(NEED_BOOST)
IF((Boost_MAJOR_VERSION LESS 1) OR ((Boost_MAJOR_VERSION EQUAL 1) AND (Boost_MINOR_VERSION LESS 50)))
MESSAGE(FATAL_ERROR "boost 1.50+ is required")
ENDIF()
ELSE(NEED_BOOST)
IF(HAVE_NANOSLEEP)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_NANOSLEEP")
ELSE(HAVE_NANOSLEEP)
MESSAGE(FATAL_ERROR "nanosleep() is required")
ENDIF(HAVE_NANOSLEEP)
ENDIF(NEED_BOOST)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
ELSEIF(CMAKE_COMPILER_IS_CLANG)
MESSAGE(STATUS "adding c++0x support for clang compiler")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
SET(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++0x")
IF(ENABLE_LIBCPP STREQUAL ON)
MESSAGE(STATUS "using libc++ instead of libstdc++")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
SET(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
ENDIF(ENABLE_LIBCPP STREQUAL ON)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
ADD_DEFINITIONS(-D_GLIBCXX_USE_NANOSLEEP)
TRY_COMPILE(STRERROR_R_RETURN_INT
${CMAKE_CURRENT_BINARY_DIR}
@ -138,32 +46,8 @@ TRY_COMPILE(HAVE_NESTED_EXCEPTION
CMAKE_FLAGS "-DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now...'"
OUTPUT_VARIABLE OUTPUT)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test.cpp "#include <boost/chrono.hpp>")
TRY_COMPILE(HAVE_BOOST_CHRONO
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/test.cpp
CMAKE_FLAGS "-DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now...'"
-DINCLUDE_DIRECTORIES=${Boost_INCLUDE_DIR}
OUTPUT_VARIABLE OUTPUT)
SET(HAVE_BOOST_CHRONO 0)
SET(HAVE_BOOST_ATOMIC 0)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test.cpp "#include <chrono>")
TRY_COMPILE(HAVE_STD_CHRONO
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/test.cpp
CMAKE_FLAGS "-DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now...'"
OUTPUT_VARIABLE OUTPUT)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test.cpp "#include <boost/atomic.hpp>")
TRY_COMPILE(HAVE_BOOST_ATOMIC
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/test.cpp
CMAKE_FLAGS "-DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now...'"
-DINCLUDE_DIRECTORIES=${Boost_INCLUDE_DIR}
OUTPUT_VARIABLE OUTPUT)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test.cpp "#include <atomic>")
TRY_COMPILE(HAVE_STD_ATOMIC
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/test.cpp
CMAKE_FLAGS "-DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now...'"
OUTPUT_VARIABLE OUTPUT)
SET(HAVE_STD_CHRONO 1)
SET(HAVE_STD_ATOMIC 1)

View File

@ -2,8 +2,7 @@
// MurmurHash2 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
#ifndef _MURMURHASH2_H_
#define _MURMURHASH2_H_
#pragma once
//-----------------------------------------------------------------------------
// Platform-specific functions and macros
@ -30,6 +29,3 @@ uint64_t MurmurHash64B (const void * key, int len, uint64_t seed);
uint32_t MurmurHash2A (const void * key, int len, uint32_t seed);
uint32_t MurmurHashNeutral2 (const void * key, int len, uint32_t seed);
uint32_t MurmurHashAligned2 (const void * key, int len, uint32_t seed);
#endif // _MURMURHASH2_H_

View File

@ -2,8 +2,7 @@
// MurmurHash3 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
#ifndef _MURMURHASH3_H_
#define _MURMURHASH3_H_
#pragma once
//-----------------------------------------------------------------------------
// Platform-specific functions and macros
@ -33,5 +32,3 @@ void MurmurHash3_x86_128 ( const void * key, int len, uint32_t seed, void * out
void MurmurHash3_x64_128 ( const void * key, int len, uint32_t seed, void * out );
//-----------------------------------------------------------------------------
#endif // _MURMURHASH3_H_

View File

@ -29,13 +29,35 @@ if (NOT NO_WERROR)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
endif ()
# Add some warnings that are not available even with -Wall -Wextra.
# Add some warnings that are not available even with -Wall -Wextra -Wpedantic.
option (WEVERYTHING "Enables -Weverything option with some exceptions. This is intended for exploration of new compiler warnings that may be found to be useful. Only makes sense for clang." ON)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra-semi -Wcomma -Winconsistent-missing-destructor-override -Wunused-exception-parameter -Wshadow-uncaptured-local")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic -Wno-vla-extension -Wno-zero-length-array -Wno-gnu-anonymous-struct -Wno-nested-anon-types")
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wredundant-parens -Wzero-as-null-pointer-constant")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow -Wshadow-uncaptured-local -Wextra-semi -Wcomma -Winconsistent-missing-destructor-override -Wunused-exception-parameter -Wcovered-switch-default -Wold-style-cast -Wrange-loop-analysis -Wunused-member-function -Wunreachable-code -Wunreachable-code-return -Wnewline-eof -Wembedded-directive -Wgnu-case-range -Wunused-macros -Wconditional-uninitialized -Wdeprecated -Wundef -Wreserved-id-macro -Wredundant-parens -Wzero-as-null-pointer-constant")
if (WEVERYTHING)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-missing-noreturn -Wno-padded -Wno-switch-enum -Wno-shadow-field-in-constructor -Wno-deprecated-dynamic-exception-spec -Wno-float-equal -Wno-weak-vtables -Wno-shift-sign-overflow -Wno-sign-conversion -Wno-conversion -Wno-exit-time-destructors -Wno-undefined-func-template -Wno-documentation-unknown-command -Wno-missing-variable-declarations -Wno-unused-template -Wno-global-constructors -Wno-c99-extensions -Wno-missing-prototypes -Wno-weak-template-vtables -Wno-zero-length-array -Wno-gnu-anonymous-struct -Wno-nested-anon-types -Wno-double-promotion -Wno-disabled-macro-expansion -Wno-used-but-marked-unused -Wno-vla-extension -Wno-vla -Wno-packed")
# TODO Enable conversion, sign-conversion, double-promotion warnings.
endif ()
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
if (WEVERYTHING)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-std-move-in-c++11")
endif ()
endif ()
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra-semi-stmt -Wshadow-field -Wstring-plus-int")
if (WEVERYTHING)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif ()
endif ()
endif ()

View File

@ -229,7 +229,7 @@ private:
report(info_per_interval);
delay_watch.restart();
}
};
}
return true;
}
@ -324,7 +324,7 @@ private:
double seconds = watch.elapsedSeconds();
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
info_per_interval.add(seconds, progress.rows, progress.bytes, info.rows, info.bytes);
info_total.add(seconds, progress.rows, progress.bytes, info.rows, info.bytes);
}
@ -332,7 +332,7 @@ private:
void report(Stats & info)
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
/// Avoid zeros, nans or exceptions
if (0 == info.queries)
@ -369,7 +369,7 @@ private:
{
WriteBufferFromFile json_out(filename);
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
auto print_key_value = [&](auto key, auto value, bool with_comma = true)
{
@ -503,6 +503,4 @@ int mainEntryClickHouseBenchmark(int argc, char ** argv)
std::cerr << getCurrentExceptionMessage(print_stacktrace, true) << std::endl;
return getCurrentExceptionCode();
}
return 0;
}

View File

@ -74,8 +74,8 @@
/// http://en.wikipedia.org/wiki/ANSI_escape_code
/// Similar codes \e[s, \e[u don't work in VT100 and Mosh.
#define SAVE_CURSOR_POSITION "\e7"
#define RESTORE_CURSOR_POSITION "\e8"
#define SAVE_CURSOR_POSITION "\033""7"
#define RESTORE_CURSOR_POSITION "\033""8"
#define CLEAR_TO_END_OF_LINE "\033[K"
@ -554,10 +554,10 @@ private:
void loop()
{
String query;
String prev_query;
String input;
String prev_input;
while (char * line_ = readline(query.empty() ? prompt().c_str() : ":-] "))
while (char * line_ = readline(input.empty() ? prompt().c_str() : ":-] "))
{
String line = line_;
free(line_);
@ -577,17 +577,17 @@ private:
if (ends_with_backslash)
line = line.substr(0, ws - 1);
query += line;
input += line;
if (!ends_with_backslash && (ends_with_semicolon || has_vertical_output_suffix || (!config().has("multiline") && !hasDataInSTDIN())))
{
if (query != prev_query)
if (input != prev_input)
{
/// Replace line breaks with spaces to prevent the following problem.
/// Every line of multi-line query is saved to history file as a separate line.
/// If the user restarts the client then after pressing the "up" button
/// every line of the query will be displayed separately.
std::string logged_query = query;
std::string logged_query = input;
std::replace(logged_query.begin(), logged_query.end(), '\n', ' ');
add_history(logged_query.c_str());
@ -596,18 +596,18 @@ private:
throwFromErrno("Cannot append history to file " + history_file, ErrorCodes::CANNOT_APPEND_HISTORY);
#endif
prev_query = query;
prev_input = input;
}
if (has_vertical_output_suffix)
query = query.substr(0, query.length() - 2);
input = input.substr(0, input.length() - 2);
try
{
/// Determine the terminal size.
ioctl(0, TIOCGWINSZ, &terminal_size);
if (!process(query))
if (!process(input))
break;
}
catch (const Exception & e)
@ -633,11 +633,11 @@ private:
connect();
}
query = "";
input = "";
}
else
{
query += '\n';
input += '\n';
}
}
}
@ -675,8 +675,6 @@ private:
/// Several queries separated by ';'.
/// INSERT data is ended by the end of line, not ';'.
String query;
const char * begin = text.data();
const char * end = begin + text.size();
@ -708,19 +706,19 @@ private:
insert->end = pos;
}
query = text.substr(begin - text.data(), pos - begin);
String str = text.substr(begin - text.data(), pos - begin);
begin = pos;
while (isWhitespaceASCII(*begin) || *begin == ';')
++begin;
TestHint test_hint(test_mode, query);
TestHint test_hint(test_mode, str);
expected_client_error = test_hint.clientError();
expected_server_error = test_hint.serverError();
try
{
if (!processSingleQuery(query, ast) && !ignore_error)
if (!processSingleQuery(str, ast) && !ignore_error)
return false;
}
catch (...)
@ -728,7 +726,7 @@ private:
last_exception = std::make_unique<Exception>(getCurrentExceptionMessage(true), getCurrentExceptionCode());
actual_client_error = last_exception->code();
if (!ignore_error && (!actual_client_error || actual_client_error != expected_client_error))
std::cerr << "Error on processing query: " << query << std::endl << last_exception->message();
std::cerr << "Error on processing query: " << str << std::endl << last_exception->message();
got_exception = true;
}
@ -904,8 +902,6 @@ private:
ParserQuery parser(end, true);
ASTPtr res;
const auto ignore_error = config().getBool("ignore-error", false);
if (is_interactive || ignore_error)
{
String message;
@ -1616,10 +1612,10 @@ public:
for (size_t i = 0; i < external_tables_arguments.size(); ++i)
{
/// Parse commandline options related to external tables.
po::parsed_options parsed = po::command_line_parser(
po::parsed_options parsed_tables = po::command_line_parser(
external_tables_arguments[i].size(), external_tables_arguments[i].data()).options(external_description).run();
po::variables_map external_options;
po::store(parsed, external_options);
po::store(parsed_tables, external_options);
try
{

View File

@ -56,7 +56,7 @@ private:
{
std::string prefix_str(prefix);
std::tie(pos, end) = std::equal_range(words.begin(), words.end(), prefix_str,
[prefix_length](const std::string & s, const std::string & prefix) { return strncmp(s.c_str(), prefix.c_str(), prefix_length) < 0; });
[prefix_length](const std::string & s, const std::string & prefix_searched) { return strncmp(s.c_str(), prefix_searched.c_str(), prefix_length) < 0; });
}
/// Iterates through matched range.

View File

@ -66,11 +66,11 @@ void LocalServer::initialize(Poco::Util::Application & self)
}
}
void LocalServer::applyCmdSettings(Context & context)
void LocalServer::applyCmdSettings()
{
#define EXTRACT_SETTING(TYPE, NAME, DEFAULT, DESCRIPTION) \
if (cmd_settings.NAME.changed) \
context.getSettingsRef().NAME = cmd_settings.NAME;
context->getSettingsRef().NAME = cmd_settings.NAME;
APPLY_FOR_SETTINGS(EXTRACT_SETTING)
#undef EXTRACT_SETTING
}
@ -179,7 +179,7 @@ try
std::string default_database = config().getString("default_database", "_local");
context->addDatabase(default_database, std::make_shared<DatabaseMemory>(default_database));
context->setCurrentDatabase(default_database);
applyCmdOptions(*context);
applyCmdOptions();
if (!context->getPath().empty())
{
@ -274,7 +274,7 @@ void LocalServer::processQueries()
context->setUser("default", "", Poco::Net::SocketAddress{}, "");
context->setCurrentQueryId("");
applyCmdSettings(*context);
applyCmdSettings();
/// Use the same query_id (and thread group) for all queries
CurrentThread::QueryScope query_scope_holder(*context);
@ -494,10 +494,10 @@ void LocalServer::init(int argc, char ** argv)
config().setBool("ignore-error", true);
}
void LocalServer::applyCmdOptions(Context & context)
void LocalServer::applyCmdOptions()
{
context.setDefaultFormat(config().getString("output-format", config().getString("format", "TSV")));
applyCmdSettings(context);
context->setDefaultFormat(config().getString("output-format", config().getString("format", "TSV")));
applyCmdSettings();
}
}

View File

@ -34,8 +34,8 @@ private:
std::string getInitialCreateTableQuery();
void tryInitPath();
void applyCmdOptions(Context & context);
void applyCmdSettings(Context & context);
void applyCmdOptions();
void applyCmdSettings();
void attachSystemTables();
void processQueries();
void setupUsers();

View File

@ -317,8 +317,8 @@ void transformFixedString(const UInt8 * src, UInt8 * dst, size_t size, UInt64 se
if (size >= 16)
{
char * dst = reinterpret_cast<char *>(std::min(pos, end - 16));
hash.get128(dst);
char * hash_dst = reinterpret_cast<char *>(std::min(pos, end - 16));
hash.get128(hash_dst);
}
else
{

View File

@ -19,4 +19,4 @@ namespace DB
std::string getIdentifierQuote(SQLHDBC hdbc);
}
#endif
#endif

View File

@ -112,7 +112,8 @@ public:
{
return asString(padding);
}
String asString(size_t padding) const
String asString(size_t cur_padding) const
{
String repr = "{";
@ -121,10 +122,10 @@ public:
if (it != content.begin())
repr += ',';
/// construct "key": "value" string with padding
repr += "\n" + pad(padding) + '"' + it->first + '"' + ": " + it->second;
repr += "\n" + pad(cur_padding) + '"' + it->first + '"' + ": " + it->second;
}
repr += "\n" + pad(padding - 1) + '}';
repr += "\n" + pad(cur_padding - 1) + '}';
return repr;
}
};
@ -762,13 +763,13 @@ private:
return true;
}
void processTestsConfigurations(const Paths & input_files)
void processTestsConfigurations(const Paths & paths)
{
tests_configurations.resize(input_files.size());
tests_configurations.resize(paths.size());
for (size_t i = 0; i != input_files.size(); ++i)
for (size_t i = 0; i != paths.size(); ++i)
{
const String path = input_files[i];
const String path = paths[i];
tests_configurations[i] = XMLConfigurationPtr(new XMLConfiguration(path));
}
@ -881,8 +882,6 @@ private:
}
}
Query query;
if (!test_config->has("query") && !test_config->has("query_file"))
{
throw DB::Exception("Missing query fields in test's config: " + test_name, DB::ErrorCodes::BAD_ARGUMENTS);
@ -907,6 +906,7 @@ private:
bool tsv = fs::path(filename).extension().string() == ".tsv";
ReadBufferFromFile query_file(filename);
Query query;
if (tsv)
{
@ -1024,7 +1024,7 @@ private:
}
if (lite_output)
return minOutput(main_metric);
return minOutput();
else
return constructTotalInfo(metrics);
}
@ -1053,11 +1053,8 @@ private:
void runQueries(const QueriesWithIndexes & queries_with_indexes)
{
for (const std::pair<Query, const size_t> & query_and_index : queries_with_indexes)
for (const auto & [query, run_index] : queries_with_indexes)
{
Query query = query_and_index.first;
const size_t run_index = query_and_index.second;
TestStopConditions & stop_conditions = stop_conditions_by_run[run_index];
Stats & statistics = statistics_by_run[run_index];
@ -1139,7 +1136,7 @@ private:
}
}
void constructSubstitutions(ConfigurationPtr & substitutions_view, StringToVector & substitutions)
void constructSubstitutions(ConfigurationPtr & substitutions_view, StringToVector & out_substitutions)
{
Keys xml_substitutions;
substitutions_view->keys(xml_substitutions);
@ -1157,21 +1154,16 @@ private:
for (size_t j = 0; j != xml_values.size(); ++j)
{
substitutions[name].push_back(xml_substitution->getString("values.value[" + std::to_string(j) + "]"));
out_substitutions[name].push_back(xml_substitution->getString("values.value[" + std::to_string(j) + "]"));
}
}
}
std::vector<String> formatQueries(const String & query, StringToVector substitutions)
std::vector<String> formatQueries(const String & query, StringToVector substitutions_to_generate)
{
std::vector<String> queries;
StringToVector::iterator substitutions_first = substitutions.begin();
StringToVector::iterator substitutions_last = substitutions.end();
runThroughAllOptionsAndPush(substitutions_first, substitutions_last, query, queries);
return queries;
std::vector<String> queries_res;
runThroughAllOptionsAndPush(substitutions_to_generate.begin(), substitutions_to_generate.end(), query, queries_res);
return queries_res;
}
/// Recursive method which goes through all substitution blocks in xml
@ -1179,11 +1171,11 @@ private:
void runThroughAllOptionsAndPush(StringToVector::iterator substitutions_left,
StringToVector::iterator substitutions_right,
const String & template_query,
std::vector<String> & queries)
std::vector<String> & out_queries)
{
if (substitutions_left == substitutions_right)
{
queries.push_back(template_query); /// completely substituted query
out_queries.push_back(template_query); /// completely substituted query
return;
}
@ -1191,7 +1183,7 @@ private:
if (template_query.find(substitution_mask) == String::npos) /// nothing to substitute here
{
runThroughAllOptionsAndPush(std::next(substitutions_left), substitutions_right, template_query, queries);
runThroughAllOptionsAndPush(std::next(substitutions_left), substitutions_right, template_query, out_queries);
return;
}
@ -1209,7 +1201,7 @@ private:
query.replace(substr_pos, substitution_mask.length(), value);
}
runThroughAllOptionsAndPush(std::next(substitutions_left), substitutions_right, query, queries);
runThroughAllOptionsAndPush(std::next(substitutions_left), substitutions_right, query, out_queries);
}
}
@ -1343,7 +1335,7 @@ public:
return json_output.asString();
}
String minOutput(const String & main_metric)
String minOutput()
{
String output;
@ -1465,7 +1457,7 @@ try
input_files = options["input-files"].as<Strings>();
Strings collected_files;
for (const String filename : input_files)
for (const String & filename : input_files)
{
fs::path file(filename);

View File

@ -31,20 +31,16 @@ public:
Poco::Net::HTTPRequestHandler * createRequestHandler(const Poco::Net::HTTPServerRequest & request) override
{
LOG_TRACE(log,
"HTTP Request for " << name << ". "
<< "Method: "
<< request.getMethod()
<< ", Address: "
<< request.clientAddress().toString()
<< ", User-Agent: "
<< (request.has("User-Agent") ? request.get("User-Agent") : "none")
<< (request.hasContentLength() ? (", Length: " + std::to_string(request.getContentLength())) : (""))
#if !NDEBUG
<< ", Content Type: " << request.getContentType()
<< ", Transfer Encoding: " << request.getTransferEncoding()
#endif
);
LOG_TRACE(log, "HTTP Request for " << name << ". "
<< "Method: "
<< request.getMethod()
<< ", Address: "
<< request.clientAddress().toString()
<< ", User-Agent: "
<< (request.has("User-Agent") ? request.get("User-Agent") : "none")
<< (request.hasContentLength() ? (", Length: " + std::to_string(request.getContentLength())) : (""))
<< ", Content Type: " << request.getContentType()
<< ", Transfer Encoding: " << request.getTransferEncoding());
const auto & uri = request.getURI();

View File

@ -21,7 +21,7 @@ MetricsTransmitter::~MetricsTransmitter()
try
{
{
std::lock_guard<std::mutex> lock{mutex};
std::lock_guard lock{mutex};
quit = true;
}
@ -56,7 +56,7 @@ void MetricsTransmitter::run()
std::vector<ProfileEvents::Count> prev_counters(ProfileEvents::end());
std::unique_lock<std::mutex> lock{mutex};
std::unique_lock lock{mutex};
while (true)
{

View File

@ -102,16 +102,14 @@ AggregateFunctionPtr AggregateFunctionFactory::getImpl(
{
String name = getAliasToOrName(name_param);
/// Find by exact match.
auto it = aggregate_functions.find(name);
if (it != aggregate_functions.end())
if (auto it = aggregate_functions.find(name); it != aggregate_functions.end())
return it->second(name, argument_types, parameters);
/// Find by case-insensitive name.
/// Combinators cannot apply for case insensitive (SQL-style) aggregate function names. Only for native names.
if (recursion_level == 0)
{
auto it = case_insensitive_aggregate_functions.find(Poco::toLower(name));
if (it != case_insensitive_aggregate_functions.end())
if (auto it = case_insensitive_aggregate_functions.find(Poco::toLower(name)); it != case_insensitive_aggregate_functions.end())
return it->second(name, argument_types, parameters);
}

View File

@ -231,7 +231,7 @@ public:
nested_state += nested_size_of_data;
}
offsets_to.push_back(offsets_to.empty() ? state.dynamic_array_size : offsets_to.back() + state.dynamic_array_size);
offsets_to.push_back(offsets_to.back() + state.dynamic_array_size);
}
bool allocatesMemoryInArena() const override

View File

@ -203,7 +203,7 @@ public:
for (size_t i = arr.size(); i < result_array_size; ++i)
to_data.insert(default_value);
to_offsets.push_back((to_offsets.empty() ? 0 : to_offsets.back()) + result_array_size);
to_offsets.push_back(to_offsets.back() + result_array_size);
}
const char * getHeaderFilePath() const override { return __FILE__; }

View File

@ -45,8 +45,6 @@ AggregateFunctionPtr createAggregateFunctionHistogram(const std::string & name,
throw Exception("Illegal type " + arguments[0]->getName() + " of argument for aggregate function " + name, ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
return res;
return nullptr;
}
}

View File

@ -187,8 +187,8 @@ template <bool result_is_nullable>
class AggregateFunctionNullUnary final : public AggregateFunctionNullBase<result_is_nullable, AggregateFunctionNullUnary<result_is_nullable>>
{
public:
AggregateFunctionNullUnary(AggregateFunctionPtr nested_function)
: AggregateFunctionNullBase<result_is_nullable, AggregateFunctionNullUnary<result_is_nullable>>(nested_function)
AggregateFunctionNullUnary(AggregateFunctionPtr nested_function_)
: AggregateFunctionNullBase<result_is_nullable, AggregateFunctionNullUnary<result_is_nullable>>(std::move(nested_function_))
{
}
@ -209,8 +209,8 @@ template <bool result_is_nullable>
class AggregateFunctionNullVariadic final : public AggregateFunctionNullBase<result_is_nullable, AggregateFunctionNullVariadic<result_is_nullable>>
{
public:
AggregateFunctionNullVariadic(AggregateFunctionPtr nested_function, const DataTypes & arguments)
: AggregateFunctionNullBase<result_is_nullable, AggregateFunctionNullVariadic<result_is_nullable>>(nested_function),
AggregateFunctionNullVariadic(AggregateFunctionPtr nested_function_, const DataTypes & arguments)
: AggregateFunctionNullBase<result_is_nullable, AggregateFunctionNullVariadic<result_is_nullable>>(std::move(nested_function_)),
number_of_arguments(arguments.size())
{
if (number_of_arguments == 1)

View File

@ -100,9 +100,12 @@ public:
return res;
}
void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override
void NO_SANITIZE_UNDEFINED add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const override
{
/// Out of range conversion may occur. This is Ok.
const auto & column = static_cast<const ColVecType &>(*columns[0]);
if constexpr (has_second_arg)
this->data(place).add(
column.getData()[row_num],

View File

@ -80,11 +80,11 @@ public:
void add(AggregateDataPtr place, const IColumn ** columns, const size_t row_num, Arena *) const override
{
// Column 0 contains array of keys of known type
const ColumnArray & array_column = static_cast<const ColumnArray &>(*columns[0]);
const IColumn::Offsets & offsets = array_column.getOffsets();
const auto & keys_vec = static_cast<const ColVecType &>(array_column.getData());
const size_t keys_vec_offset = offsets[row_num - 1];
const size_t keys_vec_size = (offsets[row_num] - keys_vec_offset);
const ColumnArray & array_column0 = static_cast<const ColumnArray &>(*columns[0]);
const IColumn::Offsets & offsets0 = array_column0.getOffsets();
const auto & keys_vec = static_cast<const ColVecType &>(array_column0.getData());
const size_t keys_vec_offset = offsets0[row_num - 1];
const size_t keys_vec_size = (offsets0[row_num] - keys_vec_offset);
// Columns 1..n contain arrays of numeric values to sum
auto & merged_maps = this->data(place).merged_maps;
@ -226,14 +226,14 @@ public:
// Advance column offsets
auto & to_keys_offsets = to_keys_arr.getOffsets();
to_keys_offsets.push_back((to_keys_offsets.empty() ? 0 : to_keys_offsets.back()) + size);
to_keys_offsets.push_back(to_keys_offsets.back() + size);
to_keys_col.reserve(size);
for (size_t col = 0; col < values_types.size(); ++col)
{
auto & to_values_arr = static_cast<ColumnArray &>(to_tuple.getColumn(col + 1));
auto & to_values_offsets = to_values_arr.getOffsets();
to_values_offsets.push_back((to_values_offsets.empty() ? 0 : to_values_offsets.back()) + size);
to_values_offsets.push_back(to_values_offsets.back() + size);
to_values_arr.getData().reserve(size);
}

View File

@ -382,13 +382,13 @@ namespace detail
if (index == BIG_THRESHOLD)
break;
UInt64 count = 0;
readBinary(count, buf);
UInt64 elem_count = 0;
readBinary(elem_count, buf);
if (index < SMALL_THRESHOLD)
count_small[index] = count;
count_small[index] = elem_count;
else
count_big[index - SMALL_THRESHOLD] = count;
count_big[index - SMALL_THRESHOLD] = elem_count;
}
}
}

View File

@ -732,10 +732,10 @@ std::unique_ptr<Exception> Connection::receiveException()
std::vector<String> Connection::receiveMultistringMessage(UInt64 msg_type)
{
size_t num = Protocol::Server::stringsInMessage(msg_type);
std::vector<String> out(num);
std::vector<String> strings(num);
for (size_t i = 0; i < num; ++i)
readStringBinary(out[i], *in);
return out;
readStringBinary(strings[i], *in);
return strings;
}

View File

@ -52,7 +52,7 @@ MultiplexedConnections::MultiplexedConnections(
void MultiplexedConnections::sendExternalTablesData(std::vector<ExternalTablesData> & data)
{
std::lock_guard<std::mutex> lock(cancel_mutex);
std::lock_guard lock(cancel_mutex);
if (!sent_query)
throw Exception("Cannot send external tables data: query not yet sent.", ErrorCodes::LOGICAL_ERROR);
@ -79,7 +79,7 @@ void MultiplexedConnections::sendQuery(
const ClientInfo * client_info,
bool with_pending_data)
{
std::lock_guard<std::mutex> lock(cancel_mutex);
std::lock_guard lock(cancel_mutex);
if (sent_query)
throw Exception("Query already sent.", ErrorCodes::LOGICAL_ERROR);
@ -121,14 +121,14 @@ void MultiplexedConnections::sendQuery(
Connection::Packet MultiplexedConnections::receivePacket()
{
std::lock_guard<std::mutex> lock(cancel_mutex);
std::lock_guard lock(cancel_mutex);
Connection::Packet packet = receivePacketUnlocked();
return packet;
}
void MultiplexedConnections::disconnect()
{
std::lock_guard<std::mutex> lock(cancel_mutex);
std::lock_guard lock(cancel_mutex);
for (ReplicaState & state : replica_states)
{
@ -143,7 +143,7 @@ void MultiplexedConnections::disconnect()
void MultiplexedConnections::sendCancel()
{
std::lock_guard<std::mutex> lock(cancel_mutex);
std::lock_guard lock(cancel_mutex);
if (!sent_query || cancelled)
throw Exception("Cannot cancel. Either no query sent or already cancelled.", ErrorCodes::LOGICAL_ERROR);
@ -160,7 +160,7 @@ void MultiplexedConnections::sendCancel()
Connection::Packet MultiplexedConnections::drain()
{
std::lock_guard<std::mutex> lock(cancel_mutex);
std::lock_guard lock(cancel_mutex);
if (!cancelled)
throw Exception("Cannot drain connections: cancel first.", ErrorCodes::LOGICAL_ERROR);
@ -195,7 +195,7 @@ Connection::Packet MultiplexedConnections::drain()
std::string MultiplexedConnections::dumpAddresses() const
{
std::lock_guard<std::mutex> lock(cancel_mutex);
std::lock_guard lock(cancel_mutex);
return dumpAddressesUnlocked();
}

View File

@ -233,7 +233,10 @@ void ColumnArray::insertFrom(const IColumn & src_, size_t n)
void ColumnArray::insertDefault()
{
getOffsets().push_back(getOffsets().back());
/// NOTE 1: We can use back() even if the array is empty (due to zero -1th element in PODArray).
/// NOTE 2: We cannot use reference in push_back, because reference get invalidated if array is reallocated.
auto last_offset = getOffsets().back();
getOffsets().push_back(last_offset);
}

View File

@ -9,7 +9,7 @@
#include <IO/WriteHelpers.h>
#if __SSE2__
#ifdef __SSE2__
#include <emmintrin.h>
#endif
@ -169,7 +169,7 @@ ColumnPtr ColumnFixedString::filter(const IColumn::Filter & filt, ssize_t result
const UInt8 * filt_end = filt_pos + col_size;
const UInt8 * data_pos = chars.data();
#if __SSE2__
#ifdef __SSE2__
/** A slightly more optimized version.
* Based on the assumption that often pieces of consecutive values
* completely pass or do not pass the filter.

View File

@ -635,11 +635,11 @@ void ColumnLowCardinality::Dictionary::checkColumn(const IColumn & column)
throw Exception("ColumnUnique expected as an argument of ColumnLowCardinality.", ErrorCodes::ILLEGAL_COLUMN);
}
void ColumnLowCardinality::Dictionary::setShared(const ColumnPtr & dictionary)
void ColumnLowCardinality::Dictionary::setShared(const ColumnPtr & column_unique_)
{
checkColumn(*dictionary);
checkColumn(*column_unique_);
column_unique = dictionary;
column_unique = column_unique_;
shared = true;
}

View File

@ -20,7 +20,7 @@ private:
public:
const char * getFamilyName() const override { return "Nothing"; }
MutableColumnPtr cloneDummy(size_t s) const override { return ColumnNothing::create(s); }
MutableColumnPtr cloneDummy(size_t s_) const override { return ColumnNothing::create(s_); }
bool canBeInsideNullable() const override { return true; }
};

View File

@ -66,9 +66,9 @@ public:
Int64 getInt(size_t n) const override { return getNestedColumn()->getInt(n); }
bool isNullAt(size_t n) const override { return is_nullable && n == getNullValueIndex(); }
StringRef serializeValueIntoArena(size_t n, Arena & arena, char const *& begin) const override;
void updateHashWithValue(size_t n, SipHash & hash) const override
void updateHashWithValue(size_t n, SipHash & hash_func) const override
{
return getNestedColumn()->updateHashWithValue(n, hash);
return getNestedColumn()->updateHashWithValue(n, hash_func);
}
int compareAt(size_t n, size_t m, const IColumn & rhs, int nan_direction_hint) const override;

View File

@ -13,7 +13,7 @@
#include <DataStreams/ColumnGathererStream.h>
#include <ext/bit_cast.h>
#if __SSE2__
#ifdef __SSE2__
#include <emmintrin.h>
#include <Columns/ColumnsCommon.h>
@ -162,7 +162,7 @@ ColumnPtr ColumnVector<T>::filter(const IColumn::Filter & filt, ssize_t result_s
const UInt8 * filt_end = filt_pos + size;
const T * data_pos = data.data();
#if __SSE2__
#ifdef __SSE2__
/** A slightly more optimized version.
* Based on the assumption that often pieces of consecutive values
* completely pass or do not pass the filter.

View File

@ -1,4 +1,4 @@
#if __SSE2__
#ifdef __SSE2__
#include <emmintrin.h>
#endif
@ -24,7 +24,7 @@ size_t countBytesInFilter(const IColumn::Filter & filt)
const Int8 * pos = reinterpret_cast<const Int8 *>(filt.data());
const Int8 * end = pos + filt.size();
#if __SSE2__ && __POPCNT__
#if defined(__SSE2__) && defined(__POPCNT__)
const __m128i zero16 = _mm_setzero_si128();
const Int8 * end64 = pos + filt.size() / 64 * 64;
@ -69,7 +69,7 @@ bool memoryIsZero(const void * data, size_t size)
const Int8 * pos = reinterpret_cast<const Int8 *>(data);
const Int8 * end = pos + size;
#if __SSE2__
#ifdef __SSE2__
const __m128 zero16 = _mm_setzero_ps();
const Int8 * end64 = pos + size / 64 * 64;
@ -205,17 +205,17 @@ namespace
/// copy array ending at *end_offset_ptr
const auto copy_array = [&] (const IColumn::Offset * offset_ptr)
{
const auto offset = offset_ptr == offsets_begin ? 0 : offset_ptr[-1];
const auto size = *offset_ptr - offset;
const auto arr_offset = offset_ptr == offsets_begin ? 0 : offset_ptr[-1];
const auto arr_size = *offset_ptr - arr_offset;
result_offsets_builder.insertOne(size);
result_offsets_builder.insertOne(arr_size);
const auto elems_size_old = res_elems.size();
res_elems.resize(elems_size_old + size);
memcpy(&res_elems[elems_size_old], &src_elems[offset], size * sizeof(T));
res_elems.resize(elems_size_old + arr_size);
memcpy(&res_elems[elems_size_old], &src_elems[arr_offset], arr_size * sizeof(T));
};
#if __SSE2__
#ifdef __SSE2__
const __m128i zero_vec = _mm_setzero_si128();
static constexpr size_t SIMD_BYTES = 16;
const auto filt_end_aligned = filt_pos + size / SIMD_BYTES * SIMD_BYTES;

View File

@ -330,7 +330,9 @@ public:
virtual bool lowCardinality() const { return false; }
virtual ~IColumn() {}
virtual ~IColumn() = default;
IColumn() = default;
IColumn(const IColumn &) = default;
/** Print column name, size, and recursively print all subcolumns.
*/

View File

@ -393,10 +393,10 @@ UInt64 ReverseIndex<IndexType, ColumnType>::insert(const StringRef & data)
if constexpr (use_saved_hash)
{
auto & data = saved_hash->getData();
if (data.size() <= num_rows)
data.resize(num_rows + 1);
data[num_rows] = hash;
auto & column_data = saved_hash->getData();
if (column_data.size() <= num_rows)
column_data.resize(num_rows + 1);
column_data[num_rows] = hash;
}
else
column->insertData(data.data, data.size);

View File

@ -10,6 +10,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#ifdef __clang__
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#pragma clang diagnostic ignored "-Wundef"
#endif
#include <gtest/gtest.h>

View File

@ -94,7 +94,11 @@ private:
Key key;
Payload payload;
void * ptr;
union
{
void * ptr;
char * char_ptr;
};
size_t size;
size_t refcount = 0;
void * chunk;
@ -231,7 +235,7 @@ public:
~Holder()
{
std::lock_guard<std::mutex> cache_lock(cache.mutex);
std::lock_guard cache_lock(cache.mutex);
if (--region.refcount == 0)
cache.lru_list.push_back(region);
cache.total_size_in_use -= region.size;
@ -301,12 +305,12 @@ private:
if (cleaned_up)
return;
std::lock_guard<std::mutex> token_lock(token->mutex);
std::lock_guard token_lock(token->mutex);
if (token->cleaned_up)
return;
std::lock_guard<std::mutex> cache_lock(token->cache.mutex);
std::lock_guard cache_lock(token->cache.mutex);
--token->refcount;
if (token->refcount == 0)
@ -349,7 +353,7 @@ private:
if (left_it->chunk == region.chunk && left_it->isFree())
{
region.size += left_it->size;
*reinterpret_cast<char **>(&region.ptr) -= left_it->size;
region.char_ptr-= left_it->size;
size_multimap.erase(size_multimap.iterator_to(*left_it));
adjacency_list.erase_and_dispose(left_it, [](RegionMetadata * elem) { elem->destroy(); });
}
@ -479,7 +483,7 @@ private:
size_multimap.erase(size_multimap.iterator_to(free_region));
free_region.size -= size;
*reinterpret_cast<char **>(&free_region.ptr) += size;
free_region.char_ptr += size;
size_multimap.insert(free_region);
adjacency_list.insert(adjacency_list.iterator_to(free_region), *allocated_region);
@ -536,7 +540,7 @@ public:
~ArrayCache()
{
std::lock_guard<std::mutex> cache_lock(mutex);
std::lock_guard cache_lock(mutex);
key_map.clear();
lru_list.clear();
@ -563,7 +567,7 @@ public:
{
InsertTokenHolder token_holder;
{
std::lock_guard<std::mutex> cache_lock(mutex);
std::lock_guard cache_lock(mutex);
auto it = key_map.find(key, RegionCompareByKey());
if (key_map.end() != it)
@ -584,7 +588,7 @@ public:
InsertToken * token = token_holder.token.get();
std::lock_guard<std::mutex> token_lock(token->mutex);
std::lock_guard token_lock(token->mutex);
token_holder.cleaned_up = token->cleaned_up;
@ -605,7 +609,7 @@ public:
RegionMetadata * region;
{
std::lock_guard<std::mutex> cache_lock(mutex);
std::lock_guard cache_lock(mutex);
region = allocate(size);
}
@ -626,14 +630,14 @@ public:
catch (...)
{
{
std::lock_guard<std::mutex> cache_lock(mutex);
std::lock_guard cache_lock(mutex);
freeRegion(*region);
}
throw;
}
}
std::lock_guard<std::mutex> cache_lock(mutex);
std::lock_guard cache_lock(mutex);
try
{
@ -692,7 +696,7 @@ public:
Statistics getStatistics() const
{
std::lock_guard<std::mutex> cache_lock(mutex);
std::lock_guard cache_lock(mutex);
Statistics res;
res.total_chunks_size = total_chunks_size;

View File

@ -22,7 +22,7 @@ namespace ErrorCodes
* simulates an array of `content_width`-bit values.
*/
template <typename BucketIndex, UInt8 content_width, size_t bucket_count>
class __attribute__ ((packed)) CompactArray final
class CompactArray final
{
public:
class Reader;

View File

@ -600,9 +600,9 @@ void ConfigProcessor::savePreprocessedConfig(const LoadedConfig & loaded_config,
}
preprocessed_path = preprocessed_dir + new_path;
auto path = Poco::Path(preprocessed_path).makeParent();
if (!path.toString().empty())
Poco::File(path).createDirectories();
auto preprocessed_path_parent = Poco::Path(preprocessed_path).makeParent();
if (!preprocessed_path_parent.toString().empty())
Poco::File(preprocessed_path_parent).createDirectories();
}
try
{

View File

@ -78,7 +78,7 @@ void ConfigReloader::run()
void ConfigReloader::reloadIfNewer(bool force, bool throw_on_error, bool fallback_to_preprocessed)
{
std::lock_guard<std::mutex> lock(reload_mutex);
std::lock_guard lock(reload_mutex);
FilesChangesTracker new_files = getNewFileList();
if (force || need_reload_from_zk || new_files.isDifferOrNewerThan(files))

View File

@ -54,7 +54,7 @@ public:
template <typename Callback>
Int64 add(Int64 delta, Callback && locked_callback, bool create_if_need = false)
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
Int64 res = -1;

View File

@ -146,7 +146,7 @@ void FileChecker::load(Map & local_map, const std::string & path)
JSON json(out.str());
JSON files = json["yandex"];
for (const auto & name_value : files)
for (const JSON name_value : files)
local_map[unescapeForFileName(name_value.getName())] = name_value.getValue()["size"].toUInt();
}

View File

@ -35,20 +35,20 @@ inline DB::UInt64 intHash64(DB::UInt64 x)
* due to high speed (latency 3 + 1 clock cycle, throughput 1 clock cycle).
* Works only with SSE 4.2 support.
*/
#if __SSE4_2__
#ifdef __SSE4_2__
#include <nmmintrin.h>
#endif
#if __aarch64__ && __ARM_FEATURE_CRC32
#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
#include <arm_acle.h>
#include <arm_neon.h>
#endif
inline DB::UInt64 intHashCRC32(DB::UInt64 x)
{
#if __SSE4_2__
#ifdef __SSE4_2__
return _mm_crc32_u64(-1ULL, x);
#elif __aarch64__ && __ARM_FEATURE_CRC32
#elif defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
return __crc32cd(-1U, x);
#else
/// On other platforms we do not have CRC32. NOTE This can be confusing.

View File

@ -278,7 +278,7 @@ template <
typename BiasEstimator = TrivialBiasEstimator,
HyperLogLogMode mode = HyperLogLogMode::FullFeatured,
DenominatorMode denominator_mode = DenominatorMode::StableIfBig>
class __attribute__ ((packed)) HyperLogLogCounter : private Hash
class HyperLogLogCounter : private Hash
{
private:
/// Number of buckets.

View File

@ -48,7 +48,7 @@ public:
MappedPtr get(const Key & key)
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
auto res = getImpl(key, lock);
if (res)
@ -61,7 +61,7 @@ public:
void set(const Key & key, const MappedPtr & mapped)
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
setImpl(key, mapped, lock);
}
@ -79,7 +79,7 @@ public:
{
InsertTokenHolder token_holder;
{
std::lock_guard<std::mutex> cache_lock(mutex);
std::lock_guard cache_lock(mutex);
auto val = getImpl(key, cache_lock);
if (val)
@ -97,7 +97,7 @@ public:
InsertToken * token = token_holder.token.get();
std::lock_guard<std::mutex> token_lock(token->mutex);
std::lock_guard token_lock(token->mutex);
token_holder.cleaned_up = token->cleaned_up;
@ -111,7 +111,7 @@ public:
++misses;
token->value = load_func();
std::lock_guard<std::mutex> cache_lock(mutex);
std::lock_guard cache_lock(mutex);
/// Insert the new value only if the token is still in present in insert_tokens.
/// (The token may be absent because of a concurrent reset() call).
@ -131,26 +131,26 @@ public:
void getStats(size_t & out_hits, size_t & out_misses) const
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
out_hits = hits;
out_misses = misses;
}
size_t weight() const
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
return current_size;
}
size_t count() const
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
return cells.size();
}
void reset()
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
queue.clear();
cells.clear();
insert_tokens.clear();
@ -234,12 +234,12 @@ private:
if (cleaned_up)
return;
std::lock_guard<std::mutex> token_lock(token->mutex);
std::lock_guard token_lock(token->mutex);
if (token->cleaned_up)
return;
std::lock_guard<std::mutex> cache_lock(token->cache.mutex);
std::lock_guard cache_lock(token->cache.mutex);
--token->refcount;
if (token->refcount == 0)

View File

@ -38,7 +38,7 @@ protected:
void operator()(T * owning_ptr) const
{
std::lock_guard<std::mutex> lock{parent->mutex};
std::lock_guard lock{parent->mutex};
parent->stack.emplace(owning_ptr);
}
};
@ -51,7 +51,7 @@ public:
template <typename Factory>
Pointer get(Factory && f)
{
std::unique_lock<std::mutex> lock(mutex);
std::unique_lock lock(mutex);
if (stack.empty())
{
@ -94,7 +94,7 @@ public:
template <typename Factory>
Pointer get(const Key & key, Factory && f)
{
std::unique_lock<std::mutex> lock(mutex);
std::unique_lock lock(mutex);
auto it = container.find(key);
if (container.end() == it)

View File

@ -127,9 +127,6 @@ protected:
c_end = c_start + end_diff;
c_end_of_storage = c_start + bytes - pad_right - pad_left;
if (pad_left)
memset(c_start - ELEMENT_SIZE, 0, ELEMENT_SIZE);
}
bool isInitialized() const
@ -312,13 +309,13 @@ public:
this->c_end = this->c_start + this->byte_size(n);
}
template <typename ... TAllocatorParams>
void push_back(const T & x, TAllocatorParams &&... allocator_params)
template <typename U, typename ... TAllocatorParams>
void push_back(U && x, TAllocatorParams &&... allocator_params)
{
if (unlikely(this->c_end == this->c_end_of_storage))
this->reserveForNextSize(std::forward<TAllocatorParams>(allocator_params)...);
*t_end() = x;
new (t_end()) T(std::forward<U>(x));
this->c_end += this->byte_size(1);
}

View File

@ -54,7 +54,7 @@ private:
PoolEntryHelper(PooledObject & data_) : data(data_) { data.in_use = true; }
~PoolEntryHelper()
{
std::unique_lock<std::mutex> lock(data.pool.mutex);
std::unique_lock lock(data.pool.mutex);
data.in_use = false;
data.pool.available.notify_one();
}
@ -107,7 +107,7 @@ public:
/** Allocates the object. Wait for free object in pool for 'timeout'. With 'timeout' < 0, the timeout is infinite. */
Entry get(Poco::Timespan::TimeDiff timeout)
{
std::unique_lock<std::mutex> lock(mutex);
std::unique_lock lock(mutex);
while (true)
{
@ -133,7 +133,7 @@ public:
void reserve(size_t count)
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
while (items.size() < count)
items.emplace_back(std::make_shared<PooledObject>(allocObject(), *this));

View File

@ -195,7 +195,7 @@ PoolWithFailoverBase<TNestedPool>::getMany(
/// At exit update shared error counts with error counts occured during this call.
SCOPE_EXIT(
{
std::lock_guard<std::mutex> lock(pool_states_mutex);
std::lock_guard lock(pool_states_mutex);
for (const ShuffledPool & pool: shuffled_pools)
shared_pool_states[pool.index].error_count += pool.error_count;
});
@ -300,7 +300,7 @@ void PoolWithFailoverBase<TNestedPool>::reportError(const Entry & entry)
{
if (nested_pools[i]->contains(entry))
{
std::lock_guard<std::mutex> lock(pool_states_mutex);
std::lock_guard lock(pool_states_mutex);
++shared_pool_states[i].error_count;
return;
}
@ -338,7 +338,7 @@ PoolWithFailoverBase<TNestedPool>::updatePoolStates()
result.reserve(nested_pools.size());
{
std::lock_guard<std::mutex> lock(pool_states_mutex);
std::lock_guard lock(pool_states_mutex);
for (auto & state : shared_pool_states)
state.randomize();

View File

@ -70,7 +70,7 @@ RWLockImpl::LockHandler RWLockImpl::getLock(RWLockImpl::Type type)
GroupsContainer::iterator it_group;
ClientsContainer::iterator it_client;
std::unique_lock<std::mutex> lock(mutex);
std::unique_lock lock(mutex);
/// Check if the same thread is acquiring previously acquired lock
auto it_handler = thread_to_handler.find(this_thread_id);
@ -139,7 +139,7 @@ RWLockImpl::LockHandler RWLockImpl::getLock(RWLockImpl::Type type)
RWLockImpl::LockHandlerImpl::~LockHandlerImpl()
{
std::unique_lock<std::mutex> lock(parent->mutex);
std::unique_lock lock(parent->mutex);
/// Remove weak_ptr to the handler, since there are no owners of the current lock
parent->thread_to_handler.erase(it_handler);

View File

@ -28,37 +28,29 @@ namespace
{
struct Pipe
{
union
{
int fds[2];
struct
{
int read_fd;
int write_fd;
};
};
int fds_rw[2];
Pipe()
{
#ifndef __APPLE__
if (0 != pipe2(fds, O_CLOEXEC))
if (0 != pipe2(fds_rw, O_CLOEXEC))
DB::throwFromErrno("Cannot create pipe", DB::ErrorCodes::CANNOT_PIPE);
#else
if (0 != pipe(fds))
DB::throwFromErrno("Cannot create pipe", DB::ErrorCodes::CANNOT_PIPE);
if (0 != fcntl(fds[0], F_SETFD, FD_CLOEXEC))
if (0 != fcntl(fds_rw[0], F_SETFD, FD_CLOEXEC))
DB::throwFromErrno("Cannot create pipe", DB::ErrorCodes::CANNOT_PIPE);
if (0 != fcntl(fds[1], F_SETFD, FD_CLOEXEC))
if (0 != fcntl(fds_rw[1], F_SETFD, FD_CLOEXEC))
DB::throwFromErrno("Cannot create pipe", DB::ErrorCodes::CANNOT_PIPE);
#endif
}
~Pipe()
{
if (read_fd >= 0)
close(read_fd);
if (write_fd >= 0)
close(write_fd);
if (fds_rw[0] >= 0)
close(fds_rw[0]);
if (fds_rw[1] >= 0)
close(fds_rw[1]);
}
};
@ -125,15 +117,15 @@ std::unique_ptr<ShellCommand> ShellCommand::executeImpl(const char * filename, c
/// And there is a lot of garbage (including, for example, mutex is blocked). And this can not be done after `vfork` - deadlock happens.
/// Replace the file descriptors with the ends of our pipes.
if (STDIN_FILENO != dup2(pipe_stdin.read_fd, STDIN_FILENO))
if (STDIN_FILENO != dup2(pipe_stdin.fds_rw[0], STDIN_FILENO))
_exit(int(ReturnCodes::CANNOT_DUP_STDIN));
if (!pipe_stdin_only)
{
if (STDOUT_FILENO != dup2(pipe_stdout.write_fd, STDOUT_FILENO))
if (STDOUT_FILENO != dup2(pipe_stdout.fds_rw[1], STDOUT_FILENO))
_exit(int(ReturnCodes::CANNOT_DUP_STDOUT));
if (STDERR_FILENO != dup2(pipe_stderr.write_fd, STDERR_FILENO))
if (STDERR_FILENO != dup2(pipe_stderr.fds_rw[1], STDERR_FILENO))
_exit(int(ReturnCodes::CANNOT_DUP_STDERR));
}
@ -143,12 +135,12 @@ std::unique_ptr<ShellCommand> ShellCommand::executeImpl(const char * filename, c
_exit(int(ReturnCodes::CANNOT_EXEC));
}
std::unique_ptr<ShellCommand> res(new ShellCommand(pid, pipe_stdin.write_fd, pipe_stdout.read_fd, pipe_stderr.read_fd, terminate_in_destructor));
std::unique_ptr<ShellCommand> res(new ShellCommand(pid, pipe_stdin.fds_rw[1], pipe_stdout.fds_rw[0], pipe_stderr.fds_rw[0], terminate_in_destructor));
/// Now the ownership of the file descriptors is passed to the result.
pipe_stdin.write_fd = -1;
pipe_stdout.read_fd = -1;
pipe_stderr.read_fd = -1;
pipe_stdin.fds_rw[1] = -1;
pipe_stdout.fds_rw[0] = -1;
pipe_stderr.fds_rw[0] = -1;
return res;
}
@ -158,8 +150,8 @@ std::unique_ptr<ShellCommand> ShellCommand::execute(const std::string & command,
{
/// Arguments in non-constant chunks of memory (as required for `execv`).
/// Moreover, their copying must be done before calling `vfork`, so after `vfork` do a minimum of things.
std::vector<char> argv0("sh", "sh" + strlen("sh") + 1);
std::vector<char> argv1("-c", "-c" + strlen("-c") + 1);
std::vector<char> argv0("sh", &("sh"[3]));
std::vector<char> argv1("-c", &("-c"[3]));
std::vector<char> argv2(command.data(), command.data() + command.size() + 1);
char * const argv[] = { argv0.data(), argv1.data(), argv2.data(), nullptr };

View File

@ -32,7 +32,7 @@ public:
Result operator() (Args &&... args)
{
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
Key key{std::forward<Args>(args)...};
auto it = cache.find(key);
@ -45,7 +45,7 @@ public:
Result res = f(std::forward<Args>(args)...);
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
cache.emplace(std::forward_as_tuple(args...), res);
}
@ -55,7 +55,7 @@ public:
void drop()
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
cache.clear();
}
};

View File

@ -32,11 +32,10 @@ StackTrace::StackTrace()
std::string StackTrace::toStringImpl(const Frames & frames, size_t frames_size)
{
char ** symbols = backtrace_symbols(frames.data(), frames_size);
std::stringstream res;
if (!symbols)
return "Cannot get symbols for stack trace.\n";
std::stringstream res;
try
{
for (size_t i = 0, size = frames_size; i < size; ++i)

View File

@ -7,11 +7,11 @@
#include <stdint.h>
#include <string.h>
#if __SSE2__
#ifdef __SSE2__
#include <emmintrin.h>
#endif
#if __SSE4_1__
#ifdef __SSE4_1__
#include <smmintrin.h>
#endif
@ -32,7 +32,7 @@ namespace ErrorCodes
struct StringSearcherBase
{
#if __SSE2__
#ifdef __SSE2__
static constexpr auto n = sizeof(__m128i);
const int page_size = getpagesize();
@ -63,7 +63,7 @@ private:
UInt8 l{};
UInt8 u{};
#if __SSE4_1__
#ifdef __SSE4_1__
/// vectors filled with `l` and `u`, for determining leftmost position of the first symbol
__m128i patl, patu;
/// lower and uppercase vectors of first 16 characters of `needle`
@ -102,7 +102,7 @@ public:
u = u_seq[0];
}
#if __SSE4_1__
#ifdef __SSE4_1__
/// for detecting leftmost position of the first symbol
patl = _mm_set1_epi8(l);
patu = _mm_set1_epi8(u);
@ -160,7 +160,7 @@ public:
{
static const Poco::UTF8Encoding utf8;
#if __SSE4_1__
#ifdef __SSE4_1__
if (pageSafe(pos))
{
const auto v_haystack = _mm_loadu_si128(reinterpret_cast<const __m128i *>(pos));
@ -227,7 +227,7 @@ public:
while (haystack < haystack_end)
{
#if __SSE4_1__
#ifdef __SSE4_1__
if (haystack + n <= haystack_end && pageSafe(haystack))
{
const auto v_haystack = _mm_loadu_si128(reinterpret_cast<const __m128i *>(haystack));
@ -249,15 +249,15 @@ public:
if (haystack < haystack_end && haystack + n <= haystack_end && pageSafe(haystack))
{
const auto v_haystack = _mm_loadu_si128(reinterpret_cast<const __m128i *>(haystack));
const auto v_against_l = _mm_cmpeq_epi8(v_haystack, cachel);
const auto v_against_u = _mm_cmpeq_epi8(v_haystack, cacheu);
const auto v_against_l_or_u = _mm_or_si128(v_against_l, v_against_u);
const auto mask = _mm_movemask_epi8(v_against_l_or_u);
const auto v_haystack_offset = _mm_loadu_si128(reinterpret_cast<const __m128i *>(haystack));
const auto v_against_l_offset = _mm_cmpeq_epi8(v_haystack_offset, cachel);
const auto v_against_u_offset = _mm_cmpeq_epi8(v_haystack_offset, cacheu);
const auto v_against_l_or_u_offset = _mm_or_si128(v_against_l_offset, v_against_u_offset);
const auto mask_offset = _mm_movemask_epi8(v_against_l_or_u_offset);
if (0xffff == cachemask)
{
if (mask == cachemask)
if (mask_offset == cachemask)
{
auto haystack_pos = haystack + cache_valid_len;
auto needle_pos = needle + cache_valid_len;
@ -276,7 +276,7 @@ public:
return haystack;
}
}
else if ((mask & cachemask) == cachemask)
else if ((mask_offset & cachemask) == cachemask)
return haystack;
/// first octet was ok, but not the first 16, move to start of next sequence and reapply
@ -334,7 +334,7 @@ private:
UInt8 l{};
UInt8 u{};
#if __SSE4_1__
#ifdef __SSE4_1__
/// vectors filled with `l` and `u`, for determining leftmost position of the first symbol
__m128i patl, patu;
/// lower and uppercase vectors of first 16 characters of `needle`
@ -352,7 +352,7 @@ public:
l = static_cast<UInt8>(std::tolower(*needle));
u = static_cast<UInt8>(std::toupper(*needle));
#if __SSE4_1__
#ifdef __SSE4_1__
patl = _mm_set1_epi8(l);
patu = _mm_set1_epi8(u);
@ -376,7 +376,7 @@ public:
bool compare(const UInt8 * pos) const
{
#if __SSE4_1__
#ifdef __SSE4_1__
if (pageSafe(pos))
{
const auto v_haystack = _mm_loadu_si128(reinterpret_cast<const __m128i *>(pos));
@ -434,7 +434,7 @@ public:
while (haystack < haystack_end)
{
#if __SSE4_1__
#ifdef __SSE4_1__
if (haystack + n <= haystack_end && pageSafe(haystack))
{
const auto v_haystack = _mm_loadu_si128(reinterpret_cast<const __m128i *>(haystack));
@ -455,15 +455,15 @@ public:
if (haystack < haystack_end && haystack + n <= haystack_end && pageSafe(haystack))
{
const auto v_haystack = _mm_loadu_si128(reinterpret_cast<const __m128i *>(haystack));
const auto v_against_l = _mm_cmpeq_epi8(v_haystack, cachel);
const auto v_against_u = _mm_cmpeq_epi8(v_haystack, cacheu);
const auto v_against_l_or_u = _mm_or_si128(v_against_l, v_against_u);
const auto mask = _mm_movemask_epi8(v_against_l_or_u);
const auto v_haystack_offset = _mm_loadu_si128(reinterpret_cast<const __m128i *>(haystack));
const auto v_against_l_offset = _mm_cmpeq_epi8(v_haystack_offset, cachel);
const auto v_against_u_offset = _mm_cmpeq_epi8(v_haystack_offset, cacheu);
const auto v_against_l_or_u_offset = _mm_or_si128(v_against_l_offset, v_against_u_offset);
const auto mask_offset = _mm_movemask_epi8(v_against_l_or_u_offset);
if (0xffff == cachemask)
{
if (mask == cachemask)
if (mask_offset == cachemask)
{
auto haystack_pos = haystack + n;
auto needle_pos = needle + n;
@ -479,7 +479,7 @@ public:
return haystack;
}
}
else if ((mask & cachemask) == cachemask)
else if ((mask_offset & cachemask) == cachemask)
return haystack;
++haystack;
@ -532,7 +532,7 @@ private:
/// first character in `needle`
UInt8 first{};
#if __SSE4_1__
#ifdef __SSE4_1__
/// vector filled `first` for determining leftmost position of the first symbol
__m128i pattern;
/// vector of first 16 characters of `needle`
@ -549,7 +549,7 @@ public:
first = *needle;
#if __SSE4_1__
#ifdef __SSE4_1__
pattern = _mm_set1_epi8(first);
auto needle_pos = needle;
@ -570,7 +570,7 @@ public:
bool compare(const UInt8 * pos) const
{
#if __SSE4_1__
#ifdef __SSE4_1__
if (pageSafe(pos))
{
const auto v_haystack = _mm_loadu_si128(reinterpret_cast<const __m128i *>(pos));
@ -620,7 +620,7 @@ public:
while (haystack < haystack_end)
{
#if __SSE4_1__
#ifdef __SSE4_1__
if (haystack + n <= haystack_end && pageSafe(haystack))
{
/// find first character
@ -642,13 +642,13 @@ public:
if (haystack < haystack_end && haystack + n <= haystack_end && pageSafe(haystack))
{
/// check for first 16 octets
const auto v_haystack = _mm_loadu_si128(reinterpret_cast<const __m128i *>(haystack));
const auto v_against_cache = _mm_cmpeq_epi8(v_haystack, cache);
const auto mask = _mm_movemask_epi8(v_against_cache);
const auto v_haystack_offset = _mm_loadu_si128(reinterpret_cast<const __m128i *>(haystack));
const auto v_against_cache = _mm_cmpeq_epi8(v_haystack_offset, cache);
const auto mask_offset = _mm_movemask_epi8(v_against_cache);
if (0xffff == cachemask)
{
if (mask == cachemask)
if (mask_offset == cachemask)
{
auto haystack_pos = haystack + n;
auto needle_pos = needle + n;
@ -661,7 +661,7 @@ public:
return haystack;
}
}
else if ((mask & cachemask) == cachemask)
else if ((mask_offset & cachemask) == cachemask)
return haystack;
++haystack;

View File

@ -56,7 +56,7 @@ std::string getOrdinalSuffix(T n)
case 2: return "nd";
case 3: return "rd";
default: return "th";
};
}
}
/// More efficient than libc, because doesn't respect locale. But for some functions table implementation could be better.

View File

@ -80,11 +80,6 @@ struct NetlinkMessage
::nlmsgerr error;
};
size_t payload_size() const
{
return header.nlmsg_len - sizeof(header) - sizeof(generic_header);
}
const Attribute * end() const
{
return reinterpret_cast<const Attribute *>(reinterpret_cast<const char *>(this) + header.nlmsg_len);

View File

@ -6,7 +6,7 @@
#include <Core/Types.h>
#if __SSE4_2__
#ifdef __SSE4_2__
#include <nmmintrin.h>
#endif
@ -75,7 +75,7 @@ struct UInt128Hash
}
};
#if __SSE4_2__
#ifdef __SSE4_2__
struct UInt128HashCRC32
{
@ -153,7 +153,7 @@ struct UInt256Hash
}
};
#if __SSE4_2__
#ifdef __SSE4_2__
struct UInt256HashCRC32
{

View File

@ -3,7 +3,7 @@
#include <Core/Types.h>
#include <Common/BitHelpers.h>
#if __SSE2__
#ifdef __SSE2__
#include <emmintrin.h>
#endif
@ -55,7 +55,7 @@ inline size_t countCodePoints(const UInt8 * data, size_t size)
size_t res = 0;
const auto end = data + size;
#if __SSE2__
#ifdef __SSE2__
constexpr auto bytes_sse = sizeof(__m128i);
const auto src_end_sse = data + size / bytes_sse * bytes_sse;

View File

@ -194,9 +194,9 @@ template <bool CaseSensitive, bool ASCII> struct VolnitskyImpl;
/// Case sensitive comparison
template <bool ASCII> struct VolnitskyImpl<true, ASCII> : VolnitskyBase<VolnitskyImpl<true, ASCII>>
{
VolnitskyImpl(const char * const needle, const size_t needle_size, const size_t haystack_size_hint = 0)
: VolnitskyBase<VolnitskyImpl<true, ASCII>>{needle, needle_size, haystack_size_hint},
fallback_searcher{needle, needle_size}
VolnitskyImpl(const char * const needle_, const size_t needle_size_, const size_t haystack_size_hint = 0)
: VolnitskyBase<VolnitskyImpl<true, ASCII>>{needle_, needle_size_, haystack_size_hint},
fallback_searcher{needle_, needle_size_}
{
}
@ -222,8 +222,8 @@ template <bool ASCII> struct VolnitskyImpl<true, ASCII> : VolnitskyBase<Volnitsk
/// Case-insensitive ASCII
template <> struct VolnitskyImpl<false, true> : VolnitskyBase<VolnitskyImpl<false, true>>
{
VolnitskyImpl(const char * const needle, const size_t needle_size, const size_t haystack_size_hint = 0)
: VolnitskyBase{needle, needle_size, haystack_size_hint}, fallback_searcher{needle, needle_size}
VolnitskyImpl(const char * const needle_, const size_t needle_size_, const size_t haystack_size_hint = 0)
: VolnitskyBase{needle_, needle_size_, haystack_size_hint}, fallback_searcher{needle_, needle_size_}
{
}
@ -248,8 +248,8 @@ template <> struct VolnitskyImpl<false, true> : VolnitskyBase<VolnitskyImpl<fals
/// Case-sensitive UTF-8
template <> struct VolnitskyImpl<false, false> : VolnitskyBase<VolnitskyImpl<false, false>>
{
VolnitskyImpl(const char * const needle, const size_t needle_size, const size_t haystack_size_hint = 0)
: VolnitskyBase{needle, needle_size, haystack_size_hint}, fallback_searcher{needle, needle_size}
VolnitskyImpl(const char * const needle_, const size_t needle_size_, const size_t haystack_size_hint = 0)
: VolnitskyBase{needle_, needle_size_, haystack_size_hint}, fallback_searcher{needle_, needle_size_}
{
}

View File

@ -59,7 +59,9 @@ using Requests = std::vector<RequestPtr>;
struct Request
{
virtual ~Request() {}
Request() = default;
Request(const Request &) = default;
virtual ~Request() = default;
virtual String getPath() const = 0;
virtual void addRootPath(const String & /* root_path */) {}
};
@ -72,7 +74,9 @@ using ResponseCallback = std::function<void(const Response &)>;
struct Response
{
int32_t error = 0;
virtual ~Response() {}
Response() = default;
Response(const Response &) = default;
virtual ~Response() = default;
virtual void removeRootPath(const String & /* root_path */) {}
};

View File

@ -17,7 +17,6 @@
#define ZOOKEEPER_CONNECTION_TIMEOUT_MS 1000
#define ZOOKEEPER_OPERATION_TIMEOUT_MS 10000
namespace DB
@ -840,7 +839,7 @@ int32_t ZooKeeper::tryMultiNoThrow(const Coordination::Requests & requests, Coor
}
size_t KeeperMultiException::getFailedOpIndex(int32_t code, const Coordination::Responses & responses)
size_t KeeperMultiException::getFailedOpIndex(int32_t exception_code, const Coordination::Responses & responses)
{
if (responses.empty())
throw DB::Exception("Responses for multi transaction is empty", DB::ErrorCodes::LOGICAL_ERROR);
@ -849,17 +848,17 @@ size_t KeeperMultiException::getFailedOpIndex(int32_t code, const Coordination::
if (responses[index]->error)
return index;
if (!Coordination::isUserError(code))
throw DB::Exception("There are no failed OPs because '" + ZooKeeper::error2string(code) + "' is not valid response code for that",
if (!Coordination::isUserError(exception_code))
throw DB::Exception("There are no failed OPs because '" + ZooKeeper::error2string(exception_code) + "' is not valid response code for that",
DB::ErrorCodes::LOGICAL_ERROR);
throw DB::Exception("There is no failed OpResult", DB::ErrorCodes::LOGICAL_ERROR);
}
KeeperMultiException::KeeperMultiException(int32_t code, const Coordination::Requests & requests, const Coordination::Responses & responses)
: KeeperException("Transaction failed", code),
requests(requests), responses(responses), failed_op_index(getFailedOpIndex(code, responses))
KeeperMultiException::KeeperMultiException(int32_t exception_code, const Coordination::Requests & requests, const Coordination::Responses & responses)
: KeeperException("Transaction failed", exception_code),
requests(requests), responses(responses), failed_op_index(getFailedOpIndex(exception_code, responses))
{
addMessage("Op #" + std::to_string(failed_op_index) + ", path: " + getPathForFirstFailedOp());
}
@ -870,15 +869,15 @@ std::string KeeperMultiException::getPathForFirstFailedOp() const
return requests[failed_op_index]->getPath();
}
void KeeperMultiException::check(int32_t code, const Coordination::Requests & requests, const Coordination::Responses & responses)
void KeeperMultiException::check(int32_t exception_code, const Coordination::Requests & requests, const Coordination::Responses & responses)
{
if (!code)
if (!exception_code)
return;
if (Coordination::isUserError(code))
throw KeeperMultiException(code, requests, responses);
if (Coordination::isUserError(exception_code))
throw KeeperMultiException(exception_code, requests, responses);
else
throw KeeperException(code);
throw KeeperException(exception_code);
}

View File

@ -14,7 +14,7 @@ using namespace zkutil;
ZooKeeperHolder::UnstorableZookeeperHandler ZooKeeperHolder::getZooKeeper()
{
std::unique_lock<std::mutex> lock(mutex);
std::unique_lock lock(mutex);
return UnstorableZookeeperHandler(ptr);
}
@ -25,7 +25,7 @@ void ZooKeeperHolder::initFromInstance(const ZooKeeper::Ptr & zookeeper_ptr)
bool ZooKeeperHolder::replaceZooKeeperSessionToNewOne()
{
std::unique_lock<std::mutex> lock(mutex);
std::unique_lock lock(mutex);
if (ptr.unique())
{

View File

@ -1181,9 +1181,9 @@ void ZooKeeper::receiveEvent()
ProfileEvents::increment(ProfileEvents::ZooKeeperWatchResponse);
response = std::make_shared<ZooKeeperWatchResponse>();
request_info.callback = [this](const Response & response)
request_info.callback = [this](const Response & response_)
{
const WatchResponse & watch_response = dynamic_cast<const WatchResponse &>(response);
const WatchResponse & watch_response = dynamic_cast<const WatchResponse &>(response_);
std::lock_guard lock(watches_mutex);

View File

@ -252,7 +252,9 @@ struct ZooKeeperRequest : virtual Request
/// If the request was sent and we didn't get the response and the error happens, then we cannot be sure was it processed or not.
bool probably_sent = false;
virtual ~ZooKeeperRequest() {}
ZooKeeperRequest() = default;
ZooKeeperRequest(const ZooKeeperRequest &) = default;
virtual ~ZooKeeperRequest() = default;
virtual ZooKeeper::OpNum getOpNum() const = 0;

View File

@ -22,7 +22,7 @@ ZooKeeperNodeCache::ZNode ZooKeeperNodeCache::get(const std::string & path, Coor
{
std::unordered_set<std::string> invalidated_paths;
{
std::lock_guard<std::mutex> lock(context->mutex);
std::lock_guard lock(context->mutex);
if (context->all_paths_invalidated)
{
@ -57,7 +57,7 @@ ZooKeeperNodeCache::ZNode ZooKeeperNodeCache::get(const std::string & path, Coor
bool changed = false;
{
std::lock_guard<std::mutex> lock(owned_context->mutex);
std::lock_guard lock(owned_context->mutex);
if (response.type != Coordination::SESSION)
changed = owned_context->invalidated_paths.emplace(response.path).second;

View File

@ -8,6 +8,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#ifdef __clang__
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#pragma clang diagnostic ignored "-Wundef"
#endif
#include <gtest/gtest.h>

View File

@ -63,6 +63,4 @@ int main(int argc, char ** argv)
std::cerr << "Some exception" << std::endl;
return 2;
}
return 0;
}

View File

@ -67,6 +67,4 @@ int main(int argc, char ** argv)
std::cerr << "Some exception: " << DB::getCurrentExceptionMessage(true) << std::endl;
return 2;
}
return 0;
}

View File

@ -3,7 +3,7 @@
#include <string.h>
#include <Core/Defines.h>
#if __SSE2__
#ifdef __SSE2__
#include <emmintrin.h>

View File

@ -60,7 +60,7 @@ int main(int argc, char ** argv)
{
pcg64 generator(randomSeed());
for (size_t i = 0; i < num_iterations; ++i)
for (size_t j = 0; j < num_iterations; ++j)
{
size_t size = std::uniform_int_distribution<size_t>(1, region_max_size)(generator);
int key = std::uniform_int_distribution<int>(1, max_key)(generator);
@ -70,8 +70,8 @@ int main(int argc, char ** argv)
[=]{ return size; },
[=](void * /*ptr*/, int & payload)
{
payload = i;
// memset(ptr, i, size);
payload = j;
// memset(ptr, j, size);
},
nullptr);

View File

@ -9,7 +9,9 @@ private:
virtual MutablePtr clone() const = 0;
public:
virtual ~IColumn() {}
IColumn() = default;
IColumn(const IColumn &) = default;
virtual ~IColumn() = default;
virtual int get() const = 0;
virtual void set(int value) = 0;

View File

@ -1,6 +1,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#ifdef __clang__
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#pragma clang diagnostic ignored "-Wundef"
#endif
#include <gtest/gtest.h>

View File

@ -3,6 +3,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#ifdef __clang__
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#pragma clang diagnostic ignored "-Wundef"
#endif
#include <gtest/gtest.h>

View File

@ -171,7 +171,7 @@ namespace Hashes
}
};
#if __SSE4_2__
#ifdef __SSE4_2__
#include <nmmintrin.h>
#endif
@ -179,7 +179,7 @@ namespace Hashes
{
size_t operator()(Key x) const
{
#if __SSE4_2__
#ifdef __SSE4_2__
return _mm_crc32_u64(-1ULL, x);
#else
/// On other platforms we do not have CRC32. NOTE This can be confusing.

View File

@ -186,8 +186,8 @@ struct MergeParallelForTwoLevelTable
for (size_t i = 0; i < num_maps; ++i)
section[i] = &source_maps[i]->impls[bucket];
typename Map::Impl * result_map;
ImplMerge::execute(section.data(), num_maps, result_map, merger, pool);
typename Map::Impl * res;
ImplMerge::execute(section.data(), num_maps, res, merger, pool);
});
pool.wait();

View File

@ -9,6 +9,9 @@
#include <Parsers/IAST.h>
#include <Parsers/ASTLiteral.h>
#ifdef __clang__
#pragma clang diagnostic ignored "-Wold-style-cast"
#endif
namespace DB

View File

@ -10,15 +10,15 @@
#include <common/Types.h>
#include <common/unaligned.h>
#if __SSE2__
#ifdef __SSE2__
#include <emmintrin.h>
#endif
#if __SSSE3__
#ifdef __SSSE3__
#include <tmmintrin.h>
#endif
#if __aarch64__
#ifdef __aarch64__
#include <arm_neon.h>
#endif
@ -213,7 +213,7 @@ template <> void inline copyOverlap<8, true>(UInt8 * op, const UInt8 *& match, c
inline void copy16(UInt8 * dst, const UInt8 * src)
{
#if __SSE2__
#ifdef __SSE2__
_mm_storeu_si128(reinterpret_cast<__m128i *>(dst),
_mm_loadu_si128(reinterpret_cast<const __m128i *>(src)));
#else
@ -351,8 +351,8 @@ void NO_INLINE decompressImpl(
char * const dest,
size_t dest_size)
{
const UInt8 * ip = (UInt8 *)source;
UInt8 * op = (UInt8 *)dest;
const UInt8 * ip = reinterpret_cast<const UInt8 *>(source);
UInt8 * op = reinterpret_cast<UInt8 *>(dest);
UInt8 * const output_end = op + dest_size;
while (1)
@ -528,8 +528,8 @@ void statistics(
size_t dest_size,
StreamStatistics & stat)
{
const UInt8 * ip = (UInt8 *)source;
UInt8 * op = (UInt8 *)dest;
const UInt8 * ip = reinterpret_cast<const UInt8 *>(source);
UInt8 * op = reinterpret_cast<UInt8 *>(dest);
UInt8 * const output_end = op + dest_size;
while (1)

View File

@ -263,7 +263,8 @@ inline bool_if_not_safe_conversion<A, B> equalsOp(A a, B b)
template <typename A, typename B>
inline bool_if_safe_conversion<A, B> equalsOp(A a, B b)
{
return a == b;
using LargestType = std::conditional_t<sizeof(A) >= sizeof(B), A, B>;
return static_cast<LargestType>(a) == static_cast<LargestType>(b);
}
template <>

View File

@ -25,7 +25,7 @@ void BlockInfo::write(WriteBuffer & out) const
writeVarUInt(FIELD_NUM, out); \
writeBinary(NAME, out);
APPLY_FOR_BLOCK_INFO_FIELDS(WRITE_FIELD);
APPLY_FOR_BLOCK_INFO_FIELDS(WRITE_FIELD)
#undef WRITE_FIELD
writeVarUInt(0, out);
@ -49,7 +49,7 @@ void BlockInfo::read(ReadBuffer & in)
readBinary(NAME, in); \
break;
APPLY_FOR_BLOCK_INFO_FIELDS(READ_FIELD);
APPLY_FOR_BLOCK_INFO_FIELDS(READ_FIELD)
#undef READ_FIELD
default:

View File

@ -75,7 +75,7 @@ namespace DB
x.push_back(value);
break;
}
};
}
}
}
@ -128,7 +128,7 @@ namespace DB
DB::writeBinary(get<Tuple>(*it), buf);
break;
}
};
}
}
}
@ -209,7 +209,7 @@ namespace DB
x.push_back(value);
break;
}
};
}
}
}
@ -262,7 +262,7 @@ namespace DB
DB::writeBinary(get<Tuple>(*it), buf);
break;
}
};
}
}
}

View File

@ -449,9 +449,6 @@ private:
case Types::Decimal32: f(field.template get<DecimalField<Decimal32>>()); return;
case Types::Decimal64: f(field.template get<DecimalField<Decimal64>>()); return;
case Types::Decimal128: f(field.template get<DecimalField<Decimal128>>()); return;
default:
throw Exception("Bad type of Field", ErrorCodes::BAD_TYPE_OF_FIELD);
}
}

View File

@ -30,12 +30,14 @@ int main(int argc, char ** argv)
field2 = field;
std::cerr << applyVisitor(to_string, field2) << std::endl;
Array array;
array.push_back(UInt64(123));
array.push_back(Int64(-123));
array.push_back(String("Hello"));
field = array;
std::cerr << applyVisitor(to_string, field) << std::endl;
{
Array array;
array.push_back(UInt64(123));
array.push_back(Int64(-123));
array.push_back(String("Hello"));
field = array;
std::cerr << applyVisitor(to_string, field) << std::endl;
}
get<Array &>(field).push_back(field);
std::cerr << applyVisitor(to_string, field) << std::endl;
@ -54,7 +56,7 @@ int main(int argc, char ** argv)
Array array(n);
{
Stopwatch watch;
watch.restart();
for (size_t i = 0; i < n; ++i)
array[i] = String(i % 32, '!');
@ -67,7 +69,7 @@ int main(int argc, char ** argv)
}
{
Stopwatch watch;
watch.restart();
size_t sum = 0;
for (size_t i = 0; i < n; ++i)

View File

@ -5,5 +5,7 @@ namespace DB
{
BlockIO::~BlockIO() = default;
BlockIO::BlockIO() = default;
BlockIO::BlockIO(const BlockIO &) = default;
}

View File

@ -60,6 +60,8 @@ struct BlockIO
}
~BlockIO();
BlockIO();
BlockIO(const BlockIO &);
};
}

View File

@ -230,9 +230,6 @@ void IProfilingBlockInputStream::checkQuota(Block & block)
prev_elapsed = total_elapsed;
break;
}
default:
throw Exception("Logical error: unknown limits mode.", ErrorCodes::LOGICAL_ERROR);
}
}

View File

@ -127,7 +127,7 @@ void MergingAggregatedMemoryEfficientBlockInputStream::cancel(bool kill)
if (parallel_merge_data)
{
{
std::unique_lock<std::mutex> lock(parallel_merge_data->merged_blocks_mutex);
std::unique_lock lock(parallel_merge_data->merged_blocks_mutex);
parallel_merge_data->finish = true;
}
parallel_merge_data->merged_blocks_changed.notify_one(); /// readImpl method must stop waiting and exit.
@ -219,7 +219,7 @@ Block MergingAggregatedMemoryEfficientBlockInputStream::readImpl()
while (true)
{
std::unique_lock<std::mutex> lock(parallel_merge_data->merged_blocks_mutex);
std::unique_lock lock(parallel_merge_data->merged_blocks_mutex);
parallel_merge_data->merged_blocks_changed.wait(lock, [this]
{
@ -323,7 +323,7 @@ void MergingAggregatedMemoryEfficientBlockInputStream::mergeThread(ThreadGroupSt
* - or, if no next blocks, set 'exhausted' flag.
*/
{
std::lock_guard<std::mutex> lock_next_blocks(parallel_merge_data->get_next_blocks_mutex);
std::lock_guard lock_next_blocks(parallel_merge_data->get_next_blocks_mutex);
if (parallel_merge_data->exhausted || parallel_merge_data->finish)
break;
@ -333,7 +333,7 @@ void MergingAggregatedMemoryEfficientBlockInputStream::mergeThread(ThreadGroupSt
if (!blocks_to_merge || blocks_to_merge->empty())
{
{
std::unique_lock<std::mutex> lock_merged_blocks(parallel_merge_data->merged_blocks_mutex);
std::unique_lock lock_merged_blocks(parallel_merge_data->merged_blocks_mutex);
parallel_merge_data->exhausted = true;
}
@ -347,7 +347,7 @@ void MergingAggregatedMemoryEfficientBlockInputStream::mergeThread(ThreadGroupSt
: blocks_to_merge->front().info.bucket_num;
{
std::unique_lock<std::mutex> lock_merged_blocks(parallel_merge_data->merged_blocks_mutex);
std::unique_lock lock_merged_blocks(parallel_merge_data->merged_blocks_mutex);
parallel_merge_data->have_space.wait(lock_merged_blocks, [this]
{
@ -370,7 +370,7 @@ void MergingAggregatedMemoryEfficientBlockInputStream::mergeThread(ThreadGroupSt
Block res = aggregator.mergeBlocks(*blocks_to_merge, final);
{
std::lock_guard<std::mutex> lock(parallel_merge_data->merged_blocks_mutex);
std::lock_guard lock(parallel_merge_data->merged_blocks_mutex);
if (parallel_merge_data->finish)
break;
@ -385,7 +385,7 @@ void MergingAggregatedMemoryEfficientBlockInputStream::mergeThread(ThreadGroupSt
catch (...)
{
{
std::lock_guard<std::mutex> lock(parallel_merge_data->merged_blocks_mutex);
std::lock_guard lock(parallel_merge_data->merged_blocks_mutex);
parallel_merge_data->exception = std::current_exception();
parallel_merge_data->finish = true;
}

View File

@ -191,7 +191,7 @@ private:
{
InputData unprepared_input;
{
std::lock_guard<std::mutex> lock(unprepared_inputs_mutex);
std::lock_guard lock(unprepared_inputs_mutex);
if (unprepared_inputs.empty())
break;
@ -203,7 +203,7 @@ private:
unprepared_input.in->readPrefix();
{
std::lock_guard<std::mutex> lock(available_inputs_mutex);
std::lock_guard lock(available_inputs_mutex);
available_inputs.push(unprepared_input);
}
}
@ -257,7 +257,7 @@ private:
/// Select the next source.
{
std::lock_guard<std::mutex> lock(available_inputs_mutex);
std::lock_guard lock(available_inputs_mutex);
/// If there are no free sources, then this thread is no longer needed. (But other threads can work with their sources.)
if (available_inputs.empty())
@ -278,7 +278,7 @@ private:
/// If this source is not run out yet, then put the resulting block in the ready queue.
{
std::lock_guard<std::mutex> lock(available_inputs_mutex);
std::lock_guard lock(available_inputs_mutex);
if (block)
{

View File

@ -104,7 +104,7 @@ void RemoteBlockInputStream::cancel(bool kill)
return;
{
std::lock_guard<std::mutex> lock(external_tables_mutex);
std::lock_guard lock(external_tables_mutex);
/// Stop sending external data.
for (auto & vec : external_tables_data)
@ -124,7 +124,7 @@ void RemoteBlockInputStream::sendExternalTables()
size_t count = multiplexed_connections->size();
{
std::lock_guard<std::mutex> lock(external_tables_mutex);
std::lock_guard lock(external_tables_mutex);
external_tables_data.reserve(count);

View File

@ -94,7 +94,7 @@ void DataTypeArray::deserializeBinary(IColumn & column, ReadBuffer & istr) const
throw;
}
offsets.push_back((offsets.empty() ? 0 : offsets.back()) + size);
offsets.push_back(offsets.back() + size);
}
@ -255,7 +255,7 @@ void DataTypeArray::deserializeBinaryBulkWithMultipleStreams(
IColumn & nested_column = column_array.getData();
/// Number of values corresponding with `offset_values` must be read.
size_t last_offset = (offset_values.empty() ? 0 : offset_values.back());
size_t last_offset = offset_values.back();
if (last_offset < nested_column.size())
throw Exception("Nested column is longer than last offset", ErrorCodes::LOGICAL_ERROR);
size_t nested_limit = last_offset - nested_column.size();
@ -341,7 +341,7 @@ static void deserializeTextImpl(IColumn & column, ReadBuffer & istr, Reader && r
throw;
}
offsets.push_back((offsets.empty() ? 0 : offsets.back()) + size);
offsets.push_back(offsets.back() + size);
}

View File

@ -56,8 +56,6 @@ static inline void readText(time_t & x, ReadBuffer & istr, const FormatSettings
case FormatSettings::DateTimeInputFormat::BestEffort:
parseDateTimeBestEffort(x, istr, time_zone, utc_time_zone);
return;
default:
__builtin_unreachable();
}
}

View File

@ -49,8 +49,9 @@ public:
case Month: return "Month";
case Quarter: return "Quarter";
case Year: return "Year";
default: __builtin_unreachable();
}
__builtin_unreachable();
}
DataTypeInterval(Kind kind) : kind(kind) {}

View File

@ -766,7 +766,7 @@ namespace
void operator()()
{
if (typeid_cast<const DataTypeNumber<T> *>(&keys_type))
column = creator((ColumnVector<T> *)(nullptr));
column = creator(static_cast<ColumnVector<T> *>(nullptr));
}
};
}
@ -780,13 +780,13 @@ MutableColumnUniquePtr DataTypeLowCardinality::createColumnUniqueImpl(const IDat
type = nullable_type->getNestedType().get();
if (isString(type))
return creator((ColumnString *)(nullptr));
return creator(static_cast<ColumnString *>(nullptr));
if (isFixedString(type))
return creator((ColumnFixedString *)(nullptr));
return creator(static_cast<ColumnFixedString *>(nullptr));
if (typeid_cast<const DataTypeDate *>(type))
return creator((ColumnVector<UInt16> *)(nullptr));
return creator(static_cast<ColumnVector<UInt16> *>(nullptr));
if (typeid_cast<const DataTypeDateTime *>(type))
return creator((ColumnVector<UInt32> *)(nullptr));
return creator(static_cast<ColumnVector<UInt32> *>(nullptr));
if (isNumber(type))
{
MutableColumnUniquePtr column;

View File

@ -14,7 +14,7 @@
#include <IO/WriteHelpers.h>
#include <IO/VarInt.h>
#if __SSE2__
#ifdef __SSE2__
#include <emmintrin.h>
#endif
@ -129,7 +129,7 @@ static NO_INLINE void deserializeBinarySSE2(ColumnString::Chars & data, ColumnSt
if (size)
{
#if __SSE2__
#ifdef __SSE2__
/// An optimistic branch in which more efficient copying is possible.
if (offset + 16 * UNROLL_TIMES <= data.allocated_bytes() && istr.position() + size + 16 * UNROLL_TIMES <= istr.buffer().end())
{

View File

@ -100,7 +100,7 @@ static inline const IColumn & extractElementColumn(const IColumn & column, size_
void DataTypeTuple::serializeBinary(const Field & field, WriteBuffer & ostr) const
{
const auto & tuple = get<const Tuple &>(field).toUnderType();
for (const auto & idx_elem : ext::enumerate(elems))
for (const auto idx_elem : ext::enumerate(elems))
idx_elem.second->serializeBinary(tuple[idx_elem.first], ostr);
}
@ -115,7 +115,7 @@ void DataTypeTuple::deserializeBinary(Field & field, ReadBuffer & istr) const
void DataTypeTuple::serializeBinary(const IColumn & column, size_t row_num, WriteBuffer & ostr) const
{
for (const auto & idx_elem : ext::enumerate(elems))
for (const auto idx_elem : ext::enumerate(elems))
idx_elem.second->serializeBinary(extractElementColumn(column, idx_elem.first), row_num, ostr);
}

View File

@ -50,7 +50,7 @@ inline UInt32 leastDecimalPrecisionFor(TypeIndex int_type)
return 20;
default:
break;
};
}
return 0;
}

View File

@ -7,6 +7,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#ifdef __clang__
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
#pragma clang diagnostic ignored "-Wundef"
#endif
#include <gtest/gtest.h>

View File

@ -273,7 +273,7 @@ void DatabaseOrdinary::createTable(
/// But there is protection from it - see using DDLGuard in InterpreterCreateQuery.
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
if (tables.find(table_name) != tables.end())
throw Exception("Table " + name + "." + table_name + " already exists.", ErrorCodes::TABLE_ALREADY_EXISTS);
}
@ -298,7 +298,7 @@ void DatabaseOrdinary::createTable(
{
/// Add a table to the map of known tables.
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
if (!tables.emplace(table_name, table).second)
throw Exception("Table " + name + "." + table_name + " already exists.", ErrorCodes::TABLE_ALREADY_EXISTS);
}
@ -492,7 +492,7 @@ void DatabaseOrdinary::shutdown()
Tables tables_snapshot;
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
tables_snapshot = tables;
}
@ -501,19 +501,19 @@ void DatabaseOrdinary::shutdown()
kv.second->shutdown();
}
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
tables.clear();
}
void DatabaseOrdinary::alterTable(
const Context & context,
const String & name,
const String & table_name,
const ColumnsDescription & columns,
const ASTModifier & storage_modifier)
{
/// Read the definition of the table and replace the necessary parts with new ones.
String table_name_escaped = escapeForFileName(name);
String table_name_escaped = escapeForFileName(table_name);
String table_metadata_tmp_path = metadata_path + "/" + table_name_escaped + ".sql.tmp";
String table_metadata_path = metadata_path + "/" + table_name_escaped + ".sql";
String statement;

View File

@ -88,7 +88,7 @@ bool DatabaseWithOwnTablesBase::isTableExist(
const Context & /*context*/,
const String & table_name) const
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
return tables.find(table_name) != tables.end();
}
@ -96,7 +96,7 @@ StoragePtr DatabaseWithOwnTablesBase::tryGetTable(
const Context & /*context*/,
const String & table_name) const
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
auto it = tables.find(table_name);
if (it == tables.end())
return {};
@ -105,13 +105,13 @@ StoragePtr DatabaseWithOwnTablesBase::tryGetTable(
DatabaseIteratorPtr DatabaseWithOwnTablesBase::getIterator(const Context & /*context*/)
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
return std::make_unique<DatabaseSnapshotIterator>(tables);
}
bool DatabaseWithOwnTablesBase::empty(const Context & /*context*/) const
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
return tables.empty();
}
@ -119,7 +119,7 @@ StoragePtr DatabaseWithOwnTablesBase::detachTable(const String & table_name)
{
StoragePtr res;
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
auto it = tables.find(table_name);
if (it == tables.end())
throw Exception("Table " + name + "." + table_name + " doesn't exist.", ErrorCodes::UNKNOWN_TABLE);
@ -132,7 +132,7 @@ StoragePtr DatabaseWithOwnTablesBase::detachTable(const String & table_name)
void DatabaseWithOwnTablesBase::attachTable(const String & table_name, const StoragePtr & table)
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
if (!tables.emplace(table_name, table).second)
throw Exception("Table " + name + "." + table_name + " already exists.", ErrorCodes::TABLE_ALREADY_EXISTS);
}
@ -144,7 +144,7 @@ void DatabaseWithOwnTablesBase::shutdown()
Tables tables_snapshot;
{
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
tables_snapshot = tables;
}
@ -153,7 +153,7 @@ void DatabaseWithOwnTablesBase::shutdown()
kv.second->shutdown();
}
std::lock_guard<std::mutex> lock(mutex);
std::lock_guard lock(mutex);
tables.clear();
}

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