Skip to content

Commit 6fd1846

Browse files
authored
fix(p2): rid inconsistency in b plus tree printer (#766)
1 parent 613c0f5 commit 6fd1846

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/include/storage/index/b_plus_tree_debug.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,12 @@ void BPLUSTREE_TYPE::BatchOpsFromFile(const std::filesystem::path &file_name) {
230230
int64_t key;
231231
char instruction;
232232
std::ifstream input(file_name);
233-
while (input) {
234-
input >> instruction >> key;
235-
RID rid(key);
233+
if (!input.is_open()) {
234+
std::cerr << "Failed to open file: " << file_name << std::endl;
235+
return;
236+
}
237+
while (input >> instruction >> key) {
238+
RID rid(static_cast<int32_t>(key >> 32), static_cast<int>(key & 0xFFFFFFFF));
236239
KeyType index_key;
237240
index_key.SetFromInteger(key);
238241
switch (instruction) {
@@ -243,9 +246,14 @@ void BPLUSTREE_TYPE::BatchOpsFromFile(const std::filesystem::path &file_name) {
243246
Remove(index_key);
244247
break;
245248
default:
249+
std::cerr << "Unknown instruction: " << instruction << std::endl;
246250
break;
247251
}
248252
}
253+
if (input.bad()) {
254+
std::cerr << "Error reading file: " << file_name << std::endl;
255+
}
256+
input.close();
249257
}
250258

251259
INDEX_TEMPLATE_ARGUMENTS

0 commit comments

Comments
 (0)