Skip to content

Commit b295ede

Browse files
adameatgithub-actions[bot]
authored andcommitted
add support for text and bytes (#26532)
1 parent 5db9555 commit b295ede

File tree

3 files changed

+71
-3
lines changed

3 files changed

+71
-3
lines changed

.github/last_commit.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8ecf0017d5b19918f37de892f536e8cb83216309
1+
b37a11ff0c3f3c8efdbf2c4abe7d7c8a4b0e0ca9

include/ydb-cpp-sdk/client/value/value.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ enum class EPrimitiveType {
6868
TzDatetime = 0x0035,
6969
TzTimestamp = 0x0036,
7070
String = 0x1001,
71+
Bytes = 0x1001,
7172
Utf8 = 0x1200,
73+
Text = 0x1200,
7274
Yson = 0x1201,
7375
Json = 0x1202,
7476
Uuid = 0x1203,
@@ -338,7 +340,9 @@ class TValueParser : public TMoveOnly {
338340
const std::string& GetTzDatetime() const;
339341
const std::string& GetTzTimestamp() const;
340342
const std::string& GetString() const;
343+
const std::string& GetBytes() const;
341344
const std::string& GetUtf8() const;
345+
const std::string& GetText() const;
342346
const std::string& GetYson() const;
343347
const std::string& GetJson() const;
344348
TDecimalValue GetDecimal() const;
@@ -370,7 +374,9 @@ class TValueParser : public TMoveOnly {
370374
std::optional<std::string> GetOptionalTzDatetime() const;
371375
std::optional<std::string> GetOptionalTzTimestamp() const;
372376
std::optional<std::string> GetOptionalString() const;
377+
std::optional<std::string> GetOptionalBytes() const;
373378
std::optional<std::string> GetOptionalUtf8() const;
379+
std::optional<std::string> GetOptionalText() const;
374380
std::optional<std::string> GetOptionalYson() const;
375381
std::optional<std::string> GetOptionalJson() const;
376382
std::optional<TDecimalValue> GetOptionalDecimal() const;
@@ -448,7 +454,9 @@ class TValueBuilderBase : public TMoveOnly {
448454
TDerived& TzDatetime(const std::string& value);
449455
TDerived& TzTimestamp(const std::string& value);
450456
TDerived& String(const std::string& value);
457+
TDerived& Bytes(const std::string& value);
451458
TDerived& Utf8(const std::string& value);
459+
TDerived& Text(const std::string& value);
452460
TDerived& Yson(const std::string& value);
453461
TDerived& Json(const std::string& value);
454462
TDerived& Decimal(const TDecimalValue& value);
@@ -480,7 +488,9 @@ class TValueBuilderBase : public TMoveOnly {
480488
TDerived& OptionalTzDatetime(const std::optional<std::string>& value);
481489
TDerived& OptionalTzTimestamp(const std::optional<std::string>& value);
482490
TDerived& OptionalString(const std::optional<std::string>& value);
491+
TDerived& OptionalBytes(const std::optional<std::string>& value);
483492
TDerived& OptionalUtf8(const std::optional<std::string>& value);
493+
TDerived& OptionalText(const std::optional<std::string>& value);
484494
TDerived& OptionalYson(const std::optional<std::string>& value);
485495
TDerived& OptionalJson(const std::optional<std::string>& value);
486496
TDerived& OptionalUuid(const std::optional<TUuidValue>& value);

src/client/value/value.cpp

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,11 +1260,21 @@ class TValueParser::TImpl {
12601260
return GetProto().bytes_value();
12611261
}
12621262

1263+
const std::string& GetBytes() const {
1264+
CheckPrimitive(NYdb::EPrimitiveType::Bytes);
1265+
return GetProto().bytes_value();
1266+
}
1267+
12631268
const std::string& GetUtf8() const {
12641269
CheckPrimitive(NYdb::EPrimitiveType::Utf8);
12651270
return GetProto().text_value();
12661271
}
12671272

1273+
const std::string& GetText() const {
1274+
CheckPrimitive(NYdb::EPrimitiveType::Text);
1275+
return GetProto().text_value();
1276+
}
1277+
12681278
const std::string& GetYson() const {
12691279
CheckPrimitive(NYdb::EPrimitiveType::Yson);
12701280
return GetProto().bytes_value();
@@ -1635,9 +1645,9 @@ class TValueParser::TImpl {
16351645
case NYdb::EPrimitiveType::TzDatetime:
16361646
case NYdb::EPrimitiveType::TzTimestamp:
16371647
return Ydb::Value::kTextValue;
1638-
case NYdb::EPrimitiveType::String:
1648+
case NYdb::EPrimitiveType::Bytes:
16391649
return Ydb::Value::kBytesValue;
1640-
case NYdb::EPrimitiveType::Utf8:
1650+
case NYdb::EPrimitiveType::Text:
16411651
return Ydb::Value::kTextValue;
16421652
case NYdb::EPrimitiveType::Yson:
16431653
return Ydb::Value::kBytesValue;
@@ -1780,10 +1790,18 @@ const std::string& TValueParser::GetString() const {
17801790
return Impl_->GetString();
17811791
}
17821792

1793+
const std::string& TValueParser::GetBytes() const {
1794+
return Impl_->GetBytes();
1795+
}
1796+
17831797
const std::string& TValueParser::GetUtf8() const {
17841798
return Impl_->GetUtf8();
17851799
}
17861800

1801+
const std::string& TValueParser::GetText() const {
1802+
return Impl_->GetText();
1803+
}
1804+
17871805
const std::string& TValueParser::GetYson() const {
17881806
return Impl_->GetYson();
17891807
}
@@ -1912,10 +1930,18 @@ std::optional<std::string> TValueParser::GetOptionalString() const {
19121930
RET_OPT_VALUE(std::string, String);
19131931
}
19141932

1933+
std::optional<std::string> TValueParser::GetOptionalBytes() const {
1934+
RET_OPT_VALUE(std::string, Bytes);
1935+
}
1936+
19151937
std::optional<std::string> TValueParser::GetOptionalUtf8() const {
19161938
RET_OPT_VALUE(std::string, Utf8);
19171939
}
19181940

1941+
std::optional<std::string> TValueParser::GetOptionalText() const {
1942+
RET_OPT_VALUE(std::string, Text);
1943+
}
1944+
19191945
std::optional<std::string> TValueParser::GetOptionalYson() const {
19201946
RET_OPT_VALUE(std::string, Yson);
19211947
}
@@ -2228,11 +2254,21 @@ class TValueBuilderImpl {
22282254
GetValue().set_bytes_value(TStringType{value});
22292255
}
22302256

2257+
void Bytes(const std::string& value) {
2258+
FillPrimitiveType(EPrimitiveType::Bytes);
2259+
GetValue().set_bytes_value(TStringType{value});
2260+
}
2261+
22312262
void Utf8(const std::string& value) {
22322263
FillPrimitiveType(EPrimitiveType::Utf8);
22332264
GetValue().set_text_value(TStringType{value});
22342265
}
22352266

2267+
void Text(const std::string& value) {
2268+
FillPrimitiveType(EPrimitiveType::Text);
2269+
GetValue().set_text_value(TStringType{value});
2270+
}
2271+
22362272
void Yson(const std::string& value) {
22372273
FillPrimitiveType(EPrimitiveType::Yson);
22382274
GetValue().set_bytes_value(TStringType{value});
@@ -3001,12 +3037,24 @@ TDerived& TValueBuilderBase<TDerived>::String(const std::string& value) {
30013037
return static_cast<TDerived&>(*this);
30023038
}
30033039

3040+
template<typename TDerived>
3041+
TDerived& TValueBuilderBase<TDerived>::Bytes(const std::string& value) {
3042+
Impl_->Bytes(value);
3043+
return static_cast<TDerived&>(*this);
3044+
}
3045+
30043046
template<typename TDerived>
30053047
TDerived& TValueBuilderBase<TDerived>::Utf8(const std::string& value) {
30063048
Impl_->Utf8(value);
30073049
return static_cast<TDerived&>(*this);
30083050
}
30093051

3052+
template<typename TDerived>
3053+
TDerived& TValueBuilderBase<TDerived>::Text(const std::string& value) {
3054+
Impl_->Text(value);
3055+
return static_cast<TDerived&>(*this);
3056+
}
3057+
30103058
template<typename TDerived>
30113059
TDerived& TValueBuilderBase<TDerived>::Yson(const std::string& value) {
30123060
Impl_->Yson(value);
@@ -3180,11 +3228,21 @@ TDerived& TValueBuilderBase<TDerived>::OptionalString(const std::optional<std::s
31803228
SET_OPT_VALUE_FROM_OPTIONAL(String);
31813229
}
31823230

3231+
template<typename TDerived>
3232+
TDerived& TValueBuilderBase<TDerived>::OptionalBytes(const std::optional<std::string>& value) {
3233+
SET_OPT_VALUE_FROM_OPTIONAL(Bytes);
3234+
}
3235+
31833236
template<typename TDerived>
31843237
TDerived& TValueBuilderBase<TDerived>::OptionalUtf8(const std::optional<std::string>& value) {
31853238
SET_OPT_VALUE_FROM_OPTIONAL(Utf8);
31863239
}
31873240

3241+
template<typename TDerived>
3242+
TDerived& TValueBuilderBase<TDerived>::OptionalText(const std::optional<std::string>& value) {
3243+
SET_OPT_VALUE_FROM_OPTIONAL(Text);
3244+
}
3245+
31883246
template<typename TDerived>
31893247
TDerived& TValueBuilderBase<TDerived>::OptionalYson(const std::optional<std::string>& value) {
31903248
SET_OPT_VALUE_FROM_OPTIONAL(Yson);

0 commit comments

Comments
 (0)