Skip to content

Commit b4d276d

Browse files
authored
Disentangle SS operation traits (#11972)
1 parent 3d45056 commit b4d276d

26 files changed

+683
-285
lines changed

ydb/core/tx/schemeshard/olap/operations/create_store.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <ydb/core/tx/schemeshard/schemeshard__operation_part.h>
22
#include <ydb/core/tx/schemeshard/schemeshard__operation_common.h>
33
#include <ydb/core/tx/schemeshard/schemeshard_impl.h>
4+
#include <ydb/core/tx/schemeshard/schemeshard__op_traits.h>
45

56
#include <ydb/core/base/subdomain.h>
67
#include <ydb/core/scheme/scheme_types_proto.h>
@@ -527,6 +528,30 @@ class TCreateOlapStore: public TSubOperation {
527528

528529
namespace NKikimr::NSchemeShard {
529530

531+
using TTag = TSchemeTxTraits<NKikimrSchemeOp::EOperationType::ESchemeOpCreateColumnStore>;
532+
533+
namespace NOperation {
534+
535+
template <>
536+
std::optional<TString> GetTargetName<TTag>(
537+
TTag,
538+
const TTxTransaction& tx)
539+
{
540+
return tx.GetCreateColumnStore().GetName();
541+
}
542+
543+
template <>
544+
bool SetName<TTag>(
545+
TTag,
546+
TTxTransaction& tx,
547+
const TString& name)
548+
{
549+
tx.MutableCreateColumnStore()->SetName(name);
550+
return true;
551+
}
552+
553+
} // namespace NOperation
554+
530555
ISubOperation::TPtr CreateNewOlapStore(TOperationId id, const TTxTransaction& tx) {
531556
return MakeSubOperation<TCreateOlapStore>(id, tx);
532557
}

ydb/core/tx/schemeshard/olap/operations/create_table.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <ydb/core/tx/schemeshard/schemeshard__operation_part.h>
22
#include <ydb/core/tx/schemeshard/schemeshard__operation_common.h>
33
#include <ydb/core/tx/schemeshard/schemeshard_impl.h>
4+
#include <ydb/core/tx/schemeshard/schemeshard__op_traits.h>
45

56
#include <ydb/core/base/subdomain.h>
67
#include <ydb/core/tx/columnshard/columnshard.h>
@@ -882,6 +883,30 @@ class TCreateColumnTable: public TSubOperation {
882883

883884
}
884885

886+
using TTag = TSchemeTxTraits<NKikimrSchemeOp::EOperationType::ESchemeOpCreateColumnTable>;
887+
888+
namespace NOperation {
889+
890+
template <>
891+
std::optional<TString> GetTargetName<TTag>(
892+
TTag,
893+
const TTxTransaction& tx)
894+
{
895+
return tx.GetCreateColumnTable().GetName();
896+
}
897+
898+
template <>
899+
bool SetName<TTag>(
900+
TTag,
901+
TTxTransaction& tx,
902+
const TString& name)
903+
{
904+
tx.MutableCreateColumnTable()->SetName(name);
905+
return true;
906+
}
907+
908+
} // namespace NOperation
909+
885910
ISubOperation::TPtr CreateNewColumnTable(TOperationId id, const TTxTransaction& tx) {
886911
return MakeSubOperation<TCreateColumnTable>(id, tx);
887912
}

ydb/core/tx/schemeshard/schemeshard__backup_collection_common.cpp

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "schemeshard__backup_collection_common.h"
22

3-
namespace NKikimr::NSchemeShard {
3+
namespace NKikimr::NSchemeShard::NBackup {
44

5-
std::optional<TBackupCollectionPaths> ResolveBackupCollectionPaths(
5+
std::optional<NBackup::TBackupCollectionPaths> ResolveBackupCollectionPaths(
66
const TString& rootPathStr,
77
const TString& name,
88
bool validateFeatureFlag,
@@ -74,7 +74,60 @@ std::optional<TBackupCollectionPaths> ResolveBackupCollectionPaths(
7474
return std::nullopt;
7575
}
7676

77-
return TBackupCollectionPaths{rootPath, dstPath};
77+
return NBackup::TBackupCollectionPaths{rootPath, dstPath};
7878
}
7979

80-
} // namespace NKikimr::NSchemeShard
80+
std::optional<THashMap<TString, THashSet<TString>>> GetRequiredPaths(
81+
const TTxTransaction& tx,
82+
const TString& targetDir,
83+
const TString& targetName,
84+
const TOperationContext& context)
85+
{
86+
THashMap<TString, THashSet<TString>> paths;
87+
const TString& targetPath = JoinPath({tx.GetWorkingDir(), targetName});
88+
89+
const TPath& bcPath = TPath::Resolve(targetPath, context.SS);
90+
{
91+
auto checks = bcPath.Check();
92+
checks
93+
.NotEmpty()
94+
.NotUnderDomainUpgrade()
95+
.IsAtLocalSchemeShard()
96+
.IsResolved()
97+
.NotUnderDeleting()
98+
.NotUnderOperation()
99+
.IsBackupCollection();
100+
101+
if (!checks) {
102+
return {};
103+
}
104+
}
105+
106+
Y_ABORT_UNLESS(context.SS->BackupCollections.contains(bcPath->PathId));
107+
const auto& bc = context.SS->BackupCollections[bcPath->PathId];
108+
109+
auto& collectionPaths = paths[targetPath];
110+
collectionPaths.emplace(targetDir);
111+
112+
for (const auto& item : bc->Description.GetExplicitEntryList().GetEntries()) {
113+
std::pair<TString, TString> paths;
114+
TString err;
115+
if (!TrySplitPathByDb(item.GetPath(), tx.GetWorkingDir(), paths, err)) {
116+
return {};
117+
}
118+
119+
auto pathPieces = SplitPath(paths.second);
120+
if (pathPieces.size() > 1) {
121+
auto parent = ExtractParent(paths.second);
122+
collectionPaths.emplace(JoinPath({targetDir, TString(parent)}));
123+
}
124+
}
125+
126+
return paths;
127+
}
128+
129+
TString ToX509String(const TInstant& datetime) {
130+
return datetime.FormatLocalTime("%Y%m%d%H%M%SZ");
131+
}
132+
133+
} // namespace NKikimr::NSchemeShard::NBackup

ydb/core/tx/schemeshard/schemeshard__backup_collection_common.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include <optional>
99

10-
namespace NKikimr::NSchemeShard {
10+
namespace NKikimr::NSchemeShard::NBackup {
1111

1212
struct TBackupCollectionPaths {
1313
TPath RootPath;
@@ -22,4 +22,12 @@ std::optional<TBackupCollectionPaths> ResolveBackupCollectionPaths(
2222
THolder<TProposeResponse>& result,
2323
bool enforceBackupCollectionsDirExists = true);
2424

25-
} // namespace NKikimr::NSchemeShard
25+
std::optional<THashMap<TString, THashSet<TString>>> GetRequiredPaths(
26+
const TTxTransaction& tx,
27+
const TString& targetDir,
28+
const TString& targetName,
29+
const TOperationContext& context);
30+
31+
TString ToX509String(const TInstant& datetime);
32+
33+
} // namespace NKikimr::NSchemeShard::NBackup

0 commit comments

Comments
 (0)