From 2a965b2a1fd7629f473f8402f5e1a24b27360912 Mon Sep 17 00:00:00 2001 From: Wan Shen Lim Date: Tue, 26 Jun 2018 13:29:39 -0400 Subject: [PATCH] undo formatting changes --- ...timestamp_ordering_transaction_manager.cpp | 26 ++--- src/concurrency/transaction_manager.cpp | 5 +- src/include/concurrency/tags | 97 +++++++++++++++++++ src/include/concurrency/transaction_context.h | 26 ++--- src/include/concurrency/transaction_manager.h | 55 ++++++----- .../concurrency/testing_transaction_util.h | 1 + 6 files changed, 157 insertions(+), 53 deletions(-) create mode 100644 src/include/concurrency/tags 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/tags b/src/include/concurrency/tags new file mode 100644 index 00000000000..2954f951428 --- /dev/null +++ b/src/include/concurrency/tags @@ -0,0 +1,97 @@ +!_TAG_FILE_SORTED 2 /0=unsorted, 1=sorted, 2=foldcase/ +AbortTransaction /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual ResultType AbortTransaction(TransactionContext *const current_txn) = 0;$/;" p language:C++ class:peloton::concurrency::TransactionManager +AcquireOwnership /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual bool AcquireOwnership($/;" p language:C++ class:peloton::concurrency::TransactionManager +AddOnCommitTrigger /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ void AddOnCommitTrigger(trigger::TriggerData &trigger_data);$/;" p language:C++ class:peloton::concurrency::TransactionContext +AddQueryString /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline void AddQueryString(const char* query_string) {$/;" f language:C++ class:peloton::concurrency::TransactionContext +BeginTransaction /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ TransactionContext *BeginTransaction($/;" p language:C++ class:peloton::concurrency::TransactionManager +BeginTransaction /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ TransactionContext *BeginTransaction() { return BeginTransaction(false); }$/;" f language:C++ class:peloton::concurrency::TransactionManager +BeginTransaction /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ TransactionContext *BeginTransaction(const IsolationLevelType type) {$/;" f language:C++ class:peloton::concurrency::TransactionManager +BeginTransaction /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ TransactionContext *BeginTransaction(const size_t thread_id) {$/;" f language:C++ class:peloton::concurrency::TransactionManager +catalog /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^namespace catalog {$/;" n language:C++ namespace:peloton +catalog_cache /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ catalog::CatalogCache catalog_cache;$/;" m language:C++ class:peloton::concurrency::TransactionContext +CommitTransaction /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual ResultType CommitTransaction($/;" p language:C++ class:peloton::concurrency::TransactionManager +commit_id_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ cid_t commit_id_;$/;" m language:C++ class:peloton::concurrency::TransactionContext +concurrency /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^namespace concurrency {$/;" n language:C++ namespace:peloton +concurrency /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^namespace concurrency {$/;" n language:C++ namespace:peloton +conflict_avoidance_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ static ConflictAvoidanceType conflict_avoidance_;$/;" m language:C++ class:peloton::concurrency::TransactionManager +EndTransaction /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ void EndTransaction(TransactionContext *current_txn);$/;" p language:C++ class:peloton::concurrency::TransactionManager +epoch_id_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ eid_t epoch_id_;$/;" m language:C++ class:peloton::concurrency::TransactionContext +ExecOnCommitTriggers /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ void ExecOnCommitTriggers();$/;" p language:C++ class:peloton::concurrency::TransactionContext +gc_object_set_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ std::shared_ptr gc_object_set_;$/;" m language:C++ class:peloton::concurrency::TransactionContext +gc_set_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ std::shared_ptr gc_set_;$/;" m language:C++ class:peloton::concurrency::TransactionContext +GetCommitId /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline cid_t GetCommitId() const { return commit_id_; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +GetCreateDropSet /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline const CreateDropSet &GetCreateDropSet() { return rw_object_set_; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +GetEpochId /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline eid_t GetEpochId() const { return epoch_id_; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +GetExpiredCid /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ cid_t GetExpiredCid() {$/;" f language:C++ class:peloton::concurrency::TransactionManager +GetGCObjectSetPtr /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline std::shared_ptr GetGCObjectSetPtr() {$/;" f language:C++ class:peloton::concurrency::TransactionContext +GetGCSetPtr /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline std::shared_ptr GetGCSetPtr() { return gc_set_; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +GetInfo /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ const std::string GetInfo() const;$/;" p language:C++ class:peloton::concurrency::TransactionContext +GetIsolationLevel /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline IsolationLevelType GetIsolationLevel() const {$/;" f language:C++ class:peloton::concurrency::TransactionContext +GetIsolationLevel /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ IsolationLevelType GetIsolationLevel() {$/;" f language:C++ class:peloton::concurrency::TransactionManager +GetQueryStrings /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline const std::vector& GetQueryStrings() const {$/;" f language:C++ class:peloton::concurrency::TransactionContext +GetReadId /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline cid_t GetReadId() const { return read_id_; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +GetReadWriteSet /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline const ReadWriteSet &GetReadWriteSet() const { return rw_set_; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +GetResult /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline ResultType GetResult() const { return result_; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +GetRWType /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ RWType GetRWType(const ItemPointer &);$/;" p language:C++ class:peloton::concurrency::TransactionContext +GetThreadId /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline size_t GetThreadId() const { return thread_id_; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +GetTimestamp /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline uint64_t GetTimestamp() const { return timestamp_; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +GetTransactionId /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline txn_id_t GetTransactionId() const { return txn_id_; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +Init /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ void Init(bool read_only, const size_t thread_id,$/;" f language:C++ class:peloton::concurrency::TransactionContext +Init /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ void Init(bool read_only, const size_t thread_id,$/;" p language:C++ class:peloton::concurrency::TransactionContext +Init /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ void Init(const ProtocolType protocol,$/;" f language:C++ class:peloton::concurrency::TransactionManager +IsGCObjectSetEmpty /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline bool IsGCObjectSetEmpty() { return gc_object_set_->size() == 0; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +IsGCSetEmpty /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline bool IsGCSetEmpty() { return gc_set_->size() == 0; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +IsInRWSet /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ bool IsInRWSet(const ItemPointer &location) {$/;" f language:C++ class:peloton::concurrency::TransactionContext +IsOccupied /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ bool IsOccupied($/;" p language:C++ class:peloton::concurrency::TransactionManager +isolation_level_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ IsolationLevelType isolation_level_;$/;" m language:C++ class:peloton::concurrency::TransactionContext +isolation_level_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ static IsolationLevelType isolation_level_;$/;" m language:C++ class:peloton::concurrency::TransactionManager +IsOwnable /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual bool IsOwnable($/;" p language:C++ class:peloton::concurrency::TransactionManager +IsOwned /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual bool IsOwned($/;" p language:C++ class:peloton::concurrency::TransactionManager +IsOwner /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual bool IsOwner($/;" p language:C++ class:peloton::concurrency::TransactionManager +IsReadOnly /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ bool IsReadOnly() const {$/;" f language:C++ class:peloton::concurrency::TransactionContext +IsVisible /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ VisibilityType IsVisible($/;" p language:C++ class:peloton::concurrency::TransactionManager +IsWritten /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ bool IsWritten() const { return is_written_; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +IsWritten /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual bool IsWritten($/;" p language:C++ class:peloton::concurrency::TransactionManager +is_written_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ bool is_written_;$/;" m language:C++ class:peloton::concurrency::TransactionContext +on_commit_triggers_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ std::unique_ptr on_commit_triggers_;$/;" m language:C++ class:peloton::concurrency::TransactionContext +peloton /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^namespace peloton {$/;" n language:C++ +peloton /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^namespace peloton {$/;" n language:C++ +PerformDelete /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual void PerformDelete(TransactionContext *const current_txn,$/;" p language:C++ class:peloton::concurrency::TransactionManager +PerformDelete /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual void PerformDelete(TransactionContext *const current_txn,$/;" p language:C++ class:peloton::concurrency::TransactionManager +PerformInsert /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual void PerformInsert(TransactionContext *const current_txn,$/;" p language:C++ class:peloton::concurrency::TransactionManager +PerformRead /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual bool PerformRead(TransactionContext *const current_txn,$/;" p language:C++ class:peloton::concurrency::TransactionManager +PerformUpdate /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual void PerformUpdate(TransactionContext *const current_txn,$/;" p language:C++ class:peloton::concurrency::TransactionManager +PerformUpdate /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual void PerformUpdate(TransactionContext *const current_txn,$/;" p language:C++ class:peloton::concurrency::TransactionManager +protocol_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ static ProtocolType protocol_;$/;" m language:C++ class:peloton::concurrency::TransactionManager +query_strings_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ std::vector query_strings_;$/;" m language:C++ class:peloton::concurrency::TransactionContext +read_id_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ cid_t read_id_;$/;" m language:C++ class:peloton::concurrency::TransactionContext +read_only_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ bool read_only_ = false;$/;" m language:C++ class:peloton::concurrency::TransactionContext +RecordCreate /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ void RecordCreate(oid_t database_oid, oid_t table_oid, oid_t index_oid) {$/;" f language:C++ class:peloton::concurrency::TransactionContext +RecordDelete /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ bool RecordDelete(const ItemPointer &);$/;" p language:C++ class:peloton::concurrency::TransactionContext +RecordDrop /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ void RecordDrop(oid_t database_oid, oid_t table_oid, oid_t index_oid) {$/;" f language:C++ class:peloton::concurrency::TransactionContext +RecordInsert /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ void RecordInsert(const ItemPointer &);$/;" p language:C++ class:peloton::concurrency::TransactionContext +RecordReadOwn /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ void RecordReadOwn(const ItemPointer &);$/;" p language:C++ class:peloton::concurrency::TransactionContext +RecordTransactionStats /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ void RecordTransactionStats($/;" p language:C++ class:peloton::concurrency::TransactionManager +RecordUpdate /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ void RecordUpdate(const ItemPointer &);$/;" p language:C++ class:peloton::concurrency::TransactionContext +result_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ ResultType result_ = ResultType::SUCCESS;$/;" m language:C++ class:peloton::concurrency::TransactionContext +rw_object_set_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ CreateDropSet rw_object_set_;$/;" m language:C++ class:peloton::concurrency::TransactionContext +rw_set_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ ReadWriteSet rw_set_;$/;" m language:C++ class:peloton::concurrency::TransactionContext +SetCommitId /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline void SetCommitId(const cid_t commit_id) { commit_id_ = commit_id; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +SetEpochId /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline void SetEpochId(const eid_t epoch_id) { epoch_id_ = epoch_id; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +SetResult /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline void SetResult(ResultType result) { result_ = result; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +SetTimestamp /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ inline void SetTimestamp(const uint64_t timestamp) { timestamp_ = timestamp; }$/;" f language:C++ class:peloton::concurrency::TransactionContext +SetTransactionResult /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ void SetTransactionResult(TransactionContext *const current_txn, const ResultType result) {$/;" f language:C++ class:peloton::concurrency::TransactionManager +storage /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^namespace storage {$/;" n language:C++ namespace:peloton +thread_id_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ size_t thread_id_;$/;" m language:C++ class:peloton::concurrency::TransactionContext +timestamp_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ uint64_t timestamp_;$/;" m language:C++ class:peloton::concurrency::TransactionContext +TransactionContext /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ TransactionContext(bool read_only, const size_t thread_id,$/;" p language:C++ class:peloton::concurrency::TransactionContext +TransactionContext /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ TransactionContext(bool read_only, const size_t thread_id,$/;" p language:C++ class:peloton::concurrency::TransactionContext +TransactionContext /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ TransactionContext(TransactionContext const &) = delete;$/;" p language:C++ class:peloton::concurrency::TransactionContext +TransactionContext /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^class TransactionContext : public Printable {$/;" c language:C++ namespace:peloton::concurrency +TransactionManager /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ TransactionManager() {}$/;" f language:C++ class:peloton::concurrency::TransactionManager +TransactionManager /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^class TransactionManager {$/;" c language:C++ namespace:peloton::concurrency +trigger /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^namespace trigger {$/;" n language:C++ namespace:peloton +txn_id_ /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ txn_id_t txn_id_;$/;" m language:C++ class:peloton::concurrency::TransactionContext +YieldOwnership /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual void YieldOwnership($/;" p language:C++ class:peloton::concurrency::TransactionManager +~TransactionContext /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_context.h /^ ~TransactionContext() = default;$/;" p language:C++ class:peloton::concurrency::TransactionContext +~TransactionManager /Users/wanshenl/Documents/pavlo/peloton/src/include/concurrency/transaction_manager.h /^ virtual ~TransactionManager() {}$/;" f language:C++ class:peloton::concurrency::TransactionManager diff --git a/src/include/concurrency/transaction_context.h b/src/include/concurrency/transaction_context.h index d6d673341d0..0339dfb73ce 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,7 +326,7 @@ 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. */ std::shared_ptr gc_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);