-
Notifications
You must be signed in to change notification settings - Fork 1
/
ptnk_dumpstreak.cpp
57 lines (50 loc) · 1.28 KB
/
ptnk_dumpstreak.cpp
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
48
49
50
51
52
53
54
55
56
57
#include "ptnk/pageiomem.h"
#include "ptnk/streak.h"
using namespace ptnk;
int main(int argc, char* argv[])
{
try
{
PageIOMem pio(argv[1], 0);
tx_id_t txid = atoi(argv[2]);
Buffer bufStreakReal; bufStreakReal.reset();
page_id_t pgidE = pio.getLastPgId();
for(page_id_t pgid = 0; pgid <= pgidE; ++ pgid)
{
Page pg(pio.readPage(pgid));
if(pg.isCommitted() && pg.hdr()->txid == txid)
{
if(pg.pageType() != PT_OVFLSTREAK)
{
BufferCRef pgstreak(pg.streak(), Page::STREAK_SIZE);
// std::cout << "streak: " << pgstreak.hexdump() << std::endl;
bufStreakReal.append(pgstreak);
}
else
{
OverflowedStreakPage ospg(pg);
bufStreakReal.append(ospg.read());
}
}
}
BufferCRef bufStreak = bufStreakReal.rref();
size_t count = *(size_t*)bufStreak.popFront(sizeof(size_t));
// std::cout << "buf streak " << bufStreak.rref().hexdump() << std::endl;
std::cout << "streak pol count " << count << std::endl;
for(size_t i = 0; i < count; ++ i)
{
page_id_t pgid;
bufStreak.popFrontTo(&pgid, sizeof(page_id_t));
std::cout << "pgid: " << pgid2str(pgid) << std::endl;
}
}
catch(std::exception& e)
{
std::cerr << e.what() << std::endl;
}
catch(...)
{
std::cerr << "unknown exception caught" << std::endl;
}
return 0;
}