public StagedMutation(TransactionGetResult doc, object?content, StagedMutationType type, MutationToken mutationToken) { Doc = doc; Content = content; Type = type; MutationToken = mutationToken; }
public void TransactionGet(long poolSeq, int index) { var tr = new TransactionId(); tr.PoolSeq = poolSeq; tr.Index = index; TransactionGetResult trgr = api.TransactionGet(tr); }
public async Task <(ulong updatedCas, MutationToken mutationToken)> MutateStagedRemove(TransactionGetResult doc, IAtrRepository atr) { // For ExtAllKvCombinations, the Java implementation was updated to write "txn" as one JSON blob instead of multiple MutateInSpecs. // Remove is the one where it had to be updated, given that we need to remove the staged data only if it exists. var txn = new TransactionXattrs() { Operation = new StagedOperation() { Type = "remove" }, Id = new CompositeId() { Transactionid = _overallContext.TransactionId, AttemptId = _attemptId }, AtrRef = new AtrRef() { Id = atr.AtrId, ScopeName = atr.ScopeName, BucketName = atr.BucketName, CollectionName = atr.CollectionName }, RestoreMetadata = doc.DocumentMetadata }; var txnAsJObject = Newtonsoft.Json.Linq.JObject.FromObject(txn, _metadataSerializer); var specs = new MutateInSpec[] { MutateInSpec.Upsert(TransactionFields.TransactionInterfacePrefixOnly, txnAsJObject, isXattr: true), MutateInSpec.Upsert(TransactionFields.Crc32, MutationMacro.ValueCRC32c, createPath: true, isXattr: true), }; var opts = GetMutateInOptions(StoreSemantics.Replace).Cas(doc.Cas).CreateAsDeleted(true); var updatedDoc = await doc.Collection.MutateInAsync(doc.Id, specs, opts).CAF(); return(updatedDoc.Cas, updatedDoc.MutationToken); }
public async Task <(ulong updatedCas, MutationToken mutationToken)> MutateStagedReplace(TransactionGetResult doc, object content, IAtrRepository atr, bool accessDeleted) { if (doc.Cas == 0) { throw new ArgumentOutOfRangeException("Document CAS should not be wildcard or default when replacing."); } var specs = CreateMutationSpecs(atr, "replace", content, doc.DocumentMetadata); var opts = GetMutateInOptions(StoreSemantics.Replace).Cas(doc.Cas); if (accessDeleted) { opts.AccessDeleted(true); } var updatedDoc = await doc.Collection.MutateInAsync(doc.Id, specs, opts).CAF(); return(updatedDoc.Cas, updatedDoc.MutationToken); }
public async Task <(ulong updatedCas, MutationToken mutationToken)> RemoveStagedInsert(TransactionGetResult doc) { var specs = new MutateInSpec[] { MutateInSpec.Remove(TransactionFields.TransactionInterfacePrefixOnly, isXattr: true) }; var opts = GetMutateInOptions(StoreSemantics.Replace).Cas(doc.Cas).AccessDeleted(true); var updatedDoc = await doc.Collection.MutateInAsync(doc.Id, specs, opts).CAF(); return(updatedDoc.Cas, updatedDoc.MutationToken); }
public Task <(ulong updatedCas, MutationToken mutationToken)> RemoveStagedInsert(TransactionGetResult doc) { throw new NotImplementedException(); }
public async Task <(ulong updatedCas, MutationToken mutationToken)> MutateStagedReplace(TransactionGetResult doc, object content, IAtrRepository atr, bool accessDeleted) { _ = await LookupDocumentAsync(doc.Collection, doc.Id); Interlocked.Increment(ref _rollingCas); return((ulong)_rollingCas, new MutationToken("fake", 1, 2, _rollingCas)); }
public static DocumentAlreadyInTransactionException Create(AttemptContext ctx, TransactionGetResult doc) { var msg = $"Document {ctx.Redactor.UserData(doc.Id)} is already in a transaction, atr={doc.TransactionXattrs?.AtrRef?.ToString()}, attemptId = {doc.TransactionXattrs?.Id?.AttemptId ?? "-"}"; return(new DocumentAlreadyInTransactionException(ctx, doc, msg)); }
private DocumentAlreadyInTransactionException(AttemptContext ctx, TransactionGetResult doc, string msg) : base(ctx, msg) { Doc = doc; }