Skip to content

Commit cc271cd

Browse files
committed
KIKIMR-19139 Load index in Dump
1 parent 8ab67a4 commit cc271cd

File tree

3 files changed

+48
-20
lines changed

3 files changed

+48
-20
lines changed

ydb/core/tablet_flat/flat_part_dump.cpp

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "flat_part_dump.h"
22
#include "flat_part_iface.h"
3-
#include "flat_page_index.h"
3+
#include "flat_part_index_iter.h"
44
#include "flat_page_data.h"
55
#include "flat_page_frames.h"
66
#include "flat_page_blobs.h"
@@ -51,10 +51,20 @@ namespace {
5151
Index(part, depth);
5252

5353
if (depth > 2) {
54-
for (auto iter = part.Index->Begin(); iter; ++iter) {
54+
auto index = TPartIndexIt(&part, Env, { });
55+
56+
for (ssize_t i = 0; ; i++) {
57+
auto ready = i == 0 ? index.Seek(0) : index.Next();
58+
if (ready != EReady::Data) {
59+
if (ready == EReady::Page) {
60+
Out << " | -- the rest of the index rows aren't loaded" << Endl;
61+
}
62+
break;
63+
}
64+
5565
Out << Endl;
5666

57-
DataPage(part, iter->GetPageId());
67+
DataPage(part, index.GetPageId());
5868
}
5969
}
6070
}
@@ -90,15 +100,21 @@ namespace {
90100
{
91101
Key.reserve(part.Scheme->Groups[0].KeyTypes.size());
92102

93-
auto label = part.Index.Label();
94-
95-
const auto items = (part.Index->End() - part.Index->Begin() + 1);
103+
auto index = TPartIndexIt(&part, Env, { });
104+
auto label = index.TryGetLabel();
96105

97-
Out
98-
<< " + Index{" << (ui16)label.Type << " rev "
99-
<< label.Format << ", " << label.Size << "b}"
100-
<< " " << items << " rec" << Endl
101-
<< " | Page Row Bytes (";
106+
if (label) {
107+
Out
108+
<< " + Index{" << (ui16)label->Type << " rev "
109+
<< label->Format << ", " << label->Size << "b}"
110+
<< Endl
111+
<< " | Page Row Bytes (";
112+
} else {
113+
Out
114+
<< " + Index{unknown}"
115+
<< Endl
116+
<< " | Page Row Bytes (";
117+
}
102118

103119
for (auto off : xrange(part.Scheme->Groups[0].KeyTypes.size())) {
104120
Out << (off ? ", " : "");
@@ -108,20 +124,24 @@ namespace {
108124

109125
Out << ")" << Endl;
110126

111-
ssize_t seen = 0;
112-
113-
for (ssize_t i = 0; i < items; i++) {
127+
for (ssize_t i = 0; ; i++) {
114128
Key.clear();
115129

116-
if (depth < 2 && (seen += 1) > 10) {
117-
Out
118-
<< " | -- skipped " << (items - Min(items, seen - 1))
119-
<< " entries, depth level " << depth << Endl;
130+
if (depth < 2 && i >= 10) {
131+
Out << " | -- skipped the rest entries, depth level " << depth << Endl;
132+
break;
133+
}
120134

135+
// prints without LastKeyRecord, but it seems ok for now
136+
auto ready = i == 0 ? index.Seek(0) : index.Next();
137+
if (ready != EReady::Data) {
138+
if (ready == EReady::Page) {
139+
Out << " | -- the rest of the index rows aren't loaded" << Endl;
140+
}
121141
break;
122142
}
123143

124-
auto record = part.Index.At(i);
144+
auto record = index.GetRecord();
125145
for (const auto &info: part.Scheme->Groups[0].ColsKeyIdx)
126146
Key.push_back(record->Cell(info));
127147

ydb/core/tablet_flat/flat_part_index_iter.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ class TPartIndexIt {
9898
return TryGetIndex();
9999
}
100100

101+
std::optional<NPage::TLabel> TryGetLabel() {
102+
auto index = TryGetIndex();
103+
if (!index) {
104+
return { };
105+
}
106+
return index->Label();
107+
}
108+
101109
public:
102110
TRowId GetEndRowId() const {
103111
return EndRowId;

ydb/core/tablet_flat/flat_table.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ class TTable: public TAtomicRefCount<TTable> {
303303
for (const auto& flat : Flatten) {
304304
if (const TPartView &partView = flat.second) {
305305
size += partView->DataSize();
306-
rows += partView->Index.Rows();
306+
rows += partView.Part->Stat.Rows;
307307
}
308308
}
309309

0 commit comments

Comments
 (0)