未验证 提交 a3f58b70 编写于 作者: W wangxiaoning 提交者: GitHub

[fix code style]fix cpplint code style (#49742)

* fix ctr_double_accessor.h

* fix graph_brpc_client.h non-const reference to pointer

* fix common_table.h

* fix graph_py_service.cc, server.cc, server.h
上级 504db4f5
...@@ -69,31 +69,33 @@ class GraphBrpcClient : public BrpcPsClient { ...@@ -69,31 +69,33 @@ class GraphBrpcClient : public BrpcPsClient {
int idx, int idx,
std::vector<int64_t> node_ids, std::vector<int64_t> node_ids,
int sample_size, int sample_size,
std::vector<std::vector<int64_t>>& res, std::vector<std::vector<int64_t>>& res, // NOLINT
std::vector<std::vector<float>>& res_weight, std::vector<std::vector<float>>& res_weight, // NOLINT
bool need_weight, bool need_weight,
int server_index = -1); int server_index = -1);
virtual std::future<int32_t> pull_graph_list(uint32_t table_id, virtual std::future<int32_t> pull_graph_list(
int type_id, uint32_t table_id,
int idx, int type_id,
int server_index, int idx,
int start, int server_index,
int size, int start,
int step, int size,
std::vector<FeatureNode>& res); int step,
virtual std::future<int32_t> random_sample_nodes(uint32_t table_id, std::vector<FeatureNode>& res); // NOLINT
int type_id, virtual std::future<int32_t> random_sample_nodes(
int idx, uint32_t table_id,
int server_index, int type_id,
int sample_size, int idx,
std::vector<int64_t>& ids); int server_index,
int sample_size,
std::vector<int64_t>& ids); // NOLINT
virtual std::future<int32_t> get_node_feat( virtual std::future<int32_t> get_node_feat(
const uint32_t& table_id, const uint32_t& table_id,
int idx, int idx,
const std::vector<int64_t>& node_ids, const std::vector<int64_t>& node_ids,
const std::vector<std::string>& feature_names, const std::vector<std::string>& feature_names,
std::vector<std::vector<std::string>>& res); std::vector<std::vector<std::string>>& res); // NOLINT
virtual std::future<int32_t> set_node_feat( virtual std::future<int32_t> set_node_feat(
const uint32_t& table_id, const uint32_t& table_id,
...@@ -108,10 +110,12 @@ class GraphBrpcClient : public BrpcPsClient { ...@@ -108,10 +110,12 @@ class GraphBrpcClient : public BrpcPsClient {
virtual std::future<int32_t> add_graph_node( virtual std::future<int32_t> add_graph_node(
uint32_t table_id, uint32_t table_id,
int idx, int idx,
std::vector<int64_t>& node_id_list, std::vector<int64_t>& node_id_list, // NOLINT
std::vector<bool>& is_weighted_list); std::vector<bool>& is_weighted_list); // NOLINT
virtual std::future<int32_t> remove_graph_node( virtual std::future<int32_t> remove_graph_node(
uint32_t table_id, int idx_, std::vector<int64_t>& node_id_list); uint32_t table_id,
int idx_,
std::vector<int64_t>& node_id_list); // NOLINT
virtual int32_t Initialize(); virtual int32_t Initialize();
int get_shard_num() { return shard_num; } int get_shard_num() { return shard_num; }
void set_shard_num(int shard_num) { this->shard_num = shard_num; } void set_shard_num(int shard_num) { this->shard_num = shard_num; }
......
...@@ -68,7 +68,7 @@ class PSServer { ...@@ -68,7 +68,7 @@ class PSServer {
virtual int32_t Configure( virtual int32_t Configure(
const PSParameter &config, const PSParameter &config,
PSEnvironment &env, PSEnvironment &env, // NOLINT
size_t server_rank, size_t server_rank,
const std::vector<framework::ProgramDesc> &server_sub_program = {}); const std::vector<framework::ProgramDesc> &server_sub_program = {});
...@@ -154,14 +154,14 @@ typedef std::function<void(void *)> PServerCallBack; ...@@ -154,14 +154,14 @@ typedef std::function<void(void *)> PServerCallBack;
class PServerClosure : public google::protobuf::Closure { class PServerClosure : public google::protobuf::Closure {
public: public:
PServerClosure(PServerCallBack callback) : _callback(callback) {} explicit PServerClosure(PServerCallBack callback) : _callback(callback) {}
virtual ~PServerClosure() {} virtual ~PServerClosure() {}
virtual void set_promise_value(int value) { virtual void set_promise_value(int value) {
for (auto &promise : _promises) { for (auto &promise : _promises) {
promise->set_value(value); promise->set_value(value);
} }
} }
void add_promise(std::shared_ptr<std::promise<int32_t>> &promise) { void add_promise(const std::shared_ptr<std::promise<int32_t>> &promise) {
_promises.push_back(promise); _promises.push_back(promise);
} }
...@@ -181,12 +181,12 @@ class PsBaseService : public PsService { ...@@ -181,12 +181,12 @@ class PsBaseService : public PsService {
_config = _server->Config(); _config = _server->Config();
return 0; return 0;
} }
virtual void service(::google::protobuf::RpcController *controller, void service(::google::protobuf::RpcController *controller,
const PsRequestMessage *request, const PsRequestMessage *request,
PsResponseMessage *response, PsResponseMessage *response,
::google::protobuf::Closure *done) override = 0; ::google::protobuf::Closure *done) override = 0;
virtual void set_response_code(PsResponseMessage &response, virtual void set_response_code(PsResponseMessage &response, // NOLINT
int err_code, int err_code,
const char *err_msg) { const char *err_msg) {
response.set_err_msg(err_msg); response.set_err_msg(err_msg);
......
...@@ -37,7 +37,7 @@ struct ReservoirValue { ...@@ -37,7 +37,7 @@ struct ReservoirValue {
counter = 0; counter = 0;
} }
ReservoirValue(uint32_t dim) { explicit ReservoirValue(uint32_t dim) {
this->dim = dim; this->dim = dim;
values.resize(dim); values.resize(dim);
counter = 0; counter = 0;
...@@ -72,8 +72,8 @@ class BarrierTable : public Table { ...@@ -72,8 +72,8 @@ class BarrierTable : public Table {
virtual void *GetShard(size_t shard_idx) { return 0; } virtual void *GetShard(size_t shard_idx) { return 0; }
virtual int32_t Pull(TableContext &context) { return 0; } virtual int32_t Pull(TableContext &context) { return 0; } // NOLINT
virtual int32_t Push(TableContext &context) { return 0; } virtual int32_t Push(TableContext &context) { return 0; } // NOLINT
int32_t Shrink(const std::string &param) override { return 0; } int32_t Shrink(const std::string &param) override { return 0; }
virtual void Clear() {} virtual void Clear() {}
...@@ -86,13 +86,13 @@ class BarrierTable : public Table { ...@@ -86,13 +86,13 @@ class BarrierTable : public Table {
} }
virtual int32_t InitializeShard() { return 0; } virtual int32_t InitializeShard() { return 0; }
virtual int32_t Initialize() override; int32_t Initialize() override;
// only for barrier // only for barrier
// 0: send_barrier 1: recv_barrier 2: complete // 0: send_barrier 1: recv_barrier 2: complete
virtual int32_t Barrier(const uint32_t trainer_id, int32_t Barrier(const uint32_t trainer_id,
const std::string barrier_type) override; const std::string barrier_type) override;
virtual int32_t SetTableMap( int32_t SetTableMap(
std::unordered_map<uint32_t, std::shared_ptr<Table>> *table_map) override; std::unordered_map<uint32_t, std::shared_ptr<Table>> *table_map) override;
private: private:
......
...@@ -75,10 +75,12 @@ class CtrDoubleAccessor : public ValueAccessor { ...@@ -75,10 +75,12 @@ class CtrDoubleAccessor : public ValueAccessor {
return val[CtrDoubleFeatureValue::DeltaScoreIndex()]; return val[CtrDoubleFeatureValue::DeltaScoreIndex()];
} }
static double& Show(float* val) { static double& Show(float* val) {
return ((double*)(val + CtrDoubleFeatureValue::ShowIndex()))[0]; return (reinterpret_cast<double*>(val +
CtrDoubleFeatureValue::ShowIndex()))[0];
} }
static double& Click(float* val) { static double& Click(float* val) {
return ((double*)(val + CtrDoubleFeatureValue::ClickIndex()))[0]; return (reinterpret_cast<double*>(
val + CtrDoubleFeatureValue::ClickIndex()))[0];
} }
static float& Slot(float* val) { static float& Slot(float* val) {
return val[CtrDoubleFeatureValue::SlotIndex()]; return val[CtrDoubleFeatureValue::SlotIndex()];
...@@ -168,12 +170,12 @@ class CtrDoubleAccessor : public ValueAccessor { ...@@ -168,12 +170,12 @@ class CtrDoubleAccessor : public ValueAccessor {
// param = 0, save all feature // param = 0, save all feature
// param = 1, save delta feature // param = 1, save delta feature
// param = 3, save all feature with time decay // param = 3, save all feature with time decay
virtual bool Save(float* value, int param) override; bool Save(float* value, int param) override;
bool SaveCache(float* value, bool SaveCache(float* value,
int param, int param,
double global_cache_threshold) override; double global_cache_threshold) override;
// update delta_score and unseen_days after save // update delta_score and unseen_days after save
virtual void UpdateStatAfterSave(float* value, int param) override; void UpdateStatAfterSave(float* value, int param) override;
// 判断该value是否保存到ssd // 判断该value是否保存到ssd
virtual bool SaveSSD(float* value); virtual bool SaveSSD(float* value);
// virtual bool save_cache(float* value, int param, double // virtual bool save_cache(float* value, int param, double
...@@ -195,14 +197,14 @@ class CtrDoubleAccessor : public ValueAccessor { ...@@ -195,14 +197,14 @@ class CtrDoubleAccessor : public ValueAccessor {
virtual int32_t Update(float** values, virtual int32_t Update(float** values,
const float** update_values, const float** update_values,
size_t num); size_t num);
virtual std::string ParseToString(const float* value, int param) override; std::string ParseToString(const float* value, int param) override;
virtual int32_t ParseFromString(const std::string& str, float* v) override; int32_t ParseFromString(const std::string& str, float* v) override;
virtual bool CreateValue(int type, const float* value); virtual bool CreateValue(int type, const float* value);
//这个接口目前只用来取show // 这个接口目前只用来取show
virtual float GetField(float* value, const std::string& name) override { float GetField(float* value, const std::string& name) override {
CHECK(name == "show"); CHECK_EQ(name, "show");
if (name == "show") { if (name == "show") {
return (float)CtrDoubleFeatureValue::Show(value); return static_cast<float>(CtrDoubleFeatureValue::Show(value));
} }
return 0.0; return 0.0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册