mirror of https://github.com/facebook/rocksdb.git
Add write unprepared classes by inheriting from write prepared
Summary: Closes https://github.com/facebook/rocksdb/pull/3907 Differential Revision: D8218325 Pulled By: lth fbshipit-source-id: ff32d8dab4a159cd2762876cba4b15e3dc51ff3b
This commit is contained in:
parent
727eb881a5
commit
aaac6cd16f
|
@ -657,6 +657,8 @@ set(SOURCES
|
||||||
utilities/transactions/transaction_util.cc
|
utilities/transactions/transaction_util.cc
|
||||||
utilities/transactions/write_prepared_txn.cc
|
utilities/transactions/write_prepared_txn.cc
|
||||||
utilities/transactions/write_prepared_txn_db.cc
|
utilities/transactions/write_prepared_txn_db.cc
|
||||||
|
utilities/transactions/write_unprepared_txn.cc
|
||||||
|
utilities/transactions/write_unprepared_txn_db.cc
|
||||||
utilities/ttl/db_ttl_impl.cc
|
utilities/ttl/db_ttl_impl.cc
|
||||||
utilities/write_batch_with_index/write_batch_with_index.cc
|
utilities/write_batch_with_index/write_batch_with_index.cc
|
||||||
utilities/write_batch_with_index/write_batch_with_index_internal.cc
|
utilities/write_batch_with_index/write_batch_with_index_internal.cc
|
||||||
|
|
2
TARGETS
2
TARGETS
|
@ -280,6 +280,8 @@ cpp_library(
|
||||||
"utilities/transactions/transaction_util.cc",
|
"utilities/transactions/transaction_util.cc",
|
||||||
"utilities/transactions/write_prepared_txn.cc",
|
"utilities/transactions/write_prepared_txn.cc",
|
||||||
"utilities/transactions/write_prepared_txn_db.cc",
|
"utilities/transactions/write_prepared_txn_db.cc",
|
||||||
|
"utilities/transactions/write_unprepared_txn.cc",
|
||||||
|
"utilities/transactions/write_unprepared_txn_db.cc",
|
||||||
"utilities/ttl/db_ttl_impl.cc",
|
"utilities/ttl/db_ttl_impl.cc",
|
||||||
"utilities/write_batch_with_index/write_batch_with_index.cc",
|
"utilities/write_batch_with_index/write_batch_with_index.cc",
|
||||||
"utilities/write_batch_with_index/write_batch_with_index_internal.cc",
|
"utilities/write_batch_with_index/write_batch_with_index_internal.cc",
|
||||||
|
|
2
src.mk
2
src.mk
|
@ -208,6 +208,8 @@ LIB_SOURCES = \
|
||||||
utilities/transactions/transaction_util.cc \
|
utilities/transactions/transaction_util.cc \
|
||||||
utilities/transactions/write_prepared_txn.cc \
|
utilities/transactions/write_prepared_txn.cc \
|
||||||
utilities/transactions/write_prepared_txn_db.cc \
|
utilities/transactions/write_prepared_txn_db.cc \
|
||||||
|
utilities/transactions/write_unprepared_txn.cc \
|
||||||
|
utilities/transactions/write_unprepared_txn_db.cc \
|
||||||
utilities/ttl/db_ttl_impl.cc \
|
utilities/ttl/db_ttl_impl.cc \
|
||||||
utilities/write_batch_with_index/write_batch_with_index.cc \
|
utilities/write_batch_with_index/write_batch_with_index.cc \
|
||||||
utilities/write_batch_with_index/write_batch_with_index_internal.cc \
|
utilities/write_batch_with_index/write_batch_with_index_internal.cc \
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "utilities/transactions/pessimistic_transaction.h"
|
#include "utilities/transactions/pessimistic_transaction.h"
|
||||||
#include "utilities/transactions/transaction_db_mutex_impl.h"
|
#include "utilities/transactions/transaction_db_mutex_impl.h"
|
||||||
#include "utilities/transactions/write_prepared_txn_db.h"
|
#include "utilities/transactions/write_prepared_txn_db.h"
|
||||||
|
#include "utilities/transactions/write_unprepared_txn_db.h"
|
||||||
|
|
||||||
namespace rocksdb {
|
namespace rocksdb {
|
||||||
|
|
||||||
|
@ -264,7 +265,9 @@ Status TransactionDB::WrapDB(
|
||||||
std::unique_ptr<PessimisticTransactionDB> txn_db;
|
std::unique_ptr<PessimisticTransactionDB> txn_db;
|
||||||
switch (txn_db_options.write_policy) {
|
switch (txn_db_options.write_policy) {
|
||||||
case WRITE_UNPREPARED:
|
case WRITE_UNPREPARED:
|
||||||
return Status::NotSupported("WRITE_UNPREPARED is not implemented yet");
|
txn_db.reset(new WriteUnpreparedTxnDB(
|
||||||
|
db, PessimisticTransactionDB::ValidateTxnDBOptions(txn_db_options)));
|
||||||
|
break;
|
||||||
case WRITE_PREPARED:
|
case WRITE_PREPARED:
|
||||||
txn_db.reset(new WritePreparedTxnDB(
|
txn_db.reset(new WritePreparedTxnDB(
|
||||||
db, PessimisticTransactionDB::ValidateTxnDBOptions(txn_db_options)));
|
db, PessimisticTransactionDB::ValidateTxnDBOptions(txn_db_options)));
|
||||||
|
@ -297,7 +300,9 @@ Status TransactionDB::WrapStackableDB(
|
||||||
|
|
||||||
switch (txn_db_options.write_policy) {
|
switch (txn_db_options.write_policy) {
|
||||||
case WRITE_UNPREPARED:
|
case WRITE_UNPREPARED:
|
||||||
return Status::NotSupported("WRITE_UNPREPARED is not implemented yet");
|
txn_db.reset(new WriteUnpreparedTxnDB(
|
||||||
|
db, PessimisticTransactionDB::ValidateTxnDBOptions(txn_db_options)));
|
||||||
|
break;
|
||||||
case WRITE_PREPARED:
|
case WRITE_PREPARED:
|
||||||
txn_db.reset(new WritePreparedTxnDB(
|
txn_db.reset(new WritePreparedTxnDB(
|
||||||
db, PessimisticTransactionDB::ValidateTxnDBOptions(txn_db_options)));
|
db, PessimisticTransactionDB::ValidateTxnDBOptions(txn_db_options)));
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under both the GPLv2 (found in the
|
||||||
|
// COPYING file in the root directory) and Apache 2.0 License
|
||||||
|
// (found in the LICENSE.Apache file in the root directory).
|
||||||
|
|
||||||
|
#ifndef ROCKSDB_LITE
|
||||||
|
|
||||||
|
#include "utilities/transactions/write_unprepared_txn.h"
|
||||||
|
|
||||||
|
#ifndef __STDC_FORMAT_MACROS
|
||||||
|
#define __STDC_FORMAT_MACROS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace rocksdb {
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace rocksdb
|
||||||
|
|
||||||
|
#endif // ROCKSDB_LITE
|
|
@ -0,0 +1,21 @@
|
||||||
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under both the GPLv2 (found in the
|
||||||
|
// COPYING file in the root directory) and Apache 2.0 License
|
||||||
|
// (found in the LICENSE.Apache file in the root directory).
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef ROCKSDB_LITE
|
||||||
|
|
||||||
|
#include "utilities/transactions/write_prepared_txn.h"
|
||||||
|
|
||||||
|
namespace rocksdb {
|
||||||
|
|
||||||
|
class WriteUnpreparedTxn : public WritePreparedTxn {
|
||||||
|
using WritePreparedTxn::WritePreparedTxn;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace rocksdb
|
||||||
|
|
||||||
|
#endif // ROCKSDB_LITE
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under both the GPLv2 (found in the
|
||||||
|
// COPYING file in the root directory) and Apache 2.0 License
|
||||||
|
// (found in the LICENSE.Apache file in the root directory).
|
||||||
|
|
||||||
|
#ifndef ROCKSDB_LITE
|
||||||
|
|
||||||
|
#ifndef __STDC_FORMAT_MACROS
|
||||||
|
#define __STDC_FORMAT_MACROS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "utilities/transactions/write_unprepared_txn_db.h"
|
||||||
|
#include "rocksdb/utilities/transaction_db.h"
|
||||||
|
|
||||||
|
namespace rocksdb {
|
||||||
|
|
||||||
|
Transaction* WriteUnpreparedTxnDB::BeginTransaction(
|
||||||
|
const WriteOptions& write_options, const TransactionOptions& txn_options,
|
||||||
|
Transaction* old_txn) {
|
||||||
|
if (old_txn != nullptr) {
|
||||||
|
ReinitializeTransaction(old_txn, write_options, txn_options);
|
||||||
|
return old_txn;
|
||||||
|
} else {
|
||||||
|
return new WriteUnpreparedTxn(this, write_options, txn_options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace rocksdb
|
||||||
|
#endif // ROCKSDB_LITE
|
|
@ -0,0 +1,27 @@
|
||||||
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
||||||
|
// This source code is licensed under both the GPLv2 (found in the
|
||||||
|
// COPYING file in the root directory) and Apache 2.0 License
|
||||||
|
// (found in the LICENSE.Apache file in the root directory).
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef ROCKSDB_LITE
|
||||||
|
|
||||||
|
#ifndef __STDC_FORMAT_MACROS
|
||||||
|
#define __STDC_FORMAT_MACROS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "utilities/transactions/write_prepared_txn_db.h"
|
||||||
|
|
||||||
|
#include "utilities/transactions/write_unprepared_txn.h"
|
||||||
|
|
||||||
|
namespace rocksdb {
|
||||||
|
|
||||||
|
class WriteUnpreparedTxnDB : public WritePreparedTxnDB {
|
||||||
|
using WritePreparedTxnDB::WritePreparedTxnDB;
|
||||||
|
|
||||||
|
Transaction* BeginTransaction(const WriteOptions& write_options, const TransactionOptions& txn_options,
|
||||||
|
Transaction* old_txn) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace rocksdb
|
||||||
|
#endif // ROCKSDB_LITE
|
Loading…
Reference in New Issue