Skip to content

Commit

Permalink
Refactored operation id
Browse files Browse the repository at this point in the history
  • Loading branch information
Gazizonoki committed Aug 29, 2024
1 parent 66fc8f0 commit e51b937
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
12 changes: 11 additions & 1 deletion include/ydb-cpp-sdk/library/operation_id/operation_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,17 @@ class TOperationId {

TOperationId();
explicit TOperationId(const std::string& string, bool allowEmpty = false);

TOperationId(const TOperationId& other);
TOperationId(TOperationId&& other) = default;

TOperationId& operator=(const TOperationId& other);
TOperationId& operator=(TOperationId&& other) = default;

~TOperationId() = default;

EKind GetKind() const;
EKind& GetMutableKind();
void SetKind(const EKind& kind);

const TDataList& GetData() const;
TDataList& GetMutableData();
Expand All @@ -47,6 +56,7 @@ class TOperationId {

private:
bool IsValidKind(int kind);
void CopyData(const TOperationId::TDataList& otherData);

EKind Kind;
TDataList Data;
Expand Down
4 changes: 2 additions & 2 deletions include/ydb-cpp-sdk/library/yql_common/issue/yql_issue.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class TIssue;
using TIssuePtr = TIntrusivePtr<TIssue>;
class TIssue: public TThrRefBase {
std::vector<TIntrusivePtr<TIssue>> Children_;
std::string Message;
TString Message;
public:
TPosition Position;
TPosition EndPosition;
Expand Down Expand Up @@ -209,7 +209,7 @@ class TIssue: public TThrRefBase {
}

// Unsafe method. Doesn't call SanitizeNonAscii(Message)
std::string* MutableMessage() {
TString* MutableMessage() {
return &Message;
}

Expand Down
28 changes: 22 additions & 6 deletions src/library/operation_id/operation_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,35 @@ TOperationId::TOperationId(const std::string &string, bool allowEmpty) {
}
}

TOperationId::EKind TOperationId::GetKind() const {
return Kind;
TOperationId::TOperationId(const TOperationId& other) {
Kind = other.Kind;
CopyData(other.Data);
}

TOperationId& TOperationId::operator=(const TOperationId& other) {
Kind = other.Kind;
Data.clear();
Index.clear();
CopyData(other.Data);
return *this;
}

TOperationId::EKind& TOperationId::GetMutableKind() {
void TOperationId::CopyData(const TOperationId::TDataList& otherData) {
for (const auto& data : otherData) {
Data.push_back(std::make_unique<TData>(data->Key, data->Value));
Index[data->Key].push_back(&Data.back()->Value);
}
}

TOperationId::EKind TOperationId::GetKind() const {
return Kind;
}

const TOperationId::TDataList& TOperationId::GetData() const {
return Data;
void TOperationId::SetKind(const EKind& kind) {
Kind = kind;
}

TOperationId::TDataList& TOperationId::GetMutableData() {
const TOperationId::TDataList& TOperationId::GetData() const {
return Data;
}

Expand Down

0 comments on commit e51b937

Please sign in to comment.