Exemple #1
0
        private IEnumerable <ReplicationBatchItem> GetReplicationItems(DocumentsOperationContext ctx, long etag, ReplicationStats stats)
        {
            var docs             = _parent._database.DocumentsStorage.GetDocumentsFrom(ctx, etag + 1);
            var tombs            = _parent._database.DocumentsStorage.GetTombstonesFrom(ctx, etag + 1);
            var conflicts        = _parent._database.DocumentsStorage.ConflictsStorage.GetConflictsFrom(ctx, etag + 1).Select(ReplicationBatchItem.From);
            var revisionsStorage = _parent._database.DocumentsStorage.RevisionsStorage;
            var revisions        = revisionsStorage.GetRevisionsFrom(ctx, etag + 1, int.MaxValue).Select(ReplicationBatchItem.From);
            var attachments      = _parent._database.DocumentsStorage.AttachmentsStorage.GetAttachmentsFrom(ctx, etag + 1);
            var counters         = _parent._database.DocumentsStorage.CountersStorage.GetCountersFrom(ctx, etag + 1);


            using (var docsIt = docs.GetEnumerator())
                using (var tombsIt = tombs.GetEnumerator())
                    using (var conflictsIt = conflicts.GetEnumerator())
                        using (var versionsIt = revisions.GetEnumerator())
                            using (var attachmentsIt = attachments.GetEnumerator())
                                using (var countersIt = counters.GetEnumerator())
                                    using (var mergedInEnumerator = new MergedReplicationBatchEnumerator(stats.DocumentRead, stats.AttachmentRead, stats.TombstoneRead, stats.CounterRead))
                                    {
                                        mergedInEnumerator.AddEnumerator(ReplicationBatchItem.ReplicationItemType.Document, docsIt);
                                        mergedInEnumerator.AddEnumerator(ReplicationBatchItem.ReplicationItemType.DocumentTombstone, tombsIt);
                                        mergedInEnumerator.AddEnumerator(ReplicationBatchItem.ReplicationItemType.Document, conflictsIt);
                                        mergedInEnumerator.AddEnumerator(ReplicationBatchItem.ReplicationItemType.Document, versionsIt);
                                        mergedInEnumerator.AddEnumerator(ReplicationBatchItem.ReplicationItemType.Attachment, attachmentsIt);
                                        mergedInEnumerator.AddEnumerator(ReplicationBatchItem.ReplicationItemType.Counter, countersIt);

                                        while (mergedInEnumerator.MoveNext())
                                        {
                                            yield return(mergedInEnumerator.Current);
                                        }
                                    }
        }
Exemple #2
0
        internal static IEnumerable <ReplicationBatchItem> GetReplicationItems(DocumentDatabase database, DocumentsOperationContext ctx, long etag, ReplicationStats stats, bool caseInsensitiveCounters)
        {
            var docs                    = database.DocumentsStorage.GetDocumentsFrom(ctx, etag + 1);
            var tombs                   = database.DocumentsStorage.GetTombstonesFrom(ctx, etag + 1);
            var conflicts               = database.DocumentsStorage.ConflictsStorage.GetConflictsFrom(ctx, etag + 1).Select(DocumentReplicationItem.From);
            var revisionsStorage        = database.DocumentsStorage.RevisionsStorage;
            var revisions               = revisionsStorage.GetRevisionsFrom(ctx, etag + 1, long.MaxValue).Select(DocumentReplicationItem.From);
            var attachments             = database.DocumentsStorage.AttachmentsStorage.GetAttachmentsFrom(ctx, etag + 1);
            var counters                = database.DocumentsStorage.CountersStorage.GetCountersFrom(ctx, etag + 1, caseInsensitiveCounters);
            var timeSeries              = database.DocumentsStorage.TimeSeriesStorage.GetSegmentsFrom(ctx, etag + 1);
            var deletedTimeSeriesRanges = database.DocumentsStorage.TimeSeriesStorage.GetDeletedRangesFrom(ctx, etag + 1);

            using (var docsIt = docs.GetEnumerator())
                using (var tombsIt = tombs.GetEnumerator())
                    using (var conflictsIt = conflicts.GetEnumerator())
                        using (var versionsIt = revisions.GetEnumerator())
                            using (var attachmentsIt = attachments.GetEnumerator())
                                using (var countersIt = counters.GetEnumerator())
                                    using (var timeSeriesIt = timeSeries.GetEnumerator())
                                        using (var deletedTimeSeriesRangesIt = deletedTimeSeriesRanges.GetEnumerator())
                                            using (var mergedInEnumerator = new MergedReplicationBatchEnumerator(stats.DocumentRead, stats.AttachmentRead, stats.TombstoneRead, stats.CounterRead, stats.TimeSeriesRead))
                                            {
                                                mergedInEnumerator.AddEnumerator(ReplicationBatchItem.ReplicationItemType.Document, docsIt);
                                                mergedInEnumerator.AddEnumerator(ReplicationBatchItem.ReplicationItemType.DocumentTombstone, tombsIt);
                                                mergedInEnumerator.AddEnumerator(ReplicationBatchItem.ReplicationItemType.Document, conflictsIt);
                                                mergedInEnumerator.AddEnumerator(ReplicationBatchItem.ReplicationItemType.Document, versionsIt);
                                                mergedInEnumerator.AddEnumerator(ReplicationBatchItem.ReplicationItemType.Attachment, attachmentsIt);
                                                mergedInEnumerator.AddEnumerator(ReplicationBatchItem.ReplicationItemType.CounterGroup, countersIt);
                                                mergedInEnumerator.AddEnumerator(ReplicationBatchItem.ReplicationItemType.TimeSeriesSegment, timeSeriesIt);
                                                mergedInEnumerator.AddEnumerator(ReplicationBatchItem.ReplicationItemType.DeletedTimeSeriesRange, deletedTimeSeriesRangesIt);

                                                while (mergedInEnumerator.MoveNext())
                                                {
                                                    yield return(mergedInEnumerator.Current);
                                                }
                                            }
        }