Repository: kudu
Updated Branches:
  refs/heads/master 2976b2a2c -> 86afadc7f


[c++-client] reduce in-flight-op partition key lifetime

This commit changes the C++ MetaCache to take the lookup partition key
by value, and updates Batcher to pass the partition key by move when
calling the MetaCache. Additionally, the partition key is no longer
stored as a field in the InFlightOp. The effect is that the InFlightOp
is smaller by the size of a std::string, and the lifetime of the
partition key is reduced from when the InFlightOp is complete to when
the meta cache lookup is complete.

Change-Id: Ia949b65a9447979c9c5eff324448af307a1db1b7
Reviewed-on: http://gerrit.cloudera.org:8080/4114
Tested-by: Kudu Jenkins
Reviewed-by: Alexey Serbin <[email protected]>
Reviewed-by: Adar Dembo <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/effcd2c9
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/effcd2c9
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/effcd2c9

Branch: refs/heads/master
Commit: effcd2c9624196bb5626cb853f0f19ce06d036c0
Parents: 2976b2a
Author: Dan Burkert <[email protected]>
Authored: Wed Aug 24 11:09:56 2016 -0700
Committer: Adar Dembo <[email protected]>
Committed: Wed Aug 24 22:21:28 2016 +0000

----------------------------------------------------------------------
 src/kudu/client/batcher.cc    | 8 +++-----
 src/kudu/client/meta_cache.cc | 8 ++++----
 src/kudu/client/meta_cache.h  | 4 ++--
 3 files changed, 9 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/effcd2c9/src/kudu/client/batcher.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/batcher.cc b/src/kudu/client/batcher.cc
index 0346119..fbdb2a9 100644
--- a/src/kudu/client/batcher.cc
+++ b/src/kudu/client/batcher.cc
@@ -166,8 +166,6 @@ struct InFlightOp {
   // The actual operation.
   gscoped_ptr<KuduWriteOperation> write_op;
 
-  string partition_key;
-
   // The tablet the operation is destined for.
   // This is only filled in after passing through the kLookingUpTablet state.
   scoped_refptr<RemoteTablet> tablet;
@@ -531,8 +529,8 @@ Status Batcher::Add(KuduWriteOperation* write_op) {
   // As soon as we get the op, start looking up where it belongs,
   // so that when the user calls Flush, we are ready to go.
   gscoped_ptr<InFlightOp> op(new InFlightOp());
-  RETURN_NOT_OK(write_op->table_->partition_schema()
-                .EncodeKey(write_op->row(), &op->partition_key));
+  string partition_key;
+  
RETURN_NOT_OK(write_op->table_->partition_schema().EncodeKey(write_op->row(), 
&partition_key));
   op->write_op.reset(write_op);
   op->state = InFlightOp::kLookingUpTablet;
 
@@ -547,7 +545,7 @@ Status Batcher::Add(KuduWriteOperation* write_op) {
   base::RefCountInc(&outstanding_lookups_);
   client_->data_->meta_cache_->LookupTabletByKey(
       op->write_op->table(),
-      op->partition_key,
+      std::move(partition_key),
       deadline,
       &op->tablet,
       Bind(&Batcher::TabletLookupFinished, this, op.get()));

http://git-wip-us.apache.org/repos/asf/kudu/blob/effcd2c9/src/kudu/client/meta_cache.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/meta_cache.cc b/src/kudu/client/meta_cache.cc
index bc11ccf..9ae6714 100644
--- a/src/kudu/client/meta_cache.cc
+++ b/src/kudu/client/meta_cache.cc
@@ -947,14 +947,14 @@ void MetaCache::ClearCache() {
 }
 
 void MetaCache::LookupTabletByKey(const KuduTable* table,
-                                  const string& partition_key,
+                                  string partition_key,
                                   const MonoTime& deadline,
                                   scoped_refptr<RemoteTablet>* remote_tablet,
                                   const StatusCallback& callback) {
   LookupRpc* rpc = new LookupRpc(this,
                                  callback,
                                  table,
-                                 partition_key,
+                                 std::move(partition_key),
                                  remote_tablet,
                                  deadline,
                                  client_->data_->messenger_,
@@ -963,14 +963,14 @@ void MetaCache::LookupTabletByKey(const KuduTable* table,
 }
 
 void MetaCache::LookupTabletByKeyOrNext(const KuduTable* table,
-                                        const string& partition_key,
+                                        string partition_key,
                                         const MonoTime& deadline,
                                         scoped_refptr<RemoteTablet>* 
remote_tablet,
                                         const StatusCallback& callback) {
   LookupRpc* rpc = new LookupRpc(this,
                                  callback,
                                  table,
-                                 partition_key,
+                                 std::move(partition_key),
                                  remote_tablet,
                                  deadline,
                                  client_->data_->messenger_,

http://git-wip-us.apache.org/repos/asf/kudu/blob/effcd2c9/src/kudu/client/meta_cache.h
----------------------------------------------------------------------
diff --git a/src/kudu/client/meta_cache.h b/src/kudu/client/meta_cache.h
index 1f93440..b621500 100644
--- a/src/kudu/client/meta_cache.h
+++ b/src/kudu/client/meta_cache.h
@@ -361,7 +361,7 @@ class MetaCache : public RefCountedThreadSafe<MetaCache> {
   // NOTE: the memory referenced by 'table' must remain valid until 'callback'
   // is invoked.
   void LookupTabletByKey(const KuduTable* table,
-                         const std::string& partition_key,
+                         std::string partition_key,
                          const MonoTime& deadline,
                          scoped_refptr<RemoteTablet>* remote_tablet,
                          const StatusCallback& callback);
@@ -369,7 +369,7 @@ class MetaCache : public RefCountedThreadSafe<MetaCache> {
   // Look up which tablet hosts the given partition key, or the next tablet if
   // the key falls in a non-covered range partition.
   void LookupTabletByKeyOrNext(const KuduTable* table,
-                               const std::string& partition_key,
+                               std::string partition_key,
                                const MonoTime& deadline,
                                scoped_refptr<RemoteTablet>* remote_tablet,
                                const StatusCallback& callback);

Reply via email to