Skip to content

Commit 653bb01

Browse files
committed
Patch 20190208.
1 parent 5e270e5 commit 653bb01

33 files changed

+746
-449
lines changed

cmake/jemalloc.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ ExternalProject_Add(jemalloc
2424
ExternalProject_Get_Property(jemalloc INSTALL_DIR)
2525

2626
add_library(jemalloc_STATIC STATIC IMPORTED)
27-
set_property(TARGET jemalloc_STATIC PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libjemallloc.a)
27+
set_property(TARGET jemalloc_STATIC PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/src/jemalloc/lib/libjemalloc.a)
2828
add_dependencies(jemalloc_STATIC jemalloc)
2929

3030
add_library(jemalloc_STATIC_PIC STATIC IMPORTED)
31-
set_property(TARGET jemalloc_STATIC_PIC PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libjemallloc_pic.a)
31+
set_property(TARGET jemalloc_STATIC_PIC PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/src/jemalloc/lib/libjemalloc_pic.a)
3232
add_dependencies(jemalloc_STATIC_PIC jemalloc)
3333

3434
add_library(jemalloc_SHARED SHARED IMPORTED)
35-
set_property(TARGET jemalloc_SHARED PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libjemallloc.so)
35+
set_property(TARGET jemalloc_SHARED PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/src/jemalloc/lib/libjemalloc.so)
3636
add_dependencies(jemalloc_SHARED jemalloc)
3737

3838
if (!APPLE)

euler/client/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ add_library(client SHARED
1111
rpc_client.cc
1212
rpc_manager.cc
1313
status.cc)
14-
target_link_libraries(client common core proto glog)
14+
target_link_libraries(client common core proto glog jemalloc_STATIC_PIC)
1515

1616
add_executable(graph_test graph_test.cc)
1717
target_link_libraries(graph_test client

euler/common/compact_weighted_collection.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ class CompactWeightedCollection : public WeightedCollection<T> {
5858
CompactWeightedCollection() {
5959
}
6060

61-
void Init(const std::vector<T>& ids,
61+
bool Init(const std::vector<T>& ids,
6262
const std::vector<float>& weights) override;
6363

64-
void Init(const std::vector<std::pair<T, float>>& id_weight_pairs) override;
64+
bool Init(const std::vector<std::pair<T, float>>& id_weight_pairs) override;
6565

6666
std::pair<T, float> Sample() const override;
6767

@@ -78,7 +78,7 @@ class CompactWeightedCollection : public WeightedCollection<T> {
7878
};
7979

8080
template<class T>
81-
void CompactWeightedCollection<T>::Init(const std::vector<T>& ids,
81+
bool CompactWeightedCollection<T>::Init(const std::vector<T>& ids,
8282
const std::vector<float>& weights) {
8383
if (ids.size() == weights.size()) {
8484
sum_weight_ = 0.0;
@@ -89,13 +89,15 @@ void CompactWeightedCollection<T>::Init(const std::vector<T>& ids,
8989
sum_weight_ += weights[i];
9090
sum_weights_[i] = sum_weight_;
9191
}
92+
return true;
9293
} else {
9394
LOG(ERROR) << "ids size != weights size, init error";
95+
return false;
9496
}
9597
}
9698

9799
template<class T>
98-
void CompactWeightedCollection<T>::Init(
100+
bool CompactWeightedCollection<T>::Init(
99101
const std::vector<std::pair<T, float>>& id_weight_pairs) {
100102
sum_weight_ = 0.0;
101103
ids_.resize(id_weight_pairs.size());
@@ -105,6 +107,7 @@ void CompactWeightedCollection<T>::Init(
105107
sum_weight_ += id_weight_pairs[i].second;
106108
sum_weights_[i] = sum_weight_;
107109
}
110+
return true;
108111
}
109112

110113
template<class T>

euler/common/fast_weighted_collection.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ namespace common {
2727
template<class T>
2828
class FastWeightedCollection : public WeightedCollection<T> {
2929
public:
30-
void Init(const std::vector<T>& ids,
30+
bool Init(const std::vector<T>& ids,
3131
const std::vector<float>& weights) override;
3232

33-
void Init(const std::vector<std::pair<T, float>>& id_weight_pairs) override;
33+
bool Init(const std::vector<std::pair<T, float>>& id_weight_pairs) override;
3434

3535
std::pair<T, float> Sample() const override;
3636

@@ -48,10 +48,10 @@ class FastWeightedCollection : public WeightedCollection<T> {
4848
};
4949

5050
template<class T>
51-
void FastWeightedCollection<T>::Init(const std::vector<T>& ids,
51+
bool FastWeightedCollection<T>::Init(const std::vector<T>& ids,
5252
const std::vector<float>& weights) {
5353
if (ids.size() != weights.size()) {
54-
return;
54+
return false;
5555
}
5656
ids_.resize(ids.size());
5757
weights_.resize(weights.size());
@@ -66,11 +66,11 @@ void FastWeightedCollection<T>::Init(const std::vector<T>& ids,
6666
norm_weights[i] /= sum_weight_;
6767
}
6868
alias_.Init(norm_weights);
69-
return;
69+
return true;
7070
}
7171

7272
template<class T>
73-
void FastWeightedCollection<T>::Init(
73+
bool FastWeightedCollection<T>::Init(
7474
const std::vector<std::pair<T, float>>& id_weight_pairs) {
7575
ids_.resize(id_weight_pairs.size());
7676
weights_.resize(id_weight_pairs.size());
@@ -85,7 +85,7 @@ void FastWeightedCollection<T>::Init(
8585
norm_weights[i] /= sum_weight_;
8686
}
8787
alias_.Init(norm_weights);
88-
return;
88+
return true;
8989
}
9090

9191
template<class T>

euler/common/weighted_collection.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ template <class T>
2828
class WeightedCollection {
2929
public:
3030
virtual ~WeightedCollection() {}
31-
virtual void Init(const std::vector<T>& ids,
31+
virtual bool Init(const std::vector<T>& ids,
3232
const std::vector<float>& weights) = 0;
33-
virtual void Init(
33+
virtual bool Init(
3434
const std::vector<std::pair<T, float> >& id_weight_pairs) = 0;
3535
virtual std::pair<T, float> Sample() const = 0;
3636
virtual size_t GetSize() const = 0;

euler/core/compact_edge.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ bool CompactEdge::DeSerialize(const char* s, size_t size) {
4646
}
4747
if (!bytes_reader.GetInt32(&type_) || // parse type
4848
!bytes_reader.GetFloat(&weight_)) { // parse weight
49-
LOG(ERROR) << "edge info error";
49+
LOG(ERROR) << "edge info error, edge_id: " << src_id << "," << dst_id;
5050
return false;
5151
}
5252

@@ -55,12 +55,12 @@ bool CompactEdge::DeSerialize(const char* s, size_t size) {
5555
// parse uint64 feature
5656
int32_t uint64_feature_type_num = 0;
5757
if (!bytes_reader.GetInt32(&uint64_feature_type_num)) {
58-
LOG(ERROR) << "uint64 feature type num error";
58+
LOG(ERROR) << "uint64 feature type num error, edge_id: " << src_id << "," << dst_id;
5959
return false;
6060
}
6161
if (!bytes_reader.GetInt32List(uint64_feature_type_num,
6262
&uint64_features_idx_)) {
63-
LOG(ERROR) << "uint64 feature idx list error";
63+
LOG(ERROR) << "uint64 feature idx list error, edge_id: " << src_id << "," << dst_id;
6464
return false;
6565
}
6666
int32_t uint64_fv_num = 0;
@@ -69,19 +69,19 @@ bool CompactEdge::DeSerialize(const char* s, size_t size) {
6969
uint64_features_idx_[i] = uint64_fv_num;
7070
}
7171
if (!bytes_reader.GetUInt64List(uint64_fv_num, &uint64_features_)) {
72-
LOG(ERROR) << "uint64 feature value list error";
72+
LOG(ERROR) << "uint64 feature value list error, edge_id: " << src_id << "," << dst_id;
7373
return false;
7474
}
7575

7676
// parse float feature
7777
int32_t float_feature_type_num = 0;
7878
if (!bytes_reader.GetInt32(&float_feature_type_num)) {
79-
LOG(ERROR) << "float feature type num error";
79+
LOG(ERROR) << "float feature type num error, edge_id: " << src_id << "," << dst_id;
8080
return false;
8181
}
8282
if (!bytes_reader.GetInt32List(float_feature_type_num,
8383
&float_features_idx_)) {
84-
LOG(ERROR) << "float feature idx list error";
84+
LOG(ERROR) << "float feature idx list error, edge_id: " << src_id << "," << dst_id;
8585
return false;
8686
}
8787
int32_t float_fv_num = 0;
@@ -90,19 +90,19 @@ bool CompactEdge::DeSerialize(const char* s, size_t size) {
9090
float_features_idx_[i] = float_fv_num;
9191
}
9292
if (!bytes_reader.GetFloatList(float_fv_num, &float_features_)) {
93-
LOG(ERROR) << "float feature value list error";
93+
LOG(ERROR) << "float feature value list error, edge_id: " << src_id << "," << dst_id;
9494
return false;
9595
}
9696

9797
// parse binary feature
9898
int32_t binary_feature_type_num = 0;
9999
if (!bytes_reader.GetInt32(&binary_feature_type_num)) {
100-
LOG(ERROR) << "binary feature type num error";
100+
LOG(ERROR) << "binary feature type num error, edge_id: " << src_id << "," << dst_id;
101101
return false;
102102
}
103103
if (!bytes_reader.GetInt32List(binary_feature_type_num,
104104
&binary_features_idx_)) {
105-
LOG(ERROR) << "binary feature idx list error";
105+
LOG(ERROR) << "binary feature idx list error, edge_id: " << src_id << "," << dst_id;
106106
return false;
107107
}
108108
int32_t binary_fv_num = 0;
@@ -111,7 +111,7 @@ bool CompactEdge::DeSerialize(const char* s, size_t size) {
111111
binary_features_idx_[i] = binary_fv_num;
112112
}
113113
if (!bytes_reader.GetString(binary_fv_num, &binary_features_)) {
114-
LOG(ERROR) << "binary feature value list error";
114+
LOG(ERROR) << "binary feature value list error, edge_id: " << src_id << "," << dst_id;
115115
return false;
116116
}
117117

euler/core/compact_node.cc

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ bool CompactNode::DeSerialize(const char* s, size_t size) {
281281

282282
int32_t edge_group_num = 0;
283283
if (!bytes_reader.GetInt32(&edge_group_num)) {
284-
LOG(ERROR) << "edge group num error";
284+
LOG(ERROR) << "edge group num error, node_id: " << id_;
285285
return false;
286286
}
287287

@@ -293,20 +293,22 @@ bool CompactNode::DeSerialize(const char* s, size_t size) {
293293
std::vector<int32_t> edge_group_size_list;
294294
if (!bytes_reader.GetInt32List(edge_group_num,
295295
&edge_group_size_list)) {
296-
LOG(ERROR) << "edge group size list error";
296+
LOG(ERROR) << "edge group size list error, node_id: " << id_;
297297
return false;
298298
}
299299

300300
std::vector<float> edge_group_weight_list;
301301
if (!bytes_reader.GetFloatList(edge_group_num,
302302
&edge_group_weight_list)) {
303-
LOG(ERROR) << "edge group weight list error";
303+
LOG(ERROR) << "edge group weight list error, node_id: " << id_;
304304
return false;
305305
}
306306

307307
// build edge_group_collection_
308-
edge_group_collection_.Init(edge_group_ids, edge_group_weight_list);
309-
308+
if (!edge_group_collection_.Init(edge_group_ids, edge_group_weight_list)) {
309+
LOG(ERROR) << "edge group collection error, node_id: " << id_;
310+
return false;
311+
}
310312
// build neighbors info
311313
int32_t total_neighbors_num = 0;
312314
std::vector<std::vector<uint64_t>> ids_list(edge_group_num);
@@ -317,7 +319,7 @@ bool CompactNode::DeSerialize(const char* s, size_t size) {
317319
ids_list[i] = std::vector<uint64_t>();
318320
if (!bytes_reader.GetUInt64List(edge_group_size_list[i],
319321
&ids_list[i])) {
320-
LOG(ERROR) << "neighbor id list error";
322+
LOG(ERROR) << "neighbor id list error, node_id: " << id_;
321323
return false;
322324
}
323325
}
@@ -327,7 +329,7 @@ bool CompactNode::DeSerialize(const char* s, size_t size) {
327329
weights_list[i] = std::vector<float>();
328330
if (!bytes_reader.GetFloatList(edge_group_size_list[i],
329331
&weights_list[i])) {
330-
LOG(ERROR) << "neighbor weight list error";
332+
LOG(ERROR) << "neighbor weight list error, node_id: " << id_;
331333
return false;
332334
}
333335
}
@@ -356,16 +358,15 @@ bool CompactNode::DeSerialize(const char* s, size_t size) {
356358
neighbors_weight_.push_back(sum_weight);
357359
}
358360
}
359-
360361
// parse uint64 feature
361362
int32_t uint64_feature_type_num = 0;
362363
if (!bytes_reader.GetInt32(&uint64_feature_type_num)) {
363-
LOG(ERROR) << "uint64 feature type num error";
364+
LOG(ERROR) << "uint64 feature type num error, node_id: " << id_;
364365
return false;
365366
}
366367
if (!bytes_reader.GetInt32List(uint64_feature_type_num,
367368
&uint64_features_idx_)) {
368-
LOG(ERROR) << "uint64 feature idx list error";
369+
LOG(ERROR) << "uint64 feature idx list error, node_id: " << id_;
369370
return false;
370371
}
371372
int32_t uint64_fv_num = 0;
@@ -374,19 +375,19 @@ bool CompactNode::DeSerialize(const char* s, size_t size) {
374375
uint64_features_idx_[i] = uint64_fv_num;
375376
}
376377
if (!bytes_reader.GetUInt64List(uint64_fv_num, &uint64_features_)) {
377-
LOG(ERROR) << "uint64 feature value list error";
378+
LOG(ERROR) << "uint64 feature value list error, node_id: " << id_;
378379
return false;
379380
}
380381

381382
// parse float feature
382383
int32_t float_feature_type_num = 0;
383384
if (!bytes_reader.GetInt32(&float_feature_type_num)) {
384-
LOG(ERROR) << "float feature type num error";
385+
LOG(ERROR) << "float feature type num error, node_id: " << id_;
385386
return false;
386387
}
387388
if (!bytes_reader.GetInt32List(float_feature_type_num,
388389
&float_features_idx_)) {
389-
LOG(ERROR) << "float feature idx list error";
390+
LOG(ERROR) << "float feature idx list error, node_id: " << id_;
390391
return false;
391392
}
392393
int32_t float_fv_num = 0;
@@ -395,19 +396,19 @@ bool CompactNode::DeSerialize(const char* s, size_t size) {
395396
float_features_idx_[i] = float_fv_num;
396397
}
397398
if (!bytes_reader.GetFloatList(float_fv_num, &float_features_)) {
398-
LOG(ERROR) << "float feature value list error";
399+
LOG(ERROR) << "float feature value list error, node_id: " << id_;
399400
return false;
400401
}
401402

402403
// parse binary feature
403404
int32_t binary_feature_type_num = 0;
404405
if (!bytes_reader.GetInt32(&binary_feature_type_num)) {
405-
LOG(ERROR) << "binary feature type num error";
406+
LOG(ERROR) << "binary feature type num error, node_id: " << id_;
406407
return false;
407408
}
408409
if (!bytes_reader.GetInt32List(binary_feature_type_num,
409410
&binary_features_idx_)) {
410-
LOG(ERROR) << "binary feature idx list error";
411+
LOG(ERROR) << "binary feature idx list error, node_id: " << id_;
411412
return false;
412413
}
413414
int32_t binary_fv_num = 0;
@@ -416,10 +417,9 @@ bool CompactNode::DeSerialize(const char* s, size_t size) {
416417
binary_features_idx_[i] = binary_fv_num;
417418
}
418419
if (!bytes_reader.GetString(binary_fv_num, &binary_features_)) {
419-
LOG(ERROR) << "binary feature value list error";
420+
LOG(ERROR) << "binary feature value list error, node_id: " << id_;
420421
return false;
421422
}
422-
423423
return true;
424424
}
425425

0 commit comments

Comments
 (0)