diff --git a/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncBatcher.cs b/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncBatcher.cs
index 103b31076a..75dff4f211 100644
--- a/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncBatcher.cs
+++ b/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncBatcher.cs
@@ -24,7 +24,7 @@ namespace Microsoft.Azure.Cosmos
///
internal class BatchAsyncBatcher
{
- private readonly CosmosSerializer cosmosSerializer;
+ private readonly CosmosSerializerCore serializerCore;
private readonly List batchOperations;
private readonly BatchAsyncBatcherExecuteDelegate executor;
private readonly BatchAsyncBatcherRetryDelegate retrier;
@@ -39,7 +39,7 @@ internal class BatchAsyncBatcher
public BatchAsyncBatcher(
int maxBatchOperationCount,
int maxBatchByteSize,
- CosmosSerializer cosmosSerializer,
+ CosmosSerializerCore serializerCore,
BatchAsyncBatcherExecuteDelegate executor,
BatchAsyncBatcherRetryDelegate retrier)
{
@@ -63,9 +63,9 @@ public BatchAsyncBatcher(
throw new ArgumentNullException(nameof(retrier));
}
- if (cosmosSerializer == null)
+ if (serializerCore == null)
{
- throw new ArgumentNullException(nameof(cosmosSerializer));
+ throw new ArgumentNullException(nameof(serializerCore));
}
this.batchOperations = new List(maxBatchOperationCount);
@@ -73,7 +73,7 @@ public BatchAsyncBatcher(
this.retrier = retrier;
this.maxBatchByteSize = maxBatchByteSize;
this.maxBatchOperationCount = maxBatchOperationCount;
- this.cosmosSerializer = cosmosSerializer;
+ this.serializerCore = serializerCore;
}
public virtual bool TryAdd(ItemBatchOperation operation)
@@ -152,7 +152,7 @@ public virtual bool TryAdd(ItemBatchOperation operation)
try
{
PartitionKeyRangeBatchExecutionResult result = await this.executor(serverRequest, cancellationToken);
- using (PartitionKeyRangeBatchResponse batchResponse = new PartitionKeyRangeBatchResponse(serverRequest.Operations.Count, result.ServerResponse, this.cosmosSerializer))
+ using (PartitionKeyRangeBatchResponse batchResponse = new PartitionKeyRangeBatchResponse(serverRequest.Operations.Count, result.ServerResponse, this.serializerCore))
{
foreach (ItemBatchOperation itemBatchOperation in batchResponse.Operations)
{
@@ -207,7 +207,7 @@ internal virtual async Task ExecuteAsync(
requestEnricher: requestMessage => BatchAsyncContainerExecutor.AddHeadersToRequestMessage(requestMessage, serverRequest.PartitionKeyRangeId),
cancellationToken: cancellationToken).ConfigureAwait(false);
- TransactionalBatchResponse serverResponse = await TransactionalBatchResponse.FromResponseMessageAsync(responseMessage, serverRequest, this.cosmosClientContext.CosmosSerializer).ConfigureAwait(false);
+ TransactionalBatchResponse serverResponse = await TransactionalBatchResponse.FromResponseMessageAsync(responseMessage, serverRequest, this.cosmosClientContext.SerializerCore).ConfigureAwait(false);
return new PartitionKeyRangeBatchExecutionResult(serverRequest.PartitionKeyRangeId, serverRequest.Operations, serverResponse);
}
@@ -250,7 +250,7 @@ private BatchAsyncStreamer GetOrAddStreamerForPartitionKeyRange(string partition
return streamer;
}
- BatchAsyncStreamer newStreamer = new BatchAsyncStreamer(this.maxServerRequestOperationCount, this.maxServerRequestBodyLength, this.dispatchTimerInSeconds, this.timerPool, this.cosmosClientContext.CosmosSerializer, this.ExecuteAsync, this.ReBatchAsync);
+ BatchAsyncStreamer newStreamer = new BatchAsyncStreamer(this.maxServerRequestOperationCount, this.maxServerRequestBodyLength, this.dispatchTimerInSeconds, this.timerPool, this.cosmosClientContext.SerializerCore, this.ExecuteAsync, this.ReBatchAsync);
if (!this.streamersByPartitionKeyRange.TryAdd(partitionKeyRangeId, newStreamer))
{
newStreamer.Dispose();
diff --git a/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncStreamer.cs b/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncStreamer.cs
index 7ccb45c313..2368b2b34e 100644
--- a/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncStreamer.cs
+++ b/Microsoft.Azure.Cosmos/src/Batch/BatchAsyncStreamer.cs
@@ -26,7 +26,7 @@ internal class BatchAsyncStreamer : IDisposable
private readonly BatchAsyncBatcherExecuteDelegate executor;
private readonly BatchAsyncBatcherRetryDelegate retrier;
private readonly int dispatchTimerInSeconds;
- private readonly CosmosSerializer cosmosSerializer;
+ private readonly CosmosSerializerCore serializerCore;
private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
private volatile BatchAsyncBatcher currentBatcher;
private TimerPool timerPool;
@@ -38,7 +38,7 @@ public BatchAsyncStreamer(
int maxBatchByteSize,
int dispatchTimerInSeconds,
TimerPool timerPool,
- CosmosSerializer cosmosSerializer,
+ CosmosSerializerCore serializerCore,
BatchAsyncBatcherExecuteDelegate executor,
BatchAsyncBatcherRetryDelegate retrier)
{
@@ -67,9 +67,9 @@ public BatchAsyncStreamer(
throw new ArgumentNullException(nameof(retrier));
}
- if (cosmosSerializer == null)
+ if (serializerCore == null)
{
- throw new ArgumentNullException(nameof(cosmosSerializer));
+ throw new ArgumentNullException(nameof(serializerCore));
}
this.maxBatchOperationCount = maxBatchOperationCount;
@@ -78,7 +78,7 @@ public BatchAsyncStreamer(
this.retrier = retrier;
this.dispatchTimerInSeconds = dispatchTimerInSeconds;
this.timerPool = timerPool;
- this.cosmosSerializer = cosmosSerializer;
+ this.serializerCore = serializerCore;
this.currentBatcher = this.CreateBatchAsyncBatcher();
this.ResetTimer();
@@ -157,7 +157,7 @@ private BatchAsyncBatcher GetBatchToDispatchAndCreate()
private BatchAsyncBatcher CreateBatchAsyncBatcher()
{
- return new BatchAsyncBatcher(this.maxBatchOperationCount, this.maxBatchByteSize, this.cosmosSerializer, this.executor, this.retrier);
+ return new BatchAsyncBatcher(this.maxBatchOperationCount, this.maxBatchByteSize, this.serializerCore, this.executor, this.retrier);
}
}
}
diff --git a/Microsoft.Azure.Cosmos/src/Batch/BatchExecutor.cs b/Microsoft.Azure.Cosmos/src/Batch/BatchExecutor.cs
index ce86787c0b..3083e5bc20 100644
--- a/Microsoft.Azure.Cosmos/src/Batch/BatchExecutor.cs
+++ b/Microsoft.Azure.Cosmos/src/Batch/BatchExecutor.cs
@@ -51,7 +51,7 @@ public async Task ExecuteAsync(CancellationToken can
SinglePartitionKeyServerBatchRequest serverRequest = await SinglePartitionKeyServerBatchRequest.CreateAsync(
serverRequestPartitionKey,
new ArraySegment(this.inputOperations.ToArray()),
- this.clientContext.CosmosSerializer,
+ this.clientContext.SerializerCore,
cancellationToken);
return await this.ExecuteServerRequestAsync(serverRequest, cancellationToken);
@@ -89,7 +89,7 @@ private async Task ExecuteServerRequestAsync(
return await TransactionalBatchResponse.FromResponseMessageAsync(
responseMessage,
serverRequest,
- this.clientContext.CosmosSerializer);
+ this.clientContext.SerializerCore);
}
}
}
diff --git a/Microsoft.Azure.Cosmos/src/Batch/ItemBatchOperation.cs b/Microsoft.Azure.Cosmos/src/Batch/ItemBatchOperation.cs
index 1530fbb917..b8fd2f16a5 100644
--- a/Microsoft.Azure.Cosmos/src/Batch/ItemBatchOperation.cs
+++ b/Microsoft.Azure.Cosmos/src/Batch/ItemBatchOperation.cs
@@ -287,9 +287,9 @@ internal int GetApproximateSerializedLength()
///
/// Materializes the operation's resource into a Memory{byte} wrapping a byte array.
///
- /// Serializer to serialize user provided objects to JSON.
+ /// Serializer to serialize user provided objects to JSON.
/// for cancellation.
- internal virtual async Task MaterializeResourceAsync(CosmosSerializer serializer, CancellationToken cancellationToken)
+ internal virtual async Task MaterializeResourceAsync(CosmosSerializerCore serializerCore, CancellationToken cancellationToken)
{
if (this.body.IsEmpty && this.ResourceStream != null)
{
@@ -361,14 +361,14 @@ public ItemBatchOperation(
///
/// Materializes the operation's resource into a Memory{byte} wrapping a byte array.
///
- /// Serializer to serialize user provided objects to JSON.
+ /// Serializer to serialize user provided objects to JSON.
/// for cancellation.
- internal override Task MaterializeResourceAsync(CosmosSerializer serializer, CancellationToken cancellationToken)
+ internal override Task MaterializeResourceAsync(CosmosSerializerCore serializerCore, CancellationToken cancellationToken)
{
if (this.body.IsEmpty && this.Resource != null)
{
- this.ResourceStream = serializer.ToStream(this.Resource);
- return base.MaterializeResourceAsync(serializer, cancellationToken);
+ this.ResourceStream = serializerCore.ToStream(this.Resource);
+ return base.MaterializeResourceAsync(serializerCore, cancellationToken);
}
return Task.FromResult(true);
diff --git a/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeBatchResponse.cs b/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeBatchResponse.cs
index a6f3ce9ca8..4c90c4f361 100644
--- a/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeBatchResponse.cs
+++ b/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeBatchResponse.cs
@@ -25,11 +25,11 @@ internal class PartitionKeyRangeBatchResponse : TransactionalBatchResponse
///
/// Original operations that generated the server responses.
/// Response from the server.
- /// Serializer to deserialize response resource body streams.
+ /// Serializer to deserialize response resource body streams.
internal PartitionKeyRangeBatchResponse(
int originalOperationsCount,
TransactionalBatchResponse serverResponse,
- CosmosSerializer serializer)
+ CosmosSerializerCore serializerCore)
{
this.StatusCode = serverResponse.StatusCode;
@@ -59,7 +59,7 @@ internal PartitionKeyRangeBatchResponse(
this.ErrorMessage = errorMessageBuilder.Length > 2 ? errorMessageBuilder.ToString(0, errorMessageBuilder.Length - 2) : null;
this.Operations = itemBatchOperations;
- this.Serializer = serializer;
+ this.SerializerCore = serializerCore;
}
///
@@ -70,7 +70,7 @@ internal PartitionKeyRangeBatchResponse(
///
public override CosmosDiagnostics Diagnostics => this.serverResponse.Diagnostics;
- internal override CosmosSerializer Serializer { get; }
+ internal override CosmosSerializerCore SerializerCore { get; }
///
/// Gets the number of operation results.
@@ -98,7 +98,7 @@ public override TransactionalBatchOperationResult GetOperationResultAtIndex(result.ResourceStream);
+ resource = this.SerializerCore.FromStream(result.ResourceStream);
}
return new TransactionalBatchOperationResult(result, resource);
diff --git a/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeServerBatchRequest.cs b/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeServerBatchRequest.cs
index 35db6ae22a..f3928ac4ca 100644
--- a/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeServerBatchRequest.cs
+++ b/Microsoft.Azure.Cosmos/src/Batch/PartitionKeyRangeServerBatchRequest.cs
@@ -18,13 +18,13 @@ internal sealed class PartitionKeyRangeServerBatchRequest : ServerBatchRequest
/// The partition key range id associated with all requests.
/// Maximum length allowed for the request body.
/// Maximum number of operations allowed in the request.
- /// Serializer to serialize user provided objects to JSON.
+ /// Serializer to serialize user provided objects to JSON.
public PartitionKeyRangeServerBatchRequest(
string partitionKeyRangeId,
int maxBodyLength,
int maxOperationCount,
- CosmosSerializer serializer)
- : base(maxBodyLength, maxOperationCount, serializer)
+ CosmosSerializerCore serializerCore)
+ : base(maxBodyLength, maxOperationCount, serializerCore)
{
this.PartitionKeyRangeId = partitionKeyRangeId;
}
@@ -44,7 +44,7 @@ public PartitionKeyRangeServerBatchRequest(
/// Desired maximum length of the request body.
/// Maximum number of operations allowed in the request.
/// Whether to stop adding operations to the request once there is non-continuity in the operation indexes.
- /// Serializer to serialize user provided objects to JSON.
+ /// Serializer to serialize user provided objects to JSON.
/// representing request cancellation.
/// A newly created instance of .
public static async Task>> CreateAsync(
@@ -53,10 +53,10 @@ public static async Task pendingOperations = await request.CreateBodyStreamAsync(operations, cancellationToken, ensureContinuousOperationIndexes);
return new Tuple>(request, pendingOperations);
}
diff --git a/Microsoft.Azure.Cosmos/src/Batch/ServerBatchRequest.cs b/Microsoft.Azure.Cosmos/src/Batch/ServerBatchRequest.cs
index e0bd7e7bc9..52c02ad215 100644
--- a/Microsoft.Azure.Cosmos/src/Batch/ServerBatchRequest.cs
+++ b/Microsoft.Azure.Cosmos/src/Batch/ServerBatchRequest.cs
@@ -21,7 +21,7 @@ internal abstract class ServerBatchRequest
private readonly int maxOperationCount;
- private readonly CosmosSerializer serializer;
+ private readonly CosmosSerializerCore serializerCore;
private ArraySegment operations;
@@ -40,12 +40,12 @@ internal abstract class ServerBatchRequest
///
/// Maximum length allowed for the request body.
/// Maximum number of operations allowed in the request.
- /// Serializer to serialize user provided objects to JSON.
- protected ServerBatchRequest(int maxBodyLength, int maxOperationCount, CosmosSerializer serializer)
+ /// Serializer to serialize user provided objects to JSON.
+ protected ServerBatchRequest(int maxBodyLength, int maxOperationCount, CosmosSerializerCore serializerCore)
{
this.maxBodyLength = maxBodyLength;
this.maxOperationCount = maxOperationCount;
- this.serializer = serializer;
+ this.serializerCore = serializerCore;
}
public IReadOnlyList Operations => this.operations;
@@ -87,7 +87,7 @@ protected async Task> CreateBodyStreamAsync(
break;
}
- await operation.MaterializeResourceAsync(this.serializer, cancellationToken);
+ await operation.MaterializeResourceAsync(this.serializerCore, cancellationToken);
materializedCount++;
previousOperationIndex = operation.OperationIndex;
diff --git a/Microsoft.Azure.Cosmos/src/Batch/SinglePartitionKeyServerBatchRequest.cs b/Microsoft.Azure.Cosmos/src/Batch/SinglePartitionKeyServerBatchRequest.cs
index 14f6e5b6fa..b1f12b25b8 100644
--- a/Microsoft.Azure.Cosmos/src/Batch/SinglePartitionKeyServerBatchRequest.cs
+++ b/Microsoft.Azure.Cosmos/src/Batch/SinglePartitionKeyServerBatchRequest.cs
@@ -15,11 +15,13 @@ internal sealed class SinglePartitionKeyServerBatchRequest : ServerBatchRequest
/// Single partition key server request.
///
/// Partition key that applies to all operations in this request.
- /// Serializer to serialize user provided objects to JSON.
+ /// Serializer to serialize user provided objects to JSON.
private SinglePartitionKeyServerBatchRequest(
PartitionKey? partitionKey,
- CosmosSerializer serializer)
- : base(maxBodyLength: int.MaxValue, maxOperationCount: int.MaxValue, serializer: serializer)
+ CosmosSerializerCore serializerCore)
+ : base(maxBodyLength: int.MaxValue,
+ maxOperationCount: int.MaxValue,
+ serializerCore: serializerCore)
{
this.PartitionKey = partitionKey;
}
@@ -35,16 +37,16 @@ private SinglePartitionKeyServerBatchRequest(
///
/// Partition key of the request.
/// Operations to be added into this batch request.
- /// Serializer to serialize user provided objects to JSON.
+ /// Serializer to serialize user provided objects to JSON.
/// representing request cancellation.
/// A newly created instance of .
public static async Task CreateAsync(
PartitionKey? partitionKey,
ArraySegment operations,
- CosmosSerializer serializer,
+ CosmosSerializerCore serializerCore,
CancellationToken cancellationToken)
{
- SinglePartitionKeyServerBatchRequest request = new SinglePartitionKeyServerBatchRequest(partitionKey, serializer);
+ SinglePartitionKeyServerBatchRequest request = new SinglePartitionKeyServerBatchRequest(partitionKey, serializerCore);
await request.CreateBodyStreamAsync(operations, cancellationToken);
return request;
}
diff --git a/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchResponse.cs b/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchResponse.cs
index ce28d3adaf..cbbf853c27 100644
--- a/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchResponse.cs
+++ b/Microsoft.Azure.Cosmos/src/Batch/TransactionalBatchResponse.cs
@@ -67,13 +67,13 @@ private TransactionalBatchResponse(
string activityId,
CosmosDiagnostics cosmosDiagnostics,
IReadOnlyList operations,
- CosmosSerializer serializer)
+ CosmosSerializerCore serializer)
{
this.StatusCode = statusCode;
this.SubStatusCode = subStatusCode;
this.ErrorMessage = errorMessage;
this.Operations = operations;
- this.Serializer = serializer;
+ this.SerializerCore = serializer;
this.RequestCharge = requestCharge;
this.RetryAfter = retryAfter;
this.ActivityId = activityId;
@@ -134,7 +134,7 @@ public virtual bool IsSuccessStatusCode
internal virtual SubStatusCodes SubStatusCode { get; }
- internal virtual CosmosSerializer Serializer { get; }
+ internal virtual CosmosSerializerCore SerializerCore { get; }
internal IReadOnlyList Operations { get; set; }
@@ -164,7 +164,7 @@ public virtual TransactionalBatchOperationResult GetOperationResultAtIndex
T resource = default(T);
if (result.ResourceStream != null)
{
- resource = this.Serializer.FromStream(result.ResourceStream);
+ resource = this.SerializerCore.FromStream(result.ResourceStream);
}
return new TransactionalBatchOperationResult(result, resource);
@@ -211,7 +211,7 @@ IEnumerator IEnumerable.GetEnumerator()
internal static async Task FromResponseMessageAsync(
ResponseMessage responseMessage,
ServerBatchRequest serverRequest,
- CosmosSerializer serializer,
+ CosmosSerializerCore serializer,
bool shouldPromoteOperationStatus = true)
{
using (responseMessage)
@@ -325,7 +325,7 @@ private static async Task PopulateFromContentAsync(
Stream content,
ResponseMessage responseMessage,
ServerBatchRequest serverRequest,
- CosmosSerializer serializer,
+ CosmosSerializerCore serializer,
bool shouldPromoteOperationStatus)
{
List results = new List();
diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorCore.cs
index 1d95f0cb98..049d7bf2bd 100644
--- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorCore.cs
+++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/ChangeFeedProcessorCore.cs
@@ -137,7 +137,7 @@ internal PartitionManager BuildPartitionManager()
PartitionSupervisorFactoryCore partitionSuperviserFactory = new PartitionSupervisorFactoryCore(
factory,
this.documentServiceLeaseStoreManager.LeaseManager,
- new FeedProcessorFactoryCore(this.monitoredContainer, this.changeFeedProcessorOptions, this.documentServiceLeaseStoreManager.LeaseCheckpointer, this.monitoredContainer.ClientContext.CosmosSerializer),
+ new FeedProcessorFactoryCore(this.monitoredContainer, this.changeFeedProcessorOptions, this.documentServiceLeaseStoreManager.LeaseCheckpointer, this.monitoredContainer.ClientContext.SerializerCore),
this.changeFeedLeaseOptions);
EqualPartitionsBalancingStrategy loadBalancingStrategy = new EqualPartitionsBalancingStrategy(
diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/RemainingWorkEstimatorCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/RemainingWorkEstimatorCore.cs
index 2aa59a836d..3d27771661 100644
--- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/RemainingWorkEstimatorCore.cs
+++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedManagement/RemainingWorkEstimatorCore.cs
@@ -126,9 +126,9 @@ internal static string ExtractLsnFromSessionToken(string sessionToken)
return segments[1];
}
- private static string GetFirstItemLSN(Collection items)
+ private static string GetFirstItemLSN(IEnumerable items)
{
- JObject item = RemainingWorkEstimatorCore.GetFirstItem(items);
+ JObject item = items.FirstOrDefault();
if (item == null)
{
return null;
@@ -168,14 +168,16 @@ private static long TryConvertToNumber(string number)
return parsed;
}
- private static Collection GetItemsFromResponse(ResponseMessage response)
+ private static IEnumerable GetItemsFromResponse(ResponseMessage response)
{
if (response.Content == null)
{
return new Collection();
}
- return CosmosContainerExtensions.DefaultJsonSerializer.FromStream>(response.Content).Data;
+ return CosmosContainerExtensions.DefaultJsonSerializer.FromFeedResponseStream(
+ response.Content,
+ ResourceType.Document);
}
private async Task GetRemainingWorkAsync(DocumentServiceLease existingLease, CancellationToken cancellationToken)
@@ -196,8 +198,8 @@ private async Task GetRemainingWorkAsync(DocumentServiceLease existingLeas
}
long parsedLSNFromSessionToken = RemainingWorkEstimatorCore.TryConvertToNumber(ExtractLsnFromSessionToken(response.Headers[HttpConstants.HttpHeaders.SessionToken]));
- Collection items = RemainingWorkEstimatorCore.GetItemsFromResponse(response);
- long lastQueryLSN = items.Count > 0
+ IEnumerable items = RemainingWorkEstimatorCore.GetItemsFromResponse(response);
+ long lastQueryLSN = items.Any()
? RemainingWorkEstimatorCore.TryConvertToNumber(RemainingWorkEstimatorCore.GetFirstItemLSN(items)) - 1
: parsedLSNFromSessionToken;
if (lastQueryLSN < 0)
diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/ChangeFeedObserver.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/ChangeFeedObserver.cs
index 13c6449e24..94aa0fe9a5 100644
--- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/ChangeFeedObserver.cs
+++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/ChangeFeedObserver.cs
@@ -33,7 +33,7 @@ internal abstract class ChangeFeedObserver
///
/// The context specifying partition for this change event, etc.
/// The documents changed.
- /// Token to signal that the parition processing is going to finish.
+ /// Token to signal that the partition processing is going to finish.
/// A Task to allow asynchronous execution.
public abstract Task ProcessChangesAsync(ChangeFeedObserverContext context, IReadOnlyCollection docs, CancellationToken cancellationToken);
}
diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/FeedProcessorCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/FeedProcessorCore.cs
index 3faf06666c..ee90e403c8 100644
--- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/FeedProcessorCore.cs
+++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/FeedProcessorCore.cs
@@ -8,6 +8,7 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.FeedProcessing
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
+ using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
@@ -24,20 +25,20 @@ internal sealed class FeedProcessorCore : FeedProcessor
private readonly PartitionCheckpointer checkpointer;
private readonly ChangeFeedObserver observer;
private readonly FeedIterator resultSetIterator;
- private readonly CosmosSerializer cosmosJsonSerializer;
+ private readonly CosmosSerializerCore serializerCore;
public FeedProcessorCore(
ChangeFeedObserver observer,
FeedIterator resultSetIterator,
ProcessorOptions options,
PartitionCheckpointer checkpointer,
- CosmosSerializer cosmosJsonSerializer)
+ CosmosSerializerCore serializerCore)
{
this.observer = observer;
this.options = options;
this.checkpointer = checkpointer;
this.resultSetIterator = resultSetIterator;
- this.cosmosJsonSerializer = cosmosJsonSerializer;
+ this.serializerCore = serializerCore;
}
public override async Task RunAsync(CancellationToken cancellationToken)
@@ -114,10 +115,12 @@ private void HandleFailedRequest(
private Task DispatchChangesAsync(ResponseMessage response, CancellationToken cancellationToken)
{
ChangeFeedObserverContext context = new ChangeFeedObserverContextCore(this.options.LeaseToken, response, this.checkpointer);
- Collection asFeedResponse;
+ IEnumerable asFeedResponse;
try
{
- asFeedResponse = this.cosmosJsonSerializer.FromStream>(response.Content).Data;
+ asFeedResponse = this.serializerCore.FromFeedResponseStream(
+ response.Content,
+ Documents.ResourceType.Document);
}
catch (Exception serializationException)
{
@@ -126,13 +129,12 @@ private Task DispatchChangesAsync(ResponseMessage response, CancellationToken ca
}
// When StartFromBeginning is used, the first request returns OK but no content
- if (asFeedResponse.Count == 0)
+ if (!asFeedResponse.Any())
{
return Task.CompletedTask;
}
- List asReadOnlyList = new List(asFeedResponse.Count);
- asReadOnlyList.AddRange(asFeedResponse);
+ List asReadOnlyList = new List(asFeedResponse);
return this.observer.ProcessChangesAsync(context, asReadOnlyList, cancellationToken);
}
diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/FeedProcessorFactoryCore.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/FeedProcessorFactoryCore.cs
index 7f7de722c2..9f108a7aa2 100644
--- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/FeedProcessorFactoryCore.cs
+++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/FeedProcessing/FeedProcessorFactoryCore.cs
@@ -16,23 +16,23 @@ internal class FeedProcessorFactoryCore : FeedProcessorFactory
private readonly ContainerCore container;
private readonly ChangeFeedProcessorOptions changeFeedProcessorOptions;
private readonly DocumentServiceLeaseCheckpointer leaseCheckpointer;
- private readonly CosmosSerializer cosmosJsonSerializer;
+ private readonly CosmosSerializerCore serializerCore;
public FeedProcessorFactoryCore(
ContainerCore container,
ChangeFeedProcessorOptions changeFeedProcessorOptions,
DocumentServiceLeaseCheckpointer leaseCheckpointer,
- CosmosSerializer cosmosJsonSerializer)
+ CosmosSerializerCore serializerCore)
{
if (container == null) throw new ArgumentNullException(nameof(container));
if (changeFeedProcessorOptions == null) throw new ArgumentNullException(nameof(changeFeedProcessorOptions));
if (leaseCheckpointer == null) throw new ArgumentNullException(nameof(leaseCheckpointer));
- if (cosmosJsonSerializer == null) throw new ArgumentNullException(nameof(cosmosJsonSerializer));
+ if (serializerCore == null) throw new ArgumentNullException(nameof(serializerCore));
this.container = container;
this.changeFeedProcessorOptions = changeFeedProcessorOptions;
this.leaseCheckpointer = leaseCheckpointer;
- this.cosmosJsonSerializer = cosmosJsonSerializer;
+ this.serializerCore = serializerCore;
}
public override FeedProcessor Create(DocumentServiceLease lease, ChangeFeedObserver observer)
@@ -64,7 +64,7 @@ public override FeedProcessor Create(DocumentServiceLease lease, ChangeFeedObser
startTime: options.StartTime,
startFromBeginning: options.StartFromBeginning);
- return new FeedProcessorCore(observer, iterator, options, checkpointer, this.cosmosJsonSerializer);
+ return new FeedProcessorCore(observer, iterator, options, checkpointer, this.serializerCore);
}
}
}
diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/LeaseManagement/DocumentServiceLeaseContainerCosmos.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/LeaseManagement/DocumentServiceLeaseContainerCosmos.cs
index a356d5037e..e46a7419a8 100644
--- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/LeaseManagement/DocumentServiceLeaseContainerCosmos.cs
+++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/LeaseManagement/DocumentServiceLeaseContainerCosmos.cs
@@ -58,7 +58,9 @@ private async Task> ListDocumentsAsync(s
{
using (ResponseMessage responseMessage = await iterator.ReadNextAsync().ConfigureAwait(false))
{
- leases.AddRange(CosmosContainerExtensions.DefaultJsonSerializer.FromStream>(responseMessage.Content).Data);
+ leases.AddRange(CosmosContainerExtensions.DefaultJsonSerializer.FromFeedResponseStream(
+ responseMessage.Content,
+ Documents.ResourceType.Document));
}
}
diff --git a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Utils/CosmosContainerExtensions.cs b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Utils/CosmosContainerExtensions.cs
index 02aea42659..ae6dd1d236 100644
--- a/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Utils/CosmosContainerExtensions.cs
+++ b/Microsoft.Azure.Cosmos/src/ChangeFeedProcessor/Utils/CosmosContainerExtensions.cs
@@ -14,7 +14,7 @@ namespace Microsoft.Azure.Cosmos.ChangeFeed.Utils
internal static class CosmosContainerExtensions
{
- public static readonly CosmosSerializer DefaultJsonSerializer = new CosmosJsonDotNetSerializer();
+ public static readonly CosmosSerializerCore DefaultJsonSerializer = new CosmosSerializerCore();
public static async Task TryGetItemAsync(
this Container container,
diff --git a/Microsoft.Azure.Cosmos/src/CosmosClient.cs b/Microsoft.Azure.Cosmos/src/CosmosClient.cs
index b5bdbf25f4..6dab099528 100644
--- a/Microsoft.Azure.Cosmos/src/CosmosClient.cs
+++ b/Microsoft.Azure.Cosmos/src/CosmosClient.cs
@@ -481,7 +481,9 @@ public virtual FeedIterator GetDatabaseQueryIterator(
return new FeedIteratorCore(
databaseStreamIterator,
- this.ClientContext.ResponseFactory.CreateQueryFeedResponse);
+ (response) => this.ClientContext.ResponseFactory.CreateQueryFeedResponse(
+ responseMessage: response,
+ resourceType: ResourceType.Database));
}
///
@@ -603,7 +605,7 @@ public virtual Task CreateDatabaseStreamAsync(
}
this.ClientContext.ValidateResource(databaseProperties.Id);
- Stream streamPayload = this.ClientContext.PropertiesSerializer.ToStream(databaseProperties);
+ Stream streamPayload = this.ClientContext.SerializerCore.ToStream(databaseProperties);
return this.CreateDatabaseStreamInternalAsync(streamPayload, throughput, requestOptions, cancellationToken);
}
@@ -631,21 +633,16 @@ internal void Init(
this.RequestHandler = clientPipelineBuilder.Build();
- CosmosSerializer userSerializer = this.ClientOptions.GetCosmosSerializerWithWrapperOrDefault();
- this.ResponseFactory = new CosmosResponseFactory(
- defaultJsonSerializer: this.ClientOptions.PropertiesSerializer,
- userJsonSerializer: userSerializer);
+ CosmosSerializerCore serializerCore = CosmosSerializerCore.Create(
+ this.ClientOptions.Serializer,
+ this.ClientOptions.SerializerOptions);
- CosmosSerializer sqlQuerySpecSerializer = CosmosSqlQuerySpecJsonConverter.CreateSqlQuerySpecSerializer(
- cosmosSerializer: userSerializer,
- propertiesSerializer: this.ClientOptions.PropertiesSerializer);
+ this.ResponseFactory = new CosmosResponseFactory(serializerCore);
this.ClientContext = new ClientContextCore(
client: this,
clientOptions: this.ClientOptions,
- userJsonSerializer: userSerializer,
- defaultJsonSerializer: this.ClientOptions.PropertiesSerializer,
- sqlQuerySpecSerializer: sqlQuerySpecSerializer,
+ serializerCore: serializerCore,
cosmosResponseFactory: this.ResponseFactory,
requestHandler: this.RequestHandler,
documentClient: this.DocumentClient);
@@ -684,7 +681,7 @@ internal Task CreateDatabaseAsync(
CancellationToken cancellationToken = default(CancellationToken))
{
Task response = this.CreateDatabaseStreamInternalAsync(
- streamPayload: this.ClientContext.PropertiesSerializer.ToStream(databaseProperties),
+ streamPayload: this.ClientContext.SerializerCore.ToStream(databaseProperties),
throughput: throughput,
requestOptions: requestOptions,
cancellationToken: cancellationToken);
@@ -710,32 +707,6 @@ private Task CreateDatabaseStreamInternalAsync(
cancellationToken: cancellationToken);
}
- private Task> DatabaseFeedRequestExecutorAsync(
- int? maxItemCount,
- string continuationToken,
- RequestOptions options,
- object state,
- CancellationToken cancellationToken)
- {
- Debug.Assert(state == null);
-
- return this.ClientContext.ProcessResourceOperationAsync>(
- resourceUri: this.DatabaseRootUri,
- resourceType: ResourceType.Database,
- operationType: OperationType.ReadFeed,
- requestOptions: options,
- cosmosContainerCore: null,
- partitionKey: null,
- streamPayload: null,
- requestEnricher: request =>
- {
- QueryRequestOptions.FillContinuationToken(request, continuationToken);
- QueryRequestOptions.FillMaxItemCount(request, maxItemCount);
- },
- responseCreator: response => this.ClientContext.ResponseFactory.CreateQueryFeedResponse(response),
- cancellationToken: cancellationToken);
- }
-
private HttpClientHandler CreateHttpClientHandler(CosmosClientOptions clientOptions)
{
if (clientOptions == null || (clientOptions.WebProxy == null))
diff --git a/Microsoft.Azure.Cosmos/src/CosmosClientOptions.cs b/Microsoft.Azure.Cosmos/src/CosmosClientOptions.cs
index 7f2a710b71..1b96a29893 100644
--- a/Microsoft.Azure.Cosmos/src/CosmosClientOptions.cs
+++ b/Microsoft.Azure.Cosmos/src/CosmosClientOptions.cs
@@ -54,8 +54,6 @@ public class CosmosClientOptions
///
/// Default request timeout
///
- private static readonly CosmosSerializer propertiesSerializer = new CosmosJsonSerializerWrapper(new CosmosJsonDotNetSerializer());
-
private int gatewayModeMaxConnectionLimit;
private CosmosSerializationOptions serializerOptions;
private CosmosSerializer serializer;
@@ -395,14 +393,6 @@ public CosmosSerializer Serializer
///
public bool AllowBulkExecution { get; set; }
- ///
- /// A JSON serializer used by the CosmosClient to serialize or de-serialize cosmos request/responses.
- /// The default serializer is always used for all system owned types like DatabaseProperties.
- /// The default serializer is used for user types if no UserJsonSerializer is specified
- ///
- [JsonConverter(typeof(ClientOptionJsonConverter))]
- internal CosmosSerializer PropertiesSerializer => CosmosClientOptions.propertiesSerializer;
-
///
/// Gets or sets the connection protocol when connecting to the Azure Cosmos service.
///
@@ -507,22 +497,6 @@ internal Protocol ConnectionProtocol
///
internal bool? EnableCpuMonitor { get; set; }
- ///
- /// Gets the user json serializer with the CosmosJsonSerializerWrapper or the default
- ///
- internal CosmosSerializer GetCosmosSerializerWithWrapperOrDefault()
- {
- if (this.SerializerOptions != null)
- {
- CosmosJsonDotNetSerializer cosmosJsonDotNetSerializer = new CosmosJsonDotNetSerializer(this.SerializerOptions);
- return new CosmosJsonSerializerWrapper(cosmosJsonDotNetSerializer);
- }
- else
- {
- return this.Serializer == null ? this.PropertiesSerializer : new CosmosJsonSerializerWrapper(this.Serializer);
- }
- }
-
internal CosmosClientOptions Clone()
{
CosmosClientOptions cloneConfiguration = (CosmosClientOptions)this.MemberwiseClone();
diff --git a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosElementSerializer.cs b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosElementSerializer.cs
index a6b29b6585..bcaf594471 100644
--- a/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosElementSerializer.cs
+++ b/Microsoft.Azure.Cosmos/src/CosmosElements/CosmosElementSerializer.cs
@@ -7,6 +7,7 @@ namespace Microsoft.Azure.Cosmos.CosmosElements
using System.Collections.Generic;
using System.IO;
using System.Linq;
+ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Microsoft.Azure.Cosmos.Json;
using Microsoft.Azure.Cosmos.Query.Core;
@@ -21,6 +22,30 @@ namespace Microsoft.Azure.Cosmos.CosmosElements
#endif
static class CosmosElementSerializer
{
+ ///
+ /// Converts a list of CosmosElements into a memory stream.
+ ///
+ /// The stream response from Azure Cosmos
+ /// The resource type
+ /// The custom serialization options. This allows custom serialization types like BSON, JSON, or other formats
+ /// Returns a memory stream of cosmos elements. By default the memory stream will contain JSON.
+ internal static CosmosArray ToCosmosElements(
+ Stream stream,
+ ResourceType resourceType,
+ CosmosSerializationFormatOptions cosmosSerializationOptions = null)
+ {
+ MemoryStream memoryStream = stream as MemoryStream;
+ if (memoryStream == null)
+ {
+ memoryStream = new MemoryStream();
+ stream.CopyTo(memoryStream);
+ }
+
+ return CosmosElementSerializer.ToCosmosElements(
+ memoryStream,
+ resourceType,
+ cosmosSerializationOptions);
+ }
///
/// Converts a list of CosmosElements into a memory stream.
///
@@ -220,6 +245,39 @@ internal static MemoryStream ToStream(
return new MemoryStream(resultAsArray.Array, resultAsArray.Offset, resultAsArray.Count);
}
+ internal static IEnumerable GetResources(
+ IReadOnlyList cosmosArray,
+ CosmosSerializerCore serializerCore)
+ {
+ if (cosmosArray == null)
+ {
+ return new List();
+ }
+
+ if (typeof(T) == typeof(CosmosElement))
+ {
+ return cosmosArray.Cast();
+ }
+
+ return CosmosElementSerializer.GetResourcesHelper(
+ cosmosArray,
+ serializerCore);
+ }
+
+ private static IEnumerable GetResourcesHelper(
+ IReadOnlyList cosmosArray,
+ CosmosSerializerCore serializerCore)
+ {
+ List result = new List();
+ foreach (CosmosElement element in cosmosArray)
+ {
+ MemoryStream memory = CosmosElementSerializer.ElementToMemoryStream(element, null);
+ result.Add(serializerCore.FromStream(memory));
+ }
+
+ return result;
+ }
+
///
/// Converts a list of CosmosElements into a list of objects.
///
@@ -233,7 +291,7 @@ internal static IEnumerable Deserialize(
string containerRid,
IEnumerable cosmosElements,
ResourceType resourceType,
- CosmosSerializer jsonSerializer,
+ CosmosSerializerCore jsonSerializer,
CosmosSerializationFormatOptions cosmosSerializationOptions = null)
{
if (!cosmosElements.Any())
@@ -247,11 +305,44 @@ internal static IEnumerable Deserialize(
resourceType,
cosmosSerializationOptions);
- IEnumerable typedResults = jsonSerializer.FromStream>(stream).Data;
+ IEnumerable typedResults = jsonSerializer.FromFeedResponseStream(
+ stream,
+ resourceType);
return typedResults;
}
+ ///
+ /// Converts a list of CosmosElements into a memory stream.
+ ///
+ /// The cosmos elements
+ /// The custom serialization options. This allows custom serialization types like BSON, JSON, or other formats
+ /// Returns a memory stream of cosmos elements. By default the memory stream will contain JSON.
+ private static MemoryStream ElementToMemoryStream(
+ CosmosElement cosmosElement,
+ CosmosSerializationFormatOptions cosmosSerializationOptions = null)
+ {
+ IJsonWriter jsonWriter;
+ if (cosmosSerializationOptions != null)
+ {
+ jsonWriter = cosmosSerializationOptions.CreateCustomWriterCallback();
+ }
+ else
+ {
+ jsonWriter = JsonWriter.Create(JsonSerializationFormat.Text);
+ }
+
+ cosmosElement.WriteTo(jsonWriter);
+
+ ReadOnlyMemory result = jsonWriter.GetResult();
+ if (!MemoryMarshal.TryGetArray(result, out ArraySegment resultAsArray))
+ {
+ resultAsArray = new ArraySegment(result.ToArray());
+ }
+
+ return new MemoryStream(resultAsArray.Array, resultAsArray.Offset, resultAsArray.Count);
+ }
+
private static string GetRootNodeName(ResourceType resourceType)
{
switch (resourceType)
diff --git a/Microsoft.Azure.Cosmos/src/FeedIteratorCore.cs b/Microsoft.Azure.Cosmos/src/FeedIteratorCore.cs
index 4f1a78e605..d8552a5c9e 100644
--- a/Microsoft.Azure.Cosmos/src/FeedIteratorCore.cs
+++ b/Microsoft.Azure.Cosmos/src/FeedIteratorCore.cs
@@ -68,13 +68,7 @@ public override async Task ReadNextAsync(CancellationToken canc
OperationType operation = OperationType.ReadFeed;
if (this.querySpec != null)
{
- // Use property serializer is for internal query operations like throughput
- // that should not use custom serializer
- CosmosSerializer serializer = this.usePropertySerializer ?
- this.clientContext.PropertiesSerializer :
- this.clientContext.SqlQuerySpecSerializer;
-
- stream = serializer.ToStream(this.querySpec);
+ stream = this.clientContext.SerializerCore.ToStreamSqlQuerySpec(this.querySpec, this.resourceType);
operation = OperationType.Query;
}
diff --git a/Microsoft.Azure.Cosmos/src/Linq/CosmosLinqQuery.cs b/Microsoft.Azure.Cosmos/src/Linq/CosmosLinqQuery.cs
index 43d7f3622f..a332e6df5b 100644
--- a/Microsoft.Azure.Cosmos/src/Linq/CosmosLinqQuery.cs
+++ b/Microsoft.Azure.Cosmos/src/Linq/CosmosLinqQuery.cs
@@ -210,7 +210,7 @@ private FeedIterator CreateFeedIterator(bool isContinuationExcpected)
FeedIteratorInternal streamIterator = this.CreateStreamIterator(isContinuationExcpected);
return new FeedIteratorCore(
streamIterator,
- this.responseFactory.CreateQueryFeedResponse);
+ this.responseFactory.CreateQueryFeedUserTypeResponse);
}
}
}
diff --git a/Microsoft.Azure.Cosmos/src/Query/v3Query/CosmosQueryClientCore.cs b/Microsoft.Azure.Cosmos/src/Query/v3Query/CosmosQueryClientCore.cs
index 8d5d31e4d5..0cf9ce795b 100644
--- a/Microsoft.Azure.Cosmos/src/Query/v3Query/CosmosQueryClientCore.cs
+++ b/Microsoft.Azure.Cosmos/src/Query/v3Query/CosmosQueryClientCore.cs
@@ -139,7 +139,7 @@ internal override async Task ExecuteItemQueryAsync
{
this.PopulatePartitionKeyRangeInfo(cosmosRequestMessage, partitionKeyRange);
@@ -180,7 +180,7 @@ internal override async Task ExecuteQueryPlanRequ
requestOptions: null,
partitionKey: null,
cosmosContainerCore: this.cosmosContainerCore,
- streamPayload: this.clientContext.SqlQuerySpecSerializer.ToStream(sqlQuerySpec),
+ streamPayload: this.clientContext.SerializerCore.ToStreamSqlQuerySpec(sqlQuerySpec, resourceType),
requestEnricher: (requestMessage) =>
{
requestMessage.Headers.Add(HttpConstants.HttpHeaders.ContentType, RuntimeConstants.MediaTypes.QueryJson);
@@ -193,7 +193,7 @@ internal override async Task ExecuteQueryPlanRequ
{
// Syntax exception are argument exceptions and thrown to the user.
message.EnsureSuccessStatusCode();
- partitionedQueryExecutionInfo = this.clientContext.CosmosSerializer.FromStream(message.Content);
+ partitionedQueryExecutionInfo = this.clientContext.SerializerCore.FromStream(message.Content);
}
return partitionedQueryExecutionInfo;
diff --git a/Microsoft.Azure.Cosmos/src/Query/v3Query/QueryResponse.cs b/Microsoft.Azure.Cosmos/src/Query/v3Query/QueryResponse.cs
index 8d84ebca2b..d9552a79f0 100644
--- a/Microsoft.Azure.Cosmos/src/Query/v3Query/QueryResponse.cs
+++ b/Microsoft.Azure.Cosmos/src/Query/v3Query/QueryResponse.cs
@@ -27,7 +27,7 @@ internal QueryResponse()
}
private QueryResponse(
- IEnumerable result,
+ IReadOnlyList result,
int count,
long responseLengthBytes,
CosmosQueryResponseMessageHeaders responseHeaders,
@@ -63,7 +63,7 @@ public override Stream Content
}
}
- internal virtual IEnumerable CosmosElements { get; }
+ internal virtual IReadOnlyList CosmosElements { get; }
internal virtual CosmosQueryResponseMessageHeaders QueryHeaders => (CosmosQueryResponseMessageHeaders)this.Headers;
@@ -83,7 +83,7 @@ internal bool GetHasMoreResults()
}
internal static QueryResponse CreateSuccess(
- IEnumerable result,
+ IReadOnlyList result,
int count,
long responseLengthBytes,
CosmosQueryResponseMessageHeaders responseHeaders,
@@ -131,7 +131,7 @@ internal static QueryResponse CreateFailure(
CosmosDiagnostics diagnostics)
{
QueryResponse cosmosQueryResponse = new QueryResponse(
- result: Enumerable.Empty(),
+ result: new List(),
count: 0,
responseLengthBytes: 0,
responseHeaders: responseHeaders,
@@ -153,25 +153,26 @@ internal static QueryResponse CreateFailure(
/// The type for the query response.
internal class QueryResponse : FeedResponse
{
- private readonly IEnumerable cosmosElements;
- private readonly CosmosSerializer jsonSerializer;
+ private readonly CosmosSerializerCore serializerCore;
private readonly CosmosSerializationFormatOptions serializationOptions;
- private IEnumerable resources;
private QueryResponse(
HttpStatusCode httpStatusCode,
- IEnumerable cosmosElements,
+ IReadOnlyList cosmosElements,
CosmosQueryResponseMessageHeaders responseMessageHeaders,
CosmosDiagnostics diagnostics,
- CosmosSerializer jsonSerializer,
+ CosmosSerializerCore serializerCore,
CosmosSerializationFormatOptions serializationOptions)
{
- this.cosmosElements = cosmosElements;
this.QueryHeaders = responseMessageHeaders;
this.Diagnostics = diagnostics;
- this.jsonSerializer = jsonSerializer;
+ this.serializerCore = serializerCore;
this.serializationOptions = serializationOptions;
this.StatusCode = httpStatusCode;
+ this.Count = cosmosElements.Count;
+ this.Resource = CosmosElementSerializer.GetResources(
+ cosmosArray: cosmosElements,
+ serializerCore: serializerCore);
}
public override string ContinuationToken => this.Headers.ContinuationToken;
@@ -184,7 +185,7 @@ private QueryResponse(
public override CosmosDiagnostics Diagnostics { get; }
- public override int Count => this.cosmosElements?.Count() ?? 0;
+ public override int Count { get; }
internal CosmosQueryResponseMessageHeaders QueryHeaders { get; }
@@ -193,45 +194,23 @@ public override IEnumerator GetEnumerator()
return this.Resource.GetEnumerator();
}
- public override IEnumerable Resource
- {
- get
- {
- if (this.resources == null)
- {
- if (typeof(T) == typeof(CosmosElement))
- {
- this.resources = this.cosmosElements.Cast();
- }
- else
- {
- this.resources = CosmosElementSerializer.Deserialize(
- this.QueryHeaders.ContainerRid,
- this.cosmosElements,
- this.QueryHeaders.ResourceType,
- this.jsonSerializer,
- this.serializationOptions);
- }
- }
-
- return this.resources;
- }
- }
+ public override IEnumerable Resource { get; }
internal static QueryResponse CreateResponse(
QueryResponse cosmosQueryResponse,
- CosmosSerializer jsonSerializer)
+ CosmosSerializerCore serializerCore)
{
QueryResponse queryResponse;
using (cosmosQueryResponse)
{
cosmosQueryResponse.EnsureSuccessStatusCode();
+
queryResponse = new QueryResponse(
httpStatusCode: cosmosQueryResponse.StatusCode,
cosmosElements: cosmosQueryResponse.CosmosElements,
responseMessageHeaders: cosmosQueryResponse.QueryHeaders,
diagnostics: cosmosQueryResponse.Diagnostics,
- jsonSerializer: jsonSerializer,
+ serializerCore: serializerCore,
serializationOptions: cosmosQueryResponse.CosmosSerializationOptions);
}
return queryResponse;
diff --git a/Microsoft.Azure.Cosmos/src/Query/v3Query/ReadFeedResponse.cs b/Microsoft.Azure.Cosmos/src/Query/v3Query/ReadFeedResponse.cs
index 9ec20eea82..69de91eec8 100644
--- a/Microsoft.Azure.Cosmos/src/Query/v3Query/ReadFeedResponse.cs
+++ b/Microsoft.Azure.Cosmos/src/Query/v3Query/ReadFeedResponse.cs
@@ -4,22 +4,27 @@
namespace Microsoft.Azure.Cosmos
{
using System.Collections.Generic;
+ using System.IO;
using System.Net;
- using Microsoft.Azure.Cosmos.Query.Core;
+ using Microsoft.Azure.Cosmos.CosmosElements;
+ using Microsoft.Azure.Cosmos.Json;
internal class ReadFeedResponse : FeedResponse
{
protected ReadFeedResponse(
HttpStatusCode httpStatusCode,
- ICollection resource,
+ CosmosArray cosmosArray,
+ CosmosSerializerCore serializerCore,
Headers responseMessageHeaders,
CosmosDiagnostics diagnostics)
{
- this.Count = resource.Count;
+ this.Count = cosmosArray.Count;
this.Headers = responseMessageHeaders;
- this.Resource = resource;
this.StatusCode = httpStatusCode;
this.Diagnostics = diagnostics;
+ this.Resource = CosmosElementSerializer.GetResources(
+ cosmosArray: cosmosArray,
+ serializerCore: serializerCore);
}
public override int Count { get; }
@@ -41,20 +46,26 @@ public override IEnumerator GetEnumerator()
internal static ReadFeedResponse CreateResponse(
ResponseMessage responseMessage,
- CosmosSerializer jsonSerializer)
+ CosmosSerializerCore serializerCore,
+ Documents.ResourceType resourceType)
{
using (responseMessage)
{
- ICollection resources = default;
+ responseMessage.EnsureSuccessStatusCode();
+
+ CosmosArray cosmosArray = null;
if (responseMessage.Content != null)
{
- CosmosFeedResponseUtil response = jsonSerializer.FromStream>(responseMessage.Content);
- resources = response.Data;
+ cosmosArray = CosmosElementSerializer.ToCosmosElements(
+ responseMessage.Content,
+ resourceType,
+ null);
}
ReadFeedResponse readFeedResponse = new ReadFeedResponse(
httpStatusCode: responseMessage.StatusCode,
- resource: resources,
+ cosmosArray: cosmosArray,
+ serializerCore: serializerCore,
responseMessageHeaders: responseMessage.Headers,
diagnostics: responseMessage.Diagnostics);
diff --git a/Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs b/Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs
index 1f879021fc..aee5a975b2 100644
--- a/Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs
+++ b/Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs
@@ -19,18 +19,14 @@ internal class ClientContextCore : CosmosClientContext
internal ClientContextCore(
CosmosClient client,
CosmosClientOptions clientOptions,
- CosmosSerializer userJsonSerializer,
- CosmosSerializer defaultJsonSerializer,
- CosmosSerializer sqlQuerySpecSerializer,
+ CosmosSerializerCore serializerCore,
CosmosResponseFactory cosmosResponseFactory,
RequestInvokerHandler requestHandler,
DocumentClient documentClient)
{
this.Client = client;
this.ClientOptions = clientOptions;
- this.CosmosSerializer = userJsonSerializer;
- this.PropertiesSerializer = defaultJsonSerializer;
- this.SqlQuerySpecSerializer = sqlQuerySpecSerializer;
+ this.SerializerCore = serializerCore;
this.ResponseFactory = cosmosResponseFactory;
this.RequestHandler = requestHandler;
this.DocumentClient = documentClient;
@@ -43,11 +39,7 @@ internal ClientContextCore(
internal override DocumentClient DocumentClient { get; }
- internal override CosmosSerializer CosmosSerializer { get; }
-
- internal override CosmosSerializer PropertiesSerializer { get; }
-
- internal override CosmosSerializer SqlQuerySpecSerializer { get; }
+ internal override CosmosSerializerCore SerializerCore { get; }
internal override CosmosResponseFactory ResponseFactory { get; }
diff --git a/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictsCore.cs b/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictsCore.cs
index 52090721b0..8619943ec4 100644
--- a/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictsCore.cs
+++ b/Microsoft.Azure.Cosmos/src/Resource/Conflict/ConflictsCore.cs
@@ -124,7 +124,9 @@ public override FeedIterator GetConflictQueryIterator(
return new FeedIteratorCore(
databaseStreamIterator,
- this.clientContext.ResponseFactory.CreateQueryFeedResponseWithPropertySerializer);
+ (response) => this.clientContext.ResponseFactory.CreateQueryFeedResponse(
+ responseMessage: response,
+ resourceType: ResourceType.Conflict));
}
public override async Task> ReadCurrentAsync(
@@ -188,7 +190,7 @@ public override T ReadConflictContent(ConflictProperties cosmosConflict)
writer.Write(cosmosConflict.Content);
writer.Flush();
stream.Position = 0;
- return this.clientContext.CosmosSerializer.FromStream(stream);
+ return this.clientContext.SerializerCore.FromStream(stream);
}
}
}
diff --git a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.Items.cs b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.Items.cs
index baa0e793af..e0e369cbab 100644
--- a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.Items.cs
+++ b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.Items.cs
@@ -365,7 +365,7 @@ public override FeedIterator GetItemQueryIterator(
return new FeedIteratorCore(
feedIterator: feedIterator,
- responseCreator: this.ClientContext.ResponseFactory.CreateQueryFeedResponse);
+ responseCreator: this.ClientContext.ResponseFactory.CreateQueryFeedUserTypeResponse);
}
public override IOrderedQueryable GetItemLinqQueryable(
@@ -519,7 +519,7 @@ internal async Task ExtractPartitionKeyAndProcessItemStreamAsyn
RequestOptions requestOptions,
CancellationToken cancellationToken)
{
- Stream streamPayload = this.ClientContext.CosmosSerializer.ToStream(item);
+ Stream streamPayload = this.ClientContext.SerializerCore.ToStream(item);
// User specified PK value, no need to extract it
if (partitionKey.HasValue)
diff --git a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.cs b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.cs
index 5187d8fe71..e425eaba19 100644
--- a/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.cs
+++ b/Microsoft.Azure.Cosmos/src/Resource/Container/ContainerCore.cs
@@ -87,7 +87,7 @@ public override Task ReplaceContainerAsync(
this.ClientContext.ValidateResource(containerProperties.Id);
Task response = this.ReplaceStreamInternalAsync(
- streamPayload: this.ClientContext.PropertiesSerializer.ToStream(containerProperties),
+ streamPayload: this.ClientContext.SerializerCore.ToStream(containerProperties),
requestOptions: requestOptions,
cancellationToken: cancellationToken);
@@ -194,7 +194,7 @@ public override Task ReplaceContainerStreamAsync(
this.ClientContext.ValidateResource(containerProperties.Id);
return this.ReplaceStreamInternalAsync(
- streamPayload: this.ClientContext.PropertiesSerializer.ToStream(containerProperties),
+ streamPayload: this.ClientContext.SerializerCore.ToStream(containerProperties),
requestOptions: requestOptions,
cancellationToken: cancellationToken);
}
diff --git a/Microsoft.Azure.Cosmos/src/Resource/CosmosClientContext.cs b/Microsoft.Azure.Cosmos/src/Resource/CosmosClientContext.cs
index f9c567194c..e2f0ff6def 100644
--- a/Microsoft.Azure.Cosmos/src/Resource/CosmosClientContext.cs
+++ b/Microsoft.Azure.Cosmos/src/Resource/CosmosClientContext.cs
@@ -27,11 +27,7 @@ internal abstract class CosmosClientContext
internal abstract DocumentClient DocumentClient { get; }
- internal abstract CosmosSerializer CosmosSerializer { get; }
-
- internal abstract CosmosSerializer PropertiesSerializer { get; }
-
- internal abstract CosmosSerializer SqlQuerySpecSerializer { get; }
+ internal abstract CosmosSerializerCore SerializerCore { get; }
internal abstract CosmosResponseFactory ResponseFactory { get; }
diff --git a/Microsoft.Azure.Cosmos/src/Resource/CosmosResponseFactory.cs b/Microsoft.Azure.Cosmos/src/Resource/CosmosResponseFactory.cs
index 34a565bb76..315e27b179 100644
--- a/Microsoft.Azure.Cosmos/src/Resource/CosmosResponseFactory.cs
+++ b/Microsoft.Azure.Cosmos/src/Resource/CosmosResponseFactory.cs
@@ -5,67 +5,59 @@
namespace Microsoft.Azure.Cosmos
{
using System;
+ using System.IO;
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos.Scripts;
internal class CosmosResponseFactory
{
- ///
- /// Cosmos JSON converter. This allows custom JSON parsers.
- ///
- private readonly CosmosSerializer cosmosSerializer;
-
///
/// This is used for all meta data types
///
- private readonly CosmosSerializer propertiesSerializer;
+ private readonly CosmosSerializerCore serializerCore;
internal CosmosResponseFactory(
- CosmosSerializer defaultJsonSerializer,
- CosmosSerializer userJsonSerializer)
+ CosmosSerializerCore jsonSerializerCore)
{
- this.propertiesSerializer = defaultJsonSerializer;
- this.cosmosSerializer = userJsonSerializer;
+ this.serializerCore = jsonSerializerCore;
}
- internal FeedResponse CreateQueryFeedResponseWithPropertySerializer(
- ResponseMessage cosmosResponseMessage)
+ internal FeedResponse CreateQueryFeedUserTypeResponse(
+ ResponseMessage responseMessage)
{
return this.CreateQueryFeedResponseHelper(
- cosmosResponseMessage,
- true);
+ responseMessage,
+ Documents.ResourceType.Document);
}
internal FeedResponse CreateQueryFeedResponse(
- ResponseMessage cosmosResponseMessage)
+ ResponseMessage responseMessage,
+ Documents.ResourceType resourceType)
{
return this.CreateQueryFeedResponseHelper(
- cosmosResponseMessage,
- false);
+ responseMessage,
+ resourceType);
}
private FeedResponse CreateQueryFeedResponseHelper(
ResponseMessage cosmosResponseMessage,
- bool usePropertySerializer)
+ Documents.ResourceType resourceType)
{
//Throw the exception
cosmosResponseMessage.EnsureSuccessStatusCode();
- // The property serializer should be used for internal
- // query operations like throughput since user serializer can break the logic
- CosmosSerializer serializer = usePropertySerializer ? this.propertiesSerializer : this.cosmosSerializer;
-
QueryResponse queryResponse = cosmosResponseMessage as QueryResponse;
if (queryResponse != null)
{
return QueryResponse.CreateResponse(
cosmosQueryResponse: queryResponse,
- jsonSerializer: serializer);
+ serializerCore: this.serializerCore);
}
return ReadFeedResponse.CreateResponse(
cosmosResponseMessage,
- serializer);
+ this.serializerCore,
+ resourceType);
}
internal Task> CreateItemResponseAsync(
@@ -73,7 +65,7 @@ internal Task> CreateItemResponseAsync(
{
return this.ProcessMessageAsync(cosmosResponseMessageTask, (cosmosResponseMessage) =>
{
- T item = this.ToObjectInternal(cosmosResponseMessage, this.cosmosSerializer);
+ T item = this.ToObjectInternal(cosmosResponseMessage);
return new ItemResponse(
cosmosResponseMessage.StatusCode,
cosmosResponseMessage.Headers,
@@ -88,7 +80,7 @@ internal Task CreateContainerResponseAsync(
{
return this.ProcessMessageAsync(cosmosResponseMessageTask, (cosmosResponseMessage) =>
{
- ContainerProperties containerProperties = this.ToObjectInternal(cosmosResponseMessage, this.propertiesSerializer);
+ ContainerProperties containerProperties = this.ToObjectInternal(cosmosResponseMessage);
return new ContainerResponse(
cosmosResponseMessage.StatusCode,
cosmosResponseMessage.Headers,
@@ -104,7 +96,7 @@ internal Task CreateUserResponseAsync(
{
return this.ProcessMessageAsync(cosmosResponseMessageTask, (cosmosResponseMessage) =>
{
- UserProperties userProperties = this.ToObjectInternal(cosmosResponseMessage, this.propertiesSerializer);
+ UserProperties userProperties = this.ToObjectInternal(cosmosResponseMessage);
return new UserResponse(
cosmosResponseMessage.StatusCode,
cosmosResponseMessage.Headers,
@@ -120,7 +112,7 @@ internal Task CreatePermissionResponseAsync(
{
return this.ProcessMessageAsync(cosmosResponseMessageTask, (cosmosResponseMessage) =>
{
- PermissionProperties permissionProperties = this.ToObjectInternal(cosmosResponseMessage, this.propertiesSerializer);
+ PermissionProperties permissionProperties = this.ToObjectInternal(cosmosResponseMessage);
return new PermissionResponse(
cosmosResponseMessage.StatusCode,
cosmosResponseMessage.Headers,
@@ -136,9 +128,7 @@ internal Task CreateDatabaseResponseAsync(
{
return this.ProcessMessageAsync(cosmosResponseMessageTask, (cosmosResponseMessage) =>
{
- DatabaseProperties databaseProperties = this.ToObjectInternal(
- cosmosResponseMessage,
- this.propertiesSerializer);
+ DatabaseProperties databaseProperties = this.ToObjectInternal(cosmosResponseMessage);
return new DatabaseResponse(
cosmosResponseMessage.StatusCode,
@@ -154,7 +144,7 @@ internal Task CreateThroughputResponseAsync(
{
return this.ProcessMessageAsync(cosmosResponseMessageTask, (cosmosResponseMessage) =>
{
- ThroughputProperties throughputProperties = this.ToObjectInternal(cosmosResponseMessage, this.propertiesSerializer);
+ ThroughputProperties throughputProperties = this.ToObjectInternal(cosmosResponseMessage);
return new ThroughputResponse(
cosmosResponseMessage.StatusCode,
cosmosResponseMessage.Headers,
@@ -167,7 +157,7 @@ internal Task> CreateStoredProcedureExecuteRes
{
return this.ProcessMessageAsync(cosmosResponseMessageTask, (cosmosResponseMessage) =>
{
- T item = this.ToObjectInternal(cosmosResponseMessage, this.cosmosSerializer);
+ T item = this.ToObjectInternal(cosmosResponseMessage);
return new StoredProcedureExecuteResponse(
cosmosResponseMessage.StatusCode,
cosmosResponseMessage.Headers,
@@ -180,7 +170,7 @@ internal Task CreateStoredProcedureResponseAsync(Task
{
- StoredProcedureProperties cosmosStoredProcedure = this.ToObjectInternal(cosmosResponseMessage, this.propertiesSerializer);
+ StoredProcedureProperties cosmosStoredProcedure = this.ToObjectInternal(cosmosResponseMessage);
return new StoredProcedureResponse(
cosmosResponseMessage.StatusCode,
cosmosResponseMessage.Headers,
@@ -193,7 +183,7 @@ internal Task CreateTriggerResponseAsync(Task
{
return this.ProcessMessageAsync(cosmosResponseMessageTask, (cosmosResponseMessage) =>
{
- TriggerProperties triggerProperties = this.ToObjectInternal(cosmosResponseMessage, this.propertiesSerializer);
+ TriggerProperties triggerProperties = this.ToObjectInternal(cosmosResponseMessage);
return new TriggerResponse(
cosmosResponseMessage.StatusCode,
cosmosResponseMessage.Headers,
@@ -206,7 +196,7 @@ internal Task CreateUserDefinedFunctionResponseAsyn
{
return this.ProcessMessageAsync(cosmosResponseMessageTask, (cosmosResponseMessage) =>
{
- UserDefinedFunctionProperties settings = this.ToObjectInternal(cosmosResponseMessage, this.propertiesSerializer);
+ UserDefinedFunctionProperties settings = this.ToObjectInternal(cosmosResponseMessage);
return new UserDefinedFunctionResponse(
cosmosResponseMessage.StatusCode,
cosmosResponseMessage.Headers,
@@ -219,21 +209,21 @@ internal async Task ProcessMessageAsync(Task cosmosRespon
{
using (ResponseMessage message = await cosmosResponseTask)
{
+ //Throw the exception
+ message.EnsureSuccessStatusCode();
+
return createResponse(message);
}
}
- internal T ToObjectInternal(ResponseMessage cosmosResponseMessage, CosmosSerializer jsonSerializer)
+ internal T ToObjectInternal(ResponseMessage responseMessage)
{
- //Throw the exception
- cosmosResponseMessage.EnsureSuccessStatusCode();
-
- if (cosmosResponseMessage.Content == null)
+ if (responseMessage.Content == null)
{
return default(T);
}
- return jsonSerializer.FromStream(cosmosResponseMessage.Content);
+ return this.serializerCore.FromStream(responseMessage.Content);
}
}
}
\ No newline at end of file
diff --git a/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseCore.cs b/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseCore.cs
index 23bae398cc..737986b018 100644
--- a/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseCore.cs
+++ b/Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseCore.cs
@@ -156,7 +156,7 @@ public override Task CreateContainerAsync(
this.ValidateContainerProperties(containerProperties);
Task response = this.CreateContainerStreamInternalAsync(
- streamPayload: this.ClientContext.PropertiesSerializer.ToStream(containerProperties),
+ streamPayload: this.ClientContext.SerializerCore.ToStream(containerProperties),
throughput: throughput,
requestOptions: requestOptions,
cancellationToken: cancellationToken);
@@ -281,7 +281,7 @@ public override Task CreateContainerStreamAsync(
this.ValidateContainerProperties(containerProperties);
- Stream streamPayload = this.ClientContext.PropertiesSerializer.ToStream(containerProperties);
+ Stream streamPayload = this.ClientContext.SerializerCore.ToStream(containerProperties);
return this.CreateContainerStreamInternalAsync(streamPayload,
throughput,
requestOptions,
@@ -333,7 +333,7 @@ public Task CreateUserStreamAsync(
this.ClientContext.ValidateResource(userProperties.Id);
- Stream streamPayload = this.ClientContext.PropertiesSerializer.ToStream(userProperties);
+ Stream streamPayload = this.ClientContext.SerializerCore.ToStream(userProperties);
return this.ProcessUserCreateAsync(
streamPayload: streamPayload,
requestOptions: requestOptions,
@@ -352,7 +352,7 @@ public override Task UpsertUserAsync(string id,
this.ClientContext.ValidateResource(id);
Task response = this.ProcessUserUpsertAsync(
- streamPayload: this.ClientContext.PropertiesSerializer.ToStream(new UserProperties(id)),
+ streamPayload: this.ClientContext.SerializerCore.ToStream(new UserProperties(id)),
requestOptions: requestOptions,
cancellationToken: cancellationToken);
@@ -423,7 +423,9 @@ public override FeedIterator GetContainerQueryIterator(
return new FeedIteratorCore(
containerStreamIterator,
- this.ClientContext.ResponseFactory.CreateQueryFeedResponse);
+ (response) => this.ClientContext.ResponseFactory.CreateQueryFeedResponse(
+ responseMessage: response,
+ resourceType: ResourceType.Collection));
}
public override FeedIterator GetUserQueryIterator(QueryDefinition queryDefinition,
@@ -441,7 +443,9 @@ public override FeedIterator GetUserQueryIterator(QueryDefinition queryDef
return new FeedIteratorCore(
userStreamIterator,
- this.ClientContext.ResponseFactory.CreateQueryFeedResponse);
+ (response) => this.ClientContext.ResponseFactory.CreateQueryFeedResponse(
+ responseMessage: response,
+ resourceType: ResourceType.User));
}
public FeedIterator GetUserQueryStreamIterator(QueryDefinition queryDefinition,
diff --git a/Microsoft.Azure.Cosmos/src/Resource/Offer/CosmosOffers.cs b/Microsoft.Azure.Cosmos/src/Resource/Offer/CosmosOffers.cs
index 9673b9c860..fcd4d6cfd4 100644
--- a/Microsoft.Azure.Cosmos/src/Resource/Offer/CosmosOffers.cs
+++ b/Microsoft.Azure.Cosmos/src/Resource/Offer/CosmosOffers.cs
@@ -75,7 +75,7 @@ internal async Task ReplaceThroughputAsync(
OfferV2 newOffer = new OfferV2(offerV2, throughput);
return await this.GetThroughputResponseAsync(
- streamPayload: this.ClientContext.PropertiesSerializer.ToStream(newOffer),
+ streamPayload: this.ClientContext.SerializerCore.ToStream(newOffer),
operationType: OperationType.Replace,
linkUri: new Uri(offerV2.SelfLink, UriKind.Relative),
resourceType: ResourceType.Offer,
@@ -95,7 +95,7 @@ internal async Task ReplaceThroughputIfExistsAsync(
OfferV2 newOffer = new OfferV2(offerV2, throughput);
return await this.GetThroughputResponseAsync(
- streamPayload: this.ClientContext.PropertiesSerializer.ToStream(newOffer),
+ streamPayload: this.ClientContext.SerializerCore.ToStream(newOffer),
operationType: OperationType.Replace,
linkUri: new Uri(offerV2.SelfLink, UriKind.Relative),
resourceType: ResourceType.Offer,
@@ -168,7 +168,9 @@ internal virtual FeedIterator GetOfferQueryIterator(
return new FeedIteratorCore(
databaseStreamIterator,
- this.ClientContext.ResponseFactory.CreateQueryFeedResponseWithPropertySerializer);
+ (response) => this.ClientContext.ResponseFactory.CreateQueryFeedResponse(
+ responseMessage: response,
+ resourceType: ResourceType.Offer));
}
internal virtual FeedIterator GetOfferQueryStreamIterator(
diff --git a/Microsoft.Azure.Cosmos/src/Resource/Permission/PermissionCore.cs b/Microsoft.Azure.Cosmos/src/Resource/Permission/PermissionCore.cs
index cb9902a065..55c98cd673 100644
--- a/Microsoft.Azure.Cosmos/src/Resource/Permission/PermissionCore.cs
+++ b/Microsoft.Azure.Cosmos/src/Resource/Permission/PermissionCore.cs
@@ -110,7 +110,7 @@ public override Task ReplaceAsync(PermissionProperties permi
this.ClientContext.ValidateResource(permissionProperties.Id);
Task response = this.ReplaceStreamInternalAsync(
- streamPayload: this.ClientContext.PropertiesSerializer.ToStream(permissionProperties),
+ streamPayload: this.ClientContext.SerializerCore.ToStream(permissionProperties),
tokenExpiryInSeconds: tokenExpiryInSeconds,
requestOptions: requestOptions,
cancellationToken: cancellationToken);
@@ -129,7 +129,7 @@ public Task ReplacePermissionStreamAsync(PermissionProperties p
this.ClientContext.ValidateResource(permissionProperties.Id);
return this.ReplaceStreamInternalAsync(
- streamPayload: this.ClientContext.PropertiesSerializer.ToStream(permissionProperties),
+ streamPayload: this.ClientContext.SerializerCore.ToStream(permissionProperties),
requestOptions: requestOptions,
cancellationToken: cancellationToken);
}
diff --git a/Microsoft.Azure.Cosmos/src/Resource/Scripts/ScriptsCore.cs b/Microsoft.Azure.Cosmos/src/Resource/Scripts/ScriptsCore.cs
index 21a72e0b49..c91d95955a 100644
--- a/Microsoft.Azure.Cosmos/src/Resource/Scripts/ScriptsCore.cs
+++ b/Microsoft.Azure.Cosmos/src/Resource/Scripts/ScriptsCore.cs
@@ -31,7 +31,7 @@ public override Task CreateStoredProcedureAsync(
return this.ProcessStoredProcedureOperationAsync(
linkUri: this.container.LinkUri,
operationType: OperationType.Create,
- streamPayload: this.clientContext.PropertiesSerializer.ToStream(storedProcedureProperties),
+ streamPayload: this.clientContext.SerializerCore.ToStream(storedProcedureProperties),
requestOptions: requestOptions,
cancellationToken: cancellationToken);
}
@@ -99,7 +99,9 @@ public override FeedIterator GetStoredProcedureQueryIterator(
return new FeedIteratorCore(
databaseStreamIterator,
- this.clientContext.ResponseFactory.CreateQueryFeedResponseWithPropertySerializer);
+ (response) => this.clientContext.ResponseFactory.CreateQueryFeedResponse(
+ responseMessage: response,
+ resourceType: ResourceType.StoredProcedure));
}
public override Task ReadStoredProcedureAsync(
@@ -128,7 +130,7 @@ public override Task ReplaceStoredProcedureAsync(
return this.ProcessStoredProcedureOperationAsync(
id: storedProcedureProperties.Id,
operationType: OperationType.Replace,
- streamPayload: this.clientContext.PropertiesSerializer.ToStream(storedProcedureProperties),
+ streamPayload: this.clientContext.SerializerCore.ToStream(storedProcedureProperties),
requestOptions: requestOptions,
cancellationToken: cancellationToken);
}
@@ -178,7 +180,7 @@ public override Task ExecuteStoredProcedureStreamAsync(
Stream streamPayload = null;
if (parameters != null)
{
- streamPayload = this.clientContext.CosmosSerializer.ToStream(parameters);
+ streamPayload = this.clientContext.SerializerCore.ToStream(parameters);
}
return this.ExecuteStoredProcedureStreamAsync(
@@ -241,7 +243,7 @@ public override Task