Skip to content

Commit 06f3a78

Browse files
authored
Merge pull request #92 from ustcyu/master
Update sequence.hpp
2 parents 9ca04c3 + e4b3ae6 commit 06f3a78

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

plato/graph/partition/sequence.hpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,14 @@ class sequence_balanced_by_source_t {
150150

151151
// get vertex's partition
152152
inline int get_partition_id(vid_t v_i) {
153-
if(v_i >= offset_.back()){
154-
CHECK(false) << "can not find which partition " << v_i << " belong";
155-
abort();
153+
for (size_t p_i = 0; p_i < (offset_.size() - 1); ++p_i) {
154+
if (v_i >= offset_[p_i] && v_i < offset_[p_i + 1]) {
155+
return p_i;
156+
}
156157
}
157-
auto t = std::upper_bound(offset_.begin(), offset_.end(), v_i);
158-
int partition_id = std::distance(offset_.begin(), t);
159-
return partition_id > 0 ? partition_id - 1 : partition_id;
158+
CHECK(false) << "can not find which partition " << v_i << " belong";
159+
// add abort() to make gcc 6 happy. Otherwise compile failed due to -Werror=return-type.
160+
abort();
160161
}
161162

162163
// get all self vertex's view
@@ -211,13 +212,14 @@ class sequence_balanced_by_destination_t {
211212

212213
// get vertex's partition
213214
inline int get_partition_id(vid_t v_i) {
214-
if(v_i >= offset_.back()){
215-
CHECK(false) << "can not find which partition " << v_i << " belong";
216-
abort();
215+
for (size_t p_i = 0; p_i < (offset_.size() - 1); ++p_i) {
216+
if (v_i >= offset_[p_i] && v_i < offset_[p_i + 1]) {
217+
return p_i;
218+
}
217219
}
218-
auto t = std::upper_bound(offset_.begin(), offset_.end(), v_i);
219-
int partition_id = std::distance(offset_.begin(), t);
220-
return partition_id > 0 ? partition_id - 1 : partition_id;
220+
CHECK(false) << "can not find which partition " << v_i << " belong";
221+
// add abort() to make gcc 6 happy. Otherwise compile failed due to -Werror=return-type.
222+
abort();
221223
}
222224

223225
sequence_v_view self_v_view(void) {

0 commit comments

Comments
 (0)