Skip to content

Commit

Permalink
fix schema construction with cached objects (ydb-platform#12935)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov333 authored and zverevgeny committed Jan 5, 2025
1 parent 7900d14 commit 3e9b9a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
8 changes: 1 addition & 7 deletions ydb/core/tx/columnshard/engines/scheme/index_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,7 @@ struct TIndexInfo: public IIndexInfo {
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;
}
Expand Down
16 changes: 4 additions & 12 deletions ydb/core/tx/columnshard/engines/scheme/objects_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,22 @@ class TSchemaObjectsCache {
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())(
"acc", AcceptionFieldsCount);
}
return it->second;
}

template <class TConstructor>
TConclusion<std::shared_ptr<TColumnFeatures>> GetOrCreateColumnFeatures(const TString& fingerprint, const TConstructor& constructor) {
TGuard lock(FeaturesMutex);
Expand Down

0 comments on commit 3e9b9a0

Please sign in to comment.