Example #1
0
        public IrbisRecord[] ReadAllRecordVersions
        (
            int mfn
        )
        {
            List <IrbisRecord> result      = new List <IrbisRecord>();
            IrbisRecord        lastVersion = ReadRecord(mfn);

            if (lastVersion != null)
            {
                result.Add(lastVersion);
                while (true)
                {
                    long offset = lastVersion.PreviousOffset;
                    if (offset == 0)
                    {
                        break;
                    }
                    MstRecord64 mstRecord       = Mst.ReadRecord2(offset);
                    IrbisRecord previousVersion = mstRecord.DecodeRecord();
                    if (previousVersion != null)
                    {
                        result.Add(previousVersion);
                        lastVersion = previousVersion;
                    }
                }
            }

            return(result.ToArray());
        }
Example #2
0
        public IrbisRecord[] SearchReadSimple
        (
            string key
        )
        {
            int[] mfns = InvertedFile.SearchSimple(key);
            List <IrbisRecord> result = new List <IrbisRecord>();

            foreach (int mfn in mfns)
            {
                try
                {
                    XrfRecord64 xrfRecord = Xrf.ReadRecord(mfn);
                    if (!xrfRecord.Deleted)
                    {
                        MstRecord64 mstRecord
                            = Mst.ReadRecord2(xrfRecord.Offset);
                        if (!mstRecord.Deleted)
                        {
                            IrbisRecord irbisRecord
                                = mstRecord.DecodeRecord();
                            irbisRecord.Database = Database;
                            result.Add(irbisRecord);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }

            return(result.ToArray());
        }
Example #3
0
        public MstRecord64 ReadRecord2
        (
            long offset
        )
        {
            if (_stream.Seek(offset, SeekOrigin.Begin) != offset)
            {
                throw new IOException();
            }

            Encoding encoding = new UTF8Encoding(false, true);

            MemoryStream memory = new MemoryStream(PreloadLength);

            _AppendStream(_stream, memory, PreloadLength);
            memory.Position = 0;

            MstRecordLeader64 leader = MstRecordLeader64.Read(memory);
            int amountToRead         = (int)(leader.Length - memory.Length);

            if (amountToRead > 0)
            {
                _AppendStream(_stream, memory, amountToRead);
            }

            List <MstDictionaryEntry64> dictionary
                = new List <MstDictionaryEntry64>();

            for (int i = 0; i < leader.Nvf; i++)
            {
                MstDictionaryEntry64 entry = new MstDictionaryEntry64
                {
                    Tag      = memory.ReadInt32Network(),
                    Position = memory.ReadInt32Network(),
                    Length   = memory.ReadInt32Network()
                };
                dictionary.Add(entry);
            }

            foreach (MstDictionaryEntry64 entry in dictionary)
            {
                long endOffset = leader.Base + entry.Position;
                memory.Seek(endOffset, SeekOrigin.Begin);
                entry.Bytes = memory.ReadBytes(entry.Length);
                if (entry.Bytes != null)
                {
                    entry.Text = encoding.GetString(entry.Bytes);
                }
            }

            MstRecord64 result = new MstRecord64
            {
                Leader     = leader,
                Dictionary = dictionary
            };

            return(result);
        }
Example #4
0
        public MstRecord64 ReadRecord
        (
            long offset
        )
        {
            if (_stream.Seek(offset, SeekOrigin.Begin) != offset)
            {
                throw new IOException();
            }

            //new ObjectDumper()
            //    .DumpStream(_stream,offset,64)
            //    .WriteLine();

            Encoding encoding = new UTF8Encoding(false, true);

            MstRecordLeader64 leader = MstRecordLeader64.Read(_stream);

            List <MstDictionaryEntry64> dictionary
                = new List <MstDictionaryEntry64>();

            for (int i = 0; i < leader.Nvf; i++)
            {
                MstDictionaryEntry64 entry = new MstDictionaryEntry64
                {
                    Tag      = _stream.ReadInt32Network(),
                    Position = _stream.ReadInt32Network(),
                    Length   = _stream.ReadInt32Network()
                };
                dictionary.Add(entry);
            }

            foreach (MstDictionaryEntry64 entry in dictionary)
            {
                long endOffset = offset + leader.Base + entry.Position;
                _stream.Seek(endOffset, SeekOrigin.Begin);
                entry.Bytes = _stream.ReadBytes(entry.Length);
                if (entry.Bytes != null)
                {
                    entry.Text = encoding.GetString(entry.Bytes);
                }
            }

            MstRecord64 result = new MstRecord64
            {
                Leader     = leader,
                Dictionary = dictionary
            };

            return(result);
        }
Example #5
0
        public IrbisRecord ReadRecord
        (
            int mfn
        )
        {
            XrfRecord64 xrfRecord = Xrf.ReadRecord(mfn);

            if (xrfRecord.Offset == 0)
            {
                return(null);
            }

            MstRecord64 mstRecord = Mst.ReadRecord2(xrfRecord.Offset);
            IrbisRecord result    = mstRecord.DecodeRecord();

            result.Database = Database;

            return(result);
        }