From 3654a3da36e702f823ebd070bdcf4a9c3ae810ff Mon Sep 17 00:00:00 2001 From: Daniil Demin Date: Mon, 26 Aug 2024 18:33:54 +0000 Subject: [PATCH] Moved commit "Restore indexes from backup with the original partitioning" from ydb repo --- include/ydb-cpp-sdk/client/table/table.h | 2 ++ src/client/table/table.cpp | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/ydb-cpp-sdk/client/table/table.h b/include/ydb-cpp-sdk/client/table/table.h index 382974aad8..82ae8c7291 100644 --- a/include/ydb-cpp-sdk/client/table/table.h +++ b/include/ydb-cpp-sdk/client/table/table.h @@ -640,6 +640,7 @@ class TTableDescription { // common void AddSecondaryIndex(const std::string& indexName, EIndexType type, const std::vector& indexColumns); void AddSecondaryIndex(const std::string& indexName, EIndexType type, const std::vector& indexColumns, const std::vector& dataColumns); + void AddSecondaryIndex(const TIndexDescription& indexDescription); // sync void AddSyncSecondaryIndex(const std::string& indexName, const std::vector& indexColumns); void AddSyncSecondaryIndex(const std::string& indexName, const std::vector& indexColumns, const std::vector& dataColumns); @@ -853,6 +854,7 @@ class TTableBuilder { TTableBuilder& SetPrimaryKeyColumn(const std::string& primaryKeyColumn); // common + TTableBuilder& AddSecondaryIndex(const TIndexDescription& indexDescription); TTableBuilder& AddSecondaryIndex(const std::string& indexName, EIndexType type, const std::vector& indexColumns, const std::vector& dataColumns); TTableBuilder& AddSecondaryIndex(const std::string& indexName, EIndexType type, const std::vector& indexColumns); TTableBuilder& AddSecondaryIndex(const std::string& indexName, EIndexType type, const std::string& indexColumn); diff --git a/src/client/table/table.cpp b/src/client/table/table.cpp index 01119cba90..67df1cf1cc 100644 --- a/src/client/table/table.cpp +++ b/src/client/table/table.cpp @@ -469,6 +469,10 @@ class TTableDescription::TImpl { Indexes_.emplace_back(TIndexDescription(indexName, type, indexColumns, dataColumns)); } + void AddSecondaryIndex(const TIndexDescription& indexDescription) { + Indexes_.emplace_back(indexDescription); + } + void AddVectorIndex(const std::string& indexName, EIndexType type, const std::vector& indexColumns, const TVectorIndexSettings& vectorIndexSettings) { Indexes_.emplace_back(TIndexDescription(indexName, type, indexColumns, {}, {}, vectorIndexSettings)); } @@ -750,6 +754,10 @@ void TTableDescription::AddSecondaryIndex(const std::string& indexName, EIndexTy Impl_->AddSecondaryIndex(indexName, type, indexColumns, dataColumns); } +void TTableDescription::AddSecondaryIndex(const TIndexDescription& indexDescription) { + Impl_->AddSecondaryIndex(indexDescription); +} + void TTableDescription::AddSyncSecondaryIndex(const std::string& indexName, const std::vector& indexColumns) { AddSecondaryIndex(indexName, EIndexType::GlobalSync, indexColumns); } @@ -1174,6 +1182,11 @@ TTableBuilder& TTableBuilder::SetPrimaryKeyColumn(const std::string& primaryKeyC return *this; } +TTableBuilder& TTableBuilder::AddSecondaryIndex(const TIndexDescription& indexDescription) { + TableDescription_.AddSecondaryIndex(indexDescription); + return *this; +} + TTableBuilder& TTableBuilder::AddSecondaryIndex(const std::string& indexName, EIndexType type, const std::vector& indexColumns, const std::vector& dataColumns) { TableDescription_.AddSecondaryIndex(indexName, type, indexColumns, dataColumns); return *this; @@ -2377,7 +2390,7 @@ TVectorIndexSettings TVectorIndexSettings::FromProto(const TProto& proto) { default: return {}; } - }; + }; return { .Metric = metricFromProto(proto),