Skip to content

Commit 3283fdc

Browse files
authored
TRowVersion::Serialize (#11285)
1 parent 12a6cb7 commit 3283fdc

File tree

6 files changed

+23
-12
lines changed

6 files changed

+23
-12
lines changed

ydb/core/base/row_version.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
#include "row_version.h"
22

3+
#include <ydb/core/protos/base.pb.h>
4+
35
#include <util/stream/output.h>
46

7+
namespace NKikimr {
8+
9+
void TRowVersion::Serialize(NKikimrProto::TRowVersion& proto) const {
10+
proto.SetStep(Step);
11+
proto.SetTxId(TxId);
12+
}
13+
14+
} // NKikimr
15+
516
Y_DECLARE_OUT_SPEC(, NKikimr::TRowVersion, stream, value) {
617
if (value == NKikimr::TRowVersion::Min()) {
718
stream << "v{min}";

ydb/core/base/row_version.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
#include <util/system/types.h>
44
#include <util/generic/ylimits.h>
55

6+
namespace NKikimrProto {
7+
class TRowVersion;
8+
}
9+
610
namespace NKikimr {
711

812
/**
@@ -71,6 +75,8 @@ namespace NKikimr {
7175
return ++copy;
7276
}
7377

78+
void Serialize(NKikimrProto::TRowVersion& proto) const;
79+
7480
friend constexpr bool operator==(const TRowVersion& a, const TRowVersion& b) {
7581
return a.Step == b.Step && a.TxId == b.TxId;
7682
}

ydb/core/tx/datashard/datashard__read_iterator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,7 @@ class TReader {
712712
record.SetSeqNo(State.SeqNo + 1);
713713

714714
if (!State.IsHeadRead) {
715-
record.MutableSnapshot()->SetStep(State.ReadVersion.Step);
716-
record.MutableSnapshot()->SetTxId(State.ReadVersion.TxId);
715+
State.ReadVersion.Serialize(*record.MutableSnapshot());
717716
}
718717

719718
return useful;

ydb/core/tx/datashard/datashard_ut_read_iterator.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,8 +3143,7 @@ Y_UNIT_TEST_SUITE(DataShardReadIterator) {
31433143
// Read in a transaction.
31443144
auto readRequest1 = helper.GetBaseReadRequest(tableName, 1);
31453145
readRequest1->Record.SetLockTxId(lockTxId);
3146-
readRequest1->Record.MutableSnapshot()->SetStep(snapshot.Step);
3147-
readRequest1->Record.MutableSnapshot()->SetTxId(snapshot.TxId);
3146+
snapshot.Serialize(*readRequest1->Record.MutableSnapshot());
31483147
AddKeyQuery(*readRequest1, {1, 1, 1});
31493148

31503149
auto readResult1 = helper.SendRead(tableName, readRequest1.release());
@@ -4596,8 +4595,7 @@ Y_UNIT_TEST_SUITE(DataShardReadIteratorConsistency) {
45964595
auto* msg = ev->Get();
45974596
if (!msg->Record.HasSnapshot()) {
45984597
Cerr << "... forcing read snapshot " << txVersion << Endl;
4599-
msg->Record.MutableSnapshot()->SetStep(txVersion.Step);
4600-
msg->Record.MutableSnapshot()->SetTxId(txVersion.TxId);
4598+
txVersion.Serialize(*msg->Record.MutableSnapshot());
46014599
}
46024600
}
46034601
});

ydb/core/tx/datashard/datashard_ut_snapshot.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,8 +1187,7 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) {
11871187
Last.MvccSnapshot.Step = record.GetSnapshot().GetStep();
11881188
Last.MvccSnapshot.TxId = record.GetSnapshot().GetTxId();
11891189
} else if (Inject.MvccSnapshot) {
1190-
record.MutableSnapshot()->SetStep(Inject.MvccSnapshot.Step);
1191-
record.MutableSnapshot()->SetTxId(Inject.MvccSnapshot.TxId);
1190+
Inject.MvccSnapshot.Serialize(*record.MutableSnapshot());
11921191
Cerr << "TEvRead: injected MvccSnapshot" << Endl;
11931192
}
11941193
break;
@@ -1788,8 +1787,7 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) {
17881787
record.MutableTableId()->SetOwnerId(tableId.PathId.OwnerId);
17891788
record.MutableTableId()->SetTableId(tableId.PathId.LocalPathId);
17901789
record.MutableTableId()->SetSchemaVersion(tableId.SchemaVersion);
1791-
record.MutableSnapshot()->SetStep(snapshot.Step);
1792-
record.MutableSnapshot()->SetTxId(snapshot.TxId);
1790+
snapshot.Serialize(*record.MutableSnapshot());
17931791
for (ui32 columnId : columns) {
17941792
record.AddColumns(columnId);
17951793
}

ydb/core/tx/datashard/ut_common/datashard_ut_common.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2685,8 +2685,7 @@ std::unique_ptr<TEvDataShard::TEvRead> GetBaseReadRequest(
26852685
record.MutableTableId()->SetSchemaVersion(description.GetTableSchemaVersion());
26862686

26872687
if (readVersion) {
2688-
record.MutableSnapshot()->SetStep(readVersion.Step);
2689-
record.MutableSnapshot()->SetTxId(readVersion.TxId);
2688+
readVersion.Serialize(*record.MutableSnapshot());
26902689
}
26912690

26922691
record.SetResultFormat(format);

0 commit comments

Comments
 (0)