Skip to content

Commit

Permalink
init class members (#1406)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexStocks authored Apr 29, 2023
1 parent 90033e1 commit 834f55d
Show file tree
Hide file tree
Showing 54 changed files with 337 additions and 338 deletions.
34 changes: 17 additions & 17 deletions include/pika_admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
*/
class SlaveofCmd : public Cmd {
public:
SlaveofCmd(const std::string& name, int arity, uint16_t flag) : Cmd(name, arity, flag), is_noone_(false) {}
SlaveofCmd(const std::string& name, int arity, uint16_t flag) : Cmd(name, arity, flag), is_none_(false) {}
virtual void Do(std::shared_ptr<Partition> partition = nullptr);
virtual void Split(std::shared_ptr<Partition> partition, const HintKeys& hint_keys){};
virtual void Merge(){};
virtual Cmd* Clone() override { return new SlaveofCmd(*this); }

private:
std::string master_ip_;
int64_t master_port_;
bool is_noone_;
int64_t master_port_ = -1;
bool is_none_ = false;
virtual void DoInitial() override;
virtual void Clear() {
is_noone_ = false;
is_none_ = false;
master_ip_.clear();
master_port_ = 0;
}
Expand All @@ -48,16 +48,16 @@ class DbSlaveofCmd : public Cmd {

private:
std::string db_name_;
bool force_sync_;
bool is_noone_;
bool have_offset_;
int64_t filenum_;
int64_t offset_;
bool force_sync_ = false;
bool is_none_ = false;
bool have_offset_ = false;
int64_t filenum_ = 0;
int64_t offset_ = 0;
virtual void DoInitial() override;
virtual void Clear() {
db_name_.clear();
force_sync_ = false;
is_noone_ = false;
is_none_ = false;
have_offset_ = false;
}
};
Expand Down Expand Up @@ -116,7 +116,7 @@ class PurgelogstoCmd : public Cmd {
virtual Cmd* Clone() override { return new PurgelogstoCmd(*this); }

private:
uint32_t num_;
uint32_t num_ = 0;
std::string table_;
virtual void DoInitial() override;
};
Expand Down Expand Up @@ -216,8 +216,8 @@ class InfoCmd : public Cmd {

private:
InfoSection info_section_;
bool rescan_; // whether to rescan the keyspace
bool off_;
bool rescan_ = false; // whether to rescan the keyspace
bool off_ = false;
std::set<std::string> keyspace_scan_tables_;

const static std::string kInfoSection;
Expand Down Expand Up @@ -350,7 +350,7 @@ class ScandbCmd : public Cmd {
virtual Cmd* Clone() override { return new ScandbCmd(*this); }

private:
storage::DataType type_;
storage::DataType type_ = storage::kAll;
virtual void DoInitial() override;
virtual void Clear() { type_ = storage::kAll; }
};
Expand All @@ -365,8 +365,8 @@ class SlowlogCmd : public Cmd {
virtual Cmd* Clone() override { return new SlowlogCmd(*this); }

private:
int64_t number_;
SlowlogCmd::SlowlogCondition condition_;
int64_t number_ = 10;
SlowlogCmd::SlowlogCondition condition_ = kGET;
virtual void DoInitial() override;
virtual void Clear() {
number_ = 10;
Expand Down Expand Up @@ -413,7 +413,7 @@ class PKPatternMatchDelCmd : public Cmd {
virtual Cmd* Clone() override { return new PKPatternMatchDelCmd(*this); }

private:
storage::DataType type_;
storage::DataType type_ = storage::kAll;
std::string pattern_;
virtual void DoInitial() override;
};
Expand Down
26 changes: 13 additions & 13 deletions include/pika_binlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class Version {
// RWLock should be held when access members.
Status StableSave();

uint32_t pro_num_;
uint64_t pro_offset_;
uint64_t logic_id_;
uint32_t term_;
uint32_t pro_num_ = 0;
uint64_t pro_offset_ = 0;
uint64_t logic_id_ = 0;
uint32_t term_ = 0;

pthread_rwlock_t rwlock_;

Expand All @@ -42,7 +42,7 @@ class Version {
}

private:
pstd::RWFile* save_;
pstd::RWFile* save_ = NULL;

// No copying allowed;
Version(const Version&);
Expand Down Expand Up @@ -102,21 +102,21 @@ class Binlog {

std::atomic<bool> opened_;

Version* version_;
pstd::WritableFile* queue_;
pstd::RWFile* versionfile_;
Version* version_ = nullptr;
pstd::WritableFile* queue_ = nullptr;
pstd::RWFile* versionfile_ = nullptr;

pstd::Mutex mutex_;

uint32_t pro_num_;
uint32_t pro_num_ = 0;

int block_offset_;
int block_offset_ = 0;

char* pool_;
bool exit_all_consume_;
char* pool_ = nullptr;
bool exit_all_consume_ = false;
const std::string binlog_path_;

uint64_t file_size_;
uint64_t file_size_ = 0;

std::string filename_;

Expand Down
8 changes: 4 additions & 4 deletions include/pika_binlog_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ class PikaBinlogReader {
Status Consume(std::string* scratch, uint32_t* filenum, uint64_t* offset);

pthread_rwlock_t rwlock_;
uint32_t cur_filenum_;
uint64_t cur_offset_;
uint64_t last_record_offset_;
uint32_t cur_filenum_ = 0;
uint64_t cur_offset_ = 0;
uint64_t last_record_offset_ = 0;

std::shared_ptr<Binlog> logger_;
pstd::SequentialFile* queue_;
pstd::SequentialFile* queue_ = nullptr;

char* const backing_store_;
Slice buffer_;
Expand Down
10 changes: 5 additions & 5 deletions include/pika_binlog_transverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ class BinlogItem {
void set_offset(uint64_t offset);

private:
uint32_t exec_time_;
uint32_t term_id_;
uint64_t logic_id_;
uint32_t filenum_;
uint64_t offset_;
uint32_t exec_time_ = 0;
uint32_t term_id_ = 0;
uint64_t logic_id_ = 0;
uint32_t filenum_ = 0;
uint64_t offset_ = 0;
std::string content_;
std::vector<std::string> extends_;
};
Expand Down
2 changes: 1 addition & 1 deletion include/pika_bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BitGetCmd : public Cmd {

private:
std::string key_;
int64_t bit_offset_;
int64_t bit_offset_ = -1;
virtual void Clear() {
key_ = "";
bit_offset_ = -1;
Expand Down
2 changes: 1 addition & 1 deletion include/pika_client_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class PikaClientConn : public net::RedisConn {
struct ClientInfo {
int fd;
std::string ip_port;
int64_t last_interaction;
int64_t last_interaction = 0;
std::shared_ptr<PikaClientConn> conn;
};

Expand Down
2 changes: 1 addition & 1 deletion include/pika_client_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PikaClientProcessor {
size_t ThreadPoolCurQueueSize();

private:
net::ThreadPool* pool_;
net::ThreadPool* pool_ = nullptr;
std::vector<net::BGThread*> bg_threads_;
};
#endif // PIKA_CLIENT_PROCESSOR_H_
8 changes: 4 additions & 4 deletions include/pika_cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ class PkClusterSlotsSlaveofCmd : public Cmd {

private:
std::string ip_;
int64_t port_;
int64_t port_ = -1;
std::set<uint32_t> slots_;
bool force_sync_;
bool is_noone_;
bool is_none_;
virtual void DoInitial() override;
virtual void Clear() {
ip_.clear();
port_ = 0;
slots_.clear();
force_sync_ = false;
is_noone_ = false;
is_none_ = false;
table_name_.clear();
}
};
Expand All @@ -121,7 +121,7 @@ class PkClusterAddTableCmd : public Cmd {
virtual void Do(std::shared_ptr<Partition> partition = nullptr);

private:
int64_t slot_num_;
int64_t slot_num_ = 0;
void DoInitial() override;
Status AddTableSanityCheck();
void Clear() override {
Expand Down
2 changes: 1 addition & 1 deletion include/pika_cmd_table_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PikaCmdTableManager {
void InsertCurrentThreadDistributionMap();
bool CheckCurrentThreadDistributionMapExist(const std::thread::id& tid);

CmdTable* cmds_;
CmdTable* cmds_ = nullptr;

pthread_rwlock_t map_protector_;
std::unordered_map<std::thread::id, PikaDataDistribution*> thread_distribution_map_;
Expand Down
2 changes: 1 addition & 1 deletion include/pika_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class CmdRes {

private:
std::string message_;
CmdRet ret_;
CmdRet ret_ = kNone;
};

class Cmd : public std::enable_shared_from_this<Cmd> {
Expand Down
80 changes: 40 additions & 40 deletions include/pika_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,34 +462,34 @@ class PikaConf : public pstd::BaseConf {
private:
Status InternalGetTargetTable(const std::string& table_name, uint32_t* const target);

int port_;
int port_ = 0;
std::string slaveof_;
int slave_priority_;
int thread_num_;
int thread_pool_size_;
int sync_thread_num_;
int slave_priority_ = 0;
int thread_num_ = 0;
int thread_pool_size_ = 0;
int sync_thread_num_ = 0;
std::string log_path_;
std::string db_path_;
std::string db_sync_path_;
int expire_dump_days_;
int db_sync_speed_;
int expire_dump_days_ = 3;
int db_sync_speed_ = 0;
std::string compact_cron_;
std::string compact_interval_;
int64_t write_buffer_size_;
int64_t arena_block_size_;
int64_t max_write_buffer_size_;
int max_write_buffer_num_;
int64_t max_client_response_size_;
bool daemonize_;
int timeout_;
int64_t write_buffer_size_ = 0;
int64_t arena_block_size_ = 0;
int64_t max_write_buffer_size_ = 0;
int max_write_buffer_num_ = 0;
int64_t max_client_response_size_ = 0;
bool daemonize_ = false;
int timeout_ = 0;
std::string server_id_;
std::string requirepass_;
std::string masterauth_;
std::string userpass_;
std::vector<std::string> user_blacklist_;
std::atomic<bool> classic_mode_;
int databases_;
int default_slot_num_;
int databases_ = 0;
int default_slot_num_ = 0;
std::vector<TableStruct> table_structs_;
std::string default_table_;
std::string bgsave_path_;
Expand All @@ -498,29 +498,29 @@ class PikaConf : public pstd::BaseConf {

std::string compression_;
std::string compression_per_level_;
int maxclients_;
int root_connection_num_;
int maxclients_ = 0;
int root_connection_num_ = 0;
std::atomic<bool> slowlog_write_errorlog_;
std::atomic<int> slowlog_log_slower_than_;
int slowlog_max_len_;
int expire_logs_days_;
int expire_logs_nums_;
bool slave_read_only_;
int slowlog_max_len_ = 0;
int expire_logs_days_ = 0;
int expire_logs_nums_ = 0;
bool slave_read_only_ = false;
std::string conf_path_;
int max_cache_statistic_keys_;
int small_compaction_threshold_;
int max_background_flushes_;
int max_background_compactions_;
int max_cache_files_;
int max_bytes_for_level_multiplier_;
int64_t block_size_;
int64_t block_cache_;
int64_t num_shard_bits_;
bool share_block_cache_;
bool cache_index_and_filter_blocks_;
bool pin_l0_filter_and_index_blocks_in_cache_;
bool optimize_filters_for_hits_;
bool level_compaction_dynamic_level_bytes_;
int max_cache_statistic_keys_ = 0;
int small_compaction_threshold_ = 0;
int max_background_flushes_ = 0;
int max_background_compactions_ = 0;
int max_cache_files_ = 0;
int max_bytes_for_level_multiplier_ = 0;
int64_t block_size_ = 0;
int64_t block_cache_ = 0;
int64_t num_shard_bits_ = 0;
bool share_block_cache_ = false;
bool cache_index_and_filter_blocks_ = false;
bool pin_l0_filter_and_index_blocks_in_cache_ = false;
bool optimize_filters_for_hits_ = false;
bool level_compaction_dynamic_level_bytes_ = false;
int64_t rate_limiter_bandwidth_ = 200 * 1024 * 1024; // 200M
std::atomic<int> sync_window_size_;
std::atomic<int> max_conn_rbuf_size_;
Expand All @@ -536,11 +536,11 @@ class PikaConf : public pstd::BaseConf {
//
// Critical configure items
//
bool write_binlog_;
int target_file_size_base_;
int binlog_file_size_;
bool write_binlog_ = false;
int target_file_size_base_ = 0;
int binlog_file_size_ = 0;

PikaMeta* local_meta_;
PikaMeta* local_meta_ = nullptr;

pthread_rwlock_t rwlock_;
};
Expand Down
6 changes: 3 additions & 3 deletions include/pika_consensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Context {

private:
std::string path_;
pstd::RWFile* save_;
pstd::RWFile* save_ = nullptr;
// No copying allowed;
Context(const Context&);
void operator=(const Context&);
Expand Down Expand Up @@ -213,10 +213,10 @@ class ConsensusCoordinator {
std::shared_ptr<Context> context_;

pthread_rwlock_t term_rwlock_;
uint32_t term_;
uint32_t term_ = 0;

std::string table_name_;
uint32_t partition_id_;
uint32_t partition_id_ = 0;

SyncProgress sync_pros_;
std::shared_ptr<StableLog> stable_logger_;
Expand Down
Loading

0 comments on commit 834f55d

Please sign in to comment.