From 8a6e787f1b75511494395b0245f80e0350b55baf Mon Sep 17 00:00:00 2001 From: Neil Deshpande Date: Sun, 6 Mar 2022 15:11:06 -0800 Subject: [PATCH 1/4] Move FeedRange API for Query to GA --- .../src/Resource/Container/Container.cs | 204 +++++++++--------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/Resource/Container/Container.cs b/Microsoft.Azure.Cosmos/src/Resource/Container/Container.cs index c1f0dda873..86c04c005d 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Container/Container.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Container/Container.cs @@ -1082,6 +1082,108 @@ public abstract FeedIterator GetItemQueryIterator( string continuationToken = null, QueryRequestOptions requestOptions = null); + /// + /// This method creates a query for items under a container in an Azure Cosmos database using a SQL statement with parameterized values. It returns a FeedIterator. + /// For more information on preparing SQL statements with parameterized values, please see . + /// + /// A FeedRange obtained from + /// The Cosmos SQL query definition. + /// (Optional) The continuation token in the Azure Cosmos DB service. + /// (Optional) The options for the item query request. + /// An iterator to go through the items. + /// + /// Query as a stream only supports single partition queries + /// + /// https://aka.ms/cosmosdb-dot-net-exceptions#stream-api + /// + /// Create a query to get all the ToDoActivity that have a cost greater than 9000 for the specified partition + /// + /// feedRanges = await this.Container.GetFeedRangesAsync(); + /// // Distribute feedRanges across multiple compute units and pass each one to a different iterator + /// QueryDefinition queryDefinition = new QueryDefinition("select * from ToDos t where t.cost > @expensive") + /// .WithParameter("@expensive", 9000); + /// using (FeedIterator feedIterator = this.Container.GetItemQueryStreamIterator( + /// feedRanges[0], + /// queryDefinition, + /// null, + /// new QueryRequestOptions() { })) + /// { + /// while (feedIterator.HasMoreResults) + /// { + /// using (ResponseMessage response = await feedIterator.ReadNextAsync()) + /// { + /// using (StreamReader sr = new StreamReader(response.Content)) + /// using (JsonTextReader jtr = new JsonTextReader(sr)) + /// { + /// JObject result = JObject.Load(jtr); + /// } + /// } + /// } + /// } + /// ]]> + /// + /// + public abstract FeedIterator GetItemQueryStreamIterator( + FeedRange feedRange, + QueryDefinition queryDefinition, + string continuationToken, + QueryRequestOptions requestOptions = null); + + /// + /// This method creates a query for items under a container in an Azure Cosmos database using a SQL statement with parameterized values. It returns a FeedIterator. + /// For more information on preparing SQL statements with parameterized values, please see . + /// + /// A FeedRange obtained from . + /// The Cosmos SQL query definition. + /// (Optional) The continuation token in the Azure Cosmos DB service. + /// (Optional) The options for the item query request. + /// An iterator to go through the items. + /// + /// Query as a stream only supports single partition queries + /// + /// https://aka.ms/cosmosdb-dot-net-exceptions#typed-api + /// + /// Create a query to get all the ToDoActivity that have a cost greater than 9000 for the specified partition + /// + /// feedRanges = await this.Container.GetFeedRangesAsync(); + /// // Distribute feedRanges across multiple compute units and pass each one to a different iterator + /// QueryDefinition queryDefinition = new QueryDefinition("select * from ToDos t where t.cost > @expensive") + /// .WithParameter("@expensive", 9000); + /// using (FeedIterator feedIterator = this.Container.GetItemQueryIterator( + /// feedRanges[0], + /// queryDefinition, + /// null, + /// new QueryRequestOptions() { })) + /// { + /// while (feedIterator.HasMoreResults) + /// { + /// foreach(var item in await feedIterator.ReadNextAsync()) + /// { + /// Console.WriteLine(item.cost); + /// } + /// } + /// } + /// ]]> + /// + /// + public abstract FeedIterator GetItemQueryIterator( + FeedRange feedRange, + QueryDefinition queryDefinition, + string continuationToken = null, + QueryRequestOptions requestOptions = null); + /// /// This method creates a LINQ query for items under a container in an Azure Cosmos DB service. /// IQueryable extension method ToFeedIterator() should be use for asynchronous execution with FeedIterator, please refer to example 2. @@ -1562,108 +1664,6 @@ public abstract Task> GetPartitionKeyRangesAsync( FeedRange feedRange, CancellationToken cancellationToken = default); - /// - /// This method creates a query for items under a container in an Azure Cosmos database using a SQL statement with parameterized values. It returns a FeedIterator. - /// For more information on preparing SQL statements with parameterized values, please see . - /// - /// A FeedRange obtained from - /// The Cosmos SQL query definition. - /// (Optional) The continuation token in the Azure Cosmos DB service. - /// (Optional) The options for the item query request. - /// An iterator to go through the items. - /// - /// Query as a stream only supports single partition queries - /// - /// https://aka.ms/cosmosdb-dot-net-exceptions#stream-api - /// - /// Create a query to get all the ToDoActivity that have a cost greater than 9000 for the specified partition - /// - /// feedRanges = await this.Container.GetFeedRangesAsync(); - /// // Distribute feedRanges across multiple compute units and pass each one to a different iterator - /// QueryDefinition queryDefinition = new QueryDefinition("select * from ToDos t where t.cost > @expensive") - /// .WithParameter("@expensive", 9000); - /// using (FeedIterator feedIterator = this.Container.GetItemQueryStreamIterator( - /// feedRanges[0], - /// queryDefinition, - /// null, - /// new QueryRequestOptions() { })) - /// { - /// while (feedIterator.HasMoreResults) - /// { - /// using (ResponseMessage response = await feedIterator.ReadNextAsync()) - /// { - /// using (StreamReader sr = new StreamReader(response.Content)) - /// using (JsonTextReader jtr = new JsonTextReader(sr)) - /// { - /// JObject result = JObject.Load(jtr); - /// } - /// } - /// } - /// } - /// ]]> - /// - /// - public abstract FeedIterator GetItemQueryStreamIterator( - FeedRange feedRange, - QueryDefinition queryDefinition, - string continuationToken, - QueryRequestOptions requestOptions = null); - - /// - /// This method creates a query for items under a container in an Azure Cosmos database using a SQL statement with parameterized values. It returns a FeedIterator. - /// For more information on preparing SQL statements with parameterized values, please see . - /// - /// A FeedRange obtained from . - /// The Cosmos SQL query definition. - /// (Optional) The continuation token in the Azure Cosmos DB service. - /// (Optional) The options for the item query request. - /// An iterator to go through the items. - /// - /// Query as a stream only supports single partition queries - /// - /// https://aka.ms/cosmosdb-dot-net-exceptions#typed-api - /// - /// Create a query to get all the ToDoActivity that have a cost greater than 9000 for the specified partition - /// - /// feedRanges = await this.Container.GetFeedRangesAsync(); - /// // Distribute feedRanges across multiple compute units and pass each one to a different iterator - /// QueryDefinition queryDefinition = new QueryDefinition("select * from ToDos t where t.cost > @expensive") - /// .WithParameter("@expensive", 9000); - /// using (FeedIterator feedIterator = this.Container.GetItemQueryIterator( - /// feedRanges[0], - /// queryDefinition, - /// null, - /// new QueryRequestOptions() { })) - /// { - /// while (feedIterator.HasMoreResults) - /// { - /// foreach(var item in await feedIterator.ReadNextAsync()) - /// { - /// Console.WriteLine(item.cost); - /// } - /// } - /// } - /// ]]> - /// - /// - public abstract FeedIterator GetItemQueryIterator( - FeedRange feedRange, - QueryDefinition queryDefinition, - string continuationToken = null, - QueryRequestOptions requestOptions = null); - #endif } } From 46cc0823a25221a050a7120d63c98b0c417ff8f4 Mon Sep 17 00:00:00 2001 From: Neil Deshpande Date: Sun, 6 Mar 2022 15:27:09 -0800 Subject: [PATCH 2/4] Fix up build break --- .../src/Resource/Container/ContainerInternal.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInternal.cs b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInternal.cs index 54d13bcb36..506ba64a74 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInternal.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerInternal.cs @@ -156,17 +156,6 @@ public abstract Task> GetPartitionKeyRangesAsync( FeedRange feedRange, CancellationToken cancellationToken = default); - public abstract FeedIterator GetItemQueryStreamIterator( - FeedRange feedRange, - QueryDefinition queryDefinition, - string continuationToken, - QueryRequestOptions requestOptions = null); - - public abstract FeedIterator GetItemQueryIterator( - FeedRange feedRange, - QueryDefinition queryDefinition, - string continuationToken = null, - QueryRequestOptions requestOptions = null); #endif public abstract class TryExecuteQueryResult From 1650c5a1d99f19839433c7188043f97606b21b6a Mon Sep 17 00:00:00 2001 From: Neil Deshpande Date: Sun, 6 Mar 2022 18:53:43 -0800 Subject: [PATCH 3/4] Update DotNetSDKAPI.json --- .../Contracts/DotNetSDKAPI.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json index fdd6f2e9b4..79cc96a511 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json @@ -1038,6 +1038,11 @@ "Attributes": [], "MethodInfo": "Microsoft.Azure.Cosmos.FeedIterator GetChangeFeedStreamIterator(Microsoft.Azure.Cosmos.ChangeFeedStartFrom, Microsoft.Azure.Cosmos.ChangeFeedMode, Microsoft.Azure.Cosmos.ChangeFeedRequestOptions);IsAbstract:True;IsStatic:False;IsVirtual:True;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" }, + "Microsoft.Azure.Cosmos.FeedIterator GetItemQueryStreamIterator(Microsoft.Azure.Cosmos.FeedRange, Microsoft.Azure.Cosmos.QueryDefinition, System.String, Microsoft.Azure.Cosmos.QueryRequestOptions)": { + "Type": "Method", + "Attributes": [], + "MethodInfo": "Microsoft.Azure.Cosmos.FeedIterator GetItemQueryStreamIterator(Microsoft.Azure.Cosmos.FeedRange, Microsoft.Azure.Cosmos.QueryDefinition, System.String, Microsoft.Azure.Cosmos.QueryRequestOptions);IsAbstract:True;IsStatic:False;IsVirtual:True;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" + }, "Microsoft.Azure.Cosmos.FeedIterator GetItemQueryStreamIterator(Microsoft.Azure.Cosmos.QueryDefinition, System.String, Microsoft.Azure.Cosmos.QueryRequestOptions)": { "Type": "Method", "Attributes": [], @@ -1053,6 +1058,11 @@ "Attributes": [], "MethodInfo": "Microsoft.Azure.Cosmos.FeedIterator`1[T] GetChangeFeedIterator[T](Microsoft.Azure.Cosmos.ChangeFeedStartFrom, Microsoft.Azure.Cosmos.ChangeFeedMode, Microsoft.Azure.Cosmos.ChangeFeedRequestOptions);IsAbstract:True;IsStatic:False;IsVirtual:True;IsGenericMethod:True;IsConstructor:False;IsFinal:False;" }, + "Microsoft.Azure.Cosmos.FeedIterator`1[T] GetItemQueryIterator[T](Microsoft.Azure.Cosmos.FeedRange, Microsoft.Azure.Cosmos.QueryDefinition, System.String, Microsoft.Azure.Cosmos.QueryRequestOptions)": { + "Type": "Method", + "Attributes": [], + "MethodInfo": "Microsoft.Azure.Cosmos.FeedIterator`1[T] GetItemQueryIterator[T](Microsoft.Azure.Cosmos.FeedRange, Microsoft.Azure.Cosmos.QueryDefinition, System.String, Microsoft.Azure.Cosmos.QueryRequestOptions);IsAbstract:True;IsStatic:False;IsVirtual:True;IsGenericMethod:True;IsConstructor:False;IsFinal:False;" + }, "Microsoft.Azure.Cosmos.FeedIterator`1[T] GetItemQueryIterator[T](Microsoft.Azure.Cosmos.QueryDefinition, System.String, Microsoft.Azure.Cosmos.QueryRequestOptions)": { "Type": "Method", "Attributes": [], From 3186e99feeb8ca9e40b13afb3edb3b42512009df Mon Sep 17 00:00:00 2001 From: Neil Deshpande Date: Sun, 6 Mar 2022 19:13:44 -0800 Subject: [PATCH 4/4] Update DotNetPreviewSDKAPI.json --- .../Contracts/DotNetPreviewSDKAPI.json | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json index 1d51c448db..912f5d4f42 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetPreviewSDKAPI.json @@ -458,16 +458,6 @@ "Microsoft.Azure.Cosmos.Container;System.Object;IsAbstract:True;IsSealed:False;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": { "Subclasses": {}, "Members": { - "Microsoft.Azure.Cosmos.FeedIterator GetItemQueryStreamIterator(Microsoft.Azure.Cosmos.FeedRange, Microsoft.Azure.Cosmos.QueryDefinition, System.String, Microsoft.Azure.Cosmos.QueryRequestOptions)": { - "Type": "Method", - "Attributes": [], - "MethodInfo": "Microsoft.Azure.Cosmos.FeedIterator GetItemQueryStreamIterator(Microsoft.Azure.Cosmos.FeedRange, Microsoft.Azure.Cosmos.QueryDefinition, System.String, Microsoft.Azure.Cosmos.QueryRequestOptions);IsAbstract:True;IsStatic:False;IsVirtual:True;IsGenericMethod:False;IsConstructor:False;IsFinal:False;" - }, - "Microsoft.Azure.Cosmos.FeedIterator`1[T] GetItemQueryIterator[T](Microsoft.Azure.Cosmos.FeedRange, Microsoft.Azure.Cosmos.QueryDefinition, System.String, Microsoft.Azure.Cosmos.QueryRequestOptions)": { - "Type": "Method", - "Attributes": [], - "MethodInfo": "Microsoft.Azure.Cosmos.FeedIterator`1[T] GetItemQueryIterator[T](Microsoft.Azure.Cosmos.FeedRange, Microsoft.Azure.Cosmos.QueryDefinition, System.String, Microsoft.Azure.Cosmos.QueryRequestOptions);IsAbstract:True;IsStatic:False;IsVirtual:True;IsGenericMethod:True;IsConstructor:False;IsFinal:False;" - }, "System.Threading.Tasks.Task`1[Microsoft.Azure.Cosmos.ResponseMessage] DeleteAllItemsByPartitionKeyStreamAsync(Microsoft.Azure.Cosmos.PartitionKey, Microsoft.Azure.Cosmos.RequestOptions, System.Threading.CancellationToken)": { "Type": "Method", "Attributes": [],