11#pragma once
22#include " column_features.h"
33
4+ #include < ydb/core/tx/columnshard/engines/scheme/abstract/schema_version.h>
5+ #include < ydb/core/tx/columnshard/engines/scheme/common/cache.h>
6+
47#include < contrib/libs/apache/arrow/cpp/src/arrow/type.h>
58#include < library/cpp/string_utils/quote/quote.h>
69#include < util/generic/hash.h>
710
811namespace NKikimr ::NOlap {
912
1013class TSchemaObjectsCache {
11- public:
12- class TSchemaVersionId {
13- private:
14- YDB_READONLY_DEF (ui64, PresetId);
15- YDB_READONLY_DEF (ui64, Version);
16-
17- public:
18- struct THash {
19- ui64 operator ()(const TSchemaVersionId& object) const {
20- return CombineHashes (object.PresetId , object.Version );
21- }
22- };
23-
24- bool operator ==(const TSchemaVersionId& other) const {
25- return std::tie (PresetId, Version) == std::tie (other.PresetId , other.Version );
26- }
27-
28- TSchemaVersionId (const ui64 presetId, const ui64 version)
29- : PresetId(presetId)
30- , Version(version) {
31- }
32- };
33-
3414private:
3515 THashMap<TString, std::shared_ptr<arrow::Field>> Fields;
3616 mutable ui64 AcceptionFieldsCount = 0 ;
@@ -40,8 +20,8 @@ class TSchemaObjectsCache {
4020 mutable ui64 AcceptionFeaturesCount = 0 ;
4121 mutable TMutex FeaturesMutex;
4222
43- THashMap <TSchemaVersionId, std::weak_ptr< const TIndexInfo>, TSchemaVersionId::THash> SchemasByVersion ;
44- mutable TMutex SchemasMutex ;
23+ using TSchemasCache = TObjectCache <TSchemaVersionId, TIndexInfo>;
24+ TSchemasCache SchemasByVersion ;
4525
4626 THashSet<TString> StringsCache;
4727 mutable TMutex StringsMutex;
@@ -102,7 +82,7 @@ class TSchemaObjectsCache {
10282 return it->second ;
10383 }
10484
105- std::shared_ptr< const TIndexInfo> UpsertIndexInfo (const ui64 presetId, TIndexInfo&& indexInfo);
85+ TSchemasCache::TEntryGuard UpsertIndexInfo (const ui64 presetId, TIndexInfo&& indexInfo);
10686};
10787
10888class TSchemaCachesManager {
0 commit comments