diff --git a/sql/sql_cmd_ddl_table.cc b/sql/sql_cmd_ddl_table.cc index b23ca906ec..21cf06ae7c 100644 --- a/sql/sql_cmd_ddl_table.cc +++ b/sql/sql_cmd_ddl_table.cc @@ -402,13 +402,13 @@ bool Sql_cmd_create_table::execute(THD *thd) { else if (thd->is_strict_mode()) thd->push_internal_handler(&strict_handler); - int sdb_res = 0, free_join_from_sdb = 0, optimize_after_sdb = 0; + int tianmu_res = 0, free_join_from_tianmu = 0, optimize_after_tianmu = 0; Query_result * result_tianmu = dynamic_cast(result); - if (Tianmu::DBHandler::Tianmu_Handle_Query(thd, query_expression, result_tianmu, 0, sdb_res, optimize_after_sdb, - free_join_from_sdb, (int)true) == Tianmu::DBHandler::Query_route_to::TO_MYSQL) + if (Tianmu::handler::ha_my_tianmu_query(thd, query_expression, result_tianmu, 0, tianmu_res, optimize_after_tianmu, + free_join_from_tianmu, (int)true) == Tianmu::handler::Query_route_to::TO_MYSQL) res = populate_table(thd, lex); else - res = sdb_res; + res = tianmu_res; // Count the number of statements offloaded to a secondary storage engine. if (using_secondary_storage_engine() && lex->unit->is_executed()) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index a923d3dd27..367f40f9ae 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -683,8 +683,8 @@ bool Sql_cmd_insert_values::execute_inner(THD *thd) { if (!has_error || thd->get_transaction()->cannot_safely_rollback(Transaction_ctx::STMT)) { bool tianmu_engine = insert_table->s->db_type() ? insert_table->s->db_type()->db_type == DB_TYPE_TIANMU: false; - bool tianmu_engier_insert_delayed = tianmu_engine ? Tianmu::DBHandler::Tianmu_Get_Insert_Delayed_Flag(thd): false; - if (!tianmu_engier_insert_delayed && mysql_bin_log.is_open()) { + bool if_tianmu_engine_insert_delayed = tianmu_engine ? Tianmu::handler::ha_my_tianmu_get_insert_delayed_flag(thd): false; + if (!if_tianmu_engine_insert_delayed && mysql_bin_log.is_open()) { int errcode = 0; if (!has_error) { /* diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 44ecb8d806..b410536562 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -309,7 +309,7 @@ bool Sql_cmd_load_table::execute_inner(THD *thd, return true; } // TIANMU UPGRADE BEGIN - if (!Tianmu::DBHandler::Tianmu_Load(thd, &m_exchange, table_list, + if (!Tianmu::handler::ha_my_tianmu_load(thd, &m_exchange, table_list, (void *)&lf_info)) { return false; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index f08d3cf088..dc0b309e60 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -575,10 +575,10 @@ bool Sql_cmd_dml::execute(THD *thd) { // if is select operation, route to Tianmu if (lex->sql_command == SQLCOM_SELECT) { - int sdb_res = 0, free_join_from_sdb = 0, optimize_after_sdb = 0; - if (Tianmu::DBHandler::Tianmu_Handle_Query(thd, unit, result, 0, sdb_res, optimize_after_sdb, - free_join_from_sdb) != Tianmu::DBHandler::Query_route_to::TO_MYSQL) { - if (sdb_res) goto err; else goto clean; + int tianmu_res = 0, free_join_from_tianmu = 0, optimize_after_tianmu = 0; + if (Tianmu::handler::ha_my_tianmu_query(thd, unit, result, 0, tianmu_res, optimize_after_tianmu, + free_join_from_tianmu) != Tianmu::handler::Query_route_to::TO_MYSQL) { + if (tianmu_res) goto err; else goto clean; } } diff --git a/storage/tianmu/base/core/posix.cpp b/storage/tianmu/base/core/posix.cpp index 07e100174a..1c76473149 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 3367a0cc68..3d9771d593 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 a2e7124aa7..ae301c9892 100644 --- a/storage/tianmu/base/core/reactor.cpp +++ b/storage/tianmu/base/core/reactor.cpp @@ -146,7 +146,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) @@ -158,7 +158,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 e2cd231e43..7e07948929 100644 --- a/storage/tianmu/common/txt_data_format.cpp +++ b/storage/tianmu/common/txt_data_format.cpp @@ -59,7 +59,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 afe600994d..aafe22e59e 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 0f67d2970c..51f385f215 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 9af22361fc..e8fae0714e 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; - mask = NULL; - coder = NULL; - reclen = NULL; - records = NULL; + dump = nullptr; + ROOT = NIL = START = nullptr; + mask = nullptr; + coder = nullptr; + reclen = nullptr; + records = nullptr; } void IncWGraph::Init() { nfinals = 0; matchlen_cost = esc_cost = 0; // mask = &_mask_; // uncomment if masking should be used - mask = NULL; + 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 d64d7356d4..2c859daffa 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(NFILTERS); diff --git a/storage/tianmu/compress/ppm.cpp b/storage/tianmu/compress/ppm.cpp index 4373999280..4128782cb7 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)) return; + if ((data == nullptr) || (dlen <= 0) || (mt == ModelType::ModelNull)) return; switch (mt) { case ModelType::ModelSufTree: @@ -60,11 +60,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'"); @@ -167,11 +167,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'"); @@ -246,11 +246,11 @@ CprsErr PPM::Compress(char *dest, int &dlen, Symb *src, int slen) { if (dlen < 1) 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) ASSERT(wg->insatend, "'wg->insatend' should be true"); @@ -310,11 +310,11 @@ CprsErr PPM::Decompress(Symb *dest, int dlen, char *src, int slen) { return DecompressArith(dest, dlen, src, 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) ASSERT(wg->insatend, "'wg->insatend' should be true"); diff --git a/storage/tianmu/compress/ppm.h b/storage/tianmu/compress/ppm.h index 2763998092..e315e89c7b 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 57127af4bc..ed013360ef 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 *logfile; - PPMModel() : logfile(NULL) {} + PPMModel() : logfile(nullptr) {} virtual ~PPMModel() {} }; diff --git a/storage/tianmu/compress/text_compressor.cpp b/storage/tianmu/compress/text_compressor.cpp index dec37ea43e..a378ff1543 100644 --- a/storage/tianmu/compress/text_compressor.cpp +++ b/storage/tianmu/compress/text_compressor.cpp @@ -127,7 +127,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)) return CprsErr::CPRS_ERR_PAR; + 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; if (ver == 0) return CompressCopy(dest, dlen, src, slen); @@ -172,7 +172,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)) return CprsErr::CPRS_ERR_PAR; + if ((dest == nullptr) || (src == nullptr) || (dlen <= 0) || (slen <= 0)) return CprsErr::CPRS_ERR_PAR; if (slen < 2) return CprsErr::CPRS_ERR_BUF; char ver = src[0], lev = (ver > 0) ? src[1] : 1; diff --git a/storage/tianmu/compress/word_graph.cpp b/storage/tianmu/compress/word_graph.cpp index b042882e7f..b883c11679 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() { @@ -284,7 +284,7 @@ void WordGraph::Clear() { finals.clear(); edges.clear(); nodes.clear(); - data = NULL; + data = nullptr; } //------------------------------------------------------------------------ @@ -729,7 +729,7 @@ void WordGraph::Move(PEdge e) { } void WordGraph::MakeLog(PNode stt, PEdge e) { - if (logfile == NULL) return; + if (logfile == nullptr) return; // if(e != ENIL) { // std::fprintf(logfile, "F\n"); // forward transition // return; diff --git a/storage/tianmu/core/aggregation_algorithm.cpp b/storage/tianmu/core/aggregation_algorithm.cpp index daed1cd542..a0da4657f1 100644 --- a/storage/tianmu/core/aggregation_algorithm.cpp +++ b/storage/tianmu/core/aggregation_algorithm.cpp @@ -85,7 +85,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) { @@ -178,7 +178,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); } @@ -263,7 +263,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 be7cf455a1..cd874d40b7 100644 --- a/storage/tianmu/core/aggregator_advanced.cpp +++ b/storage/tianmu/core/aggregator_advanced.cpp @@ -204,7 +204,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 5ad65b50f5..2263899ee8 100644 --- a/storage/tianmu/core/blocked_mem_table.cpp +++ b/storage/tianmu/core/blocked_mem_table.cpp @@ -28,7 +28,7 @@ MemBlockManager::~MemBlockManager() { void *MemBlockManager::GetBlock() { DEBUG_ASSERT(block_size != -1); - if (hard_size_limit != -1 && hard_size_limit <= current_size) return NULL; + if (hard_size_limit != -1 && hard_size_limit <= current_size) return nullptr; { std::scoped_lock g(mx); @@ -58,7 +58,7 @@ int MemBlockManager::MemoryBlocksLeft() { } void MemBlockManager::FreeBlock(void *b) { - if (b == NULL) return; + if (b == nullptr) return; std::scoped_lock g(mx); size_t r = used_blocks.erase(b); if (r == 1) { @@ -101,7 +101,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; @@ -170,7 +170,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 b1613cd9c3..c59c90883f 100644 --- a/storage/tianmu/core/bloom_block.cpp +++ b/storage/tianmu/core/bloom_block.cpp @@ -188,7 +188,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 base_lg_ = contents[n - 1]; diff --git a/storage/tianmu/core/bloom_coding.cpp b/storage/tianmu/core/bloom_coding.cpp index 5b24f110bd..86bd6bfc8c 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,8 +183,8 @@ 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 + len > limit) return NULL; + if (p == nullptr) return nullptr; + if (p + len > limit) 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 cbf71a9320..9b7cf48df1 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 25fe5cd95e..24baa3083c 100644 --- a/storage/tianmu/core/cached_buffer.cpp +++ b/storage/tianmu/core/cached_buffer.cpp @@ -43,7 +43,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; } @@ -66,7 +66,7 @@ void CachedBuffer::Get(types::BString &s, uint64_t idx) { if (idx / page_size != loaded_page) 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 c77e6a30fe..d547b3d739 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 6886b9ff3a..e2a6180855 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; @@ -85,9 +85,9 @@ ColumnBinEncoder::~ColumnBinEncoder() { } bool ColumnBinEncoder::PrepareEncoder(vcolumn::VirtualColumn *_vc, vcolumn::VirtualColumn *_vc2) { - if (_vc == NULL) return false; + if (_vc == nullptr) return false; bool nulls_possible = false; - if (!ignore_nulls) nulls_possible = _vc->IsNullsPossible() || (_vc2 != NULL && _vc2->IsNullsPossible()); + if (!ignore_nulls) nulls_possible = _vc->IsNullsPossible() || (_vc2 != nullptr && _vc2->IsNullsPossible()); vc = _vc; ColumnType vct = vc->Type(); ColumnType vct2 = _vc2 ? _vc2->Type() : ColumnType(); @@ -104,11 +104,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; @@ -140,7 +140,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; @@ -416,7 +416,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) max_found = v; if (v < min_found) min_found = v; @@ -580,7 +580,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 // values @@ -665,7 +665,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 // values @@ -1020,14 +1020,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; } @@ -1039,7 +1039,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; } @@ -1140,7 +1140,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; @@ -1152,7 +1152,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 77636e29a2..d8839eb882 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; } @@ -98,7 +98,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), @@ -493,7 +493,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 2dd233ac44..848d27b942 100644 --- a/storage/tianmu/core/compilation_tools.cpp +++ b/storage/tianmu/core/compilation_tools.cpp @@ -107,9 +107,9 @@ Query_route_to OperationUnmysterify(Item *item, common::ColOperation &oper, bool 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; @@ -167,7 +167,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/compilation_tools.h b/storage/tianmu/core/compilation_tools.h index caaa4f3cd4..988ace666d 100644 --- a/storage/tianmu/core/compilation_tools.h +++ b/storage/tianmu/core/compilation_tools.h @@ -28,7 +28,7 @@ namespace Tianmu { namespace core { using Tianmu::common::ColOperation; -using Tianmu::DBHandler::Query_route_to; +using Tianmu::handler::Query_route_to; #define ASSERT_MYSQL_STRING(x) \ DEBUG_ASSERT(!x.str[x.length] && \ diff --git a/storage/tianmu/core/compiled_query.cpp b/storage/tianmu/core/compiled_query.cpp index 3419ea5ed4..4a8fb1c761 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"); @@ -585,13 +585,13 @@ 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) s.si = *si; + 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) steps_group_by_cols.push_back(s); diff --git a/storage/tianmu/core/compiled_query.h b/storage/tianmu/core/compiled_query.h index 749a3da5cc..39cdcff785 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 fe967dbb5b..9045ea3427 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 6847680dd4..03ac287d48 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() {} @@ -88,7 +88,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; @@ -191,7 +191,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)) { @@ -229,7 +229,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()) { @@ -369,7 +369,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; @@ -414,7 +414,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); @@ -428,7 +428,7 @@ void ConditionEncoder::TransformLIKEsIntoINsOnLookup() { res = attr->GetRealString(i).Like(pattern, desc->like_esc); 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) @@ -449,7 +449,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++) { @@ -457,7 +457,7 @@ void ConditionEncoder::TransformINsOnLookup() { if ((static_cast(desc->val1.vc))->Contains(mid, s) == true) 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) @@ -469,7 +469,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; @@ -534,11 +534,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); } } @@ -569,7 +569,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); @@ -651,7 +651,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); @@ -730,14 +730,14 @@ void ConditionEncoder::EncodeIfPossible(Descriptor &desc, bool for_rough_query, if (!desc.attr.vc || desc.attr.vc->GetDim() == -1) 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() || @@ -756,11 +756,11 @@ 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)) return; - if (vcec != NULL) { + if (vcec == nullptr && (vcsc == nullptr || vcsc->GetVarMap()[0].GetTabPtr()->TableType() != TType::TABLE)) return; + 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 == NULL || desc.val2.vc->IsConst())))); + (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) && @@ -800,7 +800,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 338f461a6f..f497834377 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 b3309fc134..1833b9381b 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 8a0c3d7354..e1fe3e92b6 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 376da95074..e4313cb82e 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; right_dims = desc.right_dims; @@ -120,7 +120,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), @@ -150,7 +150,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(); } @@ -164,7 +164,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), @@ -220,7 +220,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; right_dims = d.right_dims; @@ -344,8 +344,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())) return false; + // 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)) && (!val2.vc || (val2.vc && val2.vc->IsConst())); @@ -369,7 +369,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; @@ -378,10 +378,10 @@ 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) return false; + 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; } @@ -441,7 +441,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; if (IsType_OrTree()) { @@ -466,7 +466,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) Query::UnmarkAllAny(op); + 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()))) || (val2.vc && (!val2.vc->IsConst() || (in_having && val2.vc->IsParameterized())))) { @@ -676,8 +676,8 @@ const QueryOperator *Descriptor::CreateQueryOperator(common::Operator type) cons ">=", // 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 + "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 @@ -873,7 +873,7 @@ void Descriptor::UpdateVCStatistics() // Apply all the information from // constants etc. to involved VC { MEASURE_FET("Descriptor::UpdateVCStatistics(...)"); - if (attr.vc == NULL) return; + if (attr.vc == nullptr) return; if (op == common::Operator::O_IS_NULL) { attr.vc->SetLocalNullsOnly(true); return; @@ -960,7 +960,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 { @@ -1043,7 +1043,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)) @@ -1109,7 +1109,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)) @@ -1602,7 +1602,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())) @@ -1890,7 +1890,7 @@ DescTree::DescTree(CQTerm e1, common::Operator op, CQTerm e2, CQTerm e3, TempTab DescTree::DescTree(DescTree &t) { curr = root = Copy(t.root); } DescTreeNode *DescTree::Copy(DescTreeNode *node) { - if (!node) return NULL; + if (!node) return nullptr; DescTreeNode *res = new DescTreeNode(*node); if (node->left) { res->left = Copy(node->left); @@ -1910,7 +1910,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 @@ -1935,15 +1935,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) return; + if (node == nullptr) return; if (node->left) Display(node->left); if (node->right) Display(node->right); std::cout << "------------------------" << std::endl; @@ -2002,38 +2002,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); } } @@ -2307,7 +2307,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); @@ -2334,7 +2334,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); @@ -2364,8 +2364,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) return false; diff --git a/storage/tianmu/core/descriptor.h b/storage/tianmu/core/descriptor.h index 77fa7cafed..d3d2ffe065 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 339e58c060..532d782831 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) @@ -83,7 +83,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; } } @@ -112,7 +112,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; } @@ -171,7 +171,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(); } @@ -311,7 +311,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; @@ -321,7 +321,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) nulls_found[dim] = true; @@ -338,7 +338,7 @@ int DimensionGroupMaterialized::DGMaterializedIterator::GetNextPackrow(int dim, MEASURE_FET("DGMaterializedIterator::GetNextPackrow(int dim, int ahead)"); if (ahead == 0) return GetCurPackrow(dim); IndexTable *cur_t = t[dim]; - if (cur_t == NULL) return -1; + 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) return -1; uint64_t ahead_pos = 0; diff --git a/storage/tianmu/core/dimension_group.h b/storage/tianmu/core/dimension_group.h index 6444fe1349..45da8cafaf 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; @@ -339,7 +339,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(); @@ -396,7 +396,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) @@ -408,7 +408,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 d1f4633329..2ae523d2f4 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 e7b2109db0..cb91bdfebc 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; } } @@ -71,7 +71,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; } @@ -92,7 +92,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 f1d95b9661..f58050041e 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, @@ -151,7 +151,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 10521f6171..c3d9065e47 100644 --- a/storage/tianmu/core/engine.cpp +++ b/storage/tianmu/core/engine.cpp @@ -47,13 +47,13 @@ namespace Tianmu { -namespace DBHandler { +namespace handler { extern void resolve_async_join_settings(const std::string &settings); } namespace core { -using Tianmu::DBHandler::Query_route_to; +using Tianmu::handler::Query_route_to; #ifdef PROFILE_LOCK_WAITING LockProfiler lock_profiler; @@ -78,7 +78,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; } @@ -196,7 +196,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); @@ -300,7 +300,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; } @@ -904,8 +904,8 @@ void Engine::RemoveTx(Transaction *tx) { Transaction *Engine::CreateTx(THD *thd) { // the transaction should be created by owner THD - ASSERT(thd->get_ha_data(tianmu_hton->slot)->ha_ptr == NULL, "Nested transaction is not supported!"); // stonedb8 - ASSERT(current_txn_ == NULL, "Previous transaction is not finished!"); + ASSERT(thd->get_ha_data(tianmu_hton->slot)->ha_ptr == nullptr, "Nested transaction is not supported!"); // stonedb8 + ASSERT(current_txn_ == nullptr, "Previous transaction is not finished!"); current_txn_ = new Transaction(thd); thd->get_ha_data(tianmu_hton->slot)->ha_ptr = current_txn_; // stonedb8 @@ -927,7 +927,7 @@ void Engine::ClearTx(THD *thd) { RemoveTx(current_txn_); current_txn_ = nullptr; - thd->get_ha_data(tianmu_hton->slot)->ha_ptr = NULL; // stonedb8 + thd->get_ha_data(tianmu_hton->slot)->ha_ptr = nullptr; // stonedb8 } int Engine::SetUpCacheFolder(const std::string &cachefolder_path) { @@ -1160,7 +1160,7 @@ static void HandleDelayedLoad(int tid, std::vector> &vec // stonedb8 end 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); @@ -1610,13 +1610,13 @@ Query_route_to Engine::RouteTo(THD *thd, TABLE_LIST *table_list, Query_block *se } bool Engine::IsTianmuTable(TABLE *table) { - return table && table->s->db_type() == tianmu_hton; // table->db_type is always NULL + return table && table->s->db_type() == tianmu_hton; // table->db_type is always nullptr } const char *Engine::GetFilename(Query_block *selects_list, int &is_dumpfile) { // stonedb8 - // 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->result == nullptr) { @@ -1662,7 +1662,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) return CreateIOParameters("", arg); + if (table == nullptr) return CreateIOParameters("", arg); return CreateIOParameters(GetTablePath(table), arg); } @@ -1802,7 +1802,7 @@ common::TIANMUError Engine::GetIOParams(std::unique_ptr &i 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) { @@ -1814,7 +1814,7 @@ common::TIANMUError Engine::GetIOParams(std::unique_ptr &i 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()); @@ -1827,7 +1827,7 @@ common::TIANMUError Engine::GetIOParams(std::unique_ptr &i if (ex.line.line_term->alloced_length() != 0) 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()); @@ -2128,7 +2128,7 @@ Query_route_to Engine::Handle_Query(THD *thd, Query_expression *qe, Query_result // prepare, optimize and execute the main query se = dynamic_cast(result); - if (se != NULL) result = new exporter::select_tianmu_export(se); + if (se != nullptr) result = new exporter::select_tianmu_export(se); select_lex = lex->query_block; unit = lex->unit; @@ -2275,8 +2275,8 @@ Query_route_to Engine::Handle_Query(THD *thd, Query_expression *qe, Query_result Query_route_to Engine::Execute(THD *thd, LEX *lex, Query_result *result_output, Query_expression *unit_for_union) { DEBUG_ASSERT(thd->lex == lex); Query_block *selects_list = lex->query_block; - Query_block *last_distinct = NULL; - if (unit_for_union != NULL) last_distinct = unit_for_union->union_distinct; + Query_block *last_distinct = nullptr; + if (unit_for_union != nullptr) last_distinct = unit_for_union->union_distinct; int is_dumpfile = 0; const char *export_file_name = GetFilename(selects_list, is_dumpfile); @@ -2319,7 +2319,7 @@ Query_route_to Engine::Execute(THD *thd, LEX *lex, Query_result *result_output, 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(thd, unit_for_union->item_list, unit_for_union); // stonedb8 add thd if (res) { TIANMU_LOG(LogCtl_Level::ERROR, "Error: Unsupported UNION"); @@ -2340,7 +2340,7 @@ Query_route_to Engine::Execute(THD *thd, LEX *lex, Query_result *result_output, } 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 diff --git a/storage/tianmu/core/engine.h b/storage/tianmu/core/engine.h index a83e4a44bd..6ef74d9642 100644 --- a/storage/tianmu/core/engine.h +++ b/storage/tianmu/core/engine.h @@ -64,7 +64,7 @@ class select_tianmu_export; namespace core { -using Tianmu::DBHandler::Query_route_to; +using Tianmu::handler::Query_route_to; struct AttrInfo; class TableShare; class Transaction; @@ -176,7 +176,7 @@ class Engine final { static void ComputeTimeZoneDiffInMinutes(THD *thd, short &sign, short &minutes); static std::string GetTablePath(TABLE *table); static common::TIANMUError GetIOParams(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(); @@ -185,7 +185,7 @@ class Engine final { void RemoveTx(Transaction *tx); Query_route_to Execute(THD *thd, LEX *lex, Query_result *result_output, - Query_expression *unit_for_union = NULL); // stonedb8 + Query_expression *unit_for_union = nullptr); // stonedb8 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.ic b/storage/tianmu/core/engine.ic index edbe292f09..cd58e14cae 100644 --- a/storage/tianmu/core/engine.ic +++ b/storage/tianmu/core/engine.ic @@ -221,7 +221,7 @@ int Query_expression::optimize_for_tianmu(THD *thd) { /* Send result to 'result' */ saved_error = true; set_limit(thd, global_parameters()); // stonedb8 add thd - if (fake_query_block != NULL) { + if (fake_query_block != nullptr) { thd->lex->set_current_query_block(fake_query_block); if (!is_prepared()) { if (prepare_fake_query_block(thd)) return saved_error; @@ -237,7 +237,7 @@ int Query_expression::optimize_for_tianmu(THD *thd) { if (!join->is_optimized()) { // saved_error = join->prepare(fake_query_block->table_list.first, 0, 0, // global_parameters->order_list.elements, - // global_parameters->order_list.first, NULL, NULL, fake_query_block, + // global_parameters->order_list.first, nullptr, nullptr, fake_query_block, // this); //STONEDB UPGRADE if (!is_prepared()) { if (fake_query_block->prepare(thd, nullptr)) // stonedb8 add nullptr from m8 diff --git a/storage/tianmu/core/engine_convert.cpp b/storage/tianmu/core/engine_convert.cpp index c30e47ad2e..e0b2177f8f 100644 --- a/storage/tianmu/core/engine_convert.cpp +++ b/storage/tianmu/core/engine_convert.cpp @@ -55,7 +55,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 { @@ -147,7 +147,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 { @@ -170,21 +170,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_results.cpp b/storage/tianmu/core/engine_results.cpp index 6ed7c93cb2..4555a8ec71 100644 --- a/storage/tianmu/core/engine_results.cpp +++ b/storage/tianmu/core/engine_results.cpp @@ -187,11 +187,11 @@ inline static void SetFieldState(Field *field, bool is_null) { ResultSender::ResultSender(THD *thd, Query_result *res, mem_root_deque &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) { @@ -286,7 +286,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; @@ -296,7 +296,7 @@ void ResultSender::SendRecord(const std::vectorget_result_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; @@ -411,9 +411,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); @@ -432,9 +432,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); @@ -462,7 +462,7 @@ void ResultExportSender::Init(TempTable *t) { export_res->send_result_set_metadata(thd, fields, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF); - if ((tianmu_error = Engine::GetIOParams(iop, *thd, *export_res->SqlExchange(), 0, NULL, true)) != + if ((tianmu_error = Engine::GetIOParams(iop, *thd, *export_res->SqlExchange(), 0, nullptr, true)) != common::ErrorCode::SUCCESS) throw common::Exception("Unable to get IOP"); diff --git a/storage/tianmu/core/filter.cpp b/storage/tianmu/core/filter.cpp index 22a9faa577..a3dfddfa37 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), @@ -56,7 +56,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), @@ -86,7 +86,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) { @@ -105,7 +105,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); @@ -124,7 +124,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, @@ -165,13 +165,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; } } @@ -258,7 +258,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) throw common::OutOfMemoryException(); + if (blocks[b] == nullptr) throw common::OutOfMemoryException(); } if (make_mixed) { blocks[b]->Set(0, block_last_one[b]); // create a block with a contents before Set @@ -296,7 +296,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) throw common::OutOfMemoryException(); + if (blocks[b1] == nullptr) throw common::OutOfMemoryException(); if (block_status[b1] == FB_FULL) blocks[b1]->Set(0, block_last_one[b1]); // create a block with a contents before Set @@ -359,12 +359,12 @@ 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) throw common::OutOfMemoryException(); + 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) throw common::OutOfMemoryException(); + if (blocks[b1] == nullptr) throw common::OutOfMemoryException(); blocks[b1]->Set(0, block_last_one[b1]); // create a block with a // contents before Reset } @@ -510,7 +510,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], @@ -523,7 +523,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); } @@ -534,7 +534,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) { @@ -813,7 +813,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)); @@ -832,7 +832,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 84f652da77..674d4dae2b 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) throw common::OutOfMemoryException(); + if (blocks[b] == nullptr) throw common::OutOfMemoryException(); } } if (blocks[b]) { diff --git a/storage/tianmu/core/filter_block.cpp b/storage/tianmu/core/filter_block.cpp index 474d53f78c..1349844904 100644 --- a/storage/tianmu/core/filter_block.cpp +++ b/storage/tianmu/core/filter_block.cpp @@ -106,7 +106,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 fd66162096..7d2c15d6b5 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; @@ -334,7 +334,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 11f11f7aac..5b3f30e45c 100644 --- a/storage/tianmu/core/ftree.cpp +++ b/storage/tianmu/core/ftree.cpp @@ -64,22 +64,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; } } @@ -101,11 +101,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) return -1; + if (mem == nullptr) return -1; int local_last_code = last_code; // for multithread safety if (local_last_code > -1 && sz == len[local_last_code] && @@ -122,8 +122,8 @@ void FTree::Init(int width) { total_buf_size = hdr.max_len * 10 + 10; if (mem) dealloc(mem); mem = (char *)alloc(total_buf_size, mm::BLOCK_TYPE::BLOCK_TEMPORARY); - if (len == NULL) len = (uint16_t *)alloc(total_dic_size * sizeof(uint16_t), mm::BLOCK_TYPE::BLOCK_TEMPORARY, true); - if (value_offset == NULL) + if (len == nullptr) len = (uint16_t *)alloc(total_dic_size * sizeof(uint16_t), mm::BLOCK_TYPE::BLOCK_TEMPORARY, true); + 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); @@ -149,7 +149,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) throw common::OutOfMemoryException("Too many lookup values"); + 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; value_offset[i] = common::NULL_VALUE_32; @@ -283,7 +283,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) throw common::OutOfMemoryException("Too many lookup values"); + if (hash_table == nullptr) throw common::OutOfMemoryException("Too many lookup values"); std::memset(hash_table, 0xFF, hash_size * sizeof(int)); // set -1 for all positions @@ -291,7 +291,7 @@ void FTree::InitHash() { } int FTree::HashFind(const char *v, int v_len, int position_if_not_found) { - if (hash_table == NULL) InitHash(); + 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; int step = 3 + crc_code % 8; // step: 3, 4, 5, 6, 7, 8, 9, 10 => hash_size diff --git a/storage/tianmu/core/group_distinct_cache.cpp b/storage/tianmu/core/group_distinct_cache.cpp index 8ceb445e53..de5349ac30 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() { @@ -61,10 +61,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); } @@ -82,11 +82,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; @@ -98,7 +98,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 @@ -115,7 +115,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 @@ -128,7 +128,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; @@ -166,7 +166,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 00731483e6..82428b7362 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 a2199a91e9..b786393d75 100644 --- a/storage/tianmu/core/group_distinct_table.cpp +++ b/storage/tianmu/core/group_distinct_table.cpp @@ -23,8 +23,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), @@ -35,10 +35,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; } @@ -174,7 +174,7 @@ GDTResult GroupDistinctTable::Add(int64_t group, MIIterator &mit) { } group += 1; // offset; 0 means empty position std::memmove(input_buffer, (unsigned char *)(&group), group_bytes); - encoder->Encode(input_buffer + group_bytes, mit, NULL, true); + encoder->Encode(input_buffer + group_bytes, mit, nullptr, true); return FindCurrentRow(); } diff --git a/storage/tianmu/core/group_table.h b/storage/tianmu/core/group_table.h index e572b0b895..fc9920d81e 100644 --- a/storage/tianmu/core/group_table.h +++ b/storage/tianmu/core/group_table.h @@ -178,7 +178,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 39743a51de..ee26fea7d6 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() { @@ -91,7 +91,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 distinct_watch.Initialize(no_attr); @@ -160,17 +160,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 { @@ -410,7 +410,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); @@ -432,7 +432,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 @@ -463,7 +463,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 @@ -571,7 +571,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); } @@ -588,14 +588,14 @@ 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; for (int i = 0; i < no_attr; i++) { // function should return true for e.g.: "SELECT 1, 2, // '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; @@ -634,18 +634,18 @@ bool GroupByWrapper::IsMaxOnly() // true, if an attribute is max(column), and } void GroupByWrapper::InitTupleLeft(int64_t n) { - 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) return true; + 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) return to - from + 1; + if (tuple_left == nullptr) return to - from + 1; return tuple_left->NumOfOnesBetween(from, to); } @@ -684,7 +684,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 aaffb51be2..30091a48d2 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) tuple_left->Commit(); @@ -161,8 +161,8 @@ class GroupByWrapper final { void TuplesReset(int64_t pos) { 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 422700b0fa..ea0cbfd4d8 100644 --- a/storage/tianmu/core/index_table.cpp +++ b/storage/tianmu/core/index_table.cpp @@ -101,7 +101,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)."); @@ -109,7 +109,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 1e1d3228bb..a631aa1721 100644 --- a/storage/tianmu/core/index_table.h +++ b/storage/tianmu/core/index_table.h @@ -102,7 +102,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 ) @@ -124,7 +124,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 af56bc143a..78e3512c54 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 bf64f6032f..e4c2ff2d4a 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 c2d82fa65b..539ee04c10 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 605df1da0d..e2b142367a 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 @@ -186,13 +186,13 @@ 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 @@ -222,11 +222,11 @@ void JoinerSort::ExecuteJoinConditions(Condition &cond) { dims_used_in_cond); // Add all tuples from current cache 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) break; + if (cur_matched == nullptr && !cache_full) break; if (tips.limit > -1 && result_size >= tips.limit) break; if (new_mind.NoMoreTuplesPossible()) break; // stop the join if nothing new may be obtained in some optimized @@ -326,19 +326,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; } @@ -396,7 +396,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]; } @@ -405,7 +405,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) { @@ -418,7 +418,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 { @@ -451,7 +451,7 @@ bool JoinerSortWrapper::PackPossible(vcolumn::VirtualColumn *v, MIIterator &mit) // needed, we are encoding values as for decreasing order. Assuming v is // "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; @@ -494,7 +494,7 @@ void JoinerSortWrapper::InitCache(int64_t no_of_rows) { if (cache_bytes * cache_size > max_mem_size) cache_size = max_mem_size / cache_bytes; } cache = (unsigned char *)alloc(cache_bytes * cache_size, mm::BLOCK_TYPE::BLOCK_TEMPORARY); - if (cache == NULL) throw common::OutOfMemoryException(); + if (cache == nullptr) throw common::OutOfMemoryException(); } } diff --git a/storage/tianmu/core/joiner_sort.h b/storage/tianmu/core/joiner_sort.h index 1a195662ac..3b57e20fb0 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 c5d93f9f49..b3129397e9 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 4f028a783e..63b76ff2de 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), @@ -155,7 +155,7 @@ MIIterator::MIIterator(const MIIterator &sec, bool lock) if (dimensions[i]) 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]); @@ -413,7 +413,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 029ba2c8d5..c6a50cd982 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 f3fda5ca79..135ccd81cc 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,13 +34,13 @@ 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; @@ -78,7 +78,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) @@ -95,7 +95,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; } @@ -110,7 +110,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) { InitTnew(dim, initial_size); @@ -120,7 +120,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(); @@ -168,7 +168,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; } } @@ -179,7 +179,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); @@ -191,14 +191,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 { @@ -216,7 +216,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 } } } @@ -230,13 +230,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(); @@ -244,7 +244,7 @@ void MINewContents::DisableOptimized() { } } delete f_opt; - f_opt = NULL; + f_opt = nullptr; optimized_dim_stay = -1; content_type = enumMINCType::MCT_MATERIAL; } @@ -255,7 +255,7 @@ bool MINewContents::CommitPack(int pack) // in case of single filter as a resul if (content_type != enumMINCType::MCT_FILTER_FORGET) return false; Filter *orig_filter = mind->GetFilter(optimized_dim_stay); f_opt->Commit(); - if (!f_opt->IsEmpty(pack) || orig_filter == NULL) return false; + 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 ea0326a34e..d49574d6e2 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 0a9df46626..1ee0d73bb7 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 73d6c1ab5f..80e27be6a8 100644 --- a/storage/tianmu/core/mi_rough_sorter.h +++ b/storage/tianmu/core/mi_rough_sorter.h @@ -148,7 +148,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 8ff4eaa4df..397287f74d 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; } @@ -57,9 +57,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; } @@ -81,9 +81,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; } @@ -91,7 +91,7 @@ MultiIndex::MultiIndex(MultiIndex &s, bool shallow) : m_conn(s.m_conn) { MultiIndex::~MultiIndex() { for (uint i = 0; i < dim_groups.size(); i++) { delete dim_groups[i]; - dim_groups[i] = NULL; + dim_groups[i] = nullptr; } delete[] dim_size; delete[] group_for_dim; @@ -102,7 +102,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"); @@ -114,9 +114,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(); @@ -126,11 +126,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; } @@ -138,7 +138,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; } @@ -184,7 +184,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): @@ -201,7 +201,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 @@ -268,16 +268,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); @@ -289,8 +289,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 ad343ab30f..0e70d7bd09 100644 --- a/storage/tianmu/core/multi_index.h +++ b/storage/tianmu/core/multi_index.h @@ -59,15 +59,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 50da48a1d4..5021fda5a1 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; if (toplevel && !HandledResultType(item)) return false; @@ -109,10 +109,10 @@ bool MysqlExpression::SanityAggregationCheck(Item *item, std::set &field fields.insert(item); return true; case Item::FUNC_ITEM: { - if (dynamic_cast(item) != NULL) return false; + 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; return true; @@ -161,7 +161,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); @@ -496,7 +496,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; int err; @@ -519,7 +519,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 819c5b2057..17d47f8588 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 ff7458c519..58e231853c 100644 --- a/storage/tianmu/core/pack.cpp +++ b/storage/tianmu/core/pack.cpp @@ -27,7 +27,7 @@ Pack::Pack(DPN *dpn, PackCoordinate pc, ColumnShare *s) : s(s), dpn(dpn) { NULLS_SIZE = (1 << s->pss) / 8; nulls = std::make_unique(NULLS_SIZE / 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 2d9fea280d..7bef8caaea 100644 --- a/storage/tianmu/core/pack_int.cpp +++ b/storage/tianmu/core/pack_int.cpp @@ -637,7 +637,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 14a4ae571d..7be0a981b8 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 ba6db04dbf..cd8a233865 100644 --- a/storage/tianmu/core/parameterized_filter.cpp +++ b/storage/tianmu/core/parameterized_filter.cpp @@ -135,7 +135,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); @@ -170,7 +170,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 @@ -798,7 +798,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; @@ -814,7 +814,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; @@ -904,7 +904,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) additional_nulls_possible = true; + if (all_dims[d] && mind->GetFilter(d) == nullptr) additional_nulls_possible = true; if (descriptors[i].IsOuter()) additional_nulls_possible = true; ConditionEncoder::EncodeIfPossible(descriptors[i], for_rough_query, additional_nulls_possible); @@ -1261,7 +1261,7 @@ void ParameterizedFilter::ApplyDescriptor(int desc_number, int64_t limit) if (no_dims == 0 && !desc.IsDeterministic()) 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 5529b58c81..38f41a6b26 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 + 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 NULL) - virtual int64_t RoughMax(Filter *f = NULL, - common::RSValue *rf = NULL) = 0; // for numerical: best + // 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 NULL) - virtual void GetTextStat(types::TextStat &s, [[maybe_unused]] Filter *f = NULL) { s.Invalidate(); } + // 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 0f6c9b4226..721c0b5521 100644 --- a/storage/tianmu/core/query.cpp +++ b/storage/tianmu/core/query.cpp @@ -237,21 +237,21 @@ 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, NULL); + 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()); } case Item::STRING_ITEM: { - String s(buf, 256, NULL); + 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"; @@ -436,7 +436,7 @@ void Query::ExtractOperatorType(Item *&conds, common::Operator &op, bool &negati break; case Item_func::NOT_ALL_FUNC: { Item_func *cond_func = (Item_func *)conds; - negative = dynamic_cast(cond_func) == NULL; + negative = dynamic_cast(cond_func) == nullptr; ExtractOperatorType(cond_func->arguments()[0], op, negative, like_esc); if (dynamic_cast(cond_func)) MarkWithAny(op); @@ -458,7 +458,7 @@ vcolumn::VirtualColumn *Query::CreateColumnFromExpression(std::vector 0); - vcolumn::VirtualColumn *vc = NULL; + vcolumn::VirtualColumn *vc = nullptr; if (exprs.size() == 1) { bool is_const_expr = vcolumn::VirtualColumn::IsConstExpression(exprs[0], temp_table_alias, &temp_table->GetAliases()); @@ -524,7 +524,7 @@ bool Query::IsParameterFromWhere(const TabID ¶ms_table) { } const char *Query::GetTableName(Item_field *ifield) { - const char *table_name = NULL; + const char *table_name = nullptr; if (ifield->cached_table && !ifield->cached_table->is_view() && !ifield->cached_table->is_view_or_derived()) // TIANMU UPGRADE if (ifield->cached_table->referencing_view) @@ -565,7 +565,7 @@ TempTable *Query::Preexecute(CompiledQuery &qu, ResultSender *sender, [[maybe_un } std::vector conds(qu.NumOfConds()); - TempTable *output_table = NULL; // NOTE: this pointer will be returned by the function + TempTable *output_table = nullptr; // NOTE: this pointer will be returned by the function ta.resize(qu.NumOfTabs()); auto global_limits = qu.GetGlobalLimit(); @@ -625,13 +625,13 @@ TempTable *Query::Preexecute(CompiledQuery &qu, ResultSender *sender, [[maybe_un DEBUG_ASSERT(step.t1.n < 0); step.e1.vc = (step.e1.vc_id != common::NULL_VALUE_32) ? ((TempTable *)ta[-step.t1.n - 1].get())->GetVirtualColumn(step.e1.vc_id) - : NULL; + : nullptr; step.e2.vc = (step.e2.vc_id != common::NULL_VALUE_32) ? ((TempTable *)ta[-step.t1.n - 1].get())->GetVirtualColumn(step.e2.vc_id) - : NULL; + : nullptr; step.e3.vc = (step.e3.vc_id != common::NULL_VALUE_32) ? ((TempTable *)ta[-step.t1.n - 1].get())->GetVirtualColumn(step.e3.vc_id) - : NULL; + : nullptr; if (step.n1 != static_cast(CondType::OR_SUBTREE)) { // on result = false conds[step.c1.n] = new Condition(); if (step.c2.IsNull()) { @@ -700,13 +700,13 @@ TempTable *Query::Preexecute(CompiledQuery &qu, ResultSender *sender, [[maybe_un : common::LogicalOperator::O_OR); step.e1.vc = (step.e1.vc_id != common::NULL_VALUE_32) ? ((TempTable *)ta[-step.t1.n - 1].get())->GetVirtualColumn(step.e1.vc_id) - : NULL; + : nullptr; step.e2.vc = (step.e2.vc_id != common::NULL_VALUE_32) ? ((TempTable *)ta[-step.t1.n - 1].get())->GetVirtualColumn(step.e2.vc_id) - : NULL; + : nullptr; step.e3.vc = (step.e3.vc_id != common::NULL_VALUE_32) ? ((TempTable *)ta[-step.t1.n - 1].get())->GetVirtualColumn(step.e3.vc_id) - : NULL; + : nullptr; if (!conds[step.c1.n]->IsType_Tree()) { DEBUG_ASSERT(conds[step.c1.n]); conds[step.c1.n]->AddDescriptor( @@ -855,17 +855,17 @@ TempTable *Query::Preexecute(CompiledQuery &qu, ResultSender *sender, [[maybe_un ta[-step.t1.n - 1] = TempTable::Create(*(TempTable *)ta[-step.t2.n - 1].get(), false); if (IsRoughQuery()) { if (step.t3.n == common::NULL_VALUE_32) - ((TempTable *)ta[-step.t1.n - 1].get())->RoughUnion(NULL, qu.IsResultTable(step.t1) ? sender : NULL); + ((TempTable *)ta[-step.t1.n - 1].get())->RoughUnion(nullptr, qu.IsResultTable(step.t1) ? sender : nullptr); else ((TempTable *)ta[-step.t1.n - 1].get()) - ->RoughUnion((TempTable *)ta[-step.t3.n - 1].get(), qu.IsResultTable(step.t1) ? sender : NULL); + ->RoughUnion((TempTable *)ta[-step.t3.n - 1].get(), qu.IsResultTable(step.t1) ? sender : nullptr); } else if (qu.IsResultTable(step.t1) && !qu.IsOrderedBy(step.t1) && step.n1) ((TempTable *)ta[-step.t1.n - 1].get()) ->Union((TempTable *)ta[-step.t3.n - 1].get(), (int)step.n1, sender, global_limits.first, global_limits.second); else { if (step.t3.n == common::NULL_VALUE_32) - ((TempTable *)ta[-step.t1.n - 1].get())->Union(NULL, (int)step.n1); + ((TempTable *)ta[-step.t1.n - 1].get())->Union(nullptr, (int)step.n1); else { ((TempTable *)ta[-step.t1.n - 1].get())->Union((TempTable *)ta[-step.t3.n - 1].get(), (int)step.n1); ta[-step.t3.n - 1].reset(); @@ -907,14 +907,14 @@ Query_route_to Query::Item2CQTerm(Item *an_arg, CQTerm &term, const TabID &tmp_t DEBUG_ASSERT(item_subs && "The cast to (Item_subselect*) was unsuccessful"); bool ignore_limit = false; - if (dynamic_cast(item_subs) != NULL || - dynamic_cast(item_subs) != NULL) + if (dynamic_cast(item_subs) != nullptr || + dynamic_cast(item_subs) != nullptr) ignore_limit = true; Query_expression *select_unit = item_subs->unit; // needs to check if we can relay on subquery transformation to min/max - bool ignore_minmax = (dynamic_cast(item_subs) == NULL && - dynamic_cast(item_subs) == NULL && negative && + bool ignore_minmax = (dynamic_cast(item_subs) == nullptr && + dynamic_cast(item_subs) == nullptr && negative && item_subs->substype() == Item_subselect::SINGLEROW_SUBS); subqueries_in_where.emplace_back(tmp_table, item_subs->place() != CTX_HAVING && filter_type != CondType::HAVING_COND); @@ -939,15 +939,15 @@ Query_route_to Query::Item2CQTerm(Item *an_arg, CQTerm &term, const TabID &tmp_t tab_id2subselect.insert(std::make_pair(tmp_table, std::make_pair(vc.n, subselect))); } if (oper_for_subselect) { - if (dynamic_cast(item_subs) != NULL || - dynamic_cast(item_subs) != NULL) { + if (dynamic_cast(item_subs) != nullptr || + dynamic_cast(item_subs) != nullptr) { if (negative) { MarkWithAll(*oper_for_subselect); - if (dynamic_cast(item_subs) != NULL && *oper_for_subselect == common::Operator::O_IN) + if (dynamic_cast(item_subs) != nullptr && *oper_for_subselect == common::Operator::O_IN) *oper_for_subselect = common::Operator::O_EQ_ALL; } else { MarkWithAny(*oper_for_subselect); - if (dynamic_cast(item_subs) != NULL && + if (dynamic_cast(item_subs) != nullptr && dynamic_cast(item_subs)->all == 1) *oper_for_subselect = common::Operator::O_EQ_ALL; } @@ -991,7 +991,7 @@ Query_route_to Query::Item2CQTerm(Item *an_arg, CQTerm &term, const TabID &tmp_t AttrID at; at.n = GetAddColumnId(AttrID(common::NULL_VALUE_32), tmp_table, common::ColOperation::COUNT, false); if (at.n == common::NULL_VALUE_32) // doesn't exist yet - cq->AddColumn(at, tmp_table, CQTerm(), common::ColOperation::COUNT, NULL, false); + cq->AddColumn(at, tmp_table, CQTerm(), common::ColOperation::COUNT, nullptr, false); auto phys_vc = VirtualColumnAlreadyExists(tmp_table, tmp_table, at); if (phys_vc.first == common::NULL_VALUE_32) { phys_vc.first = tmp_table.n; @@ -1005,7 +1005,7 @@ Query_route_to Query::Item2CQTerm(Item *an_arg, CQTerm &term, const TabID &tmp_t if (!an_arg->null_value) { if (an_arg->max_length <= 8) { Item *int_item = new Item_int((ulonglong)an_arg->val_int()); - MysqlExpression *mysql_expression = NULL; + MysqlExpression *mysql_expression = nullptr; MysqlExpression::Item2VarID item2varid; gc_expressions.push_back(mysql_expression = new MysqlExpression(int_item, item2varid)); vc.n = VirtualColumnAlreadyExists(tmp_table, mysql_expression); @@ -1045,7 +1045,7 @@ Query_route_to Query::Item2CQTerm(Item *an_arg, CQTerm &term, const TabID &tmp_t // int col_num = // AddColumnForMysqlExpression(expr, // tmp_table, - // NULL, DELAYED, distinct, true); + // nullptr, DELAYED, distinct, true); vc.n = VirtualColumnAlreadyExists(tmp_table, expr); if (vc.n == common::NULL_VALUE_32) { cq->CreateVirtualColumn(vc, tmp_table, expr, tmp_table); @@ -1076,7 +1076,7 @@ Query_route_to Query::Item2CQTerm(Item *an_arg, CQTerm &term, const TabID &tmp_t if (!an_arg->null_value) { if (an_arg->max_length <= 8) { Item *int_item = new Item_int((ulonglong)an_arg->val_int()); - MysqlExpression *mysql_expression = NULL; + MysqlExpression *mysql_expression = nullptr; MysqlExpression::Item2VarID item2varid; gc_expressions.push_back(mysql_expression = new MysqlExpression(int_item, item2varid)); vc.n = VirtualColumnAlreadyExists(tmp_table, mysql_expression); @@ -1186,7 +1186,7 @@ CondID Query::ConditionNumberFromComparison(Item *conds, const TabID &tmp_table, common::Operator::O_IS_NULL, common::Operator::O_NOT_NULL, common::Operator::O_BETWEEN, common::Operator::O_LIKE, common::Operator::O_IN, common::Operator::O_ESCAPE etc...};*/ char like_esc; - Item_in_optimizer *in_opt = NULL; // set if IN expression with subselect + Item_in_optimizer *in_opt = nullptr; // set if IN expression with subselect ExtractOperatorType(conds, op, negative, like_esc); Item_func *cond_func = (Item_func *)conds; @@ -1194,17 +1194,17 @@ CondID Query::ConditionNumberFromComparison(Item *conds, const TabID &tmp_table, return ConditionNumberFromMultipleEquality((Item_equal *)conds, tmp_table, filter_type, and_me_filter, is_or_subtree); else if (op == common::Operator::O_NOT_FUNC) { - if (cond_func->arg_count != 1 || dynamic_cast(cond_func->arguments()[0]) == NULL) + if (cond_func->arg_count != 1 || dynamic_cast(cond_func->arguments()[0]) == nullptr) return CondID(-2); return ConditionNumberFromComparison(cond_func->arguments()[0], tmp_table, filter_type, and_me_filter, is_or_subtree, true); } else if (op == common::Operator::O_NOT_ALL_FUNC) { if (cond_func->arg_count != 1) return CondID(-1); return ConditionNumberFromComparison(cond_func->arguments()[0], tmp_table, filter_type, and_me_filter, - is_or_subtree, dynamic_cast(cond_func) == NULL); + is_or_subtree, dynamic_cast(cond_func) == nullptr); } else if (op == common::Operator::O_UNKNOWN_FUNC) { in_opt = dynamic_cast(cond_func); - if (in_opt == NULL || cond_func->arg_count != 2 || in_opt->arguments()[0]->cols() != 1) return CondID(-2); + if (in_opt == nullptr || cond_func->arg_count != 2 || in_opt->arguments()[0]->cols() != 1) return CondID(-2); op = common::Operator::O_IN; } else if (op == common::Operator::O_ERROR) return CondID(-2); // unknown function type @@ -1298,13 +1298,13 @@ CondID Query::ConditionNumberFromComparison(Item *conds, const TabID &tmp_table, } else { CQTerm t; if (Item2CQTerm(an_arg, t, tmp_table, filter_type, an_arg->type() == Item::SUBSELECT_ITEM ? negative : false, - NULL, &op) == Query_route_to::TO_MYSQL) + nullptr, &op) == Query_route_to::TO_MYSQL) return CondID(-1); vcs.push_back(t.vc_id); } } else { if (Item2CQTerm(an_arg, terms[i], tmp_table, filter_type, - an_arg->type() == Item::SUBSELECT_ITEM ? negative : false, NULL, &op) == Query_route_to::TO_MYSQL) + an_arg->type() == Item::SUBSELECT_ITEM ? negative : false, nullptr, &op) == Query_route_to::TO_MYSQL) return CondID(-1); if ((op == common::Operator::O_LIKE || op == common::Operator::O_NOT_LIKE) && !(an_arg->data_type() == MYSQL_TYPE_VARCHAR || an_arg->data_type() == MYSQL_TYPE_STRING || @@ -1342,7 +1342,7 @@ CondID Query::ConditionNumberFromNaked(Item *conds, const TabID &tmp_table, Cond CondID filter; CQTerm naked_col; if (Item2CQTerm(conds, naked_col, tmp_table, filter_type, - conds->type() == Item::SUBSELECT_ITEM ? (and_me_filter != NULL) : false) == Query_route_to::TO_MYSQL) + conds->type() == Item::SUBSELECT_ITEM ? (and_me_filter != nullptr) : false) == Query_route_to::TO_MYSQL) return CondID(-1); bool is_string = conds->result_type() == STRING_RESULT; @@ -1354,7 +1354,7 @@ CondID Query::ConditionNumberFromNaked(Item *conds, const TabID &tmp_table, Cond else zero_item = new Item_int((longlong)0); - MysqlExpression *mysql_expression = NULL; + MysqlExpression *mysql_expression = nullptr; gc_expressions.push_back(mysql_expression = new MysqlExpression(zero_item, item2varid)); // TODO: where mysql_expression & zero_item is destroyed ??? vc.n = VirtualColumnAlreadyExists(tmp_table, mysql_expression); @@ -1466,7 +1466,7 @@ CondID Query::ConditionNumber(Item *conds, const TabID &tmp_table, CondType filt if (and_me_filter && !create_or_subtree) { cq->And(*and_me_filter, tmp_table, terms[0], common::Operator::O_IN, terms[1], CQTerm()); c_id = *and_me_filter; - and_me_filter = NULL; + and_me_filter = nullptr; } else cq->CreateConds(c_id, tmp_table, terms[0], common::Operator::O_IN, terms[1], CQTerm(), create_or_subtree || filter_type == CondType::HAVING_COND); @@ -1481,7 +1481,7 @@ CondID Query::ConditionNumber(Item *conds, const TabID &tmp_table, CondType filt if (and_me_filter && !create_or_subtree) { cq->And(*and_me_filter, tmp_table, terms[0], common::Operator::O_EQ, terms[1], CQTerm()); c_id = *and_me_filter; - and_me_filter = NULL; + and_me_filter = nullptr; } else cq->CreateConds(c_id, tmp_table, terms[0], common::Operator::O_EQ, terms[1], CQTerm(), create_or_subtree || filter_type == CondType::HAVING_COND); @@ -1514,9 +1514,9 @@ CondID Query::ConditionNumber(Item *conds, const TabID &tmp_table, CondType filt } else if (cond_type == Item::FUNC_ITEM) { Item_func *cond_func = (Item_func *)conds; Item_func::Functype func_type = cond_func->functype(); - Item *arg = NULL; + Item *arg = nullptr; if (cond_func->arg_count == 1) arg = cond_func->arguments()[0]; - if (func_type == Item_func::NOT_FUNC && arg != NULL && arg->type() == Item::SUBSELECT_ITEM && + if (func_type == Item_func::NOT_FUNC && arg != nullptr && arg->type() == Item::SUBSELECT_ITEM && ((Item_subselect *)arg)->substype() == Item_subselect::EXISTS_SUBS) { CQTerm term; if (Item2CQTerm(arg, term, tmp_table, filter_type) == Query_route_to::TO_MYSQL) return CondID(-1); @@ -1597,8 +1597,8 @@ Query_route_to Query::BuildConditions(Item *conds, CondID &cond_id, CompiledQuer bool Query::ClearSubselectTransformation(common::Operator &oper_for_subselect, Item *&field_for_subselect, Item *&conds, Item *&having, Item *&cond_to_reinsert, List *&list_to_reinsert, Item *left_expr_for_subselect) { - cond_to_reinsert = NULL; - list_to_reinsert = NULL; + cond_to_reinsert = nullptr; + list_to_reinsert = nullptr; Item *cond_removed; if (having && (having->type() == Item::COND_ITEM || @@ -1613,7 +1613,7 @@ bool Query::ClearSubselectTransformation(common::Operator &oper_for_subselect, I // the extra condition is in the last argument if (having_cond->argument_list()->elements < 2) return false; List_iterator li(*(having_cond->argument_list())); - while (li++ != NULL) cond_to_reinsert = *li.ref(); + while (li++ != nullptr) cond_to_reinsert = *li.ref(); li.rewind(); while (*li.ref() != cond_to_reinsert) li++; li.remove(); @@ -1622,7 +1622,7 @@ bool Query::ClearSubselectTransformation(common::Operator &oper_for_subselect, I } else { // if no complex boolean formula the original condition was empty cond_removed = having; - having = NULL; + having = nullptr; } cond_removed = UnRef(cond_removed); // check if the extra condition was wrapped into trigger @@ -1634,8 +1634,8 @@ bool Query::ClearSubselectTransformation(common::Operator &oper_for_subselect, I // check if the extra condition is a comparison if (cond_removed->type() != Item::FUNC_ITEM || ((Item_func *)cond_removed)->arg_count != 2) return false; // the right side of equality is the field of the original subselect - if (dynamic_cast(((Item_func *)cond_removed)->arguments()[1]) == NULL) return false; - field_for_subselect = NULL; + if (dynamic_cast(((Item_func *)cond_removed)->arguments()[1]) == nullptr) return false; + field_for_subselect = nullptr; } else if (!having || (having->type() == Item::FUNC_ITEM && (((Item_func *)having)->functype() == Item_func::ISNOTNULLTEST_FUNC || ((Item_func *)having)->functype() == Item_func::TRIG_COND_FUNC))) { @@ -1645,7 +1645,7 @@ bool Query::ClearSubselectTransformation(common::Operator &oper_for_subselect, I // the extra condition should be in the last argument if (((Item_cond *)conds)->argument_list()->elements < 2) return false; List_iterator li(*(((Item_cond *)conds)->argument_list())); - while (li++ != NULL) cond_to_reinsert = *li.ref(); + while (li++ != nullptr) cond_to_reinsert = *li.ref(); li.rewind(); while (*li.ref() != cond_to_reinsert) li++; li.remove(); @@ -1654,7 +1654,7 @@ bool Query::ClearSubselectTransformation(common::Operator &oper_for_subselect, I } else { // if no conjunctive formula the original condition was empty cond_removed = conds; - conds = NULL; + conds = nullptr; } if (cond_removed->type() == Item::FUNC_ITEM && ((Item_func *)cond_removed)->functype() == Item_func::TRIG_COND_FUNC) { @@ -1663,15 +1663,15 @@ bool Query::ClearSubselectTransformation(common::Operator &oper_for_subselect, I } if (cond_removed->type() == Item::COND_ITEM && ((Item_func *)cond_removed)->functype() == Item_func::COND_OR_FUNC) { // if the subselect field could have null values - // equality condition was OR-ed with IS NULL condition + // equality condition was OR-ed with IS nullptr condition Item_cond *cond_cond = (Item_cond *)cond_removed; List_iterator_fast li(*(cond_cond->argument_list())); cond_removed = li++; - if (cond_removed == NULL) return false; - if (li++ == NULL) return false; - if (li++ != NULL) return false; + if (cond_removed == nullptr) return false; + if (li++ == nullptr) return false; + if (li++ != nullptr) return false; // the original having was empty - having = NULL; + having = nullptr; } // check if the extra condition is a comparison if (cond_removed->type() != Item::FUNC_ITEM || ((Item_func *)cond_removed)->arg_count != 2) return false; @@ -1682,7 +1682,7 @@ bool Query::ClearSubselectTransformation(common::Operator &oper_for_subselect, I // the left side of equality should be the left side of the original // expression with subselect Item *left_ref = ((Item_func *)cond_removed)->arguments()[0]; - if (dynamic_cast(left_ref) != NULL) left_ref = ((Item_int_with_ref *)left_ref)->real_item(); + if (dynamic_cast(left_ref) != nullptr) left_ref = ((Item_int_with_ref *)left_ref)->real_item(); if (left_ref->type() != Item::REF_ITEM || /*((Item_ref *)left_ref)->ref_type() != Item_ref::DIRECT_REF ||*/ // stonedb8 DIRECT_REF is deleted ((Item_ref *)left_ref)->real_item() != left_expr_for_subselect) @@ -1791,13 +1791,13 @@ Table_Status Query::PrefixCheck(Item *conds) { } case Item::FIELD_ITEM: // regular select case Item::SUM_FUNC_ITEM: { // min(k), max(k), count(), avg(k), sum - const char *field_alias = NULL; - const char *table_alias = NULL; - const char *database_name = NULL; - const char *table_name = NULL; - const char *table_path = NULL; - const TABLE *table_ptr = NULL; - const char *field_name = NULL; + const char *field_alias = nullptr; + const char *table_alias = nullptr; + const char *database_name = nullptr; + const char *table_name = nullptr; + const char *table_path = nullptr; + const TABLE *table_ptr = nullptr; + const char *field_name = nullptr; if (FieldUnmysterify(conds, database_name, table_name, table_alias, table_path, table_ptr, field_name, field_alias) == Query_route_to::TO_MYSQL) return Table_Status::TABLE_YET_UNSEEN_INVOLVED; diff --git a/storage/tianmu/core/query.h b/storage/tianmu/core/query.h index 713789aa97..9e39999724 100644 --- a/storage/tianmu/core/query.h +++ b/storage/tianmu/core/query.h @@ -27,7 +27,7 @@ namespace Tianmu { namespace core { -using Tianmu::DBHandler::Query_route_to; +using Tianmu::handler::Query_route_to; class CompiledQuery; class MysqlExpression; @@ -64,8 +64,8 @@ class Query final { void SetRoughQuery(bool set_rough) { rough_query = set_rough; } bool IsRoughQuery() { return rough_query; } Query_route_to Compile(CompiledQuery *compiled_query, Query_block *selects_list, Query_block *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, + 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); Query_route_to BuildConditions(Item *conds, CondID &cond_id, CompiledQuery *cq, const TabID &tmp_table, @@ -132,8 +132,8 @@ class Query final { int VirtualColumnAlreadyExists(const TabID &tmp_table, const std::vector &vcs, const AttrID &at); Query_route_to 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); + bool negative = false, 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); @@ -248,7 +248,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 @@ -314,7 +314,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/query_compile.cpp b/storage/tianmu/core/query_compile.cpp index 778e686ae6..595df19ecc 100644 --- a/storage/tianmu/core/query_compile.cpp +++ b/storage/tianmu/core/query_compile.cpp @@ -459,7 +459,7 @@ Query_route_to Query::AddFields(mem_root_deque &fields, TabID const &tmp aggregation_used = true; } - MysqlExpression *expr(NULL); + MysqlExpression *expr(nullptr); ws = WrapMysqlExpression(item, tmp_table, expr, false, oper == common::ColOperation::DELAYED); if (ws == WrapStatus::FAILURE) return Query_route_to::TO_MYSQL; if (!item->item_name.ptr()) { @@ -527,11 +527,11 @@ Query_route_to Query::AddOrderByFields(ORDER *order_by, TabID const &tmp_table, // (e.g., rand()) in such case we should order by output column in TempTable if (!IsFieldItem(item) && !IsAggregationItem(item) && !IsDeterministic(item) && item->type() != Item::SUBSELECT_ITEM) { - MysqlExpression *expr = NULL; + MysqlExpression *expr = nullptr; WrapStatus ws = WrapMysqlExpression(item, tmp_table, expr, false, false); if (ws == WrapStatus::FAILURE) return Query_route_to::TO_MYSQL; DEBUG_ASSERT(!expr->IsDeterministic()); - int col_num = AddColumnForMysqlExpression(expr, tmp_table, NULL, common::ColOperation::LISTING, false, true); + int col_num = AddColumnForMysqlExpression(expr, tmp_table, nullptr, common::ColOperation::LISTING, false, true); vc = VirtualColumnAlreadyExists(tmp_table, tmp_table, AttrID(-col_num - 1)); if (vc.first == common::NULL_VALUE_32) { vc.first = tmp_table.n; @@ -543,7 +543,7 @@ Query_route_to Query::AddOrderByFields(ORDER *order_by, TabID const &tmp_table, } if (group_by_clause) { if (item->type() == Item::FUNC_ITEM) { - MysqlExpression *expr = NULL; + MysqlExpression *expr = nullptr; bool delayed = false; if (HasAggregation(item)) { delayed = true; @@ -553,7 +553,7 @@ Query_route_to Query::AddOrderByFields(ORDER *order_by, TabID const &tmp_table, if (ws == WrapStatus::FAILURE) return Query_route_to::TO_MYSQL; DEBUG_ASSERT(expr->IsDeterministic()); int col_num = AddColumnForMysqlExpression( - expr, tmp_table, NULL, delayed ? common::ColOperation::DELAYED : common::ColOperation::LISTING, false, + expr, tmp_table, nullptr, delayed ? common::ColOperation::DELAYED : common::ColOperation::LISTING, false, true); vc = VirtualColumnAlreadyExists(tmp_table, tmp_table, AttrID(-col_num - 1)); if (vc.first == common::NULL_VALUE_32) { @@ -570,7 +570,7 @@ Query_route_to Query::AddOrderByFields(ORDER *order_by, TabID const &tmp_table, result = Item2CQTerm(item, my_term, tmp_table, CondType::HAVING_COND); if (item->type() == Item::SUBSELECT_ITEM) { // create a materialized column with subsel results for the ordering - cq->AddColumn(at, tmp_table, my_term, common::ColOperation::DELAYED, NULL, false); + cq->AddColumn(at, tmp_table, my_term, common::ColOperation::DELAYED, nullptr, false); vc = VirtualColumnAlreadyExists(tmp_table, tmp_table, at); if (vc.first == common::NULL_VALUE_32) { vc.first = tmp_table.n; @@ -683,7 +683,7 @@ Query::WrapStatus Query::WrapMysqlExpression(Item *item, const TabID &tmp_table, if (IsCountStar(aggregation)) { // count(*) doesn't need any virtual column at.n = GetAddColumnId(AttrID(common::NULL_VALUE_32), tmp_table, common::ColOperation::COUNT, false); if (at.n == common::NULL_VALUE_32) // doesn't exist yet - cq->AddColumn(at, tmp_table, CQTerm(), common::ColOperation::COUNT, NULL, false); + cq->AddColumn(at, tmp_table, CQTerm(), common::ColOperation::COUNT, nullptr, false); } else { common::ColOperation oper; bool distinct; @@ -776,7 +776,7 @@ int Query::AddColumnForPhysColumn(Item *item, const TabID &tmp_table, const comm } if (!item->item_name.ptr() && item->type() == Item::SUM_FUNC_ITEM) { cq->AddColumn(at, tmp_table, CQTerm(vc.second), oper, - group_by ? NULL : ((Item_field *)(((Item_sum *)item)->get_arg(0)))->item_name.ptr(), distinct); + group_by ? nullptr : ((Item_field *)(((Item_sum *)item)->get_arg(0)))->item_name.ptr(), distinct); } else { if (item->type() == Item::SUM_FUNC_ITEM && ((Item_sum *)item)->sum_func() == Item_sum::GROUP_CONCAT_FUNC) { // pass the seprator to construct the special instruction @@ -784,9 +784,9 @@ int Query::AddColumnForPhysColumn(Item *item, const TabID &tmp_table, const comm SI si; si.separator.assign(ptr, std::strlen(ptr)); si.order = ((Item_func_group_concat *)item)->direction(); - cq->AddColumn(at, tmp_table, CQTerm(vc.second), oper, group_by ? NULL : item->item_name.ptr(), distinct, &si); + cq->AddColumn(at, tmp_table, CQTerm(vc.second), oper, group_by ? nullptr : item->item_name.ptr(), distinct, &si); } else { - cq->AddColumn(at, tmp_table, CQTerm(vc.second), oper, group_by ? NULL : item->item_name.ptr(), distinct); + cq->AddColumn(at, tmp_table, CQTerm(vc.second), oper, group_by ? nullptr : item->item_name.ptr(), distinct); } } if (!group_by && item->item_name.ptr()) @@ -825,10 +825,10 @@ int Query::AddColumnForMysqlExpression(MysqlExpression *mysql_expression, const } // if (parametrized) - // cq->AddColumn(at, tmp_table, CQTerm(vc.n), DELAYED, group_by ? NULL : + // cq->AddColumn(at, tmp_table, CQTerm(vc.n), DELAYED, group_by ? nullptr : // alias, distinct); // else - cq->AddColumn(at, tmp_table, CQTerm(vc.n), oper, group_by ? NULL : alias, distinct); + cq->AddColumn(at, tmp_table, CQTerm(vc.n), oper, group_by ? nullptr : alias, distinct); if (!group_by && alias) field_alias2num[TabIDColAlias(tmp_table.n, alias)] = at.n; return at.n; } @@ -864,7 +864,7 @@ Query_route_to Query::Compile(CompiledQuery *compiled_query, Query_block *select get_const() ) | | (multiple equality) | | | ---Item_func_not | | (???) | | - | ---Item func_isnull <- when negated IS NOT NULL is created + | ---Item func_isnull <- when negated IS NOT nullptr is created | --Item_func_opt_neg <- arguments are kept in an array accessible through arguments(), if negated | | this information is kept @@ -906,10 +906,10 @@ Query_route_to Query::Compile(CompiledQuery *compiled_query, Query_block *select value) Item_func_equal -> ??? Item_func_eq -> pairwise equality */ - bool union_all = (last_distinct == NULL); + bool union_all = (last_distinct == nullptr); TabID prev_result; - SQL_I_List *global_order = NULL; + SQL_I_List *global_order = nullptr; int col_count = 0; int64_t global_limit_value = -1; int64_t global_offset_value = -1; @@ -951,11 +951,11 @@ Query_route_to Query::Compile(CompiledQuery *compiled_query, Query_block *select Item *having = sl->having_cond(); // stonedb8 start fix List to mem_root_deque #49 // List *join_list = sl->join_list; - bool zero_result = sl->join->zero_result_cause != NULL; + bool zero_result = sl->join->zero_result_cause != nullptr; Item *field_for_subselect; - Item *cond_to_reinsert = NULL; - List *list_to_reinsert = NULL; + Item *cond_to_reinsert = nullptr; + List *list_to_reinsert = nullptr; TabID tmp_table; try { @@ -989,7 +989,7 @@ Query_route_to Query::Compile(CompiledQuery *compiled_query, Query_block *select std::vector left_tables, right_tables; bool first_table = true; // stonedb8 - if (AddJoins(*sl->join_list, tmp_table, left_tables, right_tables, (res_tab != NULL && res_tab->n != 0), + if (AddJoins(*sl->join_list, tmp_table, left_tables, right_tables, (res_tab != nullptr && res_tab->n != 0), first_table, for_subq_in_where) == Query_route_to::TO_MYSQL) throw CompilationError(); @@ -998,12 +998,12 @@ Query_route_to Query::Compile(CompiledQuery *compiled_query, Query_block *select fields->push_back(field_for_subselect); } bool aggr_used = false; - if (AddFields(*fields, tmp_table, group != NULL, col_count, ignore_minmax, aggr_used) == Query_route_to::TO_MYSQL) + if (AddFields(*fields, tmp_table, group != nullptr, col_count, ignore_minmax, aggr_used) == Query_route_to::TO_MYSQL) throw CompilationError(); if (AddGroupByFields(group, tmp_table) == Query_route_to::TO_MYSQL) throw CompilationError(); - if (AddOrderByFields(order, tmp_table, group != NULL || sl->join->select_distinct || aggr_used) == + if (AddOrderByFields(order, tmp_table, group != nullptr || sl->join->select_distinct || aggr_used) == Query_route_to::TO_MYSQL) throw CompilationError(); @@ -1052,7 +1052,7 @@ Query_route_to Query::Compile(CompiledQuery *compiled_query, Query_block *select if (!ignore_limit && global_limit_value >= 0) cq->Mode(prev_result, TMParameter::TM_TOP, global_offset_value, global_limit_value); - if (res_tab != NULL) + if (res_tab != nullptr) *res_tab = prev_result; else cq->Result(prev_result); diff --git a/storage/tianmu/core/rc_attr.cpp b/storage/tianmu/core/rc_attr.cpp index 040a51dcf6..812428da7f 100644 --- a/storage/tianmu/core/rc_attr.cpp +++ b/storage/tianmu/core/rc_attr.cpp @@ -356,7 +356,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) { if (dpn->min_i == dpn->max_i) { @@ -391,7 +391,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); } @@ -455,7 +455,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; @@ -489,7 +489,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 7478609674..b7f959356b 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 @@ -263,12 +263,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 @@ -287,11 +287,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 bec55cb46e..1c63dc287b 100644 --- a/storage/tianmu/core/rc_table.cpp +++ b/storage/tianmu/core/rc_table.cpp @@ -354,7 +354,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()); } @@ -811,7 +811,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; @@ -896,7 +896,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 8d46e7fce4..0c68165660 100644 --- a/storage/tianmu/core/rc_table.h +++ b/storage/tianmu/core/rc_table.h @@ -104,17 +104,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 4e96070f1c..90adce4354 100644 --- a/storage/tianmu/core/rcattr_exeq_rs.cpp +++ b/storage/tianmu/core/rcattr_exeq_rs.cpp @@ -64,7 +64,7 @@ common::RSValue RCAttr::RoughCheck(int pack, Descriptor &d, bool additional_null if (d.IsType_AttrValOrAttrValVal()) { 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)); @@ -125,7 +125,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; pack_prefix = GetPrefixLength(pack); @@ -303,11 +303,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()) && @@ -377,8 +377,8 @@ common::RSValue RCAttr::RoughCheck(int pack, Descriptor &d, bool additional_null } else { 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) { common::RSValue res = common::RSValue::RS_SOME; @@ -504,13 +504,13 @@ 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) return common::RSValue::RS_SOME; + if (sc == nullptr) return common::RSValue::RS_SOME; RCAttr *sec = dynamic_cast(sc->GetPhysical()); - if (sec == NULL || !Type().IsNumComparable(sec->Type())) return common::RSValue::RS_SOME; + if (sec == nullptr || !Type().IsNumComparable(sec->Type())) return common::RSValue::RS_SOME; LoadPackInfo(); sec->LoadPackInfo(); @@ -563,11 +563,11 @@ 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) return 0; + if (f && f->IsEmpty() && rf == nullptr) return 0; int64_t res; if (ATI::IsRealType(TypeName())) { union { @@ -577,7 +577,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; } } @@ -587,7 +587,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) res = common::MINUS_INF_64; // NULLS only @@ -595,11 +595,11 @@ 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) return 0; + if (f && f->IsEmpty() && rf == nullptr) return 0; int64_t res; if (ATI::IsRealType(TypeName())) { union { @@ -609,7 +609,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; } } @@ -619,7 +619,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) res = common::PLUS_INF_64; // NULLS only @@ -697,7 +697,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 @@ -728,7 +728,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)) max_len = std::max(max_len, GetActualSize(p)); + if (f == nullptr || !f->IsEmpty(p)) max_len = std::max(max_len, GetActualSize(p)); } if (max_len > 0 && max_len < 6) no_dist += int64_t(256) << ((max_len - 1) * 8); @@ -746,11 +746,11 @@ 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 + 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; + if (Type().IsLookup() && !types::RequiresUTFConversions(GetCollation()) && f->IsFull()) return RoughMax(nullptr) + 1; bool nulls_only = true; for (uint p = 0; p < SizeOfPack(); p++) if (!f->IsEmpty(p) && GetPackOntologicalStatus(p) != PackOntologicalStatus::NULLS_ONLY) { @@ -835,7 +835,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; size_t len = GetActualSize(p); diff --git a/storage/tianmu/core/rcattr_exqp.cpp b/storage/tianmu/core/rcattr_exqp.cpp index 9cfc532f3b..eeef0168f2 100644 --- a/storage/tianmu/core/rcattr_exqp.cpp +++ b/storage/tianmu/core/rcattr_exqp.cpp @@ -352,7 +352,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; @@ -423,7 +423,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; @@ -490,12 +490,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 { @@ -528,13 +528,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(); @@ -586,7 +586,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) @@ -668,7 +668,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; @@ -722,7 +722,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; @@ -1046,7 +1046,7 @@ bool RCAttr::IsDistinct(Filter *f) { MEASURE_FET("RCAttr::IsDistinct(...)"); if (ct.IsLookup() && types::RequiresUTFConversions(GetCollation())) return false; if (PhysicalColumn::IsDistinct() == common::RSValue::RS_ALL) { // = is_unique_updated && is_unique - if (f == NULL) return (NumOfNulls() == 0); // no nulls at all, and is_unique => distinct + if (f == nullptr) return (NumOfNulls() == 0); // no nulls at all, and is_unique => distinct LoadPackInfo(); for (uint b = 0; b < SizeOfPack(); b++) if (!f->IsEmpty(b) && get_dpn(b).nn > 0) // any null in nonempty pack? @@ -1059,14 +1059,14 @@ 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) return NumOfObj() - NumOfNulls(); if (d.op == common::Operator::O_IS_NULL) 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) return NumOfObj() / no_distinct; if (d.op == common::Operator::O_NOT_EQ) return NumOfObj() - (NumOfObj() / no_distinct); @@ -1159,7 +1159,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); @@ -1213,7 +1213,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 9a26c7c4ca..e2b415a2a0 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]; } } @@ -70,12 +70,12 @@ RoughMultiIndex::~RoughMultiIndex() { } common::RSValue *RoughMultiIndex::GetLocalDescFilter(int dim, int desc_num, bool read_only) { - if (desc_num < 0) return NULL; + if (desc_num < 0) 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 + if (read_only) return nullptr; // no local filter available // still here? Now j is the first unused descriptor slot, and we should // prepare a new table. @@ -116,7 +116,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) return true; + 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 // information available diff --git a/storage/tianmu/core/sorter3.cpp b/storage/tianmu/core/sorter3.cpp index fdc3b12c0a..cf3dfa8943 100644 --- a/storage/tianmu/core/sorter3.cpp +++ b/storage/tianmu/core/sorter3.cpp @@ -55,15 +55,15 @@ SorterOnePass::SorterOnePass(uint _size, uint _key_bytes, uint _total_bytes) bound_queue_size = 2 + size / 10; 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) throw common::OutOfMemoryException(); + 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(); } @@ -110,7 +110,7 @@ unsigned char *SorterOnePass::GetNextValue() { QuickSort(); already_sorted = true; } - if (buf_output_pos == buf_input_pos) return NULL; + if (buf_output_pos == buf_input_pos) return nullptr; unsigned char *res = buf_output_pos; buf_output_pos += total_bytes; return res; @@ -200,7 +200,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); @@ -208,7 +208,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) @@ -248,7 +248,7 @@ unsigned char *SorterMultiPass::GetNextValue() { already_sorted = true; } // merge - if (heap.empty()) return NULL; + if (heap.empty()) return nullptr; SorterMultiPass::Keyblock cur_val = heap.top(); unsigned char *res = cur_val.rec; heap.pop(); @@ -277,7 +277,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) throw common::OutOfMemoryException(); + if (buf == nullptr) throw common::OutOfMemoryException(); } int standard_buf_size = rows_in_small_buffer * total_bytes; int last_buf_size = @@ -295,7 +295,7 @@ 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 == -2) 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); @@ -304,7 +304,7 @@ SorterMultiPass::Keyblock SorterMultiPass::GetFromBlock(int b, bool &reloaded) { 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; @@ -324,9 +324,9 @@ 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) throw common::OutOfMemoryException(); + 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(); } @@ -338,7 +338,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() { @@ -366,7 +366,7 @@ unsigned char *SorterCounting::GetNextValue() { CountingSort(); already_sorted = true; } - if (buf_output_pos == buf_output_end) return NULL; + if (buf_output_pos == buf_output_end) return nullptr; unsigned char *res = buf_output_pos; buf_output_pos += total_bytes; return res; @@ -404,7 +404,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 b8c1aeaa1f..ec5b9ea180 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 c39131637f..466e4ba6bf 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; } @@ -218,7 +218,7 @@ void SorterWrapper::SortRoughly(std::vector &po) { bool SorterWrapper::InitPackrow(MIIterator &mit) // return true if the packrow may be skipped { - if (s == NULL) return false; // trivial sorter (constant values) + if (s == nullptr) return false; // trivial sorter (constant values) // rough sort: exclude packs which are for sure out of scope if (rough_sort_by > -1 && limit > -1 && no_values_encoded >= limit) { @@ -249,32 +249,32 @@ bool SorterWrapper::InitPackrow(MIIterator &mit) // return true if the packrow } bool SorterWrapper::PutValues(MIIterator &mit) { - if (s == NULL) return false; // trivial sorter (constant values) + if (s == nullptr) return false; // trivial sorter (constant values) if (mi_encoder) mi_encoder->Encode(input_buf, mit); bool update_stats = (rough_sort_by > -1 && limit > -1 && no_values_encoded <= limit); // otherwise statistics are either not used // 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) return false; // trivial sorter (constant values) + if (s == nullptr) return false; // trivial sorter (constant values) no_values_encoded += sw.GetEncodedValNum(); TIANMU_LOG(LogCtl_Level::DEBUG, "PutValues: no_values_encoded %lu \n", no_values_encoded); return s->PutValue(sw.GetSorter()); } 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) return false; + if (cur_val == nullptr) return false; if (mi_encoder) mi_encoder->GetValue(cur_val, cur_mit); // decode the MIIterator (for implicit/virtual values) return true; diff --git a/storage/tianmu/core/temp_table.cpp b/storage/tianmu/core/temp_table.cpp index 846ce0d60f..e2a9992fbf 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; @@ -68,15 +68,15 @@ TempTable::Attr::Attr(const Attr &a) : PhysicalColumn(a) { term = a.term; 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; @@ -89,7 +89,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; @@ -97,7 +97,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 @@ -118,8 +118,8 @@ TempTable::Attr &TempTable::Attr::operator=(const TempTable::Attr &a) { term = a.term; 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; @@ -127,7 +127,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; @@ -258,7 +258,7 @@ void TempTable::Attr::DeleteBuffer() { default: break; } - buffer = NULL; + buffer = nullptr; no_obj = 0; } @@ -392,7 +392,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: @@ -447,7 +447,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: @@ -732,7 +732,7 @@ void TempTable::Attr::ApplyFilter(MultiIndex &mind, int64_t offset, int64_t last if (last_index > mind.NumOfTuples()) last_index = mind.NumOfTuples(); void *old_buffer = buffer; - buffer = NULL; + buffer = nullptr; CreateBuffer(last_index - offset, mind.m_conn); MIIterator mit(&mind, mind.ValueOfPower()); @@ -942,13 +942,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); } @@ -972,7 +972,7 @@ std::shared_ptr TempTable::CreateMaterializedCopy(bool translate_orde filter.mind = new MultiIndex(p_power); 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); @@ -1036,9 +1036,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(); } @@ -1047,7 +1047,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); } @@ -1079,7 +1079,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) { @@ -1264,7 +1264,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; @@ -1528,7 +1528,7 @@ void TempTable::Display(std::ostream &out) { GetTable_S(s, i, j); out << s << " "; } else - out << "NULL" + out << "nullptr" << " "; } out << system::endl; @@ -1835,7 +1835,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() { @@ -1958,7 +1958,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 @@ -1969,7 +1969,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 @@ -2001,7 +2001,7 @@ void TempTable::Materialize(bool in_subq, ResultSender *sender, bool lazy) { local_limit = no_obj; 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, @@ -2099,7 +2099,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 8bab2ba3e5..6f2f76527a 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([[maybe_unused]] Filter *f = NULL, [[maybe_unused]] common::RSValue *rf = NULL) override { + size_t MaxStringSize(Filter *f = nullptr) override; // maximal byte string length in column + int64_t RoughMin([[maybe_unused]] Filter *f = nullptr, [[maybe_unused]] 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([[maybe_unused]] Filter *f = NULL, [[maybe_unused]] common::RSValue *rf = NULL) override { + // global min if filter is nullptr) + int64_t RoughMax([[maybe_unused]] Filter *f = nullptr, [[maybe_unused]] 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,7 +215,7 @@ 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 + ResultSender *sender = nullptr); // Sort data contained in // ParameterizedFilter by using some // attributes (usually specified by // AddOrder, but in general - @@ -223,8 +223,8 @@ class TempTable : public JustATable { // 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, [[maybe_unused]] Filter *f = NULL) { return common::MINUS_INF_64; } - int64_t RoughMax([[maybe_unused]] int n_a, [[maybe_unused]] Filter *f = NULL) { return common::PLUS_INF_64; } + int64_t RoughMin([[maybe_unused]] int n_a, [[maybe_unused]] Filter *f = nullptr) { return common::MINUS_INF_64; } + int64_t RoughMax([[maybe_unused]] int n_a, [[maybe_unused]] Filter *f = nullptr) { return common::PLUS_INF_64; } - uint MaxStringSize(int n_a, [[maybe_unused]] Filter *f = NULL) override { + uint MaxStringSize(int n_a, [[maybe_unused]] Filter *f = nullptr) override { if (n_a < 0) return GetFieldSize(-n_a - 1); return GetFieldSize(n_a); } @@ -439,8 +439,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 @@ -508,8 +508,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); void SetAttrsForRough(); void SetAttrsForExact(); diff --git a/storage/tianmu/core/temp_table_com.cpp b/storage/tianmu/core/temp_table_com.cpp index 4a2db9b849..ad47cbdefa 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 19bbbde977..7b5da4c97d 100644 --- a/storage/tianmu/core/temp_table_low.cpp +++ b/storage/tianmu/core/temp_table_low.cpp @@ -107,14 +107,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) { @@ -128,7 +128,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++) @@ -226,7 +226,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); @@ -243,14 +243,14 @@ 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) { int col = 0; 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 f5c96bb858..3f7fd21935 100644 --- a/storage/tianmu/core/temp_table_roughquery.cpp +++ b/storage/tianmu/core/temp_table_roughquery.cpp @@ -134,7 +134,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 @@ -260,7 +260,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()); } @@ -277,7 +277,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(); @@ -353,7 +353,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) { @@ -423,7 +423,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 || @@ -634,7 +634,7 @@ void TempTable::RoughAggregate(ResultSender *sender) { if (attrs[j]->mode == common::ColOperation::GROUP_BY) 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 fc74d4fe7e..9ac5c5ba5b 100644 --- a/storage/tianmu/core/value_matching_table.cpp +++ b/storage/tianmu/core/value_matching_table.cpp @@ -65,7 +65,7 @@ ValueMatchingTable *ValueMatchingTable::CreateNew_ValueMatchingTable(int64_t mem } ValueMatching_OnePosition::ValueMatching_OnePosition() { - t_aggr = NULL; + t_aggr = nullptr; iterator_valid = false; } @@ -73,7 +73,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); } @@ -105,10 +105,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; } @@ -121,13 +121,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 b336b6c0ac..3bc04d1cb3 100644 --- a/storage/tianmu/core/value_matching_table.h +++ b/storage/tianmu/core/value_matching_table.h @@ -108,7 +108,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 6878131173..f1060e99bf 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 400cca9614..5e35aabbba 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 23dd514bea..f704c93f09 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_my_tianmu.cpp b/storage/tianmu/handler/ha_my_tianmu.cpp index 2974a49035..970b94d9a5 100644 --- a/storage/tianmu/handler/ha_my_tianmu.cpp +++ b/storage/tianmu/handler/ha_my_tianmu.cpp @@ -24,7 +24,7 @@ #include "vc/virtual_column.h" namespace Tianmu { -namespace DBHandler { +namespace handler { enum class TianmuEngineReturnValues : int { LD_SUCCEED = 100, LD_FAILED = 101, LD_CONTINUE = 102 }; @@ -65,7 +65,7 @@ static bool Tianmu_SetStatementAllowed(THD *thd, Query_expression *qe) { return true; } -void Tianmu_UpdateAndStoreColumnComment(TABLE *table, int field_id, Field *source_field, int source_field_id, +void ha_my_tianmu_update_and_store_col_comment(TABLE *table, int field_id, Field *source_field, int source_field_id, CHARSET_INFO *cs) { try { ha_rcengine_->UpdateAndStoreColumnComment(table, field_id, source_field, source_field_id, cs); @@ -78,7 +78,7 @@ void Tianmu_UpdateAndStoreColumnComment(TABLE *table, int field_id, Field *sourc } } -Query_route_to Tianmu_Handle_Query(THD *thd, Query_expression *qe, Query_result *&result, +Query_route_to ha_my_tianmu_query(THD *thd, Query_expression *qe, Query_result *&result, ulong setup_tables_done_option, int &res, int &optimize_after_tianmu, int &tianmu_free_join, int with_insert) { Query_route_to ret = Query_route_to::TO_TIANMU; @@ -93,7 +93,7 @@ Query_route_to Tianmu_Handle_Query(THD *thd, Query_expression *qe, Query_result ret = ha_rcengine_->Handle_Query(thd, qe, result, setup_tables_done_option, res, optimize_after_tianmu, tianmu_free_join, with_insert); - if (ret == DBHandler::Query_route_to::TO_MYSQL && AtLeastOneTianmuTableInvolved(qe) && + if (ret == handler::Query_route_to::TO_MYSQL && AtLeastOneTianmuTableInvolved(qe) && ForbiddenMySQLQueryPath(qe)) { my_message(static_cast(common::ErrorCode::UNKNOWN_ERROR), "The query includes syntax that is not supported by the storage engine. \ @@ -144,7 +144,7 @@ static int Tianmu_LoadData(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, v } // returning true means 'to continue' -bool Tianmu_Load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, void *arg) { +bool ha_my_tianmu_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, void *arg) { char tianmumsg[256] = {0}; int tianmu_errcode{0}; @@ -165,6 +165,6 @@ bool Tianmu_Load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, void *arg) return false; } -bool Tianmu_Get_Insert_Delayed_Flag(THD *thd) { return tianmu_sysvar_insert_delayed; } -} // namespace DBHandler +bool ha_my_tianmu_get_insert_delayed_flag(THD *thd) { return tianmu_sysvar_insert_delayed; } +} // namespace handler } // namespace Tianmu diff --git a/storage/tianmu/handler/ha_my_tianmu.h b/storage/tianmu/handler/ha_my_tianmu.h index abcf9fb78c..ed8c178e5d 100644 --- a/storage/tianmu/handler/ha_my_tianmu.h +++ b/storage/tianmu/handler/ha_my_tianmu.h @@ -23,24 +23,24 @@ // mysql <--> tianmu interface functions namespace Tianmu { -namespace DBHandler { +namespace handler { enum class Query_route_to : unsigned int { TO_MYSQL = 0, TO_TIANMU = 1 }; // processing the queries which routed to Tianmu Engine. -Query_route_to Tianmu_Handle_Query(THD *thd, Query_expression *qe, Query_result *&result_output, +Query_route_to ha_my_tianmu_query(THD *thd, Query_expression *qe, Query_result *&result_output, ulong setup_tables_done_option, int &res, int &optimize_after_tianmu, int &tianmu_free_join, int with_insert = false); // update the comment for a column. -void Tianmu_UpdateAndStoreColumnComment(TABLE *table, int field_id, Field *source_field, int source_field_id, +void ha_my_tianmu_update_and_store_col_comment(TABLE *table, int field_id, Field *source_field, int source_field_id, CHARSET_INFO *cs); // processing the load operation. -bool Tianmu_Load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, void *arg); +bool ha_my_tianmu_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, void *arg); -bool Tianmu_Get_Insert_Delayed_Flag(THD *thd); +bool ha_my_tianmu_get_insert_delayed_flag(THD *thd); -} // namespace DBHandler +} // namespace handler } // namespace Tianmu #endif // HA_MY_TIANMU_H_ diff --git a/storage/tianmu/handler/ha_tianmu.cpp b/storage/tianmu/handler/ha_tianmu.cpp index 15d207b555..c88c1608c5 100644 --- a/storage/tianmu/handler/ha_tianmu.cpp +++ b/storage/tianmu/handler/ha_tianmu.cpp @@ -42,8 +42,12 @@ #define MYSQL_SERVER 1 +handler *rcbase_create_handler(handlerton *hton, TABLE_SHARE *table, bool partitioned, MEM_ROOT *mem_root) { + return new (mem_root) Tianmu::handler::ha_tianmu(hton, table, partitioned); +} + namespace Tianmu { -namespace DBHandler { +namespace handler { extern bool tianmu_bootstrap = 0; @@ -53,9 +57,9 @@ char *strmov_str(char *dst, const char *src) { return dst - 1; } -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; ///////////////////////////////////////////////////////////////////// // @@ -170,7 +174,7 @@ static core::Value GetValueFromField(Field *f) { return v; } -TianmuHandler::TianmuHandler(handlerton *hton, TABLE_SHARE *table_arg, bool partitioned) +ha_tianmu::ha_tianmu(handlerton *hton, TABLE_SHARE *table_arg, bool partitioned) : handler(hton, table_arg), m_partitioned(partitioned) { ref_length = sizeof(uint64_t); } @@ -224,7 +228,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; @@ -248,7 +252,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; @@ -280,9 +284,9 @@ int TianmuHandler::external_lock(THD *thd, int lock_type) { tx->AddTableRD(share); } else { tx->AddTableWR(share); - trans_register_ha(thd, false, tianmu_hton, NULL); + trans_register_ha(thd, false, tianmu_hton, nullptr); if (thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) - trans_register_ha(thd, true, tianmu_hton, NULL); + trans_register_ha(thd, true, tianmu_hton, nullptr); } } ret = 0; @@ -418,7 +422,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 { @@ -471,7 +475,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); @@ -540,7 +544,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__); DBUG_RETURN(HA_ERR_WRONG_COMMAND); } @@ -556,12 +560,12 @@ 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__); DBUG_RETURN(HA_ERR_WRONG_COMMAND); } -int TianmuHandler::rename_table(const char *from, const char *to, const dd::Table *from_table_def, +int ha_tianmu::rename_table(const char *from, const char *to, const dd::Table *from_table_def, dd::Table *to_table_def) { // stonedb8 TODO try { ha_rcengine_->RenameTable(current_txn_, from, to, from_table_def, to_table_def, ha_thd()); @@ -576,7 +580,7 @@ int TianmuHandler::rename_table(const char *from, const char *to, const dd::Tabl 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. @@ -623,7 +627,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 { @@ -678,7 +682,7 @@ 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, [[maybe_unused]] const dd::Table *table_def) { // stonedb8 TODO DBUG_ENTER(__PRETTY_FUNCTION__); @@ -693,7 +697,7 @@ int TianmuHandler::open(const char *name, [[maybe_unused]] int mode, [[maybe_unu // would be kept. if (!(share = ha_rcengine_->GetTableShare(table_share))) DBUG_RETURN(ret); - thr_lock_data_init(&share->thr_lock, &m_lock, NULL); + thr_lock_data_init(&share->thr_lock, &m_lock, nullptr); share->thr_lock.check_status = tianmu_check_status; // have primary key, use table index if (table->s->primary_key != MAX_INDEXES) ha_rcengine_->AddTableIndex(name, table, ha_thd()); @@ -715,7 +719,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; } @@ -730,12 +734,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 { @@ -756,13 +760,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); @@ -773,7 +777,7 @@ 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, +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__); @@ -820,7 +824,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 { @@ -843,7 +847,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 { @@ -869,7 +873,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 { @@ -898,7 +902,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 { @@ -930,7 +934,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; @@ -943,7 +947,7 @@ int TianmuHandler::rnd_init(bool scan) { core::FunctionExecutor fe(std::bind(&core::Query::LockPackInfoForUse, std::ref(m_query)), std::bind(&core::Query::UnlockPackInfoFromUse, std::ref(m_query))); - core::TempTable *push_down_result = m_query->Preexecute(*m_cq, NULL, false); + core::TempTable *push_down_result = m_query->Preexecute(*m_cq, nullptr, false); if (!push_down_result || push_down_result->NumOfTables() != 1) throw common::InternalException("core::Query execution returned no result object"); @@ -978,7 +982,7 @@ int TianmuHandler::rnd_init(bool scan) { } ret = 0; blob_buffers.resize(0); - if (table_ptr != NULL) blob_buffers.resize(table_ptr->NumOfDisplaybleAttrs()); + if (table_ptr != nullptr) blob_buffers.resize(table_ptr->NumOfDisplaybleAttrs()); } catch (std::exception &e) { my_message(static_cast(common::ErrorCode::UNKNOWN_ERROR), e.what(), MYF(0)); TIANMU_LOG(LogCtl_Level::ERROR, "An exception is caught: %s", e.what()); @@ -990,7 +994,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); @@ -1005,7 +1009,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; @@ -1041,7 +1045,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); @@ -1056,7 +1060,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; @@ -1096,10 +1100,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([[maybe_unused]] enum ha_extra_function operation) { +int ha_tianmu::extra([[maybe_unused]] 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(). */ // stonedb8 TODO: HA_EXTRA_NO_CACHE is deleted /* @@ -1111,12 +1115,12 @@ int TianmuHandler::extra([[maybe_unused]] 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, tianmu_hton, NULL); + trans_register_ha(thd, false, tianmu_hton, nullptr); if (thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) { - trans_register_ha(thd, true, tianmu_hton, NULL); + trans_register_ha(thd, true, tianmu_hton, nullptr); } current_txn_ = ha_rcengine_->GetTx(thd); current_txn_->AddTableWRIfNeeded(share); @@ -1138,7 +1142,7 @@ int TianmuHandler::start_stmt(THD *thd, thr_lock_type lock_type) { */ // stonedb8 TODO: register_query_cache_table is deleted /* -bool TianmuHandler::register_query_cache_table(THD *thd, char *table_key, size_t key_length, +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; @@ -1160,7 +1164,7 @@ bool TianmuHandler::register_query_cache_table(THD *thd, char *table_key, size_t during create if the table_flag HA_DROP_BEFORE_CREATE was specified for the storage engine. */ -int TianmuHandler::delete_table(const char *name, const dd::Table *table_def) { // stonedb8 TODO +int ha_tianmu::delete_table(const char *name, const dd::Table *table_def) { // stonedb8 TODO DBUG_ENTER(__PRETTY_FUNCTION__); int ret = 1; try { @@ -1184,7 +1188,7 @@ int TianmuHandler::delete_table(const char *name, const dd::Table *table_def) { 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, +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(10); // low number to force index usage @@ -1200,7 +1204,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 *info, +int ha_tianmu::create(const char *name, TABLE *table_arg, [[maybe_unused]] HA_CREATE_INFO *info, dd::Table *table_def) { // stonedb8 TODO DBUG_ENTER(__PRETTY_FUNCTION__); try { @@ -1224,7 +1228,7 @@ int TianmuHandler::create(const char *name, TABLE *table_arg, [[maybe_unused]] H DBUG_RETURN(1); } -int TianmuHandler::truncate(dd::Table *table_def) { // stonedb8 TODO +int ha_tianmu::truncate(dd::Table *table_def) { // stonedb8 TODO int ret = 0; try { ha_rcengine_->TruncateTable(m_table_name, table_def, ha_thd()); @@ -1239,7 +1243,7 @@ int TianmuHandler::truncate(dd::Table *table_def) { // stonedb8 TODO return ret; } -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; my_bitmap_map *org_bitmap = dbug_tmp_use_all_columns(table, table->write_set); @@ -1269,11 +1273,11 @@ 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); - char *str = NULL; + char *str = nullptr; uint extra_len = 0; if (length > 64000 - 3) { @@ -1316,7 +1320,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); @@ -1326,7 +1330,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 (m_query && !m_result && table_ptr->NumOfObj() != 0) { m_cq->Result(m_tmp_table); // it is ALWAYS -2 though.... @@ -1336,7 +1340,7 @@ int TianmuHandler::set_cond_iter() { core::FunctionExecutor fe(std::bind(&core::Query::LockPackInfoForUse, std::ref(m_query)), std::bind(&core::Query::UnlockPackInfoFromUse, std::ref(m_query))); - core::TempTable *push_down_result = m_query->Preexecute(*m_cq, NULL, false); + core::TempTable *push_down_result = m_query->Preexecute(*m_cq, nullptr, false); if (!push_down_result || push_down_result->NumOfTables() != 1) throw common::InternalException("core::Query execution returned no result object"); @@ -1361,7 +1365,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); @@ -1434,14 +1438,14 @@ 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; try { table_new_iter = core::RCTable::Iterator(); table_new_iter_end = core::RCTable::Iterator(); - table_ptr = NULL; + table_ptr = nullptr; filter_ptr.reset(); m_query.reset(); m_cq.reset(); @@ -1459,7 +1463,7 @@ int TianmuHandler::reset() { DBUG_RETURN(ret); } -enum_alter_inplace_result TianmuHandler::check_if_supported_inplace_alter([[maybe_unused]] TABLE *altered_table, +enum_alter_inplace_result ha_tianmu::check_if_supported_inplace_alter([[maybe_unused]] TABLE *altered_table, Alter_inplace_info *ha_alter_info) { if ((ha_alter_info->handler_flags & ~TIANMU_SUPPORTED_ALTER_ADD_DROP_ORDER) && (ha_alter_info->handler_flags != TIANMU_SUPPORTED_ALTER_COLUMN_NAME)) { @@ -1468,7 +1472,7 @@ enum_alter_inplace_result TianmuHandler::check_if_supported_inplace_alter([[mayb return HA_ALTER_INPLACE_EXCLUSIVE_LOCK; } -bool TianmuHandler::inplace_alter_table(TABLE *altered_table [[maybe_unused]], +bool ha_tianmu::inplace_alter_table(TABLE *altered_table [[maybe_unused]], Alter_inplace_info *ha_alter_info [[maybe_unused]], const dd::Table *old_table_def [[maybe_unused]], dd::Table *new_table_def [[maybe_unused]]) { // stonedb8 TODO @@ -1492,7 +1496,7 @@ bool TianmuHandler::inplace_alter_table(TABLE *altered_table [[maybe_unused]], return true; } -bool TianmuHandler::commit_inplace_alter_table(TABLE *altered_table [[maybe_unused]], +bool ha_tianmu::commit_inplace_alter_table(TABLE *altered_table [[maybe_unused]], Alter_inplace_info *ha_alter_info [[maybe_unused]], bool commit [[maybe_unused]], const dd::Table *old_table_def [[maybe_unused]], @@ -1545,7 +1549,7 @@ bool TianmuHandler::commit_inplace_alter_table(TABLE *altered_table [[maybe_unus 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, +void ha_tianmu::key_convert(const uchar *key, uint key_len, std::vector cols, std::vector &keys) { key_restore(table->record[0], const_cast(key), &table->key_info[active_index], key_len); @@ -1557,7 +1561,7 @@ void TianmuHandler::key_convert(const uchar *key, uint key_len, std::vectorread_set, f->field_index()); size_t length; if (f->is_null()) { - throw common::Exception("Priamry key part can not be NULL"); + throw common::Exception("Priamry key part can not be nullptr"); } if (f->is_flag_set(BLOB_FLAG)) // stonedb8 length = dynamic_cast(f)->get_length(); @@ -1709,10 +1713,6 @@ static int rcbase_done_func([[maybe_unused]] void *p) { DBUG_RETURN(0); } -handler *rcbase_create_handler(handlerton *hton, TABLE_SHARE *table, bool partitioned, MEM_ROOT *mem_root) { - return new (mem_root) TianmuHandler(hton, table, partitioned); -} - int rcbase_panic_func([[maybe_unused]] handlerton *hton, enum ha_panic_function flag) { if (tianmu_bootstrap) return 0; @@ -2407,22 +2407,22 @@ static struct SYS_VAR *tianmu_system_variables[] = {MYSQL_SYSVAR(bg_load_threads MYSQL_SYSVAR(result_sender_rows), nullptr}; -} // namespace DBHandler +} // 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::handler::rcbase_init_func, /* Plugin Init */ nullptr, /* Plugin Check uninstall */ - Tianmu::DBHandler::rcbase_done_func, /* Plugin Deinit */ + Tianmu::handler::rcbase_done_func, /* Plugin Deinit */ 0x0001 /* tianmu version 0.1 */, - Tianmu::DBHandler::statusvars, /* status variables */ - Tianmu::DBHandler::tianmu_system_variables, /* system variables */ + Tianmu::handler::statusvars, /* status variables */ + Tianmu::handler::tianmu_system_variables, /* system variables */ nullptr, /* config options */ 0 /* flags for plugin */ } mysql_declare_plugin_end; diff --git a/storage/tianmu/handler/ha_tianmu.h b/storage/tianmu/handler/ha_tianmu.h index 6813a72253..10711cef1a 100644 --- a/storage/tianmu/handler/ha_tianmu.h +++ b/storage/tianmu/handler/ha_tianmu.h @@ -22,13 +22,13 @@ #include "core/engine.h" namespace Tianmu { -namespace DBHandler { +namespace handler { // Class definition for the storage engine -class TianmuHandler final : public handler { +class ha_tianmu final : public handler { public: - TianmuHandler(handlerton *hton, TABLE_SHARE *table_arg, bool partitioned); - virtual ~TianmuHandler() = default; + ha_tianmu(handlerton *hton, TABLE_SHARE *table_arg, bool partitioned); + virtual ~ha_tianmu() = default; /* The name that will be used for display purposes */ const char *table_type() const override { return "TIANMU"; } /* @@ -191,7 +191,7 @@ class TianmuHandler final : public handler { bool m_partitioned = false; }; -} // namespace DBHandler +} // namespace handler } // namespace Tianmu #endif // HA_TIANMU_H_ diff --git a/storage/tianmu/index/kv_store.cpp b/storage/tianmu/index/kv_store.cpp index 65c0a23df2..c7dbea3e54 100644 --- a/storage/tianmu/index/kv_store.cpp +++ b/storage/tianmu/index/kv_store.cpp @@ -33,7 +33,7 @@ void KVStore::Init() { options.table_factory.reset(rocksdb::NewBlockBasedTableFactory(bb_table_option_)); } - // get column family names from manfest file + // get column family names from manifest file rocksdb::TransactionDBOptions txn_db_options; std::vector cf_names; std::vector cf_descr; diff --git a/storage/tianmu/index/rdb_meta_manager.cpp b/storage/tianmu/index/rdb_meta_manager.cpp index 27c950b4d8..a2cf048bd3 100644 --- a/storage/tianmu/index/rdb_meta_manager.cpp +++ b/storage/tianmu/index/rdb_meta_manager.cpp @@ -49,7 +49,7 @@ RdbKey::RdbKey(uint indexnr, uint keyno, rocksdb::ColumnFamilyHandle *cf_handle, cols_(cols) { be_store_index(m_index_nr_be, m_indexnr); - ASSERT(m_cf_handle != nullptr, "m_cf_handle is NULL"); + ASSERT(m_cf_handle != nullptr, "m_cf_handle is nullptr"); } RdbKey::RdbKey(const RdbKey &k) @@ -736,7 +736,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); @@ -944,7 +944,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; @@ -1003,7 +1003,7 @@ std::vector CFManager::get_all_cf(void) { std::scoped_lock guard(m_mutex); for (auto it : m_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 6358cfde0e..45a5be20b4 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 869378608c..d81ba8d3bb 100644 --- a/storage/tianmu/loader/parsing_strategy.cpp +++ b/storage/tianmu/loader/parsing_strategy.cpp @@ -369,7 +369,7 @@ void ParsingStrategy::GetValue(const char *value_ptr, size_t value_size, ushort if (*value_ptr == '\\' && (value_ptr[1] == 'N' || (!is_enclosed && value_ptr[1] == 'n'))) isnull = true; break; case 4: - if (!is_enclosed && strncasecmp(value_ptr, "NULL", 4) == 0) isnull = true; + if (!is_enclosed && strncasecmp(value_ptr, "nullptr", 4) == 0) isnull = true; break; default: break; diff --git a/storage/tianmu/mm/huge_heap_policy.cpp b/storage/tianmu/mm/huge_heap_policy.cpp index 2c406df2fa..1b72e05d21 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 b2ecce934a..0cbc27f217 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 674eadff59..e7fe5222de 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 1920321cf1..b62ce9b89f 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 9b06137a80..e811ef90c0 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,18 +198,18 @@ 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()) << "Failed to alloc block of size " << static_cast(size) << system::unlock; @@ -232,7 +232,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++; @@ -255,7 +255,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); ASSERT(it != m_objs.end(), "MSize Owner not found"); @@ -270,7 +270,7 @@ void MemoryHandling::dealloc(void *mh, TraceableObject *owner) { std::scoped_lock guard(m_mutex); - if (mh == NULL) return; + if (mh == nullptr) return; auto it = m_objs.find(owner); ASSERT(it != m_objs.end(), "DeAlloc owner not found"); @@ -283,7 +283,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++; @@ -327,7 +327,7 @@ bool MemoryHandling::ReleaseMemory(size_t size, [[maybe_unused]] TraceableObject std::vector dps; for (auto &it : m_objs) { - if (it.first == NULL) continue; + if (it.first == nullptr) continue; if (it.first->IsLocked() || it.first->TraceableType() != TO_TYPE::TO_PACK) continue; for (auto &mit : *it.second) { @@ -351,7 +351,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(); @@ -375,7 +375,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) return res; + if (mh == nullptr) return res; size_t oldsize = rc_msize(mh, owner); std::memcpy(res, mh, std::min(oldsize, size)); @@ -516,7 +516,7 @@ void MemoryHandling::HeapHistogram(std::ostream &out) { if (hist != used_blocks.end()) { hist->second->accumulate(hp->getBlockSize(ptr)); - if (block_type != NULL) block_type->accumulate(hp->getBlockSize(ptr)); + 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 3e033f8b14..ded02bc141 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 f66a9819b7..587c650341 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 3f713c1746..09f9512690 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 d4bc44ffdf..b6475bd018 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 3da541369b..b970af5ada 100644 --- a/storage/tianmu/mm/release_tracker.cpp +++ b/storage/tianmu/mm/release_tracker.cpp @@ -24,70 +24,70 @@ 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) SetRelPrev(head, o); + if (head != nullptr) SetRelPrev(head, o); head = o; - if (tail == NULL) tail = head; + 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 ab7fa1b088..a4343e2556 100644 --- a/storage/tianmu/mm/sys_heap_policy.cpp +++ b/storage/tianmu/mm/sys_heap_policy.cpp @@ -26,7 +26,7 @@ namespace mm { SystemHeap::~SystemHeap() {} void *SystemHeap::alloc(size_t size) { - if (size_ > 0 && (alloc_size_ + size > size_)) return NULL; + if (size_ > 0 && (alloc_size_ + size > size_)) 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 e3063188c4..a2e3b68a00 100755 --- 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; @@ -295,16 +295,16 @@ bool PageHeap::GrowHeap(Length n) { if (n > kMaxValidPages) 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) return false; + if (ptr == nullptr) return false; } system_alloc_list.push_back(ptr); actual_size = ask << kPageShift; diff --git a/storage/tianmu/mm/tcm/page_heap.h b/storage/tianmu/mm/tcm/page_heap.h index 10ad24489f..93373f15f2 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 ee774a71ca..f67f2f8326 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 1736b4350a..101c0b9545 100755 --- 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,15 +101,15 @@ 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) return array_[k]; + if (array_[k] != nullptr) return array_[k]; k++; } - return NULL; + return nullptr; } }; @@ -142,7 +142,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); @@ -166,8 +166,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]; } @@ -189,16 +189,16 @@ class TCMalloc_PageMap3 { if (i1 >= INTERIOR_LENGTH || i2 >= INTERIOR_LENGTH) return false; // Make 2nd level node if necessary - if (root_->ptrs[i1] == NULL) { + if (root_->ptrs[i1] == nullptr) { Node *n = NewNode(); - if (n == NULL) return false; + 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) return false; + if (leaf == nullptr) return false; system_alloc_list.push_back(leaf); memset(leaf, 0, sizeof(*leaf)); root_->ptrs[i1]->ptrs[i2] = reinterpret_cast(leaf); @@ -216,14 +216,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]; } } @@ -232,7 +232,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 63263324ae..6c5b8f074f 100755 --- a/storage/tianmu/mm/tcm/span.cpp +++ b/storage/tianmu/mm/tcm/span.cpp @@ -72,8 +72,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. @@ -88,8 +88,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 67fc6b4faa..20c96f202c 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 834f6f9c6d..3516e2fcd8 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 6cda9f5993..0d1ddf1016 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 0dcdba50b9..7021f5e31d 100644 --- a/storage/tianmu/mm/tcm_heap_policy.cpp +++ b/storage/tianmu/mm/tcm_heap_policy.cpp @@ -41,10 +41,10 @@ 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; @@ -59,7 +59,7 @@ 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); @@ -76,11 +76,11 @@ 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; + if (list->empty()) return nullptr; res = list->Pop(); tcm::Span *s = m_heap.GetDescriptor(ADDR_TO_PAGEID(res)); @@ -91,7 +91,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 @@ -103,10 +103,10 @@ size_t TCMHeap::getBlockSize(void *mh) { void TCMHeap::dealloc(void *mh) { // be an enabler for broken code - if (mh == NULL) return; + 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); @@ -126,7 +126,7 @@ void TCMHeap::dealloc(void *mh) { void *TCMHeap::rc_realloc(void *mh, size_t size) { void *res = alloc(size); - if (mh == NULL) return res; + if (mh == nullptr) return res; tcm::Span *span = m_heap.GetDescriptor(ADDR_TO_PAGEID(mh)); if (span->sizeclass == 0) { std::memcpy(res, mh, std::min(span->length * kPageSize, size)); diff --git a/storage/tianmu/mm/tcm_heap_policy.h b/storage/tianmu/mm/tcm_heap_policy.h index 39a7f93f87..4611431996 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 f3cbc2fb66..fd0d669302 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) return; + if (ptr == nullptr) return; s = Instance()->rc_msize(ptr, this); Instance()->dealloc(ptr, this); m_sizeAllocated -= s; @@ -77,11 +77,11 @@ void TraceableObject::dealloc(void *ptr) { } void *TraceableObject::rc_realloc(void *ptr, size_t size, BLOCK_TYPE type) { - if (ptr == NULL) return alloc(size, type); + 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; @@ -99,26 +99,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 d07449bfd4..02442562b7 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 dad7909570..807889c198 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 8f2a3129c2..9c113a1c61 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 03549aa0a7..b159e88f52 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 a198d899a4..945646dfdf 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 a501e6fbf5..fb98991172 100644 --- a/storage/tianmu/system/large_buffer.cpp +++ b/storage/tianmu/system/large_buffer.cpp @@ -122,7 +122,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 0182c5ee6b..efc80370f7 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; @@ -225,8 +225,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 d78d388abd..75a304f3de 100644 --- a/storage/tianmu/types/rc_data_types.h +++ b/storage/tianmu/types/rc_data_types.h @@ -319,7 +319,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 reinterpret_cast(const_cast
(&dt)); } diff --git a/storage/tianmu/types/rc_item_types.cpp b/storage/tianmu/types/rc_item_types.cpp index d4d63f8527..eacd70d072 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 4059789dab..fc941c0586 100644 --- a/storage/tianmu/types/rc_num.cpp +++ b/storage/tianmu/types/rc_num.cpp @@ -431,7 +431,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 e35751389e..2f778e3b42 100644 --- a/storage/tianmu/types/value_parser4txt.cpp +++ b/storage/tianmu/types/value_parser4txt.cpp @@ -91,7 +91,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; } @@ -294,7 +294,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; } @@ -353,7 +353,7 @@ common::ErrorCode ValueParserForText::ParseReal(const BString &rcbs, RCNum &rcn, if (at == common::CT::UNK) at = common::CT::REAL; 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; } @@ -470,7 +470,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; } @@ -594,7 +594,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; @@ -785,7 +785,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; @@ -945,7 +945,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; @@ -1005,7 +1005,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 82c73f27ac..2eb197597a 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 3367b9597d..c0dcefeafe 100644 --- a/storage/tianmu/util/stack_trace.cpp +++ b/storage/tianmu/util/stack_trace.cpp @@ -43,7 +43,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; *end = '+'; @@ -64,7 +64,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; } diff --git a/storage/tianmu/util/timer.cpp b/storage/tianmu/util/timer.cpp index 652772528c..e02fc6b911 100644 --- a/storage/tianmu/util/timer.cpp +++ b/storage/tianmu/util/timer.cpp @@ -43,7 +43,7 @@ KillTimer::KillTimer(THD *thd, long secs) { 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; } diff --git a/storage/tianmu/vc/const_column.cpp b/storage/tianmu/vc/const_column.cpp index b69483106c..c02cbb91bc 100644 --- a/storage/tianmu/vc/const_column.cpp +++ b/storage/tianmu/vc/const_column.cpp @@ -26,7 +26,7 @@ namespace Tianmu { namespace vcolumn { ConstColumn::ConstColumn(core::ValueOrNull const &val, core::ColumnType const &c, bool shift_to_UTC) - : VirtualColumn(c, NULL), value(val) { + : VirtualColumn(c, nullptr), value(val) { dim = -1; if (ct.IsString()) ct.SetPrecision(c.GetPrecision()); if (c.GetTypeName() == common::CT::TIMESTAMP && shift_to_UTC) { @@ -55,7 +55,7 @@ ConstColumn::ConstColumn(core::ValueOrNull const &val, core::ColumnType const &c } } -ConstColumn::ConstColumn(const types::RCValueObject &v, const core::ColumnType &c) : VirtualColumn(c, NULL), value() { +ConstColumn::ConstColumn(const types::RCValueObject &v, const core::ColumnType &c) : VirtualColumn(c, nullptr), value() { dim = -1; if (c.IsString()) { value = core::ValueOrNull(v.ToBString()); diff --git a/storage/tianmu/vc/const_expr_column.h b/storage/tianmu/vc/const_expr_column.h index 26742b769f..e7a28cf0b0 100644 --- a/storage/tianmu/vc/const_expr_column.h +++ b/storage/tianmu/vc/const_expr_column.h @@ -59,7 +59,7 @@ class ConstExpressionColumn : public ExpressionColumn { ct = ct.RemovedLookup(); } - ConstExpressionColumn(ConstExpressionColumn const &cc) : ExpressionColumn(NULL, NULL, common::NULL_VALUE_32, NULL) { + ConstExpressionColumn(ConstExpressionColumn const &cc) : ExpressionColumn(nullptr, nullptr, common::NULL_VALUE_32, nullptr) { DEBUG_ASSERT(params.size() == 0 && "cannot copy expressions"); last_val = cc.last_val; ct = cc.ct; diff --git a/storage/tianmu/vc/expr_column.cpp b/storage/tianmu/vc/expr_column.cpp index 471ce1fe86..abde94bcdf 100644 --- a/storage/tianmu/vc/expr_column.cpp +++ b/storage/tianmu/vc/expr_column.cpp @@ -62,7 +62,7 @@ ExpressionColumn::ExpressionColumn(core::MysqlExpression *expr, core::TempTable // parameter // parameter type is not available here, must be set later (EvalType()) params.insert(v); - // param_buf[v].second = NULL; //assigned + // param_buf[v].second = nullptr; //assigned // by // SetBufs() } diff --git a/storage/tianmu/vc/expr_column.h b/storage/tianmu/vc/expr_column.h index 2c2bf9b9a9..9b90bbc159 100644 --- a/storage/tianmu/vc/expr_column.h +++ b/storage/tianmu/vc/expr_column.h @@ -113,7 +113,7 @@ class ExpressionColumn : public VirtualColumn { const core::MysqlExpression::tianmu_fields_cache_t &GetTIANMUItems() const override { return expr_->GetTIANMUItems(); } - core::MysqlExpression *expr_; //!= NULL if ExpressionColumn encapsulates an expression. Note - a + core::MysqlExpression *expr_; //!= nullptr if ExpressionColumn encapsulates an expression. Note - a //! constant is an expression private: diff --git a/storage/tianmu/vc/in_set_column.cpp b/storage/tianmu/vc/in_set_column.cpp index be6a5d5222..19f4beb05b 100644 --- a/storage/tianmu/vc/in_set_column.cpp +++ b/storage/tianmu/vc/in_set_column.cpp @@ -32,7 +32,7 @@ InSetColumn::InSetColumn(core::ColumnType const &ct, core::MultiIndex *mind, full_cache(false), cache(mind->ValueOfPower()), expected_type(ct), - last_mit(NULL), + last_mit(nullptr), last_mit_size(0) { std::set uvms; for (auto &it : columns) { @@ -54,7 +54,7 @@ InSetColumn::InSetColumn(core::ColumnType const &ct, core::MultiIndex *mind, } InSetColumn::InSetColumn(core::ColumnType const &ct, core::MultiIndex *mind, core::ValueSet &external_valset) - : MultiValColumn(ct, mind), cache(external_valset), expected_type(ct), last_mit(NULL), last_mit_size(0) { + : MultiValColumn(ct, mind), cache(external_valset), expected_type(ct), last_mit(nullptr), last_mit_size(0) { dim = -1; is_const = true; full_cache = true; @@ -206,7 +206,7 @@ void InSetColumn::PrepareCache(const core::MIIterator &mit, const int64_t &at_le int max_str_size = 0; for (; (it != end) && (bin_cache.NoVals() <= at_least); ++it) max_str_size += (*it)->MaxStringSize(); it = columns.begin(); - types::BString buf(NULL, types::CollationBufLen(GetCollation(), max_str_size), true); + types::BString buf(nullptr, types::CollationBufLen(GetCollation(), max_str_size), true); for (; (it != end) && (bin_cache.NoVals() <= at_least); ++it) { types::BString s; (*it)->GetValueString(s, mit); @@ -289,7 +289,7 @@ bool InSetColumn::CopyCondImpl(const core::MIIterator &mit, types::CondArray &co types::BString s; it->GetValueString(s, mit); if (s.IsNull()) { - TIANMU_LOG(LogCtl_Level::WARN, "DoCopyCond condition is NULL"); + TIANMU_LOG(LogCtl_Level::WARN, "DoCopyCond condition is nullptr"); condition.clear(); success = false; break; diff --git a/storage/tianmu/vc/single_column.cpp b/storage/tianmu/vc/single_column.cpp index e9a5daa71a..d1f50f7226 100644 --- a/storage/tianmu/vc/single_column.cpp +++ b/storage/tianmu/vc/single_column.cpp @@ -135,7 +135,7 @@ types::BString SingleColumn::GetMaxStringImpl(const core::MIIterator &mit) { int64_t SingleColumn::GetApproxDistValsImpl(bool incl_nulls, core::RoughMultiIndex *rough_mind) { if (rough_mind) return col_->ApproxDistinctVals(incl_nulls, mind->GetFilter(dim), rough_mind->GetRSValueTable(dim), true); - return col_->ApproxDistinctVals(incl_nulls, mind->GetFilter(dim), NULL, mind->NullsExist(dim)); + return col_->ApproxDistinctVals(incl_nulls, mind->GetFilter(dim), nullptr, mind->NullsExist(dim)); } int64_t SingleColumn::GetExactDistVals() { return col_->ExactDistinctVals(mind->GetFilter(dim)); } @@ -156,7 +156,7 @@ bool SingleColumn::TryToMerge(core::Descriptor &d1, core::Descriptor &d2) { retu size_t SingleColumn::MaxStringSizeImpl() // maximal byte string length in column { - return col_->MaxStringSize(mind->NumOfDimensions() == 0 ? NULL : mind->GetFilter(dim)); + return col_->MaxStringSize(mind->NumOfDimensions() == 0 ? nullptr : mind->GetFilter(dim)); } core::PackOntologicalStatus SingleColumn::GetPackOntologicalStatusImpl(const core::MIIterator &mit) { @@ -170,7 +170,7 @@ void SingleColumn::EvaluatePackImpl(core::MIUpdatingIterator &mit, core::Descrip common::RSValue SingleColumn::RoughCheckImpl(const core::MIIterator &mit, core::Descriptor &d) { if (mit.GetCurPackrow(dim) >= 0) { // check whether isn't it a join - SingleColumn *sc = NULL; + SingleColumn *sc = nullptr; if (d.val1.vc && static_cast(d.val1.vc->IsSingleColumn())) sc = static_cast(d.val1.vc); if (sc && sc->dim != dim) // Pack2Pack rough check return col_->RoughCheck(mit.GetCurPackrow(dim), mit.GetCurPackrow(sc->dim), d); diff --git a/storage/tianmu/vc/single_column.h b/storage/tianmu/vc/single_column.h index 142ab57009..632ecd1c20 100644 --- a/storage/tianmu/vc/single_column.h +++ b/storage/tianmu/vc/single_column.h @@ -135,7 +135,7 @@ class SingleColumn : public VirtualColumn { return dummy; } - core::PhysicalColumn *col_; //!= NULL if SingleColumn encapsulates a single + core::PhysicalColumn *col_; //!= nullptr if SingleColumn encapsulates a single //! column only (no expression) // this an easily accessible copy // var_map[0].tab->GetColumn(var_map[0].col_ndx) diff --git a/storage/tianmu/vc/subselect_column.cpp b/storage/tianmu/vc/subselect_column.cpp index da09b7f25f..c3ca3d632b 100644 --- a/storage/tianmu/vc/subselect_column.cpp +++ b/storage/tianmu/vc/subselect_column.cpp @@ -170,7 +170,7 @@ common::Tribool SubSelectColumn::ContainsImpl(core::MIIterator const &mit, types // If the sub-select is something like 'select null from xxx' then there // is no need to execute the sub-select, just return common::TRIBOOL_UNKNOWN. VirtualColumn *vc = subq->GetAttrP(col_idx)->term.vc; - if (vc->IsFullConst() && vc->IsNull(core::MIIterator(NULL, mind->ValueOfPower()))) return common::TRIBOOL_UNKNOWN; + if (vc->IsFullConst() && vc->IsNull(core::MIIterator(nullptr, mind->ValueOfPower()))) return common::TRIBOOL_UNKNOWN; PrepareSubqResult(mit, false); common::Tribool res = false; @@ -310,7 +310,7 @@ int64_t SubSelectColumn::AtLeastNoDistinctValuesImpl(core::MIIterator const &mit vals.Prepare(expected_type_.GetTypeName(), expected_type_.GetScale(), expected_type_.GetCollation()); if (types::RequiresUTFConversions(GetCollation()) && Type().IsString()) { - types::BString buf(NULL, types::CollationBufLen(GetCollation(), subq->MaxStringSize(col_idx)), true); + types::BString buf(nullptr, types::CollationBufLen(GetCollation(), subq->MaxStringSize(col_idx)), true); for (int64_t i = 0; vals.NoVals() < at_least && i < subq->NumOfObj(); i++) { if (!subq->IsNull(i, col_idx)) { types::BString s; diff --git a/storage/tianmu/vc/type_cast_column.cpp b/storage/tianmu/vc/type_cast_column.cpp index 671b46a4a0..54e8bee214 100644 --- a/storage/tianmu/vc/type_cast_column.cpp +++ b/storage/tianmu/vc/type_cast_column.cpp @@ -33,7 +33,7 @@ TypeCastColumn::TypeCastColumn(const TypeCastColumn &c) : VirtualColumn(c) { } String2NumCastColumn::String2NumCastColumn(VirtualColumn *from, core::ColumnType const &to) : TypeCastColumn(from, to) { - core::MIIterator mit(NULL, PACK_INVALID); + core::MIIterator mit(nullptr, PACK_INVALID); full_const = vc->IsFullConst(); if (full_const) { types::BString rs; @@ -194,7 +194,7 @@ String2DateTimeCastColumn::String2DateTimeCastColumn(VirtualColumn *from, core:: full_const = vc->IsFullConst(); if (full_const) { types::BString rbs; - core::MIIterator mit(NULL, PACK_INVALID); + core::MIIterator mit(nullptr, PACK_INVALID); vc->GetValueString(rbs, mit); if (rbs.IsNull()) { val = common::NULL_VALUE_64; @@ -332,10 +332,10 @@ int64_t String2DateTimeCastColumn::GetMaxInt64Impl(const core::MIIterator &m) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Num2DateTimeCastColumn::Num2DateTimeCastColumn(VirtualColumn *from, core::ColumnType const &to) : String2DateTimeCastColumn(from, to) { - core::MIIterator mit(NULL, PACK_INVALID); + core::MIIterator mit(nullptr, PACK_INVALID); full_const = vc->IsFullConst(); if (full_const) { - core::MIIterator mit(NULL, PACK_INVALID); + core::MIIterator mit(nullptr, PACK_INVALID); val = vc->GetValueInt64(mit); // rcv = from->GetValue(mit); types::RCDateTime rcdt; @@ -438,7 +438,7 @@ int64_t Num2DateTimeCastColumn::GetValueInt64Impl(const core::MIIterator &mit) { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DateTime2VarcharCastColumn::DateTime2VarcharCastColumn(VirtualColumn *from, core::ColumnType const &to) : TypeCastColumn(from, to) { - core::MIIterator mit(NULL, PACK_INVALID); + core::MIIterator mit(nullptr, PACK_INVALID); full_const = vc->IsFullConst(); if (full_const) { int64_t i = vc->GetValueInt64(mit); @@ -467,7 +467,7 @@ types::RCValueObject DateTime2VarcharCastColumn::GetValueImpl(const core::MIIter Num2VarcharCastColumn::Num2VarcharCastColumn(VirtualColumn *from, core::ColumnType const &to) : TypeCastColumn(from, to) { - core::MIIterator mit(NULL, PACK_INVALID); + core::MIIterator mit(nullptr, PACK_INVALID); full_const = vc->IsFullConst(); if (full_const) { rcv = vc->GetValue(mit); @@ -509,7 +509,7 @@ void Num2VarcharCastColumn::GetValueStringImpl(types::BString &s, const core::MI ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DateTime2NumCastColumn::DateTime2NumCastColumn(VirtualColumn *from, core::ColumnType const &to) : TypeCastColumn(from, to) { - core::MIIterator mit(NULL, PACK_INVALID); + core::MIIterator mit(nullptr, PACK_INVALID); full_const = vc->IsFullConst(); if (full_const) { rcv = vc->GetValue(mit); @@ -598,7 +598,7 @@ types::RCValueObject DateTime2NumCastColumn::GetValueImpl(const core::MIIterator TimeZoneConversionCastColumn::TimeZoneConversionCastColumn(VirtualColumn *from) : TypeCastColumn(from, core::ColumnType(common::CT::DATETIME)) { DEBUG_ASSERT(from->TypeName() == common::CT::TIMESTAMP); - core::MIIterator mit(NULL, PACK_INVALID); + core::MIIterator mit(nullptr, PACK_INVALID); full_const = vc->IsFullConst(); if (full_const) { int64_t v = vc->GetValueInt64(mit); diff --git a/storage/tianmu/vc/virtual_column_base.cpp b/storage/tianmu/vc/virtual_column_base.cpp index b0250694ac..9eebdb8d86 100644 --- a/storage/tianmu/vc/virtual_column_base.cpp +++ b/storage/tianmu/vc/virtual_column_base.cpp @@ -57,7 +57,7 @@ std::set VirtualColumnBase::GetDimensions() { } int64_t VirtualColumnBase::NumOfTuples() { - if (mind == NULL) // constant + if (mind == nullptr) // constant return 1; core::DimensionVector dims(mind->NumOfDimensions()); MarkUsedDims(dims); @@ -235,8 +235,8 @@ common::RSValue VirtualColumnBase::RoughCheckImpl(const core::MIIterator &mit, c } common::RSValue res = common::RSValue::RS_SOME; - if (d.val1.vc == NULL || - ((d.op == common::Operator::O_BETWEEN || d.op == common::Operator::O_NOT_BETWEEN) && d.val2.vc == NULL)) + if (d.val1.vc == nullptr || + ((d.op == common::Operator::O_BETWEEN || d.op == common::Operator::O_NOT_BETWEEN) && d.val2.vc == nullptr)) return common::RSValue::RS_SOME; // irregular descriptor - cannot use VirtualColumn // rough statistics // In all other situations: common::RSValue::RS_NONE for nulls only diff --git a/storage/tianmu/vc/virtual_column_base.h b/storage/tianmu/vc/virtual_column_base.h index cb88d94f56..acf3369629 100644 --- a/storage/tianmu/vc/virtual_column_base.h +++ b/storage/tianmu/vc/virtual_column_base.h @@ -93,13 +93,13 @@ class VirtualColumnBase : public core::Column { inline int64_t GetValueInt64(const core::MIIterator &mit) { return GetValueInt64Impl(mit); } virtual int64_t GetNotNullValueInt64(const core::MIIterator &mit) = 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 mit points to a row in an Multiindex, requested column value comes - * from this row \return \b true if column value is NULL, \b false otherwise + * from this row \return \b true if column value is nullptr, \b false otherwise */ inline bool IsNull(const core::MIIterator &mit) { return IsNullImpl(mit); } /*! \brief Get a non null-terminated String from a column @@ -265,7 +265,7 @@ class VirtualColumnBase : public core::Column { * incl. nulls (or not) Depends on the current multiindex state, e.g. KNs, if * there are nulls etc. */ - int64_t GetApproxDistVals(bool incl_nulls, core::RoughMultiIndex *rough_mind = NULL); + int64_t GetApproxDistVals(bool incl_nulls, core::RoughMultiIndex *rough_mind = nullptr); /*! \brief Return the exact number of distinct values of the whole column, * without nulls. If the exact number is unsure, return common::NULL_VALUE_64. @@ -418,7 +418,7 @@ class VirtualColumnBase : public core::Column { */ virtual VirtualColumn *Copy() { DEBUG_ASSERT(0 && "not implemented"); - return NULL; + return nullptr; } virtual bool IsThreadSafe() { return false; }