-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathptnk_findroot.cpp
More file actions
47 lines (40 loc) · 784 Bytes
/
ptnk_findroot.cpp
File metadata and controls
47 lines (40 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "ptnk/pageiomem.h"
#include "ptnk/btree_int.h"
using namespace ptnk;
int main(int argc, char* argv[])
{
try
{
PageIOMem pio(argv[1], 0);
page_id_t pgidTgt = strtol(argv[2], NULL, 16);
const page_id_t pgidE = pio.getLastPgId();
{
FINDNEXT:
{
Page pg(pio.readPage(pgidTgt));
pg.dump(&pio);
}
for(page_id_t pgid = 0; pgid <= pgidE; ++ pgid)
{
Page pg(pio.readPage(pgid));
if(! pg.isCommitted()) continue;
if(pg.pageType() != PT_NODE) continue;
Node node(pg);
if(node.contains_(pgidTgt))
{
pgidTgt = pgid;
goto FINDNEXT;
}
}
}
}
catch(std::exception& e)
{
std::cerr << e.what() << std::endl;
}
catch(...)
{
std::cerr << "unknown exception caught" << std::endl;
}
return 0;
}