diff options
author | ivanmorozov333 <ivanmorozov@ydb.tech> | 2024-12-24 21:59:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-24 21:59:50 +0300 |
commit | f6d8d599a2b7c5f3740ad8413a171b46403c3335 (patch) | |
tree | 001a044953b3b4099167794802647b0bdb4a11d0 | |
parent | 95f3cb4348e684945c9072f40f77bd51d969e8fd (diff) | |
download | ydb-f6d8d599a2b7c5f3740ad8413a171b46403c3335.tar.gz |
fix indexes usage (#12933)
4 files changed, 47 insertions, 2 deletions
diff --git a/ydb/core/tx/columnshard/columnshard_schema.h b/ydb/core/tx/columnshard/columnshard_schema.h index 646a4409d7..1837c16501 100644 --- a/ydb/core/tx/columnshard/columnshard_schema.h +++ b/ydb/core/tx/columnshard/columnshard_schema.h @@ -1122,6 +1122,15 @@ public: return TIndexChunk(Address.GetColumnId(), Address.GetChunkIdx(), RecordsCount, RawBytes, *BlobData); } + TIndexChunk BuildIndexChunk(const TPortionInfo& portionInfo) const { + if (BlobData) { + return BuildIndexChunk(); + } else { + AFL_VERIFY(!!BlobRange); + return BuildIndexChunk(portionInfo.GetMeta().GetBlobIdxVerified(BlobRange->BlobId)); + } + } + template <class TSource> TIndexChunkLoadContext(const TSource& rowset, const IBlobGroupSelector* dsGroupSelector) : PathId(rowset.template GetValue<NColumnShard::Schema::IndexIndexes::PathId>()) diff --git a/ydb/core/tx/columnshard/engines/portions/constructor_accessor.cpp b/ydb/core/tx/columnshard/engines/portions/constructor_accessor.cpp index 380778476f..b3d6b778f1 100644 --- a/ydb/core/tx/columnshard/engines/portions/constructor_accessor.cpp +++ b/ydb/core/tx/columnshard/engines/portions/constructor_accessor.cpp @@ -121,7 +121,7 @@ void TPortionAccessorConstructor::LoadRecord(TColumnChunkLoadContextV1&& loadCon void TPortionAccessorConstructor::LoadIndex(TIndexChunkLoadContext&& loadContext) { if (loadContext.GetBlobRange()) { - const TBlobRangeLink16::TLinkId linkBlobId = RegisterBlobId(loadContext.GetBlobRange()->GetBlobId()); + const TBlobRangeLink16::TLinkId linkBlobId = PortionInfo.GetMeta().GetBlobIdxVerified(loadContext.GetBlobRange()->GetBlobId()); AddIndex(loadContext.BuildIndexChunk(linkBlobId)); } else { AddIndex(loadContext.BuildIndexChunk()); @@ -156,7 +156,7 @@ TPortionDataAccessor TPortionAccessorConstructor::BuildForLoading( }; bool needSort = false; for (auto&& i : indexes) { - auto chunk = i.BuildIndexChunk(); + auto chunk = i.BuildIndexChunk(*portion); if (indexChunks.size() && !pred(indexChunks.back(), chunk)) { needSort = true; } diff --git a/ydb/core/tx/columnshard/engines/portions/constructor_meta.h b/ydb/core/tx/columnshard/engines/portions/constructor_meta.h index 4135e89ff9..71f7ae6925 100644 --- a/ydb/core/tx/columnshard/engines/portions/constructor_meta.h +++ b/ydb/core/tx/columnshard/engines/portions/constructor_meta.h @@ -64,6 +64,24 @@ public: return idx; } + std::optional<TBlobRangeLink16::TLinkId> GetBlobIdxOptional(const TUnifiedBlobId& blobId) const { + AFL_VERIFY(blobId.IsValid()); + TBlobRangeLink16::TLinkId idx = 0; + for (auto&& i : BlobIds) { + if (i == blobId) { + return idx; + } + ++idx; + } + return std::nullopt; + } + + TBlobRangeLink16::TLinkId GetBlobIdxVerified(const TUnifiedBlobId& blobId) const { + auto result = GetBlobIdxOptional(blobId); + AFL_VERIFY(result); + return *result; + } + void SetCompactionLevel(const ui64 level) { CompactionLevel = level; } diff --git a/ydb/core/tx/columnshard/engines/portions/meta.h b/ydb/core/tx/columnshard/engines/portions/meta.h index 6b2bb00bd4..7c212fdf00 100644 --- a/ydb/core/tx/columnshard/engines/portions/meta.h +++ b/ydb/core/tx/columnshard/engines/portions/meta.h @@ -68,6 +68,24 @@ public: CompactionLevel = level; } + std::optional<TBlobRangeLink16::TLinkId> GetBlobIdxOptional(const TUnifiedBlobId& blobId) const { + AFL_VERIFY(blobId.IsValid()); + TBlobRangeLink16::TLinkId idx = 0; + for (auto&& i : BlobIds) { + if (i == blobId) { + return idx; + } + ++idx; + } + return std::nullopt; + } + + TBlobRangeLink16::TLinkId GetBlobIdxVerified(const TUnifiedBlobId& blobId) const { + auto result = GetBlobIdxOptional(blobId); + AFL_VERIFY(result); + return *result; + } + using EProduced = NPortion::EProduced; NArrow::TReplaceKey IndexKeyStart; |