diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 358d6c6eb..0518316b8 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -309,7 +309,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, DBUG_RETURN(TRUE); } // TIANMU UPGRADE BEGIN - if (!Tianmu::dbhandler::tianmu_load(thd, ex, table_list, (void*) &lf_info)) { + if (!Tianmu::handler::tianmu_load(thd, ex, table_list, (void*) &lf_info)) { DBUG_RETURN(FALSE); } //END diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 63bd52066..0a55de641 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3261,11 +3261,11 @@ case SQLCOM_PREPARE: //res= handle_query(thd, lex, result, SELECT_NO_UNLOCK, 0); // Tianmu hook added - int sdb_res, free_join_from_sdb, optimize_after_sdb;//TIANMU UPGRADE - if (Tianmu::dbhandler::TIANMU_HandleSelect(thd, lex, result, 0, sdb_res, optimize_after_sdb, free_join_from_sdb, (int)true) == 0) - res = handle_query(thd, lex, result, SELECT_NO_UNLOCK, (ulong)0, optimize_after_sdb, free_join_from_sdb); + int tianmu_res, free_join_from_tianmu, optimize_after_tianmu; + if (Tianmu::handler::ha_my_tianmu_query(thd, lex, result, 0, tianmu_res, optimize_after_tianmu, free_join_from_tianmu, (int)true) == 0) + res = handle_query(thd, lex, result, SELECT_NO_UNLOCK, (ulong)0, optimize_after_tianmu, free_join_from_tianmu); else - res = sdb_res; + res = tianmu_res; if (thd->lex->is_ignore() || thd->is_strict_mode()) thd->pop_internal_handler(); @@ -3727,7 +3727,7 @@ case SQLCOM_PREPARE: if ((check_table_access(thd, SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE) || open_and_lock_tables(thd, all_tables, 0))) goto error; - if (!Tianmu::dbhandler::TIANMU_SetStatementAllowed(thd, lex)) { + if (!Tianmu::handler::TIANMU_SetStatementAllowed(thd, lex)) { goto error; } if (!(res= sql_set_variables(thd, lex_var_list))) @@ -5178,13 +5178,13 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables) } //res= handle_query(thd, lex, result, 0, 0, 0, 0); - int sdb_res, free_join_from_sdb, optimize_after_sdb;//ATIMSTORE UPGRADE - if (Tianmu::dbhandler::TIANMU_HandleSelect(thd, lex, result, (ulong)0, - sdb_res, optimize_after_sdb, free_join_from_sdb) == 0) { - res = handle_query(thd, lex, result, (ulonglong)0, (ulonglong)0, optimize_after_sdb, free_join_from_sdb); + int tianmu_res, free_join_from_tianmu, optimize_after_tianmu;//ATIMSTORE UPGRADE + if (Tianmu::handler::ha_my_tianmu_query(thd, lex, result, (ulong)0, + tianmu_res, optimize_after_tianmu, free_join_from_tianmu) == 0) { + res = handle_query(thd, lex, result, (ulonglong)0, (ulonglong)0, optimize_after_tianmu, free_join_from_tianmu); } else - res = sdb_res; + res = tianmu_res; delete analyse_result; if (save_result != lex->result) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1c4c75210..d074fbede 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -5535,7 +5535,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables, table->field[IS_COLUMNS_GENERATION_EXPRESSION]->set_null(); //table->field[IS_COLUMNS_COLUMN_COMMENT]->store(field->comment.str, // field->comment.length, cs); - Tianmu::dbhandler::TIANMU_UpdateAndStoreColumnComment(table, IS_COLUMNS_COLUMN_COMMENT, field, count - 1, cs);//TIANMU UPGRADE + Tianmu::handler::TIANMU_UpdateAndStoreColumnComment(table, IS_COLUMNS_COLUMN_COMMENT, field, count - 1, cs);//TIANMU UPGRADE if (schema_table_store_record(thd, table)) DBUG_RETURN(1); } diff --git a/storage/tianmu/base/core/posix.cpp b/storage/tianmu/base/core/posix.cpp index 07e100174..1c7647314 100644 --- a/storage/tianmu/base/core/posix.cpp +++ b/storage/tianmu/base/core/posix.cpp @@ -96,7 +96,7 @@ posix_thread::~posix_thread() { assert(!_valid); } void posix_thread::join() { assert(_valid); - pthread_join(_pthread, NULL); + pthread_join(_pthread, nullptr); _valid = false; } diff --git a/storage/tianmu/base/core/posix.h b/storage/tianmu/base/core/posix.h index 3367a0cc6..3d9771d59 100644 --- a/storage/tianmu/base/core/posix.h +++ b/storage/tianmu/base/core/posix.h @@ -294,7 +294,7 @@ class file_desc { return size_t(r); } void timerfd_settime(int flags, const itimerspec &its) { - auto r = ::timerfd_settime(_fd, flags, &its, NULL); + auto r = ::timerfd_settime(_fd, flags, &its, nullptr); throw_system_error_on(r == -1, "timerfd_settime"); } diff --git a/storage/tianmu/base/core/reactor.cpp b/storage/tianmu/base/core/reactor.cpp index 222a071a3..7d9e6c5f7 100644 --- a/storage/tianmu/base/core/reactor.cpp +++ b/storage/tianmu/base/core/reactor.cpp @@ -139,7 +139,7 @@ reactor::signals::signals() : _pending_signals(0) {} reactor::signals::~signals() { sigset_t mask; sigfillset(&mask); - ::pthread_sigmask(SIG_BLOCK, &mask, NULL); + ::pthread_sigmask(SIG_BLOCK, &mask, nullptr); } reactor::signals::signal_handler::signal_handler(int signo, std::function &&handler) @@ -151,7 +151,7 @@ reactor::signals::signal_handler::signal_handler(int signo, std::function= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1600 #define FMT_NULL nullptr #else -#define FMT_NULL NULL +#define FMT_NULL nullptr #endif #endif diff --git a/storage/tianmu/common/txt_data_format.cpp b/storage/tianmu/common/txt_data_format.cpp index a6b5c7d83..3775269be 100644 --- a/storage/tianmu/common/txt_data_format.cpp +++ b/storage/tianmu/common/txt_data_format.cpp @@ -64,7 +64,7 @@ uint TxtDataFormat::StaticExtrnalSize(CT attrt, uint precision, int scale, const return 23; else if (attrt == CT::FLOAT) return 15; - if (col == NULL) + if (col == nullptr) return precision; else return precision / col->collation->mbmaxlen; // at creation, the charlen was multiplicated by diff --git a/storage/tianmu/compress/data_stream.h b/storage/tianmu/compress/data_stream.h index 4d6ca978f..841eaf529 100644 --- a/storage/tianmu/compress/data_stream.h +++ b/storage/tianmu/compress/data_stream.h @@ -52,8 +52,8 @@ class DataStream { pos_ = pos; } - DataStream() : buf_(NULL) { Reset(0, 0, 0); } - DataStream(char *buf, uint len, uint pos = 0) : buf_(NULL) { Reset(buf, len, pos); } + DataStream() : buf_(nullptr) { Reset(0, 0, 0); } + DataStream(char *buf, uint len, uint pos = 0) : buf_(nullptr) { Reset(buf, len, pos); } virtual ~DataStream() {} char *GetBuf() { return (char *)buf_; } uint GetPos() { return pos_; } diff --git a/storage/tianmu/compress/inc_alloc.h b/storage/tianmu/compress/inc_alloc.h index 2a525eb8f..194c0e958 100644 --- a/storage/tianmu/compress/inc_alloc.h +++ b/storage/tianmu/compress/inc_alloc.h @@ -37,7 +37,7 @@ class IncAlloc { struct Block { void *mem; uint size; - Block() : mem(NULL), size(0) {} + Block() : mem(nullptr), size(0) {} Block(void *m, uint s) : mem(m), size(s) {} }; diff --git a/storage/tianmu/compress/inc_wgraph.cpp b/storage/tianmu/compress/inc_wgraph.cpp index 822cb6222..9709910b5 100644 --- a/storage/tianmu/compress/inc_wgraph.cpp +++ b/storage/tianmu/compress/inc_wgraph.cpp @@ -28,19 +28,19 @@ const uint IncWGraph::MatchLenCoder::c2[] = {120, 128}; const uint IncWGraph::MatchLenCoder::c3[] = {102, 119, 128}; IncWGraph::IncWGraph() : memory_() { - dump_ = NULL; - ROOT_ = NIL_ = START_ = NULL; - p_mask_ = NULL; - coder_ = NULL; - reclen_ = NULL; - records_ = NULL; + dump_ = nullptr; + ROOT_ = NIL_ = START_ = nullptr; + p_mask_ = nullptr; + coder_ = nullptr; + reclen_ = nullptr; + records_ = nullptr; } void IncWGraph::Init() { nfinals_ = 0; matchlen_cost_ = esc_cost_ = 0; // p_mask_ = &_mask_; // uncomment if masking should be used - p_mask_ = NULL; + p_mask_ = nullptr; // create ROOT_ and NIL_ nodes (and START_) memory_.alloc(ROOT_); diff --git a/storage/tianmu/compress/num_compressor.h b/storage/tianmu/compress/num_compressor.h index 02c382d40..4bf01e771 100644 --- a/storage/tianmu/compress/num_compressor.h +++ b/storage/tianmu/compress/num_compressor.h @@ -216,7 +216,7 @@ inline CprsErr NumDecompress(T *dest, char *src, uint len, uint nrec, uint64_t m template NumCompressor::NumCompressor(bool copy_only) : copy_only_(copy_only) { - dump_ = NULL; + dump_ = nullptr; // Create filters_ filters_.reserve(N_FILTERS_); diff --git a/storage/tianmu/compress/ppm.cpp b/storage/tianmu/compress/ppm.cpp index 5126721e9..3e8be3414 100644 --- a/storage/tianmu/compress/ppm.cpp +++ b/storage/tianmu/compress/ppm.cpp @@ -26,11 +26,11 @@ namespace Tianmu { namespace compress { -FILE *PPM::dump_ = NULL; +FILE *PPM::dump_ = nullptr; bool PPM::printstat_ = false; PPM::PPM(const Symb *data, int dlen, ModelType mt, PPMParam param, uchar method) { - if ((data == NULL) || (dlen <= 0) || (mt == ModelType::ModelNull)) + if ((data == nullptr) || (dlen <= 0) || (mt == ModelType::ModelNull)) return; switch (mt) { @@ -63,11 +63,11 @@ CprsErr PPM::CompressArith(char *dest, int &dlen, Symb *src, int slen) { dlen = slen + 1; return CprsErr::CPRS_SUCCESS; } - WordGraph *wg = NULL; + WordGraph *wg = nullptr; try { wg = dynamic_cast(model_.get()); } catch (...) { - wg = NULL; + wg = nullptr; } if (wg) ASSERT(wg->insatend_ == false, "should be 'wg->insatend_ == false'"); @@ -171,11 +171,11 @@ CprsErr PPM::DecompressArith(Symb *dest, int dlen, char *src, int slen) { //} // if(method != 1) return CprsErr::CPRS_ERR_VER; - WordGraph *wg = NULL; + WordGraph *wg = nullptr; try { wg = dynamic_cast(model_.get()); } catch (...) { - wg = NULL; + wg = nullptr; } if (wg) ASSERT(wg->insatend_ == false, "should be 'wg->insatend_ == false'"); @@ -254,11 +254,11 @@ CprsErr PPM::Compress(char *dest, int &dlen, Symb *src, int slen) { return CprsErr::CPRS_ERR_BUF; dest[0] = 2; // compression method: with RangeCoder - WordGraph *wg = NULL; + WordGraph *wg = nullptr; try { wg = dynamic_cast(model_.get()); } catch (...) { - wg = NULL; + wg = nullptr; } if (wg) @@ -322,11 +322,11 @@ CprsErr PPM::Decompress(Symb *dest, int dlen, char *src, int slen) { if (method != 2) return CprsErr::CPRS_ERR_VER; - WordGraph *wg = NULL; + WordGraph *wg = nullptr; try { wg = dynamic_cast(model_.get()); } catch (...) { - wg = NULL; + wg = nullptr; } if (wg) diff --git a/storage/tianmu/compress/ppm.h b/storage/tianmu/compress/ppm.h index 09bc7ff03..a76be72ea 100644 --- a/storage/tianmu/compress/ppm.h +++ b/storage/tianmu/compress/ppm.h @@ -41,7 +41,7 @@ class PPM { static FILE *dump_; static bool printstat_; - // if data=NULL or dlen=0, the model_ will be null - compression will simply + // if data=nullptr or dlen=0, the model_ will be null - compression will simply // copy the data; 'method' - which version of compression will be used in // Compress/Decompress PPM(const Symb *data, int dlen, ModelType mt, PPMParam param = PPMParam(), uchar method = 2); diff --git a/storage/tianmu/compress/ppm_defs.h b/storage/tianmu/compress/ppm_defs.h index 1becd0703..1aa3f7a88 100644 --- a/storage/tianmu/compress/ppm_defs.h +++ b/storage/tianmu/compress/ppm_defs.h @@ -81,7 +81,7 @@ class PPMModel { // file for making logs during compression or decompression FILE *log_file_; - PPMModel() : log_file_(NULL) {} + PPMModel() : log_file_(nullptr) {} virtual ~PPMModel() {} }; diff --git a/storage/tianmu/compress/text_compressor.cpp b/storage/tianmu/compress/text_compressor.cpp index e6bb10305..19bad70b5 100644 --- a/storage/tianmu/compress/text_compressor.cpp +++ b/storage/tianmu/compress/text_compressor.cpp @@ -133,7 +133,7 @@ CprsErr TextCompressor::DecompressCopy(char *dest, int dlen, char *src, [[maybe_ //--------------------------------------------------------------------------------------------------------- CprsErr TextCompressor::CompressPlain(char *dest, int &dlen, char *src, int slen, int ver, int lev) { - if ((dest == NULL) || (src == NULL) || (dlen <= 0) || (slen <= 0)) + if ((dest == nullptr) || (src == nullptr) || (dlen <= 0) || (slen <= 0)) return CprsErr::CPRS_ERR_PAR; if ((ver < 0) || (ver > 2) || (lev < 1) || (lev > 9)) return CprsErr::CPRS_ERR_VER; @@ -182,7 +182,7 @@ CprsErr TextCompressor::CompressPlain(char *dest, int &dlen, char *src, int slen } CprsErr TextCompressor::DecompressPlain(char *dest, int dlen, char *src, int slen) { - if ((dest == NULL) || (src == NULL) || (dlen <= 0) || (slen <= 0)) + if ((dest == nullptr) || (src == nullptr) || (dlen <= 0) || (slen <= 0)) return CprsErr::CPRS_ERR_PAR; if (slen < 2) return CprsErr::CPRS_ERR_BUF; diff --git a/storage/tianmu/compress/word_graph.cpp b/storage/tianmu/compress/word_graph.cpp index a3998e030..0960425f4 100644 --- a/storage/tianmu/compress/word_graph.cpp +++ b/storage/tianmu/compress/word_graph.cpp @@ -40,7 +40,7 @@ WordGraph::WordGraph(const Symb *data_, int dlen_, bool insatend_) { } void WordGraph::Init() { - data_ = NULL; + data_ = nullptr; dlen_ = -1; // NIL_ = 0; ROOT = 1; // nleaves = 0; @@ -64,7 +64,7 @@ void WordGraph::Init() { // iscreating = false; // for(int i = 0; i < 256; i++) // nodes_[NIL_].child[i] = ROOT; - // lens = NULL; + // lens = nullptr; } void WordGraph::Create() { @@ -296,7 +296,7 @@ void WordGraph::Clear() { finals_.clear(); edges_.clear(); nodes_.clear(); - data_ = NULL; + data_ = nullptr; } //------------------------------------------------------------------------ @@ -750,7 +750,7 @@ void WordGraph::Move(PEdge e) { } void WordGraph::MakeLog(PNode stt, PEdge e) { - if (log_file_ == NULL) + if (log_file_ == nullptr) return; // if(e != ENIL_) { // std::fprintf(log_file_, "F\n"); // forward transition diff --git a/storage/tianmu/core/aggregation_algorithm.cpp b/storage/tianmu/core/aggregation_algorithm.cpp index 902cbf315..fec171ee8 100644 --- a/storage/tianmu/core/aggregation_algorithm.cpp +++ b/storage/tianmu/core/aggregation_algorithm.cpp @@ -86,7 +86,7 @@ void AggregationAlgorithm::Aggregate(bool just_distinct, int64_t &limit, int64_t continue; } if ((!just_distinct && cur_a.mode != common::ColOperation::GROUP_BY) || // aggregation - (just_distinct && cur_a.alias == NULL)) { // special case: hidden column for DISTINCT + (just_distinct && cur_a.alias == nullptr)) { // special case: hidden column for DISTINCT bool already_added = false; for (uint j = 0; j < i; j++) { if (*(t->GetAttrP(j)) == cur_a) { @@ -183,7 +183,7 @@ void AggregationAlgorithm::Aggregate(bool just_distinct, int64_t &limit, int64_t } if (all_done_in_one_row) { - for (uint i = 0; i < t->NumOfAttrs(); i++) { // left as uninitialized (NULL or 0) + for (uint i = 0; i < t->NumOfAttrs(); i++) { // left as uninitialized (nullptr or 0) t->GetAttrP(i)->page_size = 1; t->GetAttrP(i)->CreateBuffer(1); } @@ -282,7 +282,7 @@ void AggregationAlgorithm::MultiDimensionalGroupByScan(GroupByWrapper &gbw, int6 mit.Rewind(); // aggregated rows will be massively omitted packrow by // packrow rewind_needed = true; - for (uint i = 0; i < t->NumOfAttrs(); i++) { // left as uninitialized (NULL or 0) + for (uint i = 0; i < t->NumOfAttrs(); i++) { // left as uninitialized (nullptr or 0) if (t->GetAttrP(i)->mode == common::ColOperation::DELAYED) { MIDummyIterator m(1); t->GetAttrP(i)->term.vc->LockSourcePacks(m); diff --git a/storage/tianmu/core/aggregator_advanced.cpp b/storage/tianmu/core/aggregator_advanced.cpp index 2f827a53a..f60ed403b 100644 --- a/storage/tianmu/core/aggregator_advanced.cpp +++ b/storage/tianmu/core/aggregator_advanced.cpp @@ -214,7 +214,7 @@ void AggregatorGroupConcat::PutAggregatedValue(unsigned char *buf, const types:: types::BString AggregatorGroupConcat::GetValueT(unsigned char *buf) { auto it = lenmap.find(buf); if (it == lenmap.end()) { - // cases that grouping value is NULL + // cases that grouping value is nullptr return types::BString(); } diff --git a/storage/tianmu/core/blocked_mem_table.cpp b/storage/tianmu/core/blocked_mem_table.cpp index b884b768b..6cfdded12 100644 --- a/storage/tianmu/core/blocked_mem_table.cpp +++ b/storage/tianmu/core/blocked_mem_table.cpp @@ -29,7 +29,7 @@ void *MemBlockManager::GetBlock() { DEBUG_ASSERT(block_size != -1); if (hard_size_limit != -1 && hard_size_limit <= current_size) - return NULL; + return nullptr; { std::scoped_lock g(mx); @@ -61,7 +61,7 @@ int MemBlockManager::MemoryBlocksLeft() { } void MemBlockManager::FreeBlock(void *b) { - if (b == NULL) + if (b == nullptr) return; std::scoped_lock g(mx); size_t r = used_blocks.erase(b); @@ -106,7 +106,7 @@ void BlockedRowMemStorage::Init(int rowl, std::shared_ptr mbm, } void BlockedRowMemStorage::Clear() { - for (auto &b : blocks) bman->FreeBlock(b); // may be NULL already + for (auto &b : blocks) bman->FreeBlock(b); // may be nullptr already blocks.clear(); no_rows = 0; release = false; @@ -175,7 +175,7 @@ bool BlockedRowMemStorage::NextRow() { if (release) { if ((current & ndx_mask) == 0) { bman->FreeBlock(blocks[(current >> npower) - 1]); - blocks[(current >> npower) - 1] = NULL; + blocks[(current >> npower) - 1] = nullptr; } } diff --git a/storage/tianmu/core/bloom_block.cpp b/storage/tianmu/core/bloom_block.cpp index ec344ecb7..e21f6da2e 100644 --- a/storage/tianmu/core/bloom_block.cpp +++ b/storage/tianmu/core/bloom_block.cpp @@ -193,7 +193,7 @@ void FilterBlockBuilder::GenerateFilter() { } FilterBlockReader::FilterBlockReader(const FilterPolicy *policy, const Slice &contents) - : policy_(policy), data_(NULL), offset_(NULL), num_(0), base_lg_(0) { + : policy_(policy), data_(nullptr), offset_(nullptr), num_(0), base_lg_(0) { size_t n = contents.size(); if (n < 5) return; // 1 byte for base_lg_ and 4 for start of offset array diff --git a/storage/tianmu/core/bloom_coding.cpp b/storage/tianmu/core/bloom_coding.cpp index 6f4446808..9bc124486 100644 --- a/storage/tianmu/core/bloom_coding.cpp +++ b/storage/tianmu/core/bloom_coding.cpp @@ -136,14 +136,14 @@ const char *GetVarint32PtrFallback(const char *p, const char *limit, uint32_t *v return reinterpret_cast(p); } } - return NULL; + return nullptr; } bool GetVarint32(Slice *input, uint32_t *value) { const char *p = input->data(); const char *limit = p + input->size(); const char *q = GetVarint32Ptr(p, limit, value); - if (q == NULL) { + if (q == nullptr) { return false; } else { *input = Slice(q, limit - q); @@ -165,14 +165,14 @@ const char *GetVarint64Ptr(const char *p, const char *limit, uint64_t *value) { return reinterpret_cast(p); } } - return NULL; + return nullptr; } bool GetVarint64(Slice *input, uint64_t *value) { const char *p = input->data(); const char *limit = p + input->size(); const char *q = GetVarint64Ptr(p, limit, value); - if (q == NULL) { + if (q == nullptr) { return false; } else { *input = Slice(q, limit - q); @@ -183,10 +183,10 @@ bool GetVarint64(Slice *input, uint64_t *value) { const char *GetLengthPrefixedSlice(const char *p, const char *limit, Slice *result) { uint32_t len; p = GetVarint32Ptr(p, limit, &len); - if (p == NULL) - return NULL; + if (p == nullptr) + return nullptr; if (p + len > limit) - return NULL; + return nullptr; *result = Slice(p, len); return p + len; } diff --git a/storage/tianmu/core/bloom_coding.h b/storage/tianmu/core/bloom_coding.h index cbf71a932..9b7cf48df 100644 --- a/storage/tianmu/core/bloom_coding.h +++ b/storage/tianmu/core/bloom_coding.h @@ -42,7 +42,7 @@ extern bool GetLengthPrefixedSlice(Slice *input, Slice *result); // Pointer-based variants of GetVarint... These either store a value // in *v and return a pointer just past the parsed value, or return -// NULL on error. These routines only look at bytes in the range +// nullptr on error. These routines only look at bytes in the range // [p..limit-1] extern const char *GetVarint32Ptr(const char *p, const char *limit, uint32_t *v); extern const char *GetVarint64Ptr(const char *p, const char *limit, uint64_t *v); diff --git a/storage/tianmu/core/cached_buffer.cpp b/storage/tianmu/core/cached_buffer.cpp index 7585a5056..da74ecade 100644 --- a/storage/tianmu/core/cached_buffer.cpp +++ b/storage/tianmu/core/cached_buffer.cpp @@ -44,7 +44,7 @@ CachedBuffer::CachedBuffer(uint page_size, uint elem_size, Trans buf = (char *)alloc(buf_size, mm::BLOCK_TYPE::BLOCK_TEMPORARY); std::memset(buf, 0, buf_size); } else - buf = NULL; + buf = nullptr; loaded_page = 0; page_changed = false; } @@ -69,7 +69,7 @@ void CachedBuffer::Get(types::BString &s, uint64_t idx) { LoadPage((uint)(idx / page_size)); uint64_t pos = (idx % page_size) * (elem_size + 4); uint size = *(uint *)&buf[pos]; - if (size == common::NULL_VALUE_U) // 0 -NULL, 1 -NOT NULL + if (size == common::NULL_VALUE_U) // 0 -nullptr, 1 -NOT nullptr s = types::BString(); else if (size == 0) s = types::BString(ZERO_LENGTH_STRING, 0); diff --git a/storage/tianmu/core/cached_buffer.h b/storage/tianmu/core/cached_buffer.h index c77e6a30f..d547b3d73 100644 --- a/storage/tianmu/core/cached_buffer.h +++ b/storage/tianmu/core/cached_buffer.h @@ -38,7 +38,7 @@ class Transaction; template class CachedBuffer : public system::CacheableItem, public mm::TraceableObject { public: - explicit CachedBuffer(uint page_size = 33554432, uint elem_size = 0, Transaction *conn = NULL); + explicit CachedBuffer(uint page_size = 33554432, uint elem_size = 0, Transaction *conn = nullptr); virtual ~CachedBuffer(); uint64_t PageSize() { return page_size; } @@ -69,9 +69,9 @@ equal size, thus elem_size must be set */ template <> class CachedBuffer : public system::CacheableItem, public mm::TraceableObject { public: - CachedBuffer(uint page_size = 33554432, uint elem_size = 0, Transaction *conn = NULL); + CachedBuffer(uint page_size = 33554432, uint elem_size = 0, Transaction *conn = nullptr); CachedBuffer(uint64_t size, types::BString &value, uint page_size = 33554432, uint elem_size = 0, - Transaction *conn = NULL); + Transaction *conn = nullptr); virtual ~CachedBuffer(); uint64_t PageSize() { return page_size; } diff --git a/storage/tianmu/core/column_bin_encoder.cpp b/storage/tianmu/core/column_bin_encoder.cpp index b4730fab9..730f206ad 100644 --- a/storage/tianmu/core/column_bin_encoder.cpp +++ b/storage/tianmu/core/column_bin_encoder.cpp @@ -33,7 +33,7 @@ ColumnBinEncoder::ColumnBinEncoder(int flags) { implicit = false; disabled = false; - vc = NULL; + vc = nullptr; val_offset = 0; val_sec_offset = 0; val_size = 0; @@ -86,11 +86,11 @@ ColumnBinEncoder::~ColumnBinEncoder() { } bool ColumnBinEncoder::PrepareEncoder(vcolumn::VirtualColumn *_vc, vcolumn::VirtualColumn *_vc2) { - if (_vc == NULL) + if (_vc == nullptr) return false; bool nulls_possible = false; if (!ignore_nulls) - nulls_possible = _vc->IsNullsPossible() || (_vc2 != NULL && _vc2->IsNullsPossible()); + nulls_possible = _vc->IsNullsPossible() || (_vc2 != nullptr && _vc2->IsNullsPossible()); vc = _vc; ColumnType vct = vc->Type(); ColumnType vct2 = _vc2 ? _vc2->Type() : ColumnType(); @@ -107,11 +107,11 @@ bool ColumnBinEncoder::PrepareEncoder(vcolumn::VirtualColumn *_vc, vcolumn::Virt my_encoder.reset(new ColumnBinEncoder::EncoderDate(vc, decodable, nulls_possible, descending)); } else if (vct.GetTypeName() == common::CT::YEAR) { my_encoder.reset(new ColumnBinEncoder::EncoderYear(vc, decodable, nulls_possible, descending)); - } else if (!monotonic_encoding && vct.IsLookup() && _vc2 == NULL && + } else if (!monotonic_encoding && vct.IsLookup() && _vc2 == nullptr && !types::RequiresUTFConversions(vc->GetCollation())) { // Lookup encoding: only non-UTF my_encoder.reset(new ColumnBinEncoder::EncoderLookup(vc, decodable, nulls_possible, descending)); lookup_encoder = true; - } else if (!monotonic_encoding && vct.IsLookup() && _vc2 != NULL && + } else if (!monotonic_encoding && vct.IsLookup() && _vc2 != nullptr && vct2.IsLookup()) { // Lookup in joining - may be UTF my_encoder.reset(new ColumnBinEncoder::EncoderLookup(vc, decodable, nulls_possible, descending)); lookup_encoder = true; @@ -143,7 +143,7 @@ bool ColumnBinEncoder::PrepareEncoder(vcolumn::VirtualColumn *_vc, vcolumn::Virt // implemented yet my_encoder.reset(new ColumnBinEncoder::EncoderText(vc, decodable, nulls_possible, descending)); } - if (_vc2 != NULL) { // multiple column encoding? + if (_vc2 != nullptr) { // multiple column encoding? bool encoding_possible = my_encoder->SecondColumn(_vc2); if (!encoding_possible) { bool second_try = false; @@ -444,7 +444,7 @@ int64_t ColumnBinEncoder::EncoderInt::GetValue64(uchar *buf, [[maybe_unused]] uc } void ColumnBinEncoder::EncoderInt::UpdateStatistics(unsigned char *buf) { - int64_t v = GetValue64(buf, NULL); + int64_t v = GetValue64(buf, nullptr); if (null_status > 0 && v == common::NULL_VALUE_64) return; if (v > max_found) @@ -624,7 +624,7 @@ int64_t ColumnBinEncoder::EncoderDate::GetValue64(uchar *buf, uchar *buf_sec) { } void ColumnBinEncoder::EncoderDate::UpdateStatistics(unsigned char *buf) { - int64_t v = EncoderInt::GetValue64(buf, NULL); + int64_t v = EncoderInt::GetValue64(buf, nullptr); if (null_status > 0 && v == common::NULL_VALUE_64) return; if (v > max_found) // min/max_found as types::DT::DateSortEncoding @@ -717,7 +717,7 @@ int64_t ColumnBinEncoder::EncoderYear::GetValue64(uchar *buf, uchar *buf_sec) { } void ColumnBinEncoder::EncoderYear::UpdateStatistics(unsigned char *buf) { - int64_t v = EncoderInt::GetValue64(buf, NULL); + int64_t v = EncoderInt::GetValue64(buf, nullptr); if (null_status > 0 && v == common::NULL_VALUE_64) return; if (v > max_found) // min/max_found as types::DT::YearSortEncoding @@ -1107,14 +1107,14 @@ ColumnBinEncoder::EncoderLookup::EncoderLookup(vcolumn::VirtualColumn *vc, bool int64_t pmax = vc->RoughMax(); min_val = pmin; max_code = uint64_t(pmax - pmin); - // 0 is always NULL for lookup (because we must encode non-existing strings) + // 0 is always nullptr for lookup (because we must encode non-existing strings) null_status = 1; // 0 is null max_code++; size = CalculateByteSize(max_code); size_sec = 0; first_vc = vc; - sec_vc = NULL; - translate2 = NULL; + sec_vc = nullptr; + translate2 = nullptr; no_sec_values = -1; } @@ -1126,7 +1126,7 @@ ColumnBinEncoder::EncoderLookup::EncoderLookup(const EncoderLookup &sec) : Encod translate2 = new int[no_sec_values]; std::memcpy(translate2, sec.translate2, no_sec_values * sizeof(int)); } else - translate2 = NULL; + translate2 = nullptr; } ColumnBinEncoder::EncoderLookup::~EncoderLookup() { delete[] translate2; } @@ -1238,7 +1238,7 @@ ColumnBinEncoder::EncoderTextStat::EncoderTextStat(vcolumn::VirtualColumn *vc, b coder.CreateEncoding(); valid = coder.IsValid(); min_val = 0; - max_code = coder.MaxCode() + 2; // +1 for a PLUS_INF value, +1 for NULL or MINUS_INF value + max_code = coder.MaxCode() + 2; // +1 for a PLUS_INF value, +1 for nullptr or MINUS_INF value null_status = 1; // 0 is null size = CalculateByteSize(max_code); size_sec = 0; @@ -1250,7 +1250,7 @@ bool ColumnBinEncoder::EncoderTextStat::SecondColumn(vcolumn::VirtualColumn *vc) // in the meantime valid = coder.IsValid(); min_val = 0; - max_code = coder.MaxCode() + 2; // +1 for a PLUS_INF value, +1 for NULL or MINUS_INF value + max_code = coder.MaxCode() + 2; // +1 for a PLUS_INF value, +1 for nullptr or MINUS_INF value size = CalculateByteSize(max_code); return valid; } diff --git a/storage/tianmu/core/column_bin_encoder.h b/storage/tianmu/core/column_bin_encoder.h index 86e0d6f1a..0cc7cd5d5 100644 --- a/storage/tianmu/core/column_bin_encoder.h +++ b/storage/tianmu/core/column_bin_encoder.h @@ -60,7 +60,7 @@ class ColumnBinEncoder final { // flags bool PrepareEncoder( vcolumn::VirtualColumn *vc1, - vcolumn::VirtualColumn *vc2 = NULL); // encoder for one column, or a common encoder for two of them + vcolumn::VirtualColumn *vc2 = nullptr); // encoder for one column, or a common encoder for two of them // return false if encoding of a second column is not possible (incompatible) void Disable() { disabled = true; } @@ -99,7 +99,7 @@ class ColumnBinEncoder final { } void LoadPacks(MIIterator *mit); - void Encode(unsigned char *buf, MIIterator &mit, vcolumn::VirtualColumn *alternative_vc = NULL, + void Encode(unsigned char *buf, MIIterator &mit, vcolumn::VirtualColumn *alternative_vc = nullptr, bool update_stats = false); bool PutValue64(unsigned char *buf, int64_t v, bool sec_column, bool update_stats = false); // used in special cases only (e.g. rough), @@ -494,7 +494,7 @@ class MultiindexPositionEncoder { int dim); // how many bytes is needed to encode the dimension private: - // Encoding: 0 = NULL, or k+1. Stored on a minimal number of bytes. + // Encoding: 0 = nullptr, or k+1. Stored on a minimal number of bytes. int val_offset; // buffer offset of the value - externally set uint val_size; // number of bytes for all the stored dimensions diff --git a/storage/tianmu/core/compilation_tools.cpp b/storage/tianmu/core/compilation_tools.cpp index 72aea6196..b6fbcaebf 100644 --- a/storage/tianmu/core/compilation_tools.cpp +++ b/storage/tianmu/core/compilation_tools.cpp @@ -107,9 +107,9 @@ int OperationUnmysterify(Item *item, common::ColOperation &oper, bool &distinct, oper = common::ColOperation::VAR_POP; break; case Item_sum::SUM_BIT_FUNC: - if (dynamic_cast(item) != NULL) + if (dynamic_cast(item) != nullptr) oper = common::ColOperation::BIT_XOR; - else if (dynamic_cast(item) != NULL) + else if (dynamic_cast(item) != nullptr) oper = common::ColOperation::BIT_AND; else oper = common::ColOperation::BIT_OR; @@ -169,7 +169,7 @@ void PrintItemTree(Item *item, int indent) { indent += 1; if (!item) { - std::fprintf(stderr, "NULL item\n"); + std::fprintf(stderr, "nullptr item\n"); return; } diff --git a/storage/tianmu/core/compiled_query.cpp b/storage/tianmu/core/compiled_query.cpp index a15882c88..164d819a0 100644 --- a/storage/tianmu/core/compiled_query.cpp +++ b/storage/tianmu/core/compiled_query.cpp @@ -55,7 +55,7 @@ CompiledQuery::CQStep::CQStep(const CompiledQuery::CQStep &s) tmpar(s.tmpar), jt(s.jt), cop(s.cop), - alias(NULL), + alias(nullptr), mysql_expr(s.mysql_expr), virt_cols(s.virt_cols), tables1(s.tables1), @@ -68,7 +68,7 @@ CompiledQuery::CQStep::CQStep(const CompiledQuery::CQStep &s) alias = new char[alias_ct]; std::strcpy(alias, s.alias); } else - alias = NULL; + alias = nullptr; } CompiledQuery::CQStep &CompiledQuery::CQStep::operator=(const CompiledQuery::CQStep &s) { @@ -169,10 +169,10 @@ void CompiledQuery::CQStep::Print(Query *query) { std::strcpy(b_op, ">=ANY"); break; case common::Operator::O_IS_NULL: - std::strcpy(b_op, "IS NULL"); + std::strcpy(b_op, "IS nullptr"); break; case common::Operator::O_NOT_NULL: - std::strcpy(b_op, "IS NOT NULL"); + std::strcpy(b_op, "IS NOT nullptr"); break; case common::Operator::O_BETWEEN: std::strcpy(b_op, "BETWEEN"); @@ -607,14 +607,14 @@ void CompiledQuery::AddColumn(AttrID &a_out, const TabID &t1, CQTerm e1, common: s.t1 = t1; s.e1 = e1; s.cop = op; - if (op == common::ColOperation::GROUP_CONCAT && si != NULL) + if (op == common::ColOperation::GROUP_CONCAT && si != nullptr) s.si = *si; if (alias) { size_t const alias_ct(std::strlen(alias) + 1); s.alias = new char[alias_ct]; std::strcpy(s.alias, alias); } else - s.alias = NULL; + s.alias = nullptr; s.n1 = distinct ? 1 : 0; steps.push_back(s); if (op == common::ColOperation::GROUP_BY) diff --git a/storage/tianmu/core/compiled_query.h b/storage/tianmu/core/compiled_query.h index 38d87c647..58c836194 100644 --- a/storage/tianmu/core/compiled_query.h +++ b/storage/tianmu/core/compiled_query.h @@ -97,7 +97,7 @@ class CompiledQuery final { tmpar(TMParameter::TM_DISTINCT), jt(JoinType::JO_INNER), cop(common::ColOperation::LISTING), - alias(NULL), + alias(nullptr), n1(common::NULL_VALUE_64), n2(common::NULL_VALUE_64), si(){}; @@ -129,7 +129,7 @@ class CompiledQuery final { // Add a new step to the execution plan - void TableAlias(TabID &t_out, const TabID &n, const char *tab_name = NULL, int id = -1); + void TableAlias(TabID &t_out, const TabID &n, const char *tab_name = nullptr, int id = -1); void TmpTable(TabID &t_out, const TabID &t1, bool for_subq = false); void CreateConds(CondID &c_out, const TabID &t1, CQTerm e1, common::Operator pr, CQTerm e2, CQTerm e3 = CQTerm(), bool is_or_subtree = false, char like_esc = '\\'); @@ -148,7 +148,7 @@ class CompiledQuery final { void AddConds(const TabID &t1, const CondID &c1, CondType cond_type); void ApplyConds(const TabID &t1); void AddColumn(AttrID &a_out, const TabID &t1, CQTerm e1, common::ColOperation op, char const alias[] = 0, - bool distinct = false, SI *si = NULL); + bool distinct = false, SI *si = nullptr); /*! \brief Create compilation step CREATE_VC for mysql expression * \param a_out - id of created virtual column diff --git a/storage/tianmu/core/condition.h b/storage/tianmu/core/condition.h index fe967dbb5..9045ea342 100644 --- a/storage/tianmu/core/condition.h +++ b/storage/tianmu/core/condition.h @@ -49,7 +49,7 @@ class SingleTreeCondition : public Condition { DescTree *tree; public: - SingleTreeCondition() { tree = NULL; } + SingleTreeCondition() { tree = nullptr; } SingleTreeCondition(CQTerm e1, common::Operator op, CQTerm e2, CQTerm e3, TempTable *t, int no_dims, char like_esc); virtual ~SingleTreeCondition(); using Condition::AddDescriptor; diff --git a/storage/tianmu/core/condition_encoder.cpp b/storage/tianmu/core/condition_encoder.cpp index 3143b70ad..f67f8ae79 100644 --- a/storage/tianmu/core/condition_encoder.cpp +++ b/storage/tianmu/core/condition_encoder.cpp @@ -36,8 +36,8 @@ ConditionEncoder::ConditionEncoder(bool additional_nulls, uint32_t power) in_type(ColumnType(common::CT::UNK)), sharp(false), encoding_done(false), - attr(NULL), - desc(NULL), + attr(nullptr), + desc(nullptr), pack_power(power) {} ConditionEncoder::~ConditionEncoder() {} @@ -93,7 +93,7 @@ void ConditionEncoder::DescriptorTransformation() { if (desc->op == common::Operator::O_NOT_EQ_ALL) desc->op = common::Operator::O_NOT_IN; - static MIIterator mit(NULL, pack_power); + static MIIterator mit(nullptr, pack_power); if (desc->val1.IsNull() || (!IsSetOperator(desc->op) && desc->val1.vc && desc->val1.vc->IsConst() && desc->val1.vc->IsNull(mit))) { desc->op = common::Operator::O_FALSE; @@ -197,7 +197,7 @@ void ConditionEncoder::TransformWithRespectToNulls() { if ((IsSetAllOperator(desc->op) || desc->op == common::Operator::O_NOT_IN) && desc->val1.vc && desc->val1.vc->IsMultival()) { vcolumn::MultiValColumn *mvc = static_cast(desc->val1.vc); - MIIterator mit(NULL, pack_power); + MIIterator mit(nullptr, pack_power); // Change to common::Operator::O_FALSE for non-subselect columns, or non-correlated // subselects (otherwise ContainsNulls needs feeding arguments) if (mvc->ContainsNull(mit)) { @@ -236,7 +236,7 @@ void ConditionEncoder::TransformOtherThanINsOnNumerics() { int64_t v1 = 0; int64_t v2 = 0; bool v1_rounded = false, v2_rounded = false; - static MIIterator mit(NULL, pack_power); + static MIIterator mit(nullptr, pack_power); vcolumn::MultiValColumn *mvc = 0; if (desc->val1.vc && (desc->val1.vc)->IsMultival()) { @@ -384,7 +384,7 @@ void ConditionEncoder::TransformOtherThanINsOnNumerics() { void ConditionEncoder::TransformLIKEsPattern() { MEASURE_FET("ConditionEncoder::TransformLIKEsPattern(...)"); - static MIIterator const mit(NULL, pack_power); + static MIIterator const mit(nullptr, pack_power); types::BString pattern; desc->val1.vc->GetValueString(pattern, mit); uint min_len = 0; @@ -429,7 +429,7 @@ void ConditionEncoder::TransformLIKEsIntoINsOnLookup() { desc->op = common::Operator::O_NOT_IN; ValueSet valset(desc->table->Getpackpower()); - static MIIterator mid(NULL, pack_power); + static MIIterator mid(nullptr, pack_power); in_type = ColumnType(common::CT::NUM); types::BString pattern; desc->val1.vc->GetValueString(pattern, mid); @@ -444,7 +444,7 @@ void ConditionEncoder::TransformLIKEsIntoINsOnLookup() { if (res) valset.Add64(i); } - desc->val1.vc = new vcolumn::InSetColumn(in_type, NULL, valset); + desc->val1.vc = new vcolumn::InSetColumn(in_type, nullptr, valset); desc->val1.vc_id = desc->table->AddVirtColumn(desc->val1.vc); if (static_cast(*desc->val1.vc).IsEmpty(mid)) { if (desc->op == common::Operator::O_IN) @@ -466,7 +466,7 @@ void ConditionEncoder::TransformLIKEs() { void ConditionEncoder::TransformINsOnLookup() { MEASURE_FET("ConditionEncoder::TransformINsOnLookup(...)"); - static MIIterator mid(NULL, pack_power); + static MIIterator mid(nullptr, pack_power); ValueSet valset(desc->table->Getpackpower()); types::BString s; for (int i = 0; i < attr->Cardinality(); i++) { @@ -475,7 +475,7 @@ void ConditionEncoder::TransformINsOnLookup() { valset.Add64(i); } in_type = ColumnType(common::CT::NUM); - desc->val1.vc = new vcolumn::InSetColumn(in_type, NULL, valset); + desc->val1.vc = new vcolumn::InSetColumn(in_type, nullptr, valset); desc->val1.vc_id = desc->table->AddVirtColumn(desc->val1.vc); if (static_cast(*desc->val1.vc).IsEmpty(mid)) { if (desc->op == common::Operator::O_IN) @@ -487,7 +487,7 @@ void ConditionEncoder::TransformINsOnLookup() { void ConditionEncoder::TransformIntoINsOnLookup() { MEASURE_FET("ConditionEncoder::TransformIntoINsOnLookup(...)"); - static MIIterator mit(NULL, pack_power); + static MIIterator mit(nullptr, pack_power); ValueSet vset_positive(desc->table->Getpackpower()); ValueSet vset_negative(desc->table->Getpackpower()); types::BString s, vs1, vs2; @@ -556,11 +556,11 @@ void ConditionEncoder::TransformIntoINsOnLookup() { if (count1 <= count0) { desc->op = common::Operator::O_IN; - desc->val1.vc = new vcolumn::InSetColumn(in_type, NULL, vset_positive /* *vset.release()*/); + desc->val1.vc = new vcolumn::InSetColumn(in_type, nullptr, vset_positive /* *vset.release()*/); desc->val1.vc_id = desc->table->AddVirtColumn(desc->val1.vc); } else { desc->op = common::Operator::O_NOT_IN; - desc->val1.vc = new vcolumn::InSetColumn(in_type, NULL, vset_negative /* *vset_n.release() */); + desc->val1.vc = new vcolumn::InSetColumn(in_type, nullptr, vset_negative /* *vset_n.release() */); desc->val1.vc_id = desc->table->AddVirtColumn(desc->val1.vc); } } @@ -591,7 +591,7 @@ void ConditionEncoder::TransformINs() { MEASURE_FET("ConditionEncoder::TransformINs(...)"); DEBUG_ASSERT(dynamic_cast(desc->val1.vc)); - static MIIterator mit(NULL, pack_power); + static MIIterator mit(nullptr, pack_power); vcolumn::MultiValColumn &mvc = static_cast(*desc->val1.vc); mvc.SetExpectedType(in_type); @@ -674,7 +674,7 @@ void ConditionEncoder::TransformOtherThanINsOnNotLookup() { sharp = false; //(SOME, ALL) - MIIterator mit(NULL, pack_power); + MIIterator mit(nullptr, pack_power); vcolumn::MultiValColumn *mvc = 0; if (v1.vc && v1.vc->IsMultival()) { mvc = static_cast(v1.vc); @@ -759,15 +759,15 @@ void ConditionEncoder::EncodeIfPossible(Descriptor &desc, bool for_rough_query, return; vcolumn::SingleColumn *vcsc = - (static_cast(desc.attr.vc->IsSingleColumn()) ? static_cast(desc.attr.vc) : NULL); + (static_cast(desc.attr.vc->IsSingleColumn()) ? static_cast(desc.attr.vc) : nullptr); bool encode_now = false; if (desc.IsType_AttrAttr() && IsSimpleEqualityOperator(desc.op) && vcsc) { // special case: simple operator on two compatible numerical columns - vcolumn::SingleColumn *vcsc2 = NULL; + vcolumn::SingleColumn *vcsc2 = nullptr; if (static_cast(desc.val1.vc->IsSingleColumn())) vcsc2 = static_cast(desc.val1.vc); - if (vcsc2 == NULL || vcsc->GetVarMap()[0].GetTabPtr()->TableType() != TType::TABLE || + if (vcsc2 == nullptr || vcsc->GetVarMap()[0].GetTabPtr()->TableType() != TType::TABLE || vcsc2->GetVarMap()[0].GetTabPtr()->TableType() != TType::TABLE) return; if (vcsc->Type().IsString() || vcsc->Type().IsLookup() || vcsc2->Type().IsString() || @@ -787,12 +787,13 @@ void ConditionEncoder::EncodeIfPossible(Descriptor &desc, bool for_rough_query, if (!encode_now) { vcolumn::ExpressionColumn *vcec = dynamic_cast(desc.attr.vc); - if (vcec == NULL && (vcsc == NULL || vcsc->GetVarMap()[0].GetTabPtr()->TableType() != TType::TABLE)) + if (vcec == nullptr && (vcsc == nullptr || vcsc->GetVarMap()[0].GetTabPtr()->TableType() != TType::TABLE)) return; - if (vcec != NULL) { - encode_now = (vcec->ExactlyOneLookup() && - (desc.op == common::Operator::O_IS_NULL || desc.op == common::Operator::O_NOT_NULL || - (desc.val1.vc && desc.val1.vc->IsConst() && (desc.val2.vc == NULL || desc.val2.vc->IsConst())))); + if (vcec != nullptr) { + encode_now = + (vcec->ExactlyOneLookup() && + (desc.op == common::Operator::O_IS_NULL || desc.op == common::Operator::O_NOT_NULL || + (desc.val1.vc && desc.val1.vc->IsConst() && (desc.val2.vc == nullptr || desc.val2.vc->IsConst())))); } else { encode_now = (desc.IsType_AttrValOrAttrValVal() || desc.IsType_AttrMultiVal() || desc.op == common::Operator::O_IS_NULL || desc.op == common::Operator::O_NOT_NULL) && @@ -834,7 +835,7 @@ void ConditionEncoder::LookupExpressionTransformation() { col_desc.GetTabPtr().get(), vcec->GetDim()); desc->attr.vc_id = desc->table->AddVirtColumn(desc->attr.vc); desc->op = common::Operator::O_IN; - desc->val1.vc = new vcolumn::InSetColumn(in_type, NULL, valset); + desc->val1.vc = new vcolumn::InSetColumn(in_type, nullptr, valset); desc->val1.vc_id = desc->table->AddVirtColumn(desc->val1.vc); desc->encoded = true; } else if (valset.IsEmpty()) { diff --git a/storage/tianmu/core/cq_term.cpp b/storage/tianmu/core/cq_term.cpp index 665c6f672..639685641 100644 --- a/storage/tianmu/core/cq_term.cpp +++ b/storage/tianmu/core/cq_term.cpp @@ -26,9 +26,9 @@ namespace Tianmu { namespace core { -CQTerm::CQTerm() : type(common::CT::UNK), vc(NULL), vc_id(common::NULL_VALUE_32), is_vc_owner(false) {} +CQTerm::CQTerm() : type(common::CT::UNK), vc(nullptr), vc_id(common::NULL_VALUE_32), is_vc_owner(false) {} -CQTerm::CQTerm(int v) : type(common::CT::UNK), vc(NULL), vc_id(v), is_vc_owner(false) {} +CQTerm::CQTerm(int v) : type(common::CT::UNK), vc(nullptr), vc_id(v), is_vc_owner(false) {} CQTerm::CQTerm(const CQTerm &t) { type = t.type; diff --git a/storage/tianmu/core/cq_term.h b/storage/tianmu/core/cq_term.h index b3309fc13..1833b9381 100644 --- a/storage/tianmu/core/cq_term.h +++ b/storage/tianmu/core/cq_term.h @@ -71,7 +71,7 @@ enum class CondType { /** Interpretation of CQTerm depends on which parameters are used. - All unused parameters must be set to NULL_VALUE (int), NULL (pointers), + All unused parameters must be set to NULL_VALUE (int), nullptr (pointers), SF_NONE (SimpleFunction), common::NULL_VALUE_64 (Tint64_t). When these parameters are set: then the meaning is: @@ -105,7 +105,7 @@ struct CQTerm { CQTerm(const CQTerm &); ~CQTerm(); - bool IsNull() const { return (vc_id == common::NULL_VALUE_32 && vc == NULL); } + bool IsNull() const { return (vc_id == common::NULL_VALUE_32 && vc == nullptr); } CQTerm &operator=(const CQTerm &); bool operator==(const CQTerm &) const; char *ToString(char *buf, int tab_id) const; diff --git a/storage/tianmu/core/data_cache.h b/storage/tianmu/core/data_cache.h index 0ef58d4ba..6997eb384 100644 --- a/storage/tianmu/core/data_cache.h +++ b/storage/tianmu/core/data_cache.h @@ -126,7 +126,7 @@ class DataCache final { if constexpr (T::ID == COORD_TYPE::PACK) { removed->Lock(); } - removed->SetOwner(NULL); + removed->SetOwner(nullptr); c.erase(it); ++m_objectsReleased; } @@ -143,7 +143,7 @@ class DataCache final { auto it = c.find(coord_); if (it != c.end()) { removed = it->second; - removed->SetOwner(NULL); + removed->SetOwner(nullptr); c.erase(it); ++m_objectsReleased; } diff --git a/storage/tianmu/core/descriptor.cpp b/storage/tianmu/core/descriptor.cpp index 60e2695b3..dbd0f3806 100644 --- a/storage/tianmu/core/descriptor.cpp +++ b/storage/tianmu/core/descriptor.cpp @@ -53,8 +53,8 @@ Descriptor::Descriptor() done(false), evaluation(0), delayed(false), - table(NULL), - tree(NULL), + table(nullptr), + tree(nullptr), left_dims(0), right_dims(0), rv(common::RSValue::RS_UNKNOWN), @@ -75,7 +75,7 @@ Descriptor::Descriptor(TempTable *t, int no_dims) // no_dims is a destination n evaluation(0), delayed(false), table(t), - tree(NULL), + tree(nullptr), left_dims(no_dims), right_dims(no_dims), rv(common::RSValue::RS_UNKNOWN), @@ -102,7 +102,7 @@ Descriptor::Descriptor(const Descriptor &desc) { delayed = desc.delayed; table = desc.table; collation = desc.collation; - tree = NULL; + tree = nullptr; if (desc.tree) tree = new DescTree(*desc.tree); left_dims = desc.left_dims; @@ -121,7 +121,7 @@ Descriptor::Descriptor(CQTerm e1, common::Operator pr, CQTerm e2, CQTerm e3, Tem evaluation(0), delayed(false), table(t), - tree(NULL), + tree(nullptr), left_dims(no_dims), right_dims(no_dims), rv(common::RSValue::RS_UNKNOWN), @@ -151,7 +151,7 @@ Descriptor::Descriptor(DescTree *sec_tree, TempTable *t, int no_dims) desc_t(DescriptorJoinType::DT_NOT_KNOWN_YET), collation(DTCollation()), null_after_simplify(false) { - tree = NULL; + tree = nullptr; if (sec_tree) tree = new DescTree(*sec_tree); CalculateJoinType(); @@ -166,7 +166,7 @@ Descriptor::Descriptor(TempTable *t, vcolumn::VirtualColumn *v1, common::Operato evaluation(0), delayed(false), table(t), - tree(NULL), + tree(nullptr), left_dims(0), right_dims(0), rv(common::RSValue::RS_UNKNOWN), @@ -223,7 +223,7 @@ Descriptor &Descriptor::operator=(const Descriptor &d) { like_esc = d.like_esc; table = d.table; delete tree; - tree = NULL; + tree = nullptr; if (d.tree) tree = new DescTree(*d.tree); left_dims = d.left_dims; @@ -349,8 +349,8 @@ void Descriptor::SwitchSides() // change "aa" etc; throw error if bool Descriptor::IsType_AttrValOrAttrValVal() const // true if "phys column op val or column between val and val or " { - // or "phys_column IS NULL/NOT NULL" - if (attr.vc == NULL || !static_cast(attr.vc->IsSingleColumn())) + // or "phys_column IS nullptr/NOT nullptr" + if (attr.vc == nullptr || !static_cast(attr.vc->IsSingleColumn())) return false; return ((val1.vc && val1.vc->IsConst()) || (op == common::Operator::O_IS_NULL || op == common::Operator::O_NOT_NULL)) && @@ -375,7 +375,7 @@ bool Descriptor::IsType_JoinSimple() const // true if more than one table invol bool Descriptor::IsType_AttrAttr() const // true if "column op column" from one table { - if (attr.vc == NULL || val1.vc == NULL || !static_cast(attr.vc->IsSingleColumn()) || + if (attr.vc == nullptr || val1.vc == nullptr || !static_cast(attr.vc->IsSingleColumn()) || !static_cast(val1.vc->IsSingleColumn()) || val2.vc || IsType_Join()) return false; @@ -384,11 +384,11 @@ bool Descriptor::IsType_AttrAttr() const // true if "column op column" from one bool Descriptor::IsType_TIANMUExpression() const // only columns, constants and TIANMUExpressions { - if (attr.vc == NULL) + if (attr.vc == nullptr) return false; if ((static_cast(attr.vc->IsSingleColumn()) || attr.vc->IsConst()) && - (val1.vc == NULL || static_cast(val1.vc->IsSingleColumn()) || val1.vc->IsConst()) && - (val2.vc == NULL || static_cast(val2.vc->IsSingleColumn()) || val2.vc->IsConst())) + (val1.vc == nullptr || static_cast(val1.vc->IsSingleColumn()) || val1.vc->IsConst()) && + (val2.vc == nullptr || static_cast(val2.vc->IsSingleColumn()) || val2.vc->IsConst())) return true; return false; } @@ -450,7 +450,7 @@ common::RSValue Descriptor::EvaluateRoughlyPack(const MIIterator &mit) { void Descriptor::Simplify(bool in_having) { MEASURE_FET("Descriptor::Simplify(...)"); - static MIIterator const mit(NULL, table->Getpackpower()); + static MIIterator const mit(nullptr, table->Getpackpower()); if (op == common::Operator::O_FALSE || op == common::Operator::O_TRUE) return; @@ -476,7 +476,7 @@ void Descriptor::Simplify(bool in_having) { op == common::Operator::O_LESS_EQ || op == common::Operator::O_MORE || op == common::Operator::O_MORE_EQ)) { SwitchSides(); } - if (Query::IsAllAny(op) && dynamic_cast(val1.vc) == NULL) + if (Query::IsAllAny(op) && dynamic_cast(val1.vc) == nullptr) Query::UnmarkAllAny(op); if ((attr.vc && (!attr.vc->IsConst() || (in_having && attr.vc->IsParameterized()))) || (val1.vc && (!val1.vc->IsConst() || (in_having && val1.vc->IsParameterized()))) || @@ -673,38 +673,38 @@ to that effect. */ const QueryOperator *Descriptor::CreateQueryOperator(common::Operator type) const { const char *string_rep[static_cast(common::Operator::OPERATOR_ENUM_COUNT)] = { - "=", // common::Operator::O_EQ - "=ALL", // common::Operator::O_EQ_ALL - "=ANY", // common::Operator::O_EQ_ANY - "<>", // common::Operator::O_NOT_EQ - "<>ALL", // common::Operator::O_NOT_EQ_ALL - "<>ANY", // common::Operator::O_NOT_EQ_ANY - "<", // common::Operator::O_LESS - "", // common::Operator::O_MORE - ">ALL", // common::Operator::O_MORE_ALL - ">ANY", // common::Operator::O_MORE_ANY - "<=", // common::Operator::O_LESS_EQ - "<=ALL", // common::Operator::O_LESS_EQ_ALL - "<=ANY", // common::Operator::O_LESS_EQ_ANY - ">=", // common::Operator::O_MORE_EQ - ">=ALL", // common::Operator::O_MORE_EQ_ALL - ">=ANY", // common::Operator::O_MORE_EQ_ANY - "IS NULL", // common::Operator::O_IS_NULL - "IS NOT NULL", // common::Operator::O_NOT_NULL - "BET.", // common::Operator::O_BETWEEN - "NOT BET.", // common::Operator::O_NOT_BETWEEN - "LIKE", // common::Operator::O_LIKE - "NOT LIKE", // common::Operator::O_NOT_LIKE - "IN", // common::Operator::O_IN - "NOT IN", // common::Operator::O_NOT_IN - "EXISTS", // common::Operator::O_EXISTS - "NOT EXISTS", // common::Operator::O_NOT_EXISTS - "FALSE", // common::Operator::O_FALSE - "TRUE", // common::Operator::O_TRUE - "ESCAPE", // common::Operator::O_ESCAPE - "OR TREE" // common::Operator::O_OR_TREE + "=", // common::Operator::O_EQ + "=ALL", // common::Operator::O_EQ_ALL + "=ANY", // common::Operator::O_EQ_ANY + "<>", // common::Operator::O_NOT_EQ + "<>ALL", // common::Operator::O_NOT_EQ_ALL + "<>ANY", // common::Operator::O_NOT_EQ_ANY + "<", // common::Operator::O_LESS + "", // common::Operator::O_MORE + ">ALL", // common::Operator::O_MORE_ALL + ">ANY", // common::Operator::O_MORE_ANY + "<=", // common::Operator::O_LESS_EQ + "<=ALL", // common::Operator::O_LESS_EQ_ALL + "<=ANY", // common::Operator::O_LESS_EQ_ANY + ">=", // common::Operator::O_MORE_EQ + ">=ALL", // common::Operator::O_MORE_EQ_ALL + ">=ANY", // common::Operator::O_MORE_EQ_ANY + "IS nullptr", // common::Operator::O_IS_NULL + "IS NOT nullptr", // common::Operator::O_NOT_NULL + "BET.", // common::Operator::O_BETWEEN + "NOT BET.", // common::Operator::O_NOT_BETWEEN + "LIKE", // common::Operator::O_LIKE + "NOT LIKE", // common::Operator::O_NOT_LIKE + "IN", // common::Operator::O_IN + "NOT IN", // common::Operator::O_NOT_IN + "EXISTS", // common::Operator::O_EXISTS + "NOT EXISTS", // common::Operator::O_NOT_EXISTS + "FALSE", // common::Operator::O_FALSE + "TRUE", // common::Operator::O_TRUE + "ESCAPE", // common::Operator::O_ESCAPE + "OR TREE" // common::Operator::O_OR_TREE }; return new QueryOperator(type, string_rep[static_cast(type)]); @@ -905,7 +905,7 @@ void Descriptor::UpdateVCStatistics() // Apply all the information from // constants etc. to involved VC { MEASURE_FET("Descriptor::UpdateVCStatistics(...)"); - if (attr.vc == NULL) + if (attr.vc == nullptr) return; if (op == common::Operator::O_IS_NULL) { attr.vc->SetLocalNullsOnly(true); @@ -1001,7 +1001,7 @@ bool Descriptor::CheckCondition_UTF(const MIIterator &mit) { bool attr_ge_val1 = (sharp ? CollationStrCmp(collation, s1, s2) > 0 : CollationStrCmp(collation, s1, s2) >= 0); bool attr_le_val2 = (sharp ? CollationStrCmp(collation, s1, s3) < 0 : CollationStrCmp(collation, s1, s3) <= 0); common::Tribool val1_res, val2_res; - if (encoded) { // Rare case: for encoded conditions treat NULL as +/- inf. + if (encoded) { // Rare case: for encoded conditions treat nullptr as +/- inf. val1_res = val1.vc->IsNull(mit) ? true : common::Tribool(attr_ge_val1); val2_res = val2.vc->IsNull(mit) ? true : common::Tribool(attr_le_val2); } else { @@ -1093,7 +1093,7 @@ bool Descriptor::CheckCondition(const MIIterator &mit) { val1.vc->IsNull(mit) ? common::TRIBOOL_UNKNOWN : common::Tribool(val >= val1.vc->GetNotNullValueInt64(mit)); val2_res = val2.vc->IsNull(mit) ? common::TRIBOOL_UNKNOWN : common::Tribool(val <= val2.vc->GetNotNullValueInt64(mit)); - } else { // Rare case: for encoded conditions treat NULL as +/- inf. + } else { // Rare case: for encoded conditions treat nullptr as +/- inf. types::RCValueObject rcvo1 = attr.vc->GetValue(mit, false); val1_res = val1.vc->IsNull(mit) ? true : (sharp ? common::Tribool(rcvo1 > val1.vc->GetValue(mit, false)) @@ -1167,7 +1167,7 @@ bool Descriptor::IsNull(const MIIterator &mit) { val1.vc->IsNull(mit) ? common::TRIBOOL_UNKNOWN : common::Tribool(val >= val1.vc->GetNotNullValueInt64(mit)); val2_res = val2.vc->IsNull(mit) ? common::TRIBOOL_UNKNOWN : common::Tribool(val <= val2.vc->GetNotNullValueInt64(mit)); - } else { // Rare case: for encoded conditions treat NULL as +/- inf. + } else { // Rare case: for encoded conditions treat nullptr as +/- inf. types::RCValueObject rcvo1 = attr.vc->GetValue(mit, false); val1_res = val1.vc->IsNull(mit) ? true : (sharp ? common::Tribool(rcvo1 > val1.vc->GetValue(mit, false)) @@ -1683,7 +1683,7 @@ common::Tribool Descriptor::RoughCheckSetSubSelectCondition(const MIIterator &mi void Descriptor::CoerceColumnType(vcolumn::VirtualColumn *&for_typecast) { vcolumn::VirtualColumn *vc = attr.vc; - vcolumn::TypeCastColumn *tcc = NULL; + vcolumn::TypeCastColumn *tcc = nullptr; bool tstamp = false; if (ATI::IsNumericType(vc->TypeName())) { if (ATI::IsTxtType(for_typecast->TypeName())) @@ -1990,7 +1990,7 @@ DescTree::DescTree(DescTree &t) { curr = root = Copy(t.root); } DescTreeNode *DescTree::Copy(DescTreeNode *node) { if (!node) - return NULL; + return nullptr; DescTreeNode *res = new DescTreeNode(*node); if (node->left) { res->left = Copy(node->left); @@ -2010,7 +2010,7 @@ DescTreeNode *DescTree::Copy(DescTreeNode *node) { // if(node && node->right) // Release(node->right); // delete node; -// node = NULL; +// node = nullptr; //} // make _lop the root, make current tree the left child, make descriptor the @@ -2035,15 +2035,15 @@ void DescTree::AddTree(common::LogicalOperator lop, DescTree *tree, int no_dims) curr->right = tree->root; tree->root->parent = curr; root = curr; - tree->root = NULL; - tree->curr = NULL; + tree->root = nullptr; + tree->curr = nullptr; } } void DescTree::Display() { Display(root); } void DescTree::Display(DescTreeNode *node) { - if (node == NULL) + if (node == nullptr) return; if (node->left) Display(node->left); @@ -2109,38 +2109,38 @@ common::Tribool DescTreeNode::Simplify(DescTreeNode *&root, bool in_having) { if (res == true) { desc.op = common::Operator::O_TRUE; delete left; - left = NULL; + left = nullptr; delete right; - right = NULL; + right = nullptr; } else if (res == false) { desc.op = common::Operator::O_FALSE; delete left; - left = NULL; + left = nullptr; delete right; - right = NULL; + right = nullptr; } else if (!left->left && !right->right && desc.lop == common::LogicalOperator::O_AND) { bool merged = ParameterizedFilter::TryToMerge(left->desc, right->desc); if (merged) { delete right; - right = NULL; + right = nullptr; res = ReplaceNode(this, left, root); } } else if (desc.lop == common::LogicalOperator::O_OR) { if (left->desc.op == common::Operator::O_FALSE) { delete left; - left = NULL; + left = nullptr; res = ReplaceNode(this, right, root); } else if (left->desc.op == common::Operator::O_TRUE) { delete right; - right = NULL; + right = nullptr; res = ReplaceNode(this, left, root); } else if (right->desc.op == common::Operator::O_FALSE) { delete right; - right = NULL; + right = nullptr; res = ReplaceNode(this, left, root); } else if (right->desc.op == common::Operator::O_TRUE) { delete left; - left = NULL; + left = nullptr; res = ReplaceNode(this, right, root); } } @@ -2428,7 +2428,7 @@ void DescTreeNode::ExtractDescriptor(Descriptor &searched_desc, DescTreeNode *&r (desc.lop == common::LogicalOperator::O_OR && */ left->desc == searched_desc /*)*/) { delete left; - left = NULL; + left = nullptr; DescTreeNode *old_right = right; bool parent_is_or = (desc.lop == common::LogicalOperator::O_OR); ReplaceNode(this, right, root); @@ -2455,7 +2455,7 @@ void DescTreeNode::ExtractDescriptor(Descriptor &searched_desc, DescTreeNode *&r (desc.lop == common::LogicalOperator::O_OR &&*/ right->desc == searched_desc /*)*/) { delete right; - right = NULL; + right = nullptr; DescTreeNode *old_left = left; bool parent_is_or = (desc.lop == common::LogicalOperator::O_OR); ReplaceNode(this, left, root); @@ -2485,8 +2485,8 @@ common::Tribool DescTreeNode::ReplaceNode(DescTreeNode *src, DescTreeNode *dst, root = dst; if (src->left == dst || src->right == dst) { // src's children are reused - prevent deleting them - src->left = NULL; - src->right = NULL; + src->left = nullptr; + src->right = nullptr; } delete src; if (dst->desc.op == common::Operator::O_FALSE) diff --git a/storage/tianmu/core/descriptor.h b/storage/tianmu/core/descriptor.h index 18f3f577d..07dcfd549 100644 --- a/storage/tianmu/core/descriptor.h +++ b/storage/tianmu/core/descriptor.h @@ -76,8 +76,8 @@ class Descriptor { Descriptor(const Descriptor &desc); Descriptor(CQTerm e1, common::Operator pr, CQTerm e2, CQTerm e3, TempTable *t, int no_dims, char like_escape = '\\'); Descriptor(DescTree *tree, TempTable *t, int no_dims); - Descriptor(TempTable *t, vcolumn::VirtualColumn *v1, common::Operator pr, vcolumn::VirtualColumn *v2 = NULL, - vcolumn::VirtualColumn *v3 = NULL); + Descriptor(TempTable *t, vcolumn::VirtualColumn *v1, common::Operator pr, vcolumn::VirtualColumn *v2 = nullptr, + vcolumn::VirtualColumn *v3 = nullptr); void swap(Descriptor &d); @@ -185,14 +185,14 @@ class Descriptor { public: bool null_after_simplify; // true if Simplify set common::Operator::O_FALSE because of - // NULL + // nullptr }; class SortDescriptor { public: vcolumn::VirtualColumn *vc; int dir; // ordering direction: 0 - ascending, 1 - descending - SortDescriptor() : vc(NULL), dir(0){}; + SortDescriptor() : vc(nullptr), dir(0){}; int operator==(const SortDescriptor &sec) { return (dir == sec.dir) && (vc == sec.vc); } }; @@ -209,12 +209,12 @@ bool IsSimpleEqualityOperator(common::Operator op); struct DescTreeNode { DescTreeNode(common::LogicalOperator _lop, TempTable *t, int no_dims) - : desc(t, no_dims), locked(0), left(NULL), right(NULL), parent(NULL) { + : desc(t, no_dims), locked(0), left(nullptr), right(nullptr), parent(nullptr) { desc.lop = _lop; } DescTreeNode(CQTerm e1, common::Operator op, CQTerm e2, CQTerm e3, TempTable *t, int no_dims, char like_esc) - : desc(t, no_dims), locked(0), left(NULL), right(NULL), parent(NULL) { + : desc(t, no_dims), locked(0), left(nullptr), right(nullptr), parent(nullptr) { desc.attr = e1; desc.op = op; desc.val1 = e2; @@ -226,7 +226,7 @@ struct DescTreeNode { } DescTreeNode(DescTreeNode &n, [[maybe_unused]] bool in_subq = false) - : desc(n.desc), locked(0), left(NULL), right(NULL), parent(NULL) {} + : desc(n.desc), locked(0), left(nullptr), right(nullptr), parent(nullptr) {} ~DescTreeNode(); bool CheckCondition(MIIterator &mit); bool IsNull(MIIterator &mit); diff --git a/storage/tianmu/core/dimension_group.cpp b/storage/tianmu/core/dimension_group.cpp index c66836314..69dfc95f1 100644 --- a/storage/tianmu/core/dimension_group.cpp +++ b/storage/tianmu/core/dimension_group.cpp @@ -30,7 +30,7 @@ DimensionGroupFilter::DimensionGroupFilter(int dim, int64_t size, uint32_t power // copy_mode: 0 - copy filter, 1 - ShallowCopy filter, 2 - grab pointer DimensionGroupFilter::DimensionGroupFilter(int dim, Filter *f_source, int copy_mode, [[maybe_unused]] uint32_t power) { base_dim = dim; - f = NULL; + f = nullptr; if (copy_mode == 0) f = new Filter(*f_source); else if (copy_mode == 1) @@ -84,7 +84,7 @@ DimensionGroupMaterialized::DimensionGroupMaterialized(DimensionVector &dims) { t = new IndexTable *[no_dims]; nulls_possible = new bool[no_dims]; for (int i = 0; i < no_dims; i++) { - t[i] = NULL; + t[i] = nullptr; nulls_possible[i] = false; } } @@ -116,7 +116,7 @@ DimensionGroupMaterialized::~DimensionGroupMaterialized() { void DimensionGroupMaterialized::Empty() { for (int i = 0; i < no_dims; i++) { delete t[i]; - t[i] = NULL; + t[i] = nullptr; } no_obj = 0; } @@ -175,7 +175,7 @@ DimensionGroupMaterialized::DGMaterializedIterator::DGMaterializedIterator(int64 one_packrow[dim] = (t[dim]->OrigSize() <= ((1 << p_power) - 1)) && (t[dim]->EndOfCurrentBlock(0) >= (uint64_t)no_obj); } else - t[dim] = NULL; + t[dim] = nullptr; } Rewind(); } @@ -318,7 +318,7 @@ void DimensionGroupMaterialized::DGMaterializedIterator::FindPackEnd(int dim) { } else { // Nulls possible: do not use ahead1...3, because the current pack has to be // checked for nulls anyway - while (loc_iterator < loc_limit && // find the first non-NULL row (NULL row + while (loc_iterator < loc_limit && // find the first non-nullptr row (nullptr row // is when Get64() = 0) cur_t->Get64(loc_iterator) == 0) { nulls_found[dim] = true; @@ -328,7 +328,7 @@ void DimensionGroupMaterialized::DGMaterializedIterator::FindPackEnd(int dim) { loc_pack = ((cur_t->Get64(loc_iterator) - 1) >> p_power); ++loc_iterator; uint64_t ndx; - while (loc_iterator < loc_limit && // find the first non-NULL row from + while (loc_iterator < loc_limit && // find the first non-nullptr row from // another pack (but the same block) ((ndx = cur_t->Get64InsideBlock(loc_iterator)) == 0 || ((ndx - 1) >> p_power) == loc_pack)) { if (ndx == 0) @@ -347,7 +347,7 @@ int DimensionGroupMaterialized::DGMaterializedIterator::GetNextPackrow(int dim, if (ahead == 0) return GetCurPackrow(dim); IndexTable *cur_t = t[dim]; - if (cur_t == NULL) + if (cur_t == nullptr) return -1; uint64_t end_block = cur_t->EndOfCurrentBlock(cur_pos); if (next_pack[dim] >= no_obj || uint64_t(next_pack[dim]) >= end_block) diff --git a/storage/tianmu/core/dimension_group.h b/storage/tianmu/core/dimension_group.h index 5a8d331e6..e8aeeb792 100644 --- a/storage/tianmu/core/dimension_group.h +++ b/storage/tianmu/core/dimension_group.h @@ -38,12 +38,12 @@ class DimensionGroup { virtual void UpdateNumOfTuples() {} // may be not needed for some group types DGType Type() { return dim_group_type; } // type selector virtual Filter *GetFilter([[maybe_unused]] int dim) const { - return NULL; - } // Get the pointer to a filter attached to a dimension. NOTE: will be NULL + return nullptr; + } // Get the pointer to a filter attached to a dimension. NOTE: will be nullptr // if not applicable virtual Filter *GetUpdatableFilter([[maybe_unused]] int dim) const { - return NULL; - } // Get the pointer to a filter, if it may be changed. NOTE: will be NULL if + return nullptr; + } // Get the pointer to a filter, if it may be changed. NOTE: will be nullptr if // not applicable virtual bool DimUsed(int d) = 0; // true if the dimension is involved in this group virtual bool DimEnabled(int d) = 0; // true if the dimension is used and has @@ -118,7 +118,7 @@ class DimensionGroup { virtual DimensionGroup::Iterator *NewIterator(DimensionVector &, uint32_t power) = 0; virtual DimensionGroup::Iterator *NewOrderedIterator(DimensionVector &, [[maybe_unused]] PackOrderer *po, [[maybe_unused]] uint32_t power) { - return NULL; + return nullptr; } // create a new ordered iterator, if possible virtual DimensionGroup::Iterator *CopyIterator(DimensionGroup::Iterator *, uint32_t power) = 0; @@ -308,7 +308,7 @@ class DimensionGroupFilter : public DimensionGroup { class DimensionGroupMaterialized : public DimensionGroup { public: - // NOTE: works also for "count only" (all t[i] are NULL, only no_obj set) + // NOTE: works also for "count only" (all t[i] are nullptr, only no_obj set) DimensionGroupMaterialized(DimensionVector &dims); virtual ~DimensionGroupMaterialized(); DimensionGroup *Clone(bool shallow) override; @@ -320,7 +320,7 @@ class DimensionGroupMaterialized : public DimensionGroup { // dim void SetNumOfObj(int64_t _no_obj) { no_obj = _no_obj; } bool DimUsed(int dim) override { return dims_used[dim]; } - bool DimEnabled(int dim) override { return (t[dim] != NULL); } + bool DimEnabled(int dim) override { return (t[dim] != nullptr); } bool NullsPossible(int dim) override { return nulls_possible[dim]; } void Empty() override; @@ -340,7 +340,7 @@ class DimensionGroupMaterialized : public DimensionGroup { class DGMaterializedIterator : public DimensionGroup::Iterator { public: - // NOTE: works also for "count only" (all t[i] are NULL) + // NOTE: works also for "count only" (all t[i] are nullptr) DGMaterializedIterator(int64_t _no_obj, DimensionVector &dims, IndexTable **_t, bool *nulls, uint32_t power); DGMaterializedIterator(const Iterator &sec, uint32_t power); ~DGMaterializedIterator(); @@ -398,7 +398,7 @@ class DimensionGroupMaterialized : public DimensionGroup { // External pointers: IndexTable **t; // table is local, pointers are from DimensionGroupMaterialized, - // NULL for not used (not iterated) + // nullptr for not used (not iterated) bool *nulls_possible; }; // create a new iterator (to be deleted by user) @@ -410,7 +410,7 @@ class DimensionGroupMaterialized : public DimensionGroup { private: DimensionVector dims_used; int no_dims; // number of all possible dimensions (or just the last used one) - IndexTable **t; // NULL for not used (natural numbering) + IndexTable **t; // nullptr for not used (natural numbering) bool *nulls_possible; }; } // namespace core diff --git a/storage/tianmu/core/dimension_group_multiple.h b/storage/tianmu/core/dimension_group_multiple.h index d1f463332..2ae523d2f 100644 --- a/storage/tianmu/core/dimension_group_multiple.h +++ b/storage/tianmu/core/dimension_group_multiple.h @@ -129,7 +129,7 @@ class MultiIndexTable { class DimensionGroupMultiMaterialized : public DimensionGroup { class DGIterator : public DimensionGroup::Iterator { public: - // NOTE: works also for "count only" (all t[i] are NULL)。 + // NOTE: works also for "count only" (all t[i] are nullptr)。 DGIterator(int64_t total_count, DimensionVector &dims, std::vector &dim_tables, uint32_t power); DGIterator(const Iterator &sec, uint32_t power); ~DGIterator() = default; @@ -162,7 +162,7 @@ class DimensionGroupMultiMaterialized : public DimensionGroup { }; public: - // NOTE: works also for "count only" (all t[i] are NULL, only no_obj set) + // NOTE: works also for "count only" (all t[i] are nullptr, only no_obj set) DimensionGroupMultiMaterialized(int64_t obj, DimensionVector &dims, uint32_t power, bool is_shallow_memory = false); ~DimensionGroupMultiMaterialized() override; @@ -194,7 +194,7 @@ class DimensionGroupMultiMaterialized : public DimensionGroup { DimensionVector dims_used_; // Number of all possible dimensions (or just the last used one). int dims_count_ = 0; - // NULL for not used (natural numbering). + // nullptr for not used (natural numbering). std::vector dim_tables_; bool is_shallow_memory; }; diff --git a/storage/tianmu/core/dimension_group_virtual.cpp b/storage/tianmu/core/dimension_group_virtual.cpp index ea641e9e5..5c3eacf93 100644 --- a/storage/tianmu/core/dimension_group_virtual.cpp +++ b/storage/tianmu/core/dimension_group_virtual.cpp @@ -27,7 +27,7 @@ DimensionGroupVirtual::DimensionGroupVirtual(DimensionVector &dims, int bdim, Fi dims_used = dims; base_dim = bdim; no_dims = dims.Size(); - f = NULL; + f = nullptr; if (copy_mode == 0) f = new Filter(*f_source); else if (copy_mode == 1) @@ -36,11 +36,11 @@ DimensionGroupVirtual::DimensionGroupVirtual(DimensionVector &dims, int bdim, Fi f = f_source; dim_group_type = DGType::DG_VIRTUAL; no_obj = f->NumOfOnes(); - pack_pos = NULL; // created if needed + pack_pos = nullptr; // created if needed t = new IndexTable *[no_dims]; nulls_possible = new bool[no_dims]; for (int i = 0; i < no_dims; i++) { - t[i] = NULL; + t[i] = nullptr; nulls_possible[i] = false; } } @@ -72,7 +72,7 @@ void DimensionGroupVirtual::Empty() { f->Reset(); for (int i = 0; i < no_dims; i++) { delete t[i]; - t[i] = NULL; + t[i] = nullptr; } no_obj = 0; } @@ -93,7 +93,7 @@ DimensionGroup::Iterator *DimensionGroupVirtual::NewIterator(DimensionVector &di DimensionGroup::Iterator *DimensionGroupVirtual::NewOrderedIterator(DimensionVector &dim, PackOrderer *po, uint32_t power) { - if (pack_pos == NULL) { // not used yet - create + if (pack_pos == nullptr) { // not used yet - create int no_packs = f->NumOfBlocks(); pack_pos = new int64_t[no_packs]; int64_t cur_pack_start = 0; diff --git a/storage/tianmu/core/dimension_group_virtual.h b/storage/tianmu/core/dimension_group_virtual.h index eb54daae4..bb4b14a9a 100644 --- a/storage/tianmu/core/dimension_group_virtual.h +++ b/storage/tianmu/core/dimension_group_virtual.h @@ -33,11 +33,11 @@ class DimensionGroupVirtual : public DimensionGroup { void FillCurrentPos(DimensionGroup::Iterator *it, int64_t *cur_pos, int *cur_pack, DimensionVector &dims) override; void UpdateNumOfTuples() override; - Filter *GetFilter(int dim) const override { return (base_dim == dim || dim == -1 ? f : NULL); } + Filter *GetFilter(int dim) const override { return (base_dim == dim || dim == -1 ? f : nullptr); } // For this type of filter: dim == -1 means the only existing one - // Note: GetUpdatableFilter remains default (NULL) + // Note: GetUpdatableFilter remains default (nullptr) bool DimUsed(int dim) override { return (base_dim == dim || dims_used[dim]); } - bool DimEnabled(int dim) override { return (base_dim == dim || t[dim] != NULL); } + bool DimEnabled(int dim) override { return (base_dim == dim || t[dim] != nullptr); } bool NullsPossible(int dim) override { return nulls_possible[dim]; } void Empty() override; void NewDimensionContent(int dim, IndexTable *tnew, @@ -153,7 +153,7 @@ class DimensionGroupVirtual : public DimensionGroup { Filter *f; DimensionVector dims_used; int no_dims; // number of all possible dimensions (or just the last used one) - IndexTable **t; // NULL for not used (natural numbering) and for base_dim + IndexTable **t; // nullptr for not used (natural numbering) and for base_dim int64_t *pack_pos; // table of size = number of packs in base_dim; the first // position of a given pack in all IndexTables bool *nulls_possible; diff --git a/storage/tianmu/core/engine.cpp b/storage/tianmu/core/engine.cpp index f35ec9d61..efa85bc37 100644 --- a/storage/tianmu/core/engine.cpp +++ b/storage/tianmu/core/engine.cpp @@ -44,7 +44,7 @@ #include "util/thread_pool.h" namespace Tianmu { -namespace dbhandler { +namespace handler { extern void resolve_async_join_settings(const std::string &settings); } namespace core { @@ -71,7 +71,7 @@ static int setup_sig_handler() { sa.sa_sigaction = signal_handler; sigemptyset(&sa.sa_mask); - if (sigaction(SIGRTMIN, &sa, NULL) == -1) { + if (sigaction(SIGRTMIN, &sa, nullptr) == -1) { TIANMU_LOG(LogCtl_Level::INFO, "Failed to set up signal handler. error =%d[%s]", errno, std::strerror(errno)); return 1; } @@ -206,7 +206,7 @@ int Engine::Init(uint engine_slot) { } else { rc_querylog_.setOff(); } - std::srand(unsigned(time(NULL))); + std::srand(unsigned(time(nullptr))); if (tianmu_sysvar_servermainheapsize == 0) { long pages = sysconf(_SC_PHYS_PAGES); @@ -319,7 +319,7 @@ int Engine::Init(uint engine_slot) { if (tianmu_sysvar_start_async > 0) ResetTaskExecutor(tianmu_sysvar_start_async); - dbhandler::resolve_async_join_settings(tianmu_sysvar_async_join); + handler::resolve_async_join_settings(tianmu_sysvar_async_join); return 0; } @@ -916,8 +916,8 @@ void Engine::RemoveTx(Transaction *tx) { Transaction *Engine::CreateTx(THD *thd) { // the transaction should be created by owner THD - ASSERT(thd->ha_data[m_slot].ha_ptr == NULL, "Nested transaction is not supported!"); - ASSERT(current_txn_ == NULL, "Previous transaction is not finished!"); + ASSERT(thd->ha_data[m_slot].ha_ptr == nullptr, "Nested transaction is not supported!"); + ASSERT(current_txn_ == nullptr, "Previous transaction is not finished!"); current_txn_ = new Transaction(thd); thd->ha_data[m_slot].ha_ptr = current_txn_; @@ -941,7 +941,7 @@ void Engine::ClearTx(THD *thd) { RemoveTx(current_txn_); current_txn_ = nullptr; - thd->ha_data[m_slot].ha_ptr = NULL; + thd->ha_data[m_slot].ha_ptr = nullptr; } int Engine::SetUpCacheFolder(const std::string &cachefolder_path) { @@ -1171,7 +1171,7 @@ static void HandleDelayedLoad(int tid, std::vector> &vec } thd->set_catalog({0, 1}); // TIANMU UPGRADE - thd->set_db({NULL, 0}); /* will free the current database */ + thd->set_db({nullptr, 0}); /* will free the current database */ thd->reset_query(); thd->get_stmt_da()->set_overwrite_status(true); thd->is_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd); @@ -1625,13 +1625,13 @@ bool Engine::IsTIANMURoute(THD *thd, TABLE_LIST *table_list, SELECT_LEX *selects } bool Engine::IsTianmuTable(TABLE *table) { - return table && table->s->db_type() == rcbase_hton; // table->db_type is always NULL + return table && table->s->db_type() == rcbase_hton; // table->db_type is always nullptr } const char *Engine::GetFilename(SELECT_LEX *selects_list, int &is_dumpfile) { - // if the function returns a filename <> NULL + // if the function returns a filename <> nullptr // additionally is_dumpfile indicates whether it was 'select into OUTFILE' or - // maybe 'select into DUMPFILE' if the function returns NULL it was a regular + // maybe 'select into DUMPFILE' if the function returns nullptr it was a regular // 'select' don't look into is_dumpfile in this case if (selects_list->parent_lex->exchange) { is_dumpfile = selects_list->parent_lex->exchange->dumpfile; @@ -1670,7 +1670,7 @@ std::unique_ptr Engine::CreateIOParameters(const std::stri } std::unique_ptr Engine::CreateIOParameters([[maybe_unused]] THD *thd, TABLE *table, void *arg) { - if (table == NULL) + if (table == nullptr) return CreateIOParameters("", arg); return CreateIOParameters(GetTablePath(table), arg); @@ -1807,7 +1807,7 @@ common::TianmuError Engine::GetIOP(std::unique_ptr &io_par return common::TianmuError(common::ErrorCode::WRONG_PARAMETER, "Multicharacter escape std::string not supported."); if (ex.field.enclosed->length() > 1 && - (ex.field.enclosed->length() != 4 || strcasecmp(ex.field.enclosed->ptr(), "NULL") != 0)) + (ex.field.enclosed->length() != 4 || strcasecmp(ex.field.enclosed->ptr(), "nullptr") != 0)) return common::TianmuError(common::ErrorCode::WRONG_PARAMETER, "Multicharacter enclose std::string not supported."); if (!for_exporter) { @@ -1820,7 +1820,7 @@ common::TianmuError Engine::GetIOP(std::unique_ptr &io_par io_params->SetEscapeCharacter(*ex.field.escaped->ptr()); io_params->SetDelimiter(ex.field.field_term->ptr()); io_params->SetLineTerminator(ex.line.line_term->ptr()); - if (ex.field.enclosed->length() == 4 && strcasecmp(ex.field.enclosed->ptr(), "NULL") == 0) + if (ex.field.enclosed->length() == 4 && strcasecmp(ex.field.enclosed->ptr(), "nullptr") == 0) io_params->SetParameter(system::Parameter::STRING_QUALIFIER, '\0'); else io_params->SetParameter(system::Parameter::STRING_QUALIFIER, *ex.field.enclosed->ptr()); @@ -1836,7 +1836,7 @@ common::TianmuError Engine::GetIOP(std::unique_ptr &io_par io_params->SetLineTerminator(ex.line.line_term->ptr()); if (ex.field.enclosed->length()) { - if (ex.field.enclosed->length() == 4 && strcasecmp(ex.field.enclosed->ptr(), "NULL") == 0) + if (ex.field.enclosed->length() == 4 && strcasecmp(ex.field.enclosed->ptr(), "nullptr") == 0) io_params->SetParameter(system::Parameter::STRING_QUALIFIER, '\0'); else io_params->SetParameter(system::Parameter::STRING_QUALIFIER, *ex.field.enclosed->ptr()); diff --git a/storage/tianmu/core/engine.h b/storage/tianmu/core/engine.h index 577db646b..7f1994d78 100644 --- a/storage/tianmu/core/engine.h +++ b/storage/tianmu/core/engine.h @@ -155,14 +155,14 @@ class Engine final { static void ComputeTimeZoneDiffInMinutes(THD *thd, short &sign, short &minutes); static std::string GetTablePath(TABLE *table); static common::TianmuError GetIOP(std::unique_ptr &io_params, THD &thd, sql_exchange &ex, - TABLE *table = 0, void *arg = NULL, bool for_exporter = false); + TABLE *table = 0, void *arg = nullptr, bool for_exporter = false); static common::TianmuError GetRejectFileIOParameters(THD &thd, std::unique_ptr &io_params); static fs::path GetNextDataDir(); private: void AddTx(Transaction *tx); void RemoveTx(Transaction *tx); - int Execute(THD *thd, LEX *lex, Query_result *result_output, SELECT_LEX_UNIT *unit_for_union = NULL); + int Execute(THD *thd, LEX *lex, Query_result *result_output, SELECT_LEX_UNIT *unit_for_union = nullptr); int SetUpCacheFolder(const std::string &cachefolder_path); static bool AreConvertible(types::RCDataType &rcitem, enum_field_types my_type, uint length = 0); diff --git a/storage/tianmu/core/engine_convert.cpp b/storage/tianmu/core/engine_convert.cpp index 93d6c84ce..bf82b95c7 100644 --- a/storage/tianmu/core/engine_convert.cpp +++ b/storage/tianmu/core/engine_convert.cpp @@ -54,7 +54,7 @@ bool Engine::ConvertToField(Field *field, types::RCDataType &rcitem, std::vector case MYSQL_TYPE_BLOB: { DEBUG_ASSERT(dynamic_cast(&rcitem)); Field_blob *blob = (Field_blob *)field; - if (blob_buf == NULL) { + if (blob_buf == nullptr) { blob->set_ptr(((types::BString &)rcitem).len_, (uchar *)((types::BString &)rcitem).val_); blob->copy(); } else { @@ -142,7 +142,7 @@ bool Engine::ConvertToField(Field *field, types::RCDataType &rcitem, std::vector break; case MYSQL_TYPE_BLOB: { Field_blob *blob = (Field_blob *)field; - if (blob_buf == NULL) { + if (blob_buf == nullptr) { blob->set_ptr(((types::BString &)rcitem).len_, (uchar *)((types::BString &)rcitem).val_); blob->copy(); } else { @@ -165,21 +165,21 @@ bool Engine::ConvertToField(Field *field, types::RCDataType &rcitem, std::vector char tmp[10]; char *tmpptr = tmp; ((types::BString &)rcitem).PutString(tmpptr, ushort(sizeof(tmp)), false); - ((Field_newdate *)field)->store(tmp, sizeof(tmp), NULL); + ((Field_newdate *)field)->store(tmp, sizeof(tmp), nullptr); break; } case MYSQL_TYPE_TIME: { char tmp[10]; char *tmpptr = tmp; ((types::BString &)rcitem).PutString(tmpptr, ushort(sizeof(tmp)), false); - ((Field_time *)field)->store(tmp, sizeof(tmp), NULL); + ((Field_time *)field)->store(tmp, sizeof(tmp), nullptr); break; } case MYSQL_TYPE_DATETIME: { char tmp[19]; char *tmpptr = tmp; ((types::BString &)rcitem).PutString(tmpptr, ushort(sizeof(tmp)), false); - ((Field_datetime *)field)->store(tmp, sizeof(tmp), NULL); + ((Field_datetime *)field)->store(tmp, sizeof(tmp), nullptr); break; } default: diff --git a/storage/tianmu/core/engine_execute.cpp b/storage/tianmu/core/engine_execute.cpp index c8baa84dd..7de2826ce 100644 --- a/storage/tianmu/core/engine_execute.cpp +++ b/storage/tianmu/core/engine_execute.cpp @@ -52,7 +52,7 @@ class KillTimer { struct itimerspec interval; std::memset(&interval, 0, sizeof(interval)); interval.it_value.tv_sec = secs; - if (timer_settime(id, 0, &interval, NULL)) { + if (timer_settime(id, 0, &interval, nullptr)) { TIANMU_LOG(LogCtl_Level::INFO, "Failed to set up timer. error =%d[%s]", errno, std::strerror(errno)); return; } @@ -86,9 +86,9 @@ int Engine::HandleSelect(THD *thd, LEX *lex, Query_result *&result, ulong setup_ optimize_after_tianmu = FALSE; tianmu_free_join = 0; - SELECT_LEX_UNIT *unit = NULL; - SELECT_LEX *select_lex = NULL; - Query_result_export *se = NULL; + SELECT_LEX_UNIT *unit = nullptr; + SELECT_LEX *select_lex = nullptr; + Query_result_export *se = nullptr; if (tianmu_sysvar_pushdown) thd->variables.optimizer_switch |= OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN; @@ -165,7 +165,7 @@ int Engine::HandleSelect(THD *thd, LEX *lex, Query_result *&result, ulong setup_ } se = dynamic_cast(result); - if (se != NULL) + if (se != nullptr) result = new exporter::select_tianmu_export(se); // prepare, optimize and execute the main query select_lex = lex->select_lex; @@ -273,7 +273,7 @@ int Engine::HandleSelect(THD *thd, LEX *lex, Query_result *&result, ulong setup_ result->send_error(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR)); result->abort_result_set(); } - if (se != NULL) { + if (se != nullptr) { // free the tianmu export object, // restore the original mysql export object // and prepare if it is expected to be prepared @@ -355,8 +355,8 @@ int handle_exceptions(THD *, Transaction *, bool with_error = false); int Engine::Execute(THD *thd, LEX *lex, Query_result *result_output, SELECT_LEX_UNIT *unit_for_union) { DEBUG_ASSERT(thd->lex == lex); SELECT_LEX *selects_list = lex->select_lex; - SELECT_LEX *last_distinct = NULL; - if (unit_for_union != NULL) + SELECT_LEX *last_distinct = nullptr; + if (unit_for_union != nullptr) last_distinct = unit_for_union->union_distinct; int is_dumpfile = 0; @@ -397,7 +397,7 @@ int Engine::Execute(THD *thd, LEX *lex, Query_result *result_output, SELECT_LEX_ std::string table_path = Engine::GetTablePath(((Query_tables_list *)lex)->query_tables->table); rct = current_txn_->GetTableByPathIfExists(table_path); } - if (unit_for_union != NULL && !unit_for_union->is_prepared()) { + if (unit_for_union != nullptr && !unit_for_union->is_prepared()) { int res = result_output->prepare(unit_for_union->item_list, unit_for_union); if (res) { TIANMU_LOG(LogCtl_Level::ERROR, "Error: Unsupported UNION"); @@ -416,7 +416,7 @@ int Engine::Execute(THD *thd, LEX *lex, Query_result *result_output, SELECT_LEX_ } TempTable *result = query.Preexecute(cqu, sender.get()); - ASSERT(result != NULL, "Query execution returned no result object"); + ASSERT(result != nullptr, "Query execution returned no result object"); if (query.IsRoughQuery()) result->RoughMaterialize(false, sender.get()); else @@ -579,7 +579,7 @@ int st_select_lex_unit::optimize_for_tianmu() { /* Send result to 'result' */ saved_error = true; set_limit(global_parameters()); - if (fake_select_lex != NULL) { + if (fake_select_lex != nullptr) { thd->lex->set_current_select(fake_select_lex); if (!is_prepared()) { if (prepare_fake_select_lex(thd)) @@ -597,7 +597,7 @@ int st_select_lex_unit::optimize_for_tianmu() { if (!join->is_optimized()) { // saved_error = join->prepare(fake_select_lex->table_list.first, 0, 0, // global_parameters->order_list.elements, - // global_parameters->order_list.first, NULL, NULL, fake_select_lex, + // global_parameters->order_list.first, nullptr, nullptr, fake_select_lex, // this); //STONEDB UPGRADE if (!is_prepared()) { if (fake_select_lex->prepare(thd)) diff --git a/storage/tianmu/core/engine_results.cpp b/storage/tianmu/core/engine_results.cpp index 7a8679483..76efeb38b 100644 --- a/storage/tianmu/core/engine_results.cpp +++ b/storage/tianmu/core/engine_results.cpp @@ -190,11 +190,11 @@ inline static void SetFieldState(Field *field, bool is_null) { ResultSender::ResultSender(THD *thd, Query_result *res, List &fields) : thd(thd), res(res), - buf_lens(NULL), + buf_lens(nullptr), fields(fields), is_initialized(false), - offset(NULL), - limit(NULL), + offset(nullptr), + limit(nullptr), rows_sent(0) {} void ResultSender::Init([[maybe_unused]] TempTable *t) { @@ -297,7 +297,7 @@ void ResultSender::SendRecord(const std::vectortable->write_set, f->field_index); - auto is_null = Engine::ConvertToField(f, rcdt, NULL); + auto is_null = Engine::ConvertToField(f, rcdt, nullptr); SetFieldState(f, is_null); } break; @@ -307,7 +307,7 @@ void ResultSender::SendRecord(const std::vectorresult_field; if (buf_lens[col_id] != 0) { bitmap_set_bit(f->table->write_set, f->field_index); - auto is_null = Engine::ConvertToField(f, rcdt, NULL); + auto is_null = Engine::ConvertToField(f, rcdt, nullptr); SetFieldState(f, is_null); } break; @@ -423,9 +423,9 @@ void init_field_scan_helpers(THD *&thd, TABLE &tmp_table, TABLE_SHARE &share) { } fields_t::value_type guest_field_type(THD *&thd, TABLE &tmp_table, Item *&item) { - Field *field = NULL; - Field *tmp_field = NULL; - Field *def_field = NULL; + Field *field = nullptr; + Field *tmp_field = nullptr; + Field *def_field = nullptr; if (item->type() == Item::FUNC_ITEM) { if (item->result_type() != STRING_RESULT) field = item->tmp_table_field(&tmp_table); @@ -444,9 +444,9 @@ fields_t::value_type guest_field_type(THD *&thd, TABLE &tmp_table, Item *&item) } AttributeTypeInfo create_ati(THD *&thd, TABLE &tmp_table, Item *&item) { - Field *field = NULL; - Field *tmp_field = NULL; - Field *def_field = NULL; + Field *field = nullptr; + Field *tmp_field = nullptr; + Field *def_field = nullptr; if (item->type() == Item::FUNC_ITEM) { if (item->result_type() != STRING_RESULT) field = item->tmp_table_field(&tmp_table); @@ -475,14 +475,14 @@ void ResultExportSender::Init(TempTable *t) { export_res->send_result_set_metadata(fields, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); - if ((tianmu_error = Engine::GetIOP(iop, *thd, *export_res->SqlExchange(), 0, NULL, true)) != + if ((tianmu_error = Engine::GetIOP(iop, *thd, *export_res->SqlExchange(), 0, nullptr, true)) != common::ErrorCode::SUCCESS) throw common::Exception("Unable to get IOP"); List_iterator_fast li(fields); fields_t f; li.rewind(); - Item *item(NULL); + Item *item(nullptr); TABLE tmp_table; // Used during 'Create_field()' TABLE_SHARE share; init_field_scan_helpers(thd, tmp_table, share); diff --git a/storage/tianmu/core/filter.cpp b/storage/tianmu/core/filter.cpp index e002133e2..0f97d6e6e 100644 --- a/storage/tianmu/core/filter.cpp +++ b/storage/tianmu/core/filter.cpp @@ -30,7 +30,7 @@ Filter::Filter(int64_t no_obj, uint32_t power, bool all_ones, bool shallow) block_allocator(0), no_of_bits_in_last_block(0), shallow(shallow), - block_last_one(NULL), + block_last_one(nullptr), delayed_stats(-1), delayed_block(-1), delayed_stats_set(-1), @@ -58,7 +58,7 @@ Filter::Filter(Filter *f, int64_t no_obj, uint32_t power, bool all_ones, bool sh block_allocator(0), no_of_bits_in_last_block(0), shallow(shallow), - block_last_one(NULL), + block_last_one(nullptr), delayed_stats(-1), delayed_block(-1), delayed_stats_set(-1), @@ -90,7 +90,7 @@ Filter::Filter(const Filter &filter) blocks(0), no_of_bits_in_last_block(0), shallow(false), - block_last_one(NULL), + block_last_one(nullptr), delayed_stats(-1), delayed_block(-1), delayed_stats_set(-1) { @@ -109,7 +109,7 @@ Filter::Filter(const Filter &filter) new (blocks[i]) Block(*(tmp_filter.GetBlock(i)), block_filter); // block_filter<->this } else - blocks[i] = NULL; + blocks[i] = nullptr; } block_status = new uchar[no_blocks]; std::memcpy(block_status, filter.block_status, no_blocks); @@ -128,7 +128,7 @@ void Filter::Construct(bool all_ones, bool shallow) { block_last_one = new ushort[no_blocks]; for (size_t i = 0; i < no_blocks; i++) { block_last_one[i] = pack_def - 1; - blocks[i] = NULL; + blocks[i] = nullptr; } block_last_one[no_blocks - 1] = no_of_bits_in_last_block - 1; // No idea how to create an allocator for the pool below to use TIANMU heap, @@ -169,13 +169,13 @@ Filter::~Filter() { } delete[] block_status; - block_status = NULL; + block_status = nullptr; delete[] block_last_one; - block_last_one = NULL; + block_last_one = nullptr; delete bit_block_pool; - bit_block_pool = NULL; + bit_block_pool = nullptr; delete block_allocator; - block_allocator = NULL; + block_allocator = nullptr; } } @@ -266,7 +266,7 @@ void Filter::Set(size_t b, int n) { block_status[b] = FB_MIXED; blocks[b] = block_allocator->Alloc(); new (blocks[b]) Block(block_filter, new_block_size); // block_filter<->this - if (blocks[b] == NULL) + if (blocks[b] == nullptr) throw common::OutOfMemoryException(); } if (make_mixed) { @@ -306,7 +306,7 @@ void Filter::SetBetween(size_t b1, int n1, size_t b2, int n2) { blocks[b1] = block_allocator->Alloc(); new (blocks[b1]) Block(block_filter, pack_def); // block_filter->this } - if (blocks[b1] == NULL) + if (blocks[b1] == nullptr) throw common::OutOfMemoryException(); if (block_status[b1] == FB_FULL) blocks[b1]->Set(0, @@ -373,13 +373,13 @@ void Filter::ResetBetween(size_t b1, int n1, size_t b2, int n2) { new (blocks[b1]) Block(block_filter, new_block_size, true); // block_filter->this // set as full, // then reset a part of it - if (blocks[b1] == NULL) + if (blocks[b1] == nullptr) throw common::OutOfMemoryException(); } else { new (blocks[b1]) Block(block_filter, new_block_size, false); // block_filter->this// set as empty, // then set the beginning - if (blocks[b1] == NULL) + if (blocks[b1] == nullptr) throw common::OutOfMemoryException(); blocks[b1]->Set(0, block_last_one[b1]); // create a block with a // contents before Reset @@ -548,7 +548,7 @@ void Filter::CopyBlock(Filter &f, size_t block) { if (f.GetBlock(block)) { if (bit_block_pool == f.bit_block_pool) { // f is a shallow copy of this blocks[block] = f.blocks[block]->MoveFromShallowCopy(block_filter); // block_filter->this - f.blocks[block] = NULL; + f.blocks[block] = nullptr; } else { if (blocks[block]) blocks[block]->CopyFrom(*f.blocks[block], @@ -561,7 +561,7 @@ void Filter::CopyBlock(Filter &f, size_t block) { } else { // no block, just status to copy if (bit_block_pool == f.bit_block_pool) // f is a shallow copy of this - blocks[block] = NULL; + blocks[block] = nullptr; else if (blocks[block]) DeleteBlock(block); } @@ -572,7 +572,7 @@ void Filter::CopyBlock(Filter &f, size_t block) { void Filter::DeleteBlock(int pack) { blocks[pack]->~Block(); block_allocator->Dealloc(blocks[pack]); - blocks[pack] = NULL; + blocks[pack] = nullptr; } bool Filter::IsEqual(Filter &sec) { @@ -877,7 +877,7 @@ void Filter::AddNewBlocks(int new_blocks, bool value, int new_no_bits_last) { block_last_one = tmp_block_size; for (size_t i = no_blocks; i < no_blocks + new_blocks; i++) { - blocks[i] = NULL; + blocks[i] = nullptr; if (value) { block_status[i] = FB_FULL; block_last_one[i] = (i == no_blocks + new_blocks - 1 ? new_no_bits_last - 1 : (pack_def - 1)); @@ -896,7 +896,7 @@ char *HeapAllocator::malloc(const size_type bytes) { try { r = the_filter_block_owner->alloc(bytes, mm::BLOCK_TYPE::BLOCK_TEMPORARY); } catch (...) { - return NULL; + return nullptr; } return (char *)r; } diff --git a/storage/tianmu/core/filter.h b/storage/tianmu/core/filter.h index 3ec25dbcf..12450c493 100644 --- a/storage/tianmu/core/filter.h +++ b/storage/tianmu/core/filter.h @@ -96,7 +96,7 @@ class Filter final : public mm::TraceableObject { // then reset a part of it else new (blocks[b]) Block(block_filter, pack_def, true); // block_filter->this - if (blocks[b] == NULL) + if (blocks[b] == nullptr) throw common::OutOfMemoryException(); } } diff --git a/storage/tianmu/core/filter_block.cpp b/storage/tianmu/core/filter_block.cpp index 73f22492c..083e25e8f 100644 --- a/storage/tianmu/core/filter_block.cpp +++ b/storage/tianmu/core/filter_block.cpp @@ -108,7 +108,7 @@ void Filter::Block::Reset() { owner->bit_mut->lock(); owner->bit_block_pool->free(block_table); owner->bit_mut->unlock(); - block_table = NULL; + block_table = nullptr; } no_set_bits = 0; } diff --git a/storage/tianmu/core/filter_iterators.cpp b/storage/tianmu/core/filter_iterators.cpp index 91a0251b3..99ba7b68c 100644 --- a/storage/tianmu/core/filter_iterators.cpp +++ b/storage/tianmu/core/filter_iterators.cpp @@ -22,7 +22,7 @@ namespace Tianmu { namespace core { FilterOnesIterator::FilterOnesIterator() : buffer(max_ahead) { valid = false; - f = NULL; + f = nullptr; cur_position = -1; b = 0; bln = 0; @@ -349,7 +349,7 @@ FilterOnesIterator *FilterOnesIterator::Copy(int packs_to_go) { return f; } -FilterOnesIteratorOrdered::FilterOnesIteratorOrdered() : FilterOnesIterator(), po(NULL){}; +FilterOnesIteratorOrdered::FilterOnesIteratorOrdered() : FilterOnesIterator(), po(nullptr){}; FilterOnesIteratorOrdered::FilterOnesIteratorOrdered(Filter *ff, PackOrderer *po, uint32_t power) { Init(ff, po, power); diff --git a/storage/tianmu/core/ftree.cpp b/storage/tianmu/core/ftree.cpp index 777081bf9..a0ae510e0 100644 --- a/storage/tianmu/core/ftree.cpp +++ b/storage/tianmu/core/ftree.cpp @@ -66,22 +66,22 @@ FTree::FTree(const FTree &ft) void FTree::Destroy() { if (mem) { dealloc(mem); - mem = NULL; + mem = nullptr; } if (len) { dealloc(len); - len = NULL; + len = nullptr; } if (value_offset) { dealloc(value_offset); - value_offset = NULL; + value_offset = nullptr; } if (hash_table) { dealloc(hash_table); - hash_table = NULL; + hash_table = nullptr; } } @@ -105,11 +105,11 @@ types::BString FTree::GetRealValue(int v) { char *FTree::GetBuffer(int v) { if (v >= 0 && v < hdr.size) return (mem + value_offset[v]); - return NULL; + return nullptr; } int FTree::GetEncodedValue(const char *str, size_t sz) { - if (mem == NULL) + if (mem == nullptr) return -1; int local_last_code = last_code; // for multithread safety @@ -128,9 +128,9 @@ void FTree::Init(int width) { if (mem) dealloc(mem); mem = (char *)alloc(total_buf_size, mm::BLOCK_TYPE::BLOCK_TEMPORARY); - if (len == NULL) + if (len == nullptr) len = (uint16_t *)alloc(total_dic_size * sizeof(uint16_t), mm::BLOCK_TYPE::BLOCK_TEMPORARY, true); - if (value_offset == NULL) + if (value_offset == nullptr) value_offset = (uint32_t *)alloc(total_dic_size * sizeof(uint32_t), mm::BLOCK_TYPE::BLOCK_TEMPORARY, true); std::memset(mem, 0, total_buf_size); @@ -157,7 +157,7 @@ int FTree::Add(const char *str, size_t sz) { len = (uint16_t *)rc_realloc(len, new_dic_size * sizeof(uint16_t), mm::BLOCK_TYPE::BLOCK_TEMPORARY); value_offset = (uint32_t *)rc_realloc(value_offset, new_dic_size * sizeof(uint32_t), mm::BLOCK_TYPE::BLOCK_TEMPORARY); - if (len == NULL || value_offset == NULL) + if (len == nullptr || value_offset == nullptr) throw common::OutOfMemoryException("Too many lookup values"); for (int i = total_dic_size; i < new_dic_size; i++) { len[i] = 0; @@ -300,7 +300,7 @@ void FTree::InitHash() { while (hash_size % 2 == 0 || hash_size % 3 == 0 || hash_size % 5 == 0 || hash_size % 7 == 0) hash_size++; dealloc(hash_table); hash_table = (int *)alloc(hash_size * sizeof(int), mm::BLOCK_TYPE::BLOCK_TEMPORARY); // 2 GB max. - if (hash_table == NULL) + if (hash_table == nullptr) throw common::OutOfMemoryException("Too many lookup values"); std::memset(hash_table, 0xFF, @@ -309,7 +309,7 @@ void FTree::InitHash() { } int FTree::HashFind(const char *v, int v_len, int position_if_not_found) { - if (hash_table == NULL) + if (hash_table == nullptr) InitHash(); unsigned int crc_code = (v_len == 0 ? 0 : HashValue((const unsigned char *)v, v_len)); int row = crc_code % hash_size; diff --git a/storage/tianmu/core/group_distinct_cache.cpp b/storage/tianmu/core/group_distinct_cache.cpp index e7a5d84eb..0252276bc 100644 --- a/storage/tianmu/core/group_distinct_cache.cpp +++ b/storage/tianmu/core/group_distinct_cache.cpp @@ -24,16 +24,16 @@ namespace Tianmu { namespace core { GroupDistinctCache::GroupDistinctCache() : system::CacheableItem("JW", "GDC") { - t = NULL; - t_write = NULL; - cur_pos = NULL; + t = nullptr; + t_write = nullptr; + cur_pos = nullptr; cur_obj = 0; buf_size = 0; no_obj = 0; orig_no_obj = 0; width = 0; upper_byte_limit = 0; - cur_write_pos = NULL; + cur_write_pos = nullptr; } GroupDistinctCache::~GroupDistinctCache() { @@ -62,10 +62,10 @@ void GroupDistinctCache::Initialize() { } void GroupDistinctCache::SetCurrentValue(unsigned char *val) { - if (t == NULL) // not initialized yet! + if (t == nullptr) // not initialized yet! Initialize(); ASSERT(cur_pos, - "cur_pos buffer overflow, GroupDistinctCache OOM"); // cur_pos==NULL => + "cur_pos buffer overflow, GroupDistinctCache OOM"); // cur_pos==nullptr => // no more place std::memcpy(cur_pos, val, width); } @@ -83,11 +83,11 @@ void GroupDistinctCache::Rewind() // rewind iterator, start from object 0 CI_Put(int(cur_obj / buf_size), t); // save the last block CI_Get(0, t); // load the first block } - cur_pos = t; // may be NULL, will be initialized on the first SetCurrentValue + cur_pos = t; // may be nullptr, will be initialized on the first SetCurrentValue cur_write_pos = t_write; } else { - cur_pos = NULL; // invalid from the beginning - cur_write_pos = NULL; + cur_pos = nullptr; // invalid from the beginning + cur_write_pos = nullptr; } cur_obj = 0; cur_write_obj = 0; @@ -99,7 +99,7 @@ bool GroupDistinctCache::NextRead() // go to the next position, return false if cur_obj++; if (cur_obj >= no_obj) { cur_obj--; - cur_pos = NULL; // indicator of buffer overflow + cur_pos = nullptr; // indicator of buffer overflow return false; } if (cur_obj % buf_size == 0) { // a boundary between buffers @@ -116,7 +116,7 @@ bool GroupDistinctCache::NextWrite() // go to the next position, return false cur_obj++; if (cur_obj > no_obj) { cur_obj--; - cur_pos = NULL; // indicator of buffer overflow + cur_pos = nullptr; // indicator of buffer overflow return false; } if (cur_obj % buf_size == 0) { // a boundary between buffers @@ -129,7 +129,7 @@ bool GroupDistinctCache::NextWrite() // go to the next position, return false void GroupDistinctCache::MarkCurrentAsPreserved() { DEBUG_ASSERT(cur_obj >= cur_write_obj); - if (t_write == NULL) { + if (t_write == nullptr) { t_write = (unsigned char *)alloc(upper_byte_limit, mm::BLOCK_TYPE::BLOCK_TEMPORARY); // switch writing to the new buffer cur_write_pos = t_write; @@ -167,7 +167,7 @@ void GroupDistinctCache::Omit(int64_t obj_to_omit) { cur_obj += obj_to_omit; if (cur_obj >= no_obj) { cur_obj = no_obj; - cur_pos = NULL; // indicator of buffer overflow + cur_pos = nullptr; // indicator of buffer overflow } else if (cur_obj / buf_size != prev_block) { CI_Get(int(cur_obj / buf_size), t); // load the proper block cur_pos = t + width * (cur_obj % buf_size); diff --git a/storage/tianmu/core/group_distinct_cache.h b/storage/tianmu/core/group_distinct_cache.h index 00731483e..82428b736 100644 --- a/storage/tianmu/core/group_distinct_cache.h +++ b/storage/tianmu/core/group_distinct_cache.h @@ -66,7 +66,7 @@ class GroupDistinctCache : private system::CacheableItem, public mm::TraceableOb unsigned char *t_write; // value buffer for preserved objects, if different than t size_t upper_byte_limit; // upper byte size of t, t_write, it is also the // actual size for multi-block case - unsigned char *cur_pos; // current location in buffer; NULL - out of scope + unsigned char *cur_pos; // current location in buffer; nullptr - out of scope size_t cur_obj; // current (virtual) object number size_t no_obj; // a number of all (virtual) objects; current state (may be // lowered by switching to preserved) diff --git a/storage/tianmu/core/group_distinct_table.cpp b/storage/tianmu/core/group_distinct_table.cpp index f5001c4e7..e7a560ab6 100644 --- a/storage/tianmu/core/group_distinct_table.cpp +++ b/storage/tianmu/core/group_distinct_table.cpp @@ -24,8 +24,8 @@ namespace Tianmu { namespace core { GroupDistinctTable::GroupDistinctTable(uint32_t power) - : input_buffer(NULL), - t(NULL), + : input_buffer(nullptr), + t(nullptr), group_bytes(0), value_bytes(0), total_width(0), @@ -36,10 +36,10 @@ GroupDistinctTable::GroupDistinctTable(uint32_t power) initialized(false), use_CRC(false), filter_implementation(false), - f(NULL), + f(nullptr), group_factor(0) { max_total_size = 64_MB; - encoder = NULL; + encoder = nullptr; input_length = 0; pack_power = power; } @@ -183,7 +183,7 @@ GDTResult GroupDistinctTable::Add(int64_t group, MIIterator &mit) { } group += 1; // offset; 0 means empty position std::memmove(input_buffer, reinterpret_cast(&group), group_bytes); - encoder->Encode(input_buffer + group_bytes, mit, NULL, true); + encoder->Encode(input_buffer + group_bytes, mit, nullptr, true); return FindCurrentRow(); // return FindCurrentRowByVMTable(); } diff --git a/storage/tianmu/core/group_table.h b/storage/tianmu/core/group_table.h index c92ead236..c596cbf08 100644 --- a/storage/tianmu/core/group_table.h +++ b/storage/tianmu/core/group_table.h @@ -180,7 +180,7 @@ class GroupTable : public mm::TraceableObject { // used for complex aggregations struct ColTempDesc { ColTempDesc() { - vc = NULL; + vc = nullptr; min = common::MINUS_INF_64; max = common::PLUS_INF_64; max_no_values = 0; diff --git a/storage/tianmu/core/groupby_wrapper.cpp b/storage/tianmu/core/groupby_wrapper.cpp index c894d2d77..5ff149ce1 100644 --- a/storage/tianmu/core/groupby_wrapper.cpp +++ b/storage/tianmu/core/groupby_wrapper.cpp @@ -39,7 +39,7 @@ GroupByWrapper::GroupByWrapper(int a_size, bool distinct, Transaction *conn, uin dist_vals[i] = common::NULL_VALUE_64; } - pack_not_omitted = NULL; + pack_not_omitted = nullptr; no_grouping_attr = 0; no_aggregated_attr = 0; no_attr = 0; @@ -47,7 +47,7 @@ GroupByWrapper::GroupByWrapper(int a_size, bool distinct, Transaction *conn, uin no_groups = 0; packrows_omitted = 0; packrows_part_omitted = 0; - tuple_left = NULL; + tuple_left = nullptr; } GroupByWrapper::~GroupByWrapper() { @@ -92,7 +92,7 @@ GroupByWrapper::GroupByWrapper(const GroupByWrapper &sec) packrows_part_omitted = 0; for (int i = 0; i < no_attr; i++) pack_not_omitted[i] = sec.pack_not_omitted[i]; - tuple_left = NULL; + tuple_left = nullptr; if (sec.tuple_left) tuple_left = new Filter(*sec.tuple_left); // a copy of filter // init distinct_watch to make copy ctor has all Initialization logic @@ -162,17 +162,17 @@ void GroupByWrapper::AddAggregatedColumn(int orig_attr_no, TempTable::Attr &a, i case common::ColOperation::COUNT: if (a.term.IsNull() || (!ag_distinct && virt_col[attr_no]->IsConst())) { if (virt_col[attr_no] && virt_col[attr_no]->IsConst()) { - MIIterator dummy(NULL, p_power); + MIIterator dummy(nullptr, p_power); if (virt_col[attr_no]->IsNull(dummy)) { ag_oper = GT_Aggregation::GT_COUNT_NOT_NULL; ag_type = virt_col[attr_no]->TypeName(); ag_size = max_size; } else { - virt_col[attr_no] = NULL; // forget about constant in count(...), except null + virt_col[attr_no] = nullptr; // forget about constant in count(...), except null ag_oper = GT_Aggregation::GT_COUNT; } } else { - virt_col[attr_no] = NULL; // forget about constant in count(...), except null + virt_col[attr_no] = nullptr; // forget about constant in count(...), except null ag_oper = GT_Aggregation::GT_COUNT; } } else { @@ -415,7 +415,7 @@ void GroupByWrapper::AddAllCountStar(int64_t row, MIIterator &mit, int64_t val) // set all count(*) values { for (int gr_a = no_grouping_attr; gr_a < no_attr; gr_a++) { - if ((virt_col[gr_a] == NULL || virt_col[gr_a]->IsConst()) && gt.AttrOper(gr_a) == GT_Aggregation::GT_COUNT && + if ((virt_col[gr_a] == nullptr || virt_col[gr_a]->IsConst()) && gt.AttrOper(gr_a) == GT_Aggregation::GT_COUNT && !gt.AttrDistinct(gr_a)) { if (virt_col[gr_a] && virt_col[gr_a]->IsNull(mit)) PutAggregatedValueForCount(gr_a, row, 0); @@ -437,7 +437,7 @@ bool GroupByWrapper::PackWillNotUpdateAggregation(int i, MIIterator &mit) // fa DEBUG_ASSERT(input_mode[i] != GBInputMode::GBIMODE_NOT_SET); if (((is_lookup[i] || input_mode[i] == GBInputMode::GBIMODE_AS_TEXT) && (gt.AttrOper(i) == GT_Aggregation::GT_MIN || gt.AttrOper(i) == GT_Aggregation::GT_MAX)) || - virt_col[i] == NULL) + virt_col[i] == nullptr) return false; // Optimization: do not recalculate statistics if there is too much groups @@ -470,7 +470,7 @@ bool GroupByWrapper::DataWillNotUpdateAggregation(int i) // false, if counters DEBUG_ASSERT(input_mode[i] != GBInputMode::GBIMODE_NOT_SET); if (((is_lookup[i] || input_mode[i] == GBInputMode::GBIMODE_AS_TEXT) && (gt.AttrOper(i) == GT_Aggregation::GT_MIN || gt.AttrOper(i) == GT_Aggregation::GT_MAX)) || - virt_col[i] == NULL) + virt_col[i] == nullptr) return false; // Optimization: do not recalculate statistics if there is too much groups @@ -585,7 +585,7 @@ bool GroupByWrapper::PutCachedValue(int gr_a) // current value from distinct ca bool GroupByWrapper::CacheValid(int gr_a) // true if there is a value cached for current row { - return (distinct_watch.gd_cache[gr_a].GetCurrentValue() != NULL); + return (distinct_watch.gd_cache[gr_a].GetCurrentValue() != nullptr); } void GroupByWrapper::OmitInCache(int gr_a, int64_t obj_to_omit) { distinct_watch.gd_cache[gr_a].Omit(obj_to_omit); } @@ -603,7 +603,7 @@ bool GroupByWrapper::IsCountOnly(int gr_a) // true, if an attribute is count(*) // no attr specified) { if (gr_a != -1) { - return (virt_col[gr_a] == NULL || virt_col[gr_a]->IsConst()) && gt.AttrOper(gr_a) == GT_Aggregation::GT_COUNT && + return (virt_col[gr_a] == nullptr || virt_col[gr_a]->IsConst()) && gt.AttrOper(gr_a) == GT_Aggregation::GT_COUNT && !gt.AttrDistinct(gr_a); } bool count_found = false; @@ -611,7 +611,7 @@ bool GroupByWrapper::IsCountOnly(int gr_a) // true, if an attribute is count(*) // 'ala', COUNT(*), 5, COUNT(4) FROM ..." if (gt.AttrOper(i) == GT_Aggregation::GT_COUNT) count_found = true; - if (!((virt_col[i] == NULL || virt_col[i]->IsConst()) && gt.AttrOper(i) == GT_Aggregation::GT_COUNT && + if (!((virt_col[i] == nullptr || virt_col[i]->IsConst()) && gt.AttrOper(i) == GT_Aggregation::GT_COUNT && !gt.AttrDistinct(i)) // count(*) or count(const) && (gt.AttrOper(i) != GT_Aggregation::GT_LIST || !virt_col[i]->IsConst())) // a constant return false; @@ -652,21 +652,21 @@ bool GroupByWrapper::IsMaxOnly() // true, if an attribute is max(column), and void GroupByWrapper::InitTupleLeft(int64_t n) { if (tuple_left) { delete tuple_left; - tuple_left = NULL; + tuple_left = nullptr; } - DEBUG_ASSERT(tuple_left == NULL); + DEBUG_ASSERT(tuple_left == nullptr); tuple_left = new Filter(n, p_power); tuple_left->Set(); } bool GroupByWrapper::AnyTuplesLeft(int64_t from, int64_t to) { - if (tuple_left == NULL) + if (tuple_left == nullptr) return true; return !tuple_left->IsEmptyBetween(from, to); } int64_t GroupByWrapper::TuplesLeftBetween(int64_t from, int64_t to) { - if (tuple_left == NULL) + if (tuple_left == nullptr) return to - from + 1; return tuple_left->NumOfOnesBetween(from, to); } @@ -710,7 +710,7 @@ void DistinctWrapper::InitTuples(int64_t n_obj, const GroupTable >) { // for now - init cache with a number of objects decreased (will cache on // disk if more is needed) gd_cache[i].SetNumOfObj(n_obj); - DEBUG_ASSERT(f[i] == NULL); + DEBUG_ASSERT(f[i] == nullptr); f[i].reset(new Filter(n_obj, p_power)); gd_cache[i].SetWidth(gt.GetCachedWidth(i)); } diff --git a/storage/tianmu/core/groupby_wrapper.h b/storage/tianmu/core/groupby_wrapper.h index 9e54634f0..8935cbb55 100644 --- a/storage/tianmu/core/groupby_wrapper.h +++ b/storage/tianmu/core/groupby_wrapper.h @@ -94,7 +94,7 @@ class GroupByWrapper final { void OmitInCache(int attr, int64_t obj_to_omit); void DistinctlyOmitted(int attr, int64_t obj); bool AnyOmittedByDistinct() { return distinct_watch.AnyOmitted(); } - int64_t ApproxDistinctVals(int gr_a, MultiIndex *mind = NULL); + int64_t ApproxDistinctVals(int gr_a, MultiIndex *mind = nullptr); int NumOfAttrs() { return no_attr; } int NumOfGroupingAttrs() { return no_grouping_attr; } @@ -147,7 +147,7 @@ class GroupByWrapper final { void InitTupleLeft(int64_t n); bool AnyTuplesLeft(int64_t from, int64_t to); - bool AnyTuplesLeft() { return (tuple_left != NULL) && !tuple_left->IsEmpty(); } + bool AnyTuplesLeft() { return (tuple_left != nullptr) && !tuple_left->IsEmpty(); } int64_t TuplesLeftBetween(int64_t from, int64_t to); void CommitResets() { if (tuple_left) @@ -165,8 +165,8 @@ class GroupByWrapper final { if (tuple_left) tuple_left->ResetDelayed(pos); } - bool TuplesGet(int64_t pos) { return (tuple_left == NULL) || tuple_left->Get(pos); } - int64_t TuplesNoOnes() { return (tuple_left == NULL ? 0 : tuple_left->NumOfOnes()); } + bool TuplesGet(int64_t pos) { return (tuple_left == nullptr) || tuple_left->Get(pos); } + int64_t TuplesNoOnes() { return (tuple_left == nullptr ? 0 : tuple_left->NumOfOnes()); } // Locking packs etc. void LockPack(int i, MIIterator &mit); diff --git a/storage/tianmu/core/index_table.cpp b/storage/tianmu/core/index_table.cpp index 3d67f74b7..57d4f7d8a 100644 --- a/storage/tianmu/core/index_table.cpp +++ b/storage/tianmu/core/index_table.cpp @@ -104,7 +104,7 @@ IndexTable::~IndexTable() { void IndexTable::LoadBlock(int b) { DEBUG_ASSERT(IsLocked()); - if (buf == NULL) { // possible after block caching on disk + if (buf == nullptr) { // possible after block caching on disk buf = (unsigned char *)alloc(buffer_size_in_bytes, mm::BLOCK_TYPE::BLOCK_TEMPORARY, true); if (!buf) { TIANMU_LOG(LogCtl_Level::ERROR, "Could not allocate memory for IndexTable(LoadBlock)."); @@ -112,7 +112,7 @@ void IndexTable::LoadBlock(int b) { } } else if (block_changed) CI_Put(cur_block, buf); - DEBUG_ASSERT(buf != NULL); + DEBUG_ASSERT(buf != nullptr); CI_Get(b, buf); if (m_conn->Killed()) // from time to time... throw common::KilledException(); diff --git a/storage/tianmu/core/index_table.h b/storage/tianmu/core/index_table.h index 460aff828..34c159594 100644 --- a/storage/tianmu/core/index_table.h +++ b/storage/tianmu/core/index_table.h @@ -104,7 +104,7 @@ class IndexTable : private system::CacheableItem, public mm::TraceableObject { int64_t OrigSize() { return orig_size; - } // the size of the original table, or the largest (incl. 0 = NULL) value + } // the size of the original table, or the largest (incl. 0 = nullptr) value // which may occur in table uint64_t N() { return size; } // note: this is the upper size, the table can be used partially! int BlockShift() { return block_shift; } // block = int( tuple >> block_shift ) @@ -126,7 +126,7 @@ class IndexTable : private system::CacheableItem, public mm::TraceableObject { uint64_t block_mask; uint64_t size; int64_t orig_size; // the size of the original table, or the largest value - // (incl. 0 = NULL) which may occur in the table + // (incl. 0 = nullptr) which may occur in the table int cur_block; bool block_changed; diff --git a/storage/tianmu/core/item_tianmu_field.cpp b/storage/tianmu/core/item_tianmu_field.cpp index a0dd38392..d8c746c4a 100644 --- a/storage/tianmu/core/item_tianmu_field.cpp +++ b/storage/tianmu/core/item_tianmu_field.cpp @@ -25,7 +25,7 @@ namespace Tianmu { namespace core { Item_tianmufield::Item_tianmufield(Item_field *ifield, VarID varID) - : Item_field(current_txn_->Thd(), ifield), ifield(ifield), buf(NULL), ivalue(NULL) { + : Item_field(current_txn_->Thd(), ifield), ifield(ifield), buf(nullptr), ivalue(nullptr) { this->varID.push_back(varID); if (ifield->type() == Item::SUM_FUNC_ITEM) { was_aggregation = true; @@ -37,7 +37,7 @@ Item_tianmufield::Item_tianmufield(Item_field *ifield, VarID varID) } Item_tianmufield::~Item_tianmufield() { - // if(ivalue != NULL) delete ivalue; // done by MySQL not TIANMU, for each Item + // if(ivalue != nullptr) delete ivalue; // done by MySQL not TIANMU, for each Item // subclass ClearBuf(); } @@ -45,12 +45,12 @@ Item_tianmufield::~Item_tianmufield() { void Item_tianmufield::ClearBuf() { if (isBufOwner) { delete buf; - buf = NULL; + buf = nullptr; } } void Item_tianmufield::SetBuf(ValueOrNull *&b) { - if (buf == NULL) { + if (buf == nullptr) { isBufOwner = true; buf = new ValueOrNull; } @@ -58,9 +58,9 @@ void Item_tianmufield::SetBuf(ValueOrNull *&b) { } void Item_tianmufield::SetType(DataType t) { - if (ivalue != NULL) { + if (ivalue != nullptr) { // delete ivalue; // done by MySQL not TIANMU, for each Item subclass - ivalue = NULL; + ivalue = nullptr; } tianmu_type = t; diff --git a/storage/tianmu/core/joiner_hash_table.cpp b/storage/tianmu/core/joiner_hash_table.cpp index 4bfb4d7c0..5db9742fe 100644 --- a/storage/tianmu/core/joiner_hash_table.cpp +++ b/storage/tianmu/core/joiner_hash_table.cpp @@ -39,7 +39,7 @@ JoinerHashTable::JoinerHashTable() { for_count_only = false; initialized = false; no_of_occupied = 0; - t = NULL; + t = nullptr; key_buf_width = 0; total_width = 0; mult_offset = 0; diff --git a/storage/tianmu/core/joiner_hash_table.h b/storage/tianmu/core/joiner_hash_table.h index 00f145fc0..b554c81e9 100644 --- a/storage/tianmu/core/joiner_hash_table.h +++ b/storage/tianmu/core/joiner_hash_table.h @@ -64,7 +64,7 @@ class JoinerHashTable : public mm::TraceableObject { // put values to a temporary buffer (note that it will contain the previous // values, which may be reused void PutKeyValue(int col, MIIterator &mit) { // for all values EXCEPT NULLS - encoder[col].Encode(input_buffer.get(), mit, NULL, + encoder[col].Encode(input_buffer.get(), mit, nullptr, true); // true: update statistics } void PutMatchedValue(int col, vcolumn::VirtualColumn *vc, diff --git a/storage/tianmu/core/joiner_sort.cpp b/storage/tianmu/core/joiner_sort.cpp index 8f4c4b1ab..061cc1c34 100644 --- a/storage/tianmu/core/joiner_sort.cpp +++ b/storage/tianmu/core/joiner_sort.cpp @@ -32,7 +32,7 @@ void JoinerSort::ExecuteJoinConditions(Condition &cond) { why_failed = JoinFailure::NOT_FAILED; vcolumn::VirtualColumn *vc1 = cond[0].attr.vc; vcolumn::VirtualColumn *vc2 = cond[0].val1.vc; - if (vc1 == NULL || vc2 == NULL) { + if (vc1 == nullptr || vc2 == nullptr) { why_failed = JoinFailure::FAIL_COMPLEX; return; } else { // Normalize: let vc1 = a smaller table @@ -189,14 +189,14 @@ void JoinerSort::ExecuteJoinConditions(Condition &cond) { int64_t no_of_traversed = 1; int64_t result_size = 0; unsigned char *cur_traversed = s1->GetNextValue(); - unsigned char *cur_matched = NULL; + unsigned char *cur_matched = nullptr; bool cache_full = false; // Note: we are always checking "traversed < matched" condition. If ">" is // needed, sorters are defined as descending. while (cur_traversed) { if (m_conn->Killed()) throw common::KilledException(); - if (cur_matched == NULL) { // the first pass or the end of matched sorter + if (cur_matched == nullptr) { // the first pass or the end of matched sorter if (cache_full) { rc_control_.lock(m_conn->GetThreadID()) << "Traversed " << no_of_traversed << "/" << actual_s1_size << " tuples, produced " << result_size @@ -227,11 +227,11 @@ void JoinerSort::ExecuteJoinConditions(Condition &cond) { cur_matched = s2->GetNextValue(); if (tips.limit > -1 && result_size >= tips.limit) break; - } while (cur_matched && cur_traversed == NULL); // this loop is for the case of cur_traversed completed + } while (cur_matched && cur_traversed == nullptr); // this loop is for the case of cur_traversed completed } // End when there is no more matched rows and the cache does not need to be // rewinded - if (cur_matched == NULL && !cache_full) + if (cur_matched == nullptr && !cache_full) break; if (tips.limit > -1 && result_size >= tips.limit) break; @@ -339,19 +339,19 @@ int64_t JoinerSort::AddOuterTuples(MINewContents &new_mind, JoinerSortWrapper &s JoinerSortWrapper::JoinerSortWrapper(bool _less) { less = _less; - encoder = NULL; - cache = NULL; + encoder = nullptr; + cache = nullptr; key_bytes = 0; // size of key data for both sorters traverse_bytes = 0; // total size of the first ("traverse") sorter match_bytes = 0; // total size of the second ("match") sorter cache_size = 0; cache_bytes = 0; cur_cache_used = 0; - buf = NULL; + buf = nullptr; buf_bytes = 0; no_dims = 0; outer_offset = 0; - min_traversed = NULL; + min_traversed = nullptr; watch_traversed = false; watch_matched = false; } @@ -411,7 +411,7 @@ void JoinerSortWrapper::SetDimensions(MultiIndex *mind, DimensionVector &dim_tr, outer_offset = traverse_bytes - key_bytes; traverse_bytes += 8; } - DEBUG_ASSERT(buf == NULL); + DEBUG_ASSERT(buf == nullptr); buf_bytes = std::max(traverse_bytes, match_bytes); buf = new unsigned char[buf_bytes]; } @@ -420,7 +420,7 @@ unsigned char *JoinerSortWrapper::EncodeForSorter1([[maybe_unused]] vcolumn::Vir int64_t outer_pos) // for Traversed { std::memset(buf, 0, buf_bytes); - encoder->Encode(buf, mit, NULL, true); + encoder->Encode(buf, mit, nullptr, true); int64_t dim_value = 0; for (int i = 0; i < no_dims; i++) { if (dim_traversed[i] == true) { @@ -434,7 +434,7 @@ unsigned char *JoinerSortWrapper::EncodeForSorter1([[maybe_unused]] vcolumn::Vir } if (watch_traversed) std::memcpy(buf + key_bytes + outer_offset, &outer_pos, 8); - if (min_traversed == NULL) { + if (min_traversed == nullptr) { min_traversed = new unsigned char[key_bytes]; std::memcpy(min_traversed, buf, key_bytes); } else { @@ -470,7 +470,7 @@ bool JoinerSortWrapper::PackPossible(vcolumn::VirtualColumn *v, MIIterator &mit) // "matched" (the second) virtual column if (!watch_matched && v->GetNumOfNulls(mit) == mit.GetPackSizeLeft()) return false; - if (min_traversed == NULL || v->Type().IsLookup()) + if (min_traversed == nullptr || v->Type().IsLookup()) return true; else if (v->Type().IsString()) { types::BString local_stat; @@ -515,7 +515,7 @@ void JoinerSortWrapper::InitCache(int64_t no_of_rows) { cache_size = max_mem_size / cache_bytes; } cache = (unsigned char *)alloc(cache_bytes * cache_size, mm::BLOCK_TYPE::BLOCK_TEMPORARY); - if (cache == NULL) + if (cache == nullptr) throw common::OutOfMemoryException(); } } diff --git a/storage/tianmu/core/joiner_sort.h b/storage/tianmu/core/joiner_sort.h index 1a195662a..3b57e20fb 100644 --- a/storage/tianmu/core/joiner_sort.h +++ b/storage/tianmu/core/joiner_sort.h @@ -47,7 +47,7 @@ class JoinerSort : public TwoDimensionalJoiner { other_cond_exist(false), watch_traversed(false), watch_matched(false), - outer_filter(NULL), + outer_filter(nullptr), outer_nulls_only(false) {} ~JoinerSort(); @@ -132,7 +132,7 @@ class JoinerSortWrapper : public mm::TraceableObject { int buf_bytes; // buf size, derivable: max(traverse_bytes, match_bytes) unsigned char *min_traversed; // minimal key set as traversed (a buffer of - // key_bytes size; NULL + // key_bytes size; nullptr // - not set yet) unsigned char *cache; // a buffer for cache diff --git a/storage/tianmu/core/just_a_table.h b/storage/tianmu/core/just_a_table.h index a377c3c66..c71b387d6 100644 --- a/storage/tianmu/core/just_a_table.h +++ b/storage/tianmu/core/just_a_table.h @@ -50,7 +50,7 @@ class JustATable : public std::enable_shared_from_this { virtual bool IsNull(int64_t obj, int attr) = 0; - virtual uint MaxStringSize(int n_a, Filter *f = NULL) = 0; + virtual uint MaxStringSize(int n_a, Filter *f = nullptr) = 0; virtual std::vector GetATIs(bool orig = false) = 0; diff --git a/storage/tianmu/core/mi_iterator.cpp b/storage/tianmu/core/mi_iterator.cpp index c2402a4e6..b5fe3a7dd 100644 --- a/storage/tianmu/core/mi_iterator.cpp +++ b/storage/tianmu/core/mi_iterator.cpp @@ -25,17 +25,17 @@ std::vector null_order; // use null_order in constructor if orderi MIIterator::MIIterator() : po(null_order) { p_power = common::DFT_PSS; - mind = NULL; + mind = nullptr; no_dims = 0; mind_created_locally = false; - cur_pos = NULL; - cur_pack = NULL; - it_for_dim = NULL; + cur_pos = nullptr; + cur_pack = nullptr; + it_for_dim = nullptr; valid = false; omitted_factor = 1; next_pack_started = false; one_filter_dim = -1; - one_filter_it = NULL; + one_filter_it = nullptr; mii_type = MIIteratorType::MII_DUMMY; TaskId = 0; TasksNum = 1; @@ -45,11 +45,11 @@ MIIterator::MIIterator(MultiIndex *_mind, DimensionVector &_dimensions) : mind(_ p_power = mind->ValueOfPower(); no_dims = mind->NumOfDimensions(); mind_created_locally = false; - cur_pos = NULL; - cur_pack = NULL; - it_for_dim = NULL; + cur_pos = nullptr; + cur_pack = nullptr; + it_for_dim = nullptr; one_filter_dim = -1; - one_filter_it = NULL; + one_filter_it = nullptr; dimensions = _dimensions; TaskId = 0; TasksNum = 1; @@ -63,11 +63,11 @@ MIIterator::MIIterator(MultiIndex *_mind, DimensionVector &_dimensions, std::vec p_power = mind->ValueOfPower(); no_dims = mind->NumOfDimensions(); mind_created_locally = false; - cur_pos = NULL; - cur_pack = NULL; - it_for_dim = NULL; + cur_pos = nullptr; + cur_pack = nullptr; + it_for_dim = nullptr; one_filter_dim = -1; - one_filter_it = NULL; + one_filter_it = nullptr; dimensions = _dimensions; TaskId = 0; TasksNum = 1; @@ -75,7 +75,7 @@ MIIterator::MIIterator(MultiIndex *_mind, DimensionVector &_dimensions, std::vec } MIIterator::MIIterator(MultiIndex *_mind, uint32_t power) : mind(_mind), po(null_order) { - if (mind == NULL) { + if (mind == nullptr) { mind_created_locally = true; mind = new MultiIndex(power); // redo-power mind->AddDimension_cross(1); // just one row @@ -83,11 +83,11 @@ MIIterator::MIIterator(MultiIndex *_mind, uint32_t power) : mind(_mind), po(null mind_created_locally = false; p_power = mind->ValueOfPower(); no_dims = mind->NumOfDimensions(); - cur_pos = NULL; - cur_pack = NULL; - it_for_dim = NULL; + cur_pos = nullptr; + cur_pack = nullptr; + it_for_dim = nullptr; one_filter_dim = -1; - one_filter_it = NULL; + one_filter_it = nullptr; TaskId = 0; TasksNum = 1; dimensions = DimensionVector(no_dims); @@ -99,11 +99,11 @@ MIIterator::MIIterator(MultiIndex *_mind, int one_dimension, bool lock) : mind(_ p_power = mind->ValueOfPower(); no_dims = mind->NumOfDimensions(); mind_created_locally = false; - cur_pos = NULL; - cur_pack = NULL; + cur_pos = nullptr; + cur_pack = nullptr; dimensions = DimensionVector(no_dims); one_filter_dim = -1; - one_filter_it = NULL; + one_filter_it = nullptr; TaskId = 0; TasksNum = 1; if (one_dimension == -1) @@ -115,13 +115,13 @@ MIIterator::MIIterator(MultiIndex *_mind, int one_dimension, bool lock) : mind(_ MIIterator::MIIterator(const MIIterator &sec, bool lock) : dg(sec.dg), - it_for_dim(NULL), + it_for_dim(nullptr), mind(sec.mind), mind_created_locally(sec.mind_created_locally), no_dims(sec.no_dims), dimensions(sec.dimensions), - cur_pos(NULL), // will be initialized below - cur_pack(NULL), + cur_pos(nullptr), // will be initialized below + cur_pack(nullptr), valid(sec.valid), omitted_factor(sec.omitted_factor), no_obj(sec.no_obj), @@ -156,7 +156,7 @@ MIIterator::MIIterator(const MIIterator &sec, bool lock) mind->LockForGetIndex(i); for (uint i = 0; i < sec.it.size(); i++) it.push_back(sec.dg[i]->CopyIterator(sec.it[i], p_power)); - one_filter_it = NULL; + one_filter_it = nullptr; if (one_filter_dim > -1) { if (po.size() == 0) one_filter_it = (DimensionGroupFilter::DGFilterIterator *)(it[0]); @@ -428,7 +428,7 @@ MIDummyIterator::MIDummyIterator(MultiIndex *_mind) { valid = true; no_dims = mind->NumOfDimensions(); mind_created_locally = false; - it_for_dim = NULL; + it_for_dim = nullptr; cur_pos = new int64_t[no_dims]; cur_pack = new int[no_dims]; pack_size_left = -1; diff --git a/storage/tianmu/core/mi_iterator.h b/storage/tianmu/core/mi_iterator.h index d309298a0..afaa09f08 100644 --- a/storage/tianmu/core/mi_iterator.h +++ b/storage/tianmu/core/mi_iterator.h @@ -61,7 +61,7 @@ class MIIterator { * */ MIIterator(MultiIndex *mind, - uint32_t power); // note: mind=NULL will create a local multiindex + uint32_t power); // note: mind=nullptr will create a local multiindex // - one dim., one row MIIterator(MultiIndex *mind, int one_dimension, bool lock); // -1 is an equivalent of all dimensions// = true diff --git a/storage/tianmu/core/mi_new_contents.cpp b/storage/tianmu/core/mi_new_contents.cpp index 7c127bc03..5689ef71c 100644 --- a/storage/tianmu/core/mi_new_contents.cpp +++ b/storage/tianmu/core/mi_new_contents.cpp @@ -25,7 +25,7 @@ namespace Tianmu { namespace core { MINewContents::MINewContents(MultiIndex *m, JoinTips &tips) - : mind(m), t_new(NULL), optimized_dim_stay(-1), f_opt(NULL), t_opt(NULL) { + : mind(m), t_new(nullptr), optimized_dim_stay(-1), f_opt(nullptr), t_opt(nullptr) { no_dims = mind->NumOfDimensions(); dim_involved = DimensionVector(no_dims); // init as empty nulls_possible = new bool[no_dims]; @@ -34,14 +34,14 @@ MINewContents::MINewContents(MultiIndex *m, JoinTips &tips) new_value = new int64_t[no_dims]; ignore_repetitions_dim = -1; for (int i = 0; i < no_dims; i++) { - t_new[i] = NULL; + t_new[i] = nullptr; nulls_possible[i] = false; forget_now[i] = tips.forget_now[i]; if (tips.distinct_only[i]) ignore_repetitions_dim = i; } obj = 0; - roughsorter = NULL; + roughsorter = nullptr; f_opt_max_ones = 0; content_type = enumMINCType::MCT_UNSPECIFIED; max_filter_val = -1; @@ -79,7 +79,7 @@ void MINewContents::Init(int64_t initial_size) // initialize temporary structur optimized_dim_stay = dim; } // optimized_dim_stay > -1 if there is exactly one unforgotten dimension } - if (optimized_dim_stay != -1 && mind->GetFilter(optimized_dim_stay) == NULL) + if (optimized_dim_stay != -1 && mind->GetFilter(optimized_dim_stay) == nullptr) optimized_dim_stay = -1; // filter case only if (optimized_dim_stay != -1) @@ -96,7 +96,7 @@ void MINewContents::Init(int64_t initial_size) // initialize temporary structur } // optimized_dim_stay > -1 if there is exactly one unforgotten // dimension } - if (optimized_dim_stay != -1 && mind->GetFilter(optimized_dim_stay) == NULL) + if (optimized_dim_stay != -1 && mind->GetFilter(optimized_dim_stay) == nullptr) optimized_dim_stay = -1; // filter case only if (optimized_dim_stay != -1) content_type = enumMINCType::MCT_VIRTUAL_DIM; @@ -114,7 +114,7 @@ void MINewContents::Init(int64_t initial_size) // initialize temporary structur for (int dim = 0; dim < no_dims; dim++) { if (dim_involved[dim]) { delete t_new[dim]; - t_new[dim] = NULL; + t_new[dim] = nullptr; if (forget_now[dim]) continue; if (dim != optimized_dim_stay) { @@ -125,7 +125,7 @@ void MINewContents::Init(int64_t initial_size) // initialize temporary structur 64); // minimal initial size - maybe will not be used at all min_block_shift = std::min(min_block_shift, t_new[dim]->BlockShift()); t_opt = t_new[dim]; - t_new[dim] = NULL; + t_new[dim] = nullptr; f_opt = new Filter(mind->GetFilter(dim)->NumOfObj(), pack_power); f_opt_max_ones = mind->GetFilter(dim)->NumOfOnes(); f_opt->Reset(); @@ -176,7 +176,7 @@ void MINewContents::Commit([[maybe_unused]] int64_t joined_tuples) // commit ch int group_no = mind->group_num_for_dim[dim]; if (mind->dim_groups[group_no]) { // otherwise already deleted delete mind->dim_groups[group_no]; - mind->dim_groups[group_no] = NULL; + mind->dim_groups[group_no] = nullptr; } } @@ -188,7 +188,7 @@ void MINewContents::Commit([[maybe_unused]] int64_t joined_tuples) // commit ch DimensionGroupFilter *nf = new DimensionGroupFilter(optimized_dim_stay, f_opt, 2, pack_power); // mode 2: pass Filter ownership to the DimensionGroup - f_opt = NULL; + f_opt = nullptr; nf->Lock(optimized_dim_stay, no_locks[optimized_dim_stay]); mind->dim_groups.push_back(nf); DimensionVector dims_to_forget(dim_involved); @@ -200,14 +200,14 @@ void MINewContents::Commit([[maybe_unused]] int64_t joined_tuples) // commit ch } else if (content_type == enumMINCType::MCT_VIRTUAL_DIM) { // optimized version: virtual dimension group DimensionGroupVirtual *nv = new DimensionGroupVirtual(dim_involved, optimized_dim_stay, f_opt, 2); // mode 2: pass Filter ownership to the DimensionGroup - f_opt = NULL; + f_opt = nullptr; nv->Lock(optimized_dim_stay, no_locks[optimized_dim_stay]); mind->dim_groups.push_back(nv); for (int dim = 0; dim < no_dims; dim++) { if (dim_involved[dim] && !forget_now[dim] && dim != optimized_dim_stay) { t_new[dim]->SetNumOfLocks(no_locks[dim]); nv->NewDimensionContent(dim, t_new[dim], nulls_possible[dim]); - t_new[dim] = NULL; // ownership transferred to the DimensionGroup + t_new[dim] = nullptr; // ownership transferred to the DimensionGroup } } } else { @@ -225,7 +225,7 @@ void MINewContents::Commit([[maybe_unused]] int64_t joined_tuples) // commit ch if (dim_involved[dim] && !forget_now[dim]) { t_new[dim]->SetNumOfLocks(no_locks[dim]); ng->NewDimensionContent(dim, t_new[dim], nulls_possible[dim]); - t_new[dim] = NULL; // ownership transferred to the DimensionGroup + t_new[dim] = nullptr; // ownership transferred to the DimensionGroup } } } @@ -240,13 +240,13 @@ void MINewContents::DisableOptimized() { MEASURE_FET("MINewContents::DisableOptimized(...)"); DEBUG_ASSERT(optimized_dim_stay != -1); if (!forget_now[optimized_dim_stay]) { - DEBUG_ASSERT(t_new[optimized_dim_stay] == NULL); + DEBUG_ASSERT(t_new[optimized_dim_stay] == nullptr); t_new[optimized_dim_stay] = t_opt; - t_opt = NULL; + t_opt = nullptr; f_opt->Commit(); t_new[optimized_dim_stay]->SetByFilter(f_opt, pack_power); - if (roughsorter == NULL && mind->OrigSize(optimized_dim_stay) > (1U << pack_power)) + if (roughsorter == nullptr && mind->OrigSize(optimized_dim_stay) > (1U << pack_power)) roughsorter = new MINewContentsRSorter(mind, t_new, min_block_shift); else if (roughsorter) { roughsorter->Barrier(); @@ -254,7 +254,7 @@ void MINewContents::DisableOptimized() { } } delete f_opt; - f_opt = NULL; + f_opt = nullptr; optimized_dim_stay = -1; content_type = enumMINCType::MCT_MATERIAL; } @@ -266,7 +266,7 @@ bool MINewContents::CommitPack(int pack) // in case of single filter as a resul return false; Filter *orig_filter = mind->GetFilter(optimized_dim_stay); f_opt->Commit(); - if (!f_opt->IsEmpty(pack) || orig_filter == NULL) + if (!f_opt->IsEmpty(pack) || orig_filter == nullptr) return false; f_opt->CopyBlock(*orig_filter, pack); return true; diff --git a/storage/tianmu/core/mi_new_contents.h b/storage/tianmu/core/mi_new_contents.h index ea0326a34..d49574d6e 100644 --- a/storage/tianmu/core/mi_new_contents.h +++ b/storage/tianmu/core/mi_new_contents.h @@ -63,7 +63,7 @@ class MINewContents final { void InitTnew(int dim, int64_t initial_size); // create t_new of proper size void DisableOptimized(); // switch from optimized mode to normal mode - MINewContentsRSorter *roughsorter; // NULL if not needed + MINewContentsRSorter *roughsorter; // nullptr if not needed MultiIndex *mind; // external pointer IndexTable **t_new; // new tables diff --git a/storage/tianmu/core/mi_rough_sorter.cpp b/storage/tianmu/core/mi_rough_sorter.cpp index 8d9bef21a..404b556ac 100644 --- a/storage/tianmu/core/mi_rough_sorter.cpp +++ b/storage/tianmu/core/mi_rough_sorter.cpp @@ -36,7 +36,7 @@ MINewContentsRSorter::MINewContentsRSorter(MultiIndex *_m, IndexTable **t_new, i no_cols_to_compare = 0; no_cols_to_sort = 0; for (int dim = 0; dim < no_dim; dim++) { - tall[dim] = NULL; // will remain NULL if the dimension is not covered by sorter + tall[dim] = nullptr; // will remain nullptr if the dimension is not covered by sorter AddColumn(t_new[dim], dim); } last_pack = new int[no_dim]; @@ -56,7 +56,7 @@ MINewContentsRSorter::~MINewContentsRSorter() { } void MINewContentsRSorter::AddColumn(IndexTable *t, int dim) { - DEBUG_ASSERT(t == NULL || tall[dim] == NULL); // else already added - something is wrong! + DEBUG_ASSERT(t == nullptr || tall[dim] == nullptr); // else already added - something is wrong! tall[dim] = t; tcheck[dim] = false; if (t) { diff --git a/storage/tianmu/core/mi_rough_sorter.h b/storage/tianmu/core/mi_rough_sorter.h index 2662789d9..2b4a8145b 100644 --- a/storage/tianmu/core/mi_rough_sorter.h +++ b/storage/tianmu/core/mi_rough_sorter.h @@ -156,7 +156,7 @@ class MINewContentsRSorter { // Rough sorter of the new contents of MultiIndex class MINewContentsRSorterWorker { public: - MINewContentsRSorterWorker() : bound_queue_size(0), bound_queue(NULL), rough_sorter(NULL) {} + MINewContentsRSorterWorker() : bound_queue_size(0), bound_queue(nullptr), rough_sorter(nullptr) {} MINewContentsRSorterWorker(int _bound_queue_size, MINewContentsRSorter *_rough_sorter); virtual ~MINewContentsRSorterWorker(); diff --git a/storage/tianmu/core/multi_index.cpp b/storage/tianmu/core/multi_index.cpp index 22b08e0a0..b63679bef 100644 --- a/storage/tianmu/core/multi_index.cpp +++ b/storage/tianmu/core/multi_index.cpp @@ -34,9 +34,9 @@ MultiIndex::MultiIndex(uint32_t power) : m_conn(current_txn_) { no_dimensions = 0; no_tuples = 0; no_tuples_too_big = false; - dim_size = NULL; - group_for_dim = NULL; - group_num_for_dim = NULL; + dim_size = nullptr; + group_for_dim = nullptr; + group_num_for_dim = nullptr; iterator_lock = 0; shallow_dim_groups = false; } @@ -58,9 +58,9 @@ MultiIndex::MultiIndex(const MultiIndex &s) : m_conn(s.m_conn) { FillGroupForDim(); } else { - dim_size = NULL; - group_for_dim = NULL; - group_num_for_dim = NULL; + dim_size = nullptr; + group_for_dim = nullptr; + group_num_for_dim = nullptr; } iterator_lock = 0; shallow_dim_groups = false; @@ -83,9 +83,9 @@ MultiIndex::MultiIndex(MultiIndex &s, bool shallow) : m_conn(s.m_conn) { FillGroupForDim(); } else { - dim_size = NULL; - group_for_dim = NULL; - group_num_for_dim = NULL; + dim_size = nullptr; + group_for_dim = nullptr; + group_num_for_dim = nullptr; } iterator_lock = 0; shallow_dim_groups = shallow; @@ -95,7 +95,7 @@ MultiIndex::~MultiIndex() { if (!shallow_dim_groups) { for (uint i = 0; i < dim_groups.size(); i++) { delete dim_groups[i]; - dim_groups[i] = NULL; + dim_groups[i] = nullptr; } } delete[] dim_size; @@ -107,7 +107,7 @@ void MultiIndex::Clear() { try { for (uint i = 0; i < dim_groups.size(); i++) { delete dim_groups[i]; - dim_groups[i] = NULL; + dim_groups[i] = nullptr; } } catch (...) { DEBUG_ASSERT(!"exception from destructor"); @@ -119,9 +119,9 @@ void MultiIndex::Clear() { no_dimensions = 0; no_tuples = 0; no_tuples_too_big = false; - dim_size = NULL; - group_for_dim = NULL; - group_num_for_dim = NULL; + dim_size = nullptr; + group_for_dim = nullptr; + group_num_for_dim = nullptr; iterator_lock = 0; can_be_distinct.clear(); used_in_output.clear(); @@ -131,11 +131,11 @@ void MultiIndex::FillGroupForDim() { MEASURE_FET("MultiIndex::FillGroupForDim(...)"); int move_groups = 0; for (uint i = 0; i < dim_groups.size(); i++) { // pack all holes - if (dim_groups[i] == NULL) { - while (i + move_groups < dim_groups.size() && dim_groups[i + move_groups] == NULL) move_groups++; + if (dim_groups[i] == nullptr) { + while (i + move_groups < dim_groups.size() && dim_groups[i + move_groups] == nullptr) move_groups++; if (i + move_groups < dim_groups.size()) { dim_groups[i] = dim_groups[i + move_groups]; - dim_groups[i + move_groups] = NULL; + dim_groups[i + move_groups] = nullptr; } else break; } @@ -143,7 +143,7 @@ void MultiIndex::FillGroupForDim() { for (int i = 0; i < move_groups; i++) dim_groups.pop_back(); // clear nulls from the end for (int d = 0; d < no_dimensions; d++) { - group_for_dim[d] = NULL; + group_for_dim[d] = nullptr; group_num_for_dim[d] = -1; } @@ -189,7 +189,7 @@ void MultiIndex::AddDimension() { group_for_dim = ng; group_num_for_dim = ngn; dim_size[no_dimensions - 1] = 0; - group_for_dim[no_dimensions - 1] = NULL; + group_for_dim[no_dimensions - 1] = nullptr; group_num_for_dim[no_dimensions - 1] = -1; // Temporary code, for rare cases when we add a dimension after other joins // (smk_33): @@ -206,7 +206,7 @@ void MultiIndex::AddDimension_cross(uint64_t size) { MultiplyNoTuples(size); else no_tuples = size; - DimensionGroupFilter *nf = NULL; + DimensionGroupFilter *nf = nullptr; if (size > 0) { dim_size[new_dim] = size; nf = new DimensionGroupFilter(new_dim, size, p_power); // redo @@ -291,16 +291,16 @@ void MultiIndex::MakeCountOnly(int64_t mat_tuples, DimensionVector &dims_to_mate MEASURE_FET("MultiIndex::MakeCountOnly(...)"); MarkInvolvedDimGroups(dims_to_materialize); for (int i = 0; i < NumOfDimensions(); i++) { - if (dims_to_materialize[i] && group_for_dim[i] != NULL) { + if (dims_to_materialize[i] && group_for_dim[i] != nullptr) { // delete this group int dim_group_to_delete = group_num_for_dim[i]; for (int j = i; j < NumOfDimensions(); j++) if (group_num_for_dim[j] == dim_group_to_delete) { - group_for_dim[j] = NULL; + group_for_dim[j] = nullptr; group_num_for_dim[j] = -1; } delete dim_groups[dim_group_to_delete]; - dim_groups[dim_group_to_delete] = NULL; // these holes will be packed in FillGroupForDim() + dim_groups[dim_group_to_delete] = nullptr; // these holes will be packed in FillGroupForDim() } } DimensionGroupMaterialized *count_only_group = new DimensionGroupMaterialized(dims_to_materialize); @@ -312,8 +312,8 @@ void MultiIndex::MakeCountOnly(int64_t mat_tuples, DimensionVector &dims_to_mate void MultiIndex::UpdateNumOfTuples() { // assumptions: - // - no_material_tuples is correct, even if all t[...] are NULL (forgotten). - // However, if all f[...] are not NULL, then the index is set to IT_VIRTUAL + // - no_material_tuples is correct, even if all t[...] are nullptr (forgotten). + // However, if all f[...] are not nullptr, then the index is set to IT_VIRTUAL // and no_material_tuples = 0 // - IT_MIXED or IT_VIRTUAL may be in fact IT_ORDERED (must be set properly on // output) diff --git a/storage/tianmu/core/multi_index.h b/storage/tianmu/core/multi_index.h index 4669db53f..aa867b6d9 100644 --- a/storage/tianmu/core/multi_index.h +++ b/storage/tianmu/core/multi_index.h @@ -60,15 +60,15 @@ class MultiIndex { bool ZeroTuples() { return (!no_tuples_too_big && no_tuples == 0); } bool TooManyTuples() { return no_tuples_too_big; } Filter *GetFilter(int dim) const // Get the pointer to a filter attached to a dimension. - // NOTE: will be NULL in case of materialized MultiIndex! + // NOTE: will be nullptr in case of materialized MultiIndex! { - return no_dimensions > 0 ? group_for_dim[dim]->GetFilter(dim) : NULL; + return no_dimensions > 0 ? group_for_dim[dim]->GetFilter(dim) : nullptr; } Filter *GetUpdatableFilter(int dim) const // Get the pointer to a filter, if it may be changed. - // NOTE: will be NULL in case of materialized + // NOTE: will be nullptr in case of materialized // MultiIndex! { - return no_dimensions > 0 ? group_for_dim[dim]->GetUpdatableFilter(dim) : NULL; + return no_dimensions > 0 ? group_for_dim[dim]->GetUpdatableFilter(dim) : nullptr; } bool NullsExist(int dim) { return no_dimensions > 0 ? group_for_dim[dim]->NullsPossible(dim) : false; diff --git a/storage/tianmu/core/mysql_expression.cpp b/storage/tianmu/core/mysql_expression.cpp index f5aae3537..c191431ba 100644 --- a/storage/tianmu/core/mysql_expression.cpp +++ b/storage/tianmu/core/mysql_expression.cpp @@ -48,7 +48,7 @@ MysqlExpression::MysqlExpression(Item *item, Item2VarID &item2varid) { this->item2varid = &item2varid; this->item = TransformTree(item, TransformDirection::FORWARD); - this->item2varid = NULL; + this->item2varid = nullptr; } MysqlExpression::~MysqlExpression() { TransformTree(item, TransformDirection::BACKWARD); } @@ -59,7 +59,7 @@ bool MysqlExpression::HandledResultType(Item *item) { Item_result type = item->result_type(); if ((dynamic_cast(item)) && type == STRING_RESULT) { String s; - if (item->val_str(&s) == NULL) + if (item->val_str(&s) == nullptr) item->max_length = 0; else item->max_length = (dynamic_cast(item))->val_str(&s)->length(); @@ -78,7 +78,7 @@ bool MysqlExpression::HandledFieldType(Item_result type) { } bool MysqlExpression::SanityAggregationCheck(Item *item, std::set &fields, bool toplevel /*= true*/, - bool *has_aggregation /*= NULL*/) { + bool *has_aggregation /*= nullptr*/) { // printItemTree(item); if (!item) return false; @@ -114,11 +114,11 @@ bool MysqlExpression::SanityAggregationCheck(Item *item, std::set &field fields.insert(item); return true; case Item::FUNC_ITEM: { - if (dynamic_cast(item) != NULL) + if (dynamic_cast(item) != nullptr) return false; // currently stored procedures not supported - if (dynamic_cast(item) != NULL) { + if (dynamic_cast(item) != nullptr) { Item_func_sp *ifunc = dynamic_cast(item); if (ifunc->argument_count() != 0) return false; @@ -173,7 +173,7 @@ Item_tianmufield *MysqlExpression::GetTianmufieldItem(Item_field *ifield) { auto key = item2varid->find(ifield); DEBUG_ASSERT(key != item2varid->end()); auto it = tianmu_fields_cache.find(key->second); - Item_tianmufield *tianmufield = NULL; + Item_tianmufield *tianmufield = nullptr; if (it != tianmu_fields_cache.end()) { tianmufield = *it->second.begin(); tianmufield->varID.push_back(key->second); @@ -508,7 +508,7 @@ std::shared_ptr MysqlExpression::ItemDecimal2ValueOrNull(Item *item auto val = std::make_shared(); my_decimal dec; my_decimal *retdec = item->val_decimal(&dec); - if (retdec != NULL) { + if (retdec != nullptr) { if (retdec != &dec) my_decimal2decimal(retdec, &dec); int64_t v; @@ -533,7 +533,7 @@ std::shared_ptr MysqlExpression::ItemString2ValueOrNull(Item *item, auto val = std::make_shared(); String string_result; String *ret = item->val_str(&string_result); - if (ret != NULL) { + if (ret != nullptr) { char *p = ret->c_ptr_safe(); if (ATI::IsDateTimeType(a_type)) { types::RCDateTime rcdt; diff --git a/storage/tianmu/core/mysql_expression.h b/storage/tianmu/core/mysql_expression.h index 038d188ef..175d1d45a 100644 --- a/storage/tianmu/core/mysql_expression.h +++ b/storage/tianmu/core/mysql_expression.h @@ -48,12 +48,12 @@ class MysqlExpression { virtual ~MysqlExpression(); static bool SanityAggregationCheck(Item *item, std::set &aggregations, bool toplevel = true, - bool *has_aggregation = NULL); + bool *has_aggregation = nullptr); static bool HasAggregation(Item *item); virtual MysqlExpression::SetOfVars &GetVars(); void SetBufsOrParams(var_buf_t *bufs); - virtual DataType EvalType(TypOfVars *tv = NULL); + virtual DataType EvalType(TypOfVars *tv = nullptr); StringType GetStringType(); virtual std::shared_ptr Evaluate(); diff --git a/storage/tianmu/core/pack.cpp b/storage/tianmu/core/pack.cpp index 63f2133a9..7641203fe 100644 --- a/storage/tianmu/core/pack.cpp +++ b/storage/tianmu/core/pack.cpp @@ -35,7 +35,7 @@ Pack::Pack(DPN *dpn, PackCoordinate pc, ColumnShare *s) : s(s), dpn(dpn) { nulls = std::make_unique(bitmapSize / sizeof(uint32_t)); deletes = std::make_unique(bitmapSize / sizeof(uint32_t)); // nulls MUST be initialized in the constructor, there are 3 cases in total: - // 1. All values are NULL. It is initialized here by InitNull(); + // 1. All values are nullptr. It is initialized here by InitNull(); // 2. All values are uniform. Then it would be all zeros already. // 3. Otherwise. It would be loaded from disk by PackInt() or PackStr(). InitNull(); diff --git a/storage/tianmu/core/pack_int.cpp b/storage/tianmu/core/pack_int.cpp index 3b9652866..7d6d90619 100644 --- a/storage/tianmu/core/pack_int.cpp +++ b/storage/tianmu/core/pack_int.cpp @@ -754,7 +754,7 @@ void PackInt::DecompressAndInsertNulls(compress::NumCompressor &nc, uint } std::pair PackInt::Compress() { - uint *cur_buf = NULL; + uint *cur_buf = nullptr; size_t buffer_size = 0; mm::MMGuard tmp_comp_buffer; diff --git a/storage/tianmu/core/pack_orderer.h b/storage/tianmu/core/pack_orderer.h index 5c5277eb7..b98994a26 100644 --- a/storage/tianmu/core/pack_orderer.h +++ b/storage/tianmu/core/pack_orderer.h @@ -63,7 +63,7 @@ class PackOrderer { //! Initialized Orderer constructed with a default constructor, //! ignored if used on a initialized orderer //! \return true if successful, otherwise false - bool Init(vcolumn::VirtualColumn *vc, OrderType order, common::RSValue *r_filter = NULL); + bool Init(vcolumn::VirtualColumn *vc, OrderType order, common::RSValue *r_filter = nullptr); /*! * Reset the iterator, so it will start from the first pack in the given sort diff --git a/storage/tianmu/core/parameterized_filter.cpp b/storage/tianmu/core/parameterized_filter.cpp index 993f4d16c..48769973b 100644 --- a/storage/tianmu/core/parameterized_filter.cpp +++ b/storage/tianmu/core/parameterized_filter.cpp @@ -144,7 +144,7 @@ void ParameterizedFilter::PrepareRoughMultiIndex() { for (uint d = 0; d < (uint)mind->NumOfDimensions(); d++) { Filter *f = mind->GetFilter(d); for (int p = 0; p < rough_mind->NoPacks(d); p++) { - if (f == NULL) + if (f == nullptr) rough_mind->SetPackStatus(d, p, common::RSValue::RS_UNKNOWN); else if (f->IsFull(p)) rough_mind->SetPackStatus(d, p, common::RSValue::RS_ALL); @@ -180,7 +180,7 @@ double ParameterizedFilter::EvaluateConditionNonJoinWeight(Descriptor &d, bool f int64_t no_in_values = 1; if (d.op == common::Operator::O_IN || d.op == common::Operator::O_NOT_IN) { vcolumn::MultiValColumn *iscol = static_cast(d.val1.vc); - MIIterator mitor(NULL, d.table->Getpackpower()); + MIIterator mitor(nullptr, d.table->Getpackpower()); no_in_values = iscol->NumOfValues(mitor); } eval = log(1 + double(answer_size)); // approximate size of the result @@ -839,7 +839,7 @@ void ParameterizedFilter::SyntacticalDescriptorListPreprocessing(bool for_rough_ // now, the second part Descriptor dd(table, mind->NumOfDimensions()); dd.attr = descriptors[i].val2; - descriptors[i].val2.vc = NULL; + descriptors[i].val2.vc = nullptr; dd.op = common::Operator::O_MORE_EQ; dd.val1 = descriptors[i].val1; dd.done = false; @@ -855,7 +855,7 @@ void ParameterizedFilter::SyntacticalDescriptorListPreprocessing(bool for_rough_ Descriptor dd(table, mind->NumOfDimensions()); dd.attr = descriptors[i].attr; dd.val1 = descriptors[i].val2; - descriptors[i].val2.vc = NULL; + descriptors[i].val2.vc = nullptr; dd.op = common::Operator::O_LESS_EQ; dd.done = false; dd.left_dims = descriptors[i].left_dims; @@ -945,7 +945,7 @@ void ParameterizedFilter::SyntacticalDescriptorListPreprocessing(bool for_rough_ descriptors[i].DimensionUsed(all_dims); bool additional_nulls_possible = false; for (int d = 0; d < mind->NumOfDimensions(); d++) - if (all_dims[d] && mind->GetFilter(d) == NULL) + if (all_dims[d] && mind->GetFilter(d) == nullptr) additional_nulls_possible = true; if (descriptors[i].IsOuter()) additional_nulls_possible = true; @@ -1351,7 +1351,7 @@ void ParameterizedFilter::ApplyDescriptor(int desc_number, int64_t limit) dims.SetAll(); // Check the easy case (one-dim, parallelizable) int one_dim = -1; - common::RSValue *rf = NULL; + common::RSValue *rf = nullptr; if (no_dims == 1) { for (int i = 0; i < mind->NumOfDimensions(); i++) { if (dims[i]) { diff --git a/storage/tianmu/core/physical_column.h b/storage/tianmu/core/physical_column.h index 5529b58c8..5fe49901d 100644 --- a/storage/tianmu/core/physical_column.h +++ b/storage/tianmu/core/physical_column.h @@ -53,13 +53,13 @@ class PhysicalColumn : public Column { virtual int64_t GetValueInt64(int64_t row) const = 0; virtual int64_t GetNotNullValueInt64(int64_t row) const = 0; - /*! \brief Is the column value NULL ? + /*! \brief Is the column value nullptr ? * * \pre necessary datapacks (containing rows pointed by \e mit) are loaded and * locked * * \param row identifies a row - * \return \b true if column value is NULL, \b false otherwise + * \return \b true if column value is nullptr, \b false otherwise */ virtual bool IsNull(int64_t row) const = 0; @@ -186,7 +186,7 @@ class PhysicalColumn : public Column { // non-null values, if possible, or // common::NULL_VALUE_64 - virtual size_t MaxStringSize(Filter *f = NULL) = 0; // maximal byte string length in column + virtual size_t MaxStringSize(Filter *f = nullptr) = 0; // maximal byte string length in column // Are all the values unique? bool IsUnique() const { return is_unique; } @@ -204,19 +204,19 @@ class PhysicalColumn : public Column { return (IsUniqueUpdated() ? (IsUnique() ? common::RSValue::RS_ALL : common::RSValue::RS_NONE) : common::RSValue::RS_UNKNOWN); } - virtual int64_t RoughMin(Filter *f = NULL, - common::RSValue *rf = NULL) = 0; // for numerical: best - // rough approximation of - // min for a given filter - // (or global min if filter - // is NULL) - virtual int64_t RoughMax(Filter *f = NULL, - common::RSValue *rf = NULL) = 0; // for numerical: best - // rough approximation of - // max for a given filter - // (or global max if filter - // is NULL) - virtual void GetTextStat(types::TextStat &s, [[maybe_unused]] Filter *f = NULL) { s.Invalidate(); } + virtual int64_t RoughMin(Filter *f = nullptr, + common::RSValue *rf = nullptr) = 0; // for numerical: best + // rough approximation of + // min for a given filter + // (or global min if filter + // is nullptr) + virtual int64_t RoughMax(Filter *f = nullptr, + common::RSValue *rf = nullptr) = 0; // for numerical: best + // rough approximation of + // max for a given filter + // (or global max if filter + // is nullptr) + virtual void GetTextStat(types::TextStat &s, [[maybe_unused]] Filter *f = nullptr) { s.Invalidate(); } virtual double RoughSelectivity() { return 1; } /*! \brief Return true if the column (filtered) contain only non-null distinct * values diff --git a/storage/tianmu/core/query.cpp b/storage/tianmu/core/query.cpp index 0e1810c33..33db0ec57 100644 --- a/storage/tianmu/core/query.cpp +++ b/storage/tianmu/core/query.cpp @@ -238,13 +238,13 @@ const std::string Query::GetItemName(Item *item) { return "REF_ITEM"; } case Item::NULL_ITEM: - return "NULL"; + return "nullptr"; case Item::INT_ITEM: { Item_int_with_ref *int_ref = dynamic_cast(item); String s(buf, 256, nullptr); if (!int_ref) { String *ps = item->val_str(&s); - return ps ? ps->c_ptr_safe() : "NULL"; + return ps ? ps->c_ptr_safe() : "nullptr"; } // else item is an instance of Item_int_with_ref, not Item_int return GetItemName(int_ref->real_item()); @@ -252,7 +252,7 @@ const std::string Query::GetItemName(Item *item) { case Item::STRING_ITEM: { String s(buf, 256, nullptr); String *ps = item->val_str(&s); - return ps ? ps->c_ptr_safe() : "NULL"; + return ps ? ps->c_ptr_safe() : "nullptr"; } case Item::SUBSELECT_ITEM: return "SUBSELECT"; diff --git a/storage/tianmu/core/query.h b/storage/tianmu/core/query.h index 8ef6db85b..5eab1a5a1 100644 --- a/storage/tianmu/core/query.h +++ b/storage/tianmu/core/query.h @@ -60,9 +60,10 @@ class Query final { void SetRoughQuery(bool set_rough) { rough_query = set_rough; } bool IsRoughQuery() { return rough_query; } - int Compile(CompiledQuery *compiled_query, SELECT_LEX *selects_list, SELECT_LEX *last_distinct, TabID *res_tab = NULL, - bool ignore_limit = false, Item *left_expr_for_subselect = NULL, - common::Operator *oper_for_subselect = NULL, bool ignore_minmax = false, bool for_subq_in_where = false); + int Compile(CompiledQuery *compiled_query, SELECT_LEX *selects_list, SELECT_LEX *last_distinct, + TabID *res_tab = nullptr, bool ignore_limit = false, Item *left_expr_for_subselect = nullptr, + common::Operator *oper_for_subselect = nullptr, bool ignore_minmax = false, + bool for_subq_in_where = false); TempTable *Preexecute(CompiledQuery &qu, ResultSender *sender, bool display_now = true); int BuildConditions(Item *conds, CondID &cond_id, CompiledQuery *cq, const TabID &tmp_table, CondType filter_type, bool is_zero_result = false, JoinType join_type = JoinType::JO_INNER); @@ -127,7 +128,7 @@ class Query final { int VirtualColumnAlreadyExists(const TabID &tmp_table, const std::vector &vcs, const AttrID &at); int Item2CQTerm(Item *an_arg, CQTerm &term, const TabID &tmp_table, CondType filter_type, bool negative = false, - Item *left_expr_for_subselect = NULL, common::Operator *oper_for_subselect = NULL); + Item *left_expr_for_subselect = nullptr, common::Operator *oper_for_subselect = nullptr); // int FilterNotSubselect(Item *conds, const TabID& tmp_table, FilterType // filter_type, FilterID *and_me_filter = 0); @@ -241,7 +242,7 @@ class Query final { * \return column number */ int AddColumnForPhysColumn(Item *item, const TabID &tmp_table, const common::ColOperation oper, const bool distinct, - bool group_by, const char *alias = NULL); + bool group_by, const char *alias = nullptr); /*! \brief Creates AddColumn step in compilation by creating, if does not * exist, Virtual Column based on expression \param mysql_expression - pointer @@ -307,7 +308,7 @@ class Query final { // * e.g., not acceptable type of expression // */ // WrapStatus WrapMysqlExpressionWithAggregations(Item *item, const TabID& - // tmp_table, MysqlExpression*& expr, bool* is_const_or_aggr = NULL); + // tmp_table, MysqlExpression*& expr, bool* is_const_or_aggr = nullptr); /*! \brief Generates AddColumn compilation steps for every field on SELECT * list \param fields - list of fields \param tmp_table - alias of TempTable diff --git a/storage/tianmu/core/rc_attr.cpp b/storage/tianmu/core/rc_attr.cpp index a6f61f996..950f70186 100644 --- a/storage/tianmu/core/rc_attr.cpp +++ b/storage/tianmu/core/rc_attr.cpp @@ -360,7 +360,7 @@ void RCAttr::LoadPackInfo([[maybe_unused]] Transaction *trans_) { PackOntologicalStatus RCAttr::GetPackOntologicalStatus(int pack_no) { LoadPackInfo(); - DPN const *dpn(pack_no >= 0 ? &get_dpn(pack_no) : NULL); + DPN const *dpn(pack_no >= 0 ? &get_dpn(pack_no) : nullptr); if (pack_no < 0 || dpn->NullOnly()) return PackOntologicalStatus::NULLS_ONLY; if (GetPackType() == common::PackType::INT) { @@ -398,7 +398,7 @@ types::BString RCAttr::GetNotNullValueString(const int64_t obj) { if (GetPackType() == common::PackType::STR) { auto cur_pack = get_packS(pack); - ASSERT(cur_pack != NULL, "Pack ptr is null"); + ASSERT(cur_pack != nullptr, "Pack ptr is null"); ASSERT(cur_pack->IsLocked(), "Access unlocked pack"); return cur_pack->GetValueBinary(offset); } @@ -469,7 +469,7 @@ types::RCValueObject RCAttr::GetValue(int64_t obj, bool lookup_to_num) { ret = GetNotNullValueString(obj); else if (ATI::IsBinType(a_type)) { auto tmp_size = GetLength(obj); - types::BString rcbs(NULL, tmp_size, true); + types::BString rcbs(nullptr, tmp_size, true); GetValueBin(obj, tmp_size, rcbs.val_); rcbs.null_ = false; ret = rcbs; @@ -503,7 +503,7 @@ types::RCDataType &RCAttr::GetValueData(size_t obj, types::RCDataType &value, bo ((types::BString &)value) = GetNotNullValueString(obj); else if (ATI::IsBinType(a_type)) { auto tmp_size = GetLength(obj); - ((types::BString &)value) = types::BString(NULL, tmp_size, true); + ((types::BString &)value) = types::BString(nullptr, tmp_size, true); GetValueBin(obj, tmp_size, ((types::BString &)value).val_); value.null_ = false; } else if (ATI::IsIntegerType(a_type)) diff --git a/storage/tianmu/core/rc_attr.h b/storage/tianmu/core/rc_attr.h index 353e97dd7..d42d08b81 100644 --- a/storage/tianmu/core/rc_attr.h +++ b/storage/tianmu/core/rc_attr.h @@ -53,7 +53,7 @@ class TextStat; // ENCODING LEVELS // 0 - text values of attributes -// NULL represented as '\0' string or null pointer +// nullptr represented as '\0' string or null pointer // 1 - int encoded: // common::CT::INT,common::CT::NUM - int64_t value, // common::NULL_VALUE_64 for null, may be also @@ -277,12 +277,12 @@ class RCAttr final : public mm::TraceableObject, public PhysicalColumn, public P uint64_t ApproxAnswerSize(Descriptor &d) override; // maximal byte string length in column - size_t MaxStringSize(Filter *f = NULL) override; + size_t MaxStringSize(Filter *f = nullptr) override; bool IsDistinct(Filter *f) override; // for numerical: best rough approximation of min/max for a given filter (or - // global min if filter is NULL) or rough filter - int64_t RoughMin(Filter *f, common::RSValue *rf = NULL) override; - int64_t RoughMax(Filter *f, common::RSValue *rf = NULL) override; + // global min if filter is nullptr) or rough filter + int64_t RoughMin(Filter *f, common::RSValue *rf = nullptr) override; + int64_t RoughMax(Filter *f, common::RSValue *rf = nullptr) override; // Rough queries and indexes // Note that you should release all indexes after using a series of @@ -301,11 +301,11 @@ class RCAttr final : public mm::TraceableObject, public PhysicalColumn, public P void RoughStats(double &hist_density, int &trivial_packs, double &span); void DisplayAttrStats(Filter *f) override; // filter is for # of objects in packs double RoughSelectivity() override; - void GetTextStat(types::TextStat &s, Filter *f = NULL) override; + void GetTextStat(types::TextStat &s, Filter *f = nullptr) override; std::vector GetListOfDistinctValuesInPack(int pack) override; - void LoadData(loader::ValueCache *nvs, Transaction *conn_info = NULL); + void LoadData(loader::ValueCache *nvs, Transaction *conn_info = nullptr); void LoadPackInfo(Transaction *trans_ = current_txn_); void LoadProcessedData([[maybe_unused]] std::unique_ptr &s, [[maybe_unused]] size_t no_rows){/* TODO */}; diff --git a/storage/tianmu/core/rc_table.cpp b/storage/tianmu/core/rc_table.cpp index a83e83c94..bce1a9b72 100644 --- a/storage/tianmu/core/rc_table.cpp +++ b/storage/tianmu/core/rc_table.cpp @@ -361,7 +361,7 @@ void RCTable::CommitVersion() { // directory containing the file has also reached disk. For that an // explicit fsync() on a file descriptor for the directory is also needed. auto dir = ::opendir(m_path.c_str()); - if (dir == NULL) { + if (dir == nullptr) { throw std::system_error(errno, std::system_category(), "opendir() " + p.string()); } @@ -796,7 +796,7 @@ uint64_t RCTable::ProceedNormal(system::IOParameters &iop) { } int RCTable::binlog_load_query_log_event(system::IOParameters &iop) { - char *load_data_query, *end, *fname_start, *fname_end, *p = NULL; + char *load_data_query, *end, *fname_start, *fname_end, *p = nullptr; size_t pl = 0; List fv; Item *item; @@ -877,7 +877,7 @@ int RCTable::binlog_load_query_log_event(system::IOParameters &iop) { if (!(load_data_query = (char *)thd->alloc(lle.get_query_buffer_length() + 1 + pl))) return -1; - lle.print_query(FALSE, ex->cs ? ex->cs->csname : NULL, load_data_query, &end, &fname_start, &fname_end); + lle.print_query(FALSE, ex->cs ? ex->cs->csname : nullptr, load_data_query, &end, &fname_start, &fname_end); std::strcpy(end, p); end += pl; @@ -912,7 +912,7 @@ size_t RCTable::max_row_length(std::vector &vcs, uint row, u } int RCTable::binlog_insert2load_log_event(system::IOParameters &iop) { - char *load_data_query, *p = NULL; + char *load_data_query, *p = nullptr; size_t pl = 0; List fv; @@ -999,7 +999,7 @@ int RCTable::binlog_insert2load_block(std::vector &vcs, uint } for (uint att = 0; att < m_attrs.size(); ++att) { if (vcs[att].IsNull(i)) { - std::memcpy(ptr, "NULL", 4); + std::memcpy(ptr, "nullptr", 4); ptr += 4; if (att < cols - 1) { *ptr = FIELDS_DELIMITER; diff --git a/storage/tianmu/core/rc_table.h b/storage/tianmu/core/rc_table.h index a91269765..698773b34 100644 --- a/storage/tianmu/core/rc_table.h +++ b/storage/tianmu/core/rc_table.h @@ -106,17 +106,17 @@ class RCTable final : public JustATable { int64_t GetTable64(int64_t obj, int attr) override; // value from table in 1-level numerical form bool IsNull(int64_t obj, int attr) override; // return true if the value of attr. is null - types::RCValueObject GetValue(int64_t obj, int attr, Transaction *conn = NULL); + types::RCValueObject GetValue(int64_t obj, int attr, Transaction *conn = nullptr); const fs::path &Path() { return m_path; } // Query execution // for numerical: best rough approximation of min/max for a given filter (or - // global min if filter is NULL) - int64_t RoughMin(int n_a, Filter *f = NULL); - int64_t RoughMax(int n_a, Filter *f = NULL); + // global min if filter is nullptr) + int64_t RoughMin(int n_a, Filter *f = nullptr); + int64_t RoughMax(int n_a, Filter *f = nullptr); - uint MaxStringSize(int n_a, Filter *f = NULL) override; + uint MaxStringSize(int n_a, Filter *f = nullptr) override; void FillRowByRowid(TABLE *table, int64_t obj); void DisplayRSI(); uint32_t Getpackpower() const override; diff --git a/storage/tianmu/core/rcattr_exeq_rs.cpp b/storage/tianmu/core/rcattr_exeq_rs.cpp index 788ecfaf1..25f7d5a4c 100644 --- a/storage/tianmu/core/rcattr_exeq_rs.cpp +++ b/storage/tianmu/core/rcattr_exeq_rs.cpp @@ -65,7 +65,7 @@ common::RSValue RCAttr::RoughCheck(int pack, Descriptor &d, bool additional_null if (!d.encoded) return common::RSValue::RS_SOME; vcolumn::VirtualColumn *vc1 = d.val1.vc; - static MIIterator const mit(NULL, pss); + static MIIterator const mit(nullptr, pss); LoadPackInfo(); // just in case, although the condition was encoded and // this function should be executed earlier auto const &dpn(get_dpn(pack)); @@ -129,7 +129,7 @@ common::RSValue RCAttr::RoughCheck(int pack, Descriptor &d, bool additional_null pattern_fixed_prefix++; if ((pattern_fixed_prefix > 0) && types::BString(pat.val_, pattern_fixed_prefix).LessEqThanMax(dpn.max_s) == - false) // val_t==NULL means +/-infty + false) // val_t==nullptr means +/-infty res = common::RSValue::RS_NONE; if (pattern_fixed_prefix > GetActualSize(pack)) res = common::RSValue::RS_NONE; @@ -315,11 +315,11 @@ common::RSValue RCAttr::RoughCheck(int pack, Descriptor &d, bool additional_null res = common::RSValue::RS_NONE; } else if ((vmax.val_ && vmax.GreaterEqThanMinUTF(dpn.min_s, Type().GetCollation()) == false) || (vmin.val_ && - vmin.LessEqThanMaxUTF(dpn.max_s, Type().GetCollation()) == false)) // val_t==NULL means +/-infty + vmin.LessEqThanMaxUTF(dpn.max_s, Type().GetCollation()) == false)) // val_t==nullptr means +/-infty res = common::RSValue::RS_NONE; - else if ((vmin.val_ == NULL || vmin.GreaterEqThanMinUTF(dpn.min_s, Type().GetCollation()) == false) && - (vmax.val_ == NULL || - vmax.LessEqThanMaxUTF(dpn.max_s, Type().GetCollation()) == false)) // val_t==NULL means +/-infty + else if ((vmin.val_ == nullptr || vmin.GreaterEqThanMinUTF(dpn.min_s, Type().GetCollation()) == false) && + (vmax.val_ == nullptr || + vmax.LessEqThanMaxUTF(dpn.max_s, Type().GetCollation()) == false)) // val_t==nullptr means +/-infty res = common::RSValue::RS_ALL; else if (pack_prefix == GetActualSize(pack) && vmin == vmax) { // exact case for short texts if (vmin.GreaterEqThanMinUTF(dpn.min_s, Type().GetCollation()) && @@ -395,8 +395,8 @@ common::RSValue RCAttr::RoughCheck(int pack, Descriptor &d, bool additional_null if (!d.encoded) return common::RSValue::RS_SOME; vcolumn::SingleColumn *sc = - (static_cast(d.val1.vc->IsSingleColumn()) ? static_cast(d.val1.vc) : NULL); - RCAttr *sec = NULL; + (static_cast(d.val1.vc->IsSingleColumn()) ? static_cast(d.val1.vc) : nullptr); + RCAttr *sec = nullptr; if (sc) sec = dynamic_cast(sc->GetPhysical()); if (d.IsType_AttrAttr() && d.op != common::Operator::O_BETWEEN && d.op != common::Operator::O_NOT_BETWEEN && sec) { @@ -532,15 +532,15 @@ common::RSValue RCAttr::RoughCheck(int pack1, int pack2, Descriptor &d) { vcolumn::VirtualColumn *vc2 = d.val2.vc; // Limitations for now: only the easiest numerical cases - if (vc1 == NULL || vc2 != NULL || d.op != common::Operator::O_EQ || pack1 == -1 || pack2 == -1) + if (vc1 == nullptr || vc2 != nullptr || d.op != common::Operator::O_EQ || pack1 == -1 || pack2 == -1) return common::RSValue::RS_SOME; - vcolumn::SingleColumn *sc = NULL; + vcolumn::SingleColumn *sc = nullptr; if (static_cast(vc1->IsSingleColumn())) sc = static_cast(vc1); - if (sc == NULL) + if (sc == nullptr) return common::RSValue::RS_SOME; RCAttr *sec = dynamic_cast(sc->GetPhysical()); - if (sec == NULL || !Type().IsNumComparable(sec->Type())) + if (sec == nullptr || !Type().IsNumComparable(sec->Type())) return common::RSValue::RS_SOME; LoadPackInfo(); @@ -594,12 +594,12 @@ common::RSValue RCAttr::RoughCheckBetween(int pack, int64_t v1, int64_t v2) { return res; } -int64_t RCAttr::RoughMin(Filter *f, common::RSValue *rf) // f == NULL is treated as full filter +int64_t RCAttr::RoughMin(Filter *f, common::RSValue *rf) // f == nullptr is treated as full filter { LoadPackInfo(); if (GetPackType() == common::PackType::STR) return common::MINUS_INF_64; - if (f && f->IsEmpty() && rf == NULL) + if (f && f->IsEmpty() && rf == nullptr) return 0; int64_t res; if (ATI::IsRealType(TypeName())) { @@ -610,7 +610,7 @@ int64_t RCAttr::RoughMin(Filter *f, common::RSValue *rf) // f == NULL is treate di.d = DBL_MAX; for (uint p = 0; p < SizeOfPack(); p++) { // minimum of nonempty packs auto const &dpn(get_dpn(p)); - if ((f == NULL || !f->IsEmpty(p)) && (rf == NULL || rf[p] != common::RSValue::RS_NONE)) { + if ((f == nullptr || !f->IsEmpty(p)) && (rf == nullptr || rf[p] != common::RSValue::RS_NONE)) { if (di.d > dpn.min_d) di.i = dpn.min_i; } @@ -622,7 +622,7 @@ int64_t RCAttr::RoughMin(Filter *f, common::RSValue *rf) // f == NULL is treate res = common::PLUS_INF_64; for (uint p = 0; p < SizeOfPack(); p++) { // minimum of nonempty packs auto const &dpn(get_dpn(p)); - if ((f == NULL || !f->IsEmpty(p)) && (rf == NULL || rf[p] != common::RSValue::RS_NONE) && res > dpn.min_i) + if ((f == nullptr || !f->IsEmpty(p)) && (rf == nullptr || rf[p] != common::RSValue::RS_NONE) && res > dpn.min_i) res = dpn.min_i; } if (res == common::PLUS_INF_64) @@ -631,12 +631,12 @@ int64_t RCAttr::RoughMin(Filter *f, common::RSValue *rf) // f == NULL is treate return res; } -int64_t RCAttr::RoughMax(Filter *f, common::RSValue *rf) // f == NULL is treated as full filter +int64_t RCAttr::RoughMax(Filter *f, common::RSValue *rf) // f == nullptr is treated as full filter { LoadPackInfo(); if (GetPackType() == common::PackType::STR) return common::PLUS_INF_64; - if (f && f->IsEmpty() && rf == NULL) + if (f && f->IsEmpty() && rf == nullptr) return 0; int64_t res; if (ATI::IsRealType(TypeName())) { @@ -647,7 +647,7 @@ int64_t RCAttr::RoughMax(Filter *f, common::RSValue *rf) // f == NULL is treate di.d = -(DBL_MAX); for (uint p = 0; p < SizeOfPack(); p++) { // minimum of nonempty packs auto const &dpn(get_dpn(p)); - if ((f == NULL || !f->IsEmpty(p)) && (rf == NULL || rf[p] != common::RSValue::RS_NONE)) { + if ((f == nullptr || !f->IsEmpty(p)) && (rf == nullptr || rf[p] != common::RSValue::RS_NONE)) { if (di.d < dpn.max_d) di.i = dpn.max_i; } @@ -659,7 +659,7 @@ int64_t RCAttr::RoughMax(Filter *f, common::RSValue *rf) // f == NULL is treate res = common::MINUS_INF_64; for (uint p = 0; p < SizeOfPack(); p++) { // maximum of nonempty packs auto const &dpn(get_dpn(p)); - if ((f == NULL || !f->IsEmpty(p)) && (rf == NULL || rf[p] != common::RSValue::RS_NONE) && res < dpn.max_i) + if ((f == nullptr || !f->IsEmpty(p)) && (rf == nullptr || rf[p] != common::RSValue::RS_NONE) && res < dpn.max_i) res = dpn.max_i; } if (res == common::MINUS_INF_64) @@ -743,7 +743,7 @@ uint64_t RCAttr::ApproxDistinctVals(bool incl_nulls, Filter *f, common::RSValue values_present.Reset(); for (uint p = 0; p < SizeOfPack(); p++) { auto const &dpn(get_dpn(p)); - if ((f == NULL || !f->IsEmpty(p)) && (rf == NULL || rf[p] != common::RSValue::RS_NONE) && + if ((f == nullptr || !f->IsEmpty(p)) && (rf == nullptr || rf[p] != common::RSValue::RS_NONE) && dpn.min_i <= dpn.max_i) { // dpn.min <= dpn.max is not true e.g. when the pack contains nulls // only @@ -775,7 +775,7 @@ uint64_t RCAttr::ApproxDistinctVals(bool incl_nulls, Filter *f, common::RSValue TypeName() == common::CT::LONGTEXT) { size_t max_len = 0; for (uint p = 0; p < SizeOfPack(); p++) { // max len of nonempty packs - if (f == NULL || !f->IsEmpty(p)) + if (f == nullptr || !f->IsEmpty(p)) max_len = std::max(max_len, GetActualSize(p)); } if (max_len > 0 && max_len < 6) @@ -795,12 +795,12 @@ uint64_t RCAttr::ApproxDistinctVals(bool incl_nulls, Filter *f, common::RSValue uint64_t RCAttr::ExactDistinctVals(Filter *f) // provide the exact number of diff. non-null values, if // possible, or common::NULL_VALUE_64 { - if (f == NULL) // no exact information about tuples => nothing can be - // determined for sure + if (f == nullptr) // no exact information about tuples => nothing can be + // determined for sure return common::NULL_VALUE_64; LoadPackInfo(); if (Type().IsLookup() && !types::RequiresUTFConversions(GetCollation()) && f->IsFull()) - return RoughMax(NULL) + 1; + return RoughMax(nullptr) + 1; bool nulls_only = true; for (uint p = 0; p < SizeOfPack(); p++) if (!f->IsEmpty(p) && GetPackOntologicalStatus(p) != PackOntologicalStatus::NULLS_ONLY) { @@ -890,7 +890,7 @@ void RCAttr::GetTextStat(types::TextStat &s, Filter *f) { if (auto sp = GetFilter_CMap()) { success = true; for (uint p = 0; p < SizeOfPack(); p++) - if (f == NULL || !f->IsEmpty(p)) { + if (f == nullptr || !f->IsEmpty(p)) { auto const &dpn(get_dpn(p)); if (dpn.NullOnly()) continue; diff --git a/storage/tianmu/core/rcattr_exqp.cpp b/storage/tianmu/core/rcattr_exqp.cpp index 07887e5c2..5cb2b81a8 100644 --- a/storage/tianmu/core/rcattr_exqp.cpp +++ b/storage/tianmu/core/rcattr_exqp.cpp @@ -400,7 +400,7 @@ void RCAttr::EvaluatePack_Like(MIUpdatingIterator &mit, int dim, Descriptor &d) return; } auto p = get_packS(pack); - if (p == NULL) { // => nulls only + if (p == nullptr) { // => nulls only mit.ResetCurrentPack(); mit.NextPackrow(); return; @@ -474,7 +474,7 @@ void RCAttr::EvaluatePack_Like_UTF(MIUpdatingIterator &mit, int dim, Descriptor return; } auto p = get_packS(pack); - if (p == NULL) { // => nulls only + if (p == nullptr) { // => nulls only mit.ResetCurrentPack(); mit.NextPackrow(); return; @@ -544,12 +544,12 @@ void RCAttr::EvaluatePack_InString(MIUpdatingIterator &mit, int dim, Descriptor return; } auto p = get_packS(pack); - if (p == NULL) { // => nulls only + if (p == nullptr) { // => nulls only mit.ResetCurrentPack(); mit.NextPackrow(); return; } - DEBUG_ASSERT(dynamic_cast(d.val1.vc) != NULL); + DEBUG_ASSERT(dynamic_cast(d.val1.vc) != nullptr); vcolumn::MultiValColumn *multival_column = static_cast(d.val1.vc); bool encoded_set = multival_column->IsSetEncoded(TypeName(), ct.GetScale()); do { @@ -585,13 +585,13 @@ void RCAttr::EvaluatePack_InString_UTF(MIUpdatingIterator &mit, int dim, Descrip } auto p = get_packS(pack); - if (p == NULL) { // => nulls only + if (p == nullptr) { // => nulls only mit.ResetCurrentPack(); mit.NextPackrow(); return; } - DEBUG_ASSERT(dynamic_cast(d.val1.vc) != NULL); + DEBUG_ASSERT(dynamic_cast(d.val1.vc) != nullptr); vcolumn::MultiValColumn *multival_column = static_cast(d.val1.vc); DTCollation coll = d.GetCollation(); int arraysize = d.val1.cond_value.size(); @@ -646,7 +646,7 @@ void RCAttr::EvaluatePack_InNum(MIUpdatingIterator &mit, int dim, Descriptor &d) int64_t local_min = dpn.min_i; int64_t local_max = dpn.max_i; - DEBUG_ASSERT(dynamic_cast(d.val1.vc) != NULL); + DEBUG_ASSERT(dynamic_cast(d.val1.vc) != nullptr); vcolumn::MultiValColumn *multival_column = static_cast(d.val1.vc); bool lookup_to_num = ATI::IsStringType(TypeName()); bool encoded_set = (lookup_to_num ? multival_column->IsSetEncoded(common::CT::NUM, 0) @@ -733,7 +733,7 @@ void RCAttr::EvaluatePack_BetweenString(MIUpdatingIterator &mit, int dim, Descri } auto p = get_packS(pack); - if (p == NULL) { // => nulls only + if (p == nullptr) { // => nulls only mit.ResetCurrentPack(); mit.NextPackrow(); return; @@ -790,7 +790,7 @@ void RCAttr::EvaluatePack_BetweenString_UTF(MIUpdatingIterator &mit, int dim, De } auto p = get_packS(pack); - if (p == NULL) { // => nulls only + if (p == nullptr) { // => nulls only mit.ResetCurrentPack(); mit.NextPackrow(); return; @@ -1132,7 +1132,7 @@ bool RCAttr::IsDistinct(Filter *f) { if (ct.IsLookup() && types::RequiresUTFConversions(GetCollation())) return false; if (PhysicalColumn::IsDistinct() == common::RSValue::RS_ALL) { // = is_unique_updated && is_unique - if (f == NULL) + if (f == nullptr) return (NumOfNulls() == 0); // no nulls at all, and is_unique => distinct LoadPackInfo(); for (uint b = 0; b < SizeOfPack(); b++) @@ -1146,7 +1146,7 @@ bool RCAttr::IsDistinct(Filter *f) { uint64_t RCAttr::ApproxAnswerSize(Descriptor &d) { MEASURE_FET("RCAttr::ApproxAnswerSize(...)"); ASSERT(d.encoded, "The descriptor is not encoded!"); - static MIIterator const mit(NULL, pss); + static MIIterator const mit(nullptr, pss); LoadPackInfo(); if (d.op == common::Operator::O_NOT_NULL) @@ -1155,7 +1155,7 @@ uint64_t RCAttr::ApproxAnswerSize(Descriptor &d) { return NumOfNulls(); if (d.val1.vc && !d.val1.vc->IsConst()) { - uint64_t no_distinct = ApproxDistinctVals(false, NULL, NULL, false); + uint64_t no_distinct = ApproxDistinctVals(false, nullptr, nullptr, false); if (no_distinct == 0) no_distinct = 1; if (d.op == common::Operator::O_EQ) @@ -1261,7 +1261,7 @@ bool RCAttr::TryToMerge(Descriptor &d1, Descriptor &d2) { return false; if (GetPackType() == common::PackType::INT && d1.val1.vc && d1.val2.vc && d2.val1.vc && d2.val2.vc && d1.val1.vc->IsConst() && d1.val2.vc->IsConst() && d2.val1.vc->IsConst() && d2.val2.vc->IsConst()) { - static MIIterator const mit(NULL, pss); + static MIIterator const mit(nullptr, pss); int64_t d1min = d1.val1.vc->GetValueInt64(mit); int64_t d1max = d1.val2.vc->GetValueInt64(mit); int64_t d2min = d2.val1.vc->GetValueInt64(mit); @@ -1322,7 +1322,7 @@ bool RCAttr::TryToMerge(Descriptor &d1, Descriptor &d2) { } else if (GetPackType() == common::PackType::STR && d1.val1.vc && d1.val2.vc && d2.val1.vc && d2.val2.vc && d1.val1.vc->IsConst() && d1.val2.vc->IsConst() && d2.val1.vc->IsConst() && d2.val2.vc->IsConst() && d1.sharp == d2.sharp && d1.GetCollation().collation == d2.GetCollation().collation) { - static MIIterator const mit(NULL, pss); + static MIIterator const mit(nullptr, pss); types::BString d1min, d1max, d2min, d2max; d1.val1.vc->GetValueString(d1min, mit); d1.val2.vc->GetValueString(d1max, mit); diff --git a/storage/tianmu/core/rough_multi_index.cpp b/storage/tianmu/core/rough_multi_index.cpp index 3ddaa4775..284033aa4 100644 --- a/storage/tianmu/core/rough_multi_index.cpp +++ b/storage/tianmu/core/rough_multi_index.cpp @@ -32,7 +32,7 @@ RoughMultiIndex::RoughMultiIndex(std::vector no_of_packs) { if (no_packs[d] > 0) rf[d] = new common::RSValue[no_packs[d]]; else - rf[d] = NULL; + rf[d] = nullptr; for (int p = 0; p < no_packs[d]; p++) rf[d][p] = common::RSValue::RS_UNKNOWN; } } @@ -53,7 +53,7 @@ RoughMultiIndex::RoughMultiIndex(const RoughMultiIndex &rmind) { if (no_packs[d] > 0) rf[d] = new common::RSValue[no_packs[d]]; else - rf[d] = NULL; + rf[d] = nullptr; for (int p = 0; p < no_packs[d]; p++) rf[d][p] = rmind.rf[d][p]; } } @@ -72,14 +72,14 @@ RoughMultiIndex::~RoughMultiIndex() { common::RSValue *RoughMultiIndex::GetLocalDescFilter(int dim, int desc_num, bool read_only) { if (desc_num < 0) - return NULL; + return nullptr; uint j; for (j = 0; j < local_desc[dim].size(); j++) { if ((local_desc[dim])[j]->desc_num == desc_num) return (local_desc[dim])[j]->desc_rf; } if (read_only) - return NULL; // no local filter available + return nullptr; // no local filter available // still here? Now j is the first unused descriptor slot, and we should // prepare a new table. @@ -121,7 +121,7 @@ void RoughMultiIndex::MakeDimensionEmpty(int dim /*= -1*/) { bool RoughMultiIndex::UpdateGlobalRoughFilter(int dim, int desc_num) { bool any_nonempty = false; common::RSValue *loc_rs = GetLocalDescFilter(dim, desc_num, true); - if (loc_rs == NULL) + if (loc_rs == nullptr) return true; for (int p = 0; p < no_packs[dim]; p++) { if (rf[dim][p] == common::RSValue::RS_UNKNOWN) { // not known yet - get the first diff --git a/storage/tianmu/core/sorter3.cpp b/storage/tianmu/core/sorter3.cpp index 857cc28bb..cb343cb82 100644 --- a/storage/tianmu/core/sorter3.cpp +++ b/storage/tianmu/core/sorter3.cpp @@ -56,16 +56,16 @@ SorterOnePass::SorterOnePass(uint _size, uint _key_bytes, uint _total_bytes) if (bound_queue_size < 10) bound_queue_size = 10; - buf = NULL; - bound_queue = NULL; - buf_tmp = NULL; + buf = nullptr; + bound_queue = nullptr; + buf_tmp = nullptr; if (size > 0) { buf = (unsigned char *)alloc(size * total_bytes, mm::BLOCK_TYPE::BLOCK_TEMPORARY, true); - if (buf == NULL) + if (buf == nullptr) throw common::OutOfMemoryException(); bound_queue = (unsigned char **)alloc(bound_queue_size * 2 * sizeof(unsigned char *), mm::BLOCK_TYPE::BLOCK_TEMPORARY, true); - if (bound_queue == NULL) { + if (bound_queue == nullptr) { dealloc(buf); throw common::OutOfMemoryException(); } @@ -116,7 +116,7 @@ unsigned char *SorterOnePass::GetNextValue() { already_sorted = true; } if (buf_output_pos == buf_input_pos) - return NULL; + return nullptr; unsigned char *res = buf_output_pos; buf_output_pos += total_bytes; return res; @@ -211,7 +211,7 @@ void SorterOnePass::BubbleSort(unsigned char *s1, unsigned char *pom; j = s2; do { - pom = NULL; + pom = nullptr; for (unsigned char *i = s1; i < s2; i += total_bytes) { if (std::memcmp(i, i + total_bytes, key_bytes) > 0) { Switch(i, i + total_bytes); @@ -219,7 +219,7 @@ void SorterOnePass::BubbleSort(unsigned char *s1, } } j = pom; - } while (j != NULL); + } while (j != nullptr); } SorterMultiPass::SorterMultiPass(uint _size, uint _key_bytes, uint _total_bytes) @@ -260,7 +260,7 @@ unsigned char *SorterMultiPass::GetNextValue() { } // merge if (heap.empty()) - return NULL; + return nullptr; SorterMultiPass::Keyblock cur_val = heap.top(); unsigned char *res = cur_val.rec; heap.pop(); @@ -290,7 +290,7 @@ void SorterMultiPass::InitHeap() { rows_in_small_buffer = 3; dealloc(buf); buf = (unsigned char *)alloc(3 * total_bytes * no_blocks, mm::BLOCK_TYPE::BLOCK_TEMPORARY, true); - if (buf == NULL) + if (buf == nullptr) throw common::OutOfMemoryException(); } int standard_buf_size = rows_in_small_buffer * total_bytes; @@ -310,16 +310,16 @@ void SorterMultiPass::InitHeap() { SorterMultiPass::Keyblock SorterMultiPass::GetFromBlock(int b, bool &reloaded) { if (blocks[b].read_offset == -2) - return SorterMultiPass::Keyblock(-1, NULL, 0); // end of block - if (blocks[b].read_offset == -1) { // new buffer, to be read - if (blocks[b].file_offset > 0) { // preserve the last row before overwriting the whole buffer + return SorterMultiPass::Keyblock(-1, nullptr, 0); // end of block + if (blocks[b].read_offset == -1) { // new buffer, to be read + if (blocks[b].file_offset > 0) { // preserve the last row before overwriting the whole buffer std::memcpy(last_row, blocks[b].block_start + blocks[b].buf_size - total_bytes, total_bytes); reloaded = true; } int bytes_to_load = std::min(blocks[b].block_size - blocks[b].file_offset, blocks[b].buf_size); if (bytes_to_load <= 0) { blocks[b].read_offset = -2; - return SorterMultiPass::Keyblock(-1, NULL, 0); // end of block + return SorterMultiPass::Keyblock(-1, nullptr, 0); // end of block } CI_Get(b, blocks[b].block_start, bytes_to_load, blocks[b].file_offset); blocks[b].file_offset += bytes_to_load; @@ -340,10 +340,10 @@ SorterMultiPass::Keyblock SorterMultiPass::GetFromBlock(int b, bool &reloaded) { SorterCounting::SorterCounting(uint _size, uint _key_bytes, uint _total_bytes) : Sorter3(_size, _key_bytes, _total_bytes) { buf = (unsigned char *)alloc(size * total_bytes, mm::BLOCK_TYPE::BLOCK_TEMPORARY, true); - if (buf == NULL) + if (buf == nullptr) throw common::OutOfMemoryException(); buf_output = (unsigned char *)alloc(size * total_bytes, mm::BLOCK_TYPE::BLOCK_TEMPORARY, true); - if (buf_output == NULL) { + if (buf_output == nullptr) { dealloc(buf); throw common::OutOfMemoryException(); } @@ -355,7 +355,7 @@ SorterCounting::SorterCounting(uint _size, uint _key_bytes, uint _total_bytes) buf_input_pos = buf; buf_output_pos = buf_output; buf_end = buf + size * total_bytes; - buf_output_end = NULL; // to be calculated + buf_output_end = nullptr; // to be calculated } SorterCounting::~SorterCounting() { @@ -388,7 +388,7 @@ unsigned char *SorterCounting::GetNextValue() { already_sorted = true; } if (buf_output_pos == buf_output_end) - return NULL; + return nullptr; unsigned char *res = buf_output_pos; buf_output_pos += total_bytes; return res; @@ -426,7 +426,7 @@ void SorterCounting::CountingSort() { SorterLimit::SorterLimit(uint _size, uint _key_bytes, uint _total_bytes) : SorterOnePass(_size, _key_bytes, _total_bytes) { buf_input_pos = buf + size * total_bytes; // simulate the end of buffer - zero_buf = NULL; + zero_buf = nullptr; if (key_bytes > 0) { zero_buf = new unsigned char[key_bytes]; std::memset(zero_buf, 0, key_bytes); diff --git a/storage/tianmu/core/sorter3.h b/storage/tianmu/core/sorter3.h index 0040e1d83..dc6572d6e 100644 --- a/storage/tianmu/core/sorter3.h +++ b/storage/tianmu/core/sorter3.h @@ -50,7 +50,7 @@ class Sorter3 : public mm::TraceableObject { /* Return a pointer to a buffer position containing the next sorted row. It is assumed that the pointer is valid until next GetNextValue() is - alled, or the object is deleted. Return NULL at the end of data. + alled, or the object is deleted. Return nullptr at the end of data. */ virtual unsigned char *GetNextValue() = 0; /* @@ -154,13 +154,13 @@ class SorterMultiPass : public SorterOnePass, private system::CacheableItem { void InitHeap(); // prepare heap, load beginnings of blocks into memory Keyblock GetFromBlock(int b, bool &reloaded); // get the next value from block, return (-1, - // NULL, 0) if the block is empty + // nullptr, 0) if the block is empty // set reloaded if the data was reloaded (and the last buffer position // preserved) struct BlockDescription { BlockDescription(int b_size) - : block_size(b_size), file_offset(0), block_start(NULL), read_offset(-1), buf_size(0) {} + : block_size(b_size), file_offset(0), block_start(nullptr), read_offset(-1), buf_size(0) {} int block_size; // total size in bytes int file_offset; // current offset of file read position unsigned char *block_start; // start of buffer prepared for this block diff --git a/storage/tianmu/core/sorter_wrapper.cpp b/storage/tianmu/core/sorter_wrapper.cpp index a728dd964..1ef8135d2 100644 --- a/storage/tianmu/core/sorter_wrapper.cpp +++ b/storage/tianmu/core/sorter_wrapper.cpp @@ -27,11 +27,11 @@ namespace core { SorterWrapper::SorterWrapper(MultiIndex &_mind, int64_t _limit) : cur_mit(&_mind) { no_of_rows = _mind.NumOfTuples(); limit = _limit; - s = NULL; - mi_encoder = NULL; + s = nullptr; + mi_encoder = nullptr; buf_size = 0; - cur_val = NULL; - input_buf = NULL; + cur_val = nullptr; + input_buf = nullptr; no_values_encoded = 0; rough_sort_by = -1; } @@ -223,7 +223,7 @@ void SorterWrapper::SortRoughly(std::vector &po) { bool SorterWrapper::InitPackrow(MIIterator &mit) // return true if the packrow may be skipped { - if (s == NULL) + if (s == nullptr) return false; // trivial sorter (constant values) // rough sort: exclude packs which are for sure out of scope @@ -256,7 +256,7 @@ bool SorterWrapper::InitPackrow(MIIterator &mit) // return true if the packrow } bool SorterWrapper::PutValues(MIIterator &mit) { - if (s == NULL) + if (s == nullptr) return false; // trivial sorter (constant values) if (mi_encoder) mi_encoder->Encode(input_buf, mit); @@ -265,13 +265,13 @@ bool SorterWrapper::PutValues(MIIterator &mit) { // or already prepared for (uint i = 0; i < scol.size(); i++) if (scol[i].IsEnabled() && scol[i].IsNontrivial()) // constant num. columns are trivial - scol[i].Encode(input_buf, mit, NULL, update_stats); + scol[i].Encode(input_buf, mit, nullptr, update_stats); no_values_encoded++; return s->PutValue(input_buf); } bool SorterWrapper::PutValues(SorterWrapper &sw) { - if (s == NULL) + if (s == nullptr) return false; // trivial sorter (constant values) no_values_encoded += sw.GetEncodedValNum(); TIANMU_LOG(LogCtl_Level::DEBUG, "PutValues: no_values_encoded %d \n", no_values_encoded); @@ -279,12 +279,12 @@ bool SorterWrapper::PutValues(SorterWrapper &sw) { } bool SorterWrapper::FetchNextRow() { - if (s == NULL) { + if (s == nullptr) { no_of_rows--; - return (no_of_rows >= 0); // trivial sorter (constant values, cur_val is always NULL) + return (no_of_rows >= 0); // trivial sorter (constant values, cur_val is always nullptr) } cur_val = s->GetNextValue(); - if (cur_val == NULL) + if (cur_val == nullptr) return false; if (mi_encoder) mi_encoder->GetValue(cur_val, diff --git a/storage/tianmu/core/temp_table.cpp b/storage/tianmu/core/temp_table.cpp index 295a2bc9f..30c28d64c 100644 --- a/storage/tianmu/core/temp_table.cpp +++ b/storage/tianmu/core/temp_table.cpp @@ -44,7 +44,7 @@ namespace core { template class AttrBuffer : public CachedBuffer { public: - explicit AttrBuffer(uint page_size, uint elem_size = 0, Transaction *conn = NULL) + explicit AttrBuffer(uint page_size, uint elem_size = 0, Transaction *conn = nullptr) : CachedBuffer(page_size, elem_size, conn) {} ~AttrBuffer() = default; @@ -69,15 +69,15 @@ TempTable::Attr::Attr(const Attr &a) : PhysicalColumn(a) { if (term.vc) term.vc->ResetLocalStatistics(); dim = a.dim; - // DEBUG_ASSERT(a.buffer == NULL); // otherwise we cannot copy Attr ! - buffer = NULL; + // DEBUG_ASSERT(a.buffer == nullptr); // otherwise we cannot copy Attr ! + buffer = nullptr; no_obj = a.no_obj; no_power = a.no_power; if (a.alias) { alias = new char[std::strlen(a.alias) + 1]; std::strcpy(alias, a.alias); } else - alias = NULL; + alias = nullptr; page_size = a.page_size; orig_precision = a.orig_precision; @@ -90,7 +90,7 @@ TempTable::Attr::Attr(CQTerm t, common::ColOperation m, uint32_t power, bool dis : mode(m), distinct(dis), term(t), dim(dim), not_complete(true) { ct.Initialize(type, notnull, common::PackFmt::DEFAULT, no_digits, scale, collation); orig_precision = no_digits; - buffer = NULL; + buffer = nullptr; no_obj = 0; no_power = power; no_materialized = 0; @@ -98,7 +98,7 @@ TempTable::Attr::Attr(CQTerm t, common::ColOperation m, uint32_t power, bool dis alias = new char[std::strlen(a) + 1]; std::strcpy(alias, a); } else - alias = NULL; + alias = nullptr; if (m == common::ColOperation::GROUP_CONCAT) si = (*si1); else @@ -120,8 +120,8 @@ TempTable::Attr &TempTable::Attr::operator=(const TempTable::Attr &a) { if (term.vc) term.vc->ResetLocalStatistics(); dim = a.dim; - // DEBUG_ASSERT(a.buffer == NULL); // otherwise we cannot copy Attr ! - buffer = NULL; + // DEBUG_ASSERT(a.buffer == nullptr); // otherwise we cannot copy Attr ! + buffer = nullptr; no_obj = a.no_obj; no_power = a.no_power; delete[] alias; @@ -129,7 +129,7 @@ TempTable::Attr &TempTable::Attr::operator=(const TempTable::Attr &a) { alias = new char[std::strlen(a.alias) + 1]; std::strcpy(alias, a.alias); } else - alias = NULL; + alias = nullptr; page_size = a.page_size; orig_precision = a.orig_precision; @@ -266,7 +266,7 @@ void TempTable::Attr::DeleteBuffer() { default: break; } - buffer = NULL; + buffer = nullptr; no_obj = 0; } @@ -400,7 +400,7 @@ void TempTable::Attr::SetValueString(int64_t obj, const types::BString &val) { ((AttrBuffer *)buffer)->Set(obj, (short)std::atoi(val.GetDataBytesPointer())); break; case common::CT::BIGINT: - ((AttrBuffer *)buffer)->Set(obj, std::strtoll(val.GetDataBytesPointer(), NULL, 10)); + ((AttrBuffer *)buffer)->Set(obj, std::strtoll(val.GetDataBytesPointer(), nullptr, 10)); break; case common::CT::BIN: case common::CT::BYTE: @@ -456,7 +456,7 @@ void TempTable::Attr::GetValueString(types::BString &s, int64_t obj) { s = types::BString(); return; } - double *d_p = NULL; + double *d_p = nullptr; switch (TypeName()) { case common::CT::BIN: case common::CT::BYTE: @@ -758,7 +758,7 @@ void TempTable::Attr::ApplyFilter(MultiIndex &mind, int64_t offset, int64_t last last_index = mind.NumOfTuples(); void *old_buffer = buffer; - buffer = NULL; + buffer = nullptr; CreateBuffer(last_index - offset, mind.m_conn); MIIterator mit(&mind, mind.ValueOfPower()); @@ -969,13 +969,13 @@ std::shared_ptr TempTable::CreateMaterializedCopy(bool translate_orde std::map attr_translation; // new attr (this), old attr (working_copy) for (uint i = 0; i < attrs.size(); i++) { copy_buf.push_back(attrs[i]->buffer); - attrs[i]->buffer = NULL; + attrs[i]->buffer = nullptr; } if (no_global_virt_cols != -1) { // this is a TempTable copy for (uint i = no_global_virt_cols; i < virt_cols.size(); i++) { delete virt_cols[i]; - virt_cols[i] = NULL; + virt_cols[i] = nullptr; } virt_cols.resize(no_global_virt_cols); } @@ -1000,7 +1000,7 @@ std::shared_ptr TempTable::CreateMaterializedCopy(bool translate_orde filter.mind->AddDimension_cross(no_obj); if (virt_cols.size() < attrs.size()) virt_cols.resize(attrs.size()); - fill(virt_cols.begin(), virt_cols.end(), (vcolumn::VirtualColumn *)NULL); + fill(virt_cols.begin(), virt_cols.end(), (vcolumn::VirtualColumn *)nullptr); for (uint i = 0; i < attrs.size(); i++) { vcolumn::VirtualColumn *new_vc = new vcolumn::SingleColumn(working_copy->attrs[i], filter.mind, 0, 0, working_copy.get(), 0); @@ -1065,9 +1065,9 @@ void TempTable::DeleteMaterializedCopy(std::shared_ptr &old_t) // de { MEASURE_FET("TempTable::DeleteMaterializedCopy(...)"); for (uint i = 0; i < attrs.size(); i++) { // Make sure VCs are deleted before the source table is deleted - attrs[i]->term.vc = NULL; + attrs[i]->term.vc = nullptr; delete virt_cols[i]; - virt_cols[i] = NULL; + virt_cols[i] = nullptr; } old_t.reset(); } @@ -1076,7 +1076,7 @@ void TempTable::MoveVC(int colnum, std::vector &from, std::vector &to) { vcolumn::VirtualColumn *vc = from[colnum]; to.push_back(vc); - from[colnum] = NULL; + from[colnum] = nullptr; std::vector vv = vc->GetChildren(); for (size_t i = 0; i < vv.size(); i++) MoveVC(vv[i], from, to); } @@ -1109,7 +1109,7 @@ void TempTable::CreateDisplayableAttrP() { idx++; } } - for (uint i = idx; i < attrs.size(); i++) displayable_attr[i] = NULL; + for (uint i = idx; i < attrs.size(); i++) displayable_attr[i] = nullptr; } uint TempTable::GetDisplayableAttrIndex(uint attr) { @@ -1299,7 +1299,7 @@ void TempTable::Union(TempTable *t, int all) { using vc_ptr_t = std::shared_ptr; std::vector first_vcs; std::vector sec_vcs; - uchar *input_buf = NULL; + uchar *input_buf = nullptr; { // block to ensure deleting encoder before deleting first_vcs, sec_vcs int size = 0; @@ -1572,7 +1572,7 @@ void TempTable::Display(std::ostream &out) { GetTable_S(s, i, j); out << s << " "; } else - out << "NULL" + out << "nullptr" << " "; } out << system::endl; @@ -1899,7 +1899,7 @@ bool TempTable::SubqueryInFrom() { void TempTable::LockPackForUse([[maybe_unused]] unsigned attr, unsigned pack_no) { while (lazy && no_materialized < std::min(((int64_t)pack_no << p_power) + (1 << p_power), no_obj)) - Materialize(false, NULL, true); + Materialize(false, nullptr, true); } bool TempTable::CanOrderSources() { @@ -2026,7 +2026,7 @@ void TempTable::Materialize(bool in_subq, ResultSender *sender, bool lazy) { FillMaterializedBuffers(local_limit, local_offset, sender, lazy); else // in case of order by we need to materialize all rows to be next // ordered - FillMaterializedBuffers(no_obj, 0, NULL, lazy); + FillMaterializedBuffers(no_obj, 0, nullptr, lazy); } } else { // GROUP BY or DISTINCT - compute aggregations @@ -2039,7 +2039,7 @@ void TempTable::Materialize(bool in_subq, ResultSender *sender, bool lazy) { if (HasHavingConditions() && in_subq) having_conds[0].tree->Simplify(true); - ResultSender *local_sender = (distinct_on_materialized || order_by.size() > 0 ? NULL : sender); + ResultSender *local_sender = (distinct_on_materialized || order_by.size() > 0 ? nullptr : sender); AggregationAlgorithm aggr(this); aggr.Aggregate(table_distinct, local_limit, local_offset, local_sender); // this->tree (HAVING) used inside @@ -2072,7 +2072,7 @@ void TempTable::Materialize(bool in_subq, ResultSender *sender, bool lazy) { if (exists_only) local_limit = 1; std::shared_ptr temporary_source_table = CreateMaterializedCopy(false, in_subq); - ResultSender *local_sender = (order_by.size() > 0 ? NULL : sender); + ResultSender *local_sender = (order_by.size() > 0 ? nullptr : sender); AggregationAlgorithm aggr(this); aggr.Aggregate(true, local_limit, local_offset, @@ -2170,7 +2170,7 @@ TempTable::RecordIterator TempTable::begin(Transaction *conn) { return (RecordIt TempTable::RecordIterator TempTable::end(Transaction *conn) { return (RecordIterator(this, conn, NumOfObj())); } -TempTable::RecordIterator::RecordIterator() : table(NULL), _currentRNo(0), _conn(NULL), is_prepared(false) {} +TempTable::RecordIterator::RecordIterator() : table(nullptr), _currentRNo(0), _conn(nullptr), is_prepared(false) {} TempTable::RecordIterator::RecordIterator(TempTable *table_, Transaction *conn_, uint64_t rowNo_) : table(table_), _currentRNo(rowNo_), _conn(conn_), is_prepared(false) { diff --git a/storage/tianmu/core/temp_table.h b/storage/tianmu/core/temp_table.h index cfee86173..a6a94e52e 100644 --- a/storage/tianmu/core/temp_table.h +++ b/storage/tianmu/core/temp_table.h @@ -72,9 +72,9 @@ class TempTable : public JustATable { bool not_complete; // does not contain all the column elements - some // functions cannot be computed - Attr(CQTerm t, common::ColOperation m, uint32_t power, bool distinct = false, char *alias = NULL, int dim = -1, + Attr(CQTerm t, common::ColOperation m, uint32_t power, bool distinct = false, char *alias = nullptr, int dim = -1, common::CT type = common::CT::INT, uint scale = 0, uint precision = 10, bool notnull = true, - DTCollation collation = DTCollation(), SI *si1 = NULL); + DTCollation collation = DTCollation(), SI *si1 = nullptr); Attr(const Attr &); Attr &operator=(const Attr &); int operator==(const Attr &); @@ -96,7 +96,7 @@ class TempTable : public JustATable { } void SetPrecision(int prec) { ct.SetPrecision(prec); } void SetScale(int sc) { ct.SetScale(sc); } - void CreateBuffer(uint64_t size, Transaction *conn = NULL, bool not_completed = false); + void CreateBuffer(uint64_t size, Transaction *conn = nullptr, bool not_completed = false); void FillValue(const MIIterator &mii, size_t idx); size_t FillValues(MIIterator &mii, size_t start, size_t count); void SetNewPageSize(uint new_page_size); @@ -111,15 +111,15 @@ class TempTable : public JustATable { // values (incl. null, if flag set) uint64_t ExactDistinctVals([[maybe_unused]] Filter *f) override { return common::NULL_VALUE_64; } bool IsDistinct([[maybe_unused]] Filter *f) override { return false; } - size_t MaxStringSize(Filter *f = NULL) override; // maximal byte string length in column - int64_t RoughMin(Filter *f = NULL, common::RSValue *rf = NULL) override { + size_t MaxStringSize(Filter *f = nullptr) override; // maximal byte string length in column + int64_t RoughMin(Filter *f = nullptr, common::RSValue *rf = nullptr) override { return common::MINUS_INF_64; } // for numerical: best rough approximation of min for a given filter (or - // global min if filter is NULL) - int64_t RoughMax(Filter *f = NULL, common::RSValue *rf = NULL) override { + // global min if filter is nullptr) + int64_t RoughMax(Filter *f = nullptr, common::RSValue *rf = nullptr) override { return common::PLUS_INF_64; } // for numerical: best rough approximation of max for a given filter (or - // global max if filter is NULL) + // global max if filter is nullptr) void DisplayAttrStats([[maybe_unused]] Filter *f) override {} bool TryToMerge([[maybe_unused]] Descriptor &d1, [[maybe_unused]] Descriptor &d2) override { return false; } PackOntologicalStatus GetPackOntologicalStatus([[maybe_unused]] int pack_no) override { @@ -215,16 +215,16 @@ class TempTable : public JustATable { // Maintenance and low-level functions bool OrderByAndMaterialize(std::vector &ord, int64_t limit, int64_t offset, - ResultSender *sender = NULL); // Sort data contained in - // ParameterizedFilter by using some - // attributes (usually specified by - // AddOrder, but in general - - // arbitrary) + ResultSender *sender = nullptr); // Sort data contained in + // ParameterizedFilter by using some + // attributes (usually specified by + // AddOrder, but in general - + // arbitrary) // just materialize as SELECT * void FillMaterializedBuffers(int64_t local_limit, int64_t local_offset, ResultSender *sender, bool pagewise); - virtual void RoughMaterialize(bool in_subq = false, ResultSender *sender = NULL, bool lazy = false); - virtual void Materialize(bool in_subq = false, ResultSender *sender = NULL, bool lazy = false); + virtual void RoughMaterialize(bool in_subq = false, ResultSender *sender = nullptr, bool lazy = false); + virtual void Materialize(bool in_subq = false, ResultSender *sender = nullptr, bool lazy = false); // just_distinct = 'select distinct' but no 'group by' // Set no_obj = no. of groups in result @@ -251,7 +251,7 @@ class TempTable : public JustATable { TType TableType() const override { return TType::TEMP_TABLE; } // type of JustATable - TempTable uint NumOfAttrs() const override { return (uint)attrs.size(); } uint NumOfDisplaybleAttrs() const override { return no_cols; } // no. of columns with defined alias - bool IsDisplayAttr(int i) { return attrs[i]->alias != NULL; } + bool IsDisplayAttr(int i) { return attrs[i]->alias != nullptr; } int64_t GetTable64(int64_t obj, int attr) override; void GetTable_S(types::BString &s, int64_t obj, int attr) override; void GetTableString(types::BString &s, int64_t obj, uint attr); @@ -265,10 +265,10 @@ class TempTable : public JustATable { bool IsNull(int64_t obj, int attr) override; // return true if the value of attr. is null - int64_t RoughMin([[maybe_unused]] int n_a, Filter *f = NULL) { return common::MINUS_INF_64; } - int64_t RoughMax([[maybe_unused]] int n_a, Filter *f = NULL) { return common::PLUS_INF_64; } + int64_t RoughMin([[maybe_unused]] int n_a, Filter *f = nullptr) { return common::MINUS_INF_64; } + int64_t RoughMax([[maybe_unused]] int n_a, Filter *f = nullptr) { return common::PLUS_INF_64; } - uint MaxStringSize(int n_a, Filter *f = NULL) override { + uint MaxStringSize(int n_a, Filter *f = nullptr) override { if (n_a < 0) return GetFieldSize(-n_a - 1); return GetFieldSize(n_a); @@ -440,8 +440,8 @@ class TempTable : public JustATable { public: class RecordIterator; - virtual RecordIterator begin(Transaction *conn = NULL); - virtual RecordIterator end(Transaction *conn = NULL); + virtual RecordIterator begin(Transaction *conn = nullptr); + virtual RecordIterator end(Transaction *conn = nullptr); public: Transaction *m_conn; // external pointer @@ -509,8 +509,8 @@ class TempTableForSubquery : public TempTable { ~TempTableForSubquery(); void CreateTemplateIfNotExists(); - void Materialize(bool in_subq = false, ResultSender *sender = NULL, bool lazy = false) override; - void RoughMaterialize(bool in_subq = false, ResultSender *sender = NULL, bool lazy = false) override; + void Materialize(bool in_subq = false, ResultSender *sender = nullptr, bool lazy = false) override; + void RoughMaterialize(bool in_subq = false, ResultSender *sender = nullptr, bool lazy = false) override; void ResetToTemplate(bool rough, bool use_filter_shallow = false); void SetAttrsForRough(); void SetAttrsForExact(); diff --git a/storage/tianmu/core/temp_table_com.cpp b/storage/tianmu/core/temp_table_com.cpp index 4bff25f0c..ba50efc63 100644 --- a/storage/tianmu/core/temp_table_com.cpp +++ b/storage/tianmu/core/temp_table_com.cpp @@ -37,9 +37,9 @@ TempTable::TempTable(JustATable *t, int alias, Query *q) if (t->TableType() == TType::TEMP_TABLE) { has_temp_table = true; if (q->IsRoughQuery()) - ((TempTable *)t)->RoughMaterialize(false, NULL, true); + ((TempTable *)t)->RoughMaterialize(false, nullptr, true); else - ((TempTable *)t)->Materialize(false, NULL, false); + ((TempTable *)t)->Materialize(false, nullptr, false); filter.mind->AddDimension_cross(t->NumOfObj()); } else { filter.mind->AddDimension_cross(t->NumOfObj()); diff --git a/storage/tianmu/core/temp_table_low.cpp b/storage/tianmu/core/temp_table_low.cpp index 9bf81f257..5baa97e5f 100644 --- a/storage/tianmu/core/temp_table_low.cpp +++ b/storage/tianmu/core/temp_table_low.cpp @@ -108,14 +108,14 @@ bool TempTable::OrderByAndMaterialize(std::vector &ord, int64_t int sort_order = 0; for (auto &j : attrs) { - if (j->alias != NULL) { + if (j->alias != nullptr) { vcolumn::VirtualColumn *vc = j->term.vc; DEBUG_ASSERT(vc); sort_order = 0; for (uint i = 0; i < ord.size(); i++) if (ord[i].vc == vc) { sort_order = (ord[i].dir == 0 ? (i + 1) : -(i + 1)); - ord[i].vc = NULL; // annotate this entry as already added + ord[i].vc = nullptr; // annotate this entry as already added } sorted_table.AddSortedColumn(vc, sort_order, true); if (task_num != 1) { @@ -129,7 +129,7 @@ bool TempTable::OrderByAndMaterialize(std::vector &ord, int64_t // find all columns not added yet (i.e. not visible in output) for (uint i = 0; i < ord.size(); i++) { - if (ord[i].vc != NULL) { + if (ord[i].vc != nullptr) { sort_order = (ord[i].dir == 0 ? (i + 1) : -(i + 1)); if (task_num != 1) { for (int j = 0; j < task_num; j++) @@ -229,7 +229,7 @@ bool TempTable::OrderByAndMaterialize(std::vector &ord, int64_t // Create output for (uint i = 0; i < NumOfAttrs(); i++) { - if (attrs[i]->alias != NULL) { + if (attrs[i]->alias != nullptr) { if (sender) attrs[i]->CreateBuffer(no_obj > tianmu_sysvar_result_sender_rows ? tianmu_sysvar_result_sender_rows : no_obj, m_conn, no_obj > tianmu_sysvar_result_sender_rows); @@ -246,7 +246,7 @@ bool TempTable::OrderByAndMaterialize(std::vector &ord, int64_t int64_t produced_rows = 0; bool null_value; bool valid = true; - do { // outer loop - through streaming buffers (if sender != NULL) + do { // outer loop - through streaming buffers (if sender != nullptr) do { valid = sorted_table.FetchNextRow(); if (valid && global_row >= offset) { @@ -254,7 +254,7 @@ bool TempTable::OrderByAndMaterialize(std::vector &ord, int64_t if (m_conn->Killed()) throw common::KilledException(); for (auto &attr : attrs) { - if (attr->alias != NULL) { + if (attr->alias != nullptr) { switch (attr->TypeName()) { case common::CT::STRING: case common::CT::VARCHAR: diff --git a/storage/tianmu/core/temp_table_roughquery.cpp b/storage/tianmu/core/temp_table_roughquery.cpp index b2d133856..7f9b6f6c7 100644 --- a/storage/tianmu/core/temp_table_roughquery.cpp +++ b/storage/tianmu/core/temp_table_roughquery.cpp @@ -147,7 +147,7 @@ void TempTable::RoughAggregateSum(vcolumn::VirtualColumn *vc, int64_t &min_val, // possible) for (uint j = 0; j < group_by_attrs.size(); j++) { vcolumn::VirtualColumn *vc_gb = group_by_attrs[j]->term.vc; - if (vc_gb == NULL || vc_gb->GetNumOfNulls(mit) != 0 || vc_gb->GetMinInt64(mit) == common::NULL_VALUE_64 || + if (vc_gb == nullptr || vc_gb->GetNumOfNulls(mit) != 0 || vc_gb->GetMinInt64(mit) == common::NULL_VALUE_64 || vc_gb->GetMinInt64(mit) != vc_gb->GetMaxInt64(mit)) no_groups_or_uniform = false; // leave it true only when we are sure the // grouping columns are uniform for this packrow @@ -274,7 +274,7 @@ void TempTable::RoughAggregateSum(vcolumn::VirtualColumn *vc, int64_t &min_val, bool IsTempTableColumn(vcolumn::VirtualColumn *vc) { vcolumn::SingleColumn *sc = - ((vc && static_cast(vc->IsSingleColumn())) ? static_cast(vc) : NULL); + ((vc && static_cast(vc->IsSingleColumn())) ? static_cast(vc) : nullptr); return (sc && sc->IsTempTableColumn()); } @@ -291,7 +291,7 @@ void TempTable::RoughAggregate(ResultSender *sender) { Interpretation of the result: Minimal and maximal possible value for a given column, if executed as - exact. NULL if not known (unable to determine). + exact. nullptr if not known (unable to determine). */ // filter.Prepare(); @@ -371,7 +371,7 @@ void TempTable::RoughAggregate(ResultSender *sender) { bool double_vals = vc->Type().IsFloat(); int64_t cutoff_value = common::NULL_VALUE_64; int64_t certain_rows = 0; - bool cutoff_is_null = false; // true if all values up to limit are NULL for ascending + bool cutoff_is_null = false; // true if all values up to limit are nullptr for ascending while (mit.IsValid()) { common::RSValue res = filter.rough_mind->GetPackStatus(0, mit.GetCurPackrow(0)); if (res == common::RSValue::RS_ALL) { @@ -445,7 +445,7 @@ void TempTable::RoughAggregate(ResultSender *sender) { vcolumn::VirtualColumn *vc = attrs[i]->term.vc; bool nulls_only = vc ? (vc->GetLocalNullsOnly() || vc->IsRoughNullsOnly()) : false; types::BString vals; - bool double_vals = (vc != NULL && vc->Type().IsFloat()); + bool double_vals = (vc != nullptr && vc->Type().IsFloat()); if (vc && vc->IsConst() && !vc->IsSubSelect() && attrs[i]->mode != common::ColOperation::SUM && attrs[i]->mode != common::ColOperation::COUNT && attrs[i]->mode != common::ColOperation::BIT_XOR) { if (attrs[i]->mode == common::ColOperation::STD_POP || attrs[i]->mode == common::ColOperation::VAR_POP || @@ -666,7 +666,7 @@ void TempTable::RoughAggregate(ResultSender *sender) { group_by_attrs.push_back(attrs[j]); RoughAggregateSum(vc, min_val, max_val, group_by_attrs, nulls_only, attrs[i]->distinct); if (min_val == common::NULL_VALUE_64 || max_val == common::NULL_VALUE_64) { - attrs[i]->SetNull(0); // NULL as a result of empty set or non-computable sum + attrs[i]->SetNull(0); // nullptr as a result of empty set or non-computable sum attrs[i]->SetNull(1); } else { attrs[i]->SetValueInt64(0, min_val); diff --git a/storage/tianmu/core/value_matching_table.cpp b/storage/tianmu/core/value_matching_table.cpp index e76cd2851..9ec588aec 100644 --- a/storage/tianmu/core/value_matching_table.cpp +++ b/storage/tianmu/core/value_matching_table.cpp @@ -67,7 +67,7 @@ ValueMatchingTable *ValueMatchingTable::CreateNew_ValueMatchingTable(int64_t mem } ValueMatching_OnePosition::ValueMatching_OnePosition() { - t_aggr = NULL; + t_aggr = nullptr; iterator_valid = false; } @@ -75,7 +75,7 @@ ValueMatching_OnePosition::ValueMatching_OnePosition(ValueMatching_OnePosition & DEBUG_ASSERT(total_width > 0); iterator_valid = sec.iterator_valid; - t_aggr = NULL; + t_aggr = nullptr; t_aggr = new unsigned char[total_width]; std::memcpy(t_aggr, sec.t_aggr, total_width); } @@ -108,10 +108,10 @@ bool ValueMatching_OnePosition::FindCurrentRow([[maybe_unused]] unsigned char *i } ValueMatching_LookupTable::ValueMatching_LookupTable() { - t = NULL; - t_aggr = NULL; - occupied = NULL; - occupied_table = NULL; + t = nullptr; + t_aggr = nullptr; + occupied = nullptr; + occupied_table = nullptr; max_no_rows = 0; occupied_iterator = 0; } @@ -124,13 +124,13 @@ ValueMatching_LookupTable::ValueMatching_LookupTable(ValueMatching_LookupTable & if (sec.occupied) occupied = new Filter(*sec.occupied); else - occupied = NULL; + occupied = nullptr; if (sec.occupied_table) { occupied_table = new int[max_no_rows]; std::memcpy(occupied_table, sec.occupied_table, max_no_rows * sizeof(int)); } else - occupied_table = NULL; + occupied_table = nullptr; t = (unsigned char *)alloc(total_width * max_no_rows, mm::BLOCK_TYPE::BLOCK_TEMPORARY); t_aggr = t + input_buffer_width; diff --git a/storage/tianmu/core/value_matching_table.h b/storage/tianmu/core/value_matching_table.h index 39c845c47..ed3cb14fa 100644 --- a/storage/tianmu/core/value_matching_table.h +++ b/storage/tianmu/core/value_matching_table.h @@ -113,7 +113,7 @@ class ValueMatching_OnePosition : public ValueMatchingTable { ValueMatchingTable *Clone() override { return new ValueMatching_OnePosition(*this); } void Clear() override; - unsigned char *GetGroupingRow([[maybe_unused]] int64_t row) override { return NULL; } + unsigned char *GetGroupingRow([[maybe_unused]] int64_t row) override { return nullptr; } unsigned char *GetAggregationRow([[maybe_unused]] int64_t row) override { return t_aggr; } bool FindCurrentRow(unsigned char *input_buffer, int64_t &row, bool add_if_new = true) override; diff --git a/storage/tianmu/core/value_set.h b/storage/tianmu/core/value_set.h index df30083c4..c77fca77b 100644 --- a/storage/tianmu/core/value_set.h +++ b/storage/tianmu/core/value_set.h @@ -62,7 +62,7 @@ class ValueSet { void Prepare(common::CT at, int scale, DTCollation); bool Contains(int64_t v); // easy case, for non-null integers bool Contains(types::BString &v); // easy case, for strings - bool EasyMode() { return (use_easy_table || easy_vals != NULL || easy_hash != NULL) && prepared; } + bool EasyMode() { return (use_easy_table || easy_vals != nullptr || easy_hash != nullptr) && prepared; } bool Contains(const types::RCValueObject &v, DTCollation); bool Contains(const types::RCDataType &v, DTCollation); void Clear(); diff --git a/storage/tianmu/exporter/data_exporter.cpp b/storage/tianmu/exporter/data_exporter.cpp index 400cca961..5e35aabbb 100644 --- a/storage/tianmu/exporter/data_exporter.cpp +++ b/storage/tianmu/exporter/data_exporter.cpp @@ -41,8 +41,8 @@ void DataExporter::Init(std::shared_ptr buffer, std::vector } cur_attr = 0; - row = NULL; - row_ptr = NULL; + row = nullptr; + row_ptr = nullptr; nulls_indicator = 0; } diff --git a/storage/tianmu/exporter/data_exporter.h b/storage/tianmu/exporter/data_exporter.h index 23dd514be..f704c93f0 100644 --- a/storage/tianmu/exporter/data_exporter.h +++ b/storage/tianmu/exporter/data_exporter.h @@ -29,7 +29,7 @@ namespace exporter { class DataExporter { public: - DataExporter() : progressout(NULL), row(NULL), row_ptr(NULL), nulls_indicator(NULL) {} + DataExporter() : progressout(nullptr), row(nullptr), row_ptr(nullptr), nulls_indicator(nullptr) {} virtual void Init(std::shared_ptr buffer, std::vector source_deas, fields_t const &fields, std::vector &result_deas); virtual ~DataExporter(); diff --git a/storage/tianmu/handler/ha_rcengine.cpp b/storage/tianmu/handler/ha_rcengine.cpp index cc11d478b..2c91f0029 100644 --- a/storage/tianmu/handler/ha_rcengine.cpp +++ b/storage/tianmu/handler/ha_rcengine.cpp @@ -23,7 +23,7 @@ #include "vc/virtual_column.h" namespace Tianmu { -namespace dbhandler { +namespace handler { enum class TIANMUEngineReturnValues { LD_Successed = 100, LD_Failed = 101, LD_Continue = 102 }; @@ -72,8 +72,8 @@ bool TIANMU_SetStatementAllowed(THD *thd, LEX *lex) { return true; } -int TIANMU_HandleSelect(THD *thd, LEX *lex, Query_result *&result, ulong setup_tables_done_option, int &res, - int &optimize_after_tianmu, int &tianmu_free_join, int with_insert = false) { +int ha_my_tianmu_query(THD *thd, LEX *lex, Query_result *&result, ulong setup_tables_done_option, int &res, + int &optimize_after_tianmu, int &tianmu_free_join, int with_insert = false) { int ret = RCBASE_QUERY_ROUTE; try { // handle_select_ret is introduced here because in case of some exceptions @@ -100,8 +100,8 @@ Either restructure the query with supported syntax, or enable the MySQL core::Qu return ret; } -int TIANMU_LoadData(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, void *arg, char *errmsg, int len, - int &errcode) { +int ha_my_tianmu_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, void *arg, char *errmsg, int len, + int &errcode) { common::TianmuError tianmu_error; int ret = static_cast(TIANMUEngineReturnValues::LD_Failed); @@ -133,7 +133,7 @@ bool tianmu_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, void *arg) char tianmu_msg[256] = {0}; int tianmu_errcode = 0; switch (static_cast( - TIANMU_LoadData(thd, ex, table_list, arg, tianmu_msg, 256, tianmu_errcode))) { + ha_my_tianmu_load(thd, ex, table_list, arg, tianmu_msg, 256, tianmu_errcode))) { case TIANMUEngineReturnValues::LD_Continue: return true; case TIANMUEngineReturnValues::LD_Failed: @@ -148,5 +148,5 @@ bool tianmu_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, void *arg) return false; } -} // namespace dbhandler +} // namespace handler } // namespace Tianmu diff --git a/storage/tianmu/handler/ha_rcengine.h b/storage/tianmu/handler/ha_rcengine.h index 2c860df61..76d07e2a2 100644 --- a/storage/tianmu/handler/ha_rcengine.h +++ b/storage/tianmu/handler/ha_rcengine.h @@ -20,18 +20,18 @@ // mysql <--> tianmu interface functions namespace Tianmu { -namespace dbhandler { +namespace handler { void TIANMU_UpdateAndStoreColumnComment(TABLE *table, int field_id, Field *source_field, int source_field_id, CHARSET_INFO *cs); bool TIANMU_SetStatementAllowed(THD *thd, LEX *lex); -int TIANMU_HandleSelect(THD *thd, LEX *lex, Query_result *&result_output, ulong setup_tables_done_option, int &res, - int &optimize_after_tianmu, int &tianmu_free_join, int with_insert = false); +int ha_my_tianmu_query(THD *thd, LEX *lex, Query_result *&result_output, ulong setup_tables_done_option, int &res, + int &optimize_after_tianmu, int &tianmu_free_join, int with_insert = false); bool tianmu_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, void *arg); -} // namespace dbhandler +} // namespace handler } // namespace Tianmu #endif // TIANMU_HANDLER_HA_RCENGINE_H_ diff --git a/storage/tianmu/handler/tianmu_handler.cpp b/storage/tianmu/handler/tianmu_handler.cpp index b6c04bee2..951d7de3a 100644 --- a/storage/tianmu/handler/tianmu_handler.cpp +++ b/storage/tianmu/handler/tianmu_handler.cpp @@ -35,11 +35,11 @@ #define MYSQL_SERVER 1 namespace Tianmu { -namespace dbhandler { +namespace handler { -const Alter_inplace_info::HA_ALTER_FLAGS TianmuHandler::TIANMU_SUPPORTED_ALTER_ADD_DROP_ORDER = +const Alter_inplace_info::HA_ALTER_FLAGS ha_tianmu::TIANMU_SUPPORTED_ALTER_ADD_DROP_ORDER = Alter_inplace_info::ADD_COLUMN | Alter_inplace_info::DROP_COLUMN | Alter_inplace_info::ALTER_STORED_COLUMN_ORDER; -const Alter_inplace_info::HA_ALTER_FLAGS TianmuHandler::TIANMU_SUPPORTED_ALTER_COLUMN_NAME = +const Alter_inplace_info::HA_ALTER_FLAGS ha_tianmu::TIANMU_SUPPORTED_ALTER_COLUMN_NAME = Alter_inplace_info::ALTER_COLUMN_DEFAULT | Alter_inplace_info::ALTER_COLUMN_NAME; ///////////////////////////////////////////////////////////////////// // @@ -157,11 +157,11 @@ static core::Value GetValueFromField(Field *f) { return v; } -TianmuHandler::TianmuHandler(handlerton *hton, TABLE_SHARE *table_arg) : handler(hton, table_arg) { +ha_tianmu::ha_tianmu(handlerton *hton, TABLE_SHARE *table_arg) : handler(hton, table_arg) { ref_length = sizeof(uint64_t); } -const char **TianmuHandler::bas_ext() const { +const char **ha_tianmu::bas_ext() const { static const char *ha_rcbase_exts[] = {common::TIANMU_EXT, 0}; return ha_rcbase_exts; } @@ -215,7 +215,7 @@ static bool is_delay_insert(THD *thd) { Called from lock.cc by get_lock_data(). */ -THR_LOCK_DATA **TianmuHandler::store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type) { +THR_LOCK_DATA **ha_tianmu::store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type) { if (lock_type >= TL_WRITE_CONCURRENT_INSERT && lock_type <= TL_WRITE) { if (is_delay_insert(thd)) lock_type = TL_READ; @@ -240,7 +240,7 @@ THR_LOCK_DATA **TianmuHandler::store_lock(THD *thd, THR_LOCK_DATA **to, enum thr Called from lock.cc by lock_external() and unlock_external(). Also called from sql_table.cc by copy_data_between_tables(). */ -int TianmuHandler::external_lock(THD *thd, int lock_type) { +int ha_tianmu::external_lock(THD *thd, int lock_type) { DBUG_ENTER(__PRETTY_FUNCTION__); int ret = 1; @@ -417,7 +417,7 @@ inline bool has_dup_key(std::shared_ptr &indextab, TABLE *t Called from item_sum.cc, item_sum.cc, sql_acl.cc, sql_insert.cc, sql_insert.cc, sql_select.cc, sql_table.cc, sql_udf.cc, and sql_update.cc. */ -int TianmuHandler::write_row([[maybe_unused]] uchar *buf) { +int ha_tianmu::write_row([[maybe_unused]] uchar *buf) { int ret = 1; DBUG_ENTER(__PRETTY_FUNCTION__); try { @@ -470,7 +470,7 @@ int TianmuHandler::write_row([[maybe_unused]] uchar *buf) { Called from sql_select.cc, sql_acl.cc, sql_update.cc, and sql_insert.cc. */ -int TianmuHandler::update_row(const uchar *old_data, uchar *new_data) { +int ha_tianmu::update_row(const uchar *old_data, uchar *new_data) { DBUG_ENTER(__PRETTY_FUNCTION__); int ret = HA_ERR_INTERNAL_ERROR; auto org_bitmap = dbug_tmp_use_all_columns(table, table->write_set); @@ -539,7 +539,7 @@ int TianmuHandler::update_row(const uchar *old_data, uchar *new_data) { Called in sql_delete.cc, sql_insert.cc, and sql_select.cc. In sql_select it is used for removing duplicates while in insert it is used for REPLACE calls. */ -int TianmuHandler::delete_row([[maybe_unused]] const uchar *buf) { +int ha_tianmu::delete_row([[maybe_unused]] const uchar *buf) { DBUG_ENTER(__PRETTY_FUNCTION__); int ret = HA_ERR_INTERNAL_ERROR; auto org_bitmap = dbug_tmp_use_all_columns(table, table->write_set); @@ -578,7 +578,7 @@ int TianmuHandler::delete_row([[maybe_unused]] const uchar *buf) { Called from sql_select.cc by JOIN::rein*it. Called from sql_union.cc by st_select_lex_unit::exec(). */ -int TianmuHandler::delete_all_rows() { +int ha_tianmu::delete_all_rows() { DBUG_ENTER(__PRETTY_FUNCTION__); int ret = 1; try { @@ -592,7 +592,7 @@ int TianmuHandler::delete_all_rows() { DBUG_RETURN(ret); } -int TianmuHandler::rename_table(const char *from, const char *to) { +int ha_tianmu::rename_table(const char *from, const char *to) { try { ha_rcengine_->RenameTable(current_txn_, from, to, ha_thd()); return 0; @@ -606,7 +606,7 @@ int TianmuHandler::rename_table(const char *from, const char *to) { return 1; } -void TianmuHandler::update_create_info([[maybe_unused]] HA_CREATE_INFO *create_info) {} +void ha_tianmu::update_create_info([[maybe_unused]] HA_CREATE_INFO *create_info) {} /* ::info() is used to return information to the optimizer. @@ -653,7 +653,7 @@ void TianmuHandler::update_create_info([[maybe_unused]] HA_CREATE_INFO *create_i sql_update.cc */ -int TianmuHandler::info(uint flag) { +int ha_tianmu::info(uint flag) { DBUG_ENTER(__PRETTY_FUNCTION__); int ret = 1; try { @@ -710,7 +710,7 @@ my_bool tianmu_check_status([[maybe_unused]] void *param) { return 0; } Called from handler.cc by handler::ha_open(). The server opens all tables by calling ha_open() which then calls the handler specific open(). */ -int TianmuHandler::open(const char *name, [[maybe_unused]] int mode, [[maybe_unused]] uint test_if_locked) { +int ha_tianmu::open(const char *name, [[maybe_unused]] int mode, [[maybe_unused]] uint test_if_locked) { DBUG_ENTER(__PRETTY_FUNCTION__); table_name_ = name; @@ -748,7 +748,7 @@ int TianmuHandler::open(const char *name, [[maybe_unused]] int mode, [[maybe_unu DBUG_RETURN(ret); } -int TianmuHandler::free_share() { +int ha_tianmu::free_share() { share_.reset(); return 0; } @@ -763,12 +763,12 @@ int TianmuHandler::free_share() { myisam table. For sql_base.cc look at close_data_tables(). */ -int TianmuHandler::close() { +int ha_tianmu::close() { DBUG_ENTER(__PRETTY_FUNCTION__); DBUG_RETURN(free_share()); } -int TianmuHandler::fill_row_by_id([[maybe_unused]] uchar *buf, uint64_t rowid) { +int ha_tianmu::fill_row_by_id([[maybe_unused]] uchar *buf, uint64_t rowid) { DBUG_ENTER(__PRETTY_FUNCTION__); int rc = HA_ERR_KEY_NOT_FOUND; try { @@ -789,13 +789,13 @@ int TianmuHandler::fill_row_by_id([[maybe_unused]] uchar *buf, uint64_t rowid) { DBUG_RETURN(rc); } -int TianmuHandler::index_init(uint index, [[maybe_unused]] bool sorted) { +int ha_tianmu::index_init(uint index, [[maybe_unused]] bool sorted) { DBUG_ENTER(__PRETTY_FUNCTION__); active_index = index; DBUG_RETURN(0); } -int TianmuHandler::index_end() { +int ha_tianmu::index_end() { DBUG_ENTER(__PRETTY_FUNCTION__); active_index = MAX_KEY; DBUG_RETURN(0); @@ -806,9 +806,9 @@ int TianmuHandler::index_end() { row if available. If the key value is null, begin at the first key of the index. */ -int TianmuHandler::index_read([[maybe_unused]] uchar *buf, [[maybe_unused]] const uchar *key, - [[maybe_unused]] uint key_len __attribute__((unused)), - enum ha_rkey_function find_flag __attribute__((unused))) { +int ha_tianmu::index_read([[maybe_unused]] uchar *buf, [[maybe_unused]] const uchar *key, + [[maybe_unused]] uint key_len __attribute__((unused)), + enum ha_rkey_function find_flag __attribute__((unused))) { DBUG_ENTER(__PRETTY_FUNCTION__); int rc = HA_ERR_KEY_NOT_FOUND; try { @@ -853,7 +853,7 @@ int TianmuHandler::index_read([[maybe_unused]] uchar *buf, [[maybe_unused]] cons /* Used to read forward through the index. */ -int TianmuHandler::index_next([[maybe_unused]] uchar *buf) { +int ha_tianmu::index_next([[maybe_unused]] uchar *buf) { DBUG_ENTER(__PRETTY_FUNCTION__); int rc = HA_ERR_END_OF_FILE; try { @@ -876,7 +876,7 @@ int TianmuHandler::index_next([[maybe_unused]] uchar *buf) { /* Used to read backwards through the index. */ -int TianmuHandler::index_prev([[maybe_unused]] uchar *buf) { +int ha_tianmu::index_prev([[maybe_unused]] uchar *buf) { DBUG_ENTER(__PRETTY_FUNCTION__); int rc = HA_ERR_END_OF_FILE; try { @@ -902,7 +902,7 @@ int TianmuHandler::index_prev([[maybe_unused]] uchar *buf) { Called from opt_range.cc, opt_sum.cc, sql_handler.cc, and sql_select.cc. */ -int TianmuHandler::index_first([[maybe_unused]] uchar *buf) { +int ha_tianmu::index_first([[maybe_unused]] uchar *buf) { DBUG_ENTER(__PRETTY_FUNCTION__); int rc = HA_ERR_END_OF_FILE; try { @@ -931,7 +931,7 @@ int TianmuHandler::index_first([[maybe_unused]] uchar *buf) { Called from opt_range.cc, opt_sum.cc, sql_handler.cc, and sql_select.cc. */ -int TianmuHandler::index_last([[maybe_unused]] uchar *buf) { +int ha_tianmu::index_last([[maybe_unused]] uchar *buf) { DBUG_ENTER(__PRETTY_FUNCTION__); int rc = HA_ERR_END_OF_FILE; try { @@ -963,7 +963,7 @@ int TianmuHandler::index_last([[maybe_unused]] uchar *buf) { Called from filesort.cc, records.cc, sql_handler.cc, sql_select.cc, sql_table.cc, and sql_update.cc. */ -int TianmuHandler::rnd_init(bool scan) { +int ha_tianmu::rnd_init(bool scan) { DBUG_ENTER(__PRETTY_FUNCTION__); int ret = 1; @@ -1024,7 +1024,7 @@ int TianmuHandler::rnd_init(bool scan) { DBUG_RETURN(ret); } -int TianmuHandler::rnd_end() { +int ha_tianmu::rnd_end() { DBUG_ENTER(__PRETTY_FUNCTION__); reset(); DBUG_RETURN(0); @@ -1039,7 +1039,7 @@ int TianmuHandler::rnd_end() { Called from filesort.cc, records.cc, sql_handler.cc, sql_select.cc, sql_table.cc, and sql_update.cc. */ -int TianmuHandler::rnd_next(uchar *buf) { +int ha_tianmu::rnd_next(uchar *buf) { DBUG_ENTER(__PRETTY_FUNCTION__); int ret = HA_ERR_END_OF_FILE; @@ -1075,7 +1075,7 @@ int TianmuHandler::rnd_next(uchar *buf) { Called from filesort.cc, sql_select.cc, sql_delete.cc and sql_update.cc. */ -void TianmuHandler::position([[maybe_unused]] const uchar *record) { +void ha_tianmu::position([[maybe_unused]] const uchar *record) { DBUG_ENTER(__PRETTY_FUNCTION__); my_store_ptr(ref, ref_length, current_position_); @@ -1090,7 +1090,7 @@ void TianmuHandler::position([[maybe_unused]] const uchar *record) { or position you saved when position() was called. Called from filesort.cc records.cc sql_insert.cc sql_select.cc sql_update.cc. */ -int TianmuHandler::rnd_pos(uchar *buf, uchar *pos) { +int ha_tianmu::rnd_pos(uchar *buf, uchar *pos) { DBUG_ENTER(__PRETTY_FUNCTION__); int ret = HA_ERR_END_OF_FILE; @@ -1130,10 +1130,10 @@ int TianmuHandler::rnd_pos(uchar *buf, uchar *pos) { the storage engine. The myisam engine implements the most hints. ha_innodb.cc has the most exhaustive list of these hints. */ -int TianmuHandler::extra(enum ha_extra_function operation) { +int ha_tianmu::extra(enum ha_extra_function operation) { DBUG_ENTER(__PRETTY_FUNCTION__); /* This preemptive delete might cause problems here. - * Other place where it can be put is TianmuHandler::external_lock(). + * Other place where it can be put is ha_tianmu::external_lock(). */ if (operation == HA_EXTRA_NO_CACHE) { cq_.reset(); @@ -1142,7 +1142,7 @@ int TianmuHandler::extra(enum ha_extra_function operation) { DBUG_RETURN(0); } -int TianmuHandler::start_stmt(THD *thd, thr_lock_type lock_type) { +int ha_tianmu::start_stmt(THD *thd, thr_lock_type lock_type) { try { if (lock_type == TL_WRITE_CONCURRENT_INSERT || lock_type == TL_WRITE_DEFAULT || lock_type == TL_WRITE) { trans_register_ha(thd, false, rcbase_hton, nullptr); @@ -1167,9 +1167,8 @@ int TianmuHandler::start_stmt(THD *thd, thr_lock_type lock_type) { If current thread is in non-autocommit, we don't permit any mysql query caching. */ -my_bool TianmuHandler::register_query_cache_table(THD *thd, char *table_key, size_t key_length, - qc_engine_callback *call_back, - [[maybe_unused]] ulonglong *engine_data) { +my_bool ha_tianmu::register_query_cache_table(THD *thd, char *table_key, size_t key_length, + qc_engine_callback *call_back, [[maybe_unused]] ulonglong *engine_data) { *call_back = rcbase_query_caching_of_table_permitted; return rcbase_query_caching_of_table_permitted(thd, table_key, key_length, 0); } @@ -1188,7 +1187,7 @@ my_bool TianmuHandler::register_query_cache_table(THD *thd, char *table_key, siz during create if the table_flag HA_DROP_BEFORE_CREATE was specified for the storage engine. */ -int TianmuHandler::delete_table(const char *name) { +int ha_tianmu::delete_table(const char *name) { DBUG_ENTER(__PRETTY_FUNCTION__); int ret = 1; try { @@ -1212,8 +1211,8 @@ int TianmuHandler::delete_table(const char *name) { Called from opt_range.cc by check_quick_keys(). */ -ha_rows TianmuHandler::records_in_range([[maybe_unused]] uint inx, [[maybe_unused]] key_range *min_key, - [[maybe_unused]] key_range *max_key) { +ha_rows ha_tianmu::records_in_range([[maybe_unused]] uint inx, [[maybe_unused]] key_range *min_key, + [[maybe_unused]] key_range *max_key) { DBUG_ENTER(__PRETTY_FUNCTION__); DBUG_RETURN(stats.records); // low number to force index usage } @@ -1228,7 +1227,7 @@ ha_rows TianmuHandler::records_in_range([[maybe_unused]] uint inx, [[maybe_unuse Called from handle.cc by ha_create_table(). */ -int TianmuHandler::create(const char *name, TABLE *table_arg, [[maybe_unused]] HA_CREATE_INFO *create_info) { +int ha_tianmu::create(const char *name, TABLE *table_arg, [[maybe_unused]] HA_CREATE_INFO *create_info) { DBUG_ENTER(__PRETTY_FUNCTION__); try { // fix issue 487: bug for create table #mysql50#q.q should return failure and actually return success @@ -1258,7 +1257,7 @@ int TianmuHandler::create(const char *name, TABLE *table_arg, [[maybe_unused]] H DBUG_RETURN(1); } -int TianmuHandler::truncate() { +int ha_tianmu::truncate() { DBUG_ENTER(__PRETTY_FUNCTION__); int ret = 1; try { @@ -1272,14 +1271,14 @@ int TianmuHandler::truncate() { DBUG_RETURN(ret); } -uint TianmuHandler::max_supported_key_part_length(HA_CREATE_INFO *create_info) const { +uint ha_tianmu::max_supported_key_part_length(HA_CREATE_INFO *create_info) const { if (tianmu_sysvar_large_prefix) return (Tianmu::common::TIANMU_MAX_INDEX_COL_LEN_LARGE); else return (Tianmu::common::TIANMU_MAX_INDEX_COL_LEN_SMALL); } -int TianmuHandler::fill_row(uchar *buf) { +int ha_tianmu::fill_row(uchar *buf) { if (table_new_iter_ == table_new_iter_end_) return HA_ERR_END_OF_FILE; @@ -1310,7 +1309,7 @@ int TianmuHandler::fill_row(uchar *buf) { return 0; } -char *TianmuHandler::update_table_comment(const char *comment) { +char *ha_tianmu::update_table_comment(const char *comment) { char *ret = const_cast(comment); try { uint length = (uint)std::strlen(comment); @@ -1357,7 +1356,7 @@ char *TianmuHandler::update_table_comment(const char *comment) { return ret; } -bool TianmuHandler::explain_message(const Item *a_cond, String *buf) { +bool ha_tianmu::explain_message(const Item *a_cond, String *buf) { DBUG_ENTER(__PRETTY_FUNCTION__); if (current_txn_->Explain()) { cond_push(a_cond); @@ -1367,7 +1366,7 @@ bool TianmuHandler::explain_message(const Item *a_cond, String *buf) { DBUG_RETURN(TRUE); } -int TianmuHandler::set_cond_iter() { +int ha_tianmu::set_cond_iter() { int ret = 1; if (query_ && !result_ && table_ptr_->NumOfObj() != 0) { cq_->Result(tmp_table_); // it is ALWAYS -2 though.... @@ -1403,7 +1402,7 @@ int TianmuHandler::set_cond_iter() { return ret; } -const Item *TianmuHandler::cond_push(const Item *a_cond) { +const Item *ha_tianmu::cond_push(const Item *a_cond) { Item const *ret = a_cond; Item *cond = const_cast(a_cond); @@ -1474,7 +1473,7 @@ const Item *TianmuHandler::cond_push(const Item *a_cond) { return ret; } -int TianmuHandler::reset() { +int ha_tianmu::reset() { DBUG_ENTER(__PRETTY_FUNCTION__); int ret = 1; @@ -1499,8 +1498,8 @@ int TianmuHandler::reset() { DBUG_RETURN(ret); } -enum_alter_inplace_result TianmuHandler::check_if_supported_inplace_alter([[maybe_unused]] TABLE *altered_table, - Alter_inplace_info *ha_alter_info) { +enum_alter_inplace_result ha_tianmu::check_if_supported_inplace_alter([[maybe_unused]] TABLE *altered_table, + Alter_inplace_info *ha_alter_info) { DBUG_ENTER(__PRETTY_FUNCTION__); if ((ha_alter_info->handler_flags & ~TIANMU_SUPPORTED_ALTER_ADD_DROP_ORDER) && (ha_alter_info->handler_flags != TIANMU_SUPPORTED_ALTER_COLUMN_NAME)) { @@ -1519,7 +1518,7 @@ enum_alter_inplace_result TianmuHandler::check_if_supported_inplace_alter([[mayb DBUG_RETURN(HA_ALTER_INPLACE_EXCLUSIVE_LOCK); } -bool TianmuHandler::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { +bool ha_tianmu::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { try { if (!(ha_alter_info->handler_flags & ~TIANMU_SUPPORTED_ALTER_ADD_DROP_ORDER)) { std::vector v_old(table_share->field, table_share->field + table_share->fields); @@ -1540,8 +1539,8 @@ bool TianmuHandler::inplace_alter_table(TABLE *altered_table, Alter_inplace_info return true; } -bool TianmuHandler::commit_inplace_alter_table([[maybe_unused]] TABLE *altered_table, Alter_inplace_info *ha_alter_info, - bool commit) { +bool ha_tianmu::commit_inplace_alter_table([[maybe_unused]] TABLE *altered_table, Alter_inplace_info *ha_alter_info, + bool commit) { if (!commit) { TIANMU_LOG(LogCtl_Level::INFO, "Alter table failed : %s%s", table_name_.c_str(), " rollback"); return true; @@ -1592,8 +1591,8 @@ bool TianmuHandler::commit_inplace_alter_table([[maybe_unused]] TABLE *altered_t key: mysql format, may be union key, need changed to kvstore key format */ -void TianmuHandler::key_convert(const uchar *key, uint key_len, std::vector cols, - std::vector &keys) { +void ha_tianmu::key_convert(const uchar *key, uint key_len, std::vector cols, + std::vector &keys) { key_restore(table->record[0], (uchar *)key, &table->key_info[active_index], key_len); Field **field = table->field; @@ -1602,7 +1601,7 @@ void TianmuHandler::key_convert(const uchar *key, uint key_len, std::vectoris_null()) { - throw common::Exception("Priamry key part can not be NULL"); + throw common::Exception("Priamry key part can not be nullptr"); } if (f->flags & BLOB_FLAG) length = dynamic_cast(f)->get_length(); @@ -1739,5 +1738,5 @@ void TianmuHandler::key_convert(const uchar *key, uint key_len, std::vector> blob_buffers_; }; -} // namespace dbhandler +} // namespace handler } // namespace Tianmu #endif // TIANMU_HANDLER_TIANMU_HANDLER_H_ diff --git a/storage/tianmu/handler/tianmu_handler_com.cpp b/storage/tianmu/handler/tianmu_handler_com.cpp index 4e87b4e0b..c92d14b1c 100644 --- a/storage/tianmu/handler/tianmu_handler_com.cpp +++ b/storage/tianmu/handler/tianmu_handler_com.cpp @@ -31,8 +31,12 @@ struct st_mysql_sys_var { MYSQL_PLUGIN_VAR_HEADER; }; +handler *rcbase_create_handler(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root) { + return new (mem_root) Tianmu::handler::ha_tianmu(hton, table); +} + namespace Tianmu { -namespace dbhandler { +namespace handler { /* If frm_error() is called then we will use this to to find out what file @@ -62,10 +66,6 @@ static int rcbase_done_func([[maybe_unused]] void *p) { DBUG_RETURN(0); } -handler *rcbase_create_handler(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root) { - return new (mem_root) TianmuHandler(hton, table); -} - int rcbase_panic_func([[maybe_unused]] handlerton *hton, enum ha_panic_function flag) { if (tianmu_bootstrap) return 0; @@ -509,84 +509,94 @@ static struct st_mysql_show_var statusvars[] = { {0, 0, SHOW_UNDEF, SHOW_SCOPE_UNDEF}, }; -static MYSQL_SYSVAR_BOOL(refresh_sys_tianmu, tianmu_sysvar_refresh_sys_table, PLUGIN_VAR_BOOL, "-", NULL, +static MYSQL_SYSVAR_BOOL(refresh_sys_tianmu, tianmu_sysvar_refresh_sys_table, PLUGIN_VAR_BOOL, "-", nullptr, refresh_sys_table_func, TRUE); static MYSQL_THDVAR_STR(trigger_error, PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL, "-", tianmu_throw_error_func, - update_func_str, NULL); - -static MYSQL_SYSVAR_INT(ini_allowmysqlquerypath, tianmu_sysvar_allowmysqlquerypath, PLUGIN_VAR_READONLY, "-", NULL, - NULL, 0, 0, 1, 0); -static MYSQL_SYSVAR_STR(ini_cachefolder, tianmu_sysvar_cachefolder, PLUGIN_VAR_READONLY, "-", NULL, NULL, "cache"); -static MYSQL_SYSVAR_INT(ini_knlevel, tianmu_sysvar_knlevel, PLUGIN_VAR_READONLY, "-", NULL, NULL, 99, 0, 99, 0); -static MYSQL_SYSVAR_BOOL(ini_pushdown, tianmu_sysvar_pushdown, PLUGIN_VAR_READONLY, "-", NULL, NULL, TRUE); -static MYSQL_SYSVAR_INT(ini_servermainheapsize, tianmu_sysvar_servermainheapsize, PLUGIN_VAR_READONLY, "-", NULL, NULL, - 0, 0, 1000000, 0); + update_func_str, nullptr); + +static MYSQL_SYSVAR_INT(ini_allowmysqlquerypath, tianmu_sysvar_allowmysqlquerypath, PLUGIN_VAR_READONLY, "-", nullptr, + nullptr, 0, 0, 1, 0); +static MYSQL_SYSVAR_STR(ini_cachefolder, tianmu_sysvar_cachefolder, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, + "cache"); +static MYSQL_SYSVAR_INT(ini_knlevel, tianmu_sysvar_knlevel, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, 99, 0, 99, 0); +static MYSQL_SYSVAR_BOOL(ini_pushdown, tianmu_sysvar_pushdown, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, TRUE); +static MYSQL_SYSVAR_INT(ini_servermainheapsize, tianmu_sysvar_servermainheapsize, PLUGIN_VAR_READONLY, "-", nullptr, + nullptr, 0, 0, 1000000, 0); static MYSQL_SYSVAR_BOOL(ini_usemysqlimportexportdefaults, tianmu_sysvar_usemysqlimportexportdefaults, - PLUGIN_VAR_READONLY, "-", NULL, NULL, FALSE); -static MYSQL_SYSVAR_INT(ini_threadpoolsize, tianmu_sysvar_threadpoolsize, PLUGIN_VAR_READONLY, "-", NULL, NULL, 1, 0, - 1000000, 0); -static MYSQL_SYSVAR_INT(ini_cachesizethreshold, tianmu_sysvar_cachesizethreshold, PLUGIN_VAR_INT, "-", NULL, NULL, 4, 0, - 1024, 0); -static MYSQL_SYSVAR_INT(ini_cachereleasethreshold, tianmu_sysvar_cachereleasethreshold, PLUGIN_VAR_INT, "-", NULL, NULL, - 100, 0, 100000, 0); -static MYSQL_SYSVAR_BOOL(insert_delayed, tianmu_sysvar_insert_delayed, PLUGIN_VAR_READONLY, "-", NULL, NULL, TRUE); -static MYSQL_SYSVAR_INT(insert_cntthreshold, tianmu_sysvar_insert_cntthreshold, PLUGIN_VAR_READONLY, "-", NULL, NULL, 2, - 0, 1000, 0); -static MYSQL_SYSVAR_INT(insert_numthreshold, tianmu_sysvar_insert_numthreshold, PLUGIN_VAR_READONLY, "-", NULL, NULL, - 10000, 0, 100000, 0); -static MYSQL_SYSVAR_INT(insert_wait_ms, tianmu_sysvar_insert_wait_ms, PLUGIN_VAR_READONLY, "-", NULL, NULL, 100, 10, - 10000, 0); -static MYSQL_SYSVAR_INT(insert_wait_time, tianmu_sysvar_insert_wait_time, PLUGIN_VAR_INT, "-", NULL, NULL, 1000, 0, - 600000, 0); -static MYSQL_SYSVAR_INT(insert_max_buffered, tianmu_sysvar_insert_max_buffered, PLUGIN_VAR_READONLY, "-", NULL, NULL, - 65536, 0, 10000000, 0); -static MYSQL_SYSVAR_BOOL(compensation_start, tianmu_sysvar_compensation_start, PLUGIN_VAR_BOOL, "-", NULL, NULL, FALSE); -static MYSQL_SYSVAR_STR(hugefiledir, tianmu_sysvar_hugefiledir, PLUGIN_VAR_READONLY, "-", NULL, NULL, ""); -static MYSQL_SYSVAR_INT(cachinglevel, tianmu_sysvar_cachinglevel, PLUGIN_VAR_READONLY, "-", NULL, NULL, 1, 0, 512, 0); -static MYSQL_SYSVAR_STR(mm_policy, tianmu_sysvar_mm_policy, PLUGIN_VAR_READONLY, "-", NULL, NULL, ""); -static MYSQL_SYSVAR_INT(mm_hardlimit, tianmu_sysvar_mm_hardlimit, PLUGIN_VAR_READONLY, "-", NULL, NULL, 0, 0, 1, 0); -static MYSQL_SYSVAR_STR(mm_releasepolicy, tianmu_sysvar_mm_releasepolicy, PLUGIN_VAR_READONLY, "-", NULL, NULL, "2q"); -static MYSQL_SYSVAR_INT(mm_largetempratio, tianmu_sysvar_mm_largetempratio, PLUGIN_VAR_READONLY, "-", NULL, NULL, 0, 0, - 99, 0); + PLUGIN_VAR_READONLY, "-", nullptr, nullptr, FALSE); +static MYSQL_SYSVAR_INT(ini_threadpoolsize, tianmu_sysvar_threadpoolsize, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, 1, + 0, 1000000, 0); +static MYSQL_SYSVAR_INT(ini_cachesizethreshold, tianmu_sysvar_cachesizethreshold, PLUGIN_VAR_INT, "-", nullptr, nullptr, + 4, 0, 1024, 0); +static MYSQL_SYSVAR_INT(ini_cachereleasethreshold, tianmu_sysvar_cachereleasethreshold, PLUGIN_VAR_INT, "-", nullptr, + nullptr, 100, 0, 100000, 0); +static MYSQL_SYSVAR_BOOL(insert_delayed, tianmu_sysvar_insert_delayed, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, + TRUE); +static MYSQL_SYSVAR_INT(insert_cntthreshold, tianmu_sysvar_insert_cntthreshold, PLUGIN_VAR_READONLY, "-", nullptr, + nullptr, 2, 0, 1000, 0); +static MYSQL_SYSVAR_INT(insert_numthreshold, tianmu_sysvar_insert_numthreshold, PLUGIN_VAR_READONLY, "-", nullptr, + nullptr, 10000, 0, 100000, 0); +static MYSQL_SYSVAR_INT(insert_wait_ms, tianmu_sysvar_insert_wait_ms, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, 100, + 10, 10000, 0); +static MYSQL_SYSVAR_INT(insert_wait_time, tianmu_sysvar_insert_wait_time, PLUGIN_VAR_INT, "-", nullptr, nullptr, 1000, + 0, 600000, 0); +static MYSQL_SYSVAR_INT(insert_max_buffered, tianmu_sysvar_insert_max_buffered, PLUGIN_VAR_READONLY, "-", nullptr, + nullptr, 65536, 0, 10000000, 0); +static MYSQL_SYSVAR_BOOL(compensation_start, tianmu_sysvar_compensation_start, PLUGIN_VAR_BOOL, "-", nullptr, nullptr, + FALSE); +static MYSQL_SYSVAR_STR(hugefiledir, tianmu_sysvar_hugefiledir, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, ""); +static MYSQL_SYSVAR_INT(cachinglevel, tianmu_sysvar_cachinglevel, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, 1, 0, 512, + 0); +static MYSQL_SYSVAR_STR(mm_policy, tianmu_sysvar_mm_policy, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, ""); +static MYSQL_SYSVAR_INT(mm_hardlimit, tianmu_sysvar_mm_hardlimit, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, 0, 0, 1, + 0); +static MYSQL_SYSVAR_STR(mm_releasepolicy, tianmu_sysvar_mm_releasepolicy, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, + "2q"); +static MYSQL_SYSVAR_INT(mm_largetempratio, tianmu_sysvar_mm_largetempratio, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, + 0, 0, 99, 0); static MYSQL_SYSVAR_INT(mm_largetemppool_threshold, tianmu_sysvar_mm_large_threshold, PLUGIN_VAR_INT, - "size threshold in MB for using large temp thread pool", NULL, NULL, 16, 0, 10240, 0); -static MYSQL_SYSVAR_INT(sync_buffers, tianmu_sysvar_sync_buffers, PLUGIN_VAR_READONLY, "-", NULL, NULL, 0, 0, 1, 0); + "size threshold in MB for using large temp thread pool", nullptr, nullptr, 16, 0, 10240, 0); +static MYSQL_SYSVAR_INT(sync_buffers, tianmu_sysvar_sync_buffers, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, 0, 0, 1, + 0); -static MYSQL_SYSVAR_INT(query_threads, tianmu_sysvar_query_threads, PLUGIN_VAR_READONLY, "-", NULL, NULL, 0, 0, 100, 0); -static MYSQL_SYSVAR_INT(load_threads, tianmu_sysvar_load_threads, PLUGIN_VAR_READONLY, "-", NULL, NULL, 0, 0, 100, 0); -static MYSQL_SYSVAR_INT(bg_load_threads, tianmu_sysvar_bg_load_threads, PLUGIN_VAR_READONLY, "-", NULL, NULL, 0, 0, 100, +static MYSQL_SYSVAR_INT(query_threads, tianmu_sysvar_query_threads, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, 0, 0, + 100, 0); +static MYSQL_SYSVAR_INT(load_threads, tianmu_sysvar_load_threads, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, 0, 0, 100, 0); -static MYSQL_SYSVAR_INT(insert_buffer_size, tianmu_sysvar_insert_buffer_size, PLUGIN_VAR_READONLY, "-", NULL, NULL, 512, - 512, 10000, 0); +static MYSQL_SYSVAR_INT(bg_load_threads, tianmu_sysvar_bg_load_threads, PLUGIN_VAR_READONLY, "-", nullptr, nullptr, 0, + 0, 100, 0); +static MYSQL_SYSVAR_INT(insert_buffer_size, tianmu_sysvar_insert_buffer_size, PLUGIN_VAR_READONLY, "-", nullptr, + nullptr, 512, 512, 10000, 0); -static MYSQL_THDVAR_INT(session_debug_level, PLUGIN_VAR_INT, "session debug level", NULL, debug_update, 3, 0, 5, 0); -static MYSQL_THDVAR_INT(control_trace, PLUGIN_VAR_OPCMDARG, "ini controltrace", NULL, trace_update, 0, 0, 100, 0); +static MYSQL_THDVAR_INT(session_debug_level, PLUGIN_VAR_INT, "session debug level", nullptr, debug_update, 3, 0, 5, 0); +static MYSQL_THDVAR_INT(control_trace, PLUGIN_VAR_OPCMDARG, "ini controltrace", nullptr, trace_update, 0, 0, 100, 0); static MYSQL_SYSVAR_INT(global_debug_level, tianmu_sysvar_global_debug_level, PLUGIN_VAR_INT, "global debug level", - NULL, NULL, 4, 0, 5, 0); + nullptr, nullptr, 4, 0, 5, 0); static MYSQL_SYSVAR_INT(distinct_cache_size, tianmu_sysvar_distcache_size, PLUGIN_VAR_INT, - "Upper byte limit for GroupDistinctCache buffer", NULL, NULL, 64, 64, 256, 0); -static MYSQL_SYSVAR_BOOL(filterevaluation_speedup, tianmu_sysvar_filterevaluation_speedup, PLUGIN_VAR_BOOL, "-", NULL, - NULL, TRUE); -static MYSQL_SYSVAR_BOOL(groupby_speedup, tianmu_sysvar_groupby_speedup, PLUGIN_VAR_BOOL, "-", NULL, NULL, TRUE); -static MYSQL_SYSVAR_BOOL(orderby_speedup, tianmu_sysvar_orderby_speedup, PLUGIN_VAR_BOOL, "-", NULL, NULL, FALSE); + "Upper byte limit for GroupDistinctCache buffer", nullptr, nullptr, 64, 64, 256, 0); +static MYSQL_SYSVAR_BOOL(filterevaluation_speedup, tianmu_sysvar_filterevaluation_speedup, PLUGIN_VAR_BOOL, "-", + nullptr, nullptr, TRUE); +static MYSQL_SYSVAR_BOOL(groupby_speedup, tianmu_sysvar_groupby_speedup, PLUGIN_VAR_BOOL, "-", nullptr, nullptr, TRUE); +static MYSQL_SYSVAR_BOOL(orderby_speedup, tianmu_sysvar_orderby_speedup, PLUGIN_VAR_BOOL, "-", nullptr, nullptr, FALSE); static MYSQL_SYSVAR_INT(join_parallel, tianmu_sysvar_join_parallel, PLUGIN_VAR_INT, - "join matching parallel: 0-Disabled, 1-Auto, N-specify count", NULL, NULL, 1, 0, 1000, 0); + "join matching parallel: 0-Disabled, 1-Auto, N-specify count", nullptr, nullptr, 1, 0, 1000, 0); static MYSQL_SYSVAR_INT(join_splitrows, tianmu_sysvar_join_splitrows, PLUGIN_VAR_INT, - "join split rows:0-Disabled, 1-Auto, N-specify count", NULL, NULL, 0, 0, 1000, 0); -static MYSQL_SYSVAR_BOOL(minmax_speedup, tianmu_sysvar_minmax_speedup, PLUGIN_VAR_BOOL, "-", NULL, NULL, TRUE); + "join split rows:0-Disabled, 1-Auto, N-specify count", nullptr, nullptr, 0, 0, 1000, 0); +static MYSQL_SYSVAR_BOOL(minmax_speedup, tianmu_sysvar_minmax_speedup, PLUGIN_VAR_BOOL, "-", nullptr, nullptr, TRUE); static MYSQL_SYSVAR_UINT(index_cache_size, tianmu_sysvar_index_cache_size, PLUGIN_VAR_READONLY, - "Index cache size in MB", NULL, NULL, 0, 0, 65536, 0); -static MYSQL_SYSVAR_BOOL(index_search, tianmu_sysvar_index_search, PLUGIN_VAR_BOOL, "-", NULL, NULL, TRUE); -static MYSQL_SYSVAR_BOOL(enable_rowstore, tianmu_sysvar_enable_rowstore, PLUGIN_VAR_BOOL, "-", NULL, NULL, TRUE); -static MYSQL_SYSVAR_BOOL(parallel_filloutput, tianmu_sysvar_parallel_filloutput, PLUGIN_VAR_BOOL, "-", NULL, NULL, + "Index cache size in MB", nullptr, nullptr, 0, 0, 65536, 0); +static MYSQL_SYSVAR_BOOL(index_search, tianmu_sysvar_index_search, PLUGIN_VAR_BOOL, "-", nullptr, nullptr, TRUE); +static MYSQL_SYSVAR_BOOL(enable_rowstore, tianmu_sysvar_enable_rowstore, PLUGIN_VAR_BOOL, "-", nullptr, nullptr, TRUE); +static MYSQL_SYSVAR_BOOL(parallel_filloutput, tianmu_sysvar_parallel_filloutput, PLUGIN_VAR_BOOL, "-", nullptr, nullptr, TRUE); -static MYSQL_SYSVAR_BOOL(parallel_mapjoin, tianmu_sysvar_parallel_mapjoin, PLUGIN_VAR_BOOL, "-", NULL, NULL, FALSE); +static MYSQL_SYSVAR_BOOL(parallel_mapjoin, tianmu_sysvar_parallel_mapjoin, PLUGIN_VAR_BOOL, "-", nullptr, nullptr, + FALSE); static MYSQL_SYSVAR_INT(max_execution_time, tianmu_sysvar_max_execution_time, PLUGIN_VAR_INT, - "max query execution time in seconds", NULL, NULL, 0, 0, 10000, 0); + "max query execution time in seconds", nullptr, nullptr, 0, 0, 10000, 0); static MYSQL_SYSVAR_INT(ini_controlquerylog, tianmu_sysvar_controlquerylog, PLUGIN_VAR_INT, "global controlquerylog", - NULL, controlquerylog_update, 1, 0, 100, 0); + nullptr, controlquerylog_update, 1, 0, 100, 0); static const char *dist_policy_names[] = {"round-robin", "random", "space", 0}; static TYPELIB policy_typelib_t = {array_elements(dist_policy_names) - 1, "dist_policy_names", dist_policy_names, 0}; @@ -594,33 +604,35 @@ static MYSQL_SYSVAR_ENUM(data_distribution_policy, tianmu_sysvar_dist_policy, PL "Specifies the policy to distribute column data among multiple data " "directories." "Possible values are round-robin(default), random, and space", - NULL, NULL, 2, &policy_typelib_t); + nullptr, nullptr, 2, &policy_typelib_t); static MYSQL_SYSVAR_INT(disk_usage_threshold, tianmu_sysvar_disk_usage_threshold, PLUGIN_VAR_INT, - "Specifies the disk usage threshold for data diretories.", NULL, NULL, 85, 10, 99, 0); + "Specifies the disk usage threshold for data diretories.", nullptr, nullptr, 85, 10, 99, 0); static MYSQL_SYSVAR_UINT(lookup_max_size, tianmu_sysvar_lookup_max_size, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, - "Lookup dictionary max size", NULL, NULL, 100000, 1000, 1000000, 0); + "Lookup dictionary max size", nullptr, nullptr, 100000, 1000, 1000000, 0); -static MYSQL_SYSVAR_BOOL(qps_log, tianmu_sysvar_qps_log, PLUGIN_VAR_BOOL, "-", NULL, NULL, TRUE); +static MYSQL_SYSVAR_BOOL(qps_log, tianmu_sysvar_qps_log, PLUGIN_VAR_BOOL, "-", nullptr, nullptr, TRUE); -static MYSQL_SYSVAR_BOOL(force_hashjoin, tianmu_sysvar_force_hashjoin, PLUGIN_VAR_BOOL, "-", NULL, NULL, FALSE); +static MYSQL_SYSVAR_BOOL(force_hashjoin, tianmu_sysvar_force_hashjoin, PLUGIN_VAR_BOOL, "-", nullptr, nullptr, FALSE); static MYSQL_SYSVAR_INT(start_async, tianmu_sysvar_start_async, PLUGIN_VAR_INT, - "Enable async, specifies async threads x/100 * cpus", NULL, start_async_update, 0, 0, 100, 0); + "Enable async, specifies async threads x/100 * cpus", nullptr, start_async_update, 0, 0, 100, + 0); static MYSQL_SYSVAR_STR(async_join, tianmu_sysvar_async_join, PLUGIN_VAR_STR, - "Set async join params: packStep;traverseCount;matchCount", NULL, async_join_update, "1;0;0;0"); -static MYSQL_SYSVAR_BOOL(join_disable_switch_side, tianmu_sysvar_join_disable_switch_side, PLUGIN_VAR_BOOL, "-", NULL, - NULL, FALSE); + "Set async join params: packStep;traverseCount;matchCount", nullptr, async_join_update, + "1;0;0;0"); +static MYSQL_SYSVAR_BOOL(join_disable_switch_side, tianmu_sysvar_join_disable_switch_side, PLUGIN_VAR_BOOL, "-", + nullptr, nullptr, FALSE); static MYSQL_SYSVAR_BOOL(enable_histogram_cmap_bloom, tianmu_sysvar_enable_histogram_cmap_bloom, PLUGIN_VAR_BOOL, "-", - NULL, NULL, FALSE); + nullptr, nullptr, FALSE); static MYSQL_SYSVAR_BOOL(large_prefix, tianmu_sysvar_large_prefix, PLUGIN_VAR_RQCMDARG, "Support large index prefix length of 3072 bytes. If off, the maximum " "index prefix length is 767.", - NULL, NULL, TRUE); + nullptr, nullptr, TRUE); static MYSQL_SYSVAR_UINT(result_sender_rows, tianmu_sysvar_result_sender_rows, PLUGIN_VAR_UNSIGNED, "The number of rows to load at a time when processing " "queries like select xxx from yyya", - NULL, NULL, 65536, 1024, 131072, 0); + nullptr, nullptr, 65536, 1024, 131072, 0); void debug_update(MYSQL_THD thd, [[maybe_unused]] struct st_mysql_sys_var *var, void *var_ptr, const void *save) { if (ha_rcengine_) { @@ -740,22 +752,22 @@ static struct st_mysql_sys_var *tianmu_showvars[] = {MYSQL_SYSVAR(bg_load_thread MYSQL_SYSVAR(force_hashjoin), MYSQL_SYSVAR(start_async), MYSQL_SYSVAR(result_sender_rows), - NULL}; -} // namespace dbhandler + nullptr}; +} // namespace handler } // namespace Tianmu mysql_declare_plugin(tianmu){ MYSQL_STORAGE_ENGINE_PLUGIN, - &Tianmu::dbhandler::tianmu_storage_engine, + &Tianmu::handler::tianmu_storage_engine, "TIANMU", "StoneAtom Group Holding Limited", "Tianmu storage engine", PLUGIN_LICENSE_GPL, - Tianmu::dbhandler::rcbase_init_func, /* Plugin Init */ - Tianmu::dbhandler::rcbase_done_func, /* Plugin Deinit */ + Tianmu::handler::rcbase_init_func, /* Plugin Init */ + Tianmu::handler::rcbase_done_func, /* Plugin Deinit */ 0x0001 /* 0.1 */, - Tianmu::dbhandler::statusvars, /* status variables */ - Tianmu::dbhandler::tianmu_showvars, /* system variables */ - NULL, /* config options */ - 0 /* flags for plugin */ + Tianmu::handler::statusvars, /* status variables */ + Tianmu::handler::tianmu_showvars, /* system variables */ + nullptr, /* config options */ + 0 /* flags for plugin */ } mysql_declare_plugin_end; diff --git a/storage/tianmu/index/rdb_meta_manager.cpp b/storage/tianmu/index/rdb_meta_manager.cpp index b8a806def..aaa3e7b74 100644 --- a/storage/tianmu/index/rdb_meta_manager.cpp +++ b/storage/tianmu/index/rdb_meta_manager.cpp @@ -47,7 +47,7 @@ RdbKey::RdbKey(uint pos, uint keyno, rocksdb::ColumnFamilyHandle *cf_handle, uin key_name_(_name), cols_(cols) { be_store_index(index_pos_be_, index_pos_); - ASSERT(cf_handle_ != nullptr, "cf_handle_ is NULL"); + ASSERT(cf_handle_ != nullptr, "cf_handle_ is nullptr"); } RdbKey::RdbKey(const RdbKey &k) @@ -768,7 +768,7 @@ void DICTManager::save_index_info(rocksdb::WriteBatch *batch, uint16_t index_ver void DICTManager::add_cf_flags(rocksdb::WriteBatch *const batch, const uint32_t &cf_id, const uint32_t &cf_flags) const { - ASSERT(batch != nullptr, "batch is NULL"); + ASSERT(batch != nullptr, "batch is nullptr"); StringWriter key; key.write_uint32(static_cast(MetaType::CF_INFO)); key.write_uint32(cf_id); @@ -976,7 +976,7 @@ uint SeqGenerator::get_and_update_next_number(DICTManager *const dict) { const std::unique_ptr wb = dict->begin(); rocksdb::WriteBatch *const batch = wb.get(); - ASSERT(batch != nullptr, "batch is NULL"); + ASSERT(batch != nullptr, "batch is nullptr"); dict->update_max_index_id(batch, res); dict->commit(batch); return res; @@ -1037,7 +1037,7 @@ std::vector CFManager::get_all_cf(void) { std::scoped_lock guard(cf_mutex_); for (auto it : cf_id_map_) { - ASSERT(it.second != nullptr, "it.second is NULL"); + ASSERT(it.second != nullptr, "it.second is nullptr"); list.push_back(it.second); } return list; diff --git a/storage/tianmu/index/rdb_utils.h b/storage/tianmu/index/rdb_utils.h index 0eba096e4..0e48f2c15 100644 --- a/storage/tianmu/index/rdb_utils.h +++ b/storage/tianmu/index/rdb_utils.h @@ -48,19 +48,19 @@ struct ColAttr { }; inline void be_store_uint64(uchar *const dst_netbuf, const uint64_t &n) { - ASSERT(dst_netbuf != nullptr, "dst_netbuf is NULL"); + ASSERT(dst_netbuf != nullptr, "dst_netbuf is nullptr"); uint64_t net_val = htobe64(n); memcpy(dst_netbuf, &net_val, sizeof(net_val)); } inline void be_store_uint32(uchar *const dst_netbuf, const uint32_t &n) { - ASSERT(dst_netbuf != nullptr, "dst_netbuf is NULL"); + ASSERT(dst_netbuf != nullptr, "dst_netbuf is nullptr"); uint32_t net_val = htobe32(n); memcpy(dst_netbuf, &net_val, sizeof(net_val)); } inline void be_store_uint16(uchar *const dst_netbuf, const uint16_t &n) { - ASSERT(dst_netbuf != nullptr, "dst_netbuf is NULL"); + ASSERT(dst_netbuf != nullptr, "dst_netbuf is nullptr"); uint16_t net_val = htobe16(n); memcpy(dst_netbuf, &net_val, sizeof(net_val)); } @@ -70,7 +70,7 @@ inline void be_store_byte(uchar *const dst_netbuf, const uchar &c) { *dst_netbuf inline void be_store_index(uchar *const dst_netbuf, const uint32_t &number) { be_store_uint32(dst_netbuf, number); } inline uint64_t be_to_uint64(const uchar *const netbuf) { - ASSERT(netbuf != nullptr, "netbuf is NULL"); + ASSERT(netbuf != nullptr, "netbuf is nullptr"); uint64_t net_val; memcpy(&net_val, netbuf, sizeof(net_val)); @@ -84,7 +84,7 @@ inline uint32_t be_to_uint32(const uchar *const netbuf) { } inline uint16_t be_to_uint16(const uchar *const netbuf) { - ASSERT(netbuf != nullptr, "netbuf is NULL"); + ASSERT(netbuf != nullptr, "netbuf is nullptr"); uint16_t net_val; memcpy(&net_val, netbuf, sizeof(net_val)); @@ -92,12 +92,12 @@ inline uint16_t be_to_uint16(const uchar *const netbuf) { } inline uchar be_to_byte(const uchar *const netbuf) { - ASSERT(netbuf != nullptr, "netbuf is NULL"); + ASSERT(netbuf != nullptr, "netbuf is nullptr"); return (uchar)netbuf[0]; } inline uint32_t be_read_uint32(const uchar **netbuf_ptr) { - ASSERT(netbuf_ptr != nullptr, "netbuf_ptr is NULL"); + ASSERT(netbuf_ptr != nullptr, "netbuf_ptr is nullptr"); const uint32_t host_val = be_to_uint32(*netbuf_ptr); *netbuf_ptr += sizeof(host_val); @@ -112,8 +112,8 @@ inline uint16_t be_read_uint16(const uchar **netbuf_ptr) { } inline void be_read_gl_index(const uchar **netbuf_ptr, GlobalId *const gl_index_id) { - ASSERT(gl_index_id != nullptr, "gl_index_id is NULL"); - ASSERT(netbuf_ptr != nullptr, "netbuf_ptr is NULL"); + ASSERT(gl_index_id != nullptr, "gl_index_id is nullptr"); + ASSERT(netbuf_ptr != nullptr, "netbuf_ptr is nullptr"); gl_index_id->cf_id = be_read_uint32(netbuf_ptr); gl_index_id->index_id = be_read_uint32(netbuf_ptr); @@ -221,7 +221,7 @@ class StringWriter { } void write(const uchar *const new_data, const size_t &len) { - ASSERT(new_data != nullptr, "new_data is NULL"); + ASSERT(new_data != nullptr, "new_data is nullptr"); m_data.insert(m_data.end(), new_data, new_data + len); } diff --git a/storage/tianmu/loader/parsing_strategy.cpp b/storage/tianmu/loader/parsing_strategy.cpp index 4c29c2fb4..a1c1cd81f 100644 --- a/storage/tianmu/loader/parsing_strategy.cpp +++ b/storage/tianmu/loader/parsing_strategy.cpp @@ -376,7 +376,7 @@ void ParsingStrategy::GetValue(const char *value_ptr, size_t value_size, ushort isnull = true; break; case 4: - if (!is_enclosed && strncasecmp(value_ptr, "NULL", 4) == 0) + if (!is_enclosed && strncasecmp(value_ptr, "nullptr", 4) == 0) isnull = true; break; default: diff --git a/storage/tianmu/mm/huge_heap_policy.cpp b/storage/tianmu/mm/huge_heap_policy.cpp index 2c406df2f..1b72e05d2 100644 --- a/storage/tianmu/mm/huge_heap_policy.cpp +++ b/storage/tianmu/mm/huge_heap_policy.cpp @@ -28,7 +28,7 @@ namespace Tianmu { namespace mm { HugeHeap::HugeHeap(std::string hugedir, size_t size) : TCMHeap(0) { - heap_frame_ = NULL; + heap_frame_ = nullptr; // convert size from MB to B and make it a multiple of 2MB size_ = 1_MB * (size & ~0x1); heap_status_ = HEAP_STATUS::HEAP_ERROR; @@ -50,7 +50,7 @@ HugeHeap::HugeHeap(std::string hugedir, size_t size) : TCMHeap(0) { // MAP_SHARED to have mmap fail immediately if not enough pages // MAP_PRIVATE does copy on write // MAP_POPULATE to create page table entries and avoid future surprises - heap_frame_ = (char *)mmap(NULL, size_, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, fd_, 0); + heap_frame_ = (char *)mmap(nullptr, size_, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, fd_, 0); if (heap_frame_ == MAP_FAILED) { unlink(huge_filename_); heap_status_ = HEAP_STATUS::HEAP_OUT_OF_MEMORY; @@ -69,7 +69,7 @@ HugeHeap::HugeHeap(std::string hugedir, size_t size) : TCMHeap(0) { } HugeHeap::~HugeHeap() { - if (heap_frame_ != NULL) { + if (heap_frame_ != nullptr) { munmap(heap_frame_, size_); } if (fd_ > 0) { diff --git a/storage/tianmu/mm/initializer.cpp b/storage/tianmu/mm/initializer.cpp index b2ecce934..0cbc27f21 100644 --- a/storage/tianmu/mm/initializer.cpp +++ b/storage/tianmu/mm/initializer.cpp @@ -20,7 +20,7 @@ namespace Tianmu { namespace mm { -MemoryManagerInitializer *MemoryManagerInitializer::instance = NULL; +MemoryManagerInitializer *MemoryManagerInitializer::instance = nullptr; bool MemoryManagerInitializer::m_report_leaks = false; diff --git a/storage/tianmu/mm/initializer.h b/storage/tianmu/mm/initializer.h index 674eadff5..e7fe5222d 100644 --- a/storage/tianmu/mm/initializer.h +++ b/storage/tianmu/mm/initializer.h @@ -29,7 +29,7 @@ class MemoryManagerInitializer : public TraceableObject { public: static MemoryManagerInitializer *Instance(size_t comp_size, size_t uncomp_size, std::string hugedir = "", int hugesize = 0) { - if (instance == NULL) { + if (instance == nullptr) { try { instance = new MemoryManagerInitializer(comp_size, uncomp_size, hugedir, hugesize); } catch (common::OutOfMemoryException &) { @@ -49,7 +49,7 @@ class MemoryManagerInitializer : public TraceableObject { private: MemoryManagerInitializer(size_t comp_size, size_t uncomp_size, std::string hugedir = "", int hugesize = 0) - : TraceableObject(comp_size, uncomp_size, hugedir, NULL, hugesize) {} + : TraceableObject(comp_size, uncomp_size, hugedir, nullptr, hugesize) {} virtual ~MemoryManagerInitializer() { deinitialize(m_report_leaks); } static MemoryManagerInitializer *instance; static bool m_report_leaks; diff --git a/storage/tianmu/mm/memory_block.h b/storage/tianmu/mm/memory_block.h index 1920321cf..b62ce9b89 100644 --- a/storage/tianmu/mm/memory_block.h +++ b/storage/tianmu/mm/memory_block.h @@ -26,7 +26,7 @@ enum class BLOCK_TYPE : char { BLOCK_COMPRESSED, BLOCK_UNCOMPRESSED, BLOCK_TEMPORARY, - BLOCK_FIXED // Used in rc_realloc when pointer != NULL + BLOCK_FIXED // Used in rc_realloc when pointer != nullptr }; } // namespace mm diff --git a/storage/tianmu/mm/memory_handling_policy.cpp b/storage/tianmu/mm/memory_handling_policy.cpp index a89797bae..95832e209 100644 --- a/storage/tianmu/mm/memory_handling_policy.cpp +++ b/storage/tianmu/mm/memory_handling_policy.cpp @@ -99,25 +99,25 @@ MemoryHandling::MemoryHandling([[maybe_unused]] size_t comp_heap_size, size_t un m_main_heap = new SystemHeap(uncomp_heap_size); m_huge_heap = new HugeHeap(hugedir, hugesize); m_system = new SystemHeap(0); - m_large_temp = NULL; + m_large_temp = nullptr; } else if (hpolicy == "mysql") { m_main_heap = new MySQLHeap(uncomp_heap_size); m_huge_heap = new HugeHeap(hugedir, hugesize); m_system = new SystemHeap(0); - m_large_temp = NULL; + m_large_temp = nullptr; } else { // default or "" #ifdef USE_NUMA m_main_heap = new NUMAHeap(adj_mh_size); if (lt_size != 0) m_large_temp = new NUMAHeap(lt_size); else - m_large_temp = NULL; + m_large_temp = nullptr; #else m_main_heap = new TCMHeap(adj_mh_size); if (lt_size != 0) m_large_temp = new TCMHeap(lt_size); else - m_large_temp = NULL; + m_large_temp = nullptr; #endif m_huge_heap = new HugeHeap(hugedir, hugesize); m_system = new SystemHeap(0); @@ -178,7 +178,7 @@ void *MemoryHandling::alloc(size_t size, BLOCK_TYPE type, TraceableObject *owner // 2. it is hardcoded off // if (m_huge_heap->getHeapStatus() == HEAP_STATUS::HEAP_SUCCESS) // heap = m_huge_heap; - if ((m_large_temp != NULL) && (size >= (tianmu_sysvar_mm_large_threshold * 1_MB))) + if ((m_large_temp != nullptr) && (size >= (tianmu_sysvar_mm_large_threshold * 1_MB))) switch (owner->TraceableType()) { case TO_TYPE::TO_SORTER: case TO_TYPE::TO_CACHEDBUFFER: @@ -198,19 +198,19 @@ void *MemoryHandling::alloc(size_t size, BLOCK_TYPE type, TraceableObject *owner }; void *res = heap->alloc(size); - if (res == NULL) { + if (res == nullptr) { heap = m_main_heap; - ReleaseMemory(size, NULL); + ReleaseMemory(size, nullptr); res = heap->alloc(size); - if (res == NULL) { + if (res == nullptr) { if (m_hard_limit) { if (nothrow) return res; throw common::OutOfMemoryException(size); } res = m_system->alloc(size); - if (res == NULL) { + if (res == nullptr) { if (nothrow) return res; rc_control_.lock(current_txn_->GetThreadID()) @@ -234,7 +234,7 @@ void *MemoryHandling::alloc(size_t size, BLOCK_TYPE type, TraceableObject *owner size_t bsize = heap->getBlockSize(res); m_alloc_blocks++; m_alloc_size += bsize; - if (owner != NULL) + if (owner != nullptr) if (owner->TraceableType() == TO_TYPE::TO_PACK) { m_alloc_pack_size += bsize; m_alloc_pack++; @@ -257,7 +257,7 @@ size_t MemoryHandling::rc_msize(void *mh, TraceableObject *owner) { MEASURE_FET("MemoryHandling::rc_msize"); std::scoped_lock guard(m_mutex); - // if( owner == NULL || mh == 0 ) + // if( owner == nullptr || mh == 0 ) if (mh == 0) return 0; auto it = m_objs.find(owner); @@ -273,7 +273,7 @@ void MemoryHandling::dealloc(void *mh, TraceableObject *owner) { std::scoped_lock guard(m_mutex); - if (mh == NULL) + if (mh == nullptr) return; auto it = m_objs.find(owner); @@ -287,7 +287,7 @@ void MemoryHandling::dealloc(void *mh, TraceableObject *owner) { #endif m_free_blocks++; m_free_size += bsize; - if (owner != NULL) + if (owner != nullptr) if (owner->TraceableType() == TO_TYPE::TO_PACK) { m_free_pack_size += bsize; m_free_pack++; @@ -331,7 +331,7 @@ bool MemoryHandling::ReleaseMemory(size_t size, [[maybe_unused]] TraceableObject std::vector dps; for (auto &it : m_objs) { - if (it.first == NULL) + if (it.first == nullptr) continue; if (it.first->IsLocked() || it.first->TraceableType() != TO_TYPE::TO_PACK) continue; @@ -357,7 +357,7 @@ bool MemoryHandling::ReleaseMemory(size_t size, [[maybe_unused]] TraceableObject std::vector dps; auto it = m_objs.begin(); while (it != m_objs.end()) { - if ( (*it).first != NULL ) + if ( (*it).first != nullptr ) if ((*it).first->TraceableType() == TO_TYPE::TO_PACK && (*it).first->IsLocked() == false) { if ( (*it).first->IsPrefetchUnused() ) (*it).first->clearPrefetchUnused(); @@ -381,7 +381,7 @@ void *MemoryHandling::rc_realloc(void *mh, size_t size, TraceableObject *owner, std::scoped_lock guard(m_mutex); void *res = alloc(size, type, owner); - if (mh == NULL) + if (mh == nullptr) return res; size_t oldsize = rc_msize(mh, owner); @@ -525,7 +525,7 @@ void MemoryHandling::HeapHistogram(std::ostream &out) { if (hist != used_blocks.end()) { hist->second->accumulate(hp->getBlockSize(ptr)); - if (block_type != NULL) + if (block_type != nullptr) block_type->accumulate(hp->getBlockSize(ptr)); } } diff --git a/storage/tianmu/mm/memory_handling_policy.h b/storage/tianmu/mm/memory_handling_policy.h index 3e033f8b1..ded02bc14 100644 --- a/storage/tianmu/mm/memory_handling_policy.h +++ b/storage/tianmu/mm/memory_handling_policy.h @@ -59,7 +59,7 @@ class MemoryHandling { void DumpObjs(std::ostream &out); public: - MemoryHandling(size_t comp_heap_size, size_t uncomp_heap_size, std::string hugedir = "", core::DataCache *d = NULL, + MemoryHandling(size_t comp_heap_size, size_t uncomp_heap_size, std::string hugedir = "", core::DataCache *d = nullptr, size_t hugesize = 0); virtual ~MemoryHandling(); diff --git a/storage/tianmu/mm/numa_heap_policy.cpp b/storage/tianmu/mm/numa_heap_policy.cpp index f66a9819b..587c65034 100644 --- a/storage/tianmu/mm/numa_heap_policy.cpp +++ b/storage/tianmu/mm/numa_heap_policy.cpp @@ -76,7 +76,7 @@ void *NUMAHeap::alloc(size_t size) { ASSERT(h != m_nodeHeaps.end()); result = h->second->alloc(size); - if (result != NULL) { + if (result != nullptr) { m_blockHeap.insert(std::make_pair(result, h->second)); return result; } else { @@ -84,13 +84,13 @@ void *NUMAHeap::alloc(size_t size) { h = m_nodeHeaps.begin(); while (h != m_nodeHeaps.end()) { result = h->second->alloc(size); - if (result != NULL) { + if (result != nullptr) { m_blockHeap.insert(std::make_pair(result, h->second)); return result; } h++; } - return NULL; + return nullptr; } } diff --git a/storage/tianmu/mm/release_fifo.cpp b/storage/tianmu/mm/release_fifo.cpp index 3f713c174..09f951269 100644 --- a/storage/tianmu/mm/release_fifo.cpp +++ b/storage/tianmu/mm/release_fifo.cpp @@ -28,7 +28,7 @@ void ReleaseFIFO::Access(TraceableObject *o) { tracker.touch(o); } void ReleaseFIFO::Remove(TraceableObject *o) { tracker.remove(o); } void ReleaseFIFO::Release(unsigned num) { - TraceableObject *o = NULL; + TraceableObject *o = nullptr; for (uint i = 0; i < num; i++) { o = tracker.removeTail(); if (o->IsLocked()) { @@ -40,7 +40,7 @@ void ReleaseFIFO::Release(unsigned num) { } void ReleaseFIFO::ReleaseFull() { - TraceableObject *o = NULL; + TraceableObject *o = nullptr; int num = tracker.size(); for (int i = 0; i < num; i++) { o = tracker.removeTail(); diff --git a/storage/tianmu/mm/release_lru.cpp b/storage/tianmu/mm/release_lru.cpp index d4bc44ffd..b6475bd01 100644 --- a/storage/tianmu/mm/release_lru.cpp +++ b/storage/tianmu/mm/release_lru.cpp @@ -28,7 +28,7 @@ void ReleaseLRU::Access(TraceableObject *o) { tracker.touch(o); } void ReleaseLRU::Remove(TraceableObject *o) { tracker.remove(o); } void ReleaseLRU::Release(unsigned num) { - TraceableObject *o = NULL; + TraceableObject *o = nullptr; for (uint i = 0; i < num; i++) { o = tracker.removeMax(); if (o->IsLocked()) { @@ -40,7 +40,7 @@ void ReleaseLRU::Release(unsigned num) { } void ReleaseLRU::ReleaseFull() { - TraceableObject *o = NULL; + TraceableObject *o = nullptr; int num = tracker.size(); for (int i = 0; i < num; i++) { o = tracker.removeMax(); diff --git a/storage/tianmu/mm/release_tracker.cpp b/storage/tianmu/mm/release_tracker.cpp index 08c6d5450..5d9c7ce9a 100644 --- a/storage/tianmu/mm/release_tracker.cpp +++ b/storage/tianmu/mm/release_tracker.cpp @@ -24,74 +24,74 @@ namespace Tianmu { namespace mm { void FIFOTracker::insert(TraceableObject *o) { - ASSERT(GetRelTracker(o) == NULL, "Object has multiple trackers"); - ASSERT(GetRelPrev(o) == NULL, "Object was not removed or initialized properly"); - ASSERT(GetRelNext(o) == NULL, "Object was not removed or initialized properly"); + ASSERT(GetRelTracker(o) == nullptr, "Object has multiple trackers"); + ASSERT(GetRelPrev(o) == nullptr, "Object was not removed or initialized properly"); + ASSERT(GetRelNext(o) == nullptr, "Object was not removed or initialized properly"); SetRelTracker(o, this); - SetRelPrev(o, NULL); + SetRelPrev(o, nullptr); SetRelNext(o, head); - if (head != NULL) + if (head != nullptr) SetRelPrev(head, o); head = o; - if (tail == NULL) + if (tail == nullptr) tail = head; _size++; } TraceableObject *FIFOTracker::removeTail() { TraceableObject *res = tail; - if (res == NULL) - return NULL; + if (res == nullptr) + return nullptr; tail = GetRelPrev(tail); - if (tail != NULL) - SetRelNext(tail, NULL); + if (tail != nullptr) + SetRelNext(tail, nullptr); else { ASSERT(_size == 1, "FIFOTracker size error"); - head = NULL; + head = nullptr; } - SetRelTracker(res, NULL); - SetRelPrev(res, NULL); - SetRelNext(res, NULL); + SetRelTracker(res, nullptr); + SetRelPrev(res, nullptr); + SetRelNext(res, nullptr); _size--; return res; } TraceableObject *FIFOTracker::removeHead() { TraceableObject *res = head; - if (res == NULL) - return NULL; + if (res == nullptr) + return nullptr; head = GetRelNext(head); - if (head != NULL) - SetRelPrev(head, NULL); + if (head != nullptr) + SetRelPrev(head, nullptr); else { ASSERT(_size == 1, "FIFOTracker size error"); - tail = NULL; + tail = nullptr; } - SetRelTracker(res, NULL); - SetRelPrev(res, NULL); - SetRelNext(res, NULL); + SetRelTracker(res, nullptr); + SetRelPrev(res, nullptr); + SetRelNext(res, nullptr); _size--; return res; } void FIFOTracker::remove(TraceableObject *o) { ASSERT(GetRelTracker(o) == this, "Removing object from wrong tracker"); - SetRelTracker(o, NULL); + SetRelTracker(o, nullptr); if ((o == head) && (o == tail)) { - head = tail = NULL; + head = tail = nullptr; } else if (o == head) { head = GetRelNext(o); - SetRelPrev(head, NULL); + SetRelPrev(head, nullptr); } else if (o == tail) { tail = GetRelPrev(o); - SetRelNext(tail, NULL); + SetRelNext(tail, nullptr); } else { TraceableObject *p = GetRelPrev(o), *n = GetRelNext(o); SetRelNext(p, n); SetRelPrev(n, p); } - SetRelNext(o, NULL); - SetRelPrev(o, NULL); + SetRelNext(o, nullptr); + SetRelPrev(o, nullptr); _size--; } diff --git a/storage/tianmu/mm/sys_heap_policy.cpp b/storage/tianmu/mm/sys_heap_policy.cpp index b08a2c252..b407d08c3 100644 --- a/storage/tianmu/mm/sys_heap_policy.cpp +++ b/storage/tianmu/mm/sys_heap_policy.cpp @@ -27,7 +27,7 @@ SystemHeap::~SystemHeap() {} void *SystemHeap::alloc(size_t size) { if (size_ > 0 && (alloc_size_ + size > size_)) - return NULL; + return nullptr; void *res = malloc(size); block_sizes_.insert(std::make_pair(res, size)); diff --git a/storage/tianmu/mm/tcm/page_heap.cpp b/storage/tianmu/mm/tcm/page_heap.cpp index f00bd636e..b5f89ce17 100644 --- a/storage/tianmu/mm/tcm/page_heap.cpp +++ b/storage/tianmu/mm/tcm/page_heap.cpp @@ -68,12 +68,12 @@ Span *PageHeap::New(Length n) { } Span *result = AllocLarge(n); - // if (result != NULL) return result; + // if (result != nullptr) return result; // Grow the heap and try again // if (!GrowHeap(n)) { // ASSERT(Check()); - // return NULL; + // return nullptr; //} return result; } @@ -81,12 +81,12 @@ Span *PageHeap::New(Length n) { Span *PageHeap::AllocLarge(Length n) { // find the best span (closest to n in size). // The following loops implements address-ordered best-fit. - Span *best = NULL; + Span *best = nullptr; // Search through normal list for (Span *span = large_.normal.next; span != &large_.normal; span = span->next) { if (span->length >= n) { - if ((best == NULL) || (span->length < best->length) || + if ((best == nullptr) || (span->length < best->length) || ((span->length == best->length) && (span->start < best->start))) { best = span; ASSERT(best->location == static_cast(Span::enumSpanType::ON_NORMAL_FREELIST)); @@ -97,7 +97,7 @@ Span *PageHeap::AllocLarge(Length n) { // Search through released list in case it has a better fit for (Span *span = large_.returned.next; span != &large_.returned; span = span->next) { if (span->length >= n) { - if ((best == NULL) || (span->length < best->length) || + if ((best == nullptr) || (span->length < best->length) || ((span->length == best->length) && (span->start < best->start))) { best = span; ASSERT(best->location == static_cast(Span::enumSpanType::ON_RETURNED_FREELIST)); @@ -105,7 +105,7 @@ Span *PageHeap::AllocLarge(Length n) { } } - return best == NULL ? NULL : Carve(best, n); + return best == nullptr ? nullptr : Carve(best, n); } Span *PageHeap::Carve(Span *span, Length n) { @@ -160,7 +160,7 @@ void PageHeap::MergeIntoFreeList(Span *span) { const PageID p = span->start; const Length n = span->length; Span *prev = GetDescriptor(p - 1); - if (prev != NULL && prev->location == span->location) { + if (prev != nullptr && prev->location == span->location) { // Merge preceding span into this span ASSERT(prev->start + prev->length == p); const Length len = prev->length; @@ -172,7 +172,7 @@ void PageHeap::MergeIntoFreeList(Span *span) { Event(span, 'L', len); } Span *next = GetDescriptor(p + n); - if (next != NULL && next->location == span->location) { + if (next != nullptr && next->location == span->location) { // Merge next span into this span ASSERT(next->start == p + n); const Length len = next->length; @@ -298,16 +298,16 @@ bool PageHeap::GrowHeap(Length n) { return false; Length ask = (n > kMinSystemAlloc) ? n : static_cast(kMinSystemAlloc); size_t actual_size; - void *ptr = NULL; - ptr = TCMalloc_SystemAlloc(ask << kPageShift, NULL, kPageSize); + void *ptr = nullptr; + ptr = TCMalloc_SystemAlloc(ask << kPageShift, nullptr, kPageSize); - if (ptr == NULL) { + if (ptr == nullptr) { if (n < ask) { // Try growing just "n" pages ask = n; - ptr = TCMalloc_SystemAlloc(ask << kPageShift, NULL, kPageSize); + ptr = TCMalloc_SystemAlloc(ask << kPageShift, nullptr, kPageSize); } - if (ptr == NULL) + if (ptr == nullptr) return false; } system_alloc_list.push_back(ptr); diff --git a/storage/tianmu/mm/tcm/page_heap.h b/storage/tianmu/mm/tcm/page_heap.h index 10ad24489..93373f15f 100755 --- a/storage/tianmu/mm/tcm/page_heap.h +++ b/storage/tianmu/mm/tcm/page_heap.h @@ -88,7 +88,7 @@ class PageHeap final { // and has not yet been deleted. void RegisterSizeClass(Span *span, size_t sc); - // Return the descriptor for the specified page. Returns NULL if + // Return the descriptor for the specified page. Returns nullptr if // this PageID was not allocated previously. inline Span *GetDescriptor(PageID p) const { return reinterpret_cast(pagemap_.get(p)); } @@ -186,7 +186,7 @@ class PageHeap final { } // Allocate a large span of length == n. If successful, returns a - // span of exactly the specified length. Else, returns NULL. + // span of exactly the specified length. Else, returns nullptr. Span *AllocLarge(Length n); // Coalesce span with neighboring spans if possible, prepend to diff --git a/storage/tianmu/mm/tcm/page_heap_allocator.h b/storage/tianmu/mm/tcm/page_heap_allocator.h index ee774a71c..f67f2f832 100755 --- a/storage/tianmu/mm/tcm/page_heap_allocator.h +++ b/storage/tianmu/mm/tcm/page_heap_allocator.h @@ -56,9 +56,9 @@ class PageHeapAllocator { // other static variable tries to allocate memory. void Init() { ASSERT(kAlignedSize <= (size_t)kAllocIncrement); - free_area_ = NULL; + free_area_ = nullptr; free_avail_ = 0; - free_list_ = NULL; + free_list_ = nullptr; // Reserve some space at the beginning to avoid fragmentation. Delete(New()); } @@ -66,17 +66,17 @@ class PageHeapAllocator { T *New() { // Consult free list void *result; - if (free_list_ != NULL) { + if (free_list_ != nullptr) { result = free_list_; free_list_ = *(reinterpret_cast(result)); } else { if (free_avail_ < kAlignedSize) { // Need more room - // free_area_ = (char *)TCMalloc_SystemAlloc(kAllocIncrement, NULL, + // free_area_ = (char *)TCMalloc_SystemAlloc(kAllocIncrement, nullptr, // kPageSize); free_area_ = reinterpret_cast(MetaDataAlloc(kAllocIncrement)); - if (free_area_ == NULL) { - return NULL; + if (free_area_ == nullptr) { + return nullptr; } system_alloc_list.push_back(free_area_); free_avail_ = kAllocIncrement; diff --git a/storage/tianmu/mm/tcm/pagemap.h b/storage/tianmu/mm/tcm/pagemap.h index 23a186c73..7f131ec25 100644 --- a/storage/tianmu/mm/tcm/pagemap.h +++ b/storage/tianmu/mm/tcm/pagemap.h @@ -85,12 +85,12 @@ class TCMalloc_PageMap1 { void PreallocateMoreMemory() {} - // Return the current value for KEY. Returns NULL if not yet set, + // Return the current value for KEY. Returns nullptr if not yet set, // or if k is out of range. void *get(Number k) const { ASSERT(k < sizeof(Number) * 8); if ((k >> BITS) > 0) { - return NULL; + return nullptr; } return array_[k]; } @@ -101,16 +101,16 @@ class TCMalloc_PageMap1 { // Sets the value 'v' for key 'k'. void set(Number k, void *v) { array_[k] = v; } - // Return the first non-NULL pointer found in this map for - // a page number >= k. Returns NULL if no such number is found. + // Return the first non-nullptr pointer found in this map for + // a page number >= k. Returns nullptr if no such number is found. void *Next(Number k) const { static_assert(BITS <= sizeof(Number) * 8); while (k < (1 << BITS)) { - if (array_[k] != NULL) + if (array_[k] != nullptr) return array_[k]; k++; } - return NULL; + return nullptr; } }; @@ -143,7 +143,7 @@ class TCMalloc_PageMap3 { Node *NewNode() { Node *result = reinterpret_cast((*allocator_)(sizeof(Node))); - if (result != NULL) { + if (result != nullptr) { memset(result, 0, sizeof(*result)); } system_alloc_list.push_back(result); @@ -167,8 +167,8 @@ class TCMalloc_PageMap3 { const Number i1 = k >> (LEAF_BITS + INTERIOR_BITS); const Number i2 = (k >> LEAF_BITS) & (INTERIOR_LENGTH - 1); const Number i3 = k & (LEAF_LENGTH - 1); - if ((k >> BITS) > 0 || root_->ptrs[i1] == NULL || root_->ptrs[i1]->ptrs[i2] == NULL) { - return NULL; + if ((k >> BITS) > 0 || root_->ptrs[i1] == nullptr || root_->ptrs[i1]->ptrs[i2] == nullptr) { + return nullptr; } return reinterpret_cast(root_->ptrs[i1]->ptrs[i2])->values[i3]; } @@ -191,17 +191,17 @@ class TCMalloc_PageMap3 { return false; // Make 2nd level node if necessary - if (root_->ptrs[i1] == NULL) { + if (root_->ptrs[i1] == nullptr) { Node *n = NewNode(); - if (n == NULL) + if (n == nullptr) return false; root_->ptrs[i1] = n; } // Make leaf node if necessary - if (root_->ptrs[i1]->ptrs[i2] == NULL) { + if (root_->ptrs[i1]->ptrs[i2] == nullptr) { Leaf *leaf = reinterpret_cast((*allocator_)(sizeof(Leaf))); - if (leaf == NULL) + if (leaf == nullptr) return false; system_alloc_list.push_back(leaf); memset(leaf, 0, sizeof(*leaf)); @@ -220,14 +220,14 @@ class TCMalloc_PageMap3 { while (k < (Number(1) << BITS)) { const Number i1 = k >> (LEAF_BITS + INTERIOR_BITS); const Number i2 = (k >> LEAF_BITS) & (INTERIOR_LENGTH - 1); - if (root_->ptrs[i1] == NULL) { + if (root_->ptrs[i1] == nullptr) { // Advance to next top-level entry k = (i1 + 1) << (LEAF_BITS + INTERIOR_BITS); } else { Leaf *leaf = reinterpret_cast(root_->ptrs[i1]->ptrs[i2]); - if (leaf != NULL) { + if (leaf != nullptr) { for (Number i3 = (k & (LEAF_LENGTH - 1)); i3 < LEAF_LENGTH; i3++) { - if (leaf->values[i3] != NULL) { + if (leaf->values[i3] != nullptr) { return leaf->values[i3]; } } @@ -236,7 +236,7 @@ class TCMalloc_PageMap3 { k = ((k >> LEAF_BITS) + 1) << LEAF_BITS; } } - return NULL; + return nullptr; } }; } // namespace mm diff --git a/storage/tianmu/mm/tcm/span.cpp b/storage/tianmu/mm/tcm/span.cpp index 7262ee6bb..3caf5c026 100644 --- a/storage/tianmu/mm/tcm/span.cpp +++ b/storage/tianmu/mm/tcm/span.cpp @@ -73,8 +73,8 @@ void DLL_Init(Span *list) { void DLL_Remove(Span *span) { span->prev->next = span->next; span->next->prev = span->prev; - span->prev = NULL; - span->next = NULL; + span->prev = nullptr; + span->next = nullptr; } #if 0 // This isn't used. If that changes, rewrite to use TCMalloc_Printer. @@ -89,8 +89,8 @@ void DLL_Print(const char *label, const Span *list) #endif void DLL_Prepend(Span *list, Span *span) { - ASSERT(span->next == NULL); - ASSERT(span->prev == NULL); + ASSERT(span->next == nullptr); + ASSERT(span->prev == nullptr); span->next = list->next; span->prev = list; list->next->prev = span; diff --git a/storage/tianmu/mm/tcm/span.h b/storage/tianmu/mm/tcm/span.h index 67fc6b4fa..20c96f202 100755 --- a/storage/tianmu/mm/tcm/span.h +++ b/storage/tianmu/mm/tcm/span.h @@ -82,7 +82,7 @@ void DeleteSpan(Span *span); void DLL_Init(Span *list); // Remove 'span' from the linked list in which it resides, updating the -// pointers of adjacent Spans and setting span's next and prev to NULL. +// pointers of adjacent Spans and setting span's next and prev to nullptr. void DLL_Remove(Span *span); // Return true iff "list" is empty. diff --git a/storage/tianmu/mm/tcm/tccommon.cpp b/storage/tianmu/mm/tcm/tccommon.cpp index 2f77a010a..5f45b68b0 100755 --- a/storage/tianmu/mm/tcm/tccommon.cpp +++ b/storage/tianmu/mm/tcm/tccommon.cpp @@ -154,8 +154,8 @@ void SizeMap::Init() { static uint64_t metadata_system_bytes_ = 0; void *MetaDataAlloc(size_t bytes) { - void *result = TCMalloc_SystemAlloc(bytes, NULL, kPageSize); - if (result != NULL) { + void *result = TCMalloc_SystemAlloc(bytes, nullptr, kPageSize); + if (result != nullptr) { metadata_system_bytes_ += bytes; } return result; @@ -167,7 +167,7 @@ void *MetaDataAlloc(size_t bytes) { // This is mostly like MmapSysAllocator::Alloc, except it does these weird // munmap's in the middle of the page, which is forbidden in windows. void *TCMalloc_SystemAlloc(size_t size, size_t *actual_size, size_t alignment) { - void *ptr(NULL); + void *ptr(nullptr); if (actual_size) { *actual_size = size; } diff --git a/storage/tianmu/mm/tcm/tccommon.h b/storage/tianmu/mm/tcm/tccommon.h index 6cda9f599..0d1ddf101 100755 --- a/storage/tianmu/mm/tcm/tccommon.h +++ b/storage/tianmu/mm/tcm/tccommon.h @@ -142,7 +142,7 @@ class SizeMap { }; // Allocates "bytes" worth of memory and returns it. Increments -// metadata_system_bytes appropriately. May return NULL if allocation +// metadata_system_bytes appropriately. May return nullptr if allocation // fails. Requires pageheap_lock is held. void *MetaDataAlloc(size_t bytes); diff --git a/storage/tianmu/mm/tcm_heap_policy.cpp b/storage/tianmu/mm/tcm_heap_policy.cpp index e673b48f5..0826aba89 100644 --- a/storage/tianmu/mm/tcm_heap_policy.cpp +++ b/storage/tianmu/mm/tcm_heap_policy.cpp @@ -42,11 +42,11 @@ void *TCMHeap::alloc(size_t size) { if (size > kMaxSize) { int pages = int(size >> kPageShift); tcm::Span *s = m_heap.New(pages + 1); - if (s == NULL) - return NULL; - s->objects = NULL; - s->next = NULL; - s->prev = NULL; + if (s == nullptr) + return nullptr; + s->objects = nullptr; + s->next = nullptr; + s->prev = nullptr; s->refcount = 1; s->size = uint(size); s->sizeclass = 0; @@ -61,8 +61,8 @@ void *TCMHeap::alloc(size_t size) { // allocations of this size) int pages = int(m_sizemap.class_to_pages(cl)); tcm::Span *res = m_heap.New(pages); - if (res == NULL) - return NULL; + if (res == nullptr) + return nullptr; m_heap.RegisterSizeClass(res, cl); @@ -79,12 +79,12 @@ void *TCMHeap::alloc(size_t size) { num++; } ASSERT(ptr <= limit); - *tail = NULL; + *tail = nullptr; res->refcount = 0; list->PushRange(num, (void *)(res->start << kPageShift), tail); } if (list->empty()) - return NULL; + return nullptr; res = list->Pop(); tcm::Span *s = m_heap.GetDescriptor(ADDR_TO_PAGEID(res)); @@ -95,7 +95,7 @@ void *TCMHeap::alloc(size_t size) { size_t TCMHeap::getBlockSize(void *mh) { size_t result; tcm::Span *span = m_heap.GetDescriptor(ADDR_TO_PAGEID(mh)); - ASSERT(span != NULL); + ASSERT(span != nullptr); if (span->sizeclass == 0) result = span->size; else @@ -107,11 +107,11 @@ size_t TCMHeap::getBlockSize(void *mh) { void TCMHeap::dealloc(void *mh) { // be an enabler for broken code - if (mh == NULL) + if (mh == nullptr) return; tcm::Span *span = m_heap.GetDescriptor(ADDR_TO_PAGEID(mh)); - ASSERT(span != NULL); + ASSERT(span != nullptr); span->refcount--; if (span->sizeclass == 0) { m_heap.Delete(span); @@ -131,7 +131,7 @@ void TCMHeap::dealloc(void *mh) { void *TCMHeap::rc_realloc(void *mh, size_t size) { void *res = alloc(size); - if (mh == NULL) + if (mh == nullptr) return res; tcm::Span *span = m_heap.GetDescriptor(ADDR_TO_PAGEID(mh)); if (span->sizeclass == 0) { diff --git a/storage/tianmu/mm/tcm_heap_policy.h b/storage/tianmu/mm/tcm_heap_policy.h index 39a7f93f8..461143199 100644 --- a/storage/tianmu/mm/tcm_heap_policy.h +++ b/storage/tianmu/mm/tcm_heap_policy.h @@ -45,12 +45,12 @@ class TCMHeap : public HeapPolicy { public: void Init() { - list_ = NULL; + list_ = nullptr; length_ = 0; } // Is list empty? - bool empty() const { return list_ == NULL; } + bool empty() const { return list_ == nullptr; } void Push(void *ptr) { tcm::SLL_Push(&list_, ptr); @@ -58,7 +58,7 @@ class TCMHeap : public HeapPolicy { } void *Pop() { - ASSERT(list_ != NULL); + ASSERT(list_ != nullptr); length_--; return tcm::SLL_Pop(&list_); } @@ -74,7 +74,7 @@ class TCMHeap : public HeapPolicy { list_ = tcm::SLL_Next(list_); } current = list_; - while (current != NULL) { + while (current != nullptr) { prev = current; current = tcm::SLL_Next(current); while (current <= hi && current >= low) { diff --git a/storage/tianmu/mm/traceable_object.cpp b/storage/tianmu/mm/traceable_object.cpp index 50f1a1c5d..1cf1c2081 100644 --- a/storage/tianmu/mm/traceable_object.cpp +++ b/storage/tianmu/mm/traceable_object.cpp @@ -30,7 +30,7 @@ namespace Tianmu { namespace mm { -MemoryHandling *TraceableObject::m_MemHandling = NULL; +MemoryHandling *TraceableObject::m_MemHandling = nullptr; std::atomic_size_t TraceableObject::globalFreeable; std::atomic_size_t TraceableObject::globalUnFreeable; @@ -53,7 +53,7 @@ TraceableObject::UniquePtr TraceableObject::alloc_ptr(size_t size, BLOCK_TYPE ty void *TraceableObject::alloc(size_t size, BLOCK_TYPE type, bool nothrow) { void *addr = Instance()->alloc(size, type, this, nothrow); - if (addr != NULL) { + if (addr != nullptr) { size_t s = Instance()->rc_msize(addr, this); m_sizeAllocated += s; if (!IsLocked() && TraceableType() == TO_TYPE::TO_PACK) @@ -66,7 +66,7 @@ void *TraceableObject::alloc(size_t size, BLOCK_TYPE type, bool nothrow) { void TraceableObject::dealloc(void *ptr) { size_t s; - if (ptr == NULL) + if (ptr == nullptr) return; s = Instance()->rc_msize(ptr, this); Instance()->dealloc(ptr, this); @@ -78,12 +78,12 @@ void TraceableObject::dealloc(void *ptr) { } void *TraceableObject::rc_realloc(void *ptr, size_t size, BLOCK_TYPE type) { - if (ptr == NULL) + if (ptr == nullptr) return alloc(size, type); size_t s1 = Instance()->rc_msize(ptr, this); void *addr = Instance()->rc_realloc(ptr, size, this, type); - if (addr != NULL) { + if (addr != nullptr) { size_t s = Instance()->rc_msize(addr, this); m_sizeAllocated += s; m_sizeAllocated -= s1; @@ -101,26 +101,26 @@ void *TraceableObject::rc_realloc(void *ptr, size_t size, BLOCK_TYPE type) { size_t TraceableObject::rc_msize(void *ptr) { return Instance()->rc_msize(ptr, this); } TraceableObject::TraceableObject() - : next(NULL), - prev(NULL), - tracker(NULL), + : next(nullptr), + prev(nullptr), + tracker(nullptr), m_preUnused(false), m_sizeAllocated(0), m_locking_mutex(Instance()->m_release_mutex) {} TraceableObject::TraceableObject(size_t comp_size, size_t uncomp_size, std::string hugedir, core::DataCache *owner_, size_t hugesize) - : next(NULL), - prev(NULL), - tracker(NULL), + : next(nullptr), + prev(nullptr), + tracker(nullptr), m_preUnused(false), m_sizeAllocated(0), owner(owner_), m_locking_mutex(Instance(comp_size, uncomp_size, hugedir, owner_, hugesize)->m_release_mutex) {} TraceableObject::TraceableObject(const TraceableObject &to) - : next(NULL), - prev(NULL), - tracker(NULL), + : next(nullptr), + prev(nullptr), + tracker(nullptr), m_preUnused(false), m_sizeAllocated(0), m_locking_mutex(Instance()->m_release_mutex), diff --git a/storage/tianmu/mm/traceable_object.h b/storage/tianmu/mm/traceable_object.h index 6f218ce0a..88ae2bf5d 100644 --- a/storage/tianmu/mm/traceable_object.h +++ b/storage/tianmu/mm/traceable_object.h @@ -66,7 +66,7 @@ class TraceableObject { using UniquePtr = std::unique_ptr>; TraceableObject(); - TraceableObject(size_t, size_t, std::string = "", core::DataCache * = NULL, size_t = 0); + TraceableObject(size_t, size_t, std::string = "", core::DataCache * = nullptr, size_t = 0); TraceableObject(const TraceableObject &to); virtual ~TraceableObject(); @@ -107,14 +107,14 @@ class TraceableObject { // m_MemHandling = new MemoryHandling >(COMP_SIZE, // UNCOMP_SIZE, COMPRESSED_HEAP_RELEASE, UNCOMPRESSED_HEAP_RELEASE); TIANMU_ERROR("Memory manager is not instantiated"); - return NULL; + return nullptr; } else return m_MemHandling; } void TrackAccess() { Instance()->TrackAccess(this); } void StopAccessTracking() { Instance()->StopAccessTracking(this); } - bool IsTracked() { return tracker != NULL; } + bool IsTracked() { return tracker != nullptr; } virtual void Release() { TIANMU_ERROR("Release functionality not implemented for this object"); } core::TOCoordinate &GetCoordinate(); @@ -138,7 +138,7 @@ class TraceableObject { static MemoryHandling *m_MemHandling; static MemoryHandling *Instance(size_t comp_size, size_t uncomp_size, std::string hugedir = "", - core::DataCache *d = NULL, size_t hugesize = 0) { + core::DataCache *d = nullptr, size_t hugesize = 0) { if (!m_MemHandling) m_MemHandling = new MemoryHandling(comp_size, uncomp_size, hugedir, d, hugesize); return m_MemHandling; diff --git a/storage/tianmu/system/cacheable_item.cpp b/storage/tianmu/system/cacheable_item.cpp index ac8b09cc9..cdf2772c2 100644 --- a/storage/tianmu/system/cacheable_item.cpp +++ b/storage/tianmu/system/cacheable_item.cpp @@ -25,10 +25,10 @@ namespace Tianmu { namespace system { CacheableItem::CacheableItem(char const *owner_name, char const *object_id, int _default_block_size) { default_block_size = _default_block_size; - DEBUG_ASSERT(owner_name != NULL); - DEBUG_ASSERT(object_id != NULL); + DEBUG_ASSERT(owner_name != nullptr); + DEBUG_ASSERT(object_id != nullptr); // copy the temporary folder first - filename = NULL; + filename = nullptr; { // read the configuration parameter @@ -43,7 +43,7 @@ CacheableItem::CacheableItem(char const *owner_name, char const *object_id, int filename_n_position += 6; } - if (filename == NULL) { + if (filename == nullptr) { // if the temporary path is not set, use the current folder filename = new char[36]; // "XXXXXXnnnnnnAAAAAAAABBBBBBBB.tianmu_tmp" filename_n_position = 6; diff --git a/storage/tianmu/system/channel.cpp b/storage/tianmu/system/channel.cpp index 8f2a3129c..9c113a1c6 100644 --- a/storage/tianmu/system/channel.cpp +++ b/storage/tianmu/system/channel.cpp @@ -43,7 +43,7 @@ bool Channel::isOn() { return enabled_; } Channel &Channel::lock(uint optional_sess_id) { channel_mutex_.lock(); if (time_stamp_at_lock_ && enabled_) { - time_t curtime = time(NULL); + time_t curtime = time(nullptr); struct tm *cdt = localtime(&curtime); char sdatetime[32] = ""; struct timespec time; diff --git a/storage/tianmu/system/fet.h b/storage/tianmu/system/fet.h index 03549aa0a..b159e88f5 100644 --- a/storage/tianmu/system/fet.h +++ b/storage/tianmu/system/fet.h @@ -138,12 +138,12 @@ class FunctionsExecutionTimes { class FETOperator { public: - FETOperator(const std::string &identyfier) : id(identyfier) { gettimeofday(&start_time, NULL); } + FETOperator(const std::string &identyfier) : id(identyfier) { gettimeofday(&start_time, nullptr); } ~FETOperator() { struct timeval t2; uint64_t sec, usec; sec = usec = 0; - gettimeofday(&t2, NULL); + gettimeofday(&t2, nullptr); sec += (t2.tv_sec - start_time.tv_sec); if (t2.tv_usec < start_time.tv_usec) { diff --git a/storage/tianmu/system/io_parameters.h b/storage/tianmu/system/io_parameters.h index a198d899a..945646dfd 100644 --- a/storage/tianmu/system/io_parameters.h +++ b/storage/tianmu/system/io_parameters.h @@ -123,7 +123,7 @@ class IOParameters { void SetNullsStr(const std::string &null_str) { this->null_str_ = null_str; } void SetOutput(int mode, const char *fname) // mode: 0 - standard console-style output with header - // fname: NULL for console + // fname: nullptr for console // These settings will work until the next change { curr_output_mode_ = mode; diff --git a/storage/tianmu/system/large_buffer.cpp b/storage/tianmu/system/large_buffer.cpp index c81ec14b4..586e1bf9c 100644 --- a/storage/tianmu/system/large_buffer.cpp +++ b/storage/tianmu/system/large_buffer.cpp @@ -128,7 +128,7 @@ void LargeBuffer::FlushAndClose() { char *LargeBuffer::BufAppend(unsigned int len) { if ((int)len > size_) { TIANMU_LOG(LogCtl_Level::ERROR, "Error: LargeBuffer buffer overrun (BufAppend)"); - return NULL; + return nullptr; } int buf_pos = buf_used_; if (size_ > (int)(buf_used_ + len)) diff --git a/storage/tianmu/types/bstring.cpp b/storage/tianmu/types/bstring.cpp index e669e6ea6..77fcf987b 100644 --- a/storage/tianmu/types/bstring.cpp +++ b/storage/tianmu/types/bstring.cpp @@ -33,7 +33,7 @@ BString::BString() // null_ string } BString::BString(const char *v, size_t length, bool persistent) : persistent_(persistent) { - // NOTE: we allow val_ to be NULL. In this case, no value will be copied (just + // NOTE: we allow val_ to be nullptr. In this case, no value will be copied (just // reserve a place for future use). Only persistent! pos_ = 0; null_ = false; @@ -239,8 +239,8 @@ bool BString::Like(const BString &pattern, char escape_character) { } } if (escaped) { // redefine the pattern by processing escape characters - processed_pattern = BString(NULL, pattern_len, true); - processed_wildcards = BString(NULL, pattern_len, true); + processed_pattern = BString(nullptr, pattern_len, true); + processed_wildcards = BString(nullptr, pattern_len, true); uint i = 0; // position of the processed pattern uint j = 0; // position of the original pattern while (j < pattern_len) { diff --git a/storage/tianmu/types/rc_data_types.h b/storage/tianmu/types/rc_data_types.h index 7810ddf02..6a34d9dfd 100644 --- a/storage/tianmu/types/rc_data_types.h +++ b/storage/tianmu/types/rc_data_types.h @@ -324,7 +324,7 @@ class RCDateTime : public ValueBasic { * Date: YYYYMMDD * DATETIME/TIMESTAM: YYYYMMDDHHMMSS * \param value result of the conversion - * \return false if it is NULL, true otherwise + * \return false if it is nullptr, true otherwise */ bool ToInt64(int64_t &value) const; char *GetDataBytesPointer() const override { return (char *)&dt_; } diff --git a/storage/tianmu/types/rc_item_types.cpp b/storage/tianmu/types/rc_item_types.cpp index bd18f7a89..54d03b54a 100644 --- a/storage/tianmu/types/rc_item_types.cpp +++ b/storage/tianmu/types/rc_item_types.cpp @@ -31,8 +31,8 @@ longlong Item_sum_int_rcbase::val_int() { return (longlong)count_; } -String *Item_sum_int_rcbase::val_str([[maybe_unused]] String *str) { return NULL; } -my_decimal *Item_sum_int_rcbase::val_decimal(my_decimal *) { return NULL; } +String *Item_sum_int_rcbase::val_str([[maybe_unused]] String *str) { return nullptr; } +my_decimal *Item_sum_int_rcbase::val_decimal(my_decimal *) { return nullptr; } void Item_sum_int_rcbase::int64_value(int64_t &value) { fixed = 1; diff --git a/storage/tianmu/types/rc_num.cpp b/storage/tianmu/types/rc_num.cpp index d3584b213..8ff5f0122 100644 --- a/storage/tianmu/types/rc_num.cpp +++ b/storage/tianmu/types/rc_num.cpp @@ -453,7 +453,7 @@ RCNum &RCNum::operator/=(const RCNum &rcn) { while (lz >= 0 && buf[lz--] == '0') ; buf[lz + 2] = 0; - value_ = std::strtoll(buf, NULL, 10) * (sign == 1 ? -1 : 1); + value_ = std::strtoll(buf, nullptr, 10) * (sign == 1 ? -1 : 1); scale_ = (short)((lz + 2) - decimal); } return *this; diff --git a/storage/tianmu/types/value_parser4txt.cpp b/storage/tianmu/types/value_parser4txt.cpp index 3ec87a96c..30a0c7022 100644 --- a/storage/tianmu/types/value_parser4txt.cpp +++ b/storage/tianmu/types/value_parser4txt.cpp @@ -92,7 +92,7 @@ common::ErrorCode ValueParserForText::ParseNum(const BString &rcs, RCNum &rcn, s val = val_ptr = rcs.val_; int len = rcs.len_; EatWhiteSigns(val, len); - if (rcs.Equals("NULL", 4)) { + if (rcs.Equals("nullptr", 4)) { rcn.null_ = true; return common::ErrorCode::SUCCESS; } @@ -306,7 +306,7 @@ common::ErrorCode ValueParserForText::Parse(const BString &rcs, RCNum &rcn, comm rcn.scale_ = 0; rcn.is_double_ = false; - if (rcs.Equals("NULL", 4)) { + if (rcs.Equals("nullptr", 4)) { rcn.null_ = true; return common::ErrorCode::SUCCESS; } @@ -367,7 +367,7 @@ common::ErrorCode ValueParserForText::ParseReal(const BString &rcbs, RCNum &rcn, if (!core::ATI::IsRealType(at)) return common::ErrorCode::FAILED; - if (rcbs.Equals("NULL", 4) || rcbs.IsNull()) { + if (rcbs.Equals("nullptr", 4) || rcbs.IsNull()) { rcn.null_ = true; return common::ErrorCode::SUCCESS; } @@ -486,7 +486,7 @@ common::ErrorCode ValueParserForText::ParseBigInt(const BString &rcs, RCNum &rcn rcn.scale_ = 0; rcn.is_double_ = false; - if (rcs.Equals("NULL", 4)) { + if (rcs.Equals("nullptr", 4)) { rcn.null_ = true; return common::ErrorCode::SUCCESS; } @@ -612,7 +612,7 @@ common::ErrorCode ValueParserForText::ParseDecimal(BString const &rcs, int64_t & } common::ErrorCode ValueParserForText::ParseDateTimeOrTimestamp(const BString &rcs, RCDateTime &rcv, common::CT at) { - if (rcs.IsNull() || rcs.Equals("NULL", 4)) { + if (rcs.IsNull() || rcs.Equals("nullptr", 4)) { rcv.at_ = at; rcv.null_ = true; return common::ErrorCode::SUCCESS; @@ -810,7 +810,7 @@ common::ErrorCode ValueParserForText::ParseDateTimeOrTimestamp(const BString &rc } common::ErrorCode ValueParserForText::ParseTime(const BString &rcs, RCDateTime &rcv) { - if (rcs.IsNull() || rcs.Equals("NULL", 4)) { + if (rcs.IsNull() || rcs.Equals("nullptr", 4)) { rcv.at_ = common::CT::TIME; rcv.null_ = true; return common::ErrorCode::SUCCESS; @@ -971,7 +971,7 @@ common::ErrorCode ValueParserForText::ParseTime(const BString &rcs, RCDateTime & } common::ErrorCode ValueParserForText::ParseDate(const BString &rcs, RCDateTime &rcv) { - if (rcs.IsNull() || rcs.Equals("NULL", 4)) { + if (rcs.IsNull() || rcs.Equals("nullptr", 4)) { rcv.at_ = common::CT::DATE; rcv.null_ = true; return common::ErrorCode::SUCCESS; @@ -1033,7 +1033,7 @@ common::ErrorCode ValueParserForText::ParseDate(const BString &rcs, RCDateTime & } common::ErrorCode ValueParserForText::ParseYear(const BString &rcs, RCDateTime &rcv) { - if (rcs.IsNull() || rcs.Equals("NULL", 4)) { + if (rcs.IsNull() || rcs.Equals("nullptr", 4)) { rcv.at_ = common::CT::YEAR; rcv.null_ = true; return common::ErrorCode::SUCCESS; diff --git a/storage/tianmu/types/value_parser4txt.h b/storage/tianmu/types/value_parser4txt.h index aa6902521..e086799b3 100644 --- a/storage/tianmu/types/value_parser4txt.h +++ b/storage/tianmu/types/value_parser4txt.h @@ -56,7 +56,7 @@ class ValueParserForText { TIANMU_ERROR("type not supported:" + std::to_string(static_cast(at.Type()))); break; } - return NULL; + return nullptr; } static common::ErrorCode ParseNumeric(BString const &rcs, int64_t &out, common::CT at); diff --git a/storage/tianmu/util/stack_trace.cpp b/storage/tianmu/util/stack_trace.cpp index ddb44970d..5e4788c04 100644 --- a/storage/tianmu/util/stack_trace.cpp +++ b/storage/tianmu/util/stack_trace.cpp @@ -45,7 +45,7 @@ static inline bool DemangelSymbol(char *name, std::string &result) { char *end = p++; *end = '\0'; int status; - char *func = abi::__cxa_demangle(begin, NULL, NULL, &status); + char *func = abi::__cxa_demangle(begin, nullptr, nullptr, &status); if (!func) return false; @@ -67,7 +67,7 @@ bool GetStackTrace(std::vector &v, int skip_level, bool demangle) { char **str; str = backtrace_symbols(buffer, n); - if (str == NULL) { + if (str == nullptr) { return false; }