Improvement [#METR-2807].

This commit is contained in:
Alexey Milovidov 2014-04-08 11:47:51 +04:00
parent 5ca21127c7
commit 9dad91788b
13 changed files with 23 additions and 23 deletions

View File

@ -21,7 +21,7 @@ public:
void * alloc(size_t size)
{
void * buf = ::calloc(size, 1);
if (NULL == buf)
if (nullptr == buf)
throwFromErrno("HashTableAllocator: Cannot calloc.", ErrorCodes::CANNOT_ALLOCATE_MEMORY);
return buf;
@ -41,7 +41,7 @@ public:
void * realloc(void * buf, size_t old_size, size_t new_size)
{
buf = ::realloc(buf, new_size);
if (NULL == buf)
if (nullptr == buf)
throwFromErrno("HashTableAllocator: Cannot realloc.", ErrorCodes::CANNOT_ALLOCATE_MEMORY);
memset(reinterpret_cast<char *>(buf) + old_size, 0, new_size - old_size);
@ -82,7 +82,7 @@ public:
return HashTableAllocator::realloc(buf, old_size, new_size);
buf = ::malloc(new_size);
if (NULL == buf)
if (nullptr == buf)
throwFromErrno("HashTableAllocator: Cannot malloc.", ErrorCodes::CANNOT_ALLOCATE_MEMORY);
memcpy(buf, stack_memory, old_size);

View File

@ -121,14 +121,14 @@ private:
{
c_start = reinterpret_cast<char *>(::realloc(c_start, bytes_to_alloc));
if (NULL == c_start)
if (nullptr == c_start)
throwFromErrno("PODArray: cannot realloc", ErrorCodes::CANNOT_ALLOCATE_MEMORY);
}
else
{
c_start = reinterpret_cast<char *>(malloc(bytes_to_alloc));
if (NULL == c_start)
if (nullptr == c_start)
throwFromErrno("PODArray: cannot realloc", ErrorCodes::CANNOT_ALLOCATE_MEMORY);
memcpy(c_start, old_c_start, old_c_end_of_storage - old_c_start);

View File

@ -56,7 +56,7 @@ namespace DB
struct StringRefZeroTraits
{
static inline bool check(DB::StringRef x) { return NULL == x.data; }
static inline bool check(DB::StringRef x) { return nullptr == x.data; }
static inline void set(DB::StringRef & x) { x.data = nullptr; }
};

View File

@ -167,7 +167,7 @@ struct ExtractPath
Pos pos = data;
Pos end = pos + size;
if (NULL != (pos = strchr(data, '/')) && pos[1] == '/' && NULL != (pos = strchr(pos + 2, '/')))
if (nullptr != (pos = strchr(data, '/')) && pos[1] == '/' && nullptr != (pos = strchr(pos + 2, '/')))
{
Pos query_string_or_fragment = strpbrk(pos, "?#");
@ -190,7 +190,7 @@ struct ExtractQueryString
Pos pos = data;
Pos end = pos + size;
if (NULL != (pos = strchr(data, '?')))
if (nullptr != (pos = strchr(data, '?')))
{
Pos fragment = strchr(pos, '#');
@ -213,7 +213,7 @@ struct ExtractFragment
Pos pos = data;
Pos end = pos + size;
if (NULL != (pos = strchr(data, '#')))
if (nullptr != (pos = strchr(data, '#')))
{
res_data = pos + (without_leading_char ? 1 : 0);
res_size = end - res_data;
@ -234,7 +234,7 @@ struct ExtractQueryStringAndFragment
Pos pos = data;
Pos end = pos + size;
if (NULL != (pos = strchr(data, '?')))
if (nullptr != (pos = strchr(data, '?')))
{
res_data = pos + (without_leading_char ? 1 : 0);
res_size = end - res_data;

View File

@ -231,7 +231,7 @@ private:
{
/// Если в прошлую попытку от сервера не пришло ответа, но файл всё же был переименован.
if (i != 0 && e.code() == ErrorCodes::RECEIVED_ERROR_FROM_REMOTE_IO_SERVER
&& NULL != strstr(e.displayText().data(), "File not found"))
&& nullptr != strstr(e.displayText().data(), "File not found"))
{
LOG_TRACE((&Logger::get("RemoteWriteBuffer")), "File already renamed");
}

View File

@ -253,7 +253,7 @@ void writeAnyEscapedString(const String & s, WriteBuffer & buf)
inline void writeEscapedString(const String & s, WriteBuffer & buf)
{
/// strpbrk в libc под Linux на процессорах с SSE 4.2 хорошо оптимизирована (этот if ускоряет код в 1.5 раза)
if (NULL == strpbrk(s.data(), "\b\f\n\r\t\'\\") && strlen(s.data()) == s.size())
if (nullptr == strpbrk(s.data(), "\b\f\n\r\t\'\\") && strlen(s.data()) == s.size())
writeString(s, buf);
else
writeAnyEscapedString<'\''>(s, buf);

View File

@ -52,7 +52,7 @@ public:
{
const char * pos = strchr(str.c_str(), '/');
if (NULL == pos)
if (nullptr == pos)
{
construct(Poco::Net::IPAddress(str));
}

View File

@ -54,7 +54,7 @@ public:
String table;
ASTAlterQuery(StringRange range_ = StringRange(NULL, NULL)) : IAST(range_) {};
ASTAlterQuery(StringRange range_ = StringRange()) : IAST(range_) {};
/** Получить текст, который идентифицирует этот элемент. */
String getID() const { return ("AlterQuery_" + database + "_" + table); };

View File

@ -38,7 +38,7 @@ public:
*/
StringPtr query_string;
IAST() : range(NULL, NULL) {}
IAST() {}
IAST(StringRange range_) : range(range_) {}
virtual ~IAST() {}

View File

@ -71,7 +71,7 @@ void rewriteEntityInAst(ASTPtr ast, const String & column_name, const Field & va
ASTSelectQuery & select = dynamic_cast<ASTSelectQuery &>(*ast);
ASTExpressionList & node = dynamic_cast<ASTExpressionList &>(*select.select_expression_list);
ASTs & asts = node.children;
ASTLiteral * cur = new ASTLiteral(StringRange(NULL, NULL), value);
ASTLiteral * cur = new ASTLiteral(StringRange(), value);
cur->alias = column_name;
ASTPtr column_value = cur;
bool is_replaced = false;
@ -161,7 +161,7 @@ BlockInputStreamPtr getVirtualColumnsBlocks(ASTPtr query, const Block & input, c
new_select.select_expression_list = new ASTExpressionList();
ASTExpressionList & select_list = dynamic_cast<ASTExpressionList & >(*new_select.select_expression_list);
for (size_t i = 0; i < columns.size(); ++i)
select_list.children.push_back(new ASTIdentifier(StringRange(NULL, NULL), columns[i]));
select_list.children.push_back(new ASTIdentifier(StringRange(), columns[i]));
std::vector<ASTPtr> functions;
extractFunctions(select.where_expression, columns, functions);

View File

@ -450,7 +450,7 @@ QueryProcessingStage::Enum InterpreterSelectQuery::executeFetchColumns(BlockInpu
/// если таблица не поддерживает сэмплинг получим исключение
/// поэтому запросы типа SHOW TABLES работать с включенном default_sample не будут
if (!query.sample_size && settings.default_sample != 1)
query.sample_size = new ASTLiteral(StringRange(NULL, NULL), Float64(settings.default_sample));
query.sample_size = new ASTLiteral(StringRange(), Float64(settings.default_sample));
if (query.sample_size && (!storage || !storage->supportsSampling()))
throw Exception("Illegal SAMPLE: table doesn't support sampling", ErrorCodes::SAMPLING_NOT_SUPPORTED);

View File

@ -88,7 +88,7 @@ void executeQuery(
/// Положим запрос в список процессов. Но запрос SHOW PROCESSLIST класть не будем.
ProcessList::EntryPtr process_list_entry;
if (!internal && NULL == dynamic_cast<const ASTShowProcesslistQuery *>(&*ast))
if (!internal && nullptr == dynamic_cast<const ASTShowProcesslistQuery *>(&*ast))
{
process_list_entry = context.getProcessList().insert(
query, context.getUser(), context.getCurrentQueryId(), context.getIPAddress(), context.getSettingsRef().queue_max_wait_ms.totalMilliseconds());
@ -159,7 +159,7 @@ BlockIO executeQuery(
/// Положим запрос в список процессов. Но запрос SHOW PROCESSLIST класть не будем.
ProcessList::EntryPtr process_list_entry;
if (!internal && NULL == dynamic_cast<const ASTShowProcesslistQuery *>(&*ast))
if (!internal && nullptr == dynamic_cast<const ASTShowProcesslistQuery *>(&*ast))
{
process_list_entry = context.getProcessList().insert(
query, context.getUser(), context.getCurrentQueryId(), context.getIPAddress(), context.getSettingsRef().queue_max_wait_ms.totalMilliseconds(), context.getSettingsRef().replace_running_query);

View File

@ -439,7 +439,7 @@ public:
void * alloc(size_t size)
{
void * buf = ::calloc(size, 1);
if (NULL == buf)
if (nullptr == buf)
throwFromErrno("HashTableAllocator: Cannot calloc.", ErrorCodes::CANNOT_ALLOCATE_MEMORY);
return buf;
@ -459,7 +459,7 @@ public:
void * realloc(void * buf, size_t old_size, size_t new_size)
{
buf = ::realloc(buf, new_size);
if (NULL == buf)
if (nullptr == buf)
throwFromErrno("HashTableAllocator: Cannot realloc.", ErrorCodes::CANNOT_ALLOCATE_MEMORY);
memset(reinterpret_cast<char *>(buf) + old_size, 0, new_size - old_size);
@ -501,7 +501,7 @@ public:
return HashTableAllocator::realloc(buf, old_size, new_size);
buf = ::malloc(new_size);
if (NULL == buf)
if (nullptr == buf)
throwFromErrno("HashTableAllocator: Cannot malloc.", ErrorCodes::CANNOT_ALLOCATE_MEMORY);
memcpy(buf, stack_memory, old_size);