Skip to content

Commit 178899d

Browse files
authored
TTableInfo incapsulation (#15481)
1 parent 74fb9ec commit 178899d

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

ydb/core/tx/columnshard/tables_manager.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ bool TTablesManager::InitFromDB(NIceDb::TNiceDb& db) {
5454
}
5555

5656
while (!rowset.EndOfSet()) {
57-
TTableInfo table;
58-
if (!table.InitFromDB(rowset)) {
59-
timer.AddLoadingFail();
60-
return false;
61-
}
57+
TTableInfo table = table.InitFromDB(rowset);
6258
if (table.IsDropped()) {
6359
AFL_VERIFY(PathsToDrop[table.GetDropVersionVerified()].emplace(table.GetPathId()).second);
6460
}
@@ -114,21 +110,21 @@ bool TTablesManager::InitFromDB(NIceDb::TNiceDb& db) {
114110

115111
while (!rowset.EndOfSet()) {
116112
const auto pathId = TInternalPathId::FromRawValue(rowset.GetValue<Schema::TableVersionInfo::PathId>());
117-
Y_ABORT_UNLESS(Tables.contains(pathId));
113+
const auto table = Tables.FindPtr(pathId);
114+
AFL_VERIFY(table);
118115
NOlap::TSnapshot version(
119116
rowset.GetValue<Schema::TableVersionInfo::SinceStep>(), rowset.GetValue<Schema::TableVersionInfo::SinceTxId>());
120117

121-
auto& table = Tables[pathId];
122118
NKikimrTxColumnShard::TTableVersionInfo versionInfo;
123-
Y_ABORT_UNLESS(versionInfo.ParseFromString(rowset.GetValue<Schema::TableVersionInfo::InfoProto>()));
119+
AFL_VERIFY(versionInfo.ParseFromString(rowset.GetValue<Schema::TableVersionInfo::InfoProto>()));
124120
AFL_DEBUG(NKikimrServices::TX_COLUMNSHARD)("event", "load_table_version")("path_id", pathId)("snapshot", version);
125121
AFL_VERIFY(preset);
126122
AFL_VERIFY(preset->Id == versionInfo.GetSchemaPresetId())("preset", preset->Id)("table", versionInfo.GetSchemaPresetId());
127123

128124
if (versionInfo.HasTtlSettings()) {
129125
Ttl.AddVersionFromProto(pathId, version, versionInfo.GetTtlSettings());
130126
}
131-
table.AddVersion(version);
127+
table->AddVersion(version);
132128
if (!rowset.Next()) {
133129
timer.AddLoadingFail();
134130
return false;
@@ -223,9 +219,9 @@ ui64 TTablesManager::GetMemoryUsage() const {
223219
}
224220

225221
void TTablesManager::DropTable(const TInternalPathId pathId, const NOlap::TSnapshot& version, NIceDb::TNiceDb& db) {
226-
AFL_VERIFY(Tables.contains(pathId));
227-
auto& table = Tables[pathId];
228-
table.SetDropVersion(version);
222+
auto* table = Tables.FindPtr(pathId);
223+
AFL_VERIFY(table);
224+
table->SetDropVersion(version);
229225
AFL_VERIFY(PathsToDrop[version].emplace(pathId).second);
230226
Schema::SaveTableDropVersion(db, pathId, version.GetPlanStep(), version.GetTxId());
231227
}

ydb/core/tx/columnshard/tables_manager.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ class TSchemaPreset: public TVersionedSchema<NKikimrTxColumnShard::TSchemaPreset
9393
};
9494

9595
class TTableInfo {
96-
public:
97-
TInternalPathId PathId;
96+
const TInternalPathId PathId;
9897
std::optional<NOlap::TSnapshot> DropVersion;
9998
YDB_READONLY_DEF(TSet<NOlap::TSnapshot>, Versions);
10099

@@ -131,20 +130,19 @@ class TTableInfo {
131130
return *DropVersion < *minReadSnapshot;
132131
}
133132

134-
TTableInfo() = default;
135-
136133
TTableInfo(const TInternalPathId pathId)
137134
: PathId(pathId) {
138135
}
139136

140137
template <class TRow>
141-
bool InitFromDB(const TRow& rowset) {
142-
PathId = TInternalPathId::FromRawValue(rowset.template GetValue<Schema::TableInfo::PathId>());
138+
static TTableInfo InitFromDB(const TRow& rowset) {
139+
const auto pathId = TInternalPathId::FromRawValue(rowset.template GetValue<Schema::TableInfo::PathId>());
140+
TTableInfo result(pathId);
143141
if (rowset.template HaveValue<Schema::TableInfo::DropStep>() && rowset.template HaveValue<Schema::TableInfo::DropTxId>()) {
144-
DropVersion.emplace(
142+
result.DropVersion.emplace(
145143
rowset.template GetValue<Schema::TableInfo::DropStep>(), rowset.template GetValue<Schema::TableInfo::DropTxId>());
146144
}
147-
return true;
145+
return result;
148146
}
149147
};
150148

0 commit comments

Comments
 (0)