10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
12
13
-
14
13
#pragma once
15
14
16
15
#include < atomic>
@@ -58,8 +57,7 @@ class TransactionManager {
58
57
*/
59
58
virtual ~TransactionManager () {}
60
59
61
- void Init (const ProtocolType protocol,
62
- const IsolationLevelType isolation,
60
+ void Init (const ProtocolType protocol, const IsolationLevelType isolation,
63
61
const ConflictAvoidanceType conflict) {
64
62
protocol_ = protocol;
65
63
isolation_level_ = isolation;
@@ -74,9 +72,8 @@ class TransactionManager {
74
72
*
75
73
* @return True if occupied, False otherwise.
76
74
*/
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);
80
77
81
78
/* *
82
79
* @brief Determines if visible.
@@ -103,10 +100,9 @@ class TransactionManager {
103
100
*
104
101
* @return True if owner, False otherwise.
105
102
*/
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;
110
106
111
107
/* *
112
108
* This method tests whether any other transaction has owned this version.
@@ -117,10 +113,9 @@ class TransactionManager {
117
113
*
118
114
* @return True if owned, False otherwise.
119
115
*/
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;
124
119
125
120
/* *
126
121
* Test whether the current transaction has created this version of the tuple.
@@ -132,9 +127,9 @@ class TransactionManager {
132
127
* @return True if written, False otherwise.
133
128
*/
134
129
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;
138
133
139
134
/* *
140
135
* Test whether it can obtain ownership.
@@ -161,7 +156,7 @@ class TransactionManager {
161
156
*/
162
157
virtual bool AcquireOwnership (
163
158
TransactionContext *const current_txn,
164
- const storage::TileGroupHeader *const tile_group_header,
159
+ const storage::TileGroupHeader *const tile_group_header,
165
160
const oid_t &tuple_id) = 0;
166
161
167
162
/* *
@@ -173,8 +168,8 @@ class TransactionManager {
173
168
*/
174
169
virtual void YieldOwnership (
175
170
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,
178
173
const oid_t &tuple_id) = 0;
179
174
180
175
/* *
@@ -186,14 +181,13 @@ class TransactionManager {
186
181
* @param index_entry_ptr The index entry pointer
187
182
*/
188
183
virtual void PerformInsert (TransactionContext *const current_txn,
189
- const ItemPointer &location,
184
+ const ItemPointer &location,
190
185
ItemPointer *index_entry_ptr = nullptr ) = 0;
191
186
192
187
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;
197
191
198
192
virtual void PerformUpdate (TransactionContext *const current_txn,
199
193
const ItemPointer &old_location,
@@ -215,17 +209,18 @@ class TransactionManager {
215
209
* @param current_txn The current transaction
216
210
* @param[in] result The result
217
211
*/
218
- void SetTransactionResult (TransactionContext *const current_txn, const ResultType result) {
212
+ void SetTransactionResult (TransactionContext *const current_txn,
213
+ const ResultType result) {
219
214
current_txn->SetResult (result);
220
215
}
221
216
222
217
TransactionContext *BeginTransaction (const IsolationLevelType type) {
223
218
return BeginTransaction (0 , type, false );
224
219
}
225
220
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 );
229
224
230
225
/* *
231
226
* @brief Ends a transaction.
@@ -245,7 +240,8 @@ class TransactionManager {
245
240
virtual ResultType CommitTransaction (
246
241
TransactionContext *const current_txn) = 0;
247
242
248
- virtual ResultType AbortTransaction (TransactionContext *const current_txn) = 0;
243
+ virtual ResultType AbortTransaction (
244
+ TransactionContext *const current_txn) = 0;
249
245
250
246
/* *
251
247
* This function generates the maximum commit id of committed transactions.
@@ -263,15 +259,12 @@ class TransactionManager {
263
259
*
264
260
* @return The isolation level.
265
261
*/
266
- IsolationLevelType GetIsolationLevel () {
267
- return isolation_level_;
268
- }
262
+ IsolationLevelType GetIsolationLevel () { return isolation_level_; }
269
263
270
264
protected:
271
265
static ProtocolType protocol_;
272
266
static IsolationLevelType isolation_level_;
273
267
static ConflictAvoidanceType conflict_avoidance_;
274
-
275
268
};
276
269
} // namespace storage
277
270
} // namespace peloton
0 commit comments