public DocumentTableRow ReadDocument(int documentId) { var address = AddressReader.Read( new BlockInfo(documentId * BlockSize, BlockSize)); var documentsOffset = Version.KeyIndexOffset + Version.KeyIndexSize; using (var documentReader = new DocumentReader( Stream, Version.Compression, KeyIndex, documentsOffset, leaveOpen: true)) { var document = documentReader.Read(address); document.TableId = documentId; return(document); } }
private IEnumerable <DocumentTableRow> StreamDocuments() { var skipped = 0; var took = 0; for (int docId = 0; docId < _ix.DocumentCount; docId++) { var hash = _hashReader.Read(docId); var address = _addressReader.Read(new[] { new BlockInfo(docId * BlockSerializer.SizeOfBlock(), BlockSerializer.SizeOfBlock()) }).First(); var document = _documentReader.Read(new List <BlockInfo> { address }).First(); if (!hash.IsObsolete) { if (skipped == _skip && took < _take) { yield return(document); took++; } else if (skipped < _skip) { skipped++; } else if (took == _take) { break; } } } }