From 95a1935cb121ef728ba49c2049854a02a78f7f9e Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Tue, 25 Oct 2022 14:15:22 -0700 Subject: [PATCH] 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 --- .../transactions/lock/point/point_lock_manager.cc | 14 ++++++++------ .../transactions/lock/point/point_lock_manager.h | 5 ++--- .../transactions/lock/range/range_locking_test.cc | 11 ++++------- .../lock/range/range_tree/lib/locktree/locktree.cc | 3 +-- .../range/range_tree/lib/portability/toku_time.h | 2 +- utilities/transactions/optimistic_transaction.h | 2 +- .../transactions/optimistic_transaction_db_impl.h | 2 +- .../transactions/optimistic_transaction_test.cc | 5 +++-- utilities/transactions/transaction_base.cc | 3 +-- utilities/transactions/transaction_base.h | 5 +++-- utilities/transactions/transaction_test.cc | 10 +++++----- .../write_prepared_transaction_test.cc | 7 +++---- utilities/transactions/write_prepared_txn.cc | 4 ++-- utilities/transactions/write_prepared_txn_db.cc | 9 +++++---- .../write_unprepared_transaction_test.cc | 2 +- utilities/transactions/write_unprepared_txn_db.cc | 1 + 16 files changed, 42 insertions(+), 43 deletions(-) diff --git a/utilities/transactions/lock/point/point_lock_manager.cc b/utilities/transactions/lock/point/point_lock_manager.cc index 1948c81c1..c71a66027 100644 --- a/utilities/transactions/lock/point/point_lock_manager.cc +++ b/utilities/transactions/lock/point/point_lock_manager.cc @@ -334,10 +334,10 @@ Status PointLockManager::AcquireWithTimeout( } if (result.IsTimedOut()) { - timed_out = true; - // Even though we timed out, we will still make one more attempt to - // acquire lock below (it is possible the lock expired and we - // were never signaled). + timed_out = true; + // Even though we timed out, we will still make one more attempt to + // acquire lock below (it is possible the lock expired and we + // were never signaled). } if (result.ok() || result.IsTimedOut()) { @@ -379,8 +379,10 @@ bool PointLockManager::IncrementWaiters( const autovector& wait_ids, const std::string& key, const uint32_t& cf_id, const bool& exclusive, Env* const env) { auto id = txn->GetID(); - std::vector queue_parents(static_cast(txn->GetDeadlockDetectDepth())); - std::vector queue_values(static_cast(txn->GetDeadlockDetectDepth())); + std::vector queue_parents( + static_cast(txn->GetDeadlockDetectDepth())); + std::vector queue_values( + static_cast(txn->GetDeadlockDetectDepth())); std::lock_guard lock(wait_txn_map_mutex_); assert(!wait_txn_map_.Contains(id)); diff --git a/utilities/transactions/lock/point/point_lock_manager.h b/utilities/transactions/lock/point/point_lock_manager.h index 3c6f80dcd..5f01eaeb2 100644 --- a/utilities/transactions/lock/point/point_lock_manager.h +++ b/utilities/transactions/lock/point/point_lock_manager.h @@ -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* txn_ids); + const std::string& key, Env* env, LockInfo&& lock_info, + uint64_t* wait_time, autovector* txn_ids); void UnLockKey(PessimisticTransaction* txn, const std::string& key, LockMapStripe* stripe, LockMap* lock_map, Env* env); diff --git a/utilities/transactions/lock/range/range_locking_test.cc b/utilities/transactions/lock/range/range_locking_test.cc index 45e138326..bce66c1f3 100644 --- a/utilities/transactions/lock/range/range_locking_test.cc +++ b/utilities/transactions/lock/range/range_locking_test.cc @@ -142,20 +142,18 @@ TEST_F(RangeLockingTest, UpgradeLockAndGetConflict) { auto cf = db->DefaultColumnFamily(); Status s; std::string value; - txn_options.lock_timeout= 10; + txn_options.lock_timeout = 10; Transaction* txn0 = db->BeginTransaction(write_options, txn_options); Transaction* txn1 = db->BeginTransaction(write_options, txn_options); // Get the shared lock in txn0 - s = txn0->GetForUpdate(ReadOptions(), cf, - Slice("a"), &value, - false /*exclusive*/); + 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"); diff --git a/utilities/transactions/lock/range/range_tree/lib/locktree/locktree.cc b/utilities/transactions/lock/range/range_tree/lib/locktree/locktree.cc index 0d99130ae..3d6a590c7 100644 --- a/utilities/transactions/lock/range/range_tree/lib/locktree/locktree.cc +++ b/utilities/transactions/lock/range/range_tree/lib/locktree/locktree.cc @@ -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); diff --git a/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h b/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h index 37fde0323..46111e7f0 100644 --- a/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h +++ b/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h @@ -129,7 +129,7 @@ static inline tokutime_t toku_time_now(void) { return (uint64_t)hi << 32 | lo; #elif defined(__aarch64__) uint64_t result; - __asm __volatile__("mrs %[rt], cntvct_el0" : [ rt ] "=r"(result)); + __asm __volatile__("mrs %[rt], cntvct_el0" : [rt] "=r"(result)); return result; #elif defined(__powerpc__) return __ppc_get_timebase(); diff --git a/utilities/transactions/optimistic_transaction.h b/utilities/transactions/optimistic_transaction.h index c337de2af..de23233d5 100644 --- a/utilities/transactions/optimistic_transaction.h +++ b/utilities/transactions/optimistic_transaction.h @@ -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" diff --git a/utilities/transactions/optimistic_transaction_db_impl.h b/utilities/transactions/optimistic_transaction_db_impl.h index 49651be01..88e86ea4a 100644 --- a/utilities/transactions/optimistic_transaction_db_impl.h +++ b/utilities/transactions/optimistic_transaction_db_impl.h @@ -6,9 +6,9 @@ #pragma once #ifndef ROCKSDB_LITE +#include #include #include -#include #include "rocksdb/db.h" #include "rocksdb/options.h" diff --git a/utilities/transactions/optimistic_transaction_test.cc b/utilities/transactions/optimistic_transaction_test.cc index 1bd9fc9be..aa8192c32 100644 --- a/utilities/transactions/optimistic_transaction_test.cc +++ b/utilities/transactions/optimistic_transaction_test.cc @@ -53,7 +53,7 @@ class OptimisticTransactionTest Open(); } -private: + private: void Open() { ColumnFamilyOptions cf_options(options); OptimisticTransactionDBOptions occ_opts; @@ -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"); diff --git a/utilities/transactions/transaction_base.cc b/utilities/transactions/transaction_base.cc index c98cfcbf2..83fd94ac8 100644 --- a/utilities/transactions/transaction_base.cc +++ b/utilities/transactions/transaction_base.cc @@ -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(); diff --git a/utilities/transactions/transaction_base.h b/utilities/transactions/transaction_base.h index 504d692bf..1bcb20ca9 100644 --- a/utilities/transactions/transaction_base.h +++ b/utilities/transactions/transaction_base.h @@ -93,8 +93,9 @@ class TransactionBaseImpl : public Transaction { std::vector MultiGet(const ReadOptions& options, const std::vector& keys, std::vector* values) override { - return MultiGet(options, std::vector( - keys.size(), db_->DefaultColumnFamily()), + return MultiGet(options, + std::vector( + keys.size(), db_->DefaultColumnFamily()), keys, values); } diff --git a/utilities/transactions/transaction_test.cc b/utilities/transactions/transaction_test.cc index 632826def..5b00630f1 100644 --- a/utilities/transactions/transaction_test.cc +++ b/utilities/transactions/transaction_test.cc @@ -2490,7 +2490,7 @@ TEST_P(TransactionTest, FlushTest2) { ASSERT_OK(s); ASSERT_EQ("z", value); - delete txn; + delete txn; } } @@ -2967,9 +2967,9 @@ TEST_P(TransactionTest, MultiGetLargeBatchedTest) { std::vector values(keys.size()); std::vector statuses(keys.size()); - 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) { + 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()); } else if (i == 2) { @@ -4674,7 +4674,7 @@ TEST_P(TransactionTest, TimeoutTest) { ASSERT_OK(s); TransactionOptions txn_options0; - txn_options0.expiration = 100; // 100ms + txn_options0.expiration = 100; // 100ms txn_options0.lock_timeout = 50; // txn timeout no longer infinite Transaction* txn1 = db->BeginTransaction(write_options, txn_options0); diff --git a/utilities/transactions/write_prepared_transaction_test.cc b/utilities/transactions/write_prepared_transaction_test.cc index 71682c0e2..ce1d7803f 100644 --- a/utilities/transactions/write_prepared_transaction_test.cc +++ b/utilities/transactions/write_prepared_transaction_test.cc @@ -2120,7 +2120,7 @@ TEST_P(WritePreparedTransactionTest, IsInSnapshot) { seq++; cur_txn = seq; wp_db->AddPrepared(cur_txn); - } else { // else commit it + } else { // else commit it seq++; wp_db->AddCommitted(cur_txn, seq); wp_db->RemovePrepared(cur_txn); @@ -3445,9 +3445,8 @@ TEST_P(WritePreparedTransactionTest, Iterate) { auto* txn = db->BeginTransaction(WriteOptions()); for (int i = 0; i < 2; i++) { - Iterator* iter = (i == 0) - ? db->NewIterator(ReadOptions()) - : txn->GetIterator(ReadOptions()); + Iterator* iter = (i == 0) ? db->NewIterator(ReadOptions()) + : txn->GetIterator(ReadOptions()); // Seek iter->Seek("foo"); verify_state(iter, "foo", expected_val); diff --git a/utilities/transactions/write_prepared_txn.cc b/utilities/transactions/write_prepared_txn.cc index 1133f903a..16b5cc1cb 100644 --- a/utilities/transactions/write_prepared_txn.cc +++ b/utilities/transactions/write_prepared_txn.cc @@ -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); diff --git a/utilities/transactions/write_prepared_txn_db.cc b/utilities/transactions/write_prepared_txn_db.cc index c6661479a..595c3df8f 100644 --- a/utilities/transactions/write_prepared_txn_db.cc +++ b/utilities/transactions/write_prepared_txn_db.cc @@ -309,7 +309,6 @@ void WritePreparedTxnDB::UpdateCFComparatorMap(ColumnFamilyHandle* h) { handle_map_.reset(handle_map); } - std::vector WritePreparedTxnDB::MultiGet( const ReadOptions& options, const std::vector& 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(indexed_seq)].load(std::memory_order_acquire); + *entry_64b = commit_cache_[static_cast(indexed_seq)].load( + std::memory_order_acquire); bool valid = entry_64b->Parse(indexed_seq, entry, FORMAT); return valid; } @@ -617,8 +617,9 @@ 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(indexed_seq)].exchange( - new_entry_64b, std::memory_order_acq_rel); + CommitEntry64b evicted_entry_64b = + commit_cache_[static_cast(indexed_seq)].exchange( + new_entry_64b, std::memory_order_acq_rel); bool valid = evicted_entry_64b.Parse(indexed_seq, evicted_entry, FORMAT); return valid; } diff --git a/utilities/transactions/write_unprepared_transaction_test.cc b/utilities/transactions/write_unprepared_transaction_test.cc index 771ff5553..6c8c62e0e 100644 --- a/utilities/transactions/write_unprepared_transaction_test.cc +++ b/utilities/transactions/write_unprepared_transaction_test.cc @@ -28,7 +28,7 @@ class WriteUnpreparedTransactionTest WriteUnpreparedTransactionTest() : WriteUnpreparedTransactionTestBase(std::get<0>(GetParam()), std::get<1>(GetParam()), - std::get<2>(GetParam())){} + std::get<2>(GetParam())) {} }; INSTANTIATE_TEST_CASE_P( diff --git a/utilities/transactions/write_unprepared_txn_db.cc b/utilities/transactions/write_unprepared_txn_db.cc index 72a21755a..2ed2d5c59 100644 --- a/utilities/transactions/write_unprepared_txn_db.cc +++ b/utilities/transactions/write_unprepared_txn_db.cc @@ -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"