Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix schema construction with cached objects #12935

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading