Exemple #1
0
            public override void Add(BytesRef text, TermStats stats, long termsFilePointer)
            {
                int indexedTermLength = outerInstance.IndexedTermPrefixLength(lastTerm, text);

                //System.out.println("FGW: add text=" + text.utf8ToString() + " " + text + " fp=" + termsFilePointer);

                // write only the min prefix that shows the diff
                // against prior term
                outerInstance.m_output.WriteBytes(text.Bytes, text.Offset, indexedTermLength);

                if (termLengths.Length == numIndexTerms)
                {
                    termLengths = ArrayUtil.Grow(termLengths);
                }
                if (termsPointerDeltas.Length == numIndexTerms)
                {
                    termsPointerDeltas = ArrayUtil.Grow(termsPointerDeltas);
                }

                // save delta terms pointer
                termsPointerDeltas[numIndexTerms] = (int)(termsFilePointer - lastTermsPointer);
                lastTermsPointer = termsFilePointer;

                // save term length (in bytes)
                if (Debugging.AssertsEnabled)
                {
                    Debugging.Assert(indexedTermLength <= short.MaxValue);
                }
                termLengths[numIndexTerms] = (short)indexedTermLength;
                totTermLength += indexedTermLength;

                lastTerm.CopyBytes(text);
                numIndexTerms++;
            }
            public override void Add(BytesRef text, TermStats stats, long termsFilePointer)
            {
                int indexedTermLength = _fgtiw.IndexedTermPrefixLength(_lastTerm, text);

                // write only the min prefix that shows the diff
                // against prior term
                _fgtiw.Output.WriteBytes(text.Bytes, text.Offset, indexedTermLength);

                if (_termLengths.Length == NumIndexTerms)
                {
                    _termLengths = ArrayUtil.Grow(_termLengths);
                }
                if (_termsPointerDeltas.Length == NumIndexTerms)
                {
                    _termsPointerDeltas = ArrayUtil.Grow(_termsPointerDeltas);
                }

                // save delta terms pointer
                _termsPointerDeltas[NumIndexTerms] = (int)(termsFilePointer - _lastTermsPointer);
                _lastTermsPointer = termsFilePointer;

                // save term length (in bytes)
                Debug.Assert(indexedTermLength <= short.MaxValue);
                _termLengths[NumIndexTerms] = (short)indexedTermLength;
                _totTermLength += indexedTermLength;

                _lastTerm.CopyBytes(text);
                NumIndexTerms++;
            }