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

Commit 50411cb

Browse files
committed
formatting
1 parent 078a438 commit 50411cb

File tree

4 files changed

+47
-56
lines changed

4 files changed

+47
-56
lines changed

src/concurrency/transaction_context.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ RWType TransactionContext::GetRWType(const ItemPointer &location) {
101101
}
102102

103103
void TransactionContext::RecordRead(const ItemPointer &location) {
104-
105104
auto rw_set_it = rw_set_.find(location);
106105
if (rw_set_it != rw_set_.end()) {
107106
UNUSED_ATTRIBUTE RWType rw_type = rw_set_it->second;

src/concurrency/transaction_manager.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ bool TransactionManager::IsOccupied(TransactionContext *const current_txn,
102102
const void *position_ptr) {
103103
ItemPointer &position = *((ItemPointer *)position_ptr);
104104

105-
auto tile_group_header =
106-
storage::StorageManager::GetInstance()->GetTileGroup(position.block)->GetHeader();
105+
auto tile_group_header = storage::StorageManager::GetInstance()
106+
->GetTileGroup(position.block)
107+
->GetHeader();
107108
auto tuple_id = position.offset;
108109

109110
txn_id_t tuple_txn_id = tile_group_header->GetTransactionId(tuple_id);

src/include/concurrency/transaction_context.h

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ class TransactionContext : public Printable {
4545

4646
public:
4747
TransactionContext(const size_t thread_id, const IsolationLevelType isolation,
48-
const cid_t &read_id);
48+
const cid_t &read_id);
4949

5050
TransactionContext(const size_t thread_id, const IsolationLevelType isolation,
51-
const cid_t &read_id, const cid_t &commit_id);
51+
const cid_t &read_id, const cid_t &commit_id);
5252

5353
/**
5454
* @brief Destroys the object.
@@ -116,8 +116,9 @@ class TransactionContext : public Printable {
116116
*
117117
* @return The query strings.
118118
*/
119-
inline const std::vector<std::string>& GetQueryStrings() const {
120-
return query_strings_; }
119+
inline const std::vector<std::string> &GetQueryStrings() const {
120+
return query_strings_;
121+
}
121122

122123
/**
123124
* @brief Sets the commit identifier.
@@ -132,7 +133,7 @@ class TransactionContext : public Printable {
132133
* @param[in] epoch_id The epoch identifier
133134
*/
134135
inline void SetEpochId(const eid_t epoch_id) { epoch_id_ = epoch_id; }
135-
136+
136137
/**
137138
* @brief Sets the timestamp.
138139
*
@@ -145,18 +146,18 @@ class TransactionContext : public Printable {
145146
*
146147
* @param[in] query_string The query string
147148
*/
148-
inline void AddQueryString(const char* query_string) {
149+
inline void AddQueryString(const char *query_string) {
149150
query_strings_.push_back(std::string(query_string));
150151
}
151152

152153
void RecordCreate(oid_t database_oid, oid_t table_oid, oid_t index_oid) {
153-
rw_object_set_.push_back(std::make_tuple(database_oid, table_oid,
154-
index_oid, DDLType::CREATE));
154+
rw_object_set_.push_back(
155+
std::make_tuple(database_oid, table_oid, index_oid, DDLType::CREATE));
155156
}
156157

157158
void RecordDrop(oid_t database_oid, oid_t table_oid, oid_t index_oid) {
158-
rw_object_set_.push_back(std::make_tuple(database_oid, table_oid,
159-
index_oid, DDLType::DROP));
159+
rw_object_set_.push_back(
160+
std::make_tuple(database_oid, table_oid, index_oid, DDLType::DROP));
160161
}
161162

162163
void RecordRead(const ItemPointer &);
@@ -262,17 +263,13 @@ class TransactionContext : public Printable {
262263
*
263264
* @return True if read only, False otherwise.
264265
*/
265-
bool IsReadOnly() const {
266-
return read_only_;
267-
}
266+
bool IsReadOnly() const { return read_only_; }
268267

269268
/**
270269
* @brief mark this context as read only
271270
*
272271
*/
273-
void SetReadOnly() {
274-
read_only_ = true;
275-
}
272+
void SetReadOnly() { read_only_ = true; }
276273

277274
/**
278275
* @brief Gets the isolation level.
@@ -328,8 +325,8 @@ class TransactionContext : public Printable {
328325
ReadWriteSet rw_set_;
329326
CreateDropSet rw_object_set_;
330327

331-
/**
332-
* this set contains data location that needs to be gc'd in the transaction.
328+
/**
329+
* this set contains data location that needs to be gc'd in the transaction.
333330
*/
334331
std::shared_ptr<GCSet> gc_set_;
335332
std::shared_ptr<GCObjectSet> gc_object_set_;
@@ -344,7 +341,8 @@ class TransactionContext : public Printable {
344341

345342
std::unique_ptr<trigger::TriggerSet> on_commit_triggers_;
346343

347-
/** one default transaction is NOT 'read only' unless it is marked 'read only' explicitly*/
344+
/** one default transaction is NOT 'read only' unless it is marked 'read only'
345+
* explicitly*/
348346
bool read_only_ = false;
349347
};
350348

src/include/concurrency/transaction_manager.h

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
1413
#pragma once
1514

1615
#include <atomic>
@@ -58,8 +57,7 @@ class TransactionManager {
5857
*/
5958
virtual ~TransactionManager() {}
6059

61-
void Init(const ProtocolType protocol,
62-
const IsolationLevelType isolation,
60+
void Init(const ProtocolType protocol, const IsolationLevelType isolation,
6361
const ConflictAvoidanceType conflict) {
6462
protocol_ = protocol;
6563
isolation_level_ = isolation;
@@ -74,9 +72,8 @@ class TransactionManager {
7472
*
7573
* @return True if occupied, False otherwise.
7674
*/
77-
bool IsOccupied(
78-
TransactionContext *const current_txn,
79-
const void *position_ptr);
75+
bool IsOccupied(TransactionContext *const current_txn,
76+
const void *position_ptr);
8077

8178
/**
8279
* @brief Determines if visible.
@@ -103,10 +100,9 @@ class TransactionManager {
103100
*
104101
* @return True if owner, False otherwise.
105102
*/
106-
virtual bool IsOwner(
107-
TransactionContext *const current_txn,
108-
const storage::TileGroupHeader *const tile_group_header,
109-
const oid_t &tuple_id) = 0;
103+
virtual bool IsOwner(TransactionContext *const current_txn,
104+
const storage::TileGroupHeader *const tile_group_header,
105+
const oid_t &tuple_id) = 0;
110106

111107
/**
112108
* This method tests whether any other transaction has owned this version.
@@ -117,10 +113,9 @@ class TransactionManager {
117113
*
118114
* @return True if owned, False otherwise.
119115
*/
120-
virtual bool IsOwned(
121-
TransactionContext *const current_txn,
122-
const storage::TileGroupHeader *const tile_group_header,
123-
const oid_t &tuple_id) = 0;
116+
virtual bool IsOwned(TransactionContext *const current_txn,
117+
const storage::TileGroupHeader *const tile_group_header,
118+
const oid_t &tuple_id) = 0;
124119

125120
/**
126121
* Test whether the current transaction has created this version of the tuple.
@@ -132,9 +127,9 @@ class TransactionManager {
132127
* @return True if written, False otherwise.
133128
*/
134129
virtual bool IsWritten(
135-
TransactionContext *const current_txn,
136-
const storage::TileGroupHeader *const tile_group_header,
137-
const oid_t &tuple_id) = 0;
130+
TransactionContext *const current_txn,
131+
const storage::TileGroupHeader *const tile_group_header,
132+
const oid_t &tuple_id) = 0;
138133

139134
/**
140135
* Test whether it can obtain ownership.
@@ -161,7 +156,7 @@ class TransactionManager {
161156
*/
162157
virtual bool AcquireOwnership(
163158
TransactionContext *const current_txn,
164-
const storage::TileGroupHeader *const tile_group_header,
159+
const storage::TileGroupHeader *const tile_group_header,
165160
const oid_t &tuple_id) = 0;
166161

167162
/**
@@ -173,8 +168,8 @@ class TransactionManager {
173168
*/
174169
virtual void YieldOwnership(
175170
TransactionContext *const current_txn,
176-
// const oid_t &tile_group_id,
177-
const storage::TileGroupHeader *const tile_group_header,
171+
// const oid_t &tile_group_id,
172+
const storage::TileGroupHeader *const tile_group_header,
178173
const oid_t &tuple_id) = 0;
179174

180175
/**
@@ -186,14 +181,13 @@ class TransactionManager {
186181
* @param index_entry_ptr The index entry pointer
187182
*/
188183
virtual void PerformInsert(TransactionContext *const current_txn,
189-
const ItemPointer &location,
184+
const ItemPointer &location,
190185
ItemPointer *index_entry_ptr = nullptr) = 0;
191186

192187
virtual bool PerformRead(TransactionContext *const current_txn,
193-
const ItemPointer &location,
194-
storage::TileGroupHeader *tile_group_header,
195-
bool acquire_ownership) = 0;
196-
188+
const ItemPointer &location,
189+
storage::TileGroupHeader *tile_group_header,
190+
bool acquire_ownership) = 0;
197191

198192
virtual void PerformUpdate(TransactionContext *const current_txn,
199193
const ItemPointer &old_location,
@@ -215,17 +209,18 @@ class TransactionManager {
215209
* @param current_txn The current transaction
216210
* @param[in] result The result
217211
*/
218-
void SetTransactionResult(TransactionContext *const current_txn, const ResultType result) {
212+
void SetTransactionResult(TransactionContext *const current_txn,
213+
const ResultType result) {
219214
current_txn->SetResult(result);
220215
}
221216

222217
TransactionContext *BeginTransaction(const IsolationLevelType type) {
223218
return BeginTransaction(0, type, false);
224219
}
225220

226-
TransactionContext *BeginTransaction(const size_t thread_id = 0,
227-
const IsolationLevelType type = isolation_level_,
228-
bool read_only = false);
221+
TransactionContext *BeginTransaction(
222+
const size_t thread_id = 0,
223+
const IsolationLevelType type = isolation_level_, bool read_only = false);
229224

230225
/**
231226
* @brief Ends a transaction.
@@ -245,7 +240,8 @@ class TransactionManager {
245240
virtual ResultType CommitTransaction(
246241
TransactionContext *const current_txn) = 0;
247242

248-
virtual ResultType AbortTransaction(TransactionContext *const current_txn) = 0;
243+
virtual ResultType AbortTransaction(
244+
TransactionContext *const current_txn) = 0;
249245

250246
/**
251247
* This function generates the maximum commit id of committed transactions.
@@ -263,15 +259,12 @@ class TransactionManager {
263259
*
264260
* @return The isolation level.
265261
*/
266-
IsolationLevelType GetIsolationLevel() {
267-
return isolation_level_;
268-
}
262+
IsolationLevelType GetIsolationLevel() { return isolation_level_; }
269263

270264
protected:
271265
static ProtocolType protocol_;
272266
static IsolationLevelType isolation_level_;
273267
static ConflictAvoidanceType conflict_avoidance_;
274-
275268
};
276269
} // namespace storage
277270
} // namespace peloton

0 commit comments

Comments
 (0)