/// <summary> /// Provides a means of ensuring "read your own writes" or RYOW consistency on the current query. /// </summary> #pragma warning disable 618 /// <remarks>Note: <see cref="ScanConsistency"/> will be overwritten to <see cref="Query.ScanConsistency.AtPlus"/>.</remarks> #pragma warning restore 618 /// <param name="mutationState">State of the mutation.</param> /// <returns>A reference to the current <see cref="IQueryOptions"/> for method chaining.</returns> public IQueryOptions ConsistentWith(MutationState mutationState) { #pragma warning disable 618 ScanConsistency(Query.ScanConsistency.AtPlus); #pragma warning restore 618 _scanVectors = new Dictionary <string, Dictionary <string, List <object> > >(); foreach (var token in mutationState) { if (_scanVectors.TryGetValue(token.BucketRef, out var vector)) { var bucketId = token.VBucketId.ToString(); if (vector.TryGetValue(bucketId, out var bucketRef)) { if ((long)bucketRef.First() < token.SequenceNumber) { vector[bucketId] = new List <object> { token.SequenceNumber, token.VBucketUuid.ToString() }; } } else { vector.Add(token.VBucketId.ToString(), new List <object> { token.SequenceNumber, token.VBucketUuid.ToString() }); } } else { _scanVectors.Add(token.BucketRef, new Dictionary <string, List <object> > { { token.VBucketId.ToString(), new List <object> { token.SequenceNumber, token.VBucketUuid.ToString() } } }); } } return(this); }
/// <summary> /// Adds the <see cref="MutationToken"/>'s from another <see cref="MutationState"/>. /// </summary> /// <param name="mutationState">State of the mutation.</param> /// <returns>The <see cref="MutationState"/> object itself.</returns> public MutationState Add(MutationState mutationState) { _tokens.AddRange(mutationState._tokens); return(this); }
/// <summary> /// Creates a<see cref= "MutationState" /> from another <see cref="MutationState"/> assuming enhanced durability is enabled. /// </summary> /// <param name="mutationState">State of the mutation.</param> /// <returns>The <see cref="MutationState"/> object itself.</returns> public static MutationState From(MutationState mutationState) { return(new MutationState().Add(mutationState)); }