From 14a7f266425d9bd3fb0b993279440336391c8ed7 Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Fri, 15 Apr 2022 18:24:40 -0700 Subject: [PATCH] Add GetSharedSnapshot() to Transaction --- include/rocksdb/utilities/transaction.h | 4 ++++ utilities/transactions/transaction_base.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/include/rocksdb/utilities/transaction.h b/include/rocksdb/utilities/transaction.h index ecb797506..8e17e1d8b 100644 --- a/include/rocksdb/utilities/transaction.h +++ b/include/rocksdb/utilities/transaction.h @@ -193,6 +193,10 @@ class Transaction { // is called, or the Transaction is deleted. virtual const Snapshot* GetSnapshot() const = 0; + // Returns the Snapshot created by the last call to SetSnapshot(). + // The returned snapshot can outlive the transaction. + virtual std::shared_ptr GetSharedSnapshot() const = 0; + // Clears the current snapshot (i.e. no snapshot will be 'set') // // This removes any snapshot that currently exists or is set to be created diff --git a/utilities/transactions/transaction_base.h b/utilities/transactions/transaction_base.h index e4da8d44b..7fc51f87a 100644 --- a/utilities/transactions/transaction_base.h +++ b/utilities/transactions/transaction_base.h @@ -206,6 +206,10 @@ class TransactionBaseImpl : public Transaction { return snapshot_.get(); } + std::shared_ptr GetSharedSnapshot() const override { + return snapshot_; + } + virtual void SetSnapshot() override; void SetSnapshotOnNextOperation( std::shared_ptr notifier = nullptr) override;