diff options
author | ivanmorozov <ivanmorozov@yandex-team.com> | 2022-12-01 17:58:43 +0300 |
---|---|---|
committer | ivanmorozov <ivanmorozov@yandex-team.com> | 2022-12-01 17:58:43 +0300 |
commit | b5bb624b894c68c2228cc59c98494b68fa90d4f4 (patch) | |
tree | 7f1d407c2552c36fcab9e83521ac6900991f0ed4 | |
parent | 249d470f713fe51ed84eed444aae8a29157a426e (diff) | |
download | ydb-b5bb624b894c68c2228cc59c98494b68fa90d4f4.tar.gz |
tiering for proto providing
-rw-r--r-- | ydb/core/grpc_services/rpc_log_store.cpp | 2 | ||||
-rw-r--r-- | ydb/public/api/protos/draft/ydb_logstore.proto | 10 | ||||
-rw-r--r-- | ydb/public/lib/experimental/ydb_logstore.cpp | 10 | ||||
-rw-r--r-- | ydb/public/lib/experimental/ydb_logstore.h | 34 | ||||
-rw-r--r-- | ydb/services/ydb/ydb_logstore_ut.cpp | 12 |
5 files changed, 47 insertions, 21 deletions
diff --git a/ydb/core/grpc_services/rpc_log_store.cpp b/ydb/core/grpc_services/rpc_log_store.cpp index 372155c4ef..5b048c5887 100644 --- a/ydb/core/grpc_services/rpc_log_store.cpp +++ b/ydb/core/grpc_services/rpc_log_store.cpp @@ -439,6 +439,8 @@ private: if (!FillTtlSettings(*create->MutableTtlSettings()->MutableEnabled(), req->ttl_settings(), status, error)) { return Reply(status, error, NKikimrIssues::TIssuesIds::DEFAULT_ERROR, ctx); } + } else if (req->has_tiering_settings()) { + create->MutableTtlSettings()->MutableTiering()->SetUseTiering(req->tiering_settings().tiering_id()); } create->SetColumnShardCount(req->shards_count()); diff --git a/ydb/public/api/protos/draft/ydb_logstore.proto b/ydb/public/api/protos/draft/ydb_logstore.proto index 87a51bf2ef..fafa42c361 100644 --- a/ydb/public/api/protos/draft/ydb_logstore.proto +++ b/ydb/public/api/protos/draft/ydb_logstore.proto @@ -59,8 +59,8 @@ message Tier { Ydb.Table.TtlSettings eviction = 2; // When to evict data to the next tier (or remove if none) } -message Tiering { - repeated Tier tiers = 1; +message TieringSettings { + optional string tiering_id = 2; } message CreateLogStoreRequest { @@ -134,7 +134,7 @@ message CreateLogTableRequest { }; oneof ttl_specification { Ydb.Table.TtlSettings ttl_settings = 5; - Tiering tiering = 6; + TieringSettings tiering_settings = 6; }; // Specifies the desired number of ColumnShards for this table @@ -161,7 +161,7 @@ message DescribeLogTableResult { Schema schema = 3; oneof ttl_specification { Ydb.Table.TtlSettings ttl_settings = 5; - Tiering tiering = 4; + TieringSettings tiering_settings = 4; } // Specifies the desired number of ColumnShards for this table @@ -194,7 +194,7 @@ message AlterLogTableRequest { oneof ttl_action { google.protobuf.Empty drop_ttl_settings = 3; Ydb.Table.TtlSettings set_ttl_settings = 4; - Tiering set_tiering = 5; + TieringSettings set_tiering_settings = 5; } } diff --git a/ydb/public/lib/experimental/ydb_logstore.cpp b/ydb/public/lib/experimental/ydb_logstore.cpp index c073a9385a..c9b3c4a898 100644 --- a/ydb/public/lib/experimental/ydb_logstore.cpp +++ b/ydb/public/lib/experimental/ydb_logstore.cpp @@ -155,18 +155,14 @@ TLogTableSharding::TLogTableSharding(const Ydb::LogStore::DescribeLogTableResult } } -TLogTableDescription::TLogTableDescription(const TString& schemaPresetName, const TLogTableSharding& sharding, - const TMaybe<TTtlSettings>& ttlSettings) +TLogTableDescription::TLogTableDescription(const TString& schemaPresetName, const TLogTableSharding& sharding) : SchemaPresetName(schemaPresetName) , Sharding(sharding) - , TtlSettings(ttlSettings) {} -TLogTableDescription::TLogTableDescription(const TSchema& schema, const TLogTableSharding& sharding, - const TMaybe<TTtlSettings>& ttlSettings) +TLogTableDescription::TLogTableDescription(const TSchema& schema, const TLogTableSharding& sharding) : Schema(schema) , Sharding(sharding) - , TtlSettings(ttlSettings) {} TLogTableDescription::TLogTableDescription(Ydb::LogStore::DescribeLogTableResult&& desc, @@ -203,6 +199,8 @@ void TLogTableDescription::SerializeTo(Ydb::LogStore::CreateLogTableRequest& req if (TtlSettings) { TtlSettings->SerializeTo(*request.mutable_ttl_settings()); + } else if (TieringSettings) { + TieringSettings->SerializeTo(*request.mutable_tiering_settings()); } } diff --git a/ydb/public/lib/experimental/ydb_logstore.h b/ydb/public/lib/experimental/ydb_logstore.h index 9121d583ae..633730e015 100644 --- a/ydb/public/lib/experimental/ydb_logstore.h +++ b/ydb/public/lib/experimental/ydb_logstore.h @@ -3,6 +3,7 @@ #include <ydb/public/sdk/cpp/client/ydb_result/result.h> #include <ydb/public/sdk/cpp/client/ydb_scheme/scheme.h> #include <ydb/public/sdk/cpp/client/ydb_table/table.h> +#include <ydb/public/api/protos/draft/ydb_logstore.pb.h> namespace Ydb::LogStore { @@ -151,12 +152,25 @@ struct TLogTableSharding { TLogTableSharding(const Ydb::LogStore::DescribeLogTableResult& desc); }; +class TTieringSettings { +private: + TString TieringId; +public: + TTieringSettings(const TString& tieringId) + : TieringId(tieringId) { + + } + + void SerializeTo(Ydb::LogStore::TieringSettings& proto) const { + proto.set_tiering_id(TieringId); + } + +}; + class TLogTableDescription { public: - TLogTableDescription(const TString& schemaPresetName, const TLogTableSharding& sharding, - const TMaybe<TTtlSettings>& ttlSettings = {}); - TLogTableDescription(const TSchema& schema, const TLogTableSharding& sharding, - const TMaybe<TTtlSettings>& ttlSettings = {}); + TLogTableDescription(const TString& schemaPresetName, const TLogTableSharding& sharding); + TLogTableDescription(const TSchema& schema, const TLogTableSharding& sharding); TLogTableDescription(Ydb::LogStore::DescribeLogTableResult&& desc, const TDescribeLogTableSettings& describeSettings); void SerializeTo(Ydb::LogStore::CreateLogTableRequest& request) const; const TSchema& GetSchema() const { @@ -182,12 +196,20 @@ public: const TVector<NScheme::TPermissions>& GetEffectivePermissions() const { return EffectivePermissions; } - + TLogTableDescription& SetTtlSettings(const TTtlSettings& settings) { + TtlSettings = settings; + return *this; + } + TLogTableDescription& SetTieringSettings(const TTieringSettings& settings) { + TieringSettings = settings; + return *this; + } private: const TString SchemaPresetName; const TSchema Schema; const TLogTableSharding Sharding; - const TMaybe<TTtlSettings> TtlSettings; + TMaybe<TTtlSettings> TtlSettings; + TMaybe<TTieringSettings> TieringSettings; TString Owner; TVector<NScheme::TPermissions> Permissions; TVector<NScheme::TPermissions> EffectivePermissions; diff --git a/ydb/services/ydb/ydb_logstore_ut.cpp b/ydb/services/ydb/ydb_logstore_ut.cpp index 1b68ac53ea..e9dd8045dd 100644 --- a/ydb/services/ydb/ydb_logstore_ut.cpp +++ b/ydb/services/ydb/ydb_logstore_ut.cpp @@ -446,7 +446,8 @@ Y_UNIT_TEST_SUITE(YdbLogStore) { { NYdb::NLogStore::TTtlSettings ttlSettings("saved_at", TDuration::Seconds(2000)); NYdb::NLogStore::TLogTableSharding sharding(NYdb::NLogStore::HASH_TYPE_LOGS_SPECIAL, {"timestamp", "uid"}, 4); - NYdb::NLogStore::TLogTableDescription tableDescr("default", sharding, ttlSettings); + NYdb::NLogStore::TLogTableDescription tableDescr("default", sharding); + tableDescr.SetTtlSettings(ttlSettings); auto res = logStoreClient.CreateLogTable("/Root/LogStore/log2", std::move(tableDescr)).GetValueSync(); UNIT_ASSERT_VALUES_EQUAL_C(res.GetStatus(), EStatus::SUCCESS, res.GetIssues().ToString()); } @@ -530,7 +531,8 @@ Y_UNIT_TEST_SUITE(YdbLogStore) { { NYdb::NLogStore::TTtlSettings ttlSettings("nonexisting_column", TDuration::Seconds(2000)); NYdb::NLogStore::TLogTableSharding sharding(NYdb::NLogStore::HASH_TYPE_LOGS_SPECIAL, {"timestamp", "uid"}, 4); - NYdb::NLogStore::TLogTableDescription tableDescr("default", sharding, ttlSettings); + NYdb::NLogStore::TLogTableDescription tableDescr("default", sharding); + tableDescr.SetTtlSettings(ttlSettings); auto res = logStoreClient.CreateLogTable("/Root/LogStore/log3", std::move(tableDescr)).GetValueSync(); UNIT_ASSERT_VALUES_EQUAL_C(res.GetStatus(), EStatus::BAD_REQUEST, res.GetIssues().ToString()); } @@ -539,7 +541,8 @@ Y_UNIT_TEST_SUITE(YdbLogStore) { { NYdb::NLogStore::TTtlSettings ttlSettings("message", NYdb::NTable::TTtlSettings::EUnit::MilliSeconds, TDuration::Seconds(3600)); NYdb::NLogStore::TLogTableSharding sharding(NYdb::NLogStore::HASH_TYPE_LOGS_SPECIAL, {"timestamp", "uid"}, 4); - NYdb::NLogStore::TLogTableDescription tableDescr("default", sharding, ttlSettings); + NYdb::NLogStore::TLogTableDescription tableDescr("default", sharding); + tableDescr.SetTtlSettings(ttlSettings); auto res = logStoreClient.CreateLogTable("/Root/LogStore/log4", std::move(tableDescr)).GetValueSync(); UNIT_ASSERT_VALUES_EQUAL_C(res.GetStatus(), EStatus::BAD_REQUEST, res.GetIssues().ToString()); } @@ -548,7 +551,8 @@ Y_UNIT_TEST_SUITE(YdbLogStore) { { NYdb::NLogStore::TTtlSettings ttlSettings("uint_timestamp", NYdb::NTable::TTtlSettings::EUnit::MilliSeconds, TDuration::Seconds(3600)); NYdb::NLogStore::TLogTableSharding sharding(NYdb::NLogStore::HASH_TYPE_LOGS_SPECIAL, {"timestamp", "uid"}, 4); - NYdb::NLogStore::TLogTableDescription tableDescr("default", sharding, ttlSettings); + NYdb::NLogStore::TLogTableDescription tableDescr("default", sharding); + tableDescr.SetTtlSettings(ttlSettings); auto res = logStoreClient.CreateLogTable("/Root/LogStore/log5", std::move(tableDescr)).GetValueSync(); UNIT_ASSERT_VALUES_EQUAL_C(res.GetStatus(), EStatus::BAD_REQUEST, res.GetIssues().ToString()); } |