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

Commit 2db074c

Browse files
committed
Added is_written_ flag back in for potential future optimizations.
1 parent ad0381d commit 2db074c

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/concurrency/transaction_context.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ void TransactionContext::Init(const size_t thread_id,
7676

7777
thread_id_ = thread_id;
7878

79+
is_written_ = false;
80+
7981
isolation_level_ = isolation;
8082

8183
gc_set_ = std::make_shared<GCSet>();
@@ -115,18 +117,18 @@ void TransactionContext::RecordUpdate(const ItemPointer &location) {
115117
(rw_set_[location] != RWType::DELETE &&
116118
rw_set_[location] != RWType::INS_DEL));
117119
auto rw_set_it = rw_set_.find(location);
118-
if (rw_set_it != rw_set_.end()) {
119-
if (rw_set_it->second == RWType::READ || rw_set_it->second == RWType::READ_OWN) {
120-
rw_set_it->second = RWType::UPDATE;
121-
}
122-
return;
120+
if (rw_set_it != rw_set_.end() && (rw_set_it->second == RWType::READ ||
121+
rw_set_it->second == RWType::READ_OWN)) {
122+
rw_set_it->second = RWType::UPDATE;
123+
is_written_ = true;
123124
}
124-
rw_set_[location] = RWType::UPDATE;
125+
PELOTON_ASSERT(is_written_);
125126
}
126127

127128
void TransactionContext::RecordInsert(const ItemPointer &location) {
128129
PELOTON_ASSERT(rw_set_.find(location) == rw_set_.end());
129130
rw_set_[location] = RWType::INSERT;
131+
is_written_ = true;
130132
}
131133

132134
bool TransactionContext::RecordDelete(const ItemPointer &location) {
@@ -135,10 +137,12 @@ bool TransactionContext::RecordDelete(const ItemPointer &location) {
135137
rw_set_[location] != RWType::INS_DEL));
136138
auto rw_set_it = rw_set_.find(location);
137139
if (rw_set_it != rw_set_.end() && rw_set_it->second == RWType::INSERT) {
140+
PELOTON_ASSERT(is_written_);
138141
rw_set_it->second = RWType::INS_DEL;
139142
return true;
140143
} else {
141144
rw_set_[location] = RWType::DELETE;
145+
is_written_ = true;
142146
return false;
143147
}
144148
}

src/include/concurrency/transaction_context.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ class TransactionContext : public Printable {
338338

339339
IsolationLevelType isolation_level_;
340340

341+
bool is_written_;
342+
341343
std::unique_ptr<trigger::TriggerSet> on_commit_triggers_;
342344

343345
/** one default transaction is NOT 'read only' unless it is marked 'read only' explicitly*/

0 commit comments

Comments
 (0)