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

Commit 6ca864e

Browse files
Yingjun Wupoojanilangekar
authored andcommitted
change writeset type to tbb::concurrent_unordered_set
1 parent a898325 commit 6ca864e

File tree

6 files changed

+16
-9
lines changed

6 files changed

+16
-9
lines changed

src/codegen/updater.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void Updater::Init(storage::DataTable *table,
3838
target_list_ =
3939
new TargetList(target_vector, target_vector + target_vector_size);
4040

41-
statement_write_set_ = new ReadWriteSet();
41+
statement_write_set_ = new WriteSet();
4242
}
4343

4444
char *Updater::GetDataPtr(uint32_t tile_group_id, uint32_t tuple_offset) {
@@ -78,7 +78,8 @@ char *Updater::Prepare(uint32_t tile_group_id, uint32_t tuple_offset) {
7878
char *Updater::PreparePK(uint32_t tile_group_id, uint32_t tuple_offset) {
7979

8080
PELOTON_ASSERT(table_ != nullptr && executor_context_ != nullptr);
81-
if (statement_write_set_->Contains(ItemPointer(tile_group_id, tuple_offset))) {
81+
82+
if (statement_write_set_->find(ItemPointer(tile_group_id, tuple_offset)) != statement_write_set_->end()) {
8283
return nullptr;
8384
}
8485

@@ -173,7 +174,7 @@ void Updater::UpdatePK() {
173174
return;
174175
}
175176
txn_manager.PerformInsert(txn, new_location_, index_entry_ptr);
176-
statement_write_set_->Insert(new_location_, RWType::INSERT);
177+
statement_write_set_->insert(new_location_);
177178
executor_context_->num_processed++;
178179
}
179180

src/executor/update_executor.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ bool UpdateExecutor::DInit() {
5353
PELOTON_ASSERT(target_table_);
5454
PELOTON_ASSERT(project_info_);
5555

56-
statement_write_set_.Clear();
56+
statement_write_set_.clear();
5757

5858
return true;
5959
}
@@ -63,7 +63,7 @@ bool UpdateExecutor::PerformUpdatePrimaryKey(
6363
storage::TileGroupHeader *tile_group_header, oid_t physical_tuple_id,
6464
ItemPointer &old_location) {
6565

66-
if (statement_write_set_.Contains(old_location)) {
66+
if (statement_write_set_.find(old_location) != statement_write_set_.end()) {
6767
return true;
6868
}
6969

@@ -143,8 +143,7 @@ bool UpdateExecutor::PerformUpdatePrimaryKey(
143143
}
144144

145145
transaction_manager.PerformInsert(current_txn, location, index_entry_ptr);
146-
statement_write_set_.Insert(location, RWType::INSERT);
147-
146+
statement_write_set_.insert(location);
148147
return true;
149148
}
150149

src/include/codegen/updater.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class Updater {
8282
// the same operation.
8383
// By maintaining the statement-level write set, an update operation will check
8484
// whether the to-be-updated tuple is created by the same operation.
85-
ReadWriteSet *statement_write_set_;
85+
WriteSet *statement_write_set_;
8686

8787
// Ownership information
8888
bool is_owner_;

src/include/common/internal_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <unistd.h>
2525

2626
#include "tbb/concurrent_vector.h"
27+
#include "tbb/concurrent_unordered_set.h"
2728

2829
#include "parser/pg_trigger.h"
2930
#include "type/type_id.h"
@@ -1209,6 +1210,8 @@ std::ostream &operator<<(std::ostream &os, const RWType &type);
12091210
typedef CuckooMap<ItemPointer, RWType, ItemPointerHasher, ItemPointerComparator>
12101211
ReadWriteSet;
12111212

1213+
typedef tbb::concurrent_unordered_multiset<ItemPointer, ItemPointerHasher, ItemPointerComparator> WriteSet;
1214+
12121215
// this enum is to identify why the version should be GC'd.
12131216
enum class GCVersionType {
12141217
INVALID,

src/include/common/item_pointer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class ItemPointer {
4444
}
4545
}
4646

47+
bool operator==(const ItemPointer &rhs) const {
48+
return (block == rhs.block && offset == rhs.offset);
49+
}
50+
4751
} __attribute__((__aligned__(8))) __attribute__((__packed__));
4852

4953
extern ItemPointer INVALID_ITEMPOINTER;

src/include/executor/update_executor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class UpdateExecutor : public AbstractExecutor {
6060
// the same operation.
6161
// By maintaining the statement-level write set, an update operation will check
6262
// whether the to-be-updated tuple is created by the same operation.
63-
ReadWriteSet statement_write_set_;
63+
WriteSet statement_write_set_;
6464
};
6565

6666
} // namespace executor

0 commit comments

Comments
 (0)