Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        public DocumentTableStream(Stream stream, SegmentInfo ix, int skip = 0, int take = int.MaxValue)
            : base(ix.PrimaryKeyFieldName)
        {
            _dataFile = stream;
            _ix       = ix;
            _dataFile.Seek(_ix.KeyIndexOffset, SeekOrigin.Begin);
            var keyIndex = DocumentSerializer.ReadKeyIndex(_dataFile, _ix.KeyIndexSize);

            _hashReader     = new DocHashReader(_dataFile, _ix.DocHashOffset, leaveOpen: false);
            _addressReader  = new BlockInfoReader(_dataFile, _ix.DocAddressesOffset);
            _documentReader = new DocumentReader(
                _dataFile, _ix.Compression, keyIndex, _ix.KeyIndexOffset + _ix.KeyIndexSize, leaveOpen: false);

            _skip = skip;
            _take = take;
        }