mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 21:42:39 +00:00
Merge master
This commit is contained in:
commit
fd6362d2f2
@ -23,6 +23,7 @@ if (COMPILER_CLANG)
|
|||||||
no_warning(zero-length-array)
|
no_warning(zero-length-array)
|
||||||
no_warning(c++98-compat-pedantic)
|
no_warning(c++98-compat-pedantic)
|
||||||
no_warning(c++98-compat)
|
no_warning(c++98-compat)
|
||||||
|
no_warning(c++20-compat) # Use constinit in C++20 without warnings
|
||||||
no_warning(conversion)
|
no_warning(conversion)
|
||||||
no_warning(ctad-maybe-unsupported) # clang 9+, linux-only
|
no_warning(ctad-maybe-unsupported) # clang 9+, linux-only
|
||||||
no_warning(disabled-macro-expansion)
|
no_warning(disabled-macro-expansion)
|
||||||
|
@ -55,9 +55,9 @@ Differs from ‘intDiv’ in that it returns zero when dividing by zero or when
|
|||||||
|
|
||||||
## modulo(a, b), a % b operator
|
## modulo(a, b), a % b operator
|
||||||
|
|
||||||
Calculates the remainder after division.
|
Calculates the remainder when dividing `a` by `b`.
|
||||||
If arguments are floating-point numbers, they are pre-converted to integers by dropping the decimal portion.
|
The result type is an integer if both inputs are integers. If one of the inputs is a floating-point number, the result is a floating-point number.
|
||||||
The remainder is taken in the same sense as in C++. Truncated division is used for negative numbers.
|
The remainder is computed like in C++. Truncated division is used for negative numbers.
|
||||||
An exception is thrown when dividing by zero or when dividing a minimal negative number by minus one.
|
An exception is thrown when dividing by zero or when dividing a minimal negative number by minus one.
|
||||||
|
|
||||||
## moduloOrZero(a, b)
|
## moduloOrZero(a, b)
|
||||||
|
@ -1241,7 +1241,7 @@ Same as for [parseDateTime64BestEffort](#parsedatetime64besteffort), except that
|
|||||||
|
|
||||||
## toLowCardinality
|
## toLowCardinality
|
||||||
|
|
||||||
Converts input parameter to the [LowCardianlity](../../sql-reference/data-types/lowcardinality.md) version of same data type.
|
Converts input parameter to the [LowCardinality](../../sql-reference/data-types/lowcardinality.md) version of same data type.
|
||||||
|
|
||||||
To convert data from the `LowCardinality` data type use the [CAST](#type_conversion_function-cast) function. For example, `CAST(x as String)`.
|
To convert data from the `LowCardinality` data type use the [CAST](#type_conversion_function-cast) function. For example, `CAST(x as String)`.
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ SELECT toTypeName(0), toTypeName(0 + 0), toTypeName(0 + 0 + 0), toTypeName(0 + 0
|
|||||||
## modulo(a, b), оператор a % b {#modulo}
|
## modulo(a, b), оператор a % b {#modulo}
|
||||||
|
|
||||||
Вычисляет остаток от деления.
|
Вычисляет остаток от деления.
|
||||||
Если аргументы - числа с плавающей запятой, то они предварительно преобразуются в целые числа, путём отбрасывания дробной части.
|
Тип результата - целое число, если оба аргумента - целые числа. Если один из аргументов является числом с плавающей точкой, результатом будет число с плавающей точкой.
|
||||||
Берётся остаток в том же смысле, как это делается в C++. По факту, для отрицательных чисел, используется truncated division.
|
Берётся остаток в том же смысле, как это делается в C++. По факту, для отрицательных чисел, используется truncated division.
|
||||||
При делении на ноль или при делении минимального отрицательного числа на минус единицу, кидается исключение.
|
При делении на ноль или при делении минимального отрицательного числа на минус единицу, кидается исключение.
|
||||||
|
|
||||||
|
@ -1162,7 +1162,7 @@ FORMAT PrettyCompactMonoBlock;
|
|||||||
|
|
||||||
## toLowCardinality {#tolowcardinality}
|
## toLowCardinality {#tolowcardinality}
|
||||||
|
|
||||||
Преобразует входные данные в версию [LowCardianlity](../data-types/lowcardinality.md) того же типа данных.
|
Преобразует входные данные в версию [LowCardinality](../data-types/lowcardinality.md) того же типа данных.
|
||||||
|
|
||||||
Чтобы преобразовать данные из типа `LowCardinality`, используйте функцию [CAST](#type_conversion_function-cast). Например, `CAST(x as String)`.
|
Чтобы преобразовать данные из типа `LowCardinality`, используйте функцию [CAST](#type_conversion_function-cast). Например, `CAST(x as String)`.
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ SELECT toTypeName(0), toTypeName(0 + 0), toTypeName(0 + 0 + 0), toTypeName(0 + 0
|
|||||||
## modulo(a, b), a % b operator {#modulo}
|
## modulo(a, b), a % b operator {#modulo}
|
||||||
|
|
||||||
计算除法后的余数。
|
计算除法后的余数。
|
||||||
如果参数是浮点数,则通过删除小数部分将它们预转换为整数。
|
如果两个输入都是整数,结果类型是整数。如果其中一个输入是浮点数,则结果是浮点数。
|
||||||
其余部分与C++中的含义相同。截断除法用于负数。
|
其余部分与C++中的含义相同。截断除法用于负数。
|
||||||
除以零或将最小负数除以-1时抛出异常。
|
除以零或将最小负数除以-1时抛出异常。
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ SELECT parseDateTimeBestEffort('10 20:19')
|
|||||||
|
|
||||||
## toLowCardinality {#tolowcardinality}
|
## toLowCardinality {#tolowcardinality}
|
||||||
|
|
||||||
把输入值转换为[LowCardianlity](../data-types/lowcardinality.md)的相同类型的数据。
|
把输入值转换为[LowCardinality](../data-types/lowcardinality.md)的相同类型的数据。
|
||||||
|
|
||||||
如果要把`LowCardinality`类型的数据转换为其他类型,使用[CAST](#type_conversion_function-cast)函数。比如:`CAST(x as String)`。
|
如果要把`LowCardinality`类型的数据转换为其他类型,使用[CAST](#type_conversion_function-cast)函数。比如:`CAST(x as String)`。
|
||||||
|
|
||||||
|
@ -43,13 +43,6 @@ ProfileEvents::Counters & CurrentThread::getProfileEvents()
|
|||||||
return current_thread ? current_thread->performance_counters : ProfileEvents::global_counters;
|
return current_thread ? current_thread->performance_counters : ProfileEvents::global_counters;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryTracker * CurrentThread::getMemoryTracker()
|
|
||||||
{
|
|
||||||
if (unlikely(!current_thread))
|
|
||||||
return nullptr;
|
|
||||||
return ¤t_thread->memory_tracker;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CurrentThread::updateProgressIn(const Progress & value)
|
void CurrentThread::updateProgressIn(const Progress & value)
|
||||||
{
|
{
|
||||||
if (unlikely(!current_thread))
|
if (unlikely(!current_thread))
|
||||||
|
@ -54,7 +54,12 @@ public:
|
|||||||
static void updatePerformanceCounters();
|
static void updatePerformanceCounters();
|
||||||
|
|
||||||
static ProfileEvents::Counters & getProfileEvents();
|
static ProfileEvents::Counters & getProfileEvents();
|
||||||
static MemoryTracker * getMemoryTracker();
|
inline ALWAYS_INLINE static MemoryTracker * getMemoryTracker()
|
||||||
|
{
|
||||||
|
if (unlikely(!current_thread))
|
||||||
|
return nullptr;
|
||||||
|
return ¤t_thread->memory_tracker;
|
||||||
|
}
|
||||||
|
|
||||||
/// Update read and write rows (bytes) statistics (used in system.query_thread_log)
|
/// Update read and write rows (bytes) statistics (used in system.query_thread_log)
|
||||||
static void updateProgressIn(const Progress & value);
|
static void updateProgressIn(const Progress & value);
|
||||||
|
@ -1061,14 +1061,13 @@ void FileCache::loadCacheInfoIntoMemory(std::lock_guard<std::mutex> & cache_lock
|
|||||||
fs::directory_iterator key_it{key_prefix_it->path()};
|
fs::directory_iterator key_it{key_prefix_it->path()};
|
||||||
for (; key_it != fs::directory_iterator(); ++key_it)
|
for (; key_it != fs::directory_iterator(); ++key_it)
|
||||||
{
|
{
|
||||||
key = Key(unhexUInt<UInt128>(key_it->path().filename().string().data()));
|
|
||||||
|
|
||||||
if (!key_it->is_directory())
|
if (!key_it->is_directory())
|
||||||
{
|
{
|
||||||
LOG_WARNING(log, "Unexpected file: {}. Expected a directory", key_it->path().string());
|
LOG_WARNING(log, "Unexpected file: {}. Expected a directory", key_it->path().string());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
key = Key(unhexUInt<UInt128>(key_it->path().filename().string().data()));
|
||||||
fs::directory_iterator offset_it{key_it->path()};
|
fs::directory_iterator offset_it{key_it->path()};
|
||||||
for (; offset_it != fs::directory_iterator(); ++offset_it)
|
for (; offset_it != fs::directory_iterator(); ++offset_it)
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include <IO/WriteBufferFromString.h>
|
#include <IO/WriteBufferFromString.h>
|
||||||
#include <IO/Operators.h>
|
#include <IO/Operators.h>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <Common/FileCache.h>
|
|
||||||
|
|
||||||
namespace CurrentMetrics
|
namespace CurrentMetrics
|
||||||
{
|
{
|
||||||
|
@ -24,9 +24,7 @@ namespace ErrorCodes
|
|||||||
extern const int LOGICAL_ERROR;
|
extern const int LOGICAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thread_local ThreadStatus constinit * current_thread = nullptr;
|
||||||
thread_local ThreadStatus * current_thread = nullptr;
|
|
||||||
thread_local ThreadStatus * main_thread = nullptr;
|
|
||||||
|
|
||||||
#if !defined(SANITIZER)
|
#if !defined(SANITIZER)
|
||||||
namespace
|
namespace
|
||||||
|
@ -102,8 +102,16 @@ public:
|
|||||||
|
|
||||||
using ThreadGroupStatusPtr = std::shared_ptr<ThreadGroupStatus>;
|
using ThreadGroupStatusPtr = std::shared_ptr<ThreadGroupStatus>;
|
||||||
|
|
||||||
|
/**
|
||||||
extern thread_local ThreadStatus * current_thread;
|
* We use **constinit** here to tell the compiler the current_thread variable is initialized.
|
||||||
|
* If we didn't help the compiler, then it would most likely add a check before every use of the variable to initialize it if needed.
|
||||||
|
* Instead it will trust that we are doing the right thing (and we do initialize it to nullptr) and emit more optimal code.
|
||||||
|
* This is noticeable in functions like CurrentMemoryTracker::free and CurrentMemoryTracker::allocImpl
|
||||||
|
* See also:
|
||||||
|
* - https://en.cppreference.com/w/cpp/language/constinit
|
||||||
|
* - https://github.com/ClickHouse/ClickHouse/pull/40078
|
||||||
|
*/
|
||||||
|
extern thread_local constinit ThreadStatus * current_thread;
|
||||||
|
|
||||||
/** Encapsulates all per-thread info (ProfileEvents, MemoryTracker, query_id, query context, etc.).
|
/** Encapsulates all per-thread info (ProfileEvents, MemoryTracker, query_id, query context, etc.).
|
||||||
* The object must be created in thread function and destroyed in the same thread before the exit.
|
* The object must be created in thread function and destroyed in the same thread before the exit.
|
||||||
|
Loading…
Reference in New Issue
Block a user