Exemplo n.º 1
0
        /// <summary>Optimized implementation. </summary>
        public virtual bool SkipTo(int target)
        {
            if (df >= skipInterval)
            {
                // optimized case
                if (skipListReader == null)
                {
                    skipListReader = new DefaultSkipListReader((IndexInput)freqStream.Clone(), maxSkipLevels, skipInterval);  // lazily clone
                }
                if (!haveSkipped)
                {
                    // lazily initialize skip stream
                    skipListReader.Init(skipPointer, freqBasePointer, proxBasePointer, df, currentFieldStoresPayloads);
                    haveSkipped = true;
                }

                int newCount = skipListReader.SkipTo(target);
                if (newCount > count)
                {
                    freqStream.Seek(skipListReader.GetFreqPointer());
                    SkipProx(skipListReader.GetProxPointer(), skipListReader.GetPayloadLength());

                    doc   = skipListReader.GetDoc();
                    count = newCount;
                }
            }

            // done skipping, now just scan
            do
            {
                if (!Next())
                {
                    return(false);
                }
            }while (target > doc);
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>Optimized implementation. </summary>
        public virtual bool SkipTo(int target)
        {
            if (df >= skipInterval)
            {
                // optimized case
                if (skipListReader == null)
                    skipListReader = new DefaultSkipListReader((IndexInput) freqStream.Clone(), maxSkipLevels, skipInterval); // lazily clone

                if (!haveSkipped)
                {
                    // lazily initialize skip stream
                    skipListReader.Init(skipPointer, freqBasePointer, proxBasePointer, df, currentFieldStoresPayloads);
                    haveSkipped = true;
                }

                int newCount = skipListReader.SkipTo(target);
                if (newCount > count)
                {
                    freqStream.Seek(skipListReader.GetFreqPointer());
                    SkipProx(skipListReader.GetProxPointer(), skipListReader.GetPayloadLength());

                    doc = skipListReader.GetDoc();
                    count = newCount;
                }
            }

            // done skipping, now just scan
            do
            {
                if (!Next())
                    return false;
            }
            while (target > doc);
            return true;
        }