Skip to content

Commit

Permalink
cleaned up epkrange comparer code in parallel query (#2060)
Browse files Browse the repository at this point in the history
  • Loading branch information
bchong95 authored Dec 16, 2020
1 parent a2cd79c commit 5bd37c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 49 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,26 @@ public async ValueTask<bool> MoveNextAsync(ITrace trace)
else
{
// left most and any non null continuations
List<FeedRangeState<QueryState>> feedRangeStates = crossPartitionState
IOrderedEnumerable<FeedRangeState<QueryState>> feedRangeStates = crossPartitionState
.Value
.ToArray()
.OrderBy(tuple => (FeedRangeEpk)tuple.FeedRange, EpkRangeComparer.Singleton)
.ToList();
.OrderBy(tuple => ((FeedRangeEpk)tuple.FeedRange).Range.Min);

List<ParallelContinuationToken> activeParallelContinuationTokens = new List<ParallelContinuationToken>();
for (int i = 0; i < feedRangeStates.Count; i++)
{
FeedRangeState<QueryState> firstState = feedRangeStates.First();
ParallelContinuationToken firstParallelContinuationToken = new ParallelContinuationToken(
token: firstState.State != null ? ((CosmosString)firstState.State.Value).Value : null,
range: ((FeedRangeEpk)firstState.FeedRange).Range);

activeParallelContinuationTokens.Add(firstParallelContinuationToken);
}

foreach (FeedRangeState<QueryState> feedRangeState in feedRangeStates.Skip(1))
{
this.cancellationToken.ThrowIfCancellationRequested();

FeedRangeState<QueryState> feedRangeState = feedRangeStates[i];
if ((i == 0) || (feedRangeState.State != null))
if (feedRangeState.State != null)
{
ParallelContinuationToken parallelContinuationToken = new ParallelContinuationToken(
token: feedRangeState.State != null ? ((CosmosString)feedRangeState.State.Value).Value : null,
Expand Down

0 comments on commit 5bd37c9

Please sign in to comment.