Skip to content

Commit

Permalink
KIKIMR-19139 Load index in Dump
Browse files Browse the repository at this point in the history
  • Loading branch information
kunga committed Sep 27, 2023
1 parent 8ab67a4 commit cc271cd
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 20 deletions.
58 changes: 39 additions & 19 deletions ydb/core/tablet_flat/flat_part_dump.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "flat_part_dump.h"
#include "flat_part_iface.h"
#include "flat_page_index.h"
#include "flat_part_index_iter.h"
#include "flat_page_data.h"
#include "flat_page_frames.h"
#include "flat_page_blobs.h"
Expand Down Expand Up @@ -51,10 +51,20 @@ namespace {
Index(part, depth);

if (depth > 2) {
for (auto iter = part.Index->Begin(); iter; ++iter) {
auto index = TPartIndexIt(&part, Env, { });

for (ssize_t i = 0; ; i++) {
auto ready = i == 0 ? index.Seek(0) : index.Next();
if (ready != EReady::Data) {
if (ready == EReady::Page) {
Out << " | -- the rest of the index rows aren't loaded" << Endl;
}
break;
}

Out << Endl;

DataPage(part, iter->GetPageId());
DataPage(part, index.GetPageId());
}
}
}
Expand Down Expand Up @@ -90,15 +100,21 @@ namespace {
{
Key.reserve(part.Scheme->Groups[0].KeyTypes.size());

auto label = part.Index.Label();

const auto items = (part.Index->End() - part.Index->Begin() + 1);
auto index = TPartIndexIt(&part, Env, { });
auto label = index.TryGetLabel();

Out
<< " + Index{" << (ui16)label.Type << " rev "
<< label.Format << ", " << label.Size << "b}"
<< " " << items << " rec" << Endl
<< " | Page Row Bytes (";
if (label) {
Out
<< " + Index{" << (ui16)label->Type << " rev "
<< label->Format << ", " << label->Size << "b}"
<< Endl
<< " | Page Row Bytes (";
} else {
Out
<< " + Index{unknown}"
<< Endl
<< " | Page Row Bytes (";
}

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

Out << ")" << Endl;

ssize_t seen = 0;

for (ssize_t i = 0; i < items; i++) {
for (ssize_t i = 0; ; i++) {
Key.clear();

if (depth < 2 && (seen += 1) > 10) {
Out
<< " | -- skipped " << (items - Min(items, seen - 1))
<< " entries, depth level " << depth << Endl;
if (depth < 2 && i >= 10) {
Out << " | -- skipped the rest entries, depth level " << depth << Endl;
break;
}

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

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

Expand Down
8 changes: 8 additions & 0 deletions ydb/core/tablet_flat/flat_part_index_iter.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ class TPartIndexIt {
return TryGetIndex();
}

std::optional<NPage::TLabel> TryGetLabel() {
auto index = TryGetIndex();
if (!index) {
return { };
}
return index->Label();
}

public:
TRowId GetEndRowId() const {
return EndRowId;
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tablet_flat/flat_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class TTable: public TAtomicRefCount<TTable> {
for (const auto& flat : Flatten) {
if (const TPartView &partView = flat.second) {
size += partView->DataSize();
rows += partView->Index.Rows();
rows += partView.Part->Stat.Rows;
}
}

Expand Down

0 comments on commit cc271cd

Please sign in to comment.