7
7
#include < ydb/core/tx/columnshard/blobs_action/abstract/storages_manager.h>
8
8
#include < ydb/core/tx/columnshard/common/blob.h>
9
9
#include < ydb/core/tx/columnshard/common/path_id.h>
10
+ #include < ydb/core/tx/columnshard/common/thread_safe_optional.h>
10
11
#include < ydb/core/tx/columnshard/engines/scheme/versions/abstract_scheme.h>
11
12
12
13
#include < ydb/library/accessor/accessor.h>
13
14
#include < ydb/library/formats/arrow/replace_key.h>
14
15
15
16
#include < util/generic/hash_set.h>
16
- # include < atomic >
17
+
17
18
18
19
namespace NKikimrColumnShardDataSharingProto {
19
20
class TPortionInfo ;
@@ -85,37 +86,12 @@ class TPortionInfo {
85
86
friend class TCompactedPortionInfo ;
86
87
friend class TWrittenPortionInfo ;
87
88
88
- TPortionInfo (const TPortionInfo& other)
89
- : PathId(other.PathId)
90
- , PortionId(other.PortionId)
91
- , RemoveSnapshot(other.RemoveSnapshot)
92
- , RemoveSnapshotDefined(other.RemoveSnapshotDefined.load(std::memory_order_acquire))
93
- , SchemaVersion(other.SchemaVersion)
94
- , ShardingVersion(other.ShardingVersion)
95
- , Meta(other.Meta)
96
- , RuntimeFeatures(other.RuntimeFeatures) {
97
- }
98
-
99
- TPortionInfo& operator =(const TPortionInfo& other) {
100
- if (this == &other) {
101
- return *this ;
102
- }
103
-
104
- PathId = other.PathId ;
105
- PortionId = other.PortionId ;
106
- RemoveSnapshot = other.RemoveSnapshot ;
107
- RemoveSnapshotDefined.store (other.RemoveSnapshotDefined .load (std::memory_order_acquire), std::memory_order_release);
108
- SchemaVersion = other.SchemaVersion ;
109
- ShardingVersion = other.ShardingVersion ;
110
- Meta = other.Meta ;
111
- RuntimeFeatures = other.RuntimeFeatures ;
112
- return *this ;
113
- }
89
+ TPortionInfo (const TPortionInfo&) = default ;
90
+ TPortionInfo& operator =(const TPortionInfo&) = default ;
114
91
115
92
TInternalPathId PathId;
116
93
ui64 PortionId = 0 ; // Id of independent (overlayed by PK) portion of data in pathId
117
- TSnapshot RemoveSnapshot = TSnapshot::Zero();
118
- std::atomic<bool > RemoveSnapshotDefined = false ;
94
+ TThreadSafeOptional<TSnapshot> RemoveSnapshot;
119
95
ui64 SchemaVersion = 0 ;
120
96
std::optional<ui64> ShardingVersion;
121
97
@@ -193,33 +169,8 @@ class TPortionInfo {
193
169
TPortionInfo (TPortionMeta&& meta)
194
170
: Meta(std::move(meta)) {
195
171
}
196
-
197
- TPortionInfo (TPortionInfo&& other) noexcept
198
- : PathId(std::move(other.PathId))
199
- , PortionId(other.PortionId)
200
- , RemoveSnapshot(std::move(other.RemoveSnapshot))
201
- , RemoveSnapshotDefined(other.RemoveSnapshotDefined.load(std::memory_order_acquire))
202
- , SchemaVersion(other.SchemaVersion)
203
- , ShardingVersion(std::move(other.ShardingVersion))
204
- , Meta(std::move(other.Meta))
205
- , RuntimeFeatures(other.RuntimeFeatures) {
206
- }
207
-
208
- TPortionInfo& operator =(TPortionInfo&& other) noexcept {
209
- if (this == &other) {
210
- return *this ;
211
- }
212
-
213
- PathId = std::move (other.PathId );
214
- PortionId = other.PortionId ;
215
- RemoveSnapshot = std::move (other.RemoveSnapshot );
216
- RemoveSnapshotDefined.store (other.RemoveSnapshotDefined .load (std::memory_order_acquire), std::memory_order_release);
217
- SchemaVersion = other.SchemaVersion ;
218
- ShardingVersion = std::move (other.ShardingVersion );
219
- Meta = std::move (other.Meta );
220
- RuntimeFeatures = other.RuntimeFeatures ;
221
- return *this ;
222
- }
172
+ TPortionInfo (TPortionInfo&&) = default ;
173
+ TPortionInfo& operator =(TPortionInfo&&) = default ;
223
174
224
175
virtual void FillDefaultColumn (NAssembling::TColumnAssemblingInfo& column, const std::optional<TSnapshot>& defaultSnapshot) const = 0;
225
176
@@ -264,9 +215,8 @@ class TPortionInfo {
264
215
}
265
216
266
217
void SetRemoveSnapshot (const TSnapshot& snap) {
267
- AFL_VERIFY (!RemoveSnapshotDefined.load ());
268
- RemoveSnapshot = snap;
269
- RemoveSnapshotDefined.store (true , std::memory_order_release);
218
+ AFL_VERIFY (!HasRemoveSnapshot ());
219
+ RemoveSnapshot.Set (snap);
270
220
}
271
221
272
222
void SetRemoveSnapshot (const ui64 planStep, const ui64 txId) {
@@ -391,7 +341,7 @@ class TPortionInfo {
391
341
TString DebugString (const bool withDetails = false ) const ;
392
342
393
343
bool HasRemoveSnapshot () const {
394
- return RemoveSnapshotDefined. load (std::memory_order_acquire );
344
+ return RemoveSnapshot. Has ( );
395
345
}
396
346
397
347
bool IsRemovedFor (const TSnapshot& snapshot) const {
@@ -427,13 +377,13 @@ class TPortionInfo {
427
377
}
428
378
429
379
const TSnapshot& GetRemoveSnapshotVerified () const {
430
- AFL_VERIFY (RemoveSnapshotDefined. load (std::memory_order_acquire ));
431
- return RemoveSnapshot;
380
+ AFL_VERIFY (HasRemoveSnapshot ( ));
381
+ return RemoveSnapshot. Get () ;
432
382
}
433
383
434
384
std::optional<TSnapshot> GetRemoveSnapshotOptional () const {
435
- if (RemoveSnapshotDefined. load (std::memory_order_acquire )) {
436
- return RemoveSnapshot;
385
+ if (HasRemoveSnapshot ( )) {
386
+ return RemoveSnapshot. Get () ;
437
387
} else {
438
388
return {};
439
389
}
@@ -445,7 +395,7 @@ class TPortionInfo {
445
395
}
446
396
447
397
bool IsVisible (const TSnapshot& snapshot, const bool checkCommitSnapshot = true ) const {
448
- const bool visible = (!RemoveSnapshotDefined. load (std::memory_order_acquire ) || snapshot < GetRemoveSnapshotVerified ()) && DoIsVisible (snapshot, checkCommitSnapshot);
398
+ const bool visible = (!HasRemoveSnapshot ( ) || snapshot < GetRemoveSnapshotVerified ()) && DoIsVisible (snapshot, checkCommitSnapshot);
449
399
450
400
AFL_TRACE (NKikimrServices::TX_COLUMNSHARD)(" event" , " IsVisible" )(" analyze_portion" , DebugString ())(" visible" , visible)(
451
401
" snapshot" , snapshot.DebugString ());
0 commit comments