-
Notifications
You must be signed in to change notification settings - Fork 525
Query: Adds Distribution for MakeList and MakeSet #4490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
microsoft-github-policy-service
merged 24 commits into
master
from
users/ezrahaleva/MakeListDistribution
Jun 20, 2024
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
e443aa3
added MakeList and MakeSet aggregators
ezrahaleva-msft db1872a
Added MakeList and MakeSet to AggregateQueryTests.cs
ezrahaleva-msft b84e8e2
Adjust Aggregators
ezrahaleva-msft f42c7ec
Add Array Aggregate Continuation Token Test
ezrahaleva-msft 2cb739c
Added group by coverage for MakeList and MakeSet
ezrahaleva-msft 7c863d4
address comments
ezrahaleva-msft ff6637c
cleaning
ezrahaleva-msft a2c6d44
Refactored test to better detect when to ignore result order
ezrahaleva-msft 1c82431
cleaning
ezrahaleva-msft 8353971
cleaning, update baseline
ezrahaleva-msft 2758e0b
cleaning
ezrahaleva-msft 61059ac
removed old comment
ezrahaleva-msft 57f6311
cleaning/refactoring
ezrahaleva-msft 2c1c051
Merge branch 'master' into users/ezrahaleva/MakeListDistribution
ezrahaleva-msft 51f5d12
cleaning
ezrahaleva-msft 5fcb089
Add explicit cases to hit continuation token limit.
ezrahaleva-msft 6522334
Added additional case to GroupBy tests
ezrahaleva-msft 0defd1a
cleaning
ezrahaleva-msft eec3632
cleaning
ezrahaleva-msft 918c35e
cleaning, updated baseline test
ezrahaleva-msft 4dc9f9d
cleaning, updated baseline test
ezrahaleva-msft f05d33f
Added coverage to QueryPlanBaselineTests.cs
ezrahaleva-msft 710fc76
refactored
ezrahaleva-msft be853ce
Merge branch 'master' into users/ezrahaleva/MakeListDistribution
ezrahaleva-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,8 @@ internal enum AggregateOperator | |
| { | ||
| Average, | ||
| Count, | ||
| MakeList, | ||
| MakeSet, | ||
| Max, | ||
| Min, | ||
| Sum, | ||
|
|
||
70 changes: 70 additions & 0 deletions
70
Microsoft.Azure.Cosmos/src/Query/Core/Pipeline/Aggregate/Aggregators/MakeListAggregator.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| //------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| //------------------------------------------------------------ | ||
|
|
||
| namespace Microsoft.Azure.Cosmos.Query.Core.Pipeline.Aggregate.Aggregators | ||
| { | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.Globalization; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using Microsoft.Azure.Cosmos.CosmosElements; | ||
| using Microsoft.Azure.Cosmos.CosmosElements.Numbers; | ||
| using Microsoft.Azure.Cosmos.Query.Core.Exceptions; | ||
| using Microsoft.Azure.Cosmos.Query.Core.Monads; | ||
|
|
||
| internal sealed class MakeListAggregator : IAggregator | ||
| { | ||
| private readonly List<CosmosElement> globalList; | ||
|
|
||
| private MakeListAggregator(CosmosArray initialList) | ||
ezrahaleva-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| this.globalList = new List<CosmosElement>(); | ||
|
|
||
| this.Aggregate(initialList); | ||
| } | ||
|
|
||
| public void Aggregate(CosmosElement localList) | ||
| { | ||
| if (!(localList is CosmosArray cosmosArray)) | ||
| { | ||
| throw new ArgumentException($"{nameof(localList)} must be an array."); | ||
| } | ||
|
|
||
| this.globalList.AddRange(cosmosArray.ToList<CosmosElement>()); | ||
| } | ||
ezrahaleva-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public CosmosElement GetResult() | ||
| { | ||
| return CosmosArray.Create(this.globalList); | ||
| } | ||
ezrahaleva-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public static TryCatch<IAggregator> TryCreate(CosmosElement continuationToken) | ||
| { | ||
| CosmosArray partialList; | ||
| if (continuationToken != null) | ||
| { | ||
| if (!(continuationToken is CosmosArray cosmosPartialList)) | ||
| { | ||
| return TryCatch<IAggregator>.FromException( | ||
| new MalformedContinuationTokenException($@"Invalid MakeList continuation token: ""{continuationToken}"".")); | ||
| } | ||
|
|
||
| partialList = cosmosPartialList; | ||
| } | ||
| else | ||
| { | ||
| partialList = CosmosArray.Empty; | ||
| } | ||
|
|
||
| return TryCatch<IAggregator>.FromResult(new MakeListAggregator(initialList: partialList)); | ||
| } | ||
ezrahaleva-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public CosmosElement GetCosmosElementContinuationToken() | ||
ezrahaleva-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| return this.GetResult(); | ||
| } | ||
ezrahaleva-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
75 changes: 75 additions & 0 deletions
75
Microsoft.Azure.Cosmos/src/Query/Core/Pipeline/Aggregate/Aggregators/MakeSetAggregator.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| //------------------------------------------------------------ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| //------------------------------------------------------------ | ||
|
|
||
| namespace Microsoft.Azure.Cosmos.Query.Core.Pipeline.Aggregate.Aggregators | ||
| { | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.Globalization; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using Microsoft.Azure.Cosmos.CosmosElements; | ||
| using Microsoft.Azure.Cosmos.CosmosElements.Numbers; | ||
| using Microsoft.Azure.Cosmos.Query.Core.Exceptions; | ||
| using Microsoft.Azure.Cosmos.Query.Core.Monads; | ||
|
|
||
| internal sealed class MakeSetAggregator : IAggregator | ||
| { | ||
| private readonly HashSet<CosmosElement> globalSet; | ||
|
|
||
| private MakeSetAggregator(CosmosArray initialSet) | ||
ezrahaleva-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| this.globalSet = new HashSet<CosmosElement>(); | ||
|
|
||
| this.Aggregate(initialSet); | ||
| } | ||
|
|
||
| public void Aggregate(CosmosElement localSet) | ||
| { | ||
| if (!(localSet is CosmosArray cosmosArray)) | ||
| { | ||
| throw new ArgumentException($"{nameof(localSet)} must be an array."); | ||
| } | ||
|
|
||
| this.globalSet.UnionWith(cosmosArray.ToList<CosmosElement>()); | ||
| } | ||
|
|
||
| public CosmosElement GetResult() | ||
| { | ||
| return CosmosArray.Create(this.globalSet); | ||
| } | ||
|
|
||
| public string GetContinuationToken() | ||
| { | ||
| return this.globalSet.ToString(); | ||
| } | ||
|
|
||
| public static TryCatch<IAggregator> TryCreate(CosmosElement continuationToken) | ||
| { | ||
| CosmosArray partialSet; | ||
| if (continuationToken != null) | ||
| { | ||
| if (!(continuationToken is CosmosArray cosmosPartialSet)) | ||
| { | ||
| return TryCatch<IAggregator>.FromException( | ||
| new MalformedContinuationTokenException($@"Invalid MakeSet continuation token: ""{continuationToken}"".")); | ||
| } | ||
|
|
||
| partialSet = cosmosPartialSet; | ||
| } | ||
| else | ||
| { | ||
| partialSet = CosmosArray.Empty; | ||
| } | ||
|
|
||
| return TryCatch<IAggregator>.FromResult(new MakeSetAggregator(initialSet: partialSet)); | ||
| } | ||
ezrahaleva-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public CosmosElement GetCosmosElementContinuationToken() | ||
| { | ||
| return this.GetResult(); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.