Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tianmu): porting code from pr_758 to improve code #11 #870

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sql/sql_load.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
DBUG_RETURN(TRUE);
}
// TIANMU UPGRADE BEGIN
if (!Tianmu::dbhandler::tianmu_load(thd, ex, table_list, (void*) &lf_info)) {
if (!Tianmu::handler::tianmu_load(thd, ex, table_list, (void*) &lf_info)) {
DBUG_RETURN(FALSE);
}
//END
Expand Down
20 changes: 10 additions & 10 deletions sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3261,11 +3261,11 @@ case SQLCOM_PREPARE:
//res= handle_query(thd, lex, result, SELECT_NO_UNLOCK, 0);
// Tianmu hook added

int sdb_res, free_join_from_sdb, optimize_after_sdb;//TIANMU UPGRADE
if (Tianmu::dbhandler::TIANMU_HandleSelect(thd, lex, result, 0, sdb_res, optimize_after_sdb, free_join_from_sdb, (int)true) == 0)
res = handle_query(thd, lex, result, SELECT_NO_UNLOCK, (ulong)0, optimize_after_sdb, free_join_from_sdb);
int tianmu_res, free_join_from_tianmu, optimize_after_tianmu;
if (Tianmu::handler::ha_my_tianmu_query(thd, lex, result, 0, tianmu_res, optimize_after_tianmu, free_join_from_tianmu, (int)true) == 0)
res = handle_query(thd, lex, result, SELECT_NO_UNLOCK, (ulong)0, optimize_after_tianmu, free_join_from_tianmu);
else
res = sdb_res;
res = tianmu_res;

if (thd->lex->is_ignore() || thd->is_strict_mode())
thd->pop_internal_handler();
Expand Down Expand Up @@ -3727,7 +3727,7 @@ case SQLCOM_PREPARE:
if ((check_table_access(thd, SELECT_ACL, all_tables, FALSE, UINT_MAX, FALSE)
|| open_and_lock_tables(thd, all_tables, 0)))
goto error;
if (!Tianmu::dbhandler::TIANMU_SetStatementAllowed(thd, lex)) {
if (!Tianmu::handler::TIANMU_SetStatementAllowed(thd, lex)) {
goto error;
}
if (!(res= sql_set_variables(thd, lex_var_list)))
Expand Down Expand Up @@ -5178,13 +5178,13 @@ static bool execute_sqlcom_select(THD *thd, TABLE_LIST *all_tables)
}
//res= handle_query(thd, lex, result, 0, 0, 0, 0);

int sdb_res, free_join_from_sdb, optimize_after_sdb;//ATIMSTORE UPGRADE
if (Tianmu::dbhandler::TIANMU_HandleSelect(thd, lex, result, (ulong)0,
sdb_res, optimize_after_sdb, free_join_from_sdb) == 0) {
res = handle_query(thd, lex, result, (ulonglong)0, (ulonglong)0, optimize_after_sdb, free_join_from_sdb);
int tianmu_res, free_join_from_tianmu, optimize_after_tianmu;//ATIMSTORE UPGRADE
if (Tianmu::handler::ha_my_tianmu_query(thd, lex, result, (ulong)0,
tianmu_res, optimize_after_tianmu, free_join_from_tianmu) == 0) {
res = handle_query(thd, lex, result, (ulonglong)0, (ulonglong)0, optimize_after_tianmu, free_join_from_tianmu);
}
else
res = sdb_res;
res = tianmu_res;

delete analyse_result;
if (save_result != lex->result)
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_show.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5535,7 +5535,7 @@ static int get_schema_column_record(THD *thd, TABLE_LIST *tables,
table->field[IS_COLUMNS_GENERATION_EXPRESSION]->set_null();
//table->field[IS_COLUMNS_COLUMN_COMMENT]->store(field->comment.str,
// field->comment.length, cs);
Tianmu::dbhandler::TIANMU_UpdateAndStoreColumnComment(table, IS_COLUMNS_COLUMN_COMMENT, field, count - 1, cs);//TIANMU UPGRADE
Tianmu::handler::TIANMU_UpdateAndStoreColumnComment(table, IS_COLUMNS_COLUMN_COMMENT, field, count - 1, cs);//TIANMU UPGRADE
if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
}
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/base/core/posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/base/core/posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
12 changes: 6 additions & 6 deletions storage/tianmu/base/core/reactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ reactor::signals::signals() : _pending_signals(0) {}
reactor::signals::~signals() {
sigset_t mask;
sigfillset(&mask);
::pthread_sigmask(SIG_BLOCK, &mask, NULL);
::pthread_sigmask(SIG_BLOCK, &mask, nullptr);
}

reactor::signals::signal_handler::signal_handler(int signo, std::function<void()> &&handler)
Expand All @@ -151,7 +151,7 @@ reactor::signals::signal_handler::signal_handler(int signo, std::function<void()
auto r = ::sigaction(signo, &sa, nullptr);
throw_system_error_on(r == -1);
auto mask = make_sigset_mask(signo);
r = ::pthread_sigmask(SIG_UNBLOCK, &mask, NULL);
r = ::pthread_sigmask(SIG_UNBLOCK, &mask, nullptr);
throw_pthread_error(r);
}

Expand Down Expand Up @@ -214,7 +214,7 @@ static decltype(auto) install_signal_handler_stack() {
throw_system_error_on(r == -1);
return defer([mem = std::move(mem), prev_stack]() mutable {
try {
auto r = sigaltstack(&prev_stack, NULL);
auto r = sigaltstack(&prev_stack, nullptr);
throw_system_error_on(r == -1);
} catch (...) {
mem.release(); // We failed to restore previous stack, must leak it.
Expand Down Expand Up @@ -302,7 +302,7 @@ reactor::reactor(unsigned id)
sigset_t mask;
sigemptyset(&mask);
sigaddset(&mask, alarm_signal());
r = ::pthread_sigmask(SIG_BLOCK, &mask, NULL);
r = ::pthread_sigmask(SIG_BLOCK, &mask, nullptr);
assert(r == 0);
struct sigevent sev;
sev.sigev_notify = SIGEV_THREAD_ID;
Expand Down Expand Up @@ -780,7 +780,7 @@ void reactor::enable_timer(steady_clock_type::time_point when) {
itimerspec its;
its.it_interval = to_timespec(when);
its.it_value = to_timespec(when);
auto ret = timer_settime(_steady_clock_timer, TIMER_ABSTIME, &its, NULL);
auto ret = timer_settime(_steady_clock_timer, TIMER_ABSTIME, &its, nullptr);
throw_system_error_on(ret == -1);
}

Expand Down Expand Up @@ -2138,7 +2138,7 @@ void smp::configure(const options &opt) {
for (auto sig : {SIGSEGV}) {
sigdelset(&mask, sig);
}
auto r = ::pthread_sigmask(SIG_BLOCK, &mask, NULL);
auto r = ::pthread_sigmask(SIG_BLOCK, &mask, nullptr);
throw_pthread_error(r);
allocate_reactor(i);
_reactors[i] = &engine();
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/base/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ using intmax_t = __int64;
#if FMT_HAS_FEATURE(cxx_nullptr) || (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1600
#define FMT_NULL nullptr
#else
#define FMT_NULL NULL
#define FMT_NULL nullptr
#endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/common/txt_data_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ uint TxtDataFormat::StaticExtrnalSize(CT attrt, uint precision, int scale, const
return 23;
else if (attrt == CT::FLOAT)
return 15;
if (col == NULL)
if (col == nullptr)
return precision;
else
return precision / col->collation->mbmaxlen; // at creation, the charlen was multiplicated by
Expand Down
4 changes: 2 additions & 2 deletions storage/tianmu/compress/data_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_; }
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/compress/inc_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
};

Expand Down
14 changes: 7 additions & 7 deletions storage/tianmu/compress/inc_wgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ const uint IncWGraph::MatchLenCoder::c2[] = {120, 128};
const uint IncWGraph::MatchLenCoder::c3[] = {102, 119, 128};

IncWGraph::IncWGraph() : memory_() {
dump_ = NULL;
ROOT_ = NIL_ = START_ = NULL;
p_mask_ = NULL;
coder_ = NULL;
reclen_ = NULL;
records_ = NULL;
dump_ = nullptr;
ROOT_ = NIL_ = START_ = nullptr;
p_mask_ = nullptr;
coder_ = nullptr;
reclen_ = nullptr;
records_ = nullptr;
}

void IncWGraph::Init() {
nfinals_ = 0;
matchlen_cost_ = esc_cost_ = 0;
// p_mask_ = &_mask_; // uncomment if masking should be used
p_mask_ = NULL;
p_mask_ = nullptr;

// create ROOT_ and NIL_ nodes (and START_)
memory_.alloc(ROOT_);
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/compress/num_compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ inline CprsErr NumDecompress(T *dest, char *src, uint len, uint nrec, uint64_t m

template <class T>
NumCompressor<T>::NumCompressor(bool copy_only) : copy_only_(copy_only) {
dump_ = NULL;
dump_ = nullptr;

// Create filters_
filters_.reserve(N_FILTERS_);
Expand Down
20 changes: 10 additions & 10 deletions storage/tianmu/compress/ppm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
namespace Tianmu {
namespace compress {

FILE *PPM::dump_ = NULL;
FILE *PPM::dump_ = nullptr;
bool PPM::printstat_ = false;

PPM::PPM(const Symb *data, int dlen, ModelType mt, PPMParam param, uchar method) {
if ((data == NULL) || (dlen <= 0) || (mt == ModelType::ModelNull))
if ((data == nullptr) || (dlen <= 0) || (mt == ModelType::ModelNull))
return;

switch (mt) {
Expand Down Expand Up @@ -63,11 +63,11 @@ CprsErr PPM::CompressArith(char *dest, int &dlen, Symb *src, int slen) {
dlen = slen + 1;
return CprsErr::CPRS_SUCCESS;
}
WordGraph *wg = NULL;
WordGraph *wg = nullptr;
try {
wg = dynamic_cast<WordGraph *>(model_.get());
} catch (...) {
wg = NULL;
wg = nullptr;
}
if (wg)
ASSERT(wg->insatend_ == false, "should be 'wg->insatend_ == false'");
Expand Down Expand Up @@ -171,11 +171,11 @@ CprsErr PPM::DecompressArith(Symb *dest, int dlen, char *src, int slen) {
//}
// if(method != 1) return CprsErr::CPRS_ERR_VER;

WordGraph *wg = NULL;
WordGraph *wg = nullptr;
try {
wg = dynamic_cast<WordGraph *>(model_.get());
} catch (...) {
wg = NULL;
wg = nullptr;
}
if (wg)
ASSERT(wg->insatend_ == false, "should be 'wg->insatend_ == false'");
Expand Down Expand Up @@ -254,11 +254,11 @@ CprsErr PPM::Compress(char *dest, int &dlen, Symb *src, int slen) {
return CprsErr::CPRS_ERR_BUF;
dest[0] = 2; // compression method: with RangeCoder

WordGraph *wg = NULL;
WordGraph *wg = nullptr;
try {
wg = dynamic_cast<WordGraph *>(model_.get());
} catch (...) {
wg = NULL;
wg = nullptr;
}

if (wg)
Expand Down Expand Up @@ -322,11 +322,11 @@ CprsErr PPM::Decompress(Symb *dest, int dlen, char *src, int slen) {
if (method != 2)
return CprsErr::CPRS_ERR_VER;

WordGraph *wg = NULL;
WordGraph *wg = nullptr;
try {
wg = dynamic_cast<WordGraph *>(model_.get());
} catch (...) {
wg = NULL;
wg = nullptr;
}

if (wg)
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/compress/ppm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/compress/ppm_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class PPMModel {
// file for making logs during compression or decompression
FILE *log_file_;

PPMModel() : log_file_(NULL) {}
PPMModel() : log_file_(nullptr) {}
virtual ~PPMModel() {}
};

Expand Down
4 changes: 2 additions & 2 deletions storage/tianmu/compress/text_compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ CprsErr TextCompressor::DecompressCopy(char *dest, int dlen, char *src, [[maybe_
//---------------------------------------------------------------------------------------------------------

CprsErr TextCompressor::CompressPlain(char *dest, int &dlen, char *src, int slen, int ver, int lev) {
if ((dest == NULL) || (src == NULL) || (dlen <= 0) || (slen <= 0))
if ((dest == nullptr) || (src == nullptr) || (dlen <= 0) || (slen <= 0))
return CprsErr::CPRS_ERR_PAR;
if ((ver < 0) || (ver > 2) || (lev < 1) || (lev > 9))
return CprsErr::CPRS_ERR_VER;
Expand Down Expand Up @@ -182,7 +182,7 @@ CprsErr TextCompressor::CompressPlain(char *dest, int &dlen, char *src, int slen
}

CprsErr TextCompressor::DecompressPlain(char *dest, int dlen, char *src, int slen) {
if ((dest == NULL) || (src == NULL) || (dlen <= 0) || (slen <= 0))
if ((dest == nullptr) || (src == nullptr) || (dlen <= 0) || (slen <= 0))
return CprsErr::CPRS_ERR_PAR;
if (slen < 2)
return CprsErr::CPRS_ERR_BUF;
Expand Down
8 changes: 4 additions & 4 deletions storage/tianmu/compress/word_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down Expand Up @@ -296,7 +296,7 @@ void WordGraph::Clear() {
finals_.clear();
edges_.clear();
nodes_.clear();
data_ = NULL;
data_ = nullptr;
}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -750,7 +750,7 @@ void WordGraph::Move(PEdge e) {
}

void WordGraph::MakeLog(PNode stt, PEdge e) {
if (log_file_ == NULL)
if (log_file_ == nullptr)
return;
// if(e != ENIL_) {
// std::fprintf(log_file_, "F\n"); // forward transition
Expand Down
6 changes: 3 additions & 3 deletions storage/tianmu/core/aggregation_algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void AggregationAlgorithm::Aggregate(bool just_distinct, int64_t &limit, int64_t
continue;
}
if ((!just_distinct && cur_a.mode != common::ColOperation::GROUP_BY) || // aggregation
(just_distinct && cur_a.alias == NULL)) { // special case: hidden column for DISTINCT
(just_distinct && cur_a.alias == nullptr)) { // special case: hidden column for DISTINCT
bool already_added = false;
for (uint j = 0; j < i; j++) {
if (*(t->GetAttrP(j)) == cur_a) {
Expand Down Expand Up @@ -183,7 +183,7 @@ void AggregationAlgorithm::Aggregate(bool just_distinct, int64_t &limit, int64_t
}

if (all_done_in_one_row) {
for (uint i = 0; i < t->NumOfAttrs(); i++) { // left as uninitialized (NULL or 0)
for (uint i = 0; i < t->NumOfAttrs(); i++) { // left as uninitialized (nullptr or 0)
t->GetAttrP(i)->page_size = 1;
t->GetAttrP(i)->CreateBuffer(1);
}
Expand Down Expand Up @@ -282,7 +282,7 @@ void AggregationAlgorithm::MultiDimensionalGroupByScan(GroupByWrapper &gbw, int6
mit.Rewind(); // aggregated rows will be massively omitted packrow by
// packrow
rewind_needed = true;
for (uint i = 0; i < t->NumOfAttrs(); i++) { // left as uninitialized (NULL or 0)
for (uint i = 0; i < t->NumOfAttrs(); i++) { // left as uninitialized (nullptr or 0)
if (t->GetAttrP(i)->mode == common::ColOperation::DELAYED) {
MIDummyIterator m(1);
t->GetAttrP(i)->term.vc->LockSourcePacks(m);
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/core/aggregator_advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void AggregatorGroupConcat::PutAggregatedValue(unsigned char *buf, const types::
types::BString AggregatorGroupConcat::GetValueT(unsigned char *buf) {
auto it = lenmap.find(buf);
if (it == lenmap.end()) {
// cases that grouping value is NULL
// cases that grouping value is nullptr
return types::BString();
}

Expand Down
Loading