From 67c3020d9b625b5480f99639a7b76af56fd3f3dd Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Tue, 3 Dec 2024 16:33:38 -0600 Subject: [PATCH] Improved the performance of TableServiceClient.GetTableClient() --- sdk/tables/Azure.Data.Tables/CHANGELOG.md | 1 + sdk/tables/Azure.Data.Tables/src/TableClient.cs | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sdk/tables/Azure.Data.Tables/CHANGELOG.md b/sdk/tables/Azure.Data.Tables/CHANGELOG.md index 08e33625c427c..a7f7638829dc3 100644 --- a/sdk/tables/Azure.Data.Tables/CHANGELOG.md +++ b/sdk/tables/Azure.Data.Tables/CHANGELOG.md @@ -11,6 +11,7 @@ ### Bugs Fixed ### Other Changes +- Improved the performance of `TableServiceClient.GetTableClient()` ## 12.9.1 (2024-09-17) diff --git a/sdk/tables/Azure.Data.Tables/src/TableClient.cs b/sdk/tables/Azure.Data.Tables/src/TableClient.cs index 8b2346e1727c1..4bae886964b6c 100644 --- a/sdk/tables/Azure.Data.Tables/src/TableClient.cs +++ b/sdk/tables/Azure.Data.Tables/src/TableClient.cs @@ -234,7 +234,7 @@ public TableClient(string connectionString, string tableName, TableClientOptions _version = options.VersionString; _diagnostics = new ClientDiagnostics(options); _tableOperations = new TableRestClient(_diagnostics, _pipeline, _endpoint.AbsoluteUri, _version); - _batchOperations = new TableRestClient(_diagnostics, CreateBatchPipeline(), _tableOperations.endpoint, _tableOperations.clientVersion); + _batchOperations = new TableRestClient(_diagnostics, _batchPipeline, _tableOperations.endpoint, _tableOperations.clientVersion); Name = tableName; Uri = new TableUriBuilder(_endpoint) { Query = null, Sas = null, Tablename = Name }.ToUri(); } @@ -286,7 +286,7 @@ public TableClient(Uri endpoint, string tableName, TokenCredential tokenCredenti _version = options.VersionString; _diagnostics = new ClientDiagnostics(options); _tableOperations = new TableRestClient(_diagnostics, _pipeline, _endpoint.AbsoluteUri, _version); - _batchOperations = new TableRestClient(_diagnostics, CreateBatchPipeline(), _tableOperations.endpoint, _tableOperations.clientVersion); + _batchOperations = new TableRestClient(_diagnostics, _batchPipeline, _tableOperations.endpoint, _tableOperations.clientVersion); Name = tableName; Uri = new TableUriBuilder(_endpoint) { Query = null, Sas = null, Tablename = Name }.ToUri(); } @@ -337,7 +337,7 @@ null when string.IsNullOrWhiteSpace(_endpoint.Query) => policy, _version = options.VersionString; _diagnostics = new ClientDiagnostics(options); _tableOperations = new TableRestClient(_diagnostics, _pipeline, _endpoint.AbsoluteUri, _version); - _batchOperations = new TableRestClient(_diagnostics, CreateBatchPipeline(), _tableOperations.endpoint, _tableOperations.clientVersion); + _batchOperations = new TableRestClient(_diagnostics, _batchPipeline, _tableOperations.endpoint, _tableOperations.clientVersion); Name = tableName; Uri = new TableUriBuilder(_endpoint) { Query = null, Sas = null, Tablename = Name }.ToUri(); } @@ -363,7 +363,7 @@ internal TableClient( { _tableOperations = tableOperations; } - _batchOperations = new TableRestClient(diagnostics, CreateBatchPipeline(), _tableOperations.endpoint, _tableOperations.clientVersion); + _batchOperations = new TableRestClient(diagnostics, _batchPipeline, _tableOperations.endpoint, _tableOperations.clientVersion); _version = version; Name = table; Uri = new TableUriBuilder(_endpoint) { Query = null, Sas = null, Tablename = Name }.ToUri(); @@ -1743,6 +1743,8 @@ private HttpMessage CreateUpdateOrMergeRequest(TableRestClient batchOperations, return msg; } + private static readonly HttpPipeline _batchPipeline = CreateBatchPipeline(); + /// /// Creates a pipeline to use for processing sub-operations before they are combined into a single multipart request. ///