-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92a1247
commit 53620be
Showing
10 changed files
with
531 additions
and
502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#include "shard_reader.h" | ||
|
||
namespace NKikimr::NTxUT { | ||
|
||
std::unique_ptr<NKikimr::TEvDataShard::TEvKqpScan> TShardReader::BuildStartEvent() const { | ||
auto ev = std::make_unique<TEvDataShard::TEvKqpScan>(); | ||
ev->Record.SetLocalPathId(PathId); | ||
ev->Record.MutableSnapshot()->SetStep(Snapshot.GetPlanStep()); | ||
ev->Record.MutableSnapshot()->SetTxId(Snapshot.GetTxId()); | ||
|
||
ev->Record.SetStatsMode(NYql::NDqProto::DQ_STATS_MODE_FULL); | ||
ev->Record.SetTxId(Snapshot.GetTxId()); | ||
|
||
ev->Record.SetReverse(Reverse); | ||
ev->Record.SetItemsLimit(Limit); | ||
|
||
ev->Record.SetDataFormat(NKikimrDataEvents::FORMAT_ARROW); | ||
|
||
auto protoRanges = ev->Record.MutableRanges(); | ||
protoRanges->Reserve(Ranges.size()); | ||
for (auto& range : Ranges) { | ||
auto newRange = protoRanges->Add(); | ||
range.Serialize(*newRange); | ||
} | ||
|
||
if (ProgramProto) { | ||
NKikimrSSA::TOlapProgram olapProgram; | ||
{ | ||
TString programBytes; | ||
TStringOutput stream(programBytes); | ||
ProgramProto->SerializeToArcadiaStream(&stream); | ||
olapProgram.SetProgram(programBytes); | ||
} | ||
{ | ||
TString programBytes; | ||
TStringOutput stream(programBytes); | ||
olapProgram.SerializeToArcadiaStream(&stream); | ||
ev->Record.SetOlapProgram(programBytes); | ||
} | ||
ev->Record.SetOlapProgramType(NKikimrSchemeOp::EOlapProgramType::OLAP_PROGRAM_SSA_PROGRAM_WITH_PARAMETERS); | ||
} else if (SerializedProgram) { | ||
ev->Record.SetOlapProgram(*SerializedProgram); | ||
ev->Record.SetOlapProgramType(NKikimrSchemeOp::EOlapProgramType::OLAP_PROGRAM_SSA_PROGRAM_WITH_PARAMETERS); | ||
} | ||
|
||
return ev; | ||
} | ||
|
||
NKikimr::NTxUT::TShardReader& TShardReader::SetReplyColumns(const std::vector<TString>& replyColumns) { | ||
AFL_VERIFY(!SerializedProgram); | ||
if (!ProgramProto) { | ||
ProgramProto = NKikimrSSA::TProgram(); | ||
} | ||
for (auto&& command : *ProgramProto->MutableCommand()) { | ||
if (command.HasProjection()) { | ||
NKikimrSSA::TProgram::TProjection proj; | ||
for (auto&& i : replyColumns) { | ||
proj.AddColumns()->SetName(i); | ||
} | ||
*command.MutableProjection() = proj; | ||
return *this; | ||
} | ||
} | ||
{ | ||
auto* command = ProgramProto->AddCommand(); | ||
NKikimrSSA::TProgram::TProjection proj; | ||
for (auto&& i : replyColumns) { | ||
proj.AddColumns()->SetName(i); | ||
} | ||
*command->MutableProjection() = proj; | ||
} | ||
return *this; | ||
} | ||
|
||
NKikimr::NTxUT::TShardReader& TShardReader::SetReplyColumnIds(const std::vector<ui32>& replyColumnIds) { | ||
AFL_VERIFY(!SerializedProgram); | ||
if (!ProgramProto) { | ||
ProgramProto = NKikimrSSA::TProgram(); | ||
} | ||
for (auto&& command : *ProgramProto->MutableCommand()) { | ||
if (command.HasProjection()) { | ||
NKikimrSSA::TProgram::TProjection proj; | ||
for (auto&& i : replyColumnIds) { | ||
proj.AddColumns()->SetId(i); | ||
} | ||
*command.MutableProjection() = proj; | ||
return *this; | ||
} | ||
} | ||
{ | ||
auto* command = ProgramProto->AddCommand(); | ||
NKikimrSSA::TProgram::TProjection proj; | ||
for (auto&& i : replyColumnIds) { | ||
proj.AddColumns()->SetId(i); | ||
} | ||
*command->MutableProjection() = proj; | ||
} | ||
return *this; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "shard_writer.h" | ||
|
||
#include <ydb/core/formats/arrow/arrow_helpers.h> | ||
#include <ydb/core/testlib/tablet_helpers.h> | ||
#include <ydb/core/tx/columnshard/defs.h> | ||
#include <ydb/core/tx/data_events/events.h> | ||
#include <ydb/core/tx/data_events/payload_helper.h> | ||
|
||
namespace NKikimr::NTxUT { | ||
|
||
NKikimrDataEvents::TEvWriteResult::EStatus TShardWriter::StartCommit(const ui64 txId) { | ||
auto evCommit = std::make_unique<NKikimr::NEvents::TDataEvents::TEvWrite>(txId, NKikimrDataEvents::TEvWrite::MODE_IMMEDIATE); | ||
evCommit->Record.MutableLocks()->SetOp(NKikimrDataEvents::TKqpLocks::Commit); | ||
auto* lock = evCommit->Record.MutableLocks()->AddLocks(); | ||
lock->SetLockId(LockId); | ||
ForwardToTablet(Runtime, TTestTxConfig::TxTablet0, Sender, evCommit.release()); | ||
|
||
TAutoPtr<NActors::IEventHandle> handle; | ||
auto event = Runtime.GrabEdgeEvent<NKikimr::NEvents::TDataEvents::TEvWriteResult>(handle); | ||
AFL_VERIFY(event); | ||
|
||
return event->Record.GetStatus(); | ||
} | ||
|
||
NKikimrDataEvents::TEvWriteResult::EStatus TShardWriter::Abort(const ui64 txId) { | ||
auto evCommit = std::make_unique<NKikimr::NEvents::TDataEvents::TEvWrite>(txId, NKikimrDataEvents::TEvWrite::MODE_IMMEDIATE); | ||
evCommit->Record.MutableLocks()->SetOp(NKikimrDataEvents::TKqpLocks::Rollback); | ||
auto* lock = evCommit->Record.MutableLocks()->AddLocks(); | ||
lock->SetLockId(LockId); | ||
ForwardToTablet(Runtime, TTestTxConfig::TxTablet0, Sender, evCommit.release()); | ||
|
||
TAutoPtr<NActors::IEventHandle> handle; | ||
auto event = Runtime.GrabEdgeEvent<NKikimr::NEvents::TDataEvents::TEvWriteResult>(handle); | ||
AFL_VERIFY(event); | ||
|
||
return event->Record.GetStatus(); | ||
} | ||
|
||
NKikimrDataEvents::TEvWriteResult::EStatus TShardWriter::Write( | ||
const std::shared_ptr<arrow::RecordBatch>& batch, const std::vector<ui32>& columnIds, const ui64 txId) { | ||
TString blobData = NArrow::SerializeBatchNoCompression(batch); | ||
// AFL_VERIFY(blobData.size() < NColumnShard::TLimits::GetMaxBlobSize()); | ||
|
||
auto evWrite = std::make_unique<NKikimr::NEvents::TDataEvents::TEvWrite>(NKikimrDataEvents::TEvWrite::MODE_IMMEDIATE); | ||
evWrite->SetTxId(txId); | ||
evWrite->SetLockId(LockId, LockNodeId); | ||
const ui64 payloadIndex = NEvWrite::TPayloadWriter<NKikimr::NEvents::TDataEvents::TEvWrite>(*evWrite).AddDataToPayload(std::move(blobData)); | ||
evWrite->AddOperation(NKikimrDataEvents::TEvWrite::TOperation::OPERATION_REPLACE, { OwnerId, PathId, SchemaVersion }, columnIds, | ||
payloadIndex, NKikimrDataEvents::FORMAT_ARROW); | ||
|
||
ForwardToTablet(Runtime, TabletId, Sender, evWrite.release()); | ||
|
||
TAutoPtr<NActors::IEventHandle> handle; | ||
auto event = Runtime.GrabEdgeEvent<NKikimr::NEvents::TDataEvents::TEvWriteResult>(handle); | ||
AFL_VERIFY(event); | ||
|
||
AFL_VERIFY(event->Record.GetOrigin() == PathId); | ||
AFL_VERIFY(event->Record.GetTxId() == LockId); | ||
|
||
return event->Record.GetStatus(); | ||
} | ||
|
||
} // namespace NKikimr::NTxUT |
Oops, something went wrong.