Samunroyu commented on code in PR #2328:
URL: 
https://github.com/apache/incubator-pegasus/pull/2328#discussion_r3418287494


##########
src/meta/server_state.cpp:
##########
@@ -776,12 +776,16 @@ void server_state::initialize_node_state()
     for (auto &app_pair : _all_apps) {
         app_state &app = *(app_pair.second);
         for (const auto &pc : app.pcs) {
-            if (pc.hp_primary) {
-                node_state *ns = get_node_state(_nodes, pc.hp_primary, true);
+            host_port primary;
+            GET_HOST_PORT(pc, primary, primary);
+            if (primary) {
+                node_state *ns = get_node_state(_nodes, primary, true);
                 ns->put_partition(pc.pid, true);
             }
 
-            for (const auto &secondary : pc.hp_secondaries) {
+            std::vector<host_port> secondaries;
+            GET_HOST_PORTS(pc, secondaries, secondaries);
+            for (const auto &secondary : secondaries) {

Review Comment:
   This is a correctness-focused refactoring PR. The per-partition vector copy 
overhead is acceptable for meta server paths (partition count is typically in 
the thousands, not millions). A follow-up optimization could introduce a 
get_host_ports_ref() helper that returns const std::vector<host_port>& when 
__isset is true, avoiding the copy.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to