Run clang-format on utilities/transactions (#10871)

Summary:
This PR is the result of running the following command
```
find ./utilities/transactions/ -name '*.cc' -o -name '*.h' -o -name '*.c' -o -name '*.hpp' -o -name '*.cpp' | xargs clang-format -i
```

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10871

Test Plan: make check

Reviewed By: cbi42

Differential Revision: D40686871

Pulled By: riversand963

fbshipit-source-id: 613738d667ec8f8e13cce4802e0e166d6be52211
main
Yanqin Jin 2 years ago committed by Facebook GitHub Bot
parent 84563a2701
commit 95a1935cb1
  1. 6
      utilities/transactions/lock/point/point_lock_manager.cc
  2. 5
      utilities/transactions/lock/point/point_lock_manager.h
  3. 7
      utilities/transactions/lock/range/range_locking_test.cc
  4. 3
      utilities/transactions/lock/range/range_tree/lib/locktree/locktree.cc
  5. 2
      utilities/transactions/optimistic_transaction.h
  6. 2
      utilities/transactions/optimistic_transaction_db_impl.h
  7. 3
      utilities/transactions/optimistic_transaction_test.cc
  8. 3
      utilities/transactions/transaction_base.cc
  9. 3
      utilities/transactions/transaction_base.h
  10. 4
      utilities/transactions/transaction_test.cc
  11. 3
      utilities/transactions/write_prepared_transaction_test.cc
  12. 4
      utilities/transactions/write_prepared_txn.cc
  13. 7
      utilities/transactions/write_prepared_txn_db.cc
  14. 1
      utilities/transactions/write_unprepared_txn_db.cc

@ -379,8 +379,10 @@ bool PointLockManager::IncrementWaiters(
const autovector<TransactionID>& wait_ids, const std::string& key,
const uint32_t& cf_id, const bool& exclusive, Env* const env) {
auto id = txn->GetID();
std::vector<int> queue_parents(static_cast<size_t>(txn->GetDeadlockDetectDepth()));
std::vector<TransactionID> queue_values(static_cast<size_t>(txn->GetDeadlockDetectDepth()));
std::vector<int> queue_parents(
static_cast<size_t>(txn->GetDeadlockDetectDepth()));
std::vector<TransactionID> queue_values(
static_cast<size_t>(txn->GetDeadlockDetectDepth()));
std::lock_guard<std::mutex> lock(wait_txn_map_mutex_);
assert(!wait_txn_map_.Contains(id));

@ -203,9 +203,8 @@ class PointLockManager : public LockManager {
LockInfo&& lock_info);
Status AcquireLocked(LockMap* lock_map, LockMapStripe* stripe,
const std::string& key, Env* env,
LockInfo&& lock_info, uint64_t* wait_time,
autovector<TransactionID>* txn_ids);
const std::string& key, Env* env, LockInfo&& lock_info,
uint64_t* wait_time, autovector<TransactionID>* txn_ids);
void UnLockKey(PessimisticTransaction* txn, const std::string& key,
LockMapStripe* stripe, LockMap* lock_map, Env* env);

@ -148,14 +148,12 @@ TEST_F(RangeLockingTest, UpgradeLockAndGetConflict) {
Transaction* txn1 = db->BeginTransaction(write_options, txn_options);
// Get the shared lock in txn0
s = txn0->GetForUpdate(ReadOptions(), cf,
Slice("a"), &value,
s = txn0->GetForUpdate(ReadOptions(), cf, Slice("a"), &value,
false /*exclusive*/);
ASSERT_TRUE(s.IsNotFound());
// Get the shared lock on the same key in txn1
s = txn1->GetForUpdate(ReadOptions(), cf,
Slice("a"), &value,
s = txn1->GetForUpdate(ReadOptions(), cf, Slice("a"), &value,
false /*exclusive*/);
ASSERT_TRUE(s.IsNotFound());
@ -170,7 +168,6 @@ TEST_F(RangeLockingTest, UpgradeLockAndGetConflict) {
delete txn1;
}
TEST_F(RangeLockingTest, SnapshotValidation) {
Status s;
Slice key_slice = Slice("k");

@ -199,8 +199,7 @@ static bool determine_conflicting_txnids(
if (other_txnid == TXNID_SHARED) {
// Add all shared lock owners, except this transaction.
for (TXNID shared_id : *lock.owners) {
if (shared_id != txnid)
conflicts->add(shared_id);
if (shared_id != txnid) conflicts->add(shared_id);
}
} else {
conflicts->add(other_txnid);

@ -18,8 +18,8 @@
#include "rocksdb/snapshot.h"
#include "rocksdb/status.h"
#include "rocksdb/types.h"
#include "rocksdb/utilities/transaction.h"
#include "rocksdb/utilities/optimistic_transaction_db.h"
#include "rocksdb/utilities/transaction.h"
#include "rocksdb/utilities/write_batch_with_index.h"
#include "utilities/transactions/transaction_base.h"
#include "utilities/transactions/transaction_util.h"

@ -6,9 +6,9 @@
#pragma once
#ifndef ROCKSDB_LITE
#include <algorithm>
#include <mutex>
#include <vector>
#include <algorithm>
#include "rocksdb/db.h"
#include "rocksdb/options.h"

@ -1426,7 +1426,8 @@ TEST_P(OptimisticTransactionTest, SequenceNumberAfterRecoverTest) {
WriteOptions write_options;
OptimisticTransactionOptions transaction_options;
Transaction* transaction(txn_db->BeginTransaction(write_options, transaction_options));
Transaction* transaction(
txn_db->BeginTransaction(write_options, transaction_options));
Status s = transaction->Put("foo", "val");
ASSERT_OK(s);
s = transaction->Put("foo2", "val");

@ -209,8 +209,7 @@ Status TransactionBaseImpl::RollbackToSavePoint() {
}
Status TransactionBaseImpl::PopSavePoint() {
if (save_points_ == nullptr ||
save_points_->empty()) {
if (save_points_ == nullptr || save_points_->empty()) {
// No SavePoint yet.
assert(write_batch_.PopSavePoint().IsNotFound());
return Status::NotFound();

@ -93,7 +93,8 @@ class TransactionBaseImpl : public Transaction {
std::vector<Status> MultiGet(const ReadOptions& options,
const std::vector<Slice>& keys,
std::vector<std::string>* values) override {
return MultiGet(options, std::vector<ColumnFamilyHandle*>(
return MultiGet(options,
std::vector<ColumnFamilyHandle*>(
keys.size(), db_->DefaultColumnFamily()),
keys, values);
}

@ -2967,8 +2967,8 @@ TEST_P(TransactionTest, MultiGetLargeBatchedTest) {
std::vector<PinnableSlice> values(keys.size());
std::vector<Status> statuses(keys.size());
wb.MultiGetFromBatchAndDB(db, snapshot_read_options, handles[1], keys.size(), keys.data(),
values.data(), statuses.data(), false);
wb.MultiGetFromBatchAndDB(db, snapshot_read_options, handles[1], keys.size(),
keys.data(), values.data(), statuses.data(), false);
for (size_t i = 0; i < keys.size(); ++i) {
if (i == 1) {
ASSERT_TRUE(statuses[1].IsNotFound());

@ -3445,8 +3445,7 @@ TEST_P(WritePreparedTransactionTest, Iterate) {
auto* txn = db->BeginTransaction(WriteOptions());
for (int i = 0; i < 2; i++) {
Iterator* iter = (i == 0)
? db->NewIterator(ReadOptions())
Iterator* iter = (i == 0) ? db->NewIterator(ReadOptions())
: txn->GetIterator(ReadOptions());
// Seek
iter->Seek("foo");

@ -115,8 +115,8 @@ Status WritePreparedTxn::PrepareInternal() {
// For each duplicate key we account for a new sub-batch
prepare_batch_cnt_ = GetWriteBatch()->SubBatchCnt();
// Having AddPrepared in the PreReleaseCallback allows in-order addition of
// prepared entries to PreparedHeap and hence enables an optimization. Refer to
// SmallestUnCommittedSeq for more details.
// prepared entries to PreparedHeap and hence enables an optimization. Refer
// to SmallestUnCommittedSeq for more details.
AddPreparedCallback add_prepared_callback(
wpt_db_, db_impl_, prepare_batch_cnt_,
db_impl_->immutable_db_options().two_write_queues, kFirstPrepareBatch);

@ -309,7 +309,6 @@ void WritePreparedTxnDB::UpdateCFComparatorMap(ColumnFamilyHandle* h) {
handle_map_.reset(handle_map);
}
std::vector<Status> WritePreparedTxnDB::MultiGet(
const ReadOptions& options,
const std::vector<ColumnFamilyHandle*>& column_family,
@ -608,7 +607,8 @@ void WritePreparedTxnDB::RemovePrepared(const uint64_t prepare_seq,
bool WritePreparedTxnDB::GetCommitEntry(const uint64_t indexed_seq,
CommitEntry64b* entry_64b,
CommitEntry* entry) const {
*entry_64b = commit_cache_[static_cast<size_t>(indexed_seq)].load(std::memory_order_acquire);
*entry_64b = commit_cache_[static_cast<size_t>(indexed_seq)].load(
std::memory_order_acquire);
bool valid = entry_64b->Parse(indexed_seq, entry, FORMAT);
return valid;
}
@ -617,7 +617,8 @@ bool WritePreparedTxnDB::AddCommitEntry(const uint64_t indexed_seq,
const CommitEntry& new_entry,
CommitEntry* evicted_entry) {
CommitEntry64b new_entry_64b(new_entry, FORMAT);
CommitEntry64b evicted_entry_64b = commit_cache_[static_cast<size_t>(indexed_seq)].exchange(
CommitEntry64b evicted_entry_64b =
commit_cache_[static_cast<size_t>(indexed_seq)].exchange(
new_entry_64b, std::memory_order_acq_rel);
bool valid = evicted_entry_64b.Parse(indexed_seq, evicted_entry, FORMAT);
return valid;

@ -6,6 +6,7 @@
#ifndef ROCKSDB_LITE
#include "utilities/transactions/write_unprepared_txn_db.h"
#include "db/arena_wrapped_db_iter.h"
#include "rocksdb/utilities/transaction_db.h"
#include "util/cast_util.h"

Loading…
Cancel
Save