public IEnumerable<QueryRow> GetAllDocs(QueryOptions options)
        {
            var remainingIDs = default(List<string>);
            var enumerator = GetDocEnumerator(options, out remainingIDs);
            var current = 0;
            foreach(var next in enumerator) {
                if (current++ >= options.Limit) {
                    yield break;
                }

                var sequenceNumber = 0L;
                var docID = next.CurrentDocID;
                remainingIDs.Remove(docID);
                var value = default(IDictionary<string, object>);
                if (next.Exists) {
                    sequenceNumber = (long)next.SelectedRev.sequence;
                    var conflicts = default(IList<string>);
                    if (options.AllDocsMode >= AllDocsMode.ShowConflicts && next.IsConflicted) {
                        SelectCurrentRevision(next);
                        using (var innerEnumerator = new CBForestHistoryEnumerator(next, true, false)) {
                            conflicts = innerEnumerator.Select(x => (string)x.SelectedRev.revID).ToList();
                        }

                        if (conflicts.Count == 1) {
                            conflicts = null;
                        }
                    }

                    bool valid = conflicts != null || options.AllDocsMode != AllDocsMode.OnlyConflicts;
                    if (!valid) {
                        continue;
                    }

                    value = new NonNullDictionary<string, object> {
                        { "rev", next.CurrentRevID },
                        { "deleted", next.IsDeleted ? (object)true : null },
                        { "_conflicts", conflicts }
                    };
                }

                var row = new QueryRow(value == null ? null : docID, sequenceNumber, docID, value, 
                    value == null ? null : new RevisionInternal(next, options.IncludeDocs), null);
                if (options.Filter == null || options.Filter(row)) {
                    yield return row;
                }
            }

            foreach (var docId in remainingIDs) {
                var value = GetAllDocsEntry(docId);
                
                    
                var row = new QueryRow(value != null ? docId as string : null, 0, docId, value, null, null);
                if (options.Filter == null || options.Filter(row)) {
                    yield return row;
                }
            }
                
        }
        public IEnumerable<QueryRow> GetAllDocs(QueryOptions options)
        {
            var remainingIDs = default(List<string>);
            var enumerator = GetDocEnumerator(options, out remainingIDs);
            var current = 0;
            foreach(var next in enumerator) {
                if(current++ >= options.Limit) {
                    yield break;
                }

                var sequenceNumber = 0L;
                var docID = next.CurrentDocID;
                remainingIDs.Remove(docID);
                var value = default(IDictionary<string, object>);
                if(next.Exists) {
                    sequenceNumber = (long)next.SelectedRev.sequence;
                    var conflicts = default(IList<string>);
                    if(options.AllDocsMode >= AllDocsMode.ShowConflicts && next.IsConflicted) {
                        SelectCurrentRevision(next);
                        LoadRevisionBody(next);
                        using(var innerEnumerator = GetHistoryFromSequence(next.Sequence)) {
                            conflicts = innerEnumerator.Select(x => (string)x.SelectedRev.revID).ToList();
                        }

                        if(conflicts.Count == 1) {
                            conflicts = null;
                        }
                    }

                    bool valid = conflicts != null || options.AllDocsMode != AllDocsMode.OnlyConflicts;
                    if(!valid) {
                        continue;
                    }

                    value = new NonNullDictionary<string, object> {
                        { "rev", next.CurrentRevID },
                        { "deleted", next.IsDeleted ? (object)true : null },
                        { "_conflicts", conflicts }
                    };
                    Log.To.Query.V(TAG, "AllDocs: Found row with key=\"{0}\", value={1}",
                        new SecureLogString(docID, LogMessageSensitivity.PotentiallyInsecure),
                        new SecureLogJsonString(value, LogMessageSensitivity.PotentiallyInsecure));
                } else {
                    Log.To.Query.V(TAG, "AllDocs: No such row with key=\"{0}\"", new SecureLogString(docID, LogMessageSensitivity.PotentiallyInsecure));
                }

                var row = new QueryRow(value == null ? null : docID, sequenceNumber, docID, value,
                    value == null ? null : new ForestRevisionInternal(next, options.IncludeDocs), null);
                if(options.Filter == null || options.Filter(row)) {
                    yield return row;
                } else {
                    Log.To.Query.V(TAG, "   ... on 2nd thought, filter predicate skipped that row");
                }
            }

            foreach(var docId in remainingIDs) {
                var value = GetAllDocsEntry(docId);


                var row = new QueryRow(value != null ? docId as string : null, 0, docId, value, null, null);
                if(options.Filter == null || options.Filter(row)) {
                    yield return row;
                }
            }

        }