Пример #1
0
 public void Set(TermInfo ti)
 {
     DocFreq = ti.DocFreq;
     FreqPointer = ti.FreqPointer;
     ProxPointer = ti.ProxPointer;
     SkipOffset = ti.SkipOffset;
 }
Пример #2
0
        internal override void Seek(TermInfo ti, Term term)
        {
            base.Seek(ti, term);
            if (ti != null)
            {
                lazySkipPointer = ti.ProxPointer;
            }

            lazySkipProxCount = 0;
            proxCount         = 0;
            payloadLength     = 0;
            needToLoadPayload = false;
        }
Пример #3
0
        /// <summary>
        /// Adds a new &lt;&lt; <paramref name="fieldNumber"/>, termBytes&gt;, <see cref="TermInfo"/>&gt; pair to the set.
        /// Term must be lexicographically greater than all previous Terms added.
        /// <see cref="TermInfo"/> pointers must be positive and greater than all previous.
        /// </summary>
        public void Add(int fieldNumber, BytesRef term, TermInfo ti)
        {
            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert(CompareToLastTerm(fieldNumber, term) < 0 || (isIndex && term.Length == 0 && lastTerm.Length == 0), () => "Terms are out of order: field=" + FieldName(fieldInfos, fieldNumber) + " (number " + fieldNumber + ")" + " lastField=" + FieldName(fieldInfos, lastFieldNumber) + " (number " + lastFieldNumber + ")" + " text=" + term.Utf8ToString() + " lastText=" + lastTerm.Utf8ToString());
            }

            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert(ti.FreqPointer >= lastTi.FreqPointer, () => "freqPointer out of order (" + ti.FreqPointer + " < " + lastTi.FreqPointer + ")");
            }
            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert(ti.ProxPointer >= lastTi.ProxPointer, () => "proxPointer out of order (" + ti.ProxPointer + " < " + lastTi.ProxPointer + ")");
            }

            if (!isIndex && size % indexInterval == 0)
            {
                other.Add(lastFieldNumber, lastTerm, lastTi);        // add an index term
            }
            WriteTerm(fieldNumber, term);                            // write term

            output.WriteVInt32(ti.DocFreq);                          // write doc freq
            output.WriteVInt64(ti.FreqPointer - lastTi.FreqPointer); // write pointers
            output.WriteVInt64(ti.ProxPointer - lastTi.ProxPointer);

            if (ti.DocFreq >= skipInterval)
            {
                output.WriteVInt32(ti.SkipOffset);
            }

            if (isIndex)
            {
                output.WriteVInt64(other.output.GetFilePointer() - lastIndexPointer);
                lastIndexPointer = other.output.GetFilePointer(); // write pointer
            }

            lastFieldNumber = fieldNumber;
            lastTi.Set(ti);
            size++;
        }
Пример #4
0
 // called only from asserts
 private static bool SameTermInfo(TermInfo ti1, TermInfo ti2, SegmentTermEnum enumerator) // LUCENENET: CA1822: Mark members as static
 {
     if (ti1.DocFreq != ti2.DocFreq)
     {
         return(false);
     }
     if (ti1.FreqPointer != ti2.FreqPointer)
     {
         return(false);
     }
     if (ti1.ProxPointer != ti2.ProxPointer)
     {
         return(false);
     }
     // skipOffset is only valid when docFreq >= skipInterval:
     if (ti1.DocFreq >= enumerator.skipInterval && ti1.SkipOffset != ti2.SkipOffset)
     {
         return(false);
     }
     return(true);
 }
Пример #5
0
 // called only from asserts
 private bool SameTermInfo(TermInfo ti1, TermInfo ti2, SegmentTermEnum enumerator)
 {
     if (ti1.DocFreq != ti2.DocFreq)
     {
         return(false);
     }
     if (ti1.FreqPointer != ti2.FreqPointer)
     {
         return(false);
     }
     if (ti1.ProxPointer != ti2.ProxPointer)
     {
         return(false);
     }
     // skipOffset is only valid when docFreq >= skipInterval:
     if (ti1.DocFreq >= enumerator.skipInterval && ti1.SkipOffset != ti2.SkipOffset)
     {
         return(false);
     }
     return(true);
 }
Пример #6
0
        /// <summary>
        /// Adds a new &lt;&lt; <paramref name="fieldNumber"/>, termBytes&gt;, <see cref="TermInfo"/>&gt; pair to the set.
        /// Term must be lexicographically greater than all previous Terms added.
        /// <see cref="TermInfo"/> pointers must be positive and greater than all previous.
        /// </summary>
        public void Add(int fieldNumber, BytesRef term, TermInfo ti)
        {
            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert(CompareToLastTerm(fieldNumber, term) < 0 || (isIndex && term.Length == 0 && lastTerm.Length == 0),
                                 "Terms are out of order: field={0} (number {1}) lastField={2} (number {3}) text={4} lastText={5}",
                                 FieldName(fieldInfos, fieldNumber), fieldNumber, FieldName(fieldInfos, lastFieldNumber), lastFieldNumber,
                                 // LUCENENET specific - use wrapper BytesRefFormatter struct to defer building the string unless string.Format() is called
                                 new BytesRefFormatter(term, BytesRefFormat.UTF8), new BytesRefFormatter(lastTerm, BytesRefFormat.UTF8));

                Debugging.Assert(ti.FreqPointer >= lastTi.FreqPointer, "freqPointer out of order ({0} < {1})", ti.FreqPointer, lastTi.FreqPointer);
                Debugging.Assert(ti.ProxPointer >= lastTi.ProxPointer, "proxPointer out of order ({0} < {1})", ti.ProxPointer, lastTi.ProxPointer);
            }

            if (!isIndex && size % indexInterval == 0)
            {
                other.Add(lastFieldNumber, lastTerm, lastTi);        // add an index term
            }
            WriteTerm(fieldNumber, term);                            // write term

            output.WriteVInt32(ti.DocFreq);                          // write doc freq
            output.WriteVInt64(ti.FreqPointer - lastTi.FreqPointer); // write pointers
            output.WriteVInt64(ti.ProxPointer - lastTi.ProxPointer);

            if (ti.DocFreq >= skipInterval)
            {
                output.WriteVInt32(ti.SkipOffset);
            }

            if (isIndex)
            {
                output.WriteVInt64(other.output.Position - lastIndexPointer); // LUCENENET specific: Renamed from getFilePointer() to match FileStream
                lastIndexPointer = other.output.Position;                     // write pointer // LUCENENET specific: Renamed from getFilePointer() to match FileStream
            }

            lastFieldNumber = fieldNumber;
            lastTi.Set(ti);
            size++;
        }
Пример #7
0
        internal virtual void Seek(TermInfo ti, Term term)
        {
            Count = 0;
            FieldInfo fi = FieldInfos.FieldInfo(term.Field);

            this.IndexOptions          = (fi != null) ? fi.FieldIndexOptions : FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
            CurrentFieldStoresPayloads = (fi != null) && fi.HasPayloads();
            if (ti == null)
            {
                Df = 0;
            }
            else
            {
                Df              = ti.DocFreq;
                Doc_Renamed     = 0;
                FreqBasePointer = ti.FreqPointer;
                ProxBasePointer = ti.ProxPointer;
                SkipPointer     = FreqBasePointer + ti.SkipOffset;
                FreqStream.Seek(FreqBasePointer);
                HaveSkipped = false;
            }
        }
Пример #8
0
        internal virtual void Seek(TermInfo ti, Term term)
        {
            m_count = 0;
            FieldInfo fi = fieldInfos.FieldInfo(term.Field);

            this.m_indexOptions          = (fi != null) ? fi.IndexOptions : IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
            m_currentFieldStoresPayloads = (fi != null) && fi.HasPayloads;
            if (ti == null)
            {
                m_df = 0;
            }
            else
            {
                m_df            = ti.DocFreq;
                doc             = 0;
                freqBasePointer = ti.FreqPointer;
                proxBasePointer = ti.ProxPointer;
                skipPointer     = freqBasePointer + ti.SkipOffset;
                m_freqStream.Seek(freqBasePointer);
                haveSkipped = false;
            }
        }
Пример #9
0
        public virtual void Seek(Term term)
        {
            TermInfo ti = tis.Get(term);

            Seek(ti, term);
        }
Пример #10
0
 internal virtual void Seek(TermInfo ti, Term term)
 {
     Count = 0;
     FieldInfo fi = FieldInfos.FieldInfo(term.Field());
     this.IndexOptions = (fi != null) ? fi.FieldIndexOptions : FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
     CurrentFieldStoresPayloads = (fi != null) ? fi.HasPayloads() : false;
     if (ti == null)
     {
         Df = 0;
     }
     else
     {
         Df = ti.DocFreq;
         Doc_Renamed = 0;
         FreqBasePointer = ti.FreqPointer;
         ProxBasePointer = ti.ProxPointer;
         SkipPointer = FreqBasePointer + ti.SkipOffset;
         FreqStream.Seek(FreqBasePointer);
         HaveSkipped = false;
     }
 }
Пример #11
0
 public TermInfoAndOrd(TermInfo ti, long termOrd)
     : base(ti)
 {
     Debug.Assert(termOrd >= 0);
     this.termOrd = termOrd;
 }
Пример #12
0
 /// <summary>
 /// Sets the argument to the current TermInfo in the enumeration.
 /// Initially invalid, valid after next() called for the first time.
 /// </summary>
 internal void TermInfo(TermInfo ti)
 {
     ti.Set(TermInfo_Renamed);
 }
Пример #13
0
 /// <summary>
 /// Sets the argument to the current <see cref="Lucene3x.TermInfo"/> in the enumeration.
 /// Initially invalid, valid after <see cref="Next()"/> called for the first time.
 /// </summary>
 internal void TermInfo(TermInfo ti)
 {
     ti.Set(termInfo);
 }
Пример #14
0
 /// <summary>
 /// Sets the argument to the current TermInfo in the enumeration.
 /// Initially invalid, valid after next() called for the first time.
 /// </summary>
 internal void TermInfo(TermInfo ti)
 {
     ti.Set(TermInfo_Renamed);
 }
Пример #15
0
 internal void Seek(long pointer, long p, Term t, TermInfo ti)
 {
     Input.Seek(pointer);
     Position = p;
     TermBuffer.Set(t);
     PrevBuffer.Reset();
     //System.out.println("  ste doSeek prev=" + prevBuffer.toTerm() + " this=" + this);
     TermInfo_Renamed.Set(ti);
     First = p == -1;
 }
Пример #16
0
        public virtual void SeekEnum(SegmentTermEnum enumerator, int indexOffset)
        {
            PagedBytesDataInput input = (PagedBytesDataInput)DataInput.Clone();

            input.Position = IndexToDataOffset.Get(indexOffset);

            // read the term
            int fieldId = input.ReadVInt();
            Term field = Fields[fieldId];
            Term term = new Term(field.Field(), input.ReadString());

            // read the terminfo
            TermInfo termInfo = new TermInfo();
            termInfo.DocFreq = input.ReadVInt();
            if (termInfo.DocFreq >= SkipInterval)
            {
                termInfo.SkipOffset = input.ReadVInt();
            }
            else
            {
                termInfo.SkipOffset = 0;
            }
            termInfo.FreqPointer = input.ReadVLong();
            termInfo.ProxPointer = input.ReadVLong();

            long pointer = input.ReadVLong();

            // perform the seek
            enumerator.Seek(pointer, ((long)indexOffset * TotalIndexInterval) - 1, term, termInfo);
        }
Пример #17
0
 public TermInfoAndOrd(TermInfo ti, long termOrd)
     : base(ti)
 {
     Debug.Assert(termOrd >= 0);
     this.TermOrd = termOrd;
 }
Пример #18
0
 // called only from asserts
 private bool SameTermInfo(TermInfo ti1, TermInfo ti2, SegmentTermEnum enumerator)
 {
     if (ti1.DocFreq != ti2.DocFreq)
     {
         return false;
     }
     if (ti1.FreqPointer != ti2.FreqPointer)
     {
         return false;
     }
     if (ti1.ProxPointer != ti2.ProxPointer)
     {
         return false;
     }
     // skipOffset is only valid when docFreq >= skipInterval:
     if (ti1.DocFreq >= enumerator.SkipInterval && ti1.SkipOffset != ti2.SkipOffset)
     {
         return false;
     }
     return true;
 }
Пример #19
0
        /// <summary>
        /// Adds a new <<fieldNumber, termBytes>, TermInfo> pair to the set.
        ///  Term must be lexicographically greater than all previous Terms added.
        ///  TermInfo pointers must be positive and greater than all previous.
        /// </summary>
        public void Add(int fieldNumber, BytesRef term, TermInfo ti)
        {
            Debug.Assert(CompareToLastTerm(fieldNumber, term) < 0 || (IsIndex && term.Length == 0 && LastTerm.Length == 0), "Terms are out of order: field=" + FieldName(FieldInfos, fieldNumber) + " (number " + fieldNumber + ")" + " lastField=" + FieldName(FieldInfos, LastFieldNumber) + " (number " + LastFieldNumber + ")" + " text=" + term.Utf8ToString() + " lastText=" + LastTerm.Utf8ToString());

            Debug.Assert(ti.FreqPointer >= LastTi.FreqPointer, "freqPointer out of order (" + ti.FreqPointer + " < " + LastTi.FreqPointer + ")");
            Debug.Assert(ti.ProxPointer >= LastTi.ProxPointer, "proxPointer out of order (" + ti.ProxPointer + " < " + LastTi.ProxPointer + ")");

            if (!IsIndex && Size % IndexInterval == 0)
            {
                Other.Add(LastFieldNumber, LastTerm, LastTi); // add an index term
            }
            WriteTerm(fieldNumber, term); // write term

            Output.WriteVInt(ti.DocFreq); // write doc freq
            Output.WriteVLong(ti.FreqPointer - LastTi.FreqPointer); // write pointers
            Output.WriteVLong(ti.ProxPointer - LastTi.ProxPointer);

            if (ti.DocFreq >= SkipInterval)
            {
                Output.WriteVInt(ti.SkipOffset);
            }

            if (IsIndex)
            {
                Output.WriteVLong(Other.Output.FilePointer - LastIndexPointer);
                LastIndexPointer = Other.Output.FilePointer; // write pointer
            }

            LastFieldNumber = fieldNumber;
            LastTi.Set(ti);
            Size++;
        }