kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [kudu] branch master updated: [tablet] Remove used state member
Date Wed, 18 Sep 2019 16:43:08 GMT
This is an automated email from the ASF dual-hosted git repository.

adar 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 518402c  [tablet] Remove used state member
518402c is described below

commit 518402c00ca41457ce4ea23b90759fdf1dae91fb
Author: lingbin <lingbinlb@gmail.com>
AuthorDate: Wed Sep 18 21:05:14 2019 +0800

    [tablet] Remove used state member
    
    Each type of transaction subclass (i.e. WriteTransaction
    and AlterSchemaTransaction) uses its own state member,
    so the state member of the base class is useless
    
    Change-Id: I7d18063438905a5938cd6ae80f21179f0d6b0dd5
    Reviewed-on: http://gerrit.cloudera.org:8080/14253
    Tested-by: Kudu Jenkins
    Reviewed-by: Adar Dembo <adar@cloudera.com>
---
 src/kudu/tablet/transactions/alter_schema_transaction.cc | 2 +-
 src/kudu/tablet/transactions/transaction.cc              | 5 ++---
 src/kudu/tablet/transactions/transaction.h               | 9 +++------
 src/kudu/tablet/transactions/transaction_tracker-test.cc | 4 +++-
 src/kudu/tablet/transactions/write_transaction.cc        | 2 +-
 5 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/kudu/tablet/transactions/alter_schema_transaction.cc b/src/kudu/tablet/transactions/alter_schema_transaction.cc
index f988a4c..a964342 100644
--- a/src/kudu/tablet/transactions/alter_schema_transaction.cc
+++ b/src/kudu/tablet/transactions/alter_schema_transaction.cc
@@ -80,7 +80,7 @@ string AlterSchemaTransactionState::ToString() const {
 
 AlterSchemaTransaction::AlterSchemaTransaction(unique_ptr<AlterSchemaTransactionState>
state,
                                                DriverType type)
-    : Transaction(state.get(), type, Transaction::ALTER_SCHEMA_TXN),
+    : Transaction(type, Transaction::ALTER_SCHEMA_TXN),
       state_(std::move(state)) {
 }
 
diff --git a/src/kudu/tablet/transactions/transaction.cc b/src/kudu/tablet/transactions/transaction.cc
index 2ee867f..312c8b5 100644
--- a/src/kudu/tablet/transactions/transaction.cc
+++ b/src/kudu/tablet/transactions/transaction.cc
@@ -24,9 +24,8 @@ namespace tablet {
 
 using consensus::DriverType;
 
-Transaction::Transaction(TransactionState* state, DriverType type, TransactionType tx_type)
-    : state_(state),
-      type_(type),
+Transaction::Transaction(DriverType type, TransactionType tx_type)
+    : type_(type),
       tx_type_(tx_type) {
 }
 
diff --git a/src/kudu/tablet/transactions/transaction.h b/src/kudu/tablet/transactions/transaction.h
index 2fabd05..5671d98 100644
--- a/src/kudu/tablet/transactions/transaction.h
+++ b/src/kudu/tablet/transactions/transaction.h
@@ -88,11 +88,11 @@ class Transaction {
     ABORTED
   };
 
-  Transaction(TransactionState* state, consensus::DriverType type, TransactionType tx_type);
+  Transaction(consensus::DriverType type, TransactionType tx_type);
 
   // Returns the TransactionState for this transaction.
-  virtual TransactionState* state() { return state_; }
-  virtual const TransactionState* state() const { return state_; }
+  virtual TransactionState* state() = 0;
+  virtual const TransactionState* state() const = 0;
 
   // Returns whether this transaction is being executed on the leader or on a
   // replica.
@@ -141,9 +141,6 @@ class Transaction {
   virtual ~Transaction() {}
 
  private:
-  // A private version of this transaction's transaction state so that
-  // we can use base TransactionState methods on destructors.
-  TransactionState* state_;
   const consensus::DriverType type_;
   const TransactionType tx_type_;
 };
diff --git a/src/kudu/tablet/transactions/transaction_tracker-test.cc b/src/kudu/tablet/transactions/transaction_tracker-test.cc
index 13b30b2..0b48d52 100644
--- a/src/kudu/tablet/transactions/transaction_tracker-test.cc
+++ b/src/kudu/tablet/transactions/transaction_tracker-test.cc
@@ -72,13 +72,15 @@ class TransactionTrackerTest : public KuduTest {
   class NoOpTransaction : public Transaction {
    public:
     explicit NoOpTransaction(NoOpTransactionState* state)
-      : Transaction(state, consensus::LEADER, Transaction::WRITE_TXN),
+      : Transaction(consensus::LEADER, Transaction::WRITE_TXN),
         state_(state) {
     }
 
     virtual void NewReplicateMsg(gscoped_ptr<consensus::ReplicateMsg>* replicate_msg)
OVERRIDE {
       replicate_msg->reset(new consensus::ReplicateMsg());
     }
+    virtual TransactionState* state() { return state_.get();  }
+    virtual const TransactionState* state() const { return state_.get();  }
 
     virtual Status Prepare() OVERRIDE { return Status::OK(); }
     virtual Status Start() OVERRIDE { return Status::OK(); }
diff --git a/src/kudu/tablet/transactions/write_transaction.cc b/src/kudu/tablet/transactions/write_transaction.cc
index 421f68c..c25d3a7 100644
--- a/src/kudu/tablet/transactions/write_transaction.cc
+++ b/src/kudu/tablet/transactions/write_transaction.cc
@@ -133,7 +133,7 @@ Status WriteAuthorizationContext::CheckPrivileges() const {
 }
 
 WriteTransaction::WriteTransaction(unique_ptr<WriteTransactionState> state, DriverType
type)
-  : Transaction(state.get(), type, Transaction::WRITE_TXN),
+  : Transaction(type, Transaction::WRITE_TXN),
   state_(std::move(state)) {
   start_time_ = MonoTime::Now();
 }


Mime
View raw message