public bool MoveNext() { Current = null; while (_counters.MoveNext()) { var current = _counters.Current; if (CanMoveNextAndNotExceedLastDocumentInBatch(current.Etag, _lastProcessedDocEtagInBatch) == false) { return(false); } var doc = _docsStorage.Get(_context, current.DocumentId); if (doc != null && current.Etag > doc.Etag) { Current = current; return(true); } // counter has lower etag than its document - we skip it to avoid // sending a counter of document that can not exist on the destination side _stats.RecordChangeVector(current.ChangeVector); _stats.RecordLastFilteredOutEtag(current.Etag, EtlItemType.Counter); } return(false); }
public bool MoveNext() { Current = null; while (_tombstones.MoveNext()) { var current = _tombstones.Current; if (current.Type == _tombstoneType) { if (_fromCollections == null) { Current = current; return(true); } var tombstoneCollection = (string)current.Collection; if (string.IsNullOrEmpty(tombstoneCollection)) { if (_tombstoneType == Tombstone.TombstoneType.Attachment) { var documentId = AttachmentsStorage.ExtractDocIdAndAttachmentNameFromTombstone(_context, current.LowerId).DocId; var document = _context.DocumentDatabase.DocumentsStorage.Get(_context, documentId); if (document != null) // document could be deleted, no need to send DELETE of tombstone, we can filter it out { tombstoneCollection = _context.DocumentDatabase.DocumentsStorage.ExtractCollectionName(_context, document.Data).Name; } } else { ThrowUnexpectedNullCollectionTombstone(_tombstoneType); } } if (_fromCollections.Contains(tombstoneCollection, StringComparer.OrdinalIgnoreCase)) { Current = current; return(true); } } _stats.RecordChangeVector(current.ChangeVector); _stats.RecordLastFilteredOutEtag(current.Etag); } return(false); }
public bool MoveNext() { Current = null; while (_tombstones.MoveNext()) { var current = _tombstones.Current; if (current.Type == Tombstone.TombstoneType.Document) { Current = current; return(true); } _stats.RecordChangeVector(current.ChangeVector); _stats.RecordLastFilteredOutEtag(current.Etag); } return(false); }
public bool MoveNext() { Current = null; while (_counters.MoveNext()) { var current = _counters.Current; var doc = _docsStorage.Get(_context, current.DocumentId); if (doc != null && current.Etag > doc.Etag) { Current = current; return(true); } _stats.RecordChangeVector(current.ChangeVector); _stats.RecordLastFilteredOutEtag(current.Etag, EtlItemType.Counter); } return(false); }
public bool MoveNext() { Current = null; while (_tombstones.MoveNext()) { var current = _tombstones.Current; if (_maxEtag != null) { switch (_tombstoneType) { case Tombstone.TombstoneType.Counter: if (PreventCountersIteratingTooFarEnumerator <ExtractedItem> .CanMoveNext(current.Etag, _maxEtag.Value) == false) { return(false); } break; default: ThrowMaxEtagLimitNotSupported(_tombstoneType); break; } } if (current.Type == _tombstoneType) { if (_fromCollections == null) { Current = current; return(true); } var tombstoneCollection = (string)current.Collection; if (string.IsNullOrEmpty(tombstoneCollection)) { if (_tombstoneType == Tombstone.TombstoneType.Attachment) { var documentId = AttachmentsStorage.ExtractDocIdAndAttachmentNameFromTombstone(_context, current.LowerId).DocId; var document = _context.DocumentDatabase.DocumentsStorage.Get(_context, documentId); if (document != null) // document could be deleted, no need to send DELETE of tombstone, we can filter it out { tombstoneCollection = _context.DocumentDatabase.DocumentsStorage.ExtractCollectionName(_context, document.Data).Name; } } else { ThrowUnexpectedNullCollectionTombstone(_tombstoneType); } } if (_fromCollections.Contains(tombstoneCollection, StringComparer.OrdinalIgnoreCase)) { Current = current; return(true); } } var etlItemType = EtlItemType.None; switch (current.Type) { case Tombstone.TombstoneType.Document: case Tombstone.TombstoneType.Attachment: case Tombstone.TombstoneType.Revision: etlItemType = EtlItemType.Document; break; case Tombstone.TombstoneType.Counter: etlItemType = EtlItemType.Counter; break; default: ThrowFilteringTombstonesOfTypeNotSupported(current.Type); break; } _stats.RecordChangeVector(current.ChangeVector); _stats.RecordLastFilteredOutEtag(current.Etag, etlItemType); } return(false); }