Skip to content

Commit

Permalink
fix(tianmu): fix some refactor code issue. (#11)
Browse files Browse the repository at this point in the history
[summary]
1 fix some function has the same name with class member variable name;
2 some class member variable is not google style;
  • Loading branch information
lujiashun authored and mergify[bot] committed Nov 8, 2022
1 parent 19b9e36 commit 0af724e
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 47 deletions.
4 changes: 2 additions & 2 deletions storage/tianmu/compress/code_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class CoderStream : protected ArithCoder {
my_stream_.Reset(buf, len, pos);
str_ = &my_stream_;
}
void Reset(BitStream *str_ = 0) { str_ = str_; }
void Reset(BitStream *str = 0) { str_ = str; }
CoderStream() { Reset(); }
CoderStream(char *buf, uint len, uint pos = 0) { Reset(buf, len, pos); }
CoderStream(BitStream *str_) { Reset(str_); }
CoderStream(BitStream *str) { Reset(str); }
virtual ~CoderStream() {}
using ArithCoder::BaseT;
using ArithCoder::MAX_TOTAL_;
Expand Down
18 changes: 9 additions & 9 deletions storage/tianmu/compress/data_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class DataStream {
using uint64_t = unsigned long long;

void Reset() { pos_ = 0; }
void Reset(uint len_, uint pos_ = 0) {
len_ = len_;
pos_ = pos_;
void Reset(uint len, uint pos = 0) {
len_ = len;
pos_ = pos;
}
void Reset(char *buf, uint len, uint pos = 0) {
buf_ = (uchar *)buf;
Expand All @@ -57,7 +57,7 @@ class DataStream {
virtual ~DataStream() {}
char *GetBuf() { return (char *)buf_; }
uint GetPos() { return pos_; }
void SetPos(uint pos_) { pos_ = pos_; }
void SetPos(uint pos) { pos_ = pos; }
bool CanRead() { return pos_ < len_; }
bool CanWrite() { return pos_ < len_; }
virtual uchar Get() = 0;
Expand Down Expand Up @@ -85,18 +85,18 @@ class BitStream : public DataStream {
DataStream::Reset();
clrlen_ = 0;
}
void Reset(uint len_, uint pos_ = 0) {
DataStream::Reset(len_, pos_);
void Reset(uint len, uint pos = 0) {
DataStream::Reset(len, pos);
clrlen_ = 0;
}
void Reset(char *buf_, uint len_, uint pos_ = 0) {
DataStream::Reset(buf_, len_, pos_);
void Reset(char *buf, uint len, uint pos = 0) {
DataStream::Reset(buf, len, pos);
clrlen_ = 0;
}

// len_, pos_ - numbers of BITS
BitStream() { Reset(0, 0, 0); }
BitStream(char *buf_, uint len_, uint pos_ = 0) { Reset(buf_, len_, pos_); }
BitStream(char *buf, uint len, uint pos = 0) { Reset(buf, len, pos); }
virtual ~BitStream() {}
uchar NextBit(); // show the next bit, but don't remove it from the stream
uchar NextByte(); // show the next byte, but don't remove it from the stream
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 @@ -61,7 +61,7 @@ class PPMModel {
static const int N_Symb_ = 256;

public:
virtual void TransformForPPM(PPMParam param_ = PPMParam()) = 0;
virtual void TransformForPPM(PPMParam param = PPMParam()) = 0;

virtual void InitPPM() = 0;

Expand Down
4 changes: 2 additions & 2 deletions storage/tianmu/compress/suffix_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ void SuffixTree<Symb, NSymb>::Print(std::ostream &str, uint flags, PNode n, PNod
//------------------------------------------------------------------------

template <class Symb, int NSymb>
void SuffixTree<Symb, NSymb>::TransformForPPM(PPMParam param_) {
param_ = param_;
void SuffixTree<Symb, NSymb>::TransformForPPM(PPMParam param) {
param_ = param;

// compute counts of all nodes_ in the 'tree'
SetCounts();
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/compress/suffix_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class SuffixTree : public PPMModel {
//-------------------------------------------------------------------------
// definitions for PPM

void TransformForPPM(PPMParam param_ = PPMParam()) override;
void TransformForPPM(PPMParam param = PPMParam()) override;
void InitPPM() override { state_ = ROOT_; }
// compression: [str,len_total] -> [len_of_edge,rng,total]
void Move(Symb *str, int &len, Range &rng, Count &total) override;
Expand Down
4 changes: 2 additions & 2 deletions storage/tianmu/compress/word_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ void WordGraph::Print(std::ostream &str, [[maybe_unused]] uint flags) {
// transformation for PPM
//------------------------------------------------------------------------

void WordGraph::TransformForPPM(PPMParam param_) {
param_ = param_;
void WordGraph::TransformForPPM(PPMParam param) {
param_ = param;

// propagate 'stop' numbers from final nodes_ to all border-path nodes_
PropagateStop();
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/compress/word_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class WordGraph : public PPMModel {
//-------------------------------------------------------------------------
// definitions for PPM

void TransformForPPM(PPMParam param_ = PPMParam()) override;
void TransformForPPM(PPMParam param = PPMParam()) override;
void InitPPM() override;

// compression: [str,len_total] -> [len_of_edge,rng,total]
Expand Down
2 changes: 1 addition & 1 deletion storage/tianmu/types/rc_item_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Item_sum_int_rcbase : public Item_sum_num {
maybe_null = null_value = 0;
}

void int64_value(int64_t &value_);
void int64_value(int64_t &value);

void clear() override;
bool add() override;
Expand Down
30 changes: 15 additions & 15 deletions storage/tianmu/types/rc_num.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ RCNum::RCNum(int64_t value_, short scale, bool is_double_, common::CT attrt) {
Assign(value_, scale, is_double_, attrt);
}

RCNum::RCNum(double value_)
: value_(*(int64_t *)&value_), scale_(0), is_double_(true), is_dot_(false), attr_type_(common::CT::REAL) {
RCNum::RCNum(double value)
: value_(*(int64_t *)&value), scale_(0), is_double_(true), is_dot_(false), attr_type_(common::CT::REAL) {
null_ = (value_ == NULL_VALUE_D ? true : false);
}

Expand All @@ -51,10 +51,10 @@ RCNum::RCNum(const RCNum &rcn)

RCNum::~RCNum() {}

RCNum &RCNum::Assign(int64_t value_, short scale, bool is_double_, common::CT attrt) {
this->value_ = value_;
RCNum &RCNum::Assign(int64_t value, short scale, bool is_double, common::CT attrt) {
this->value_ = value;
this->scale_ = scale;
this->is_double_ = is_double_;
this->is_double_ = is_double;
this->attr_type_ = attrt;

if (scale != -1 && !is_double_) {
Expand All @@ -76,8 +76,8 @@ RCNum &RCNum::Assign(int64_t value_, short scale, bool is_double_, common::CT at
return *this;
}

RCNum &RCNum::Assign(double value_) {
this->value_ = *(int64_t *)&value_;
RCNum &RCNum::Assign(double value) {
this->value_ = *(int64_t *)&value;
this->scale_ = 0;
this->is_double_ = true;
this->is_dot_ = false;
Expand Down Expand Up @@ -411,18 +411,18 @@ RCNum &RCNum::operator*=(const RCNum &rcn) {
return *this;
}

void fcvt(char *buf_, double val_, int digits_, int *dec_, int *sign_) {
void fcvt(char *buf, double val, int digits, int *dec, int *sign) {
static int const fmtlen = 10;
char format[fmtlen + 1];
std::snprintf(format, fmtlen + 1, "%%.%df", digits_);
std::snprintf(buf_, digits_, format, val_);
int len(std::strlen(buf_));
(*sign_) = (buf_[0] == '-') ? 1 : 0;
(*sign_) && std::memmove(buf_, buf_ + 1, len);
char *pbuf(buf_);
std::snprintf(format, fmtlen + 1, "%%.%df", digits);
std::snprintf(buf, digits, format, val);
int len(std::strlen(buf));
(*sign) = (buf[0] == '-') ? 1 : 0;
(*sign) && std::memmove(buf, buf + 1, len);
char *pbuf(buf);
::strsep(&pbuf, ".,");
if (pbuf) {
(*dec_) = pbuf - buf_ - 1;
(*dec) = pbuf - buf - 1;
std::memmove(pbuf - 1, pbuf, std::strlen(pbuf) + 1);
}
return;
Expand Down
16 changes: 8 additions & 8 deletions storage/tianmu/types/text_stat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ TextStat::TextStat() {

bool TextStat::AddString(const BString &rcbs) {
size_t len = rcbs.size();
if (len > TAB_SIZE) {
if (len > TAB_SIZE_) {
valid_ = false;
return false;
}
Expand All @@ -41,7 +41,7 @@ bool TextStat::AddString(const BString &rcbs) {
chars_found_[256 * i + uchar(rcbs[i])] = 1;
}

if (len < TAB_SIZE)
if (len < TAB_SIZE_)
chars_found_[256 * len] = 1; // value of len n puts 0 on position n (starting with 0)
if (len > max_string_size_)
max_string_size_ = len;
Expand All @@ -51,7 +51,7 @@ bool TextStat::AddString(const BString &rcbs) {

bool TextStat::AddChar(uchar v, int pos) // return false if out of range
{
if (static_cast<size_t>(pos) >= TAB_SIZE || v == 0) {
if (static_cast<size_t>(pos) >= TAB_SIZE_ || v == 0) {
valid_ = false;
return false;
}
Expand All @@ -64,9 +64,9 @@ bool TextStat::AddChar(uchar v, int pos) // return false if out of range

void TextStat::AddLen(int pos) // value of len n puts 0 on position n (starting with 0)
{
if (static_cast<size_t>(pos) == TAB_SIZE)
if (static_cast<size_t>(pos) == TAB_SIZE_)
return;
DEBUG_ASSERT(static_cast<size_t>(pos) < TAB_SIZE);
DEBUG_ASSERT(static_cast<size_t>(pos) < TAB_SIZE_);
chars_found_[256 * pos] = 1;
if (static_cast<size_t>(pos) > max_string_size_)
max_string_size_ = pos;
Expand Down Expand Up @@ -151,7 +151,7 @@ int64_t TextStat::Encode(const BString &rcbs,
{
int64_t res = 0;
size_t len = rcbs.size();
if (len > TAB_SIZE)
if (len > TAB_SIZE_)
return common::NULL_VALUE_64;
int charcode;
for (size_t i = 0; i < len; i++) {
Expand Down Expand Up @@ -205,9 +205,9 @@ BString TextStat::Decode(int64_t code) {

int charcode;
int len = max_string_size_;
char buf_val[TMP_BUFFER_SIZE] = {0};
char buf_val[TMP_BUFFER_SIZE_] = {0};

DEBUG_ASSERT(max_string_size_ < TMP_BUFFER_SIZE);
DEBUG_ASSERT(max_string_size_ < TMP_BUFFER_SIZE_);
buf_val[max_string_size_] = 0;
for (int i = max_string_size_ - 1; i >= 0; i--) {
charcode = 0;
Expand Down
10 changes: 5 additions & 5 deletions storage/tianmu/types/text_stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ class TextStat final {
void Invalidate() { valid_ = false; }

private:
static constexpr int TMP_BUFFER_SIZE = 49;
static constexpr int TMP_BUFFER_SIZE_ = 49;

static constexpr size_t TAB_SIZE = 48;
static constexpr size_t TAB_SIZE_ = 48;

// binary length of position n, value 0 means that this is a constant
// character
std::array<int, TAB_SIZE> len_table_;
std::array<int, TAB_SIZE_> len_table_;

// encode_table[c + 256 * n] is a character for code c on position n
std::array<uchar, 256 * TAB_SIZE> encode_table_;
std::array<uchar, 256 * TAB_SIZE_> encode_table_;

// a buffer for two purposes: collecting 0/1 info about chars found, or
// collecting decoding into
std::array<uchar, 256 * TAB_SIZE> chars_found_;
std::array<uchar, 256 * TAB_SIZE_> chars_found_;

bool chars_found_for_decoding_{false}; // true, if chars_found is initialized for value decoding
bool valid_{true};
Expand Down

0 comments on commit 0af724e

Please sign in to comment.