Skip to content

Commit 87b27e1

Browse files
committed
Review fixes
1 parent 540009a commit 87b27e1

File tree

5 files changed

+50
-37
lines changed

5 files changed

+50
-37
lines changed

ydb/core/tx/datashard/datashard__write.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,25 @@ ui64 EvWrite::Convertor::GetProposeFlags(NKikimrDataEvents::TEvWrite::ETxMode tx
256256
}
257257

258258
NKikimrDataEvents::TEvWrite::ETxMode EvWrite::Convertor::GetTxMode(ui64 flags) {
259-
NKikimrDataEvents::TEvWrite::ETxMode txMode;
260-
if ((flags & TTxFlags::Immediate) && !(flags & TTxFlags::ForceOnline))
261-
txMode = NKikimrDataEvents::TEvWrite::ETxMode::TEvWrite_ETxMode_MODE_IMMEDIATE;
262-
else if (flags & TTxFlags::VolatilePrepare)
263-
txMode = NKikimrDataEvents::TEvWrite::ETxMode::TEvWrite_ETxMode_MODE_VOLATILE_PREPARE;
264-
else
265-
txMode = NKikimrDataEvents::TEvWrite::ETxMode::TEvWrite_ETxMode_MODE_PREPARE;
266-
return txMode;
259+
if ((flags & TTxFlags::Immediate) && !(flags & TTxFlags::ForceOnline)) {
260+
return NKikimrDataEvents::TEvWrite::ETxMode::TEvWrite_ETxMode_MODE_IMMEDIATE;
261+
}
262+
else if (flags & TTxFlags::VolatilePrepare) {
263+
return NKikimrDataEvents::TEvWrite::ETxMode::TEvWrite_ETxMode_MODE_VOLATILE_PREPARE;
264+
}
265+
else {
266+
return NKikimrDataEvents::TEvWrite::ETxMode::TEvWrite_ETxMode_MODE_PREPARE;
267+
}
268+
}
269+
270+
NKikimrTxDataShard::TEvProposeTransactionResult::EStatus EvWrite::Convertor::GetStatus(NKikimrDataEvents::TEvWriteResult::EStatus status) {
271+
switch (status) {
272+
case NKikimrDataEvents::TEvWriteResult::STATUS_COMPLETED:
273+
return NKikimrTxDataShard::TEvProposeTransactionResult::COMPLETE;
274+
case NKikimrDataEvents::TEvWriteResult::STATUS_PREPARED:
275+
return NKikimrTxDataShard::TEvProposeTransactionResult::PREPARED;
276+
default:
277+
return NKikimrTxDataShard::TEvProposeTransactionResult::ERROR;
278+
}
267279
}
268280
}

