Skip to content

Commit f961757

Browse files
authored
Improve schemeshard codegen (#11579)
1 parent 224fb1c commit f961757

File tree

6 files changed

+37
-27
lines changed

6 files changed

+37
-27
lines changed

ydb/core/tx/schemeshard/generated/codegen/main.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1+
#include <ydb/core/protos/flat_scheme_op.pb.h>
2+
3+
#include <google/protobuf/descriptor.pb.h>
4+
#include <jinja2cpp/reflected_value.h>
5+
#include <jinja2cpp/template.h>
6+
#include <jinja2cpp/template_env.h>
7+
#include <jinja2cpp/value.h>
8+
19
#include <util/stream/file.h>
210
#include <util/stream/output.h>
311
#include <util/string/builder.h>
412
#include <util/system/src_location.h>
5-
#include <ydb/core/protos/flat_scheme_op.pb.h>
6-
#include <google/protobuf/descriptor.pb.h>
713

8-
#include <jinja2cpp/template_env.h>
9-
#include <jinja2cpp/template.h>
10-
#include <jinja2cpp/value.h>
11-
#include <jinja2cpp/reflected_value.h>
1214
#include <cstdint>
15+
#include <iostream>
1316
#include <string>
1417
#include <vector>
15-
#include <iostream>
1618

1719
std::string replace(
1820
const std::string& str,

ydb/core/tx/schemeshard/generated/dispatch_op.h.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
// Auto-generated by {{ generator }}, do not modify.
22
#pragma once
33

4-
#include <ydb/core/tx/schemeshard/generated/traits.h>
4+
#include <ydb/core/protos/flat_scheme_op.pb.h>
55

66
namespace NKikimr::NSchemeShard::NGenerated {
77

8-
template <class TFn>
8+
template <template <NKikimrSchemeOp::EOperationType> class TTraits, class TTraitsFallback, class TFn>
99
constexpr auto DispatchOp(const TTxTransaction& tx, TFn fn) {
1010
switch (tx.GetOperationType()) {
1111
{% for opType in opTypes %}
1212
case {{ opType }}:
13-
return fn(TSchemeTxTraits<{{ opType }}>{});
13+
return fn(TTraits<{{ opType }}>{});
1414
{% endfor %}
1515
default:
16-
return fn(TSchemeTxTraitsFallback{});
16+
return fn(TTraitsFallback{});
1717
}
1818
}
1919

ydb/core/tx/schemeshard/generated/ya.make

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ RUN_PROGRAM(
1111
IN dispatch_op.h.in
1212
OUT dispatch_op.h
1313
OUTPUT_INCLUDES
14-
ydb/core/tx/schemeshard/generated/traits.h
15-
)
16-
17-
SRCS(
18-
traits.h
14+
ydb/core/protos/flat_scheme_op.pb.h
1915
)
2016

2117
END()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
#include "schemeshard__op_traits.h"
4+
5+
#include <ydb/core/tx/schemeshard/generated/dispatch_op.h>
6+
7+
namespace NKikimr::NSchemeShard {
8+
9+
template <class TFn>
10+
constexpr auto DispatchOp(const TTxTransaction& tx, TFn fn) {
11+
return NGenerated::DispatchOp<TSchemeTxTraits, TSchemeTxTraitsFallback, TFn>(tx, std::forward<TFn>(fn));
12+
}
13+
14+
} // namespace NKikimr::NSchemeShard

ydb/core/tx/schemeshard/generated/traits.h renamed to ydb/core/tx/schemeshard/schemeshard__op_traits.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#pragma once
22

3+
#include <ydb/core/protos/flat_scheme_op.pb.h>
4+
35
#include <util/generic/string.h>
46
#include <util/generic/map.h>
57

68
#include <optional>
79

8-
#include <ydb/core/protos/flat_scheme_op.pb.h>
9-
10-
namespace NKikimr::NSchemeShard::NGenerated {
10+
namespace NKikimr::NSchemeShard {
1111

1212
using TTxTransaction = NKikimrSchemeOp::TModifyScheme;
1313

@@ -290,4 +290,4 @@ struct TSchemeTxTraits<NKikimrSchemeOp::EOperationType::ESchemeOpCreateBackupCol
290290
constexpr inline static bool CreateDirsFromName = true;
291291
};
292292

293-
} // namespace NKikimr::NSchemeShard::NGenerated
293+
} // namespace NKikimr::NSchemeShard

ydb/core/tx/schemeshard/schemeshard__operation.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#include "schemeshard__operation.h"
2-
#include "schemeshard__operation_part.h"
32

4-
#include "schemeshard__operation_side_effects.h"
5-
#include "schemeshard__operation_memory_changes.h"
3+
#include "schemeshard__dispatch_op.h"
64
#include "schemeshard__operation_db_changes.h"
7-
5+
#include "schemeshard__operation_memory_changes.h"
6+
#include "schemeshard__operation_part.h"
7+
#include "schemeshard__operation_side_effects.h"
88
#include "schemeshard_audit_log.h"
99
#include "schemeshard_impl.h"
1010

11-
#include <ydb/core/tx/schemeshard/generated/dispatch_op.h>
1211
#include <ydb/core/tablet/tablet_exception.h>
1312
#include <ydb/core/tablet_flat/flat_cxx_database.h>
1413
#include <ydb/core/tablet_flat/tablet_flat_executor.h>
@@ -792,6 +791,7 @@ bool CreateDirs(const TTxTransaction& tx, const TPath& parentPath, TPath path, T
792791

793792
while (path != parentPath) {
794793
if (createdPaths.contains(path.PathString())) {
794+
path.Rise();
795795
continue;
796796
}
797797

@@ -854,8 +854,6 @@ bool CreateDirs(const TTxTransaction& tx, const TPath& parentPath, TPath path, T
854854

855855
// # Generates additional MkDirs for transactions
856856
TOperation::TSplitTransactionsResult TOperation::SplitIntoTransactions(const TTxTransaction& tx, const TOperationContext& context) {
857-
using namespace NGenerated;
858-
859857
TSplitTransactionsResult result;
860858
THashSet<TString> createdPaths;
861859

0 commit comments

Comments
 (0)