Skip to content

(refactoring) Inline TChangeRecordBuilder's methods #734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions ydb/core/tx/datashard/change_record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
99 changes: 77 additions & 22 deletions ydb/core/tx/datashard/change_record.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down