Ejemplo n.º 1
0
            public int DocumentCount;                                       //Count of the document records in this index

            public IndexFileInfo(List <Hubble.Core.Entity.DocumentPosition> stepDocIndex,
                                 IndexFile.FilePosition indexFilePostion, int documentCount)
            {
                this.StepDocIndex     = stepDocIndex;
                this.IndexFilePostion = indexFilePostion;
                this.DocumentCount    = documentCount;
            }
Ejemplo n.º 2
0
        private bool NextFileIndex()
        {
            _CurrentFileIndex++;

            if (_CurrentFileIndex >= _WordStepDocIndex.IndexFileInfoList.Count)
            {
                _End = true;
                return(false);
            }

            IndexFile.FilePosition fp = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].IndexFilePostion;

            if (_WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex == null)
            {
                _CurrentIndexBuf        = _IndexFileProxy.GetIndexBufferMemory(fp.Serial, fp.Position, fp.Length);
                _CurrentDocId           = -1;
                _LastDocIdInCurrentStep = -1;
            }
            else
            {
                _CurrentStepDocIndex    = -1;
                _CurrentDocId           = -1;
                _LastDocIdInCurrentStep = -1;
                int length = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[0].Position;

                _CurrentIndexBuf = _IndexFileProxy.GetIndexBufferMemory(fp.Serial, fp.Position, length);
            }
            return(true);
        }
Ejemplo n.º 3
0
        private bool NextFileIndexBuf()
        {
            if (_WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex == null)
            {
                return(NextFileIndex());
            }

            _CurrentStepDocIndex++;

            if (_CurrentStepDocIndex >= _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex.Count)
            {
                return(NextFileIndex());
            }

            IndexFile.FilePosition fp = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].IndexFilePostion;

            _CurrentDocId = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[_CurrentStepDocIndex].DocId;
            int positionInIndex = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[_CurrentStepDocIndex].Position;

            int length;

            if (_CurrentStepDocIndex < _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex.Count - 1)
            {
                length = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[_CurrentStepDocIndex + 1].Position - positionInIndex;
            }
            else
            {
                length = fp.Length - positionInIndex;
            }

            _CurrentIndexBuf = _IndexFileProxy.GetIndexBufferMemory(fp.Serial, fp.Position + positionInIndex, length);

            return(true);
        }
Ejemplo n.º 4
0
 internal void Add(IndexFile.FilePosition fp)
 {
     _FPList.Add(fp);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Match step doc index for this docid
        /// </summary>
        /// <param name="docId"></param>
        private bool Match(int docid)
        {
            if (_WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex == null)
            {
                //Current file index hasn't skip doc index

                return(false);
            }
            else
            {
                int nextStepDocIndex = _CurrentStepDocIndex + 1;

                bool lessThenNextStepDocIndex = false;

                int lastDocIdInCurrentStep = -1; //last docid in current segment of step;

                for (; nextStepDocIndex < _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex.Count; nextStepDocIndex++)
                {
                    //StepDocIndex[nextStepDocIndex].DocId is the last docid of the segment of nextStepDocIndex.
                    lastDocIdInCurrentStep = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[nextStepDocIndex].DocId;
                    if (docid <= lastDocIdInCurrentStep)
                    {
                        lessThenNextStepDocIndex = true;
                        break;
                    }
                }

                if (!lessThenNextStepDocIndex)
                {
                    return(false);
                }
                else
                {
                    if (_CurrentStepDocIndex + 1 == nextStepDocIndex)
                    {
                        _LastDocIdInCurrentStep = lastDocIdInCurrentStep;
                        return(false);
                    }
                    else
                    {
                        _CurrentStepDocIndex = nextStepDocIndex - 1;
                        _CurrentDocId        = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[_CurrentStepDocIndex].DocId;
                        IndexFile.FilePosition fp = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].IndexFilePostion;

                        int positionInIndex = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[_CurrentStepDocIndex].Position;

                        int length;
                        if (_CurrentStepDocIndex < _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex.Count - 1)
                        {
                            length = _WordStepDocIndex.IndexFileInfoList[_CurrentFileIndex].StepDocIndex[_CurrentStepDocIndex + 1].Position - positionInIndex;
                        }
                        else
                        {
                            length = fp.Length - positionInIndex;
                        }

                        _CurrentIndexBuf = _IndexFileProxy.GetIndexBufferMemory(fp.Serial, fp.Position + positionInIndex, length);

                        return(true);
                    }
                }
            }
        }