ydb/core/tx/datashard/datashard_ut_write.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Y_UNIT_TEST_SUITE(DataShardWrite) {
3535
auto opts = TShardedTableOptions();
3636
auto [shards, tableId] = CreateShardedTable(server, sender, "/Root", "table-1", opts);
3737

38-
EvWriteRows rows = EvWrite ? EvWriteRows{{{0, 1}}, {{2, 3}}, {{4, 5}}} : EvWriteRows{};
38+
auto rows = EvWrite ? TEvWriteRows{{{0, 1}}, {{2, 3}}, {{4, 5}}} : TEvWriteRows{};
3939
auto upsertObserver = ReplaceEvProposeTransactionWithEvWrite(runtime, rows);
4040
auto upsertResultObserver = ReplaceEvProposeTransactionResultWithEvWrite(runtime, rows);
4141

ydb/core/tx/datashard/datashard_write.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <ydb/library/actors/core/event.h>
44
#include <ydb/core/protos/data_events.pb.h>
5+
#include <ydb/core/protos/tx_datashard.pb.h>
56

67
#include <util/generic/ptr.h>
78

@@ -14,5 +15,6 @@ class Convertor {
1415
static ui64 GetTxId(const TAutoPtr<IEventHandle>& ev);
1516
static ui64 GetProposeFlags(NKikimrDataEvents::TEvWrite::ETxMode txMode);
1617
static NKikimrDataEvents::TEvWrite::ETxMode GetTxMode(ui64 flags);
18+
static NKikimrTxDataShard::TEvProposeTransactionResult::EStatus GetStatus(NKikimrDataEvents::TEvWriteResult::EStatus status);
1719
};
1820
}

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,11 +1880,11 @@ NKikimrDataEvents::TEvWriteResult Write(TTestActorRuntime& runtime, TActorId sen
18801880

18811881

18821882

1883-
TTestActorRuntimeBase::TEventObserverHolder ReplaceEvProposeTransactionWithEvWrite(TTestActorRuntime& runtime, EvWriteRows& rows) {
1883+
TTestActorRuntimeBase::TEventObserverHolder ReplaceEvProposeTransactionWithEvWrite(TTestActorRuntime& runtime, TEvWriteRows& rows) {
18841884
if (rows.empty())
18851885
return {};
18861886

1887-
return TTestActorRuntimeBase::TEventObserverHolder(runtime.AddObserver([&rows](TAutoPtr<IEventHandle>& event) {
1887+
return runtime.AddObserver([&rows](TAutoPtr<IEventHandle>& event) {
18881888
if (event->GetTypeRewrite() != TEvDataShard::EvProposeTransaction)
18891889
return;
18901890

@@ -1945,14 +1945,14 @@ TTestActorRuntimeBase::TEventObserverHolder ReplaceEvProposeTransactionWithEvWri
19451945
auto handle = new IEventHandle(event->Recipient, event->Sender, evWrite.release(), 0, event->Cookie);
19461946
handle->Rewrite(handle->GetTypeRewrite(), event->GetRecipientRewrite());
19471947
event.Reset(handle);
1948-
}));
1948+
});
19491949
}
19501950

1951-
TTestActorRuntimeBase::TEventObserverHolder ReplaceEvProposeTransactionResultWithEvWrite(TTestActorRuntime& runtime, EvWriteRows& rows) {
1951+
TTestActorRuntimeBase::TEventObserverHolder ReplaceEvProposeTransactionResultWithEvWrite(TTestActorRuntime& runtime, TEvWriteRows& rows) {
19521952
if (rows.empty())
19531953
return {};
19541954

1955-
return TTestActorRuntimeBase::TEventObserverHolder(runtime.AddObserver([&rows](TAutoPtr<IEventHandle>& event) {
1955+
return runtime.AddObserver([&rows](TAutoPtr<IEventHandle>& event) {
19561956
if (event->GetTypeRewrite() != NEvents::TDataEvents::EvWriteResult)
19571957
return;
19581958

@@ -1964,18 +1964,15 @@ TTestActorRuntimeBase::TEventObserverHolder ReplaceEvProposeTransactionResultWit
19641964
// Construct new EvProposeTransactionResult
19651965
ui64 txId = record.GetTxId();
19661966
ui64 origin = record.GetOrigin();
1967-
auto status = NKikimrTxDataShard::TEvProposeTransactionResult::ERROR;
1968-
if (record.GetStatus() == NKikimrDataEvents::TEvWriteResult::STATUS_COMPLETED)
1969-
status = NKikimrTxDataShard::TEvProposeTransactionResult::COMPLETE;
1970-
else if (record.GetStatus() == NKikimrDataEvents::TEvWriteResult::STATUS_PREPARED)
1971-
status = NKikimrTxDataShard::TEvProposeTransactionResult::PREPARED;
1967+
auto status = NKikimr::NDataShard::EvWrite::Convertor::GetStatus(record.GetStatus());
1968+
19721969
auto evResult = std::make_unique<TEvDataShard::TEvProposeTransactionResult>(NKikimrTxDataShard::TX_KIND_DATA, origin, txId, status);
19731970

19741971
// Replace event
19751972
auto handle = new IEventHandle(event->Recipient, event->Sender, evResult.release(), 0, event->Cookie);
19761973
handle->Rewrite(handle->GetTypeRewrite(), event->GetRecipientRewrite());
19771974
event.Reset(handle);
1978-
}));
1975+
});
19791976
}
19801977

19811978
void UploadRows(TTestActorRuntime& runtime, const TString& tablePath, const TVector<std::pair<TString, Ydb::Type_PrimitiveTypeId>>& types, const TVector<TCell>& keys, const TVector<TCell>& values)
@@ -2006,9 +2003,10 @@ void WaitTabletBecomesOffline(TServer::TPtr server, ui64 tabletId)
20062003
struct IsShardStateChange
20072004
{
20082005
IsShardStateChange(ui64 tabletId)
2009-
: TabletId(tabletId)
2010-
{
2011-
}
2006+
:
2007+
TabletId(tabletId)
2008+
{
2009+
}
20122010

20132011
bool operator()(IEventHandle& ev)
20142012
{
@@ -2062,7 +2060,8 @@ namespace {
20622060
, Snapshot(snapshot)
20632061
, Ordered(ordered)
20642062
, State(pause ? EState::PauseWait : EState::Normal)
2065-
{ }
2063+
{
2064+
}
20662065

20672066
void Bootstrap(const TActorContext& ctx) {
20682067
auto request = MakeHolder<TEvTxUserProxy::TEvProposeTransaction>();

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,8 @@ void ExecSQL(Tests::TServer::TPtr server,
714714
NKikimrDataEvents::TEvWriteResult Write(TTestActorRuntime& runtime, TActorId sender, ui64 shardId, std::unique_ptr<NEvents::TDataEvents::TEvWrite>&& request, NKikimrDataEvents::TEvWriteResult::EStatus expectedStatus = NKikimrDataEvents::TEvWriteResult::STATUS_UNSPECIFIED, NWilson::TTraceId traceId = {});
715715
NKikimrDataEvents::TEvWriteResult Write(TTestActorRuntime& runtime, TActorId sender, ui64 shardId, ui64 tableId, const TVector<TShardedTableOptions::TColumn>& columns, ui32 rowCount, ui64 txId, NKikimrDataEvents::TEvWrite::ETxMode txMode, NKikimrDataEvents::TEvWriteResult::EStatus expectedStatus = NKikimrDataEvents::TEvWriteResult::STATUS_UNSPECIFIED, NWilson::TTraceId traceId = {});
716716

717-
struct EvWriteRow {
718-
EvWriteRow(std::initializer_list<ui32> init) {
717+
struct TEvWriteRow {
718+
TEvWriteRow(std::initializer_list<ui32> init) {
719719
for (ui32 value : init) {
720720
Cells.emplace_back(TCell((const char*)&value, sizeof(ui32)));
721721
}
@@ -729,29 +729,29 @@ struct EvWriteRow {
729729
Completed
730730
} Status = Init;
731731
};
732-
class EvWriteRows : public std::vector<EvWriteRow> {
732+
class TEvWriteRows : public std::vector<TEvWriteRow> {
733733
public:
734-
EvWriteRows() = default;
735-
EvWriteRows(std::initializer_list<EvWriteRow> init) :
736-
std::vector<EvWriteRow>(init) { }
734+
TEvWriteRows() = default;
735+
TEvWriteRows(std::initializer_list<TEvWriteRow> init) :
736+
std::vector<TEvWriteRow>(init) { }
737737

738-
const EvWriteRow& ProcessNextRow() {
739-
auto processedRow = std::find_if(begin(), end(), [](const auto& row) { return row.Status == EvWriteRow::EStatus::Init; });
738+
const TEvWriteRow& ProcessNextRow() {
739+
auto processedRow = std::find_if(begin(), end(), [](const auto& row) { return row.Status == TEvWriteRow::EStatus::Init; });
740740
Y_VERIFY_S(processedRow != end(), "There should be at least one EvWrite row to process.");
741-
processedRow->Status = EvWriteRow::EStatus::Processing;
741+
processedRow->Status = TEvWriteRow::EStatus::Processing;
742742
Cerr << "Processing next EvWrite row\n";
743743
return *processedRow;
744744
}
745745
void CompleteNextRow() {
746-
auto processedRow = std::find_if(begin(), end(), [](const auto& row) { return row.Status == EvWriteRow::EStatus::Processing; });
746+
auto processedRow = std::find_if(begin(), end(), [](const auto& row) { return row.Status == TEvWriteRow::EStatus::Processing; });
747747
Y_VERIFY_S(processedRow != end(), "There should be at lest one EvWrite row processing.");
748-
processedRow->Status = EvWriteRow::EStatus::Completed;
748+
processedRow->Status = TEvWriteRow::EStatus::Completed;
749749
Cerr << "Completed next EvWrite row\n";
750750
}
751751
};
752752

753-
TTestActorRuntimeBase::TEventObserverHolder ReplaceEvProposeTransactionWithEvWrite(TTestActorRuntime& runtime, EvWriteRows& rows);
754-
TTestActorRuntimeBase::TEventObserverHolder ReplaceEvProposeTransactionResultWithEvWrite(TTestActorRuntime& runtime, EvWriteRows& rows);
753+
TTestActorRuntimeBase::TEventObserverHolder ReplaceEvProposeTransactionWithEvWrite(TTestActorRuntime& runtime, TEvWriteRows& rows);
754+
TTestActorRuntimeBase::TEventObserverHolder ReplaceEvProposeTransactionResultWithEvWrite(TTestActorRuntime& runtime, TEvWriteRows& rows);
755755

756756
void UploadRows(TTestActorRuntime& runtime, const TString& tablePath, const TVector<std::pair<TString, Ydb::Type_PrimitiveTypeId>>& types, const TVector<TCell>& keys, const TVector<TCell>& values);
757757

0 commit comments

Comments
 (0)