diff options
author | ivanmorozov333 <ivanmorozov@ydb.tech> | 2024-12-24 22:00:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-24 22:00:07 +0300 |
commit | be43a4691ebdd4dbe260a8d77df4cd8423b14c05 (patch) | |
tree | 522e70e1921f540b1bb465e225c1e24a6cb55e14 | |
parent | f6d8d599a2b7c5f3740ad8413a171b46403c3335 (diff) | |
download | ydb-be43a4691ebdd4dbe260a8d77df4cd8423b14c05.tar.gz |
fix schema construction with cached objects (#12935)
-rw-r--r-- | ydb/core/tx/columnshard/engines/scheme/index_info.h | 8 | ||||
-rw-r--r-- | ydb/core/tx/columnshard/engines/scheme/objects_cache.h | 16 |
2 files changed, 5 insertions, 19 deletions
diff --git a/ydb/core/tx/columnshard/engines/scheme/index_info.h b/ydb/core/tx/columnshard/engines/scheme/index_info.h index 420347ae780..e4b3534cfd1 100644 --- a/ydb/core/tx/columnshard/engines/scheme/index_info.h +++ b/ydb/core/tx/columnshard/engines/scheme/index_info.h @@ -80,13 +80,7 @@ private: AFL_VERIFY(arrowType.ok()); auto f = std::make_shared<arrow::Field>(column.Name, arrowType.ValueUnsafe(), !column.NotNull); if (cache) { - auto fFound = cache->GetField(f->ToString(true)); - if (!fFound) { - cache->RegisterField(f->ToString(true), f); - return f; - } else { - return fFound; - } + return cache->GetOrInsertField(f); } else { return f; } diff --git a/ydb/core/tx/columnshard/engines/scheme/objects_cache.h b/ydb/core/tx/columnshard/engines/scheme/objects_cache.h index fabd9089438..cf7dd7793eb 100644 --- a/ydb/core/tx/columnshard/engines/scheme/objects_cache.h +++ b/ydb/core/tx/columnshard/engines/scheme/objects_cache.h @@ -36,23 +36,14 @@ public: return *it; } - void RegisterField(const TString& fingerprint, const std::shared_ptr<arrow::Field>& f) { - AFL_TRACE(NKikimrServices::TX_COLUMNSHARD)("event", "register_field")("fp", fingerprint)("f", f->ToString()); - TGuard lock(FieldsMutex); - AFL_VERIFY(Fields.emplace(fingerprint, f).second); - } - void RegisterColumnFeatures(const TString& fingerprint, const std::shared_ptr<TColumnFeatures>& f) { - AFL_TRACE(NKikimrServices::TX_COLUMNSHARD)("event", "register_column_features")("fp", fingerprint)("info", f->DebugString()); - TGuard lock(FeaturesMutex); - AFL_VERIFY(ColumnFeatures.emplace(fingerprint, f).second); - } - std::shared_ptr<arrow::Field> GetField(const TString& fingerprint) const { + std::shared_ptr<arrow::Field> GetOrInsertField(const std::shared_ptr<arrow::Field>& f) { TGuard lock(FieldsMutex); + const TString fingerprint = f->ToString(true); auto it = Fields.find(fingerprint); if (it == Fields.end()) { AFL_TRACE(NKikimrServices::TX_COLUMNSHARD)("event", "get_field_miss")("fp", fingerprint)("count", Fields.size())( "acc", AcceptionFieldsCount); - return nullptr; + it = Fields.emplace(fingerprint, f).first; } if (++AcceptionFieldsCount % 1000 == 0) { AFL_TRACE(NKikimrServices::TX_COLUMNSHARD)("event", "get_field_accept")("fp", fingerprint)("count", Fields.size())( @@ -60,6 +51,7 @@ public: } return it->second; } + template <class TConstructor> TConclusion<std::shared_ptr<TColumnFeatures>> GetOrCreateColumnFeatures(const TString& fingerprint, const TConstructor& constructor) { TGuard lock(FeaturesMutex); |