예제 #1
0
파일: IDXFile.cs 프로젝트: wj60387/hubble
        /// <summary>
        /// Get step doc index.
        /// </summary>
        /// <param name="position">first byte of the index (include step doc index)</param>
        /// <param name="length">index buffer length</param>
        /// <param name="count">count of the document records in this index</param>
        /// <param name="indexPostion">first byte of the index (exclude step doc index)<</param>
        /// <returns>step doc index. If no step doc index, return null</returns>
        public List <DocumentPosition> GetStepDocIndex(long position, long length,
                                                       out int count, out long indexPostion)
        {
            Query.PerformanceReport performanceReport = new Hubble.Core.Query.PerformanceReport();


            List <DocumentPosition> result;

            //indexPostion = position;

            _IndexFile.Seek(position, System.IO.SeekOrigin.Begin);

            result = DocumentPositionList.DeserializeSkipDocIndex(_IndexFile, false, out count);

            if (result != null)
            {
                count = DocumentPositionList.GetDocumentsCount(_IndexFile);
            }

            indexPostion = _IndexFile.Position; //The index position exclude count;

            performanceReport.Stop(string.Format("Read index file: len={0}, {1} results. ", _IndexFile.Position - position,
                                                 count));

            return(result);
        }
예제 #2
0
파일: DDXFile.cs 프로젝트: wj60387/hubble
        private void GetSegmentStartStrings()
        {
            List <string> strList = new List <string>(256);

            _File.Seek(0, SeekOrigin.Begin);
            byte[] segment = new byte[SegmentSize];

            if (Hubble.Framework.IO.File.ReadToBuffer(_File, segment))
            {
                do
                {
                    string word;
                    long   position;
                    long   length;

                    if (UnicodeString.Decode(segment, 0, out word, "", out position, out length) >= 0)
                    {
                        strList.Add(word);
                    }
                } while (Hubble.Framework.IO.File.ReadToBuffer(_File, segment));
            }

            _SegmentStartStrings = strList.ToArray();
        }