Skip to content

Commit 97a08d2

Browse files
authored
Merge 4365df4 into 7b9c7e3
2 parents 7b9c7e3 + 4365df4 commit 97a08d2

File tree

8 files changed

+181
-77
lines changed

8 files changed

+181
-77
lines changed

ydb/core/protos/flat_scheme_op.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,17 @@ message TTTLSettings {
221221
optional uint32 MaxShardsInFlight = 6 [default = 0]; // zero means no limit
222222
}
223223

224+
message TTier {
225+
optional uint32 EvictAfterSeconds = 1;
226+
optional string StorageName = 2;
227+
}
228+
224229
message TEnabled {
225230
optional string ColumnName = 1;
226231
optional uint32 ExpireAfterSeconds = 2;
227232
optional EUnit ColumnUnit = 3;
228233
optional TSysSettings SysSettings = 4;
234+
repeated TTier Tiers = 5;
229235
}
230236

231237
message TDisabled {
@@ -555,6 +561,7 @@ message TColumnDataLifeCycle {
555561
uint64 ExpireAfterBytes = 4;
556562
}
557563
optional TTTLSettings.EUnit ColumnUnit = 3;
564+
repeated TTTLSettings.TTier Tiers = 5;
558565
}
559566

560567
message TDisabled {

ydb/core/ydb_convert/table_description.cpp

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ THashSet<EAlterOperationKind> GetAlterOperationKinds(const Ydb::Table::AlterTabl
4848
req->alter_columns_size() ||
4949
req->ttl_action_case() !=
5050
Ydb::Table::AlterTableRequest::TTL_ACTION_NOT_SET ||
51-
req->tiering_action_case() !=
52-
Ydb::Table::AlterTableRequest::TIERING_ACTION_NOT_SET ||
5351
req->has_alter_storage_settings() || req->add_column_families_size() ||
5452
req->alter_column_families_size() || req->set_compaction_policy() ||
5553
req->has_alter_partitioning_settings() ||
@@ -509,11 +507,22 @@ Ydb::Type* AddColumn<NKikimrSchemeOp::TColumnDescription>(Ydb::Table::ColumnMeta
509507

510508
template <typename TYdbProto, typename TTtl>
511509
static void AddTtl(TYdbProto& out, const TTtl& inTTL) {
510+
static const auto& fillCommonFields = []<class TModeSettings>(TModeSettings& out, const TTtl& in) {
511+
out.set_column_name(in.GetColumnName());
512+
if (in.HasExpireAfterSeconds()) {
513+
out.set_expire_after_seconds(in.GetExpireAfterSeconds());
514+
}
515+
for (const auto& in_tier : in.GetTiers()) {
516+
auto* out_tier = out.add_storage_tiers();
517+
out_tier->set_evict_after_seconds(in_tier.GetEvictAfterSeconds());
518+
out_tier->set_storage_name(in_tier.GetStorageName());
519+
}
520+
};
521+
512522
switch (inTTL.GetColumnUnit()) {
513523
case NKikimrSchemeOp::TTTLSettings::UNIT_AUTO: {
514524
auto& outTTL = *out.mutable_ttl_settings()->mutable_date_type_column();
515-
outTTL.set_column_name(inTTL.GetColumnName());
516-
outTTL.set_expire_after_seconds(inTTL.GetExpireAfterSeconds());
525+
fillCommonFields(outTTL, inTTL);
517526
break;
518527
}
519528

@@ -522,9 +531,8 @@ static void AddTtl(TYdbProto& out, const TTtl& inTTL) {
522531
case NKikimrSchemeOp::TTTLSettings::UNIT_MICROSECONDS:
523532
case NKikimrSchemeOp::TTTLSettings::UNIT_NANOSECONDS: {
524533
auto& outTTL = *out.mutable_ttl_settings()->mutable_value_since_unix_epoch();
525-
outTTL.set_column_name(inTTL.GetColumnName());
534+
fillCommonFields(outTTL, inTTL);
526535
outTTL.set_column_unit(static_cast<Ydb::Table::ValueSinceUnixEpochModeSettings::Unit>(inTTL.GetColumnUnit()));
527-
outTTL.set_expire_after_seconds(inTTL.GetExpireAfterSeconds());
528536
break;
529537
}
530538

@@ -572,10 +580,6 @@ void FillColumnDescriptionImpl(TYdbProto& out,
572580
if (in.GetTTLSettings().HasEnabled()) {
573581
AddTtl(out, in.GetTTLSettings().GetEnabled());
574582
}
575-
576-
if (in.GetTTLSettings().HasUseTiering()) {
577-
out.set_tiering(in.GetTTLSettings().GetUseTiering());
578-
}
579583
}
580584
}
581585

@@ -612,10 +616,6 @@ void FillColumnDescription(Ydb::Table::DescribeTableResult& out, const NKikimrSc
612616
if (in.GetTtlSettings().HasEnabled()) {
613617
AddTtl(out, in.GetTtlSettings().GetEnabled());
614618
}
615-
616-
if (in.GetTtlSettings().HasUseTiering()) {
617-
out.set_tiering(in.GetTtlSettings().GetUseTiering());
618-
}
619619
}
620620

621621
out.set_store_type(Ydb::Table::StoreType::STORE_TYPE_COLUMN);
@@ -829,12 +829,6 @@ bool BuildAlterColumnTableModifyScheme(const TString& path, const Ydb::Table::Al
829829
} else if (req->has_drop_ttl_settings()) {
830830
alterColumnTable->MutableAlterTtlSettings()->MutableDisabled();
831831
}
832-
833-
if (req->has_set_tiering()) {
834-
alterColumnTable->MutableAlterTtlSettings()->SetUseTiering(req->set_tiering());
835-
} else if (req->has_drop_tiering()) {
836-
alterColumnTable->MutableAlterTtlSettings()->SetUseTiering("");
837-
}
838832
}
839833

840834
return true;

ydb/core/ydb_convert/table_settings.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,25 @@ bool FillTtlSettings(TTtlSettingsEnabled& out, const Ydb::Table::TtlSettings& in
2828
return false;
2929
};
3030

31+
static const auto& fillCommonFields = []<class TModeSettings>(TTtlSettingsEnabled& out, const TModeSettings& in) {
32+
out.SetColumnName(in.column_name());
33+
if (in.has_expire_after_seconds()) {
34+
out.SetExpireAfterSeconds(in.expire_after_seconds());
35+
}
36+
for (const auto& in_tier : in.storage_tiers()) {
37+
auto* out_tier = out.AddTiers();
38+
out_tier->SetEvictAfterSeconds(in_tier.evict_after_seconds());
39+
out_tier->SetStorageName(in_tier.storage_name());
40+
}
41+
};
42+
3143
switch (in.mode_case()) {
3244
case Ydb::Table::TtlSettings::kDateTypeColumn:
33-
out.SetColumnName(in.date_type_column().column_name());
34-
out.SetExpireAfterSeconds(in.date_type_column().expire_after_seconds());
45+
fillCommonFields(out, in.date_type_column());
3546
break;
3647

3748
case Ydb::Table::TtlSettings::kValueSinceUnixEpoch:
38-
out.SetColumnName(in.value_since_unix_epoch().column_name());
39-
out.SetExpireAfterSeconds(in.value_since_unix_epoch().expire_after_seconds());
49+
fillCommonFields(out, in.value_since_unix_epoch());
4050

4151
#define CASE_UNIT(type) \
4252
case Ydb::Table::ValueSinceUnixEpochModeSettings::type: \

ydb/public/api/protos/ydb_table.proto

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,13 @@ message ColumnMeta {
433433
}
434434
}
435435

436+
message EvictionTier {
437+
// Name of tiered storage
438+
string storage_name = 1;
439+
440+
uint32 evict_after_seconds = 2;
441+
}
442+
436443
message DateTypeColumnModeSettings {
437444
// The row will be considered as expired at the moment of time, when the value
438445
// stored in <column_name> is less than or equal to the current time (in epoch
@@ -442,7 +449,9 @@ message DateTypeColumnModeSettings {
442449
// The column type must be a date type
443450
string column_name = 1;
444451

445-
uint32 expire_after_seconds = 2;
452+
optional uint32 expire_after_seconds = 2;
453+
454+
repeated EvictionTier storage_tiers = 3;
446455
}
447456

448457
message ValueSinceUnixEpochModeSettings {
@@ -468,7 +477,9 @@ message ValueSinceUnixEpochModeSettings {
468477

469478
// This option is always interpreted as seconds regardless of the
470479
// <column_unit> value.
471-
uint32 expire_after_seconds = 3;
480+
optional uint32 expire_after_seconds = 3;
481+
482+
repeated EvictionTier storage_tiers = 4;
472483
}
473484

474485
message TtlSettings {
@@ -624,7 +635,7 @@ message CreateTableRequest {
624635
Ydb.FeatureFlag.Status key_bloom_filter = 16;
625636
// Read replicas settings for table
626637
ReadReplicasSettings read_replicas_settings = 17;
627-
// Tiering rules name. It specifies how data migrates from one tier (logical storage) to another.
638+
// Deprecated. Use TTL instead.
628639
string tiering = 18;
629640
// Is temporary table
630641
bool temporary = 19;
@@ -704,7 +715,7 @@ message AlterTableRequest {
704715
repeated string drop_changefeeds = 20;
705716
// Rename existed index
706717
repeated RenameIndexItem rename_indexes = 21;
707-
// Setup or remove tiering
718+
// Deprecated. Use ttl_action instead
708719
oneof tiering_action {
709720
string set_tiering = 22;
710721
google.protobuf.Empty drop_tiering = 23;

ydb/public/lib/experimental/ydb_logstore.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,6 @@ void TLogTableDescription::SerializeTo(Ydb::LogStore::CreateLogTableRequest& req
199199

200200
if (TtlSettings) {
201201
TtlSettings->SerializeTo(*request.mutable_ttl_settings());
202-
} else if (TieringSettings) {
203-
TieringSettings->SerializeTo(*request.mutable_tiering_settings());
204202
}
205203
}
206204

ydb/public/lib/experimental/ydb_logstore.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,6 @@ struct TLogTableSharding {
152152
TLogTableSharding(const Ydb::LogStore::DescribeLogTableResult& desc);
153153
};
154154

155-
class TTieringSettings {
156-
private:
157-
TString TieringId;
158-
public:
159-
TTieringSettings(const TString& tieringId)
160-
: TieringId(tieringId) {
161-
162-
}
163-
164-
void SerializeTo(Ydb::LogStore::TieringSettings& proto) const {
165-
proto.set_tiering_id(TieringId);
166-
}
167-
168-
};
169-
170155
class TLogTableDescription {
171156
public:
172157
TLogTableDescription(const TString& schemaPresetName, const TLogTableSharding& sharding);
@@ -200,16 +185,11 @@ class TLogTableDescription {
200185
TtlSettings = settings;
201186
return *this;
202187
}
203-
TLogTableDescription& SetTieringSettings(const TTieringSettings& settings) {
204-
TieringSettings = settings;
205-
return *this;
206-
}
207188
private:
208189
const TString SchemaPresetName;
209190
const TSchema Schema;
210191
const TLogTableSharding Sharding;
211192
TMaybe<TTtlSettings> TtlSettings;
212-
TMaybe<TTieringSettings> TieringSettings;
213193
TString Owner;
214194
TVector<NScheme::TPermissions> Permissions;
215195
TVector<NScheme::TPermissions> EffectivePermissions;

0 commit comments

Comments
 (0)