Skip to content

Commit

Permalink
TRowVersion::Serialize (#11285)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberROFL authored Nov 5, 2024
1 parent 12a6cb7 commit 3283fdc
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
11 changes: 11 additions & 0 deletions ydb/core/base/row_version.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
#include "row_version.h"

#include <ydb/core/protos/base.pb.h>

#include <util/stream/output.h>

namespace NKikimr {

void TRowVersion::Serialize(NKikimrProto::TRowVersion& proto) const {
proto.SetStep(Step);
proto.SetTxId(TxId);
}

} // NKikimr

Y_DECLARE_OUT_SPEC(, NKikimr::TRowVersion, stream, value) {
if (value == NKikimr::TRowVersion::Min()) {
stream << "v{min}";
Expand Down
6 changes: 6 additions & 0 deletions ydb/core/base/row_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include <util/system/types.h>
#include <util/generic/ylimits.h>

namespace NKikimrProto {
class TRowVersion;
}

namespace NKikimr {

/**
Expand Down Expand Up @@ -71,6 +75,8 @@ namespace NKikimr {
return ++copy;
}

void Serialize(NKikimrProto::TRowVersion& proto) const;

friend constexpr bool operator==(const TRowVersion& a, const TRowVersion& b) {
return a.Step == b.Step && a.TxId == b.TxId;
}
Expand Down
3 changes: 1 addition & 2 deletions ydb/core/tx/datashard/datashard__read_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,7 @@ class TReader {
record.SetSeqNo(State.SeqNo + 1);

if (!State.IsHeadRead) {
record.MutableSnapshot()->SetStep(State.ReadVersion.Step);
record.MutableSnapshot()->SetTxId(State.ReadVersion.TxId);
State.ReadVersion.Serialize(*record.MutableSnapshot());
}

return useful;
Expand Down
6 changes: 2 additions & 4 deletions ydb/core/tx/datashard/datashard_ut_read_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3143,8 +3143,7 @@ Y_UNIT_TEST_SUITE(DataShardReadIterator) {
// Read in a transaction.
auto readRequest1 = helper.GetBaseReadRequest(tableName, 1);
readRequest1->Record.SetLockTxId(lockTxId);
readRequest1->Record.MutableSnapshot()->SetStep(snapshot.Step);
readRequest1->Record.MutableSnapshot()->SetTxId(snapshot.TxId);
snapshot.Serialize(*readRequest1->Record.MutableSnapshot());
AddKeyQuery(*readRequest1, {1, 1, 1});

auto readResult1 = helper.SendRead(tableName, readRequest1.release());
Expand Down Expand Up @@ -4596,8 +4595,7 @@ Y_UNIT_TEST_SUITE(DataShardReadIteratorConsistency) {
auto* msg = ev->Get();
if (!msg->Record.HasSnapshot()) {
Cerr << "... forcing read snapshot " << txVersion << Endl;
msg->Record.MutableSnapshot()->SetStep(txVersion.Step);
msg->Record.MutableSnapshot()->SetTxId(txVersion.TxId);
txVersion.Serialize(*msg->Record.MutableSnapshot());
}
}
});
Expand Down
6 changes: 2 additions & 4 deletions ydb/core/tx/datashard/datashard_ut_snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1187,8 +1187,7 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) {
Last.MvccSnapshot.Step = record.GetSnapshot().GetStep();
Last.MvccSnapshot.TxId = record.GetSnapshot().GetTxId();
} else if (Inject.MvccSnapshot) {
record.MutableSnapshot()->SetStep(Inject.MvccSnapshot.Step);
record.MutableSnapshot()->SetTxId(Inject.MvccSnapshot.TxId);
Inject.MvccSnapshot.Serialize(*record.MutableSnapshot());
Cerr << "TEvRead: injected MvccSnapshot" << Endl;
}
break;
Expand Down Expand Up @@ -1788,8 +1787,7 @@ Y_UNIT_TEST_SUITE(DataShardSnapshots) {
record.MutableTableId()->SetOwnerId(tableId.PathId.OwnerId);
record.MutableTableId()->SetTableId(tableId.PathId.LocalPathId);
record.MutableTableId()->SetSchemaVersion(tableId.SchemaVersion);
record.MutableSnapshot()->SetStep(snapshot.Step);
record.MutableSnapshot()->SetTxId(snapshot.TxId);
snapshot.Serialize(*record.MutableSnapshot());
for (ui32 columnId : columns) {
record.AddColumns(columnId);
}
Expand Down
3 changes: 1 addition & 2 deletions ydb/core/tx/datashard/ut_common/datashard_ut_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2685,8 +2685,7 @@ std::unique_ptr<TEvDataShard::TEvRead> GetBaseReadRequest(
record.MutableTableId()->SetSchemaVersion(description.GetTableSchemaVersion());

if (readVersion) {
record.MutableSnapshot()->SetStep(readVersion.Step);
record.MutableSnapshot()->SetTxId(readVersion.TxId);
readVersion.Serialize(*record.MutableSnapshot());
}

record.SetResultFormat(format);
Expand Down

0 comments on commit 3283fdc

Please sign in to comment.