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

Commit fb4217d

Browse files
Use a single Iterator instance for Cuckoohash
1 parent 3a32398 commit fb4217d

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/concurrency/timestamp_ordering_transaction_manager.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -775,20 +775,19 @@ ResultType TimestampOrderingTransactionManager::CommitTransaction(
775775
gc_object_set->emplace_back(database_oid, table_oid, index_oid);
776776
}
777777

778+
// Call the GetIterator() function to explicitly lock the cuckoohash
779+
// and initilaize the iterator
780+
auto rw_set_lt = rw_set.GetConstIterator();
781+
778782
oid_t database_id = 0;
779783
if (static_cast<StatsType>(settings::SettingsManager::GetInt(settings::SettingId::stats_mode)) !=
780784
StatsType::INVALID) {
781785
if (!rw_set.IsEmpty()) {
782-
auto rw_set_iterator = rw_set.GetConstIterator();
783-
const auto tile_group_id = rw_set_iterator.begin()->first.block;
786+
const auto tile_group_id = rw_set_lt.begin()->first.block;
784787
database_id = manager.GetTileGroup(tile_group_id)->GetDatabaseId();
785788
}
786789
}
787790

788-
// Call the GetIterator() function to explicitly lock the cuckoohash
789-
// and initilaize the iterator
790-
auto rw_set_lt = rw_set.GetConstIterator();
791-
792791
// install everything.
793792
// 1. install a new version for update operations;
794793
// 2. install an empty version for delete operations;
@@ -952,20 +951,20 @@ ResultType TimestampOrderingTransactionManager::AbortTransaction(
952951
gc_object_set->emplace_back(database_oid, table_oid, index_oid);
953952
}
954953

954+
955+
// Call the GetIterator() function to explicitly lock the cuckoohash
956+
// and initilaize the iterator
957+
auto rw_set_lt = rw_set.GetConstIterator();
958+
955959
oid_t database_id = 0;
956960
if (static_cast<StatsType>(settings::SettingsManager::GetInt(settings::SettingId::stats_mode)) !=
957961
StatsType::INVALID) {
958962
if (!rw_set.IsEmpty()) {
959-
auto rw_set_iterator = rw_set.GetConstIterator();
960-
const auto tile_group_id = rw_set_iterator.begin()->first.block;
963+
const auto tile_group_id = rw_set_lt.begin()->first.block;
961964
database_id = manager.GetTileGroup(tile_group_id)->GetDatabaseId();
962965
}
963966
}
964967

965-
// Call the GetIterator() function to explicitly lock the cuckoohash
966-
// and initilaize the iterator
967-
auto rw_set_lt = rw_set.GetConstIterator();
968-
969968
// Iterate through each item pointer in the read write set
970969
// TODO: This might be inefficient since we will have to get the
971970
// tile_group_header for each entry. Check if this needs to be consolidated

0 commit comments

Comments
 (0)