Skip to content

Commit

Permalink
cr: fix grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
kunga committed Dec 29, 2023
1 parent 5be885a commit b623877
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 81 deletions.
2 changes: 1 addition & 1 deletion ydb/core/tablet_flat/benchmark/b_part_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace {

Cerr << "DataBytes = " << part->Stat.Bytes << " DataPages = " << IndexTools::CountMainPages(*part) << Endl;
Cerr << "FlatIndexBytes = " << part->GetPageSize(part->IndexPages.Groups[groups ? 1 : 0], {}) << " BTreeIndexBytes = " << part->IndexPages.BTreeGroups[groups ? 1 : 0].IndexSize << Endl;
Cerr << "Levels = " << part->IndexPages.BTreeGroups[groups ? 1 : 0].LevelsCount << Endl;
Cerr << "Levels = " << part->IndexPages.BTreeGroups[groups ? 1 : 0].LevelCount << Endl;

// 100 MB
UNIT_ASSERT_GE(part->Stat.Bytes, 100ull*1024*1024);
Expand Down
24 changes: 12 additions & 12 deletions ydb/core/tablet_flat/flat_page_btree_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace NKikimr::NTable::NPage {

struct TShortChild {
TPageId PageId;
TRowId RowsCount;
TRowId RowCount;
ui64 DataSize;

auto operator<=>(const TShortChild&) const = default;
Expand All @@ -95,22 +95,22 @@ namespace NKikimr::NTable::NPage {

struct TChild {
TPageId PageId;
TRowId RowsCount;
TRowId RowCount;
ui64 DataSize;
TRowId ErasedRowsCount;
TRowId ErasedRowCount;

auto operator<=>(const TChild&) const = default;

TString ToString() const noexcept
{
return TStringBuilder() << "PageId: " << PageId << " RowsCount: " << RowsCount << " DataSize: " << DataSize << " ErasedRowsCount: " << ErasedRowsCount;
return TStringBuilder() << "PageId: " << PageId << " RowCount: " << RowCount << " DataSize: " << DataSize << " ErasedRowCount: " << ErasedRowCount;
}
} Y_PACKED;

static_assert(sizeof(TChild) == 28, "Invalid TBtreeIndexNode TChild size");

static_assert(offsetof(TChild, PageId) == offsetof(TShortChild, PageId));
static_assert(offsetof(TChild, RowsCount) == offsetof(TShortChild, RowsCount));
static_assert(offsetof(TChild, RowCount) == offsetof(TShortChild, RowCount));
static_assert(offsetof(TChild, DataSize) == offsetof(TShortChild, DataSize));

#pragma pack(pop)
Expand Down Expand Up @@ -306,7 +306,7 @@ namespace NKikimr::NTable::NPage {
{
if (Header->IsShortChildFormat) {
const TShortChild* const shortChild = TDeref<const TShortChild>::At(Children, pos * sizeof(TShortChild));
return { shortChild->PageId, shortChild->RowsCount, shortChild->DataSize, 0 };
return { shortChild->PageId, shortChild->RowCount, shortChild->DataSize, 0 };
} else {
return *TDeref<const TChild>::At(Children, pos * sizeof(TChild));
}
Expand All @@ -326,19 +326,19 @@ namespace NKikimr::NTable::NPage {

auto range = xrange(0u, childrenCount);
const auto cmp = [this](TRowId rowId, TPos pos) {
return rowId < GetShortChild(pos).RowsCount;
return rowId < GetShortChild(pos).RowCount;
};

TRecIdx result;
if (!on) {
// Will do a full binary search on full range
} else if (GetShortChild(*on).RowsCount <= rowId) {
} else if (GetShortChild(*on).RowCount <= rowId) {
// Try a short linear search first
result = *on;
for (int linear = 0; linear < 4; ++linear) {
result++;
Y_ABORT_UNLESS(result < childrenCount, "Should always seek some child");
if (GetShortChild(result).RowsCount > rowId) {
if (GetShortChild(result).RowCount > rowId) {
return result;
}
}
Expand All @@ -352,7 +352,7 @@ namespace NKikimr::NTable::NPage {
if (result == 0) {
return 0;
}
if (GetShortChild(result - 1).RowsCount <= rowId) {
if (GetShortChild(result - 1).RowCount <= rowId) {
return result;
}
result--;
Expand Down Expand Up @@ -464,14 +464,14 @@ namespace NKikimr::NTable::NPage {
};

struct TBtreeIndexMeta : public TBtreeIndexNode::TChild {
ui32 LevelsCount;
ui32 LevelCount;
ui64 IndexSize;

auto operator<=>(const TBtreeIndexMeta&) const = default;

TString ToString() const noexcept
{
return TStringBuilder() << TBtreeIndexNode::TChild::ToString() << " LevelsCount: " << LevelsCount << " IndexSize: " << IndexSize;
return TStringBuilder() << TBtreeIndexNode::TChild::ToString() << " LevelCount: " << LevelCount << " IndexSize: " << IndexSize;
}
};
}
26 changes: 13 additions & 13 deletions ydb/core/tablet_flat/flat_page_btree_index_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace NKikimr::NTable::NPage {
}

void AddChild(TChild child) {
Y_ABORT_UNLESS(child.ErasedRowsCount == 0 || !IsShortChildFormat(), "Short format can't have ErasedRowsCount");
Y_ABORT_UNLESS(child.ErasedRowCount == 0 || !IsShortChildFormat(), "Short format can't have ErasedRowCount");
Children.push_back(child);
}

Expand Down Expand Up @@ -249,7 +249,7 @@ namespace NKikimr::NTable::NPage {
void PlaceChild(const TChild& child) noexcept
{
if (IsShortChildFormat()) {
Place<TShortChild>() = TShortChild{child.PageId, child.RowsCount, child.DataSize};
Place<TShortChild>() = TShortChild{child.PageId, child.RowCount, child.DataSize};
} else {
Place<TChild>() = child;
}
Expand Down Expand Up @@ -375,14 +375,14 @@ namespace NKikimr::NTable::NPage {
}

void AddShortChild(TShortChild child) {
AddChild(TChild{child.PageId, child.RowsCount, child.DataSize, 0});
AddChild(TChild{child.PageId, child.RowCount, child.DataSize, 0});
}

void AddChild(TChild child) {
// aggregate in order to perform search by row id from any leaf node
child.RowsCount = (ChildrenRowsCount += child.RowsCount);
child.DataSize = (ChildrenSize += child.DataSize);
child.ErasedRowsCount = (ChildrenErasedRowsCount += child.ErasedRowsCount);
child.RowCount = (ChildRowCount += child.RowCount);
child.DataSize = (ChildSize += child.DataSize);
child.ErasedRowCount = (ChildErasedRowCount += child.ErasedRowCount);

Levels[0].PushChild(child);
}
Expand All @@ -409,9 +409,9 @@ namespace NKikimr::NTable::NPage {
IndexSize = 0;
Writer.Reset();
Levels = { TLevel() };
ChildrenRowsCount = 0;
ChildrenErasedRowsCount = 0;
ChildrenSize = 0;
ChildRowCount = 0;
ChildErasedRowCount = 0;
ChildSize = 0;
}

private:
Expand Down Expand Up @@ -463,7 +463,7 @@ namespace NKikimr::NTable::NPage {
if (levelIndex + 1 == Levels.size()) {
Levels.emplace_back();
}
Levels[levelIndex + 1].PushChild(TChild{pageId, lastChild.RowsCount, lastChild.DataSize, lastChild.ErasedRowsCount});
Levels[levelIndex + 1].PushChild(TChild{pageId, lastChild.RowCount, lastChild.DataSize, lastChild.ErasedRowCount});
if (!last) {
Levels[levelIndex + 1].PushKey(Levels[levelIndex].PopKey());
}
Expand Down Expand Up @@ -498,9 +498,9 @@ namespace NKikimr::NTable::NPage {
const ui32 NodeKeysMin;
const ui32 NodeKeysMax;

TRowId ChildrenRowsCount = 0;
TRowId ChildrenErasedRowsCount = 0;
ui64 ChildrenSize = 0;
TRowId ChildRowCount = 0;
TRowId ChildErasedRowCount = 0;
ui64 ChildSize = 0;
};

}
20 changes: 10 additions & 10 deletions ydb/core/tablet_flat/flat_part_btree_index_iter.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class TPartBtreeIndexIt : public IIndexIter {
, GroupId(groupId)
, GroupInfo(part->Scheme->GetLayout(groupId))
, Meta(groupId.IsHistoric() ? part->IndexPages.BTreeHistoric[groupId.Index] : part->IndexPages.BTreeGroups[groupId.Index])
, State(Reserve(Meta.LevelsCount + 1))
, State(Reserve(Meta.LevelCount + 1))
{
const static TCellsIterable EmptyKey(static_cast<const char*>(nullptr), TColumns());
State.emplace_back(Meta, 0, GetEndRowId(), EmptyKey, EmptyKey);
Expand Down Expand Up @@ -180,7 +180,7 @@ class TPartBtreeIndexIt : public IIndexIter {
EReady Next() override {
Y_ABORT_UNLESS(!IsExhausted());

if (Meta.LevelsCount == 0) {
if (Meta.LevelCount == 0) {
return Exhaust();
}

Expand All @@ -194,7 +194,7 @@ class TPartBtreeIndexIt : public IIndexIter {
PushNextState(*State.back().Pos + 1);
}

for (ui32 level : xrange<ui32>(State.size() - 1, Meta.LevelsCount)) {
for (ui32 level : xrange<ui32>(State.size() - 1, Meta.LevelCount)) {
if (!TryLoad(State[level])) {
// exiting with an intermediate state
Y_DEBUG_ABORT_UNLESS(!IsLeaf() && !IsExhausted());
Expand All @@ -211,7 +211,7 @@ class TPartBtreeIndexIt : public IIndexIter {
EReady Prev() override {
Y_ABORT_UNLESS(!IsExhausted());

if (Meta.LevelsCount == 0) {
if (Meta.LevelCount == 0) {
return Exhaust();
}

Expand All @@ -225,7 +225,7 @@ class TPartBtreeIndexIt : public IIndexIter {
PushNextState(*State.back().Pos - 1);
}

for (ui32 level : xrange<ui32>(State.size() - 1, Meta.LevelsCount)) {
for (ui32 level : xrange<ui32>(State.size() - 1, Meta.LevelCount)) {
if (!TryLoad(State[level])) {
// exiting with an intermediate state
Y_DEBUG_ABORT_UNLESS(!IsLeaf() && !IsExhausted());
Expand All @@ -246,7 +246,7 @@ class TPartBtreeIndexIt : public IIndexIter {
}

TRowId GetEndRowId() const override {
return Meta.RowsCount;
return Meta.RowCount;
}

TPageId GetPageId() const override {
Expand Down Expand Up @@ -286,7 +286,7 @@ class TPartBtreeIndexIt : public IIndexIter {
State[0].Pos = { };
}

for (ui32 level : xrange<ui32>(State.size() - 1, Meta.LevelsCount)) {
for (ui32 level : xrange<ui32>(State.size() - 1, Meta.LevelCount)) {
auto &state = State[level];
Y_DEBUG_ABORT_UNLESS(seek.BelongsTo(state));
if (!TryLoad(state)) {
Expand Down Expand Up @@ -316,7 +316,7 @@ class TPartBtreeIndexIt : public IIndexIter {
bool IsLeaf() const noexcept {
// Note: it is possible to have 0 levels in B-Tree
// so we may have exhausted state with leaf (data) node
return State.size() == Meta.LevelsCount + 1 && !IsExhausted();
return State.size() == Meta.LevelCount + 1 && !IsExhausted();
}

EReady Exhaust() {
Expand All @@ -334,8 +334,8 @@ class TPartBtreeIndexIt : public IIndexIter {

auto child = current.Node->GetChild(pos);

TRowId beginRowId = pos ? current.Node->GetChild(pos - 1).RowsCount : current.BeginRowId;
TRowId endRowId = child.RowsCount;
TRowId beginRowId = pos ? current.Node->GetChild(pos - 1).RowCount : current.BeginRowId;
TRowId endRowId = child.RowCount;

TCellsIterable beginKey = pos ? current.Node->GetKeyCellsIterable(pos - 1, GroupInfo.ColsKeyIdx) : current.BeginKey;
TCellsIterable endKey = pos < current.Node->GetKeysCount() ? current.Node->GetKeyCellsIterable(pos, GroupInfo.ColsKeyIdx) : current.EndKey;
Expand Down
26 changes: 13 additions & 13 deletions ydb/core/tablet_flat/flat_part_charge_btree_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ class TChargeBTreeIndex : public ICharge {

const auto& meta = Part->IndexPages.BTreeGroups[0];

if (Y_UNLIKELY(row1 >= meta.RowsCount)) {
if (Y_UNLIKELY(row1 >= meta.RowCount)) {
return { true, true }; // already out of bounds, nothing to precharge
}
if (Y_UNLIKELY(row1 > row2)) {
row2 = row1; // will not go further than row1
}

TVector<TBtreeIndexNode> level, nextLevel(Reserve(2));
for (ui32 high = 0; high < meta.LevelsCount && ready; high++) {
if (high == 0) {
for (ui32 height = 0; height < meta.LevelCount && ready; height++) {
if (height == 0) {
ready &= TryLoadNode(meta.PageId, nextLevel);
} else {
for (ui32 i : xrange<ui32>(level.size())) {
TRecIdx from = 0, to = level[i].GetKeysCount();
if (i == 0) {
from = level[i].Seek(row1);
}
if (i + 1 == level.size() && row2 < meta.RowsCount) {
if (i + 1 == level.size() && row2 < meta.RowCount) {
to = level[i].Seek(row2);
}
for (TRecIdx j : xrange(from, to + 1)) {
Expand All @@ -70,15 +70,15 @@ class TChargeBTreeIndex : public ICharge {
return {false, false};
}

if (meta.LevelsCount == 0) {
if (meta.LevelCount == 0) {
ready &= HasDataPage(meta.PageId, { });
} else {
for (ui32 i : xrange<ui32>(level.size())) {
TRecIdx from = 0, to = level[i].GetKeysCount();
if (i == 0) {
from = level[i].Seek(row1);
}
if (i + 1 == level.size() && row2 < meta.RowsCount) {
if (i + 1 == level.size() && row2 < meta.RowCount) {
to = level[i].Seek(row2);
}
for (TRecIdx j : xrange(from, to + 1)) {
Expand All @@ -103,25 +103,25 @@ class TChargeBTreeIndex : public ICharge {

const auto& meta = Part->IndexPages.BTreeGroups[0];

if (Y_UNLIKELY(row1 >= meta.RowsCount)) {
row1 = meta.RowsCount - 1; // start from the last row
if (Y_UNLIKELY(row1 >= meta.RowCount)) {
row1 = meta.RowCount - 1; // start from the last row
}
if (Y_UNLIKELY(row1 < row2)) {
row2 = row1; // will not go further than row1
}

// level contains nodes in reverse order
TVector<TBtreeIndexNode> level, nextLevel(Reserve(2));
for (ui32 high = 0; high < meta.LevelsCount && ready; high++) {
if (high == 0) {
for (ui32 height = 0; height < meta.LevelCount && ready; height++) {
if (height == 0) {
ready &= TryLoadNode(meta.PageId, nextLevel);
} else {
for (ui32 i : xrange<ui32>(level.size())) {
TRecIdx from = level[i].GetKeysCount(), to = 0;
if (i == 0) {
from = level[i].Seek(row1);
}
if (i + 1 == level.size() && row2 < meta.RowsCount) {
if (i + 1 == level.size() && row2 < meta.RowCount) {
to = level[i].Seek(row2);
}
for (TRecIdx j = from + 1; j > to; j--) {
Expand All @@ -139,15 +139,15 @@ class TChargeBTreeIndex : public ICharge {
return {false, false};
}

if (meta.LevelsCount == 0) {
if (meta.LevelCount == 0) {
ready &= HasDataPage(meta.PageId, { });
} else {
for (ui32 i : xrange<ui32>(level.size())) {
TRecIdx from = level[i].GetKeysCount(), to = 0;
if (i == 0) {
from = level[i].Seek(row1);
}
if (i + 1 == level.size() && row2 < meta.RowsCount) {
if (i + 1 == level.size() && row2 < meta.RowCount) {
to = level[i].Seek(row2);
}
for (TRecIdx j = from + 1; j > to; j--) {
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tablet_flat/flat_part_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ namespace {
{
if (part.IndexPages.BTreeGroups) {
auto meta = part.IndexPages.BTreeGroups.front();
if (meta.LevelsCount) {
if (meta.LevelCount) {
BTreeIndexNode(part, meta);
} else {
Out
Expand Down
6 changes: 3 additions & 3 deletions ydb/core/tablet_flat/flat_part_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ void TLoader::StageParseMeta() noexcept
for (const auto &meta : history ? layout.GetBTreeHistoricIndexes() : layout.GetBTreeGroupIndexes()) {
NPage::TBtreeIndexMeta converted{{
meta.GetRootPageId(),
meta.GetRowsCount(),
meta.GetRowCount(),
meta.GetDataSize(),
meta.GetErasedRowsCount()},
meta.GetLevelsCount(),
meta.GetErasedRowCount()},
meta.GetLevelCount(),
meta.GetIndexSize()};
(history ? BTreeHistoricIndexes : BTreeGroupIndexes).push_back(converted);
}
Expand Down
6 changes: 3 additions & 3 deletions ydb/core/tablet_flat/flat_part_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -666,11 +666,11 @@ namespace NTable {
for (auto meta : history ? Current.BTreeHistoricIndexes : Current.BTreeGroupIndexes) {
auto m = history ? lay->AddBTreeHistoricIndexes() : lay->AddBTreeGroupIndexes();
m->SetRootPageId(meta.PageId);
m->SetLevelsCount(meta.LevelsCount);
m->SetLevelCount(meta.LevelCount);
m->SetIndexSize(meta.IndexSize);
m->SetDataSize(meta.DataSize);
m->SetRowsCount(meta.RowsCount);
m->SetErasedRowsCount(meta.ErasedRowsCount);
m->SetRowCount(meta.RowCount);
m->SetErasedRowCount(meta.ErasedRowCount);
}
}

Expand Down
Loading

0 comments on commit b623877

Please sign in to comment.