Skip to content

Commit

Permalink
Merge branch 'users/ealsur/bulkretry503' of https://github.com/Azure/…
Browse files Browse the repository at this point in the history
…azure-cosmos-dotnet-v3 into users/ealsur/bulkretry503
  • Loading branch information
ealsur committed Dec 16, 2020
2 parents 0b462bd + c44ab3a commit a2ae814
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 212 deletions.
3 changes: 2 additions & 1 deletion Microsoft.Azure.Cosmos/src/Handler/RequestInvokerHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ internal static HttpMethod GetHttpMethod(
operationType == OperationType.SqlQuery ||
operationType == OperationType.QueryPlan ||
operationType == OperationType.Batch ||
operationType == OperationType.ExecuteJavaScript)
operationType == OperationType.ExecuteJavaScript ||
operationType == OperationType.CompleteUserTransaction)
{
return HttpMethod.Post;
}
Expand Down
18 changes: 5 additions & 13 deletions Microsoft.Azure.Cosmos/src/Json/JsonWriter.JsonBinaryWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ namespace Microsoft.Azure.Cosmos.Json
#endif
abstract partial class JsonWriter : IJsonWriter
{
internal static bool EnableEncodedStrings = false;

/// <summary>
/// Concrete implementation of <see cref="JsonWriter"/> that knows how to serialize to binary encoding.
/// </summary>
Expand Down Expand Up @@ -738,23 +736,20 @@ private void WriteFieldNameOrString(bool isFieldName, Utf8Span utf8Span)
throw new InvalidOperationException($"Unable to serialize a {nameof(JsonBinaryEncoding.MultiByteTypeMarker)} of length: {multiByteTypeMarker.Length}");
}
}
else if (EnableEncodedStrings
&& isFieldName
else if (isFieldName
&& (utf8Span.Length >= MinReferenceStringLength)
&& this.TryRegisterStringValue(utf8Span))
{
// Work is done in the check
}
else if (EnableEncodedStrings
&& !isFieldName
else if (!isFieldName
&& (utf8Span.Length == JsonBinaryEncoding.GuidLength)
&& JsonBinaryEncoding.TryEncodeGuidString(utf8Span.Span, this.binaryWriter.Cursor))
{
// Encoded value as guid string
this.binaryWriter.Position += JsonBinaryEncoding.EncodedGuidLength;
}
else if (EnableEncodedStrings
&& !isFieldName
else if (!isFieldName
&& (utf8Span.Length == JsonBinaryEncoding.GuidWithQuotesLength)
&& (utf8Span.Span[0] == '"')
&& (utf8Span.Span[JsonBinaryEncoding.GuidWithQuotesLength - 1] == '"')
Expand All @@ -765,16 +760,13 @@ private void WriteFieldNameOrString(bool isFieldName, Utf8Span utf8Span)
this.binaryWriter.Cursor[0] = JsonBinaryEncoding.TypeMarker.DoubleQuotedLowercaseGuidString;
this.binaryWriter.Position += JsonBinaryEncoding.EncodedGuidLength;
}
else if (EnableEncodedStrings
&& !isFieldName
else if (!isFieldName
&& JsonBinaryEncoding.TryEncodeCompressedString(utf8Span.Span, this.binaryWriter.Cursor, out int bytesWritten))
{
// Encoded value as a compressed string
this.binaryWriter.Position += bytesWritten;
}
else if (
EnableEncodedStrings
&& !isFieldName
else if (!isFieldName
&& (utf8Span.Length >= MinReferenceStringLength)
&& (utf8Span.Length <= MaxReferenceStringLength)
&& this.TryRegisterStringValue(utf8Span))
Expand Down

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
Loading

0 comments on commit a2ae814

Please sign in to comment.