Skip to content

Commit e51b937

Browse files
committed
Refactored operation id
1 parent 66fc8f0 commit e51b937

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

include/ydb-cpp-sdk/library/operation_id/operation_id.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,17 @@ class TOperationId {
3535

3636
TOperationId();
3737
explicit TOperationId(const std::string& string, bool allowEmpty = false);
38+
39+
TOperationId(const TOperationId& other);
40+
TOperationId(TOperationId&& other) = default;
41+
42+
TOperationId& operator=(const TOperationId& other);
43+
TOperationId& operator=(TOperationId&& other) = default;
44+
45+
~TOperationId() = default;
46+
3847
EKind GetKind() const;
39-
EKind& GetMutableKind();
48+
void SetKind(const EKind& kind);
4049

4150
const TDataList& GetData() const;
4251
TDataList& GetMutableData();
@@ -47,6 +56,7 @@ class TOperationId {
4756

4857
private:
4958
bool IsValidKind(int kind);
59+
void CopyData(const TOperationId::TDataList& otherData);
5060

5161
EKind Kind;
5262
TDataList Data;

include/ydb-cpp-sdk/library/yql_common/issue/yql_issue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class TIssue;
112112
using TIssuePtr = TIntrusivePtr<TIssue>;
113113
class TIssue: public TThrRefBase {
114114
std::vector<TIntrusivePtr<TIssue>> Children_;
115-
std::string Message;
115+
TString Message;
116116
public:
117117
TPosition Position;
118118
TPosition EndPosition;
@@ -209,7 +209,7 @@ class TIssue: public TThrRefBase {
209209
}
210210

211211
// Unsafe method. Doesn't call SanitizeNonAscii(Message)
212-
std::string* MutableMessage() {
212+
TString* MutableMessage() {
213213
return &Message;
214214
}
215215

src/library/operation_id/operation_id.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,35 @@ TOperationId::TOperationId(const std::string &string, bool allowEmpty) {
120120
}
121121
}
122122

123-
TOperationId::EKind TOperationId::GetKind() const {
124-
return Kind;
123+
TOperationId::TOperationId(const TOperationId& other) {
124+
Kind = other.Kind;
125+
CopyData(other.Data);
126+
}
127+
128+
TOperationId& TOperationId::operator=(const TOperationId& other) {
129+
Kind = other.Kind;
130+
Data.clear();
131+
Index.clear();
132+
CopyData(other.Data);
133+
return *this;
125134
}
126135

127-
TOperationId::EKind& TOperationId::GetMutableKind() {
136+
void TOperationId::CopyData(const TOperationId::TDataList& otherData) {
137+
for (const auto& data : otherData) {
138+
Data.push_back(std::make_unique<TData>(data->Key, data->Value));
139+
Index[data->Key].push_back(&Data.back()->Value);
140+
}
141+
}
142+
143+
TOperationId::EKind TOperationId::GetKind() const {
128144
return Kind;
129145
}
130146

131-
const TOperationId::TDataList& TOperationId::GetData() const {
132-
return Data;
147+
void TOperationId::SetKind(const EKind& kind) {
148+
Kind = kind;
133149
}
134150

135-
TOperationId::TDataList& TOperationId::GetMutableData() {
151+
const TOperationId::TDataList& TOperationId::GetData() const {
136152
return Data;
137153
}
138154

0 commit comments

Comments
 (0)