neverchanje commented on a change in pull request #680:
URL: https://github.com/apache/incubator-pegasus/pull/680#discussion_r557880104



##########
File path: src/server/pegasus_server_write.cpp
##########
@@ -170,5 +136,77 @@ void pegasus_server_write::request_key_check(int64_t 
decree,
     }
 }
 
+pegasus_server_write::single_put_rpc_map 
pegasus_server_write::_single_put_methods = {
+    {dsn::apps::RPC_RRDB_RRDB_MULTI_PUT,
+     [](pegasus_server_write *server_write, dsn::message_ex *request) -> int {
+         return server_write->multi_put(request);
+     }},

Review comment:
       ```suggestion
       {dsn::apps::RPC_RRDB_RRDB_MULTI_PUT,
        [this](dsn::message_ex *request) -> int {
            return multi_put(request);
        }},
   ```
   
   Can we use "this"?

##########
File path: src/server/pegasus_server_write.h
##########
@@ -84,6 +94,10 @@ class pegasus_server_write : public 
dsn::replication::replica_base
     int64_t _decree;
 
     const bool _verbose_log;
+
+    typedef std::map<dsn::task_code, std::function<int(pegasus_server_write *, 
dsn::message_ex *)>>
+        single_put_rpc_map;
+    static single_put_rpc_map _single_put_methods;

Review comment:
       Called them `non_batch_writes_map`, and `_non_batch_write_handlers`. The 
other methods are not "put". It's somewhat ambiguous.

##########
File path: src/server/pegasus_server_write.cpp
##########
@@ -50,44 +50,13 @@ int 
pegasus_server_write::on_batched_write_requests(dsn::message_ex **requests,
         return _write_svc->empty_put(_decree);
     }
 
-    dsn::task_code rpc_code(requests[0]->rpc_code());
-    if (rpc_code == dsn::apps::RPC_RRDB_RRDB_MULTI_PUT) {
-        dassert(count == 1, "count = %d", count);
-        auto rpc = multi_put_rpc::auto_reply(requests[0]);
-        return _write_svc->multi_put(_write_ctx, rpc.request(), 
rpc.response());
+    auto iter = _single_put_methods.find(requests[0]->rpc_code());
+    if (iter != _single_put_methods.end()) {
+        dcheck_eq(count, 1);
+        return iter->second(this, requests[0]);
+    } else {
+        return on_batched_writes(requests, count);
     }

Review comment:
       ```suggestion
       }
       return on_batched_writes(requests, count);
   ```




----------------------------------------------------------------
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.

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