You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2019/07/03 01:14:06 UTC

[kudu] branch master updated: KUDU-2876 Audit the semantics and the usage of Tabet::GetComponents

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

alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new 8409823  KUDU-2876 Audit the semantics and the usage of Tabet::GetComponents
8409823 is described below

commit 84098234dd787ccedc2717d95b22bdfd43a1429f
Author: oclarms <oc...@gmail.com>
AuthorDate: Thu Jun 27 21:11:37 2019 +0800

    KUDU-2876 Audit the semantics and the usage of Tabet::GetComponents
    
    Add Tablet::GetComponentsOrNull function. Tablet::GetComponents to
    verify that the output parameter is not null, Tablet::GetComponentsOrNull
    does not verify.
    
    Change-Id: Ib2eb6a268429741ad3609647dc1a73edec495ff2
    Reviewed-on: http://gerrit.cloudera.org:8080/13750
    Tested-by: Kudu Jenkins
    Reviewed-by: Alexey Serbin <as...@cloudera.com>
---
 src/kudu/tablet/tablet.cc | 8 ++++----
 src/kudu/tablet/tablet.h  | 5 +++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/kudu/tablet/tablet.cc b/src/kudu/tablet/tablet.cc
index c6489b5..49e7b85 100644
--- a/src/kudu/tablet/tablet.cc
+++ b/src/kudu/tablet/tablet.cc
@@ -1922,7 +1922,7 @@ Status Tablet::CountLiveRows(int64_t* count) const {
   }
 
   scoped_refptr<TabletComponents> comps;
-  GetComponents(&comps);
+  GetComponentsOrNull(&comps);
   if (!comps) {
     return Status::RuntimeError("The tablet has been shut down");
   }
@@ -1940,7 +1940,7 @@ Status Tablet::CountLiveRows(int64_t* count) const {
 
 size_t Tablet::MemRowSetSize() const {
   scoped_refptr<TabletComponents> comps;
-  GetComponents(&comps);
+  GetComponentsOrNull(&comps);
 
   if (comps) {
     return comps->memrowset->memory_footprint();
@@ -1964,7 +1964,7 @@ size_t Tablet::MemRowSetLogReplaySize(const ReplaySizeMap& replay_size_map) cons
 
 size_t Tablet::OnDiskSize() const {
   scoped_refptr<TabletComponents> comps;
-  GetComponents(&comps);
+  GetComponentsOrNull(&comps);
 
   if (!comps) return 0;
 
@@ -1978,7 +1978,7 @@ size_t Tablet::OnDiskSize() const {
 
 size_t Tablet::OnDiskDataSize() const {
   scoped_refptr<TabletComponents> comps;
-  GetComponents(&comps);
+  GetComponentsOrNull(&comps);
 
   if (!comps) return 0;
 
diff --git a/src/kudu/tablet/tablet.h b/src/kudu/tablet/tablet.h
index 8235daf..31ef480 100644
--- a/src/kudu/tablet/tablet.h
+++ b/src/kudu/tablet/tablet.h
@@ -627,6 +627,11 @@ class Tablet {
 
   void GetComponents(scoped_refptr<TabletComponents>* comps) const {
     shared_lock<rw_spinlock> l(component_lock_);
+    *comps = CHECK_NOTNULL(components_.get());
+  }
+
+  void GetComponentsOrNull(scoped_refptr<TabletComponents>* comps) const {
+    shared_lock<rw_spinlock> l(component_lock_);
     *comps = components_;
   }