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