From bb2a2c66c888487182a0b8a6375e57e66a3c8a1d Mon Sep 17 00:00:00 2001 From: Ilnaz Nizametdinov Date: Tue, 26 Dec 2023 20:15:07 +0300 Subject: (refactoring) Inline TChangeRecordBuilder's methods (#734) --- ydb/core/tx/datashard/change_record.cpp | 77 ------------------------- ydb/core/tx/datashard/change_record.h | 99 +++++++++++++++++++++++++-------- 2 files changed, 77 insertions(+), 99 deletions(-) diff --git a/ydb/core/tx/datashard/change_record.cpp b/ydb/core/tx/datashard/change_record.cpp index d87038bd66f..d087d3688db 100644 --- a/ydb/core/tx/datashard/change_record.cpp +++ b/ydb/core/tx/datashard/change_record.cpp @@ -103,81 +103,4 @@ void TChangeRecord::Out(IOutputStream& out) const { << " }"; } -TChangeRecordBuilder::TChangeRecordBuilder(EKind kind) { - Record.Kind = kind; -} - -TChangeRecordBuilder::TChangeRecordBuilder(TChangeRecord&& record) { - Record = std::move(record); -} - -TChangeRecordBuilder& TChangeRecordBuilder::WithLockId(ui64 lockId) { - Record.LockId = lockId; - return *this; -} - -TChangeRecordBuilder& TChangeRecordBuilder::WithLockOffset(ui64 lockOffset) { - Record.LockOffset = lockOffset; - return *this; -} - -TChangeRecordBuilder& TChangeRecordBuilder::WithOrder(ui64 order) { - Record.Order = order; - return *this; -} - -TChangeRecordBuilder& TChangeRecordBuilder::WithGroup(ui64 group) { - Record.Group = group; - return *this; -} - -TChangeRecordBuilder& TChangeRecordBuilder::WithStep(ui64 step) { - Record.Step = step; - return *this; -} - -TChangeRecordBuilder& TChangeRecordBuilder::WithTxId(ui64 txId) { - Record.TxId = txId; - return *this; -} - -TChangeRecordBuilder& TChangeRecordBuilder::WithPathId(const TPathId& pathId) { - Record.PathId = pathId; - return *this; -} - -TChangeRecordBuilder& TChangeRecordBuilder::WithTableId(const TPathId& tableId) { - Record.TableId = tableId; - return *this; -} - -TChangeRecordBuilder& TChangeRecordBuilder::WithSchemaVersion(ui64 version) { - Record.SchemaVersion = version; - return *this; -} - -TChangeRecordBuilder& TChangeRecordBuilder::WithSchema(TUserTable::TCPtr schema) { - Record.Schema = schema; - return *this; -} - -TChangeRecordBuilder& TChangeRecordBuilder::WithBody(const TString& body) { - Record.Body = body; - return *this; -} - -TChangeRecordBuilder& TChangeRecordBuilder::WithBody(TString&& body) { - Record.Body = std::move(body); - return *this; -} - -TChangeRecordBuilder& TChangeRecordBuilder::WithSource(ESource source) { - Record.Source = source; - return *this; -} - -TChangeRecord&& TChangeRecordBuilder::Build() { - return std::move(Record); -} - } diff --git a/ydb/core/tx/datashard/change_record.h b/ydb/core/tx/datashard/change_record.h index 9d32fe1efa7..4dec245559f 100644 --- a/ydb/core/tx/datashard/change_record.h +++ b/ydb/core/tx/datashard/change_record.h @@ -84,28 +84,83 @@ class TChangeRecordBuilder { using ESource = TChangeRecord::ESource; public: - explicit TChangeRecordBuilder(EKind kind); - explicit TChangeRecordBuilder(TChangeRecord&& record); - - TChangeRecordBuilder& WithLockId(ui64 lockId); - TChangeRecordBuilder& WithLockOffset(ui64 lockOffset); - - TChangeRecordBuilder& WithOrder(ui64 order); - TChangeRecordBuilder& WithGroup(ui64 group); - TChangeRecordBuilder& WithStep(ui64 step); - TChangeRecordBuilder& WithTxId(ui64 txId); - TChangeRecordBuilder& WithPathId(const TPathId& pathId); - - TChangeRecordBuilder& WithTableId(const TPathId& tableId); - TChangeRecordBuilder& WithSchemaVersion(ui64 version); - TChangeRecordBuilder& WithSchema(TUserTable::TCPtr schema); - - TChangeRecordBuilder& WithBody(const TString& body); - TChangeRecordBuilder& WithBody(TString&& body); - - TChangeRecordBuilder& WithSource(ESource source); - - TChangeRecord&& Build(); + explicit TChangeRecordBuilder(EKind kind) { + Record.Kind = kind; + } + + explicit TChangeRecordBuilder(TChangeRecord&& record) + : Record(std::move(record)) + { + } + + TChangeRecordBuilder& WithLockId(ui64 lockId) { + Record.LockId = lockId; + return *this; + } + + TChangeRecordBuilder& WithLockOffset(ui64 lockOffset) { + Record.LockOffset = lockOffset; + return *this; + } + + TChangeRecordBuilder& WithOrder(ui64 order) { + Record.Order = order; + return *this; + } + + TChangeRecordBuilder& WithGroup(ui64 group) { + Record.Group = group; + return *this; + } + + TChangeRecordBuilder& WithStep(ui64 step) { + Record.Step = step; + return *this; + } + + TChangeRecordBuilder& WithTxId(ui64 txId) { + Record.TxId = txId; + return *this; + } + + TChangeRecordBuilder& WithPathId(const TPathId& pathId) { + Record.PathId = pathId; + return *this; + } + + TChangeRecordBuilder& WithTableId(const TPathId& tableId) { + Record.TableId = tableId; + return *this; + } + + TChangeRecordBuilder& WithSchemaVersion(ui64 version) { + Record.SchemaVersion = version; + return *this; + } + + TChangeRecordBuilder& WithSchema(TUserTable::TCPtr schema) { + Record.Schema = schema; + return *this; + } + + TChangeRecordBuilder& WithBody(const TString& body) { + Record.Body = body; + return *this; + } + + TChangeRecordBuilder& WithBody(TString&& body) { + Record.Body = std::move(body); + return *this; + } + + TChangeRecordBuilder& WithSource(ESource source) { + Record.Source = source; + return *this; + } + + TChangeRecord&& Build() { + return std::move(Record); + } private: TChangeRecord Record; -- cgit v1.3