From f32d3f9a5af81a394eeb196612991735c09f6896 Mon Sep 17 00:00:00 2001 From: ustcyu <57656474+ustcyu@users.noreply.github.com> Date: Thu, 14 May 2020 19:07:19 +0800 Subject: [PATCH 1/2] Update sequence.hpp Simple implementation --- plato/graph/partition/sequence.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plato/graph/partition/sequence.hpp b/plato/graph/partition/sequence.hpp index 870d61f7..afa3286a 100644 --- a/plato/graph/partition/sequence.hpp +++ b/plato/graph/partition/sequence.hpp @@ -150,13 +150,13 @@ class sequence_balanced_by_source_t { // get vertex's partition inline int get_partition_id(vid_t v_i) { - if(v_i >= offset_.back()){ + for (size_t p_i = 0; p_i < (offset_.size() - 1); ++p_i) { + if (v_i >= offset_[p_i] && v_i < offset_[p_i + 1]) { + return p_i; + } CHECK(false) << "can not find which partition " << v_i << " belong"; + // add abort() to make gcc 6 happy. Otherwise compile failed due to -Werror=return-type. abort(); - } - auto t = std::upper_bound(offset_.begin(), offset_.end(), v_i); - int partition_id = std::distance(offset_.begin(), t); - return partition_id > 0 ? partition_id - 1 : partition_id; } // get all self vertex's view @@ -211,13 +211,13 @@ class sequence_balanced_by_destination_t { // get vertex's partition inline int get_partition_id(vid_t v_i) { - if(v_i >= offset_.back()){ + for (size_t p_i = 0; p_i < (offset_.size() - 1); ++p_i) { + if (v_i >= offset_[p_i] && v_i < offset_[p_i + 1]) { + return p_i; + } CHECK(false) << "can not find which partition " << v_i << " belong"; + // add abort() to make gcc 6 happy. Otherwise compile failed due to -Werror=return-type. abort(); - } - auto t = std::upper_bound(offset_.begin(), offset_.end(), v_i); - int partition_id = std::distance(offset_.begin(), t); - return partition_id > 0 ? partition_id - 1 : partition_id; } sequence_v_view self_v_view(void) { From e4b3ae644f74acb4b57e3150b6f3b50546dce9da Mon Sep 17 00:00:00 2001 From: ustcyu <57656474+ustcyu@users.noreply.github.com> Date: Thu, 14 May 2020 19:14:07 +0800 Subject: [PATCH 2/2] Update sequence.hpp Add } --- plato/graph/partition/sequence.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plato/graph/partition/sequence.hpp b/plato/graph/partition/sequence.hpp index afa3286a..b30bd1f9 100644 --- a/plato/graph/partition/sequence.hpp +++ b/plato/graph/partition/sequence.hpp @@ -154,9 +154,10 @@ class sequence_balanced_by_source_t { if (v_i >= offset_[p_i] && v_i < offset_[p_i + 1]) { return p_i; } - CHECK(false) << "can not find which partition " << v_i << " belong"; - // add abort() to make gcc 6 happy. Otherwise compile failed due to -Werror=return-type. - abort(); + } + CHECK(false) << "can not find which partition " << v_i << " belong"; + // add abort() to make gcc 6 happy. Otherwise compile failed due to -Werror=return-type. + abort(); } // get all self vertex's view @@ -215,9 +216,10 @@ class sequence_balanced_by_destination_t { if (v_i >= offset_[p_i] && v_i < offset_[p_i + 1]) { return p_i; } - CHECK(false) << "can not find which partition " << v_i << " belong"; - // add abort() to make gcc 6 happy. Otherwise compile failed due to -Werror=return-type. - abort(); + } + CHECK(false) << "can not find which partition " << v_i << " belong"; + // add abort() to make gcc 6 happy. Otherwise compile failed due to -Werror=return-type. + abort(); } sequence_v_view self_v_view(void) {