From 5739f18b0c4b4f380490a81b3b00a20e14f733b7 Mon Sep 17 00:00:00 2001 From: Wan Shen Lim Date: Tue, 26 Jun 2018 13:31:17 -0400 Subject: [PATCH] undo formatting changes --- ...timestamp_ordering_transaction_manager.cpp | 26 ++++----- src/concurrency/transaction_manager.cpp | 5 +- src/include/concurrency/transaction_context.h | 28 +++++----- src/include/concurrency/transaction_manager.h | 55 +++++++++++-------- .../concurrency/testing_transaction_util.h | 1 + 5 files changed, 61 insertions(+), 54 deletions(-) diff --git a/src/concurrency/timestamp_ordering_transaction_manager.cpp b/src/concurrency/timestamp_ordering_transaction_manager.cpp index f4f834ef0be..587abe00e06 100644 --- a/src/concurrency/timestamp_ordering_transaction_manager.cpp +++ b/src/concurrency/timestamp_ordering_transaction_manager.cpp @@ -148,9 +148,10 @@ void TimestampOrderingTransactionManager::YieldOwnership( tile_group_header->SetTransactionId(tuple_id, INITIAL_TXN_ID); } -bool TimestampOrderingTransactionManager::PerformRead( - TransactionContext *const current_txn, const ItemPointer &read_location, - storage::TileGroupHeader *tile_group_header, bool acquire_ownership) { +bool TimestampOrderingTransactionManager::PerformRead(TransactionContext *const current_txn, + const ItemPointer &read_location, + storage::TileGroupHeader *tile_group_header, + bool acquire_ownership) { ItemPointer location = read_location; ////////////////////////////////////////////////////////// @@ -346,8 +347,7 @@ void TimestampOrderingTransactionManager::PerformInsert( oid_t tuple_id = location.offset; auto storage_manager = storage::StorageManager::GetInstance(); - auto tile_group_header = - storage_manager->GetTileGroup(tile_group_id)->GetHeader(); + auto tile_group_header = storage_manager->GetTileGroup(tile_group_id)->GetHeader(); auto transaction_id = current_txn->GetTransactionId(); // check MVCC info @@ -391,8 +391,9 @@ void TimestampOrderingTransactionManager::PerformUpdate( // version. PELOTON_ASSERT(tile_group_header->GetTransactionId(old_location.offset) == transaction_id); - PELOTON_ASSERT(tile_group_header->GetPrevItemPointer(old_location.offset) - .IsNull() == true); + PELOTON_ASSERT( + tile_group_header->GetPrevItemPointer(old_location.offset).IsNull() == + true); // check whether the new version is empty. PELOTON_ASSERT(new_tile_group_header->GetTransactionId(new_location.offset) == @@ -496,8 +497,9 @@ void TimestampOrderingTransactionManager::PerformDelete( PELOTON_ASSERT(tile_group_header->GetTransactionId(old_location.offset) == transaction_id); // we must be deleting the latest version. - PELOTON_ASSERT(tile_group_header->GetPrevItemPointer(old_location.offset) - .IsNull() == true); + PELOTON_ASSERT( + tile_group_header->GetPrevItemPointer(old_location.offset).IsNull() == + true); // check whether the new version is empty. PELOTON_ASSERT(new_tile_group_header->GetTransactionId(new_location.offset) == @@ -552,8 +554,7 @@ void TimestampOrderingTransactionManager::PerformDelete( oid_t tuple_id = location.offset; auto storage_manager = storage::StorageManager::GetInstance(); - auto tile_group_header = - storage_manager->GetTileGroup(tile_group_id)->GetHeader(); + auto tile_group_header = storage_manager->GetTileGroup(tile_group_id)->GetHeader(); PELOTON_ASSERT(tile_group_header->GetTransactionId(tuple_id) == current_txn->GetTransactionId()); @@ -595,8 +596,6 @@ ResultType TimestampOrderingTransactionManager::CommitTransaction( return ResultType::SUCCESS; } - auto &rw_set = current_txn->GetReadWriteSet(); - auto storage_manager = storage::StorageManager::GetInstance(); auto &log_manager = logging::LogManager::GetInstance(); @@ -605,6 +604,7 @@ ResultType TimestampOrderingTransactionManager::CommitTransaction( // generate transaction id. cid_t end_commit_id = current_txn->GetCommitId(); + auto &rw_set = current_txn->GetReadWriteSet(); auto &rw_object_set = current_txn->GetCreateDropSet(); auto gc_set = current_txn->GetGCSetPtr(); diff --git a/src/concurrency/transaction_manager.cpp b/src/concurrency/transaction_manager.cpp index 813155ddc7d..e2f9bcbccfb 100644 --- a/src/concurrency/transaction_manager.cpp +++ b/src/concurrency/transaction_manager.cpp @@ -99,9 +99,8 @@ bool TransactionManager::IsOccupied(TransactionContext *const current_txn, const void *position_ptr) { ItemPointer &position = *((ItemPointer *)position_ptr); - auto tile_group_header = storage::StorageManager::GetInstance() - ->GetTileGroup(position.block) - ->GetHeader(); + auto tile_group_header = + storage::StorageManager::GetInstance()->GetTileGroup(position.block)->GetHeader(); auto tuple_id = position.offset; txn_id_t tuple_txn_id = tile_group_header->GetTransactionId(tuple_id); diff --git a/src/include/concurrency/transaction_context.h b/src/include/concurrency/transaction_context.h index d6d673341d0..c23ab1d59c9 100644 --- a/src/include/concurrency/transaction_context.h +++ b/src/include/concurrency/transaction_context.h @@ -118,9 +118,8 @@ class TransactionContext : public Printable { * * @return The query strings. */ - inline const std::vector &GetQueryStrings() const { - return query_strings_; - } + inline const std::vector& GetQueryStrings() const { + return query_strings_; } /** * @brief Sets the commit identifier. @@ -135,7 +134,7 @@ class TransactionContext : public Printable { * @param[in] epoch_id The epoch identifier */ inline void SetEpochId(const eid_t epoch_id) { epoch_id_ = epoch_id; } - + /** * @brief Sets the timestamp. * @@ -148,18 +147,18 @@ class TransactionContext : public Printable { * * @param[in] query_string The query string */ - inline void AddQueryString(const char *query_string) { + inline void AddQueryString(const char* query_string) { query_strings_.push_back(std::string(query_string)); } void RecordCreate(oid_t database_oid, oid_t table_oid, oid_t index_oid) { - rw_object_set_.push_back( - std::make_tuple(database_oid, table_oid, index_oid, DDLType::CREATE)); + rw_object_set_.push_back(std::make_tuple(database_oid, table_oid, + index_oid, DDLType::CREATE)); } void RecordDrop(oid_t database_oid, oid_t table_oid, oid_t index_oid) { - rw_object_set_.push_back( - std::make_tuple(database_oid, table_oid, index_oid, DDLType::DROP)); + rw_object_set_.push_back(std::make_tuple(database_oid, table_oid, + index_oid, DDLType::DROP)); } void RecordReadOwn(const ItemPointer &); @@ -262,7 +261,9 @@ class TransactionContext : public Printable { * * @return True if read only, False otherwise. */ - bool IsReadOnly() const { return read_only_; } + bool IsReadOnly() const { + return read_only_; + } /** * @brief Determines if already written. @@ -325,8 +326,8 @@ class TransactionContext : public Printable { ReadWriteSet rw_set_; CreateDropSet rw_object_set_; - /** - * this set contains data location that needs to be gc'd in the transaction. + /** + * this set contains data location that needs to be gc'd in the transaction. */ std::shared_ptr gc_set_; std::shared_ptr gc_object_set_; @@ -340,8 +341,7 @@ class TransactionContext : public Printable { std::unique_ptr on_commit_triggers_; - /** one default transaction is NOT 'read only' unless it is marked 'read only' - * explicitly*/ + /** one default transaction is NOT 'read only' unless it is marked 'read only' explicitly*/ bool read_only_ = false; }; diff --git a/src/include/concurrency/transaction_manager.h b/src/include/concurrency/transaction_manager.h index b52ed4e7916..e15eb4b6d33 100644 --- a/src/include/concurrency/transaction_manager.h +++ b/src/include/concurrency/transaction_manager.h @@ -10,6 +10,7 @@ // //===----------------------------------------------------------------------===// + #pragma once #include @@ -57,7 +58,8 @@ class TransactionManager { */ virtual ~TransactionManager() {} - void Init(const ProtocolType protocol, const IsolationLevelType isolation, + void Init(const ProtocolType protocol, + const IsolationLevelType isolation, const ConflictAvoidanceType conflict) { protocol_ = protocol; isolation_level_ = isolation; @@ -72,8 +74,9 @@ class TransactionManager { * * @return True if occupied, False otherwise. */ - bool IsOccupied(TransactionContext *const current_txn, - const void *position_ptr); + bool IsOccupied( + TransactionContext *const current_txn, + const void *position_ptr); /** * @brief Determines if visible. @@ -100,9 +103,10 @@ class TransactionManager { * * @return True if owner, False otherwise. */ - virtual bool IsOwner(TransactionContext *const current_txn, - const storage::TileGroupHeader *const tile_group_header, - const oid_t &tuple_id) = 0; + virtual bool IsOwner( + TransactionContext *const current_txn, + const storage::TileGroupHeader *const tile_group_header, + const oid_t &tuple_id) = 0; /** * This method tests whether any other transaction has owned this version. @@ -113,9 +117,10 @@ class TransactionManager { * * @return True if owned, False otherwise. */ - virtual bool IsOwned(TransactionContext *const current_txn, - const storage::TileGroupHeader *const tile_group_header, - const oid_t &tuple_id) = 0; + virtual bool IsOwned( + TransactionContext *const current_txn, + const storage::TileGroupHeader *const tile_group_header, + const oid_t &tuple_id) = 0; /** * Test whether the current transaction has created this version of the tuple. @@ -127,9 +132,9 @@ class TransactionManager { * @return True if written, False otherwise. */ virtual bool IsWritten( - TransactionContext *const current_txn, - const storage::TileGroupHeader *const tile_group_header, - const oid_t &tuple_id) = 0; + TransactionContext *const current_txn, + const storage::TileGroupHeader *const tile_group_header, + const oid_t &tuple_id) = 0; /** * Test whether it can obtain ownership. @@ -156,7 +161,7 @@ class TransactionManager { */ virtual bool AcquireOwnership( TransactionContext *const current_txn, - const storage::TileGroupHeader *const tile_group_header, + const storage::TileGroupHeader *const tile_group_header, const oid_t &tuple_id) = 0; /** @@ -168,8 +173,8 @@ class TransactionManager { */ virtual void YieldOwnership( TransactionContext *const current_txn, - // const oid_t &tile_group_id, - const storage::TileGroupHeader *const tile_group_header, + // const oid_t &tile_group_id, + const storage::TileGroupHeader *const tile_group_header, const oid_t &tuple_id) = 0; /** @@ -181,13 +186,14 @@ class TransactionManager { * @param index_entry_ptr The index entry pointer */ virtual void PerformInsert(TransactionContext *const current_txn, - const ItemPointer &location, + const ItemPointer &location, ItemPointer *index_entry_ptr = nullptr) = 0; virtual bool PerformRead(TransactionContext *const current_txn, - const ItemPointer &location, - storage::TileGroupHeader *tile_group_header, - bool acquire_ownership) = 0; + const ItemPointer &location, + storage::TileGroupHeader *tile_group_header, + bool acquire_ownership) = 0; + virtual void PerformUpdate(TransactionContext *const current_txn, const ItemPointer &old_location, @@ -209,8 +215,7 @@ class TransactionManager { * @param current_txn The current transaction * @param[in] result The result */ - void SetTransactionResult(TransactionContext *const current_txn, - const ResultType result) { + void SetTransactionResult(TransactionContext *const current_txn, const ResultType result) { current_txn->SetResult(result); } @@ -246,8 +251,7 @@ class TransactionManager { virtual ResultType CommitTransaction( TransactionContext *const current_txn) = 0; - virtual ResultType AbortTransaction( - TransactionContext *const current_txn) = 0; + virtual ResultType AbortTransaction(TransactionContext *const current_txn) = 0; /** * This function generates the maximum commit id of committed transactions. @@ -265,12 +269,15 @@ class TransactionManager { * * @return The isolation level. */ - IsolationLevelType GetIsolationLevel() { return isolation_level_; } + IsolationLevelType GetIsolationLevel() { + return isolation_level_; + } protected: static ProtocolType protocol_; static IsolationLevelType isolation_level_; static ConflictAvoidanceType conflict_avoidance_; + }; } // namespace storage } // namespace peloton diff --git a/test/include/concurrency/testing_transaction_util.h b/test/include/concurrency/testing_transaction_util.h index 14457503d6a..4fe3cb9df79 100644 --- a/test/include/concurrency/testing_transaction_util.h +++ b/test/include/concurrency/testing_transaction_util.h @@ -355,6 +355,7 @@ class TransactionScheduler { table(datatable_), time(0), concurrent(false) { + for (size_t i = 0; i < num_txn; i++) { if (read_only_.find(i) != read_only_.end()) { schedules.emplace_back(i, true);