Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Commit

Permalink
undo formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lmwnshn committed Jun 26, 2018
1 parent 9b29a4c commit 5739f18
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 54 deletions.
26 changes: 13 additions & 13 deletions src/concurrency/timestamp_ordering_transaction_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

//////////////////////////////////////////////////////////
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) ==
Expand Down Expand Up @@ -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) ==
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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();

Expand All @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions src/concurrency/transaction_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 14 additions & 14 deletions src/include/concurrency/transaction_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ class TransactionContext : public Printable {
*
* @return The query strings.
*/
inline const std::vector<std::string> &GetQueryStrings() const {
return query_strings_;
}
inline const std::vector<std::string>& GetQueryStrings() const {
return query_strings_; }

/**
* @brief Sets the commit identifier.
Expand All @@ -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.
*
Expand All @@ -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 &);
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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<GCSet> gc_set_;
std::shared_ptr<GCObjectSet> gc_object_set_;
Expand All @@ -340,8 +341,7 @@ class TransactionContext : public Printable {

std::unique_ptr<trigger::TriggerSet> 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;
};

Expand Down
55 changes: 31 additions & 24 deletions src/include/concurrency/transaction_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//


#pragma once

#include <atomic>
Expand Down Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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;

/**
Expand All @@ -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;

/**
Expand All @@ -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,
Expand All @@ -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);
}

Expand Down Expand Up @@ -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.
Expand All @@ -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
1 change: 1 addition & 0 deletions test/include/concurrency/testing_transaction_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5739f18

Please sign in to comment.