diff options
author | sabdenovch <sabdenovch@yandex-team.com> | 2023-11-13 17:13:28 +0300 |
---|---|---|
committer | sabdenovch <sabdenovch@yandex-team.com> | 2023-11-13 17:39:55 +0300 |
commit | 1cf16c24115be68be4115e95138a7dafb36da0fe (patch) | |
tree | ac01fe1281dcf5ab7fadfbd4fa13089ea34870cc | |
parent | 57c8de46af8f8840637688fe93275b6305b5b137 (diff) | |
download | ydb-1cf16c24115be68be4115e95138a7dafb36da0fe.tar.gz |
YT-20267: Synchronous updates of table and secondary index
Implemented synchronous updates to table and index. Also, schema validation upon index creation added
-rw-r--r-- | yt/yt/client/api/rpc_proxy/table_mount_cache.cpp | 10 | ||||
-rw-r--r-- | yt/yt/client/table_client/row_buffer.cpp | 9 | ||||
-rw-r--r-- | yt/yt/client/table_client/row_buffer.h | 3 | ||||
-rw-r--r-- | yt/yt/client/tablet_client/public.h | 4 | ||||
-rw-r--r-- | yt/yt/client/tablet_client/table_mount_cache.h | 10 | ||||
-rw-r--r-- | yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto | 7 |
6 files changed, 41 insertions, 2 deletions
diff --git a/yt/yt/client/api/rpc_proxy/table_mount_cache.cpp b/yt/yt/client/api/rpc_proxy/table_mount_cache.cpp index 8fa52f652d..0ed2e660bb 100644 --- a/yt/yt/client/api/rpc_proxy/table_mount_cache.cpp +++ b/yt/yt/client/api/rpc_proxy/table_mount_cache.cpp @@ -96,6 +96,16 @@ private: tableInfo->Replicas.push_back(replicaInfo); } + tableInfo->Indices.reserve(rsp->indices_size()); + for (const auto& protoIndexInfo: rsp->indices()) { + TIndexInfo indexInfo; + FromProto(&indexInfo.TableId, protoIndexInfo.index_table_id()); + indexInfo.Kind = FromProto<ESecondaryIndexKind>(protoIndexInfo.index_kind()); + THROW_ERROR_EXCEPTION_IF(!TEnumTraits<ESecondaryIndexKind>::FindLiteralByValue(indexInfo.Kind).has_value(), + "Unsupported secondary index kind %v (client not up-to-date)", indexInfo.Kind); + tableInfo->Indices.push_back(indexInfo); + } + if (tableInfo->IsSorted()) { tableInfo->LowerCapBound = MinKey(); tableInfo->UpperCapBound = MaxKey(); diff --git a/yt/yt/client/table_client/row_buffer.cpp b/yt/yt/client/table_client/row_buffer.cpp index 40b85f7f1f..38036bd80d 100644 --- a/yt/yt/client/table_client/row_buffer.cpp +++ b/yt/yt/client/table_client/row_buffer.cpp @@ -107,7 +107,8 @@ TMutableUnversionedRow TRowBuffer::CaptureAndPermuteRow( const TTableSchema& tableSchema, int schemafulColumnCount, const TNameTableToSchemaIdMapping& idMapping, - std::vector<bool>* columnPresenceBuffer) + std::vector<bool>* columnPresenceBuffer, + std::optional<TUnversionedValue> addend) { int valueCount = schemafulColumnCount; @@ -126,6 +127,9 @@ TMutableUnversionedRow TRowBuffer::CaptureAndPermuteRow( ++valueCount; } } + if (addend) { + ++valueCount; + } auto capturedRow = TMutableUnversionedRow::Allocate(&Pool_, valueCount); for (int pos = 0; pos < schemafulColumnCount; ++pos) { @@ -144,6 +148,9 @@ TMutableUnversionedRow TRowBuffer::CaptureAndPermuteRow( capturedRow[pos] = value; capturedRow[pos].Id = mappedId; } + if (addend) { + capturedRow[valueCount++] = *addend; + } return capturedRow; } diff --git a/yt/yt/client/table_client/row_buffer.h b/yt/yt/client/table_client/row_buffer.h index 48f6494016..94e3605027 100644 --- a/yt/yt/client/table_client/row_buffer.h +++ b/yt/yt/client/table_client/row_buffer.h @@ -81,7 +81,8 @@ public: const TTableSchema& tableSchema, int schemafulColumnCount, const TNameTableToSchemaIdMapping& idMapping, - std::vector<bool>* columnPresenceBuffer); + std::vector<bool>* columnPresenceBuffer, + std::optional<TUnversionedValue> addend = std::nullopt); //! Captures the row applying #idMapping to value ids. //! #idMapping must be identity for key columns. diff --git a/yt/yt/client/tablet_client/public.h b/yt/yt/client/tablet_client/public.h index 782a8d19ec..799fdb05ab 100644 --- a/yt/yt/client/tablet_client/public.h +++ b/yt/yt/client/tablet_client/public.h @@ -206,6 +206,10 @@ DEFINE_ENUM(ETabletServiceFeatures, ((WriteGenerations) (0)) ); +DEFINE_ENUM(ESecondaryIndexKind, + ((FullSync) (0)) +); + //////////////////////////////////////////////////////////////////////////////// DECLARE_REFCOUNTED_CLASS(TTableMountCacheConfig) diff --git a/yt/yt/client/tablet_client/table_mount_cache.h b/yt/yt/client/tablet_client/table_mount_cache.h index a83c13002d..44fa398800 100644 --- a/yt/yt/client/tablet_client/table_mount_cache.h +++ b/yt/yt/client/tablet_client/table_mount_cache.h @@ -61,6 +61,14 @@ DEFINE_REFCOUNTED_TYPE(TTableReplicaInfo) //////////////////////////////////////////////////////////////////////////////// +struct TIndexInfo +{ + NObjectClient::TObjectId TableId; + ESecondaryIndexKind Kind; +}; + +//////////////////////////////////////////////////////////////////////////////// + //! Describes the primary and the auxiliary schemas derived from the table schema. //! Cf. TTableSchema::ToXXX methods. DEFINE_ENUM(ETableSchemaKind, @@ -107,6 +115,8 @@ struct TTableMountInfo std::vector<TTableReplicaInfoPtr> Replicas; + std::vector<TIndexInfo> Indices; + //! For sorted tables, these are -infinity and +infinity. //! For ordered tablets, these are |[0]| and |[tablet_count]| resp. NTableClient::TLegacyOwningKey LowerCapBound; diff --git a/yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto b/yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto index 4d76c67036..e997eeed4f 100644 --- a/yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto +++ b/yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto @@ -1275,6 +1275,12 @@ message TReplicaInfo required int32 mode = 4; // ETableReplicaMode } +message TIndexInfo +{ + required NYT.NProto.TGuid index_table_id = 1; + required int32 index_kind = 2; // NTableClient::ESecondaryIndexKind +} + message TReqGetTableMountInfo { required string path = 1; @@ -1289,6 +1295,7 @@ message TRspGetTableMountInfo required NYT.NProto.TGuid upstream_replica_id = 5; repeated TReplicaInfo replicas = 6; optional string physical_path = 7; + repeated TIndexInfo indices = 8; } //////////////////////////////////////////////////////////////////////////////// |