aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorilnaz <ilnaz@ydb.tech>2023-01-13 12:06:06 +0300
committerilnaz <ilnaz@ydb.tech>2023-01-13 12:06:06 +0300
commitaf913bab9b81a719bf5aa055d02322be47fc5c70 (patch)
tree0bb83df854972a5342afffe1a01ad9461a42c149
parent7c44ed5547e5ffd0dfcea1db3c1ac97a4b5f901a (diff)
downloadydb-af913bab9b81a719bf5aa055d02322be47fc5c70.tar.gz
(refactoring) Memory changes
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_memory_changes.cpp59
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_memory_changes.h3
2 files changed, 25 insertions, 37 deletions
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_memory_changes.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_memory_changes.cpp
index 4b98347759..893ecaeefa 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_memory_changes.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_memory_changes.cpp
@@ -1,40 +1,38 @@
#include "schemeshard__operation_memory_changes.h"
#include "schemeshard_impl.h"
-#include <ydb/core/tx/tx_processing.h>
-
namespace NKikimr::NSchemeShard {
-void TMemoryChanges::GrabNewTxState(TSchemeShard* ss, const TOperationId& op) {
- Y_VERIFY(!ss->TxInFlight.contains(op));
+template <typename I, typename C, typename H>
+static void GrabNew(const I& id, const C& cont, H& holder) {
+ Y_VERIFY(!cont.contains(id));
+ holder.emplace(id, nullptr);
+}
- TxStates.emplace(op, nullptr);
+template <typename T, typename I, typename C, typename H>
+static void Grab(const I& id, const C& cont, H& holder) {
+ Y_VERIFY(cont.contains(id));
+ holder.emplace(id, new T(*cont.at(id)));
}
-void TMemoryChanges::GrabNewPath(TSchemeShard* ss, const TPathId& pathId) {
- Y_VERIFY(!ss->PathsById.contains(pathId));
+void TMemoryChanges::GrabNewTxState(TSchemeShard* ss, const TOperationId& opId) {
+ GrabNew(opId, ss->TxInFlight, TxStates);
+}
- Paths.emplace(pathId, nullptr);
+void TMemoryChanges::GrabNewPath(TSchemeShard* ss, const TPathId& pathId) {
+ GrabNew(pathId, ss->PathsById, Paths);
}
void TMemoryChanges::GrabPath(TSchemeShard* ss, const TPathId& pathId) {
- Y_VERIFY(ss->PathsById.contains(pathId));
-
- TPathElement::TPtr copy = new TPathElement(*ss->PathsById.at(pathId));
- Paths.emplace(pathId, copy);
+ Grab<TPathElement>(pathId, ss->PathsById, Paths);
}
void TMemoryChanges::GrabNewTable(TSchemeShard* ss, const TPathId& pathId) {
- Y_VERIFY(!ss->Tables.contains(pathId));
-
- Tables.emplace(pathId, nullptr);
+ GrabNew(pathId, ss->Tables, Tables);
}
void TMemoryChanges::GrabTable(TSchemeShard* ss, const TPathId& pathId) {
- Y_VERIFY(ss->Tables.contains(pathId));
-
- TTableInfo::TPtr copy = new TTableInfo(*ss->Tables.at(pathId));
- Tables.emplace(pathId, copy);
+ Grab<TTableInfo>(pathId, ss->Tables, Tables);
}
void TMemoryChanges::GrabNewShard(TSchemeShard*, const TShardIdx& shardId) {
@@ -49,47 +47,38 @@ void TMemoryChanges::GrabShard(TSchemeShard *ss, const TShardIdx &shardId) {
}
void TMemoryChanges::GrabDomain(TSchemeShard* ss, const TPathId& pathId) {
- Y_VERIFY(ss->SubDomains.contains(pathId));
-
- TSubDomainInfo::TPtr copy = new TSubDomainInfo(*ss->SubDomains.at(pathId));
- SubDomains.emplace(pathId, copy);
+ Grab<TSubDomainInfo>(pathId, ss->SubDomains, SubDomains);
}
void TMemoryChanges::GrabNewIndex(TSchemeShard* ss, const TPathId& pathId) {
- Y_VERIFY(!ss->Indexes.contains(pathId));
-
- Indexes.emplace(pathId, nullptr);
+ GrabNew(pathId, ss->Indexes, Indexes);
}
void TMemoryChanges::GrabIndex(TSchemeShard* ss, const TPathId& pathId) {
- Y_VERIFY(ss->Indexes.contains(pathId));
-
- TTableIndexInfo::TPtr copy = new TTableIndexInfo(*ss->Indexes.at(pathId));
- Indexes.emplace(pathId, copy);
+ Grab<TTableIndexInfo>(pathId, ss->Indexes, Indexes);
}
void TMemoryChanges::GrabNewCdcStream(TSchemeShard* ss, const TPathId& pathId) {
- Y_VERIFY(!ss->CdcStreams.contains(pathId));
+ GrabNew(pathId, ss->CdcStreams, CdcStreams);
+}
- CdcStreams.emplace(pathId, nullptr);
+void TMemoryChanges::GrabCdcStream(TSchemeShard* ss, const TPathId& pathId) {
+ Grab<TCdcStreamInfo>(pathId, ss->CdcStreams, CdcStreams);
}
void TMemoryChanges::GrabNewTableSnapshot(TSchemeShard* ss, const TPathId& pathId, TTxId snapshotTxId) {
Y_VERIFY(!ss->TablesWithSnapshots.contains(pathId));
-
TablesWithSnapshots.emplace(pathId, snapshotTxId);
}
void TMemoryChanges::GrabNewLongLock(TSchemeShard* ss, const TPathId& pathId) {
Y_VERIFY(!ss->LockedPaths.contains(pathId));
-
LockedPaths.emplace(pathId, InvalidTxId); // will be removed on UnDo()
}
void TMemoryChanges::GrabLongLock(TSchemeShard* ss, const TPathId& pathId, TTxId lockTxId) {
Y_VERIFY(ss->LockedPaths.contains(pathId));
Y_VERIFY(ss->LockedPaths.at(pathId) == lockTxId);
-
LockedPaths.emplace(pathId, lockTxId); // will be restored on UnDo()
}
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_memory_changes.h b/ydb/core/tx/schemeshard/schemeshard__operation_memory_changes.h
index 359f52d320..f5b73942c4 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_memory_changes.h
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_memory_changes.h
@@ -4,8 +4,6 @@
#include "schemeshard_path_element.h"
#include "schemeshard_info_types.h"
-#include <ydb/core/tablet_flat/tablet_flat_executor.h>
-
#include <util/generic/ptr.h>
#include <util/generic/stack.h>
@@ -61,6 +59,7 @@ public:
void GrabIndex(TSchemeShard* ss, const TPathId& pathId);
void GrabNewCdcStream(TSchemeShard* ss, const TPathId& pathId);
+ void GrabCdcStream(TSchemeShard* ss, const TPathId& pathId);
void GrabNewTableSnapshot(TSchemeShard* ss, const TPathId& pathId, TTxId snapshotTxId);