diff options
author | nsofya <[email protected]> | 2023-08-04 13:15:12 +0300 |
---|---|---|
committer | nsofya <[email protected]> | 2023-08-04 14:50:22 +0300 |
commit | 01ca4df3ffce38d467ddefc9ba58937f7dc9a6ac (patch) | |
tree | 865bbc05aca324646c9ea4d660a2b13751457451 | |
parent | 0378da6ac1a3be2823cd3031fbf0ae403d962995 (diff) |
Remove unnecessary parsing
5 files changed, 23 insertions, 28 deletions
diff --git a/ydb/core/tx/columnshard/columnshard__write.cpp b/ydb/core/tx/columnshard/columnshard__write.cpp index a3f5e4e9980..39a12f5baf5 100644 --- a/ydb/core/tx/columnshard/columnshard__write.cpp +++ b/ydb/core/tx/columnshard/columnshard__write.cpp @@ -42,8 +42,7 @@ private: bool TTxWrite::InsertOneBlob(TTransactionContext& txc, const TEvPrivate::TEvWriteBlobsResult::TPutBlobData& blobData, const TWriteId writeId) { const TString data = blobData.GetBlobData(); - NKikimrTxColumnShard::TLogicalMetadata meta; - Y_VERIFY(meta.ParseFromString(blobData.GetLogicalMeta())); + const NKikimrTxColumnShard::TLogicalMetadata& meta = blobData.GetLogicalMeta(); const auto& logoBlobId = blobData.GetBlobId(); Y_VERIFY(logoBlobId.IsValid()); @@ -57,7 +56,7 @@ bool TTxWrite::InsertOneBlob(TTransactionContext& txc, const TEvPrivate::TEvWrit const auto& writeMeta(PutBlobResult->Get()->GetWriteMeta()); - NOlap::TInsertedData insertData(0, (ui64)writeId, writeMeta.GetTableId(), writeMeta.GetDedupId(), logoBlobId, blobData.GetLogicalMeta(), time, PutBlobResult->Get()->GetSnapshot()); + NOlap::TInsertedData insertData((ui64)writeId, writeMeta.GetTableId(), writeMeta.GetDedupId(), logoBlobId, meta, time, PutBlobResult->Get()->GetSnapshot()); bool ok = Self->InsertTable->Insert(dbTable, std::move(insertData)); if (ok) { THashSet<TWriteId> writesToAbort = Self->InsertTable->OldWritesToAbort(time); diff --git a/ydb/core/tx/columnshard/columnshard_private_events.h b/ydb/core/tx/columnshard/columnshard_private_events.h index 7fd7da79e3a..af290e25565 100644 --- a/ydb/core/tx/columnshard/columnshard_private_events.h +++ b/ydb/core/tx/columnshard/columnshard_private_events.h @@ -254,18 +254,22 @@ struct TEvPrivate { class TPutBlobData { YDB_READONLY_DEF(TUnifiedBlobId, BlobId); YDB_READONLY_DEF(TString, BlobData); - YDB_ACCESSOR_DEF(TString, LogicalMeta); + YDB_READONLY_DEF(NKikimrTxColumnShard::TLogicalMetadata, LogicalMeta); YDB_ACCESSOR(ui64, RowsCount, 0); YDB_ACCESSOR(ui64, RawBytes, 0); public: TPutBlobData() = default; - TPutBlobData(const TUnifiedBlobId& blobId, const TString& data, ui64 rowsCount, ui64 rawBytes) + TPutBlobData(const TUnifiedBlobId& blobId, const TString& data, ui64 rowsCount, ui64 rawBytes, const TInstant dirtyTime) : BlobId(blobId) , BlobData(data) , RowsCount(rowsCount) , RawBytes(rawBytes) - {} + { + LogicalMeta.SetNumRows(rowsCount); + LogicalMeta.SetRawBytes(rawBytes); + LogicalMeta.SetDirtyWriteTimeSeconds(dirtyTime.Seconds()); + } }; TEvWriteBlobsResult(const NColumnShard::TBlobPutResult::TPtr& putResult, const NEvWrite::TWriteMeta& writeMeta, const NOlap::TSnapshot& snapshot) diff --git a/ydb/core/tx/columnshard/engines/insert_table/data.h b/ydb/core/tx/columnshard/engines/insert_table/data.h index dcbae641e22..a02cd61fb51 100644 --- a/ydb/core/tx/columnshard/engines/insert_table/data.h +++ b/ydb/core/tx/columnshard/engines/insert_table/data.h @@ -1,6 +1,7 @@ #pragma once #include <ydb/core/tx/columnshard/blob.h> #include <ydb/core/tx/columnshard/engines/defs.h> +#include <ydb/core/protos/tx_columnshard.pb.h> namespace NKikimr::NOlap { @@ -16,6 +17,18 @@ public: TInsertedData() = delete; // avoid invalid TInsertedData anywhere + TInsertedData(ui64 writeTxId, ui64 pathId, TString dedupId, const TUnifiedBlobId& blobId, + const NKikimrTxColumnShard::TLogicalMetadata& meta, const TInstant& writeTime, const TSnapshot& schemaVersion) + : WriteTxId(writeTxId) + , PathId(pathId) + , DedupId(dedupId) + , BlobId(blobId) + , DirtyTime(writeTime) + , SchemaVersion(schemaVersion) + { + Y_VERIFY(meta.SerializeToString(&Metadata)); + } + TInsertedData(ui64 shardOrPlan, ui64 writeTxId, ui64 pathId, TString dedupId, const TUnifiedBlobId& blobId, const TString& meta, const TInstant& writeTime, const std::optional<TSnapshot>& schemaVersion) : ShardOrPlan(shardOrPlan) diff --git a/ydb/core/tx/columnshard/engines/writer/indexed_blob_constructor.cpp b/ydb/core/tx/columnshard/engines/writer/indexed_blob_constructor.cpp index 6e62e700576..87232608f2c 100644 --- a/ydb/core/tx/columnshard/engines/writer/indexed_blob_constructor.cpp +++ b/ydb/core/tx/columnshard/engines/writer/indexed_blob_constructor.cpp @@ -26,7 +26,7 @@ IBlobConstructor::EStatus TIndexedWriteController::TBlobConstructor::BuildNext() bool TIndexedWriteController::TBlobConstructor::RegisterBlobId(const TUnifiedBlobId& blobId) { const auto& blobInfo = BlobsSplitted[CurrentIndex - 1]; - Owner.AddBlob(NColumnShard::TEvPrivate::TEvWriteBlobsResult::TPutBlobData(blobId, blobInfo.GetData(), blobInfo.GetRowsCount(), blobInfo.GetRawBytes())); + Owner.BlobData.emplace_back(blobId, blobInfo.GetData(), blobInfo.GetRowsCount(), blobInfo.GetRawBytes(), AppData()->TimeProvider->Now()); return true; } @@ -80,22 +80,4 @@ NOlap::IBlobConstructor::TPtr TIndexedWriteController::GetBlobConstructor() { return BlobConstructor; } -void TIndexedWriteController::AddBlob(NColumnShard::TEvPrivate::TEvWriteBlobsResult::TPutBlobData&& data) { - ui64 dirtyTime = AppData()->TimeProvider->Now().Seconds(); - Y_VERIFY(dirtyTime); - - NKikimrTxColumnShard::TLogicalMetadata outMeta; - outMeta.SetNumRows(data.GetRowsCount()); - outMeta.SetRawBytes(data.GetRawBytes()); - outMeta.SetDirtyWriteTimeSeconds(dirtyTime); - - TString metaString; - if (!outMeta.SerializeToString(&metaString)) { - AFL_ERROR(NKikimrServices::TX_COLUMNSHARD)("event", "ev_write_bad_metadata"); - Y_VERIFY(false); - } - BlobData.push_back(std::move(data)); - BlobData.back().SetLogicalMeta(metaString); -} - } diff --git a/ydb/core/tx/columnshard/engines/writer/indexed_blob_constructor.h b/ydb/core/tx/columnshard/engines/writer/indexed_blob_constructor.h index f76187e450b..299c9b640ff 100644 --- a/ydb/core/tx/columnshard/engines/writer/indexed_blob_constructor.h +++ b/ydb/core/tx/columnshard/engines/writer/indexed_blob_constructor.h @@ -43,9 +43,6 @@ public: void DoOnReadyResult(const NActors::TActorContext& ctx, const NColumnShard::TBlobPutResult::TPtr& putResult) override; NOlap::IBlobConstructor::TPtr GetBlobConstructor() override; - -public: - void AddBlob(NColumnShard::TEvPrivate::TEvWriteBlobsResult::TPutBlobData&& data); }; } |