SWEEP: Lucene.Net.Codecs.Sep: Reviewed line-by-line and fixed several potential logic bugs, most notably invalid comparisons due to non-nullable IndexOptions fields.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/17ec8e0c Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/17ec8e0c Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/17ec8e0c Branch: refs/heads/api-work Commit: 17ec8e0c0a8c6f2a90ece0726384ce6a74debc8e Parents: 2834c04 Author: Shad Storhaug <[email protected]> Authored: Thu Mar 16 16:31:22 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Thu Mar 16 16:31:22 2017 +0700 ---------------------------------------------------------------------- src/Lucene.Net.Codecs/Sep/SepPostingsReader.cs | 158 ++++++++++++-------- src/Lucene.Net.Codecs/Sep/SepPostingsWriter.cs | 55 ++++--- src/Lucene.Net.Codecs/Sep/SepSkipListReader.cs | 74 ++++++--- src/Lucene.Net.Codecs/Sep/SepSkipListWriter.cs | 24 +-- 4 files changed, 190 insertions(+), 121 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17ec8e0c/src/Lucene.Net.Codecs/Sep/SepPostingsReader.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Codecs/Sep/SepPostingsReader.cs b/src/Lucene.Net.Codecs/Sep/SepPostingsReader.cs index dac8caa..d305642 100644 --- a/src/Lucene.Net.Codecs/Sep/SepPostingsReader.cs +++ b/src/Lucene.Net.Codecs/Sep/SepPostingsReader.cs @@ -119,11 +119,11 @@ namespace Lucene.Net.Codecs.Sep // We store only the seek point to the docs file because // the rest of the info (freqIndex, posIndex, etc.) is // stored in the docs file: - internal Int32IndexInput.AbstractIndex DOC_INDEX; - internal Int32IndexInput.AbstractIndex POS_INDEX; - internal Int32IndexInput.AbstractIndex FREQ_INDEX; - internal long PAYLOAD_FP; - internal long SKIP_FP; + internal Int32IndexInput.AbstractIndex docIndex; + internal Int32IndexInput.AbstractIndex posIndex; + internal Int32IndexInput.AbstractIndex freqIndex; + internal long payloadFP; + internal long skipFP; public override object Clone() { @@ -137,64 +137,68 @@ namespace Lucene.Net.Codecs.Sep base.CopyFrom(tsOther); var other = (SepTermState)tsOther; - if (DOC_INDEX == null) + if (docIndex == null) { - DOC_INDEX = other.DOC_INDEX.Clone(); + docIndex = other.docIndex.Clone(); } else { - DOC_INDEX.CopyFrom(other.DOC_INDEX); + docIndex.CopyFrom(other.docIndex); } - if (other.FREQ_INDEX != null) + if (other.freqIndex != null) { - if (FREQ_INDEX == null) + if (freqIndex == null) { - FREQ_INDEX = other.FREQ_INDEX.Clone(); + freqIndex = other.freqIndex.Clone(); } else { - FREQ_INDEX.CopyFrom(other.FREQ_INDEX); + freqIndex.CopyFrom(other.freqIndex); } } else { - FREQ_INDEX = null; + freqIndex = null; } - if (other.POS_INDEX != null) + if (other.posIndex != null) { - if (POS_INDEX == null) + if (posIndex == null) { - POS_INDEX = other.POS_INDEX.Clone(); + posIndex = other.posIndex.Clone(); } else { - POS_INDEX.CopyFrom(other.POS_INDEX); + posIndex.CopyFrom(other.posIndex); } } else { - POS_INDEX = null; + posIndex = null; } - PAYLOAD_FP = other.PAYLOAD_FP; - SKIP_FP = other.SKIP_FP; + payloadFP = other.payloadFP; + skipFP = other.skipFP; } public override string ToString() { - return base.ToString() + " docIndex=" + DOC_INDEX + " freqIndex=" + FREQ_INDEX + " posIndex=" + POS_INDEX + - " payloadFP=" + PAYLOAD_FP + " skipFP=" + SKIP_FP; + return base.ToString() + " docIndex=" + docIndex + " freqIndex=" + freqIndex + " posIndex=" + posIndex + + " payloadFP=" + payloadFP + " skipFP=" + skipFP; } } public override BlockTermState NewTermState() { - var state = new SepTermState {DOC_INDEX = _docIn.GetIndex()}; + var state = new SepTermState { docIndex = _docIn.GetIndex() }; if (_freqIn != null) - state.FREQ_INDEX = _freqIn.GetIndex(); + { + state.freqIndex = _freqIn.GetIndex(); + } if (_posIn != null) - state.POS_INDEX = _posIn.GetIndex(); + { + state.posIndex = _posIn.GetIndex(); + } return state; } @@ -203,42 +207,46 @@ namespace Lucene.Net.Codecs.Sep bool absolute) { var termState = (SepTermState) bTermState; - termState.DOC_INDEX.Read(input, absolute); + termState.docIndex.Read(input, absolute); if (fieldInfo.IndexOptions != IndexOptions.DOCS_ONLY) { - termState.FREQ_INDEX.Read(input, absolute); + termState.freqIndex.Read(input, absolute); if (fieldInfo.IndexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) { - termState.POS_INDEX.Read(input, absolute); - + //System.out.println(" freqIndex=" + termState.freqIndex); + termState.posIndex.Read(input, absolute); + //System.out.println(" posIndex=" + termState.posIndex); if (fieldInfo.HasPayloads) { if (absolute) { - termState.PAYLOAD_FP = input.ReadVInt64(); + termState.payloadFP = input.ReadVInt64(); } else { - termState.PAYLOAD_FP += input.ReadVInt64(); + termState.payloadFP += input.ReadVInt64(); } + //System.out.println(" payloadFP=" + termState.payloadFP); } } } if (termState.DocFreq >= _skipMinimum) { + //System.out.println(" readSkip @ " + in.getPosition()); if (absolute) { - termState.SKIP_FP = input.ReadVInt64(); + termState.skipFP = input.ReadVInt64(); } else { - termState.SKIP_FP += input.ReadVInt64(); + termState.skipFP += input.ReadVInt64(); } + //System.out.println(" skipFP=" + termState.skipFP); } else if (absolute) { - termState.SKIP_FP = 0; + termState.skipFP = 0; } } @@ -248,7 +256,7 @@ namespace Lucene.Net.Codecs.Sep var termState = (SepTermState)bTermState; SepDocsEnum docsEnum; - if (!(reuse is SepDocsEnum)) + if (reuse == null || !(reuse is SepDocsEnum)) { docsEnum = new SepDocsEnum(this); } @@ -274,7 +282,7 @@ namespace Lucene.Net.Codecs.Sep Debug.Assert(fieldInfo.IndexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS); var termState = (SepTermState)bTermState; SepDocsAndPositionsEnum postingsEnum; - if (!(reuse is SepDocsAndPositionsEnum)) + if (reuse == null || !(reuse is SepDocsAndPositionsEnum)) { postingsEnum = new SepDocsAndPositionsEnum(this); } @@ -305,7 +313,7 @@ namespace Lucene.Net.Codecs.Sep // TODO: -- should we do omitTF with 2 different enum classes? private bool _omitTf; - private IndexOptions _indexOptions; + private IndexOptions? _indexOptions; private bool _storePayloads; private IBits _liveDocs; private readonly Int32IndexInput.AbstractReader _docReader; @@ -315,7 +323,7 @@ namespace Lucene.Net.Codecs.Sep private readonly Int32IndexInput.AbstractIndex _docIndex; private readonly Int32IndexInput.AbstractIndex _freqIndex; private readonly Int32IndexInput.AbstractIndex _posIndex; - internal Int32IndexInput startDocIn; + internal readonly Int32IndexInput startDocIn; // TODO: -- should we do hasProx with 2 different enum classes? @@ -337,34 +345,34 @@ namespace Lucene.Net.Codecs.Sep _freqReader = null; _freqIndex = null; } - _posIndex = outerInstance._posIn != null ? outerInstance._posIn.GetIndex() : null; + _posIndex = outerInstance._posIn != null + ? outerInstance._posIn.GetIndex() // only init this so skipper can read it + : null; startDocIn = outerInstance._docIn; } internal virtual SepDocsEnum Init(FieldInfo fieldInfo, SepTermState termState, IBits liveDocs) { - _liveDocs = liveDocs; - if (fieldInfo.IndexOptions.HasValue) - _indexOptions = fieldInfo.IndexOptions.Value; - + this._liveDocs = liveDocs; + this._indexOptions = fieldInfo.IndexOptions; _omitTf = _indexOptions == IndexOptions.DOCS_ONLY; _storePayloads = fieldInfo.HasPayloads; // TODO: can't we only do this if consumer // skipped consuming the previous docs? - _docIndex.CopyFrom(termState.DOC_INDEX); + _docIndex.CopyFrom(termState.docIndex); _docIndex.Seek(_docReader); if (!_omitTf) { - _freqIndex.CopyFrom(termState.FREQ_INDEX); + _freqIndex.CopyFrom(termState.freqIndex); _freqIndex.Seek(_freqReader); } _docFreq = termState.DocFreq; // NOTE: unused if docFreq < skipMinimum: - _skipFp = termState.SKIP_FP; + _skipFp = termState.skipFP; _count = 0; _doc = -1; _accum = 0; @@ -425,7 +433,9 @@ namespace Lucene.Net.Codecs.Sep // This DocsEnum has never done any skipping _skipper = new SepSkipListReader((IndexInput)_outerInstance._skipIn.Clone(), _outerInstance._freqIn, - _outerInstance._docIn, _outerInstance._posIn, _outerInstance._maxSkipLevels, + _outerInstance._docIn, + _outerInstance._posIn, + _outerInstance._maxSkipLevels, _outerInstance._skipInterval); } @@ -482,6 +492,7 @@ namespace Lucene.Net.Codecs.Sep private int _accum; private int _count; private int _freq; + // private long freqStart; // LUCENENET - Not used private bool _storePayloads; private IBits _liveDocs; @@ -511,6 +522,8 @@ namespace Lucene.Net.Codecs.Sep internal SepDocsAndPositionsEnum(SepPostingsReader outerInstance) { _outerInstance = outerInstance; + + startDocIn = outerInstance._docIn; _docReader = outerInstance._docIn.GetReader(); _docIndex = outerInstance._docIn.GetIndex(); _freqReader = outerInstance._freqIn.GetReader(); @@ -518,28 +531,32 @@ namespace Lucene.Net.Codecs.Sep _posReader = outerInstance._posIn.GetReader(); _posIndex = outerInstance._posIn.GetIndex(); _payloadIn = (IndexInput) outerInstance._payloadIn.Clone(); - - startDocIn = outerInstance._docIn; } internal virtual SepDocsAndPositionsEnum Init(FieldInfo fieldInfo, SepTermState termState, IBits liveDocs) { _liveDocs = liveDocs; _storePayloads = fieldInfo.HasPayloads; + //System.out.println("Sep D&P init"); - // TODO: can't we only do this if consumer skipped consuming the previous docs? - _docIndex.CopyFrom(termState.DOC_INDEX); + // TODO: can't we only do this if consumer + // skipped consuming the previous docs? + _docIndex.CopyFrom(termState.docIndex); _docIndex.Seek(_docReader); + //System.out.println(" docIndex=" + docIndex); - _freqIndex.CopyFrom(termState.FREQ_INDEX); + _freqIndex.CopyFrom(termState.freqIndex); _freqIndex.Seek(_freqReader); + //System.out.println(" freqIndex=" + freqIndex); - _posIndex.CopyFrom(termState.POS_INDEX); + _posIndex.CopyFrom(termState.posIndex); + //System.out.println(" posIndex=" + posIndex); _posSeekPending = true; _payloadPending = false; - _payloadFp = termState.PAYLOAD_FP; - _skipFp = termState.SKIP_FP; + _payloadFp = termState.payloadFP; + _skipFp = termState.skipFP; + //System.out.println(" skipFP=" + skipFP); _docFreq = termState.DocFreq; _count = 0; @@ -557,17 +574,28 @@ namespace Lucene.Net.Codecs.Sep while (true) { if (_count == _docFreq) + { return _doc = NO_MORE_DOCS; + } _count++; + // TODO: maybe we should do the 1-bit trick for encoding + // freq=1 case? + // Decode next doc + //System.out.println(" sep d&p read doc"); _accum += _docReader.Next(); + + //System.out.println(" sep d&p read freq"); _freq = _freqReader.Next(); + _pendingPosCount += _freq; if (_liveDocs == null || _liveDocs.Get(_accum)) + { break; + } } _position = 0; @@ -590,7 +618,6 @@ namespace Lucene.Net.Codecs.Sep if ((target - _outerInstance._skipInterval) >= _doc && _docFreq >= _outerInstance._skipMinimum) { - // There are enough docs in the posting to have // skip data, and its not too close @@ -600,7 +627,9 @@ namespace Lucene.Net.Codecs.Sep // This DocsEnum has never done any skipping _skipper = new SepSkipListReader((IndexInput) _outerInstance._skipIn.Clone(), _outerInstance._freqIn, - _outerInstance._docIn, _outerInstance._posIn, _outerInstance._maxSkipLevels, + _outerInstance._docIn, + _outerInstance._posIn, + _outerInstance._maxSkipLevels, _outerInstance._skipInterval); } @@ -614,28 +643,29 @@ namespace Lucene.Net.Codecs.Sep } int newCount = _skipper.SkipTo(target); + //System.out.println(" skip newCount=" + newCount + " vs " + count); if (newCount > _count) { - // Skipper did move _skipper.FreqIndex.Seek(_freqReader); _skipper.DocIndex.Seek(_docReader); - + //System.out.println(" doc seek'd to " + skipper.getDocIndex()); // NOTE: don't seek pos here; do it lazily // instead. Eg a PhraseQuery may skip to many // docs before finally asking for positions... - _posIndex.CopyFrom(_skipper.PosIndex); _posSeekPending = true; _count = newCount; _doc = _accum = _skipper.Doc; - + //System.out.println(" moved to doc=" + doc); + //payloadIn.seek(skipper.getPayloadPointer()); _payloadFp = _skipper.PayloadPointer; _pendingPosCount = 0; _pendingPayloadBytes = 0; _payloadPending = false; _payloadLength = _skipper.PayloadLength; + //System.out.println(" move payloadLen=" + payloadLength); } } @@ -644,11 +674,13 @@ namespace Lucene.Net.Codecs.Sep { if (NextDoc() == NO_MORE_DOCS) { + //System.out.println(" advance nextDoc=END"); return NO_MORE_DOCS; } - + //System.out.println(" advance nextDoc=" + doc); } while (target > _doc); + //System.out.println(" return doc=" + doc); return _doc; } @@ -735,7 +767,7 @@ namespace Lucene.Net.Codecs.Sep if (_payload == null) { - _payload = new BytesRef {Bytes = new byte[_payloadLength]}; + _payload = new BytesRef { Bytes = new byte[_payloadLength] }; } else if (_payload.Bytes.Length < _payloadLength) { http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17ec8e0c/src/Lucene.Net.Codecs/Sep/SepPostingsWriter.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Codecs/Sep/SepPostingsWriter.cs b/src/Lucene.Net.Codecs/Sep/SepPostingsWriter.cs index 53dee93..f54d201 100644 --- a/src/Lucene.Net.Codecs/Sep/SepPostingsWriter.cs +++ b/src/Lucene.Net.Codecs/Sep/SepPostingsWriter.cs @@ -82,7 +82,7 @@ namespace Lucene.Net.Codecs.Sep internal readonly int totalNumDocs; internal bool storePayloads; - internal IndexOptions indexOptions; + internal IndexOptions? indexOptions; internal FieldInfo fieldInfo; @@ -108,7 +108,7 @@ namespace Lucene.Net.Codecs.Sep posOut = null; posIndex = null; payloadOut = null; - var success = false; + bool success = false; try { this.skipInterval = skipInterval; @@ -189,14 +189,13 @@ namespace Lucene.Net.Codecs.Sep // Currently, this instance is re-used across fields, so // our parent calls setField whenever the field changes - public override int SetField(FieldInfo fi) + public override int SetField(FieldInfo fieldInfo) { - fieldInfo = fi; + this.fieldInfo = fieldInfo; - if (fieldInfo.IndexOptions.HasValue) - indexOptions = fieldInfo.IndexOptions.Value; + indexOptions = fieldInfo.IndexOptions; - if (indexOptions >= IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) + if (indexOptions.GetValueOrDefault().CompareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0) { throw new System.NotSupportedException("this codec cannot index offsets"); } @@ -211,7 +210,10 @@ namespace Lucene.Net.Codecs.Sep private SepTermState SetEmptyState() { - var emptyState = new SepTermState {DocIndex = docOut.GetIndex()}; + var emptyState = new SepTermState + { + DocIndex = docOut.GetIndex() + }; if (indexOptions != IndexOptions.DOCS_ONLY) { emptyState.FreqIndex = freqOut.GetIndex(); @@ -231,7 +233,7 @@ namespace Lucene.Net.Codecs.Sep /// </summary> public override void StartDoc(int docId, int termDocFreq) { - var delta = docId - lastDocID; + int delta = docId - lastDocID; if (docId < 0 || (df > 0 && delta <= 0)) { @@ -239,9 +241,11 @@ namespace Lucene.Net.Codecs.Sep docOut + ")"); } - if ((++df%skipInterval) == 0) + if ((++df % skipInterval) == 0) { - // TODO: -- awkward we have to make these two separate calls to skipper + // TODO: -- awkward we have to make these two + // separate calls to skipper + //System.out.println(" buffer skip lastDocID=" + lastDocID); skipListWriter.SetSkipData(lastDocID, storePayloads, lastPayloadLength); skipListWriter.BufferSkip(df); } @@ -256,13 +260,13 @@ namespace Lucene.Net.Codecs.Sep } /// <summary> - /// Add a new position & payload </summary> + /// Add a new position & payload </summary> public override void AddPosition(int position, BytesRef payload, int startOffset, int endOffset) { Debug.Assert(indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS); + int delta = position - lastPosition; - Debug.Assert(delta >= 0, "position=" + position + " lastPosition=" + lastPosition); - // not quite right (if pos=0 is repeated twice we don't catch it) + Debug.Assert(delta >= 0, "position=" + position + " lastPosition=" + lastPosition); // not quite right (if pos=0 is repeated twice we don't catch it) lastPosition = position; if (storePayloads) @@ -281,7 +285,7 @@ namespace Lucene.Net.Codecs.Sep posOut.Write(delta << 1); } - if (payloadLength > 0 && payload != null) + if (payloadLength > 0) { payloadOut.WriteBytes(payload.Bytes, payload.Offset, payloadLength); } @@ -342,7 +346,9 @@ namespace Lucene.Net.Codecs.Sep if (df >= skipMinimum) { state.SkipFp = skipOut.FilePointer; + //System.out.println(" skipFP=" + skipFP); skipListWriter.WriteSkip(skipOut); + //System.out.println(" numBytes=" + (skipOut.getFilePointer()-skipFP)); } else { @@ -387,17 +393,18 @@ namespace Lucene.Net.Codecs.Sep } } } - if (state.SkipFp == -1) return; - - if (absolute) - { - output.WriteVInt64(state.SkipFp); - } - else + if (state.SkipFp != -1) { - output.WriteVInt64(state.SkipFp - lastSkipFP); + if (absolute) + { + output.WriteVInt64(state.SkipFp); + } + else + { + output.WriteVInt64(state.SkipFp - lastSkipFP); + } + lastSkipFP = state.SkipFp; } - lastSkipFP = state.SkipFp; } protected override void Dispose(bool disposing) http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17ec8e0c/src/Lucene.Net.Codecs/Sep/SepSkipListReader.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Codecs/Sep/SepSkipListReader.cs b/src/Lucene.Net.Codecs/Sep/SepSkipListReader.cs index 09c677f..dd0dff8 100644 --- a/src/Lucene.Net.Codecs/Sep/SepSkipListReader.cs +++ b/src/Lucene.Net.Codecs/Sep/SepSkipListReader.cs @@ -51,22 +51,28 @@ namespace Lucene.Net.Codecs.Sep : base(skipStream, maxSkipLevels, skipInterval) { if (freqIn != null) + { _freqIndex = new Int32IndexInput.AbstractIndex[maxSkipLevels]; - + } _docIndex = new Int32IndexInput.AbstractIndex[maxSkipLevels]; - if (posIn != null) + { _posIndex = new Int32IndexInput.AbstractIndex[m_maxNumberOfSkipLevels]; + } for (var i = 0; i < maxSkipLevels; i++) { if (freqIn != null) + { _freqIndex[i] = freqIn.GetIndex(); + } _docIndex[i] = docIn.GetIndex(); if (posIn != null) + { _posIndex[i] = posIn.GetIndex(); + } } _payloadPointer = new long[maxSkipLevels]; @@ -77,18 +83,23 @@ namespace Lucene.Net.Codecs.Sep _lastPosIndex = posIn != null ? posIn.GetIndex() : null; } - private IndexOptions _indexOptions; + private IndexOptions? _indexOptions; - internal virtual void SetIndexOptions(IndexOptions v) + internal virtual void SetIndexOptions(IndexOptions? v) { _indexOptions = v; } - internal virtual void Init(long skipPointer, Int32IndexInput.AbstractIndex docBaseIndex, Int32IndexInput.AbstractIndex freqBaseIndex, - Int32IndexInput.AbstractIndex posBaseIndex, long payloadBasePointer, int df, bool storesPayloads) + internal virtual void Init(long skipPointer, + Int32IndexInput.AbstractIndex docBaseIndex, + Int32IndexInput.AbstractIndex freqBaseIndex, + Int32IndexInput.AbstractIndex posBaseIndex, + long payloadBasePointer, + int df, + bool storesPayloads) { base.Init(skipPointer, df); - _currentFieldStoresPayloads = storesPayloads; + this._currentFieldStoresPayloads = storesPayloads; _lastPayloadPointer = payloadBasePointer; @@ -96,10 +107,13 @@ namespace Lucene.Net.Codecs.Sep { _docIndex[i].CopyFrom(docBaseIndex); if (_freqIndex != null) + { _freqIndex[i].CopyFrom(freqBaseIndex); - + } if (posBaseIndex != null) + { _posIndex[i].CopyFrom(posBaseIndex); + } } Arrays.Fill(_payloadPointer, payloadBasePointer); Arrays.Fill(_payloadLength, 0); @@ -133,24 +147,33 @@ namespace Lucene.Net.Codecs.Sep _lastPayloadPointer = _payloadPointer[level]; _lastPayloadLength = _payloadLength[level]; - + if (_freqIndex != null) + { _lastFreqIndex.CopyFrom(_freqIndex[level]); + } _lastDocIndex.CopyFrom(_docIndex[level]); if (_lastPosIndex != null) + { _lastPosIndex.CopyFrom(_posIndex[level]); + } - if (level <= 0) return; + if (level > 0) + { + if (_freqIndex != null) + { + _freqIndex[level - 1].CopyFrom(_freqIndex[level]); + } - if (_freqIndex != null) - _freqIndex[level - 1].CopyFrom(_freqIndex[level]); - - _docIndex[level - 1].CopyFrom(_docIndex[level]); - - if (_posIndex != null) - _posIndex[level - 1].CopyFrom(_posIndex[level]); + _docIndex[level - 1].CopyFrom(_docIndex[level]); + + if (_posIndex != null) + { + _posIndex[level - 1].CopyFrom(_posIndex[level]); + } + } } internal virtual Int32IndexInput.AbstractIndex FreqIndex @@ -193,16 +216,21 @@ namespace Lucene.Net.Codecs.Sep } if (_indexOptions != IndexOptions.DOCS_ONLY) + { _freqIndex[level].Read(skipStream, false); + } _docIndex[level].Read(skipStream, false); - if (_indexOptions != IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) return delta; + if (_indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) + { + _posIndex[level].Read(skipStream, false); + + if (_currentFieldStoresPayloads) + { + _payloadPointer[level] += skipStream.ReadVInt32(); + } + } - _posIndex[level].Read(skipStream, false); - - if (_currentFieldStoresPayloads) - _payloadPointer[level] += skipStream.ReadVInt32(); - return delta; } } http://git-wip-us.apache.org/repos/asf/lucenenet/blob/17ec8e0c/src/Lucene.Net.Codecs/Sep/SepSkipListWriter.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Codecs/Sep/SepSkipListWriter.cs b/src/Lucene.Net.Codecs/Sep/SepSkipListWriter.cs index e596347..a9eb542 100644 --- a/src/Lucene.Net.Codecs/Sep/SepSkipListWriter.cs +++ b/src/Lucene.Net.Codecs/Sep/SepSkipListWriter.cs @@ -51,14 +51,16 @@ namespace Lucene.Net.Codecs.Sep private int _curPayloadLength; private long _curPayloadPointer; - internal SepSkipListWriter(int skipInterval, int numberOfSkipLevels, int docCount, Int32IndexOutput freqOutput, - Int32IndexOutput docOutput, Int32IndexOutput posOutput, IndexOutput payloadOutput) + internal SepSkipListWriter(int skipInterval, int numberOfSkipLevels, int docCount, + Int32IndexOutput freqOutput, + Int32IndexOutput docOutput, + Int32IndexOutput posOutput, + IndexOutput payloadOutput) : base(skipInterval, numberOfSkipLevels, docCount) { - - _freqOutput = freqOutput; - _posOutput = posOutput; - _payloadOutput = payloadOutput; + this._freqOutput = freqOutput; + this._posOutput = posOutput; + this._payloadOutput = payloadOutput; _lastSkipDoc = new int[numberOfSkipLevels]; _lastSkipPayloadLength = new int[numberOfSkipLevels]; @@ -83,9 +85,9 @@ namespace Lucene.Net.Codecs.Sep } } - private IndexOptions _indexOptions; + private IndexOptions? _indexOptions; - internal virtual void SetIndexOptions(IndexOptions v) + internal virtual void SetIndexOptions(IndexOptions? v) { _indexOptions = v; } @@ -110,9 +112,9 @@ namespace Lucene.Net.Codecs.Sep /// </summary> internal virtual void SetSkipData(int doc, bool storePayloads, int payloadLength) { - _curDoc = doc; - _curStorePayloads = storePayloads; - _curPayloadLength = payloadLength; + this._curDoc = doc; + this._curStorePayloads = storePayloads; + this._curPayloadLength = payloadLength; if (_payloadOutput != null) { _curPayloadPointer = _payloadOutput.FilePointer;
