public IEnumerable <ReplicationBatchItem> GetConflictsFrom(DocumentsOperationContext context, long etag) { var table = context.Transaction.InnerTransaction.OpenTable(ConflictsSchema, ConflictsSlice); foreach (var tvr in table.SeekForwardFrom(ConflictsSchema.FixedSizeIndexes[AllConflictedDocsEtagsSlice], etag, 0)) { yield return(ReplicationBatchItem.From(TableValueToConflictDocument(context, ref tvr.Reader))); } }
private ReplicationBatchItem ConvertForTest(TransactionOperationContext context, ReplicationBatchItem item) { if (item.Type == ReplicationBatchItem.ReplicationItemType.Attachment) { item.Stream.Position = 0; var stream = new MemoryStream(); item.Stream.CopyTo(stream); stream.Position = 0; item.Stream.Position = 0; return(new ReplicationBatchItem { Base64Hash = item.Base64Hash.Clone(context.Allocator), ContentType = context.GetLazyString(item.ContentType), Name = context.GetLazyString(item.Name), Id = context.GetLazyString(item.Id), Stream = stream, Type = item.Type, ChangeVector = item.ChangeVector, LastModifiedTicks = item.LastModifiedTicks, TransactionMarker = item.TransactionMarker, Etag = item.Etag }); } if (item.Type == ReplicationBatchItem.ReplicationItemType.Document) { return(new ReplicationBatchItem { Id = context.GetLazyString(item.Id), Data = item.Data?.Clone(context), Collection = context.GetLazyString(item.Collection), Flags = item.Flags, Type = item.Type, ChangeVector = item.ChangeVector, LastModifiedTicks = item.LastModifiedTicks, TransactionMarker = item.TransactionMarker, Etag = item.Etag }); } throw new InvalidOperationException($"This test should receive only the following types: ReplicationItemType.Document, ReplicationItemType.Attachment."); }