diff options
author | Evgeniy Ivanov <eivanov89@yandex-team.ru> | 2022-02-17 23:23:44 +0300 |
---|---|---|
committer | Evgeniy Ivanov <eivanov89@yandex-team.ru> | 2022-02-17 23:23:44 +0300 |
commit | 7d14ee9ad556c0f5673b44ddf5d85bfc530bb0fc (patch) | |
tree | a8d55fdc55a6f2f9fbb4cdb773370a61f1eca5cc | |
parent | 1e12ad07b2ad2362e06100f7f32e772e628bef66 (diff) | |
download | ydb-7d14ee9ad556c0f5673b44ddf5d85bfc530bb0fc.tar.gz |
KIKIMR-5850: rename nulls to key/row/cell defaults
ref:cf6dea4380b60b81a17b81d959edc351738bbf69
32 files changed, 267 insertions, 267 deletions
diff --git a/ydb/core/tablet_flat/flat_comp_shard.cpp b/ydb/core/tablet_flat/flat_comp_shard.cpp index b2356799de..b26139877d 100644 --- a/ydb/core/tablet_flat/flat_comp_shard.cpp +++ b/ydb/core/tablet_flat/flat_comp_shard.cpp @@ -68,7 +68,7 @@ namespace NCompShard { bool TSplitStatIterator::TCmpHeapByFirstKey::operator()(const TItemState* b, const TItemState* a) const noexcept { TCellsRef left = a->Slice.FirstKey.GetCells(); TCellsRef right = b->Slice.FirstKey.GetCells(); - if (int cmp = ComparePartKeys(left, right, Nulls)) { + if (int cmp = ComparePartKeys(left, right, KeyCellDefaults)) { return cmp < 0; } return a->Slice.FirstInclusive && !b->Slice.FirstInclusive; @@ -77,13 +77,13 @@ namespace NCompShard { bool TSplitStatIterator::TCmpHeapByNextKey::operator()(const TItemState* b, const TItemState* a) const noexcept { TCellsRef left = a->NextKey; TCellsRef right = b->NextKey; - return ComparePartKeys(left, right, Nulls) < 0; + return ComparePartKeys(left, right, KeyCellDefaults) < 0; } bool TSplitStatIterator::TCmpHeapByLastKey::operator()(const TItemState* b, const TItemState* a) const noexcept { TCellsRef left = a->Slice.LastKey.GetCells(); TCellsRef right = b->Slice.LastKey.GetCells(); - if (int cmp = ComparePartKeys(left, right, Nulls)) { + if (int cmp = ComparePartKeys(left, right, KeyCellDefaults)) { return cmp < 0; } return !a->Slice.LastInclusive && b->Slice.LastInclusive; @@ -92,13 +92,13 @@ namespace NCompShard { bool TSplitStatIterator::HasStarted(const TItemState* item) const noexcept { TCellsRef left = item->Slice.FirstKey.GetCells(); TCellsRef right = Key; - return ComparePartKeys(left, right, Nulls) < 0; + return ComparePartKeys(left, right, KeyCellDefaults) < 0; } bool TSplitStatIterator::HasStopped(const TItemState* item) const noexcept { TCellsRef left = item->Slice.LastKey.GetCells(); TCellsRef right = Key; - if (int cmp = ComparePartKeys(left, right, Nulls)) { + if (int cmp = ComparePartKeys(left, right, KeyCellDefaults)) { return cmp < 0; } return !item->Slice.LastInclusive; @@ -136,7 +136,7 @@ namespace NCompShard { if (InitQueue && NextQueue) { TCellsRef left = InitQueue.top()->Slice.FirstKey.GetCells(); TCellsRef right = NextQueue.top()->NextKey; - if (ComparePartKeys(left, right, Nulls) <= 0) { + if (ComparePartKeys(left, right, KeyCellDefaults) <= 0) { selected = left; } else { selected = right; @@ -152,7 +152,7 @@ namespace NCompShard { TCellsRef splitKey = Key; // Take all matching items from init queue and initialize them - while (InitQueue && ComparePartKeys(InitQueue.top()->Slice.FirstKey.GetCells(), splitKey, Nulls) <= 0) { + while (InitQueue && ComparePartKeys(InitQueue.top()->Slice.FirstKey.GetCells(), splitKey, KeyCellDefaults) <= 0) { auto* item = InitQueue.top(); InitQueue.pop(); StartQueue.push(item); @@ -183,7 +183,7 @@ namespace NCompShard { if (item->LastPageRows <= 1) { item->IsPartial = false; } else if (item->NextPage) { - item->IsPartial = ComparePartKeys(splitKey, item->NextKey, Nulls) < 0; + item->IsPartial = ComparePartKeys(splitKey, item->NextKey, KeyCellDefaults) < 0; } else if (HasStopped(item)) { item->IsPartial = false; } else { @@ -200,7 +200,7 @@ namespace NCompShard { ActivationQueue.clear(); // Take all slices that have next key matching the new boundary - while (NextQueue && ComparePartKeys(NextQueue.top()->NextKey, splitKey, Nulls) <= 0) { + while (NextQueue && ComparePartKeys(NextQueue.top()->NextKey, splitKey, KeyCellDefaults) <= 0) { auto* item = NextQueue.top(); NextQueue.pop(); @@ -271,7 +271,7 @@ namespace NCompShard { auto heapByFirstKeyMin = [this](const TItemState* b, const TItemState* a) noexcept -> bool { TCellsRef left = a->First.Key; TCellsRef right = b->First.Key; - if (int cmp = ComparePartKeys(left, right, Nulls)) { + if (int cmp = ComparePartKeys(left, right, KeyCellDefaults)) { return cmp < 0; } return a->First.Inclusive && !b->First.Inclusive; @@ -280,7 +280,7 @@ namespace NCompShard { auto noIntersection = [this](const TRightBoundary& a, const TLeftBoundary& b) noexcept -> bool { TCellsRef left = a.Key; TCellsRef right = b.Key; - if (int cmp = ComparePartKeys(left, right, Nulls)) { + if (int cmp = ComparePartKeys(left, right, KeyCellDefaults)) { return cmp < 0; } return !a.Inclusive || !b.Inclusive; @@ -289,7 +289,7 @@ namespace NCompShard { auto lessBoundary = [this](const TRightBoundary& a, const TRightBoundary& b) noexcept -> bool { TCellsRef left = a.Key; TCellsRef right = b.Key; - if (int cmp = ComparePartKeys(left, right, Nulls)) { + if (int cmp = ComparePartKeys(left, right, KeyCellDefaults)) { return cmp < 0; } return !a.Inclusive && b.Inclusive; @@ -455,8 +455,8 @@ namespace NCompShard { } } - bool TTableShard::FindSplitKey(TSerializedCellVec& foundKey, const TKeyCellDefaults& nulls) const noexcept { - TSplitStatIterator it(nulls); + bool TTableShard::FindSplitKey(TSerializedCellVec& foundKey, const TKeyCellDefaults& keyDefaults) const noexcept { + TSplitStatIterator it(keyDefaults); for (const auto& kvInfo : Parts) { for (const auto& kvSlice : kvInfo.second.Slices) { @@ -507,24 +507,24 @@ namespace NCompShard { } bool TSliceSplitOp::Execute(IPages* env) { - const TIntrusiveConstPtr<TKeyCellDefaults> nulls = Table->RowScheme->Keys; + const TIntrusiveConstPtr<TKeyCellDefaults> keyDefaults = Table->RowScheme->Keys; - TVector<TCell> keyCellsBuffer(nulls->Size()); - auto getKeyCells = [this, &nulls, &keyCellsBuffer](ui64 keyId) { + TVector<TCell> keyCellsBuffer(keyDefaults->Size()); + auto getKeyCells = [this, &keyDefaults, &keyCellsBuffer](ui64 keyId) { auto* key = Table->SplitKeys.FindPtr(keyId); Y_VERIFY(key, "Cannot find split key %" PRIu64, keyId); auto keyCells = key->GetCells(); - if (keyCells.size() < nulls->Size()) { + if (keyCells.size() < keyDefaults->Size()) { for (size_t i = 0; i < keyCells.size(); ++i) { keyCellsBuffer[i] = keyCells[i]; } - for (size_t i = keyCells.size(); i < nulls->Size(); ++i) { - keyCellsBuffer[i] = nulls->Defs[i]; + for (size_t i = keyCells.size(); i < keyDefaults->Size(); ++i) { + keyCellsBuffer[i] = keyDefaults->Defs[i]; } keyCells = keyCellsBuffer; } - Y_VERIFY_DEBUG(keyCells.size() == nulls->Size()); + Y_VERIFY_DEBUG(keyCells.size() == keyDefaults->Size()); return keyCells; }; @@ -533,7 +533,7 @@ namespace NCompShard { TCharge charge(env, *Part, TTagsRef{ }); for (size_t idx = 1; idx < Shards.size(); ++idx) { auto keyCells = getKeyCells(Shards[idx]->LeftKey); - ok &= charge.SplitKey(keyCells, *nulls, Slice.BeginRowId(), Slice.EndRowId()); + ok &= charge.SplitKey(keyCells, *keyDefaults, Slice.BeginRowId(), Slice.EndRowId()); } if (!ok) { @@ -543,7 +543,7 @@ namespace NCompShard { TSlice current = Slice; TVector<TSlice> results(Reserve(Shards.size())); - TPartSimpleIt it(Part.Get(), { }, nulls, env); + TPartSimpleIt it(Part.Get(), { }, keyDefaults, env); for (size_t idx = 1; idx < Shards.size(); ++idx) { const TRowId currentBegin = current.BeginRowId(); const TRowId currentEnd = current.EndRowId(); @@ -566,7 +566,7 @@ namespace NCompShard { TSerializedCellVec rowKey; if (rowId != currentEnd) { rowKey = TSerializedCellVec(TSerializedCellVec::Serialize(it.GetRawKey())); - } else if (Y_UNLIKELY(ComparePartKeys(current.LastKey.GetCells(), keyCells, *nulls) < 0)) { + } else if (Y_UNLIKELY(ComparePartKeys(current.LastKey.GetCells(), keyCells, *keyDefaults) < 0)) { // This shouldn't normally happen, but better safe than sorry // Current split key is actually out of bounds for the slice // Since there's no real intersection leave it as is @@ -691,33 +691,33 @@ namespace NCompShard { TIntrusiveConstPtr<TRowScheme> rowScheme, TVector<const TBounds*>& input) noexcept { - const TKeyCellDefaults& nulls = *rowScheme->Keys; + const TKeyCellDefaults& keyDefaults = *rowScheme->Keys; // Sorts heap by the first key (returns true when a->FirstKey < b->FirstKey) - auto heapByFirstKeyMin = [&nulls](const TBounds* b, const TBounds* a) noexcept -> bool { + auto heapByFirstKeyMin = [&keyDefaults](const TBounds* b, const TBounds* a) noexcept -> bool { TCellsRef left = a->FirstKey.GetCells(); TCellsRef right = b->FirstKey.GetCells(); - if (int cmp = ComparePartKeys(left, right, nulls)) { + if (int cmp = ComparePartKeys(left, right, keyDefaults)) { return cmp < 0; } return a->FirstInclusive && !b->FirstInclusive; }; // Returns true when a->LastKey < b->LastKey - auto lastKeyLess = [&nulls](const TBounds* a, const TBounds* b) noexcept -> bool { + auto lastKeyLess = [&keyDefaults](const TBounds* a, const TBounds* b) noexcept -> bool { TCellsRef left = a->LastKey.GetCells(); TCellsRef right = b->LastKey.GetCells(); - if (int cmp = ComparePartKeys(left, right, nulls)) { + if (int cmp = ComparePartKeys(left, right, keyDefaults)) { return cmp < 0; } return !a->LastInclusive && b->LastInclusive; }; // Returns true when a->LastKey may be stitched with b->FirstKey - auto mayStitch = [&nulls](const TBounds* a, const TBounds* b) noexcept -> bool { + auto mayStitch = [&keyDefaults](const TBounds* a, const TBounds* b) noexcept -> bool { TCellsRef left = a->LastKey.GetCells(); TCellsRef right = b->FirstKey.GetCells(); - int cmp = ComparePartKeys(left, right, nulls); + int cmp = ComparePartKeys(left, right, keyDefaults); if (cmp < 0) { return false; } @@ -882,11 +882,11 @@ namespace NCompShard { } } - const auto& nulls = *TableInfo.RowScheme->Keys; + const auto& keyDefaults = *TableInfo.RowScheme->Keys; std::sort(splitKeyIds.begin(), splitKeyIds.end(), [&](ui64 a, ui64 b) -> bool { auto left = TableInfo.SplitKeys.at(a).GetCells(); auto right = TableInfo.SplitKeys.at(b).GetCells(); - return ComparePartKeys(left, right, nulls) < 0; + return ComparePartKeys(left, right, keyDefaults) < 0; }); Shards.PushBack(new TTableShard()); @@ -1753,7 +1753,7 @@ namespace NCompShard { void TShardedCompactionStrategy::AddParts(TVector<TPartView> parts) { // Types and default values for current table keys - const auto& nulls = *TableInfo.RowScheme->Keys; + const auto& keyDefaults = *TableInfo.RowScheme->Keys; // A part/slice combination we scheduled to add struct TItem { @@ -1767,34 +1767,34 @@ namespace NCompShard { }; // Sorts items by their first key - auto cmpByFirstKey = [&nulls](const TItem& a, const TItem& b) noexcept -> bool { + auto cmpByFirstKey = [&keyDefaults](const TItem& a, const TItem& b) noexcept -> bool { auto left = a.Slice.FirstKey.GetCells(); auto right = b.Slice.FirstKey.GetCells(); - if (int cmp = ComparePartKeys(left, right, nulls)) { + if (int cmp = ComparePartKeys(left, right, keyDefaults)) { return cmp < 0; } return a.Slice.FirstInclusive && !b.Slice.FirstInclusive; }; // Returns true if the item is completely to the left of boundary - auto cmpFullyInside = [&nulls](const TItem& a, const TSerializedCellVec& boundary) noexcept -> bool { + auto cmpFullyInside = [&keyDefaults](const TItem& a, const TSerializedCellVec& boundary) noexcept -> bool { auto left = a.Slice.LastKey.GetCells(); if (Y_UNLIKELY(!left)) { return false; // +inf } - if (int cmp = ComparePartKeys(left, boundary.GetCells(), nulls)) { + if (int cmp = ComparePartKeys(left, boundary.GetCells(), keyDefaults)) { return cmp < 0; } return !a.Slice.LastInclusive; }; // Returns true if the item is completely to the right of boundary - auto cmpFullyOutside = [&nulls](const TItem& a, const TSerializedCellVec& boundary) noexcept -> bool { + auto cmpFullyOutside = [&keyDefaults](const TItem& a, const TSerializedCellVec& boundary) noexcept -> bool { auto right = a.Slice.FirstKey.GetCells(); if (Y_UNLIKELY(!right)) { return false; // -inf } - return ComparePartKeys(boundary.GetCells(), right, nulls) <= 0; + return ComparePartKeys(boundary.GetCells(), right, keyDefaults) <= 0; }; // A part/slice combination that crosses at least one shard boundary @@ -1812,22 +1812,22 @@ namespace NCompShard { }; // Heap order of split items by their last key - auto cmpHeapByLastKey = [&nulls](const TSplitItem& a, const TSplitItem& b) noexcept -> bool { + auto cmpHeapByLastKey = [&keyDefaults](const TSplitItem& a, const TSplitItem& b) noexcept -> bool { auto left = b.Slice.LastKey.GetCells(); auto right = a.Slice.LastKey.GetCells(); - if (int cmp = ComparePartKeys(left, right, nulls)) { + if (int cmp = ComparePartKeys(left, right, keyDefaults)) { return cmp < 0; } return !b.Slice.LastInclusive && a.Slice.LastInclusive; }; // Returns true if item is completely to the left of boundary - auto cmpSplitFullyInside = [&nulls](const TSplitItem& a, const TSerializedCellVec& boundary) noexcept -> bool { + auto cmpSplitFullyInside = [&keyDefaults](const TSplitItem& a, const TSerializedCellVec& boundary) noexcept -> bool { auto left = a.Slice.LastKey.GetCells(); if (Y_UNLIKELY(!left)) { return false; // +inf } - if (int cmp = ComparePartKeys(left, boundary.GetCells(), nulls)) { + if (int cmp = ComparePartKeys(left, boundary.GetCells(), keyDefaults)) { return cmp < 0; } return !a.Slice.LastInclusive; diff --git a/ydb/core/tablet_flat/flat_comp_shard.h b/ydb/core/tablet_flat/flat_comp_shard.h index 68393ee9f6..115e9ce859 100644 --- a/ydb/core/tablet_flat/flat_comp_shard.h +++ b/ydb/core/tablet_flat/flat_comp_shard.h @@ -100,12 +100,12 @@ namespace NCompShard { */ class TSplitStatIterator { public: - TSplitStatIterator(const TKeyCellDefaults& nulls) - : Nulls(nulls) - , InitQueue(TCmpHeapByFirstKey{Nulls}) - , NextQueue(TCmpHeapByNextKey{Nulls}) - , StartQueue(TCmpHeapByFirstKey{Nulls}) - , StopQueue(TCmpHeapByLastKey{Nulls}) + TSplitStatIterator(const TKeyCellDefaults& keyDefaults) + : KeyCellDefaults(keyDefaults) + , InitQueue(TCmpHeapByFirstKey{KeyCellDefaults}) + , NextQueue(TCmpHeapByNextKey{KeyCellDefaults}) + , StartQueue(TCmpHeapByFirstKey{KeyCellDefaults}) + , StopQueue(TCmpHeapByLastKey{KeyCellDefaults}) { } void AddSlice(const TPart* part, const TSlice& slice, ui64 size) noexcept; @@ -148,19 +148,19 @@ namespace NCompShard { }; struct TCmpHeapByFirstKey { - const TKeyCellDefaults& Nulls; + const TKeyCellDefaults& KeyCellDefaults; bool operator()(const TItemState* b, const TItemState* a) const noexcept; }; struct TCmpHeapByNextKey { - const TKeyCellDefaults& Nulls; + const TKeyCellDefaults& KeyCellDefaults; bool operator()(const TItemState* b, const TItemState* a) const noexcept; }; struct TCmpHeapByLastKey { - const TKeyCellDefaults& Nulls; + const TKeyCellDefaults& KeyCellDefaults; bool operator()(const TItemState* b, const TItemState* a) const noexcept; }; @@ -176,7 +176,7 @@ namespace NCompShard { void InitPageSize(TItemState* item) const noexcept; private: - const TKeyCellDefaults& Nulls; + const TKeyCellDefaults& KeyCellDefaults; TVector<TCell> Key; TDeque<TItemState> Items; TItemQueue<TCmpHeapByFirstKey> InitQueue; @@ -195,8 +195,8 @@ namespace NCompShard { */ class TPageReuseBuilder { public: - TPageReuseBuilder(const TKeyCellDefaults& nulls) - : Nulls(nulls) + TPageReuseBuilder(const TKeyCellDefaults& keyDefaults) + : KeyCellDefaults(keyDefaults) { } void AddSlice(const TPart* part, const TSlice& slice, bool reusable) noexcept; @@ -257,7 +257,7 @@ namespace NCompShard { }; private: - const TKeyCellDefaults& Nulls; + const TKeyCellDefaults& KeyCellDefaults; TDeque<TItemState> Items; }; @@ -381,7 +381,7 @@ namespace NCompShard { void RegisterItem(const TTablePart& info, TTablePart::TItem& item, bool isGarbage) noexcept; - bool FindSplitKey(TSerializedCellVec& foundKey, const TKeyCellDefaults& nulls) const noexcept; + bool FindSplitKey(TSerializedCellVec& foundKey, const TKeyCellDefaults& keyDefaults) const noexcept; }; /** diff --git a/ydb/core/tablet_flat/flat_iterator.h b/ydb/core/tablet_flat/flat_iterator.h index 60195c17b4..edc4bc2ede 100644 --- a/ydb/core/tablet_flat/flat_iterator.h +++ b/ydb/core/tablet_flat/flat_iterator.h @@ -856,7 +856,7 @@ inline EReady TTableItBase<TIteratorOps>::DoSkipUncommitted() noexcept template<class TIteratorOps> inline EReady TTableItBase<TIteratorOps>::Apply() noexcept { - State.Reset(Remap.Nulls()); + State.Reset(Remap.CellDefaults()); const TDbTupleRef key = GetKey(); diff --git a/ydb/core/tablet_flat/flat_mem_iter.h b/ydb/core/tablet_flat/flat_mem_iter.h index 063d52d78d..55223cabe2 100644 --- a/ydb/core/tablet_flat/flat_mem_iter.h +++ b/ydb/core/tablet_flat/flat_mem_iter.h @@ -20,17 +20,17 @@ namespace NTable { using TCells = TArrayRef<const TCell>; TMemIt(const TMemTable* memTable, - TIntrusiveConstPtr<TKeyCellDefaults> nulls, + TIntrusiveConstPtr<TKeyCellDefaults> keyDefaults, const TRemap* remap, IPages *env, NMem::TTreeIterator iterator) : MemTable(memTable) - , Nulls(std::move(nulls)) + , KeyCellDefaults(std::move(keyDefaults)) , Remap(remap) , Env(env) , RowIt(std::move(iterator)) { - Key.reserve(Nulls->Size()); + Key.reserve(KeyCellDefaults->Size()); Y_VERIFY(Key.capacity() > 0, "No key cells in part scheme"); Y_VERIFY(Remap, "Remap cannot be NULL"); @@ -41,12 +41,12 @@ namespace NTable { const NMem::TTreeSnapshot& snapshot, TCells key, ESeek seek, - TIntrusiveConstPtr<TKeyCellDefaults> nulls, + TIntrusiveConstPtr<TKeyCellDefaults> keyDefaults, const TRemap *remap, IPages *env, EDirection direction = EDirection::Forward) noexcept { - auto *iter = new TMemIt(&memTable, std::move(nulls), remap, env, snapshot.Iterator()); + auto *iter = new TMemIt(&memTable, std::move(keyDefaults), remap, env, snapshot.Iterator()); switch (direction) { case EDirection::Forward: @@ -66,7 +66,7 @@ namespace NTable { CurrentVersion = nullptr; if (key) { - NMem::TPoint search{ key, *Nulls }; + NMem::TPoint search{ key, *KeyCellDefaults }; switch (seek) { case ESeek::Lower: @@ -98,7 +98,7 @@ namespace NTable { CurrentVersion = nullptr; if (key) { - NMem::TPoint search{ key, *Nulls }; + NMem::TPoint search{ key, *KeyCellDefaults }; switch (seek) { case ESeek::Exact: @@ -131,14 +131,14 @@ namespace NTable { const ui32 len = MemTable->Scheme->Keys->Size(); const auto *key = RowIt.GetKey(); - if (len >= Nulls->BasicTypes().size()) { - return { Nulls->BasicTypes().begin(), key, len }; + if (len >= KeyCellDefaults->BasicTypes().size()) { + return { KeyCellDefaults->BasicTypes().begin(), key, len }; } else if (!Key) { Key.insert(Key.end(), key, key + len); - Key.insert(Key.end(), (**Nulls).begin() + len, (**Nulls).end()); + Key.insert(Key.end(), (**KeyCellDefaults).begin() + len, (**KeyCellDefaults).end()); } - return { Nulls->BasicTypes().begin(), Key.begin(), ui32(Key.size()) }; + return { KeyCellDefaults->BasicTypes().begin(), Key.begin(), ui32(Key.size()) }; } bool IsDelta() const noexcept @@ -349,7 +349,7 @@ namespace NTable { public: const TMemTable *MemTable = nullptr; - const TIntrusiveConstPtr<TKeyCellDefaults> Nulls; + const TIntrusiveConstPtr<TKeyCellDefaults> KeyCellDefaults; const TRemap* Remap = nullptr; IPages * const Env = nullptr; ui64 InvisibleRowSkips = 0; diff --git a/ydb/core/tablet_flat/flat_mem_warm.h b/ydb/core/tablet_flat/flat_mem_warm.h index efcd425c12..851700f980 100644 --- a/ydb/core/tablet_flat/flat_mem_warm.h +++ b/ydb/core/tablet_flat/flat_mem_warm.h @@ -25,7 +25,7 @@ namespace NMem { struct TPoint { TArrayRef<const TCell> Key; - const TKeyCellDefaults &Nulls; + const TKeyCellDefaults &KeyCellDefaults; }; struct TCandidate { @@ -56,17 +56,17 @@ namespace NMem { } int DoCompare(const TCell* a, const TPoint& b) const { - const size_t bSize = Min(b.Key.size(), b.Nulls->size()); + const size_t bSize = Min(b.Key.size(), b.KeyCellDefaults->size()); for (size_t i = 0; i < bSize; ++i) { - const TCell& left = i < Count ? a[i] : b.Nulls[i]; + const TCell& left = i < Count ? a[i] : b.KeyCellDefaults[i]; - if (int cmp = CompareTypedCells(left, b.Key[i], b.Nulls.Types[i])) + if (int cmp = CompareTypedCells(left, b.Key[i], b.KeyCellDefaults.Types[i])) return cmp; } // Missing point cells are filled with a virtual +inf - return b.Key.size() < b.Nulls->size() ? -1 : 0; + return b.Key.size() < b.KeyCellDefaults->size() ? -1 : 0; } bool operator()(const TTreeKey& a, const TPoint& b) const { diff --git a/ydb/core/tablet_flat/flat_ops_compact.h b/ydb/core/tablet_flat/flat_ops_compact.h index 9e2acd4fc0..c71b7fe479 100644 --- a/ydb/core/tablet_flat/flat_ops_compact.h +++ b/ydb/core/tablet_flat/flat_ops_compact.h @@ -172,7 +172,7 @@ namespace NTabletFlatExecutor { if (row.GetRowState() == NTable::ERowOp::Erase) { logl << "erased"; } else { - logl << NFmt::TCells(*row, *Scheme->Nulls, Registry); + logl << NFmt::TCells(*row, *Scheme->RowCellDefaults, Registry); } logl << " txId " << txId << " }"; @@ -226,7 +226,7 @@ namespace NTabletFlatExecutor { if (row.GetRowState() == NTable::ERowOp::Erase) { logl << "erased"; } else { - logl << NFmt::TCells(*row, *Scheme->Nulls, Registry); + logl << NFmt::TCells(*row, *Scheme->RowCellDefaults, Registry); } logl << " at " << rowVersion << " }"; diff --git a/ydb/core/tablet_flat/flat_page_base.h b/ydb/core/tablet_flat/flat_page_base.h index ca4ae27e32..48671596d4 100644 --- a/ydb/core/tablet_flat/flat_page_base.h +++ b/ydb/core/tablet_flat/flat_page_base.h @@ -269,11 +269,11 @@ template <typename TRecord> struct TCompare { using TColumns = TArrayRef<const TPartScheme::TColumn>; - TCompare(TColumns keys, const TKeyCellDefaults &nulls) + TCompare(TColumns keys, const TKeyCellDefaults &keyDefaults) : Info(keys) - , Nulls(nulls) + , KeyCellDefaults(keyDefaults) { - Y_VERIFY(Nulls->size() >= Info.size()); + Y_VERIFY(KeyCellDefaults->size() >= Info.size()); } bool operator()(const TRecord &record, TCells key) const noexcept @@ -288,19 +288,19 @@ struct TCompare { int Compare(const TRecord &rec, const TCells key) const noexcept { - for (TPos it = 0; it < Min(key.size(), Nulls->size()); it++) { - const TCell left = it < Info.size() ? rec.Cell(Info[it]) : Nulls[it]; + for (TPos it = 0; it < Min(key.size(), KeyCellDefaults->size()); it++) { + const TCell left = it < Info.size() ? rec.Cell(Info[it]) : KeyCellDefaults[it]; - if (int cmp = CompareTypedCells(left, key[it], Nulls.Types[it])) + if (int cmp = CompareTypedCells(left, key[it], KeyCellDefaults.Types[it])) return cmp; } - return key.size() < Nulls->size() ? -1 : 0; + return key.size() < KeyCellDefaults->size() ? -1 : 0; } private: const TColumns Info; - const TKeyCellDefaults &Nulls; + const TKeyCellDefaults &KeyCellDefaults; }; diff --git a/ydb/core/tablet_flat/flat_page_data.h b/ydb/core/tablet_flat/flat_page_data.h index 07422d27d7..6e62fc2101 100644 --- a/ydb/core/tablet_flat/flat_page_data.h +++ b/ydb/core/tablet_flat/flat_page_data.h @@ -229,7 +229,7 @@ namespace NPage { } TIter LookupKey(TCells key, const TPartScheme::TGroupInfo &group, - ESeek seek, const TKeyCellDefaults *nulls) const noexcept + ESeek seek, const TKeyCellDefaults *keyDefaults) const noexcept { if (!key) { switch (seek) { @@ -243,7 +243,7 @@ namespace NPage { TIter it; - const auto cmp = TCompare<TRecord>(group.ColsKeyData, *nulls); + const auto cmp = TCompare<TRecord>(group.ColsKeyData, *keyDefaults); switch (seek) { case ESeek::Exact: it = std::lower_bound(Page.Begin(), Page.End(), key, cmp); @@ -266,7 +266,7 @@ namespace NPage { } TIter LookupKeyReverse(TCells key, const TPartScheme::TGroupInfo &group, - ESeek seek, const TKeyCellDefaults *nulls) const noexcept + ESeek seek, const TKeyCellDefaults *keyDefaults) const noexcept { if (!key) { switch (seek) { @@ -280,7 +280,7 @@ namespace NPage { TIter it; - const auto cmp = TCompare<TRecord>(group.ColsKeyData, *nulls); + const auto cmp = TCompare<TRecord>(group.ColsKeyData, *keyDefaults); switch (seek) { case ESeek::Exact: it = std::lower_bound(Page.Begin(), Page.End(), key, cmp); diff --git a/ydb/core/tablet_flat/flat_page_index.h b/ydb/core/tablet_flat/flat_page_index.h index e936891d0c..712ebf06de 100644 --- a/ydb/core/tablet_flat/flat_page_index.h +++ b/ydb/core/tablet_flat/flat_page_index.h @@ -175,7 +175,7 @@ namespace NPage { */ TIter LookupKey( TCells key, const TPartScheme::TGroupInfo &group, - const ESeek seek, const TKeyCellDefaults *nulls) const noexcept + const ESeek seek, const TKeyCellDefaults *keyDefaults) const noexcept { if (!key) { // Special treatment for an empty key @@ -188,7 +188,7 @@ namespace NPage { } } - const auto cmp = TCompare<TRecord>(group.ColsKeyIdx, *nulls); + const auto cmp = TCompare<TRecord>(group.ColsKeyIdx, *keyDefaults); // N.B. we know that key < it->Key TIter it = std::upper_bound(Page.Begin(), Page.End(), key, cmp); @@ -219,7 +219,7 @@ namespace NPage { */ TIter LookupKeyReverse( TCells key, const TPartScheme::TGroupInfo &group, - const ESeek seek, const TKeyCellDefaults *nulls) const noexcept + const ESeek seek, const TKeyCellDefaults *keyDefaults) const noexcept { if (!key) { // Special treatment for an empty key @@ -232,7 +232,7 @@ namespace NPage { } } - const auto cmp = TCompare<TRecord>(group.ColsKeyIdx, *nulls); + const auto cmp = TCompare<TRecord>(group.ColsKeyIdx, *keyDefaults); TIter it; switch (seek) { diff --git a/ydb/core/tablet_flat/flat_part_charge.h b/ydb/core/tablet_flat/flat_part_charge.h index 989d551b19..edd07ed097 100644 --- a/ydb/core/tablet_flat/flat_part_charge.h +++ b/ydb/core/tablet_flat/flat_part_charge.h @@ -46,14 +46,14 @@ namespace NTable { } static bool Range(IPages *env, const TCells key1, const TCells key2, - const TRun &run, const TKeyCellDefaults &nulls, TTagsRef tags, + const TRun &run, const TKeyCellDefaults &keyDefaults, TTagsRef tags, ui64 items, ui64 bytes, bool includeHistory = false) noexcept { if (run.size() == 1) { auto pos = run.begin(); TRowId row1 = pos->Slice.BeginRowId(); TRowId row2 = pos->Slice.EndRowId() - 1; - return TCharge(env, *pos->Part, tags, includeHistory).Do(key1, key2, row1, row2, nulls, items, bytes).Ready; + return TCharge(env, *pos->Part, tags, includeHistory).Do(key1, key2, row1, row2, keyDefaults, items, bytes).Ready; } bool ready = true; @@ -62,13 +62,13 @@ namespace NTable { if (pos == run.end()) return true; - bool fromStart = TSlice::CompareSearchKeyFirstKey(key1, pos->Slice, nulls) <= 0; + bool fromStart = TSlice::CompareSearchKeyFirstKey(key1, pos->Slice, keyDefaults) <= 0; while (pos != run.end()) { TRowId row1 = pos->Slice.BeginRowId(); TRowId row2 = pos->Slice.EndRowId() - 1; - const int cmp = TSlice::CompareLastKeySearchKey(pos->Slice, key2, nulls); + const int cmp = TSlice::CompareLastKeySearchKey(pos->Slice, key2, keyDefaults); TArrayRef<const TCell> key1r; if (!fromStart) { @@ -79,7 +79,7 @@ namespace NTable { key2r = key2; } - auto r = TCharge(env, *pos->Part, tags, includeHistory).Do(key1r, key2r, row1, row2, nulls, items, bytes); + auto r = TCharge(env, *pos->Part, tags, includeHistory).Do(key1r, key2r, row1, row2, keyDefaults, items, bytes); ready &= r.Ready; if (cmp >= 0 /* slice->LastKey >= key2 */) { @@ -102,14 +102,14 @@ namespace NTable { } static bool RangeReverse(IPages *env, const TCells key1, const TCells key2, - const TRun &run, const TKeyCellDefaults &nulls, TTagsRef tags, + const TRun &run, const TKeyCellDefaults &keyDefaults, TTagsRef tags, ui64 items, ui64 bytes, bool includeHistory = false) noexcept { if (run.size() == 1) { auto pos = run.begin(); TRowId row1 = pos->Slice.EndRowId() - 1; TRowId row2 = pos->Slice.BeginRowId(); - return TCharge(env, *pos->Part, tags, includeHistory).DoReverse(key1, key2, row1, row2, nulls, items, bytes).Ready; + return TCharge(env, *pos->Part, tags, includeHistory).DoReverse(key1, key2, row1, row2, keyDefaults, items, bytes).Ready; } bool ready = true; @@ -118,14 +118,14 @@ namespace NTable { if (pos == run.end()) return true; - bool fromEnd = TSlice::CompareLastKeySearchKey(pos->Slice, key1, nulls) <= 0; + bool fromEnd = TSlice::CompareLastKeySearchKey(pos->Slice, key1, keyDefaults) <= 0; for (;;) { TRowId row1 = pos->Slice.EndRowId() - 1; TRowId row2 = pos->Slice.BeginRowId(); // N.B. empty key2 is like -inf during reverse iteration - const int cmp = key2 ? TSlice::CompareSearchKeyFirstKey(key2, pos->Slice, nulls) : -1; + const int cmp = key2 ? TSlice::CompareSearchKeyFirstKey(key2, pos->Slice, keyDefaults) : -1; TArrayRef<const TCell> key1r; if (!fromEnd) { @@ -136,7 +136,7 @@ namespace NTable { key2r = key2; } - auto r = TCharge(env, *pos->Part, tags, includeHistory).DoReverse(key1r, key2r, row1, row2, nulls, items, bytes); + auto r = TCharge(env, *pos->Part, tags, includeHistory).DoReverse(key1r, key2r, row1, row2, keyDefaults, items, bytes); ready &= r.Ready; if (pos == run.begin()) { @@ -170,7 +170,7 @@ namespace NTable { * last key < splitKey are precharged. This method will not try to * load pages outside of [beginRowId, endRowId) range. */ - bool SplitKey(const TCells splitKey, const TKeyCellDefaults& nulls, + bool SplitKey(const TCells splitKey, const TKeyCellDefaults& keyDefaults, const TRowId beginRowId, const TRowId endRowId) const noexcept { Y_VERIFY_DEBUG(beginRowId < endRowId, "Unexpected empty row range"); @@ -178,10 +178,10 @@ namespace NTable { bool ready = true; - const auto cmp = NPage::TCompare<NPage::TIndex::TRecord>(Scheme.Groups[0].ColsKeyIdx, nulls); + const auto cmp = NPage::TCompare<NPage::TIndex::TRecord>(Scheme.Groups[0].ColsKeyIdx, keyDefaults); // The first page that may contain splitKey - auto found = Index.LookupKey(splitKey, Scheme.Groups[0], ESeek::Lower, &nulls); + auto found = Index.LookupKey(splitKey, Scheme.Groups[0], ESeek::Lower, &keyDefaults); // Do we need to load the previous page (e.g. splitKey <= foundKey) bool needPrev = !found || !cmp(*found, splitKey); @@ -285,7 +285,7 @@ namespace NTable { * Precharges data for rows between max(key1, row1) and min(key2, row2) inclusive */ TResult Do(const TCells key1, const TCells key2, const TRowId row1, - const TRowId row2, const TKeyCellDefaults &nulls, ui64 itemsLimit, + const TRowId row2, const TKeyCellDefaults &keyDefaults, ui64 itemsLimit, ui64 bytesLimit) const noexcept { auto startRow = row1; @@ -311,7 +311,7 @@ namespace NTable { if (key1) { // First page to precharge (may contain key >= key1) - auto keyPage = Index.LookupKey(key1, Scheme.Groups[0], ESeek::Lower, &nulls); + auto keyPage = Index.LookupKey(key1, Scheme.Groups[0], ESeek::Lower, &keyDefaults); if (!keyPage || keyPage > last) { return { true, true }; // first key is outside of bounds } @@ -330,7 +330,7 @@ namespace NTable { if (key2) { // Last page to precharge (may contain key >= key2) // We actually use the next page since lookup is not exact - auto keyPage = Index.LookupKey(key2, Scheme.Groups[0], ESeek::Lower, &nulls) + 1; + auto keyPage = Index.LookupKey(key2, Scheme.Groups[0], ESeek::Lower, &keyDefaults) + 1; if (keyPage && keyPage <= last) { if (keyPage >= firstExt) { last = keyPage; // precharge up to keyPage @@ -352,7 +352,7 @@ namespace NTable { * Precharges data for rows between min(key1, row1) and max(key2, row2) inclusive in reverse */ TResult DoReverse(const TCells key1, const TCells key2, const TRowId row1, - const TRowId row2, const TKeyCellDefaults &nulls, ui64 itemsLimit, + const TRowId row2, const TKeyCellDefaults &keyDefaults, ui64 itemsLimit, ui64 bytesLimit) const noexcept { auto startRow = row1; @@ -380,7 +380,7 @@ namespace NTable { if (key1) { // First page to precharge (may contain key <= key1) - auto keyPage = Index.LookupKeyReverse(key1, Scheme.Groups[0], ESeek::Lower, &nulls); + auto keyPage = Index.LookupKeyReverse(key1, Scheme.Groups[0], ESeek::Lower, &keyDefaults); if (!keyPage || keyPage < last) { return { true, true }; // first key is outside of bounds } @@ -393,7 +393,7 @@ namespace NTable { if (key2) { // Last page to precharge (may contain key <= key2) - auto keyPage = Index.LookupKeyReverse(key2, Scheme.Groups[0], ESeek::Lower, &nulls); + auto keyPage = Index.LookupKeyReverse(key2, Scheme.Groups[0], ESeek::Lower, &keyDefaults); if (keyPage && keyPage >= last) { if (keyPage <= first) { last = keyPage; // precharge up to keyPage @@ -600,15 +600,15 @@ namespace NTable { const auto& scheme = Part->Scheme->HistoryGroup; Y_VERIFY_DEBUG(scheme.ColsKeyIdx.size() == 3); - // Directly use the histroy key nulls with correct sort order - const TKeyCellDefaults* nulls = Part->Scheme->HistoryKeys.Get(); + // Directly use the histroy key defaults with correct sort order + const TKeyCellDefaults* keyDefaults = Part->Scheme->HistoryKeys.Get(); - auto first = HistoryIndex->LookupKey(startKey, scheme, ESeek::Lower, nulls); + auto first = HistoryIndex->LookupKey(startKey, scheme, ESeek::Lower, keyDefaults); if (!first) { return true; } - auto last = HistoryIndex->LookupKey(endKey, scheme, ESeek::Lower, nulls); + auto last = HistoryIndex->LookupKey(endKey, scheme, ESeek::Lower, keyDefaults); bool ready = true; diff --git a/ydb/core/tablet_flat/flat_part_iter_multi.h b/ydb/core/tablet_flat/flat_part_iter_multi.h index 23236e27aa..2b6921854c 100644 --- a/ydb/core/tablet_flat/flat_part_iter_multi.h +++ b/ydb/core/tablet_flat/flat_part_iter_multi.h @@ -136,12 +136,12 @@ namespace NTable { EReady Seek( const TCells key, ESeek seek, const TPart* part, IPages* env, - const TPartScheme::TGroupInfo& scheme, const TKeyCellDefaults* nulls) noexcept + const TPartScheme::TGroupInfo& scheme, const TKeyCellDefaults* keyDefaults) noexcept { Y_VERIFY_DEBUG(seek == ESeek::Exact || seek == ESeek::Lower || seek == ESeek::Upper, "Only ESeek{Exact, Upper, Lower} are currently supported here"); - if (Index = IndexRef.LookupKey(key, scheme, seek, nulls)) { + if (Index = IndexRef.LookupKey(key, scheme, seek, keyDefaults)) { if (Index->GetRowId() >= EndRowId) { // Page is outside of bounds return Exhausted(); @@ -166,7 +166,7 @@ namespace NTable { return EReady::Page; } - if (Data = Page.LookupKey(key, scheme, seek, nulls)) { + if (Data = Page.LookupKey(key, scheme, seek, keyDefaults)) { RowId = Page.BaseRow() + Data.Off(); if (RowId >= EndRowId) { @@ -208,12 +208,12 @@ namespace NTable { EReady SeekReverse( const TCells key, ESeek seek, const TPart* part, IPages* env, - const TPartScheme::TGroupInfo& scheme, const TKeyCellDefaults* nulls) noexcept + const TPartScheme::TGroupInfo& scheme, const TKeyCellDefaults* keyDefaults) noexcept { Y_VERIFY_DEBUG(seek == ESeek::Exact || seek == ESeek::Lower || seek == ESeek::Upper, "Only ESeek{Exact, Upper, Lower} are currently supported here"); - if (Index = IndexRef.LookupKeyReverse(key, scheme, seek, nulls)) { + if (Index = IndexRef.LookupKeyReverse(key, scheme, seek, keyDefaults)) { if (Index->GetRowId() < BeginRowId) { // Page may be outside of bounds auto next = Index + 1; @@ -234,7 +234,7 @@ namespace NTable { return EReady::Page; } - if (Data = Page.LookupKeyReverse(key, scheme, seek, nulls)) { + if (Data = Page.LookupKeyReverse(key, scheme, seek, keyDefaults)) { RowId = Page.BaseRow() + Data.Off(); if (RowId < BeginRowId) { @@ -453,8 +453,8 @@ namespace NTable { Y_VERIFY_DEBUG(scheme.ColsKeyIdx.size() == 3); Y_VERIFY_DEBUG(scheme.ColsKeyData.size() == 3); - // Directly use the histroy key nulls with correct sort order - const TKeyCellDefaults* nulls = part->Scheme->HistoryKeys.Get(); + // Directly use the histroy key keyDefaults with correct sort order + const TKeyCellDefaults* keyDefaults = part->Scheme->HistoryKeys.Get(); // Helper for loading row id and row version from the index auto checkIndex = [&]() -> bool { @@ -498,7 +498,7 @@ namespace NTable { // Perform binary search on the last iteration if (linear == 0 && Data) { - Data = Page.LookupKey(key, scheme, ESeek::Lower, nulls); + Data = Page.LookupKey(key, scheme, ESeek::Lower, keyDefaults); } if (!Data) { @@ -563,7 +563,7 @@ namespace NTable { } // Full binary search - if (Index = IndexRef.LookupKey(key, scheme, ESeek::Lower, nulls)) { + if (Index = IndexRef.LookupKey(key, scheme, ESeek::Lower, keyDefaults)) { // We need exact match on rowId, bail on larger values TRowId indexRowId = Index->Cell(scheme.ColsKeyIdx[0]).AsValue<TRowId>(); if (rowId < indexRowId) { @@ -580,7 +580,7 @@ namespace NTable { return EReady::Page; } - if (Data = Page.LookupKey(key, scheme, ESeek::Lower, nulls)) { + if (Data = Page.LookupKey(key, scheme, ESeek::Lower, keyDefaults)) { if (!checkData()) { // First row for the next RowId MaxVersion = TRowVersion::Max(); @@ -669,17 +669,17 @@ namespace NTable { using TCells = NPage::TCells; using TGroupId = NPage::TGroupId; - TPartSimpleIt(const TPart* part, TTagsRef tags, TIntrusiveConstPtr<TKeyCellDefaults> nulls, IPages* env) + TPartSimpleIt(const TPart* part, TTagsRef tags, TIntrusiveConstPtr<TKeyCellDefaults> keyDefaults, IPages* env) : Part(part) , Env(env) , Pinout(Part->Scheme->MakePinout(tags)) - , Nulls(std::move(nulls)) + , KeyCellDefaults(std::move(keyDefaults)) , Main(Part->Index, TGroupId(0)) , SkipMainDeltas(0) , SkipMainVersion(false) , SkipEraseVersion(false) { - Key.reserve(Nulls->Size()); + Key.reserve(KeyCellDefaults->Size()); Groups.reserve(Pinout.AltGroups().size()); GroupRemap.resize(Part->Scheme->Groups.size(), Max<ui32>()); @@ -710,13 +710,13 @@ namespace NTable { EReady Seek(const TCells key, ESeek seek) noexcept { ClearKey(); - return Main.Seek(key, seek, Part, Env, Part->Scheme->Groups[0], &*Nulls); + return Main.Seek(key, seek, Part, Env, Part->Scheme->Groups[0], &*KeyCellDefaults); } EReady SeekReverse(const TCells key, ESeek seek) noexcept { ClearKey(); - return Main.SeekReverse(key, seek, Part, Env, Part->Scheme->Groups[0], &*Nulls); + return Main.SeekReverse(key, seek, Part, Env, Part->Scheme->Groups[0], &*KeyCellDefaults); } EReady Seek(TRowId rowId) noexcept @@ -775,7 +775,7 @@ namespace NTable { { InitKey(); - return TDbTupleRef(Nulls->BasicTypes().begin(), Key.begin(), Key.size()); + return TDbTupleRef(KeyCellDefaults->BasicTypes().begin(), Key.begin(), Key.size()); } TCells GetRawKey() const noexcept @@ -1083,8 +1083,8 @@ namespace NTable { Key.push_back(Main.GetRecord()->Cell(info[pos])); } - for (size_t pos = info.size(); pos < Nulls->Size(); ++pos) { - Key.push_back((*Nulls)[pos]); + for (size_t pos = info.size(); pos < KeyCellDefaults->Size(); ++pos) { + Key.push_back((*KeyCellDefaults)[pos]); } } } @@ -1172,7 +1172,7 @@ namespace NTable { private: const TPinout Pinout; - const TIntrusiveConstPtr<TKeyCellDefaults> Nulls; + const TIntrusiveConstPtr<TKeyCellDefaults> KeyCellDefaults; TPartGroupKeyIt Main; @@ -1211,10 +1211,10 @@ namespace NTable { public: using TCells = NPage::TCells; - TRunIt(const TRun& run, TTagsRef tags, TIntrusiveConstPtr<TKeyCellDefaults> nulls, IPages* env) + TRunIt(const TRun& run, TTagsRef tags, TIntrusiveConstPtr<TKeyCellDefaults> keyDefaults, IPages* env) : Run(run) , Tags(tags) - , Nulls(std::move(nulls)) + , KeyCellDefaults(std::move(keyDefaults)) , Env(env) , Current(Run.end()) { @@ -1251,7 +1251,7 @@ namespace NTable { pos = Run.LowerBound(key); if (pos != Run.end() && - TSlice::CompareSearchKeyFirstKey(key, pos->Slice, *Nulls) <= 0) + TSlice::CompareSearchKeyFirstKey(key, pos->Slice, *KeyCellDefaults) <= 0) { // Key is at the start of the slice seekToStart = true; @@ -1266,7 +1266,7 @@ namespace NTable { pos = Run.UpperBound(key); if (pos != Run.end() && - TSlice::CompareSearchKeyFirstKey(key, pos->Slice, *Nulls) < 0) + TSlice::CompareSearchKeyFirstKey(key, pos->Slice, *KeyCellDefaults) < 0) { // Key is at the start of the slice seekToStart = true; @@ -1342,7 +1342,7 @@ namespace NTable { pos = Run.LowerBoundReverse(key); if (pos != Run.end() && - TSlice::CompareLastKeySearchKey(pos->Slice, key, *Nulls) <= 0) + TSlice::CompareLastKeySearchKey(pos->Slice, key, *KeyCellDefaults) <= 0) { seekToEnd = true; } @@ -1356,7 +1356,7 @@ namespace NTable { pos = Run.UpperBoundReverse(key); if (pos != Run.end() && - TSlice::CompareLastKeySearchKey(pos->Slice, key, *Nulls) < 0) + TSlice::CompareLastKeySearchKey(pos->Slice, key, *KeyCellDefaults) < 0) { seekToEnd = true; } @@ -1536,7 +1536,7 @@ namespace NTable { CurrentIt = std::move(it->second); Cache.erase(it); } else { - CurrentIt = MakeHolder<TPartSimpleIt>(part, Tags, Nulls, Env); + CurrentIt = MakeHolder<TPartSimpleIt>(part, Tags, KeyCellDefaults, Env); } CurrentIt->SetBounds(Current->Slice); } @@ -1582,7 +1582,7 @@ namespace NTable { public: const TRun& Run; TTagsRef const Tags; - TIntrusiveConstPtr<TKeyCellDefaults> const Nulls; + TIntrusiveConstPtr<TKeyCellDefaults> const KeyCellDefaults; IPages* const Env; ui64 InvisibleRowSkips = 0; diff --git a/ydb/core/tablet_flat/flat_part_shrink.h b/ydb/core/tablet_flat/flat_part_shrink.h index 8a55f3fbf9..6c2c828df7 100644 --- a/ydb/core/tablet_flat/flat_part_shrink.h +++ b/ydb/core/tablet_flat/flat_part_shrink.h @@ -15,9 +15,9 @@ namespace NTable { public: using TCells = TArrayRef<const TCell>; - TShrink(IPages *env, TIntrusiveConstPtr<TKeyCellDefaults> nulls) + TShrink(IPages *env, TIntrusiveConstPtr<TKeyCellDefaults> keyDefaults) : Env(env) - , Nulls(nulls) + , KeyCellDefaults(keyDefaults) { } @@ -29,8 +29,8 @@ namespace NTable { TShrink& Put(TArrayRef<const TPartView> all, TRawVals from_, TRawVals to_) { - const TCelled from(from_, *Nulls, false); - const TCelled to(to_, *Nulls, false); + const TCelled from(from_, *KeyCellDefaults, false); + const TCelled to(to_, *KeyCellDefaults, false); return Put(all, from, to); } @@ -43,10 +43,10 @@ namespace NTable { if (!from && !to) /* [-inf, +inf) */ { PartView.emplace_back(partView); } else { - TPartSimpleIt first(partView.Part.Get(), { }, Nulls, Env); + TPartSimpleIt first(partView.Part.Get(), { }, KeyCellDefaults, Env); Skipped += EReady::Page == first.Seek(from, ESeek::Lower); - TPartSimpleIt last(partView.Part.Get(), { }, Nulls, Env); + TPartSimpleIt last(partView.Part.Get(), { }, KeyCellDefaults, Env); Skipped += EReady::Page == last.Seek(to, to ? ESeek::Lower : ESeek::Upper); auto firstRowId = first.GetRowId(); @@ -87,7 +87,7 @@ namespace NTable { public: IPages * const Env = nullptr; - TIntrusiveConstPtr<TKeyCellDefaults> Nulls; + TIntrusiveConstPtr<TKeyCellDefaults> KeyCellDefaults; size_t Skipped = 0; TVector<TPartView> PartView; }; diff --git a/ydb/core/tablet_flat/flat_part_slice.cpp b/ydb/core/tablet_flat/flat_part_slice.cpp index 458435b13b..a2e2e85d81 100644 --- a/ydb/core/tablet_flat/flat_part_slice.cpp +++ b/ydb/core/tablet_flat/flat_part_slice.cpp @@ -10,7 +10,7 @@ namespace NTable { namespace { -void PrintCells(IOutputStream& out, TArrayRef<const TCell> cells, const TCellDefaults& nulls) noexcept +void PrintCells(IOutputStream& out, TArrayRef<const TCell> cells, const TCellDefaults& cellDefaults) noexcept { out << '{'; size_t pos = 0; @@ -19,7 +19,7 @@ void PrintCells(IOutputStream& out, TArrayRef<const TCell> cells, const TCellDef out << ", "; } TString value; - DbgPrintValue(value, cell, nulls.Types[pos++]); + DbgPrintValue(value, cell, cellDefaults.Types[pos++]); out << value; } out << '}'; @@ -44,14 +44,14 @@ bool ValidateSlices(TConstArrayRef<TSlice> slices) noexcept //////////////////////////////////////////////////////////////////////////////// -int ComparePartKeys(TCellsRef left, TCellsRef right, const TKeyCellDefaults &nulls) noexcept { +int ComparePartKeys(TCellsRef left, TCellsRef right, const TKeyCellDefaults &keyDefaults) noexcept { size_t end = Max(left.size(), right.size()); - Y_VERIFY_DEBUG(end <= nulls.Size(), "Key schema is smaller than compared keys"); + Y_VERIFY_DEBUG(end <= keyDefaults.Size(), "Key schema is smaller than compared keys"); for (size_t pos = 0; pos < end; ++pos) { - const auto& leftCell = pos < left.size() ? left[pos] : nulls.Defs[pos]; - const auto& rightCell = pos < right.size() ? right[pos] : nulls.Defs[pos]; - if (int cmp = CompareTypedCells(leftCell, rightCell, nulls.Types[pos])) { + const auto& leftCell = pos < left.size() ? left[pos] : keyDefaults.Defs[pos]; + const auto& rightCell = pos < right.size() ? right[pos] : keyDefaults.Defs[pos]; + if (int cmp = CompareTypedCells(leftCell, rightCell, keyDefaults.Types[pos])) { return cmp; } } @@ -61,47 +61,47 @@ int ComparePartKeys(TCellsRef left, TCellsRef right, const TKeyCellDefaults &nul //////////////////////////////////////////////////////////////////////////////// -void TBounds::Describe(IOutputStream& out, const TKeyCellDefaults& nulls) const noexcept +void TBounds::Describe(IOutputStream& out, const TKeyCellDefaults& keyDefaults) const noexcept { auto left = FirstKey.GetCells(); auto right = LastKey.GetCells(); out << (FirstInclusive ? '[' : '('); if (left) { - PrintCells(out, left, nulls); + PrintCells(out, left, keyDefaults); } else { out << "-inf"; } out << ", "; if (right) { - PrintCells(out, right, nulls); + PrintCells(out, right, keyDefaults); } else { out << "+inf"; } out << (LastInclusive ? ']' : ')'); } -bool TBounds::LessByKey(const TBounds& a, const TBounds& b, const TKeyCellDefaults& nulls) noexcept +bool TBounds::LessByKey(const TBounds& a, const TBounds& b, const TKeyCellDefaults& keyDefaults) noexcept { auto left = a.LastKey.GetCells(); auto right = b.FirstKey.GetCells(); if (Y_UNLIKELY(!left)) { // Empty LastKey is +inf-epsilon => +inf-epsilon < any is never true Y_VERIFY_DEBUG(!a.LastInclusive, - "Unexpected inclusion of +inf: %s", NFmt::Ln(a, nulls).data()); + "Unexpected inclusion of +inf: %s", NFmt::Ln(a, keyDefaults).data()); return false; } if (Y_UNLIKELY(!right)) { // Empty FirstKey is -inf => any < -inf is never true Y_VERIFY_DEBUG(b.FirstInclusive, - "Unexpected exclusion of -inf: %s", NFmt::Ln(b, nulls).data()); + "Unexpected exclusion of -inf: %s", NFmt::Ln(b, keyDefaults).data()); return false; } size_t end = Max(left.size(), right.size()); - Y_VERIFY_DEBUG(end <= nulls.Size(), "Key schema is smaller than slice boundary keys"); + Y_VERIFY_DEBUG(end <= keyDefaults.Size(), "Key schema is smaller than slice boundary keys"); for (size_t pos = 0; pos < end; ++pos) { - const auto& leftCell = pos < left.size() ? left[pos] : nulls[pos]; - const auto& rightCell = pos < right.size() ? right[pos] : nulls[pos]; - if (int cmp = CompareTypedCells(leftCell, rightCell, nulls.Types[pos])) { + const auto& leftCell = pos < left.size() ? left[pos] : keyDefaults[pos]; + const auto& rightCell = pos < right.size() ? right[pos] : keyDefaults[pos]; + if (int cmp = CompareTypedCells(leftCell, rightCell, keyDefaults.Types[pos])) { return cmp < 0; } } @@ -112,7 +112,7 @@ bool TBounds::LessByKey(const TBounds& a, const TBounds& b, const TKeyCellDefaul int TBounds::CompareSearchKeyFirstKey( TArrayRef<const TCell> key, const TBounds& bounds, - const TKeyCellDefaults& nulls) noexcept + const TKeyCellDefaults& keyDefaults) noexcept { if (!key) { // Search key is +inf => +inf > any @@ -121,20 +121,20 @@ int TBounds::CompareSearchKeyFirstKey( auto right = bounds.FirstKey.GetCells(); if (Y_UNLIKELY(!right)) { Y_VERIFY_DEBUG(bounds.FirstInclusive, - "Unexpected exclusion of -inf: %s", NFmt::Ln(bounds, nulls).data()); + "Unexpected exclusion of -inf: %s", NFmt::Ln(bounds, keyDefaults).data()); // Empty FirstKey is -inf => any > -inf return +1; } - Y_VERIFY_DEBUG(key.size() <= nulls.Size(), + Y_VERIFY_DEBUG(key.size() <= keyDefaults.Size(), "Key schema is smaller than the search key"); for (size_t pos = 0; pos < key.size(); ++pos) { const auto& leftCell = key[pos]; - const auto& rightCell = pos < right.size() ? right[pos] : nulls[pos]; - if (int cmp = CompareTypedCells(leftCell, rightCell, nulls.Types[pos])) { + const auto& rightCell = pos < right.size() ? right[pos] : keyDefaults[pos]; + if (int cmp = CompareTypedCells(leftCell, rightCell, keyDefaults.Types[pos])) { return cmp; } } - if (key.size() < nulls.Size()) { + if (key.size() < keyDefaults.Size()) { // Search key is extended with +inf => +inf > any return +1; } @@ -145,12 +145,12 @@ int TBounds::CompareSearchKeyFirstKey( int TBounds::CompareLastKeySearchKey( const TBounds& bounds, TArrayRef<const TCell> key, - const TKeyCellDefaults& nulls) noexcept + const TKeyCellDefaults& keyDefaults) noexcept { auto left = bounds.LastKey.GetCells(); if (Y_UNLIKELY(!left)) { Y_VERIFY_DEBUG(!bounds.LastInclusive, - "Unexpected inclusion of +inf: %s", NFmt::Ln(bounds, nulls).data()); + "Unexpected inclusion of +inf: %s", NFmt::Ln(bounds, keyDefaults).data()); // Empty LastKey is +inf-epsilon // +inf-epsilon > any, // +inf-epsilon < +inf @@ -160,16 +160,16 @@ int TBounds::CompareLastKeySearchKey( // Search key is +inf => any < +inf return -1; } - Y_VERIFY_DEBUG(key.size() <= nulls.Size(), + Y_VERIFY_DEBUG(key.size() <= keyDefaults.Size(), "Key schema is smaller than the search key"); for (size_t pos = 0; pos < key.size(); ++pos) { - const auto& leftCell = pos < left.size() ? left[pos] : nulls[pos]; + const auto& leftCell = pos < left.size() ? left[pos] : keyDefaults[pos]; const auto& rightCell = key[pos]; - if (int cmp = CompareTypedCells(leftCell, rightCell, nulls.Types[pos])) { + if (int cmp = CompareTypedCells(leftCell, rightCell, keyDefaults.Types[pos])) { return cmp; } } - if (key.size() < nulls.Size()) { + if (key.size() < keyDefaults.Size()) { // Search key is extended with +inf => any < +inf return -1; } @@ -562,7 +562,7 @@ TIntrusiveConstPtr<TSlices> TSlices::Replace(TIntrusiveConstPtr<TSlices> run, TC TLevels::iterator TLevels::AddLevel() { size_t index = Levels.size(); - Levels.emplace_front(*Nulls, index); + Levels.emplace_front(*KeyCellDefaults, index); return Levels.begin(); } diff --git a/ydb/core/tablet_flat/flat_part_slice.h b/ydb/core/tablet_flat/flat_part_slice.h index 7d54e4020d..6a2a717412 100644 --- a/ydb/core/tablet_flat/flat_part_slice.h +++ b/ydb/core/tablet_flat/flat_part_slice.h @@ -13,7 +13,7 @@ namespace NTable { /** * A very simple comparator for part keys (extended with schema defaults) */ - int ComparePartKeys(TCellsRef left, TCellsRef right, const TKeyCellDefaults &nulls) noexcept; + int ComparePartKeys(TCellsRef left, TCellsRef right, const TKeyCellDefaults &keyDefaults) noexcept; /** * Bounds for a range of keys @@ -41,12 +41,12 @@ namespace NTable { { } - void Describe(IOutputStream& out, const TKeyCellDefaults& nulls) const noexcept; + void Describe(IOutputStream& out, const TKeyCellDefaults& keyDefaults) const noexcept; /** * Returns true if a is less than b without any intersections */ - static bool LessByKey(const TBounds& a, const TBounds& b, const TKeyCellDefaults& nulls) noexcept; + static bool LessByKey(const TBounds& a, const TBounds& b, const TKeyCellDefaults& keyDefaults) noexcept; /** * Compares search key and bounds first key @@ -56,7 +56,7 @@ namespace NTable { static int CompareSearchKeyFirstKey( TArrayRef<const TCell> key, const TBounds& bounds, - const TKeyCellDefaults& nulls) noexcept; + const TKeyCellDefaults& keyDefaults) noexcept; /** * Compares bounds last key and search key @@ -66,7 +66,7 @@ namespace NTable { static int CompareLastKeySearchKey( const TBounds& bounds, TArrayRef<const TCell> key, - const TKeyCellDefaults& nulls) noexcept; + const TKeyCellDefaults& keyDefaults) noexcept; }; /** @@ -565,10 +565,10 @@ namespace NTable { struct TCompare { typedef void is_transparent; - const TKeyCellDefaults& Nulls; + const TKeyCellDefaults& KeyCellDefaults; - explicit TCompare(const TKeyCellDefaults& nulls) - : Nulls(nulls) + explicit TCompare(const TKeyCellDefaults& keyDefaults) + : KeyCellDefaults(keyDefaults) { } @@ -577,7 +577,7 @@ namespace NTable { if (a.Part.Get() == b.Part.Get()) { return TSlice::LessByRowId(a.Slice, b.Slice); } else { - return TSlice::LessByKey(a.Slice, b.Slice, Nulls); + return TSlice::LessByKey(a.Slice, b.Slice, KeyCellDefaults); } } @@ -586,7 +586,7 @@ namespace NTable { if (a.Part == b.Part.Get()) { return TSlice::LessByRowId(a.Slice, b.Slice); } else { - return TSlice::LessByKey(a.Slice, b.Slice, Nulls); + return TSlice::LessByKey(a.Slice, b.Slice, KeyCellDefaults); } } @@ -595,42 +595,42 @@ namespace NTable { if (a.Part.Get() == b.Part) { return TSlice::LessByRowId(a.Slice, b.Slice); } else { - return TSlice::LessByKey(a.Slice, b.Slice, Nulls); + return TSlice::LessByKey(a.Slice, b.Slice, KeyCellDefaults); } } Y_FORCE_INLINE bool operator()(const TItem& a, const TLowerBound& key) const { // Returns true if a.LastKey < key - return TSlice::CompareLastKeySearchKey(a.Slice, key.Cells, Nulls) < 0; + return TSlice::CompareLastKeySearchKey(a.Slice, key.Cells, KeyCellDefaults) < 0; } Y_FORCE_INLINE bool operator()(const TUpperBound& key, const TItem& b) const { // Returns true if key < b.LastKey - return TSlice::CompareLastKeySearchKey(b.Slice, key.Cells, Nulls) > 0; + return TSlice::CompareLastKeySearchKey(b.Slice, key.Cells, KeyCellDefaults) > 0; } Y_FORCE_INLINE bool operator()(const TLowerBoundReverse& key, const TItem& b) const { // Returns true if key < b.FirstKey - return TSlice::CompareSearchKeyFirstKey(key.Cells, b.Slice, Nulls) < 0; + return TSlice::CompareSearchKeyFirstKey(key.Cells, b.Slice, KeyCellDefaults) < 0; } Y_FORCE_INLINE bool operator()(const TItem& a, const TUpperBoundReverse& key) const { // Returns true if a.FirstKey < key - return TSlice::CompareSearchKeyFirstKey(key.Cells, a.Slice, Nulls) > 0; + return TSlice::CompareSearchKeyFirstKey(key.Cells, a.Slice, KeyCellDefaults) > 0; } Y_FORCE_INLINE bool operator()(const TSearchRange& range, const TItem& b) const { - return TSlice::CompareSearchKeyFirstKey(range.To, b.Slice, Nulls) < 0; + return TSlice::CompareSearchKeyFirstKey(range.To, b.Slice, KeyCellDefaults) < 0; } Y_FORCE_INLINE bool operator()(const TItem& a, const TSearchRange& range) const { - return TSlice::CompareLastKeySearchKey(a.Slice, range.From, Nulls) < 0; + return TSlice::CompareLastKeySearchKey(a.Slice, range.From, KeyCellDefaults) < 0; } }; @@ -641,9 +641,9 @@ namespace NTable { using iterator = TItems::iterator; using value_type = TItem; - explicit TRun(const TKeyCellDefaults& nulls) - : Nulls(nulls) - , Slices({ }, TCompare(nulls)) + explicit TRun(const TKeyCellDefaults& keyDefaults) + : KeyCellDefaults(keyDefaults) + , Slices({ }, TCompare(keyDefaults)) { } @@ -679,7 +679,7 @@ namespace NTable { { TInsertKey key = { part, slice }; auto it = Slices.lower_bound(key); - bool possible = it == Slices.end() || TCompare(Nulls)(key, *it); + bool possible = it == Slices.end() || TCompare(KeyCellDefaults)(key, *it); return { it, possible }; } @@ -751,7 +751,7 @@ namespace NTable { } private: - const TKeyCellDefaults& Nulls; + const TKeyCellDefaults& KeyCellDefaults; TItems Slices; }; @@ -761,8 +761,8 @@ namespace NTable { class TLevels { class TItem : public TRun { public: - TItem(const TKeyCellDefaults& nulls, size_t index) - : TRun(nulls) + TItem(const TKeyCellDefaults& keyDefaults, size_t index) + : TRun(keyDefaults) , Index(index) { } @@ -783,8 +783,8 @@ namespace NTable { TRun::iterator Position; }; - explicit TLevels(TIntrusiveConstPtr<TKeyCellDefaults> nulls) - : Nulls(std::move(nulls)) + explicit TLevels(TIntrusiveConstPtr<TKeyCellDefaults> keyDefaults) + : KeyCellDefaults(std::move(keyDefaults)) { } @@ -811,7 +811,7 @@ namespace NTable { iterator AddLevel(); private: - TIntrusiveConstPtr<TKeyCellDefaults> Nulls; + TIntrusiveConstPtr<TKeyCellDefaults> KeyCellDefaults; TItems Levels; TEpoch MaxEpoch = TEpoch::Min(); }; diff --git a/ydb/core/tablet_flat/flat_range_cache.cpp b/ydb/core/tablet_flat/flat_range_cache.cpp index a489b95864..f4894ffbbd 100644 --- a/ydb/core/tablet_flat/flat_range_cache.cpp +++ b/ydb/core/tablet_flat/flat_range_cache.cpp @@ -4,11 +4,11 @@ namespace NKikimr { namespace NTable { -TKeyRangeCache::TKeyRangeCache(const TKeyCellDefaults& nulls, const TKeyRangeCacheConfig& config) - : Nulls(nulls) +TKeyRangeCache::TKeyRangeCache(const TKeyCellDefaults& keyDefaults, const TKeyRangeCacheConfig& config) + : KeyCellDefaults(keyDefaults) , Config(config) , Pool(new TSpecialMemoryPool()) - , Entries(TKeyRangeEntryCompare(Nulls.Types), TAllocator(&UsedHeapMemory)) + , Entries(TKeyRangeEntryCompare(KeyCellDefaults.Types), TAllocator(&UsedHeapMemory)) { } TKeyRangeCache::~TKeyRangeCache() @@ -184,9 +184,9 @@ void TKeyRangeCache::TDumpRanges::DumpTo(IOutputStream& out) const { for (const auto& entry : Self->Entries) { out << (first ? " " : ", "); out << (entry.FromInclusive ? "[" : "("); - out << NFmt::TPrintableTypedCells(entry.FromKey, Self->Nulls.BasicTypes()); + out << NFmt::TPrintableTypedCells(entry.FromKey, Self->KeyCellDefaults.BasicTypes()); out << ", "; - out << NFmt::TPrintableTypedCells(entry.ToKey, Self->Nulls.BasicTypes()); + out << NFmt::TPrintableTypedCells(entry.ToKey, Self->KeyCellDefaults.BasicTypes()); out << (entry.ToInclusive ? "]" : ")"); first = false; } diff --git a/ydb/core/tablet_flat/flat_range_cache.h b/ydb/core/tablet_flat/flat_range_cache.h index 0b60d54afb..b5f689c15b 100644 --- a/ydb/core/tablet_flat/flat_range_cache.h +++ b/ydb/core/tablet_flat/flat_range_cache.h @@ -387,7 +387,7 @@ public: }; public: - TKeyRangeCache(const TKeyCellDefaults& nulls, const TKeyRangeCacheConfig& config); + TKeyRangeCache(const TKeyCellDefaults& keyDefaults, const TKeyRangeCacheConfig& config); ~TKeyRangeCache(); @@ -552,7 +552,7 @@ private: static TCell AllocateCellCopy(TSpecialMemoryPool* pool, const TCell& cell); private: - const TKeyCellDefaults& Nulls; + const TKeyCellDefaults& KeyCellDefaults; const TKeyRangeCacheConfig Config; THolder<TSpecialMemoryPool> Pool; size_t UsedHeapMemory = 0; diff --git a/ydb/core/tablet_flat/flat_range_cache_ut.cpp b/ydb/core/tablet_flat/flat_range_cache_ut.cpp index 897e3caaeb..f518a8a1f7 100644 --- a/ydb/core/tablet_flat/flat_range_cache_ut.cpp +++ b/ydb/core/tablet_flat/flat_range_cache_ut.cpp @@ -47,9 +47,9 @@ Y_UNIT_TEST_SUITE(TFlatEraseCacheTest) { TVector<NScheme::TTypeIdOrder> types; types.emplace_back(NScheme::NTypeIds::Uint64); TVector<TCell> defs(1); - TIntrusiveConstPtr<TKeyCellDefaults> nulls = TKeyCellDefaults::Make(types, defs); + TIntrusiveConstPtr<TKeyCellDefaults> keyDefaults = TKeyCellDefaults::Make(types, defs); // Empty default config - TKeyRangeCache cache(*nulls, { }); + TKeyRangeCache cache(*keyDefaults, { }); // Empty keys, both inclusive TKeyRangeEntry entry({ }, { }, true, true, TRowVersion::Min()); // This will allocate a single node in the map diff --git a/ydb/core/tablet_flat/flat_row_celled.h b/ydb/core/tablet_flat/flat_row_celled.h index 42ce8bf78b..e9ff85b4f2 100644 --- a/ydb/core/tablet_flat/flat_row_celled.h +++ b/ydb/core/tablet_flat/flat_row_celled.h @@ -10,17 +10,17 @@ namespace NTable { struct TCelled { using TRaw = TArrayRef<const TRawTypeValue>; - TCelled(TRaw key, const TKeyCellDefaults &nulls, bool extend) - : Size(extend ? nulls->size() : Min(nulls->size(), key.size())) + TCelled(TRaw key, const TKeyCellDefaults &keyDefaults, bool extend) + : Size(extend ? keyDefaults->size() : Min(keyDefaults->size(), key.size())) , Large(Size > Small.size() ? Size : 0) , Cells(Large ? Large.begin() : Small.begin()) { - Y_VERIFY(key.size() <= nulls->size(), "Key is tool large"); + Y_VERIFY(key.size() <= keyDefaults->size(), "Key is tool large"); for (ui32 it = 0; it < Size; it++) { if (it >= key.size()) { - Cells[it] = nulls[it]; - } else if (key[it] && key[it].Type() != nulls.Types[it].GetTypeId()) { + Cells[it] = keyDefaults[it]; + } else if (key[it] && key[it].Type() != keyDefaults.Types[it].GetTypeId()) { Y_FAIL("Key does not comply table schema"); } else { Cells[it] = TCell((char*)key[it].Data(), key[it].Size()); diff --git a/ydb/core/tablet_flat/flat_row_misc.h b/ydb/core/tablet_flat/flat_row_misc.h index 3001119e66..4fbfe0de99 100644 --- a/ydb/core/tablet_flat/flat_row_misc.h +++ b/ydb/core/tablet_flat/flat_row_misc.h @@ -21,8 +21,8 @@ namespace NFmt { } - TCells(TCellsRef cells, const NTable::TCellDefaults &nulls, const TReg *reg) - : TCells(cells, nulls.Types, reg) + TCells(TCellsRef cells, const NTable::TCellDefaults &cellDefaults, const TReg *reg) + : TCells(cells, cellDefaults.Types, reg) { } diff --git a/ydb/core/tablet_flat/flat_row_remap.h b/ydb/core/tablet_flat/flat_row_remap.h index 22f304131a..f948e82e3a 100644 --- a/ydb/core/tablet_flat/flat_row_remap.h +++ b/ydb/core/tablet_flat/flat_row_remap.h @@ -42,14 +42,14 @@ namespace NTable { , Types_(tags.size(), 0) { Tag2Pos.reserve(tags.size()); - Nulls_.reserve(tags.size()); + CellDefaults_.reserve(tags.size()); for (TPos on = 0; on < tags.size(); on++) { const auto *info = scheme.ColInfo(tags[on]); Y_VERIFY(info, "Column %" PRIu32 " does not exist", tags[on]); Types_[on] = info->TypeId; - Nulls_.emplace_back((*scheme.Nulls)[info->Pos]); + CellDefaults_.emplace_back((*scheme.RowCellDefaults)[info->Pos]); if (info->IsKey()) KeyPins_.push_back({ on, info->Key }); @@ -74,9 +74,9 @@ namespace NTable { return KeyPins_; } - TArrayRef<const TCell> Nulls() const noexcept + TArrayRef<const TCell> CellDefaults() const noexcept { - return Nulls_; + return CellDefaults_; } THas Has(TTag tag) const noexcept @@ -91,7 +91,7 @@ namespace NTable { private: TSmallVec<TPin> KeyPins_; TSmallVec<NScheme::TTypeId> Types_; - TSmallVec<TCell> Nulls_; + TSmallVec<TCell> CellDefaults_; THashMap<TTag, TPos> Tag2Pos; }; diff --git a/ydb/core/tablet_flat/flat_row_scheme.h b/ydb/core/tablet_flat/flat_row_scheme.h index b9a05aa217..4ee03bea87 100644 --- a/ydb/core/tablet_flat/flat_row_scheme.h +++ b/ydb/core/tablet_flat/flat_row_scheme.h @@ -40,11 +40,11 @@ namespace NTable { TRowScheme( TVector<TColInfo> cols, TIntrusiveConstPtr<TKeyCellDefaults> keys, - TIntrusiveConstPtr<TRowCellDefaults> nulls, + TIntrusiveConstPtr<TRowCellDefaults> rowDefaults, TVector<ui32> families) : Cols(std::move(cols)) , Keys(std::move(keys)) - , Nulls(std::move(nulls)) + , RowCellDefaults(std::move(rowDefaults)) , Families(std::move(families)) { for (const auto &col: Cols) @@ -141,9 +141,9 @@ namespace NTable { */ } else { - auto &null = (*scheme.Nulls)[other->Pos]; + auto &null = (*scheme.RowCellDefaults)[other->Pos]; - if (CompareTypedCells(null, (*Nulls)[col.Pos], col.TypeId)) + if (CompareTypedCells(null, (*RowCellDefaults)[col.Pos], col.TypeId)) Y_FAIL("Cannot alter existing columnt default value"); } } @@ -152,7 +152,7 @@ namespace NTable { public: const TVector<TColInfo> Cols; const TIntrusiveConstPtr<TKeyCellDefaults> Keys; - const TIntrusiveConstPtr<TRowCellDefaults> Nulls; + const TIntrusiveConstPtr<TRowCellDefaults> RowCellDefaults; const TVector<ui32> Families; // per-group families private: diff --git a/ydb/core/tablet_flat/flat_row_state.h b/ydb/core/tablet_flat/flat_row_state.h index b51d732785..a1fda38c26 100644 --- a/ydb/core/tablet_flat/flat_row_state.h +++ b/ydb/core/tablet_flat/flat_row_state.h @@ -23,13 +23,13 @@ namespace NTable { State.assign(slots, { }); } - void Reset(TArrayRef<const TCell> nulls) + void Reset(TArrayRef<const TCell> cellDefaults) { Rop = ERowOp::Absent; Need_ = 0; - Left_ = nulls.size(); + Left_ = cellDefaults.size(); State.assign(Left_, { }); - Cells.assign(nulls.begin(), nulls.end()); + Cells.assign(cellDefaults.begin(), cellDefaults.end()); } ui32 Need() const noexcept { return Need_; } diff --git a/ydb/core/tablet_flat/flat_scan_feed.h b/ydb/core/tablet_flat/flat_scan_feed.h index c6784dac33..192fb2684a 100644 --- a/ydb/core/tablet_flat/flat_scan_feed.h +++ b/ydb/core/tablet_flat/flat_scan_feed.h @@ -307,9 +307,9 @@ namespace NTable { Y_VERIFY(Lead, "Cannot seek with invalid lead"); - auto nulls = Subset.Scheme->Keys; + auto keyDefaults = Subset.Scheme->Keys; - Y_VERIFY(Lead.Key.GetCells().size() <= nulls->Size(), "TLead key is too large"); + Y_VERIFY(Lead.Key.GetCells().size() <= keyDefaults->Size(), "TLead key is too large"); Iter = new TTableIt(Subset.Scheme.Get(), Lead.Tags, -1, SnapshotVersion, Subset.CommittedTransactions); @@ -318,7 +318,7 @@ namespace NTable { for (auto &mem: Subset.Frozen) Iter->Push( TMemIt::Make( - *mem, mem.Snapshot, Lead.Key.GetCells(), Lead.Relation, nulls, &Iter->Remap, CurrentEnv)); + *mem, mem.Snapshot, Lead.Key.GetCells(), Lead.Relation, keyDefaults, &Iter->Remap, CurrentEnv)); if (Lead.StopKey.GetCells()) { if (Lead.StopKeyInclusive) { @@ -358,11 +358,11 @@ namespace NTable { void PrepareBoots() noexcept { - auto nulls = Subset.Scheme->Keys; + auto keyDefaults = Subset.Scheme->Keys; // Assume subset is immutable and only construct levels once if (!Levels && (Subset.Flatten || LoadedParts)) { - Levels.Reset(new TLevels(nulls)); + Levels.Reset(new TLevels(keyDefaults)); TVector<const TPartView*> parts; parts.reserve(Subset.Flatten.size() + LoadedParts.size()); for (const auto& partView : Subset.Flatten) { @@ -389,7 +389,7 @@ namespace NTable { Boots.reserve(Levels->size()); for (auto &run: *Levels) { Boots.push_back( - MakeHolder<TRunIt>(run, Lead.Tags, nulls, CurrentEnv)); + MakeHolder<TRunIt>(run, Lead.Tags, keyDefaults, CurrentEnv)); } } } diff --git a/ydb/core/tablet_flat/flat_table.cpp b/ydb/core/tablet_flat/flat_table.cpp index 686a404268..11b3b90199 100644 --- a/ydb/core/tablet_flat/flat_table.cpp +++ b/ydb/core/tablet_flat/flat_table.cpp @@ -766,7 +766,7 @@ TTable::TReady TTable::Select(TRawVals key_, TTagsRef tags, IPages* env, TRowSta const TRemap remap(*Scheme, tags); - row.Reset(remap.Nulls()); + row.Reset(remap.CellDefaults()); for (auto &pin: remap.KeyPins()) row.Set(pin.Pos, { ECellOp::Set, ELargeObj::Inline }, key[pin.Key]); diff --git a/ydb/core/tablet_flat/test/libs/rows/tool.h b/ydb/core/tablet_flat/test/libs/rows/tool.h index b02aa443bf..427d542eaa 100644 --- a/ydb/core/tablet_flat/test/libs/rows/tool.h +++ b/ydb/core/tablet_flat/test/libs/rows/tool.h @@ -158,7 +158,7 @@ namespace NTest { cells.at(ColFor(value)->Pos) = value.Cell; } - out << NFmt::TCells(cells, *Scheme.Nulls, DbgRegistry()); + out << NFmt::TCells(cells, *Scheme.RowCellDefaults, DbgRegistry()); } const TColInfo* ColFor(const TRow::TUpdate &value) const diff --git a/ydb/core/tablet_flat/test/libs/table/wrap_iter.h b/ydb/core/tablet_flat/test/libs/table/wrap_iter.h index 228890542a..66101968c4 100644 --- a/ydb/core/tablet_flat/test/libs/table/wrap_iter.h +++ b/ydb/core/tablet_flat/test/libs/table/wrap_iter.h @@ -15,7 +15,7 @@ namespace NTest { TWrapIterImpl(const TSubset &subset, TRowVersion snapshot = TRowVersion::Max()) : Scheme(subset.Scheme) - , Nulls(Scheme->Keys) + , KeyCellDefaults(Scheme->Keys) , Frozen(subset.Frozen) , Flatten(subset.Flatten) , Snapshot(snapshot) @@ -68,11 +68,11 @@ namespace NTest { for (auto &mem: Frozen) Iter->Push( - TMemIt::Make(*mem, mem.Snapshot, key, seek, Nulls, &Iter->Remap, Env, + TMemIt::Make(*mem, mem.Snapshot, key, seek, KeyCellDefaults, &Iter->Remap, Env, TIter::Direction)); for (auto &run: Levels) { - auto one = MakeHolder<TRunIt>(run, Remap().Tags, Nulls, Env); + auto one = MakeHolder<TRunIt>(run, Remap().Tags, KeyCellDefaults, Env); EReady status; if constexpr (TIter::Direction == EDirection::Reverse) { @@ -100,7 +100,7 @@ namespace NTest { public: const TIntrusiveConstPtr<TRowScheme> Scheme; - const TIntrusiveConstPtr<TKeyCellDefaults> Nulls; + const TIntrusiveConstPtr<TKeyCellDefaults> KeyCellDefaults; const TFrozen Frozen; const TFlatten Flatten; const TRowVersion Snapshot; diff --git a/ydb/core/tablet_flat/test/libs/table/wrap_part.h b/ydb/core/tablet_flat/test/libs/table/wrap_part.h index 2cf16dae9e..d7538b947e 100644 --- a/ydb/core/tablet_flat/test/libs/table/wrap_part.h +++ b/ydb/core/tablet_flat/test/libs/table/wrap_part.h @@ -134,7 +134,7 @@ namespace NTest { EReady RollUp() { if (Defaults) { - State.Reset(Remap_.Nulls()); + State.Reset(Remap_.CellDefaults()); } else { State.Init(Remap_.Size()); } diff --git a/ydb/core/tablet_flat/test/libs/table/wrap_warm.h b/ydb/core/tablet_flat/test/libs/table/wrap_warm.h index 059cac1a21..6d747ecf7d 100644 --- a/ydb/core/tablet_flat/test/libs/table/wrap_warm.h +++ b/ydb/core/tablet_flat/test/libs/table/wrap_warm.h @@ -72,7 +72,7 @@ namespace NTest { { if (Iter->IsValid()) { if (Defaults) { - State.Reset(Remap_.Nulls()); + State.Reset(Remap_.CellDefaults()); } else { State.Init(Remap_.Size()); } diff --git a/ydb/core/tablet_flat/test/tool/perf/do_mem.h b/ydb/core/tablet_flat/test/tool/perf/do_mem.h index 833f1a9902..384290bd8d 100644 --- a/ydb/core/tablet_flat/test/tool/perf/do_mem.h +++ b/ydb/core/tablet_flat/test/tool/perf/do_mem.h @@ -16,7 +16,7 @@ namespace NPerf { public: TDoMem(ILogger *logger, const TMass &mass) : Table(NTest::TMake(mass).Mem()) - , Nulls(Table->Scheme->Keys) + , KeyCellDefaults(Table->Scheme->Keys) , Remap(TRemap::Full(*Table->Scheme)) { if (auto logl = logger->Log(NKikiSched::ELnLev::INF1)) { @@ -35,7 +35,7 @@ namespace NPerf { { const TCelled key(key_, *Table->Scheme->Keys, false); - Iter = TMemIt::Make(*Table, Table->Immediate(), key, seek, Nulls, &Remap, nullptr); + Iter = TMemIt::Make(*Table, Table->Immediate(), key, seek, KeyCellDefaults, &Remap, nullptr); } ui64 Scan(ui64 items, TSponge &aggr) override @@ -57,7 +57,7 @@ namespace NPerf { private: void Apply(TSponge &aggr) noexcept { - State.Reset(Remap.Nulls()); + State.Reset(Remap.CellDefaults()); const auto key = Iter->GetKey(); @@ -70,7 +70,7 @@ namespace NPerf { private: TIntrusivePtr<TMemTable> Table; - TIntrusiveConstPtr<TKeyCellDefaults> Nulls; + TIntrusiveConstPtr<TKeyCellDefaults> KeyCellDefaults; TRemap Remap; TAutoPtr<TMemIt> Iter; TRowState State; diff --git a/ydb/core/tablet_flat/ut/flat_comp_ut_common.h b/ydb/core/tablet_flat/ut/flat_comp_ut_common.h index cec48721e7..ab7dfb8dde 100644 --- a/ydb/core/tablet_flat/ut/flat_comp_ut_common.h +++ b/ydb/core/tablet_flat/ut/flat_comp_ut_common.h @@ -262,9 +262,9 @@ public: , Step(step) { } - TString ToString(const TKeyCellDefaults& nulls, bool dumpStep) const { + TString ToString(const TKeyCellDefaults& keyDefaults, bool dumpStep) const { TStringStream s; - Describe(s, nulls); + Describe(s, keyDefaults); s << "@" << Epoch; if (dumpStep) { s << "/" << Step; @@ -273,15 +273,15 @@ public: } }; - const TKeyCellDefaults& nulls = *DB.GetRowScheme(table)->Keys; - auto keyRangeLess = [&nulls](const TKeyRange& a, const TKeyRange& b) -> bool { - if (auto cmp = ComparePartKeys(a.FirstKey.GetCells(), b.FirstKey.GetCells(), nulls)) { + const TKeyCellDefaults& keyDefaults = *DB.GetRowScheme(table)->Keys; + auto keyRangeLess = [&keyDefaults](const TKeyRange& a, const TKeyRange& b) -> bool { + if (auto cmp = ComparePartKeys(a.FirstKey.GetCells(), b.FirstKey.GetCells(), keyDefaults)) { return cmp < 0; } if (a.FirstInclusive != b.FirstInclusive) { return a.FirstInclusive && !b.FirstInclusive; } - if (auto cmp = ComparePartKeys(a.LastKey.GetCells(), b.LastKey.GetCells(), nulls)) { + if (auto cmp = ComparePartKeys(a.LastKey.GetCells(), b.LastKey.GetCells(), keyDefaults)) { return cmp < 0; } if (a.LastInclusive != b.LastInclusive) { @@ -303,7 +303,7 @@ public: if (result) { result.append(' '); } - result += keyRange.ToString(nulls, dumpStep); + result += keyRange.ToString(keyDefaults, dumpStep); } return result; } diff --git a/ydb/core/tablet_flat/ut/ut_charge.cpp b/ydb/core/tablet_flat/ut/ut_charge.cpp index 17717c26f1..fa063eb8e7 100644 --- a/ydb/core/tablet_flat/ut/ut_charge.cpp +++ b/ydb/core/tablet_flat/ut/ut_charge.cpp @@ -117,17 +117,17 @@ namespace { TTouchEnv env(true); - const auto &nulls = *Tool.Scheme.Keys; + const auto &keyDefaults = *Tool.Scheme.Keys; const auto from = Tool.KeyCells(Mass.Saved[lower]); const auto to = Tool.KeyCells(Mass.Saved[upper]); - TRun run(nulls); + TRun run(keyDefaults); auto part = Eggs.Lone(); for (auto& slice : *part->Slices) { run.Insert(part, slice); } - TCharge::Range(&env, from, to, run, nulls, TTagsRef{ }, items, Max<ui64>()); + TCharge::Range(&env, from, to, run, keyDefaults, TTagsRef{ }, items, Max<ui64>()); if (!env.Is(arr, 0x00 /* require all pages */)) { Log() diff --git a/ydb/core/tablet_flat/ut/ut_part.cpp b/ydb/core/tablet_flat/ut/ut_part.cpp index 0c336e95ac..e046b861d2 100644 --- a/ydb/core/tablet_flat/ut/ut_part.cpp +++ b/ydb/core/tablet_flat/ut/ut_part.cpp @@ -165,7 +165,7 @@ Y_UNIT_TEST_SUITE(TPart) { wrap.To(10).Has(foo).Has(bar); } - Y_UNIT_TEST(Nulls) + Y_UNIT_TEST(CellDefaults) { TLayoutCook lay, fake; |