aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorivanmorozov333 <ivanmorozov@ydb.tech>2024-10-31 10:08:01 +0300
committerGitHub <noreply@github.com>2024-10-31 10:08:01 +0300
commitb9d09c35e7ac68cc901fd377249a1d3e091b60a5 (patch)
tree3d28a6422539bfb3030f291f155531bc35d37dbd
parentbc145a84db0310336dad10a5e2348d0ce3f1340c (diff)
downloadydb-b9d09c35e7ac68cc901fd377249a1d3e091b60a5.tar.gz
precalculate storage ids for index info (#11127)
-rw-r--r--ydb/core/tx/columnshard/engines/scheme/index_info.cpp11
-rw-r--r--ydb/core/tx/columnshard/engines/scheme/index_info.h10
2 files changed, 15 insertions, 6 deletions
diff --git a/ydb/core/tx/columnshard/engines/scheme/index_info.cpp b/ydb/core/tx/columnshard/engines/scheme/index_info.cpp
index 3c687bfa4c1..a456a6f6740 100644
--- a/ydb/core/tx/columnshard/engines/scheme/index_info.cpp
+++ b/ydb/core/tx/columnshard/engines/scheme/index_info.cpp
@@ -124,6 +124,7 @@ void TIndexInfo::SetAllKeys(const std::shared_ptr<IStoragesManager>& operators,
if (!Schema) {
AFL_VERIFY(!SchemaWithSpecials);
InitializeCaches(operators, columns, nullptr);
+ Precalculate();
}
}
@@ -282,6 +283,7 @@ bool TIndexInfo::DeserializeFromProto(const NKikimrSchemeOp::TColumnTableSchema&
}
Version = schema.GetVersion();
+ Precalculate();
Validate();
return true;
}
@@ -550,10 +552,19 @@ TIndexInfo::TIndexInfo(const TIndexInfo& original, const TSchemaDiffView& diff,
if (diff.GetCompressionOptions()) {
DeserializeDefaultCompressionFromProto(*diff.GetCompressionOptions());
}
+ Precalculate();
Validate();
}
+void TIndexInfo::Precalculate() {
+ UsedStorageIds = std::make_shared<std::set<TString>>();
+ for (auto&& i : ColumnFeatures) {
+ UsedStorageIds->emplace(i->GetOperator()->GetStorageId());
+ }
+}
+
void TIndexInfo::Validate() const {
+ AFL_VERIFY(!!UsedStorageIds);
AFL_VERIFY(ColumnFeatures.size() == SchemaColumnIdsWithSpecials.size());
AFL_VERIFY(ColumnFeatures.size() == (ui32)SchemaWithSpecials->num_fields());
AFL_VERIFY(ColumnFeatures.size() == (ui32)Schema->num_fields() + IIndexInfo::SpecialColumnsCount);
diff --git a/ydb/core/tx/columnshard/engines/scheme/index_info.h b/ydb/core/tx/columnshard/engines/scheme/index_info.h
index fcea496b720..b9004b743b5 100644
--- a/ydb/core/tx/columnshard/engines/scheme/index_info.h
+++ b/ydb/core/tx/columnshard/engines/scheme/index_info.h
@@ -98,6 +98,7 @@ private:
std::vector<std::shared_ptr<TColumnFeatures>> ColumnFeatures;
THashMap<ui32, NIndexes::TIndexMetaContainer> Indexes;
+ std::shared_ptr<std::set<TString>> UsedStorageIds;
bool SchemeNeedActualization = false;
std::shared_ptr<NStorageOptimizer::IOptimizerPlannerConstructor> CompactionPlannerConstructor;
@@ -149,6 +150,7 @@ private:
const std::shared_ptr<TSchemaObjectsCache>& cache) const;
void Validate() const;
+ void Precalculate();
bool DeserializeFromProto(const NKikimrSchemeOp::TColumnTableSchema& schema, const std::shared_ptr<IStoragesManager>& operators,
const std::shared_ptr<TSchemaObjectsCache>& cache);
@@ -228,15 +230,11 @@ public:
}
std::set<TString> GetUsedStorageIds(const TString& portionTierName) const {
- std::set<TString> result;
if (portionTierName && portionTierName != IStoragesManager::DefaultStorageId) {
- result.emplace(portionTierName);
+ return { portionTierName };
} else {
- for (auto&& i : ColumnFeatures) {
- result.emplace(i->GetOperator()->GetStorageId());
- }
+ return *UsedStorageIds;
}
- return result;
}
const THashMap<ui32, NIndexes::TIndexMetaContainer>& GetIndexes() const {