Browse Source

(refactoring) Inline TChangeRecordBuilder's methods (#734)

Ilnaz Nizametdinov 1 year ago
parent
commit
bb2a2c66c8
2 changed files with 77 additions and 99 deletions
  1. 0 77
      ydb/core/tx/datashard/change_record.cpp
  2. 77 22
      ydb/core/tx/datashard/change_record.h

+ 0 - 77
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);
-}
-
 }

+ 77 - 22
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;