This is an automated email from the ASF dual-hosted git repository.

yuchenhe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git


The following commit(s) were added to refs/heads/master by this push:
     new df8f41e  refactor: use rocksdb_wrapper::get to reimplement 
check_and_mutate (#655)
df8f41e is described below

commit df8f41e88f36dbcc61485b3d6e7afb7d54daa6d8
Author: zhao liwei <[email protected]>
AuthorDate: Mon Dec 14 10:45:16 2020 +0800

    refactor: use rocksdb_wrapper::get to reimplement check_and_mutate (#655)
---
 src/server/pegasus_write_service_impl.h | 36 ++++++++++++---------------------
 1 file changed, 13 insertions(+), 23 deletions(-)

diff --git a/src/server/pegasus_write_service_impl.h 
b/src/server/pegasus_write_service_impl.h
index 3655a6c..6187ebd 100644
--- a/src/server/pegasus_write_service_impl.h
+++ b/src/server/pegasus_write_service_impl.h
@@ -412,41 +412,31 @@ public:
 
         ::dsn::blob check_key;
         pegasus_generate_key(check_key, update.hash_key, 
update.check_sort_key);
-        rocksdb::Slice check_raw_key(check_key.data(), check_key.length());
-        std::string check_raw_value;
-        rocksdb::Status check_status = _db->Get(_rd_opts, check_raw_key, 
&check_raw_value);
-        if (check_status.ok()) {
-            // read check value succeed
-            if (check_if_record_expired(
-                    _pegasus_data_version, utils::epoch_now(), 
check_raw_value)) {
-                // check value ttl timeout
-                _pfc_recent_expire_count->increment();
-                check_status = rocksdb::Status::NotFound();
-            }
-        } else if (!check_status.IsNotFound()) {
+
+        db_get_context get_context;
+        dsn::string_view check_raw_key(check_key.data(), check_key.length());
+        int err = _rocksdb_wrapper->get(check_raw_key, &get_context);
+        if (err != 0) {
             // read check value failed
-            derror_rocksdb("GetCheckValue for CheckAndMutate",
-                           check_status.ToString(),
-                           "decree: {}, hash_key: {}, check_sort_key: {}",
+            derror_rocksdb("Error to GetCheckValue for CheckAndMutate decree: 
{}, hash_key: {}, "
+                           "check_sort_key: {}",
                            decree,
                            utils::c_escape_string(update.hash_key),
                            utils::c_escape_string(update.check_sort_key));
-            resp.error = check_status.code();
+            resp.error = err;
             return resp.error;
         }
-        dassert_f(check_status.ok() || check_status.IsNotFound(),
-                  "status = %s",
-                  check_status.ToString().c_str());
 
         ::dsn::blob check_value;
-        if (check_status.ok()) {
+        bool value_exist = !get_context.expired && get_context.found;
+        if (value_exist) {
             pegasus_extract_user_data(
-                _pegasus_data_version, std::move(check_raw_value), 
check_value);
+                _pegasus_data_version, std::move(get_context.raw_value), 
check_value);
         }
 
         if (update.return_check_value) {
             resp.check_value_returned = true;
-            if (check_status.ok()) {
+            if (value_exist) {
                 resp.check_value_exist = true;
                 resp.check_value = check_value;
             }
@@ -456,7 +446,7 @@ public:
         bool passed = validate_check(decree,
                                      update.check_type,
                                      update.check_operand,
-                                     check_status.ok(),
+                                     value_exist,
                                      check_value,
                                      invalid_argument);
 


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

Reply via email to