aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkungasc <kungasc@yandex-team.com>2023-07-25 17:07:17 +0300
committerroot <root@qavm-2ed34686.qemu>2023-07-25 17:07:17 +0300
commit29e76423c4d4340981732d6bf77ab8dc85fd31ed (patch)
tree261e05b58bbfec436ad2a84e1da8d34ce5ccc7e3
parent238f866d33e00e2c2a359256859e718fe902e9ea (diff)
downloadydb-29e76423c4d4340981732d6bf77ab8dc85fd31ed.tar.gz
Better TBlockWithRecords naming
-rw-r--r--ydb/core/tablet_flat/flat_page_base.h12
-rw-r--r--ydb/core/tablet_flat/flat_page_data.h27
-rw-r--r--ydb/core/tablet_flat/flat_page_index.h19
-rw-r--r--ydb/core/tablet_flat/flat_page_writer.h2
-rw-r--r--ydb/core/tablet_flat/flat_part_dump.cpp2
-rw-r--r--ydb/core/tablet_flat/flat_part_keys.h4
-rw-r--r--ydb/core/tablet_flat/flat_part_writer.h6
-rw-r--r--ydb/core/tablet_flat/ut/ut_comp_shard.cpp4
-rw-r--r--ydb/core/tablet_flat/ut/ut_slice_loader.cpp2
9 files changed, 39 insertions, 39 deletions
diff --git a/ydb/core/tablet_flat/flat_page_base.h b/ydb/core/tablet_flat/flat_page_base.h
index 69d2b8ff7fc..66191064764 100644
--- a/ydb/core/tablet_flat/flat_page_base.h
+++ b/ydb/core/tablet_flat/flat_page_base.h
@@ -166,7 +166,7 @@ struct TDataRef {
} Y_PACKED;
struct TRecordsHeader {
- TRecIdx Records;
+ TRecIdx Count;
} Y_PACKED;
struct TRecordsEntry {
@@ -249,22 +249,22 @@ struct TBlockWithRecords {
const TRecord* Record(TRecIdx idx) const noexcept
{
- return TDeref<TRecord>::At(Base, Array[idx].Offset);
+ return TDeref<TRecord>::At(Base, Offsets[idx].Offset);
}
TIterator Begin() const noexcept
{
- return TIterator(this, 0, Records);
+ return TIterator(this, 0, Count);
}
TIterator End() const noexcept
{
- return TIterator(this, Records, Records);
+ return TIterator(this, Count, Count);
}
const void *Base = nullptr;
- const TRecordsEntry *Array = nullptr;
- ui32 Records = 0;
+ const TRecordsEntry *Offsets = nullptr;
+ ui32 Count = 0;
};
using TCells = TArrayRef<const TCell>;
diff --git a/ydb/core/tablet_flat/flat_page_data.h b/ydb/core/tablet_flat/flat_page_data.h
index cef621b3f2e..89fc1874dd9 100644
--- a/ydb/core/tablet_flat/flat_page_data.h
+++ b/ydb/core/tablet_flat/flat_page_data.h
@@ -201,39 +201,40 @@ namespace NPage {
if (Raw = raw ? *raw : TSharedData{ }) {
const void* base = Raw.data();
- auto got = NPage::TLabelWrapper().Read(Raw, EPage::DataPage);
+ auto data = NPage::TLabelWrapper().Read(Raw, EPage::DataPage);
- Y_VERIFY(got.Version == 1, "Unknown EPage::DataPage version");
+ Y_VERIFY(data.Version == 1, "Unknown EPage::DataPage version");
- if (got.Codec != ECodec::Plain) {
+ if (data.Codec != ECodec::Plain) {
/* Compressed, should convert to regular page */
- Y_VERIFY(got == ECodec::LZ4, "Only LZ4 encoding allowed");
+ Y_VERIFY(data == ECodec::LZ4, "Only LZ4 encoding allowed");
Codec = Codec ? Codec : NBlockCodecs::Codec("lz4fast");
- auto size = Codec->DecompressedLength(got.Page);
+ auto size = Codec->DecompressedLength(data.Page);
// We expect original page had the same label size as a compressed page
- size_t labelSize = reinterpret_cast<const char*>(got.Page.data()) - reinterpret_cast<const char*>(base);
+ size_t labelSize = reinterpret_cast<const char*>(data.Page.data()) - reinterpret_cast<const char*>(base);
Decoded.Resize(labelSize + size);
- size = Codec->Decompress(got.Page, Decoded.Begin() + labelSize);
+ size = Codec->Decompress(data.Page, Decoded.Begin() + labelSize);
Decoded.Resize(labelSize + size);
::memset(Decoded.Begin(), 0, labelSize);
base = Decoded.Begin();
- got.Page = { Decoded.Begin() + labelSize, Decoded.End() };
+ data.Page = { Decoded.Begin() + labelSize, Decoded.End() };
}
- auto *hdr = TDeref<TRecordsHeader>::At(got.Page.data(), 0);
- auto skip = got.Page.size() - hdr->Records * sizeof(TPgSize);
+ auto *recordsHeader = TDeref<TRecordsHeader>::At(data.Page.data(), 0);
+ auto count = recordsHeader->Count;
- BaseRow_ = TDeref<const TExtra>::At(hdr + 1, 0)->BaseRow;
+ BaseRow_ = TDeref<const TExtra>::At(recordsHeader + 1, 0)->BaseRow;
Page.Base = base;
- Page.Array = TDeref<const TRecordsEntry>::At(hdr, skip);
- Page.Records = hdr->Records;
+ auto offsetsOffset = data.Page.size() - count * sizeof(TPgSize);
+ Page.Offsets = TDeref<const TRecordsEntry>::At(recordsHeader, offsetsOffset);
+ Page.Count = count;
}
return *this;
diff --git a/ydb/core/tablet_flat/flat_page_index.h b/ydb/core/tablet_flat/flat_page_index.h
index 49ee1d9aa43..065360a8f4c 100644
--- a/ydb/core/tablet_flat/flat_page_index.h
+++ b/ydb/core/tablet_flat/flat_page_index.h
@@ -64,19 +64,18 @@ namespace NPage {
TIndex(TSharedData raw)
: Raw(std::move(raw))
{
- const auto got = NPage::TLabelWrapper().Read(Raw, EPage::Index);
+ const auto data = NPage::TLabelWrapper().Read(Raw, EPage::Index);
+ Y_VERIFY(data == ECodec::Plain && (data.Version == 2 || data.Version == 3));
- Y_VERIFY(got == ECodec::Plain && (got.Version == 2 || got.Version == 3));
-
- auto *hdr = TDeref<const TRecordsHeader>::At(got.Page.data(), 0);
- auto skip = got.Page.size() - hdr->Records * sizeof(TPgSize);
-
- Y_VERIFY(hdr->Records >= 1u + (got.Version < 3 ? 0u : 1u));
+ auto *recordsHeader = TDeref<const TRecordsHeader>::At(data.Page.data(), 0);
+ auto count = recordsHeader->Count;
+ Y_VERIFY(count >= 1u + (data.Version == 3 ? 1 : 0));
Page.Base = Raw.data();
- Page.Array = TDeref<const TRecordsEntry>::At(hdr, skip);
- Page.Records = hdr->Records - (got.Version == 3 ? 1 : 0);
- LastKey = (got.Version == 3) ? Page.Record(Page.Records) : nullptr;
+ auto offsetsOffset = data.Page.size() - count * sizeof(TPgSize);
+ Page.Offsets = TDeref<const TRecordsEntry>::At(recordsHeader, offsetsOffset);
+ Page.Count = count - (data.Version == 3 ? 1 : 0);
+ LastKey = (data.Version == 3) ? Page.Record(Page.Count) : nullptr;
EndRowId = LastKey ? LastKey->GetRowId() + 1 : Max<TRowId>();
}
diff --git a/ydb/core/tablet_flat/flat_page_writer.h b/ydb/core/tablet_flat/flat_page_writer.h
index 6e9fcea1f10..80f49e28e23 100644
--- a/ydb/core/tablet_flat/flat_page_writer.h
+++ b/ydb/core/tablet_flat/flat_page_writer.h
@@ -93,7 +93,7 @@ namespace NPage {
}
if (auto *hdr = TDeref<TRecordsHeader>::At(ptr, 0)) {
- hdr->Records = Offsets.size();
+ hdr->Count = Offsets.size();
}
{ /* Place on the end reconds offsets */
diff --git a/ydb/core/tablet_flat/flat_part_dump.cpp b/ydb/core/tablet_flat/flat_part_dump.cpp
index 3604dba6991..40b38e66511 100644
--- a/ydb/core/tablet_flat/flat_part_dump.cpp
+++ b/ydb/core/tablet_flat/flat_part_dump.cpp
@@ -150,7 +150,7 @@ namespace {
Out
<< " + Rows{" << page << "} Label{" << page << (ui16)label.Type
<< " rev " << label.Format << ", " << label.Size << "b}"
- << ", [" << data.BaseRow() << ", +" << data->Records << ")row"
+ << ", [" << data.BaseRow() << ", +" << data->Count << ")row"
<< Endl;
} else {
diff --git a/ydb/core/tablet_flat/flat_part_keys.h b/ydb/core/tablet_flat/flat_part_keys.h
index dd68f0c7f28..dde566d0923 100644
--- a/ydb/core/tablet_flat/flat_part_keys.h
+++ b/ydb/core/tablet_flat/flat_part_keys.h
@@ -170,7 +170,7 @@ namespace NTable {
return false;
}
Y_VERIFY(Page.BaseRow() == Index->GetRowId(), "Index and data are out of sync");
- auto lastRowId = Page.BaseRow() + (Page->Records - 1);
+ auto lastRowId = Page.BaseRow() + (Page->Count - 1);
if (lastRowId < rowId) {
// Row is out of range for this page
RowId = Max<TRowId>();
@@ -194,7 +194,7 @@ namespace NTable {
return false;
}
Y_VERIFY(Page.BaseRow() == it->GetRowId(), "Index and data are out of sync");
- auto lastRowId = Page.BaseRow() + (Page->Records - 1);
+ auto lastRowId = Page.BaseRow() + (Page->Count - 1);
LoadRow(lastRowId);
return true;
}
diff --git a/ydb/core/tablet_flat/flat_part_writer.h b/ydb/core/tablet_flat/flat_part_writer.h
index a5dc97c10ec..3c8f3aae6db 100644
--- a/ydb/core/tablet_flat/flat_part_writer.h
+++ b/ydb/core/tablet_flat/flat_part_writer.h
@@ -696,7 +696,7 @@ namespace NTable {
TCellDefaults object for expanding defaults.
*/
- Y_VERIFY(dataPage->Records, "Invalid EPage::DataPage blob");
+ Y_VERIFY(dataPage->Count, "Invalid EPage::DataPage blob");
if (groupId.IsMain()) {
Y_VERIFY_DEBUG(NextSliceFirstRowId != Max<TRowId>());
@@ -729,8 +729,8 @@ namespace NTable {
if (groupId.IsMain() && (NextSliceForce || Phase == 1 || Current.Bytes - LastSliceBytes >= SliceSize)) {
NextSliceForce = false;
- TRowId lastRowId = dataPage.BaseRow() + dataPage->Records - 1;
- InitKey(dataPage->Record(dataPage->Records - 1), groupId);
+ TRowId lastRowId = dataPage.BaseRow() + dataPage->Count - 1;
+ InitKey(dataPage->Record(dataPage->Count - 1), groupId);
SaveSlice(lastRowId, TSerializedCellVec(Key));
diff --git a/ydb/core/tablet_flat/ut/ut_comp_shard.cpp b/ydb/core/tablet_flat/ut/ut_comp_shard.cpp
index 0a4a1432763..19beb167759 100644
--- a/ydb/core/tablet_flat/ut/ut_comp_shard.cpp
+++ b/ydb/core/tablet_flat/ut/ut_comp_shard.cpp
@@ -848,7 +848,7 @@ Y_UNIT_TEST_SUITE(TShardedCompaction) {
{
auto partView = source.ToPartView();
UNIT_ASSERT_VALUES_EQUAL(partView.Slices->size(), 1u);
- UNIT_ASSERT_VALUES_EQUAL(partView->Index->Records, pageCount);
+ UNIT_ASSERT_VALUES_EQUAL(partView->Index->Count, pageCount);
}
TVector<TSerializedCellVec> splitKeyValues;
@@ -862,7 +862,7 @@ Y_UNIT_TEST_SUITE(TShardedCompaction) {
{
auto partView = born.ToPartView();
UNIT_ASSERT_VALUES_EQUAL(partView.Slices->size(), 3u);
- UNIT_ASSERT_VALUES_EQUAL(partView->Index->Records, 6u);
+ UNIT_ASSERT_VALUES_EQUAL(partView->Index->Count, 6u);
UNIT_ASSERT_VALUES_EQUAL(partView->Index->Record(0)->GetRowId(), 0u);
UNIT_ASSERT_VALUES_EQUAL(partView->Index->Record(1)->GetRowId(), 4u);
diff --git a/ydb/core/tablet_flat/ut/ut_slice_loader.cpp b/ydb/core/tablet_flat/ut/ut_slice_loader.cpp
index df307fb627c..3b8e3020fbe 100644
--- a/ydb/core/tablet_flat/ut/ut_slice_loader.cpp
+++ b/ydb/core/tablet_flat/ut/ut_slice_loader.cpp
@@ -189,7 +189,7 @@ Y_UNIT_TEST_SUITE(TPartSliceLoader) {
break;
}
}
- UNIT_ASSERT_C(holes.size() == Part0()->Index->Records,
+ UNIT_ASSERT_C(holes.size() == Part0()->Index->Count,
"Generated screen has " << holes.size() << " intervals");
screen = new TScreen(std::move(holes));
}