@@ -53,15 +53,20 @@ bool BWTREE_INDEX_TYPE::InsertEntry(const storage::Tuple *key,
53
53
KeyType index_key;
54
54
index_key.SetFromKey (key);
55
55
56
- bool ret = container.Insert (index_key, value);
56
+ bool ret;
57
+ if (HasUniqueKeys () == true ) {
58
+ ret = container.Insert (index_key, value, true );
59
+ } else {
60
+ ret = container.Insert (index_key, value, false );
61
+ }
57
62
58
- if (static_cast <StatsType>(settings::SettingsManager::GetInt (
59
- settings::SettingId::stats_mode)) != StatsType::INVALID) {
63
+ if (static_cast <StatsType>(settings::SettingsManager::GetInt (settings::SettingId::stats_mode)) != StatsType::INVALID) {
60
64
stats::BackendStatsContext::GetInstance ()->IncrementIndexInserts (metadata);
61
65
}
62
66
63
- LOG_TRACE (" InsertEntry(key=%s, val=%s) [%s]" ,
64
- index_key.GetInfo ().c_str (),
67
+ // NOTE: If I use index_key.GetInfo() here, I always get an empty key?
68
+ LOG_DEBUG (" InsertEntry(key=%s, val=%s) [%s]" ,
69
+ key->GetInfo ().c_str (),
65
70
IndexUtil::GetInfo (value).c_str (),
66
71
(ret ? " SUCCESS" : " FAIL" ));
67
72
@@ -85,14 +90,13 @@ bool BWTREE_INDEX_TYPE::DeleteEntry(const storage::Tuple *key,
85
90
// it is unnecessary for us to allocate memory
86
91
bool ret = container.Delete (index_key, value);
87
92
88
- if (static_cast <StatsType>(settings::SettingsManager::GetInt (
89
- settings::SettingId::stats_mode)) != StatsType::INVALID) {
93
+ if (static_cast <StatsType>(settings::SettingsManager::GetInt (settings::SettingId::stats_mode)) != StatsType::INVALID) {
90
94
stats::BackendStatsContext::GetInstance ()->IncrementIndexDeletes (
91
95
delete_count, metadata);
92
96
}
93
97
94
- LOG_TRACE (" DeleteEntry(key=%s, val=%s) [%s]" ,
95
- index_key. GetInfo ().c_str (),
98
+ LOG_DEBUG (" DeleteEntry(key=%s, val=%s) [%s]" ,
99
+ key-> GetInfo ().c_str (),
96
100
IndexUtil::GetInfo (value).c_str (),
97
101
(ret ? " SUCCESS" : " FAIL" ));
98
102
@@ -122,8 +126,7 @@ bool BWTREE_INDEX_TYPE::CondInsertEntry(
122
126
assert (ret == false );
123
127
}
124
128
125
- if (static_cast <StatsType>(settings::SettingsManager::GetInt (
126
- settings::SettingId::stats_mode)) != StatsType::INVALID) {
129
+ if (static_cast <StatsType>(settings::SettingsManager::GetInt (settings::SettingId::stats_mode)) != StatsType::INVALID) {
127
130
stats::BackendStatsContext::GetInstance ()->IncrementIndexInserts (metadata);
128
131
}
129
132
@@ -197,8 +200,7 @@ void BWTREE_INDEX_TYPE::Scan(
197
200
}
198
201
} // if is full scan
199
202
200
- if (static_cast <StatsType>(settings::SettingsManager::GetInt (
201
- settings::SettingId::stats_mode)) != StatsType::INVALID) {
203
+ if (static_cast <StatsType>(settings::SettingsManager::GetInt (settings::SettingId::stats_mode)) != StatsType::INVALID) {
202
204
stats::BackendStatsContext::GetInstance ()->IncrementIndexReads (
203
205
result.size (), metadata);
204
206
}
@@ -222,6 +224,7 @@ void BWTREE_INDEX_TYPE::ScanLimit(
222
224
const std::vector<ExpressionType> &expr_list,
223
225
ScanDirectionType scan_direction, std::vector<ValueType> &result,
224
226
const ConjunctionScanPredicate *csp_p, uint64_t limit, uint64_t offset) {
227
+
225
228
// Only work with limit == 1 and offset == 0
226
229
// Because that gets translated to "min"
227
230
// But still since we could not access tuples in the table
@@ -243,6 +246,7 @@ void BWTREE_INDEX_TYPE::ScanLimit(
243
246
auto scan_itr = container.Begin (index_low_key);
244
247
if ((scan_itr.IsEnd () == false ) &&
245
248
(container.KeyCmpLessEqual (scan_itr->first , index_high_key))) {
249
+
246
250
result.push_back (scan_itr->second );
247
251
}
248
252
} else {
@@ -263,8 +267,7 @@ void BWTREE_INDEX_TYPE::ScanAllKeys(std::vector<ValueType> &result) {
263
267
it++;
264
268
}
265
269
266
- if (static_cast <StatsType>(settings::SettingsManager::GetInt (
267
- settings::SettingId::stats_mode)) != StatsType::INVALID) {
270
+ if (static_cast <StatsType>(settings::SettingsManager::GetInt (settings::SettingId::stats_mode)) != StatsType::INVALID) {
268
271
stats::BackendStatsContext::GetInstance ()->IncrementIndexReads (
269
272
result.size (), metadata);
270
273
}
@@ -280,8 +283,7 @@ void BWTREE_INDEX_TYPE::ScanKey(const storage::Tuple *key,
280
283
// This function in BwTree fills a given vector
281
284
container.GetValue (index_key, result);
282
285
283
- if (static_cast <StatsType>(settings::SettingsManager::GetInt (
284
- settings::SettingId::stats_mode)) != StatsType::INVALID) {
286
+ if (static_cast <StatsType>(settings::SettingsManager::GetInt (settings::SettingId::stats_mode)) != StatsType::INVALID) {
285
287
stats::BackendStatsContext::GetInstance ()->IncrementIndexReads (
286
288
result.size (), metadata);
287
289
}
0 commit comments