diff options
author | ilnaz <ilnaz@ydb.tech> | 2022-12-07 00:34:23 +0300 |
---|---|---|
committer | ilnaz <ilnaz@ydb.tech> | 2022-12-07 00:34:23 +0300 |
commit | 5b2521a5d471e8eca93b51fa3c56b52caa7ce540 (patch) | |
tree | 2115a6123a99e7e6232bd93cf06f803e6ad982e0 | |
parent | f45ed89d35dff9fd996496b14e7cb528e6c627ad (diff) | |
download | ydb-5b2521a5d471e8eca93b51fa3c56b52caa7ce540.tar.gz |
VirtualTimestamp in cpp sdk
-rw-r--r-- | ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp | 5 | ||||
-rw-r--r-- | ydb/public/sdk/cpp/client/ydb_table/table.cpp | 24 | ||||
-rw-r--r-- | ydb/public/sdk/cpp/client/ydb_table/table.h | 4 |
3 files changed, 27 insertions, 6 deletions
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp b/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp index ee7866fc04b..ed39b75b2c3 100644 --- a/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp +++ b/ydb/public/lib/ydb_cli/commands/ydb_service_scheme.cpp @@ -343,14 +343,15 @@ namespace { return; } - TPrettyTable table({ "Name", "Mode", "Format" }, + TPrettyTable table({ "Name", "Mode", "Format", "VirtualTimestamps" }, TPrettyTableConfig().WithoutRowDelimiters()); for (const auto& changefeed : changefeeds) { table.AddRow() .Column(0, changefeed.GetName()) .Column(1, changefeed.GetMode()) - .Column(2, changefeed.GetFormat()); + .Column(2, changefeed.GetFormat()) + .Column(3, changefeed.GetVirtualTimestamps() ? "on" : "off"); } Cout << Endl << "Changefeeds:" << Endl << table; diff --git a/ydb/public/sdk/cpp/client/ydb_table/table.cpp b/ydb/public/sdk/cpp/client/ydb_table/table.cpp index d161f64854a..e26310af5e6 100644 --- a/ydb/public/sdk/cpp/client/ydb_table/table.cpp +++ b/ydb/public/sdk/cpp/client/ydb_table/table.cpp @@ -4395,6 +4395,11 @@ TChangefeedDescription::TChangefeedDescription(const Ydb::Table::ChangefeedDescr : TChangefeedDescription(FromProto(proto)) {} +TChangefeedDescription& TChangefeedDescription::WithVirtualTimestamps() { + VirtualTimestamps_ = true; + return *this; +} + const TString& TChangefeedDescription::GetName() const { return Name_; } @@ -4407,11 +4412,13 @@ EChangefeedFormat TChangefeedDescription::GetFormat() const { return Format_; } +bool TChangefeedDescription::GetVirtualTimestamps() const { + return VirtualTimestamps_; +} + template <typename TProto> TChangefeedDescription TChangefeedDescription::FromProto(const TProto& proto) { EChangefeedMode mode; - EChangefeedFormat format; - switch (proto.mode()) { case Ydb::Table::ChangefeedMode::MODE_KEYS_ONLY: mode = EChangefeedMode::KeysOnly; @@ -4433,6 +4440,7 @@ TChangefeedDescription TChangefeedDescription::FromProto(const TProto& proto) { break; } + EChangefeedFormat format; switch (proto.format()) { case Ydb::Table::ChangefeedFormat::FORMAT_JSON: format = EChangefeedFormat::Json; @@ -4442,11 +4450,17 @@ TChangefeedDescription TChangefeedDescription::FromProto(const TProto& proto) { break; } - return TChangefeedDescription(proto.name(), mode, format); + auto ret = TChangefeedDescription(proto.name(), mode, format); + if (proto.virtual_timestamps()) { + ret.WithVirtualTimestamps(); + } + + return ret; } void TChangefeedDescription::SerializeTo(Ydb::Table::Changefeed& proto) const { proto.set_name(Name_); + proto.set_virtual_timestamps(VirtualTimestamps_); switch (Mode_) { case EChangefeedMode::KeysOnly: @@ -4488,13 +4502,15 @@ void TChangefeedDescription::Out(IOutputStream& o) const { o << "{ name: \"" << Name_ << "\"" << ", mode: " << Mode_ << "" << ", format: " << Format_ << "" + << ", virtual_timestamps: " << (VirtualTimestamps_ ? "on": "off") << "" << " }"; } bool operator==(const TChangefeedDescription& lhs, const TChangefeedDescription& rhs) { return lhs.GetName() == rhs.GetName() && lhs.GetMode() == rhs.GetMode() - && lhs.GetFormat() == rhs.GetFormat(); + && lhs.GetFormat() == rhs.GetFormat() + && lhs.GetVirtualTimestamps() == rhs.GetVirtualTimestamps(); } bool operator!=(const TChangefeedDescription& lhs, const TChangefeedDescription& rhs) { diff --git a/ydb/public/sdk/cpp/client/ydb_table/table.h b/ydb/public/sdk/cpp/client/ydb_table/table.h index 7fc7e1484fe..676de851691 100644 --- a/ydb/public/sdk/cpp/client/ydb_table/table.h +++ b/ydb/public/sdk/cpp/client/ydb_table/table.h @@ -201,9 +201,12 @@ class TChangefeedDescription { public: TChangefeedDescription(const TString& name, EChangefeedMode mode, EChangefeedFormat format); + TChangefeedDescription& WithVirtualTimestamps(); + const TString& GetName() const; EChangefeedMode GetMode() const; EChangefeedFormat GetFormat() const; + bool GetVirtualTimestamps() const; void SerializeTo(Ydb::Table::Changefeed& proto) const; TString ToString() const; @@ -220,6 +223,7 @@ private: TString Name_; EChangefeedMode Mode_; EChangefeedFormat Format_; + bool VirtualTimestamps_ = false; }; bool operator==(const TChangefeedDescription& lhs, const TChangefeedDescription& rhs); |