You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/01/29 13:27:24 UTC
[02/37] lucenenet git commit: Lucene.Net.Codecs: member accessibility
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsFormat.cs b/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsFormat.cs
index 9ab1706..8f64077 100644
--- a/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsFormat.cs
+++ b/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsFormat.cs
@@ -30,26 +30,21 @@ namespace Lucene.Net.Codecs.Pulsing
/// </summary>
public abstract class PulsingPostingsFormat : PostingsFormat
{
-
private readonly int _freqCutoff;
private readonly int _minBlockSize;
private readonly int _maxBlockSize;
private readonly PostingsBaseFormat _wrappedPostingsBaseFormat;
- public int FreqCutoff
- {
- get { return _freqCutoff; }
- }
-
- protected PulsingPostingsFormat(String name, PostingsBaseFormat wrappedPostingsBaseFormat, int freqCutoff) :
- this(name, wrappedPostingsBaseFormat, freqCutoff, BlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE,
+ public PulsingPostingsFormat(string name, PostingsBaseFormat wrappedPostingsBaseFormat, int freqCutoff)
+ : this(name, wrappedPostingsBaseFormat, freqCutoff, BlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE,
BlockTreeTermsWriter.DEFAULT_MAX_BLOCK_SIZE)
{
}
/// <summary>Terms with freq less than or equal freqCutoff are inlined into terms dict.</summary>
- protected PulsingPostingsFormat(String name, PostingsBaseFormat wrappedPostingsBaseFormat, int freqCutoff,
- int minBlockSize, int maxBlockSize) : base(name)
+ public PulsingPostingsFormat(string name, PostingsBaseFormat wrappedPostingsBaseFormat, int freqCutoff,
+ int minBlockSize, int maxBlockSize)
+ : base(name)
{
Debug.Assert(minBlockSize > 1);
@@ -59,7 +54,7 @@ namespace Lucene.Net.Codecs.Pulsing
_wrappedPostingsBaseFormat = wrappedPostingsBaseFormat;
}
- public override String ToString()
+ public override string ToString()
{
return string.Format("{0} (freqCutoff={1}, minBlockSize={2}, maxBlockSize={3})", Name, _freqCutoff, _minBlockSize, _maxBlockSize);
}
@@ -121,5 +116,10 @@ namespace Lucene.Net.Codecs.Pulsing
}
}
}
+
+ public virtual int FreqCutoff
+ {
+ get { return _freqCutoff; }
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsReader.cs b/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsReader.cs
index aaca6da..1e24672 100644
--- a/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsReader.cs
+++ b/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsReader.cs
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+using Lucene.Net.Support;
+
namespace Lucene.Net.Codecs.Pulsing
{
@@ -36,7 +38,6 @@ namespace Lucene.Net.Codecs.Pulsing
/// </summary>
public class PulsingPostingsReader : PostingsReaderBase
{
-
// Fallback reader for non-pulsed terms:
private readonly PostingsReaderBase _wrappedPostingsReader;
private readonly SegmentReadState _segmentState;
@@ -94,6 +95,66 @@ namespace Lucene.Net.Codecs.Pulsing
}
}
+ internal class PulsingTermState : BlockTermState
+ {
+ internal bool Absolute { get; set; }
+ [WritableArray]
+ internal long[] Longs { get; set; }
+ [WritableArray]
+ internal byte[] Postings { get; set; }
+ internal int PostingsSize { get; set; } // -1 if this term was not inlined
+ internal BlockTermState WrappedTermState { get; set; }
+
+ public override object Clone()
+ {
+ var clone = (PulsingTermState)base.Clone();
+ if (PostingsSize != -1)
+ {
+ clone.Postings = new byte[PostingsSize];
+ Array.Copy(Postings, 0, clone.Postings, 0, PostingsSize);
+ }
+ else
+ {
+ Debug.Assert(WrappedTermState != null);
+ clone.WrappedTermState = (BlockTermState)WrappedTermState.Clone();
+ clone.Absolute = Absolute;
+
+ if (Longs == null) return clone;
+
+ clone.Longs = new long[Longs.Length];
+ Array.Copy(Longs, 0, clone.Longs, 0, Longs.Length);
+ }
+ return clone;
+ }
+
+ public override void CopyFrom(TermState other)
+ {
+ base.CopyFrom(other);
+ var _other = (PulsingTermState)other;
+ PostingsSize = _other.PostingsSize;
+ if (_other.PostingsSize != -1)
+ {
+ if (Postings == null || Postings.Length < _other.PostingsSize)
+ {
+ Postings = new byte[ArrayUtil.Oversize(_other.PostingsSize, 1)];
+ }
+ Array.Copy(_other.Postings, 0, Postings, 0, _other.PostingsSize);
+ }
+ else
+ {
+ WrappedTermState.CopyFrom(_other.WrappedTermState);
+ }
+ }
+
+ public override string ToString()
+ {
+ if (PostingsSize == -1)
+ return "PulsingTermState: not inlined: wrapped=" + WrappedTermState;
+
+ return "PulsingTermState: inlined size=" + PostingsSize + " " + base.ToString();
+ }
+ }
+
public override BlockTermState NewTermState()
{
return new PulsingTermState {WrappedTermState = _wrappedPostingsReader.NewTermState()};
@@ -247,125 +308,7 @@ namespace Lucene.Net.Codecs.Pulsing
return wrapped;
}
- public override long RamBytesUsed()
- {
- return ((_wrappedPostingsReader != null) ? _wrappedPostingsReader.RamBytesUsed() : 0);
- }
-
- public override void CheckIntegrity()
- {
- _wrappedPostingsReader.CheckIntegrity();
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- _wrappedPostingsReader.Dispose();
- }
- }
-
- /// <summary>
- /// for a docsenum, gets the 'other' reused enum.
- /// Example: Pulsing(Standard).
- /// when doing a term range query you are switching back and forth
- /// between Pulsing and Standard
- ///
- /// The way the reuse works is that Pulsing.other = Standard and
- /// Standard.other = Pulsing.
- /// </summary>
- private DocsEnum GetOther(DocsEnum de)
- {
- if (de == null)
- return null;
-
- var atts = de.Attributes;
- DocsEnum result;
- atts.AddAttribute<IPulsingEnumAttribute>().Enums().TryGetValue(this, out result);
- return result;
- }
-
- /// <summary>
- /// for a docsenum, sets the 'other' reused enum.
- /// see GetOther for an example.
- /// </summary>
- private DocsEnum SetOther(DocsEnum de, DocsEnum other)
- {
- var atts = de.Attributes;
- return atts.AddAttribute<IPulsingEnumAttribute>().Enums()[this] = other;
- }
-
- ///<summary>
- /// A per-docsenum attribute that stores additional reuse information
- /// so that pulsing enums can keep a reference to their wrapped enums,
- /// and vice versa. this way we can always reuse.
- ///
- /// @lucene.internal
- /// </summary>
- public interface IPulsingEnumAttribute : IAttribute
- {
- Dictionary<PulsingPostingsReader, DocsEnum> Enums(); // LUCENENET TODO: Make property, change to IDictionary
- }
-
- internal class PulsingTermState : BlockTermState
- {
- public bool Absolute { get; set; }
- public long[] Longs { get; set; }
- public byte[] Postings { get; set; }
- public int PostingsSize { get; set; } // -1 if this term was not inlined
- public BlockTermState WrappedTermState { get; set; }
-
- public override object Clone()
- {
- var clone = (PulsingTermState) base.Clone();
- if (PostingsSize != -1)
- {
- clone.Postings = new byte[PostingsSize];
- Array.Copy(Postings, 0, clone.Postings, 0, PostingsSize);
- }
- else
- {
- Debug.Assert(WrappedTermState != null);
- clone.WrappedTermState = (BlockTermState) WrappedTermState.Clone();
- clone.Absolute = Absolute;
-
- if (Longs == null) return clone;
-
- clone.Longs = new long[Longs.Length];
- Array.Copy(Longs, 0, clone.Longs, 0, Longs.Length);
- }
- return clone;
- }
-
- public override void CopyFrom(TermState other)
- {
- base.CopyFrom(other);
- var _other = (PulsingTermState) other;
- PostingsSize = _other.PostingsSize;
- if (_other.PostingsSize != -1)
- {
- if (Postings == null || Postings.Length < _other.PostingsSize)
- {
- Postings = new byte[ArrayUtil.Oversize(_other.PostingsSize, 1)];
- }
- Array.Copy(_other.Postings, 0, Postings, 0, _other.PostingsSize);
- }
- else
- {
- WrappedTermState.CopyFrom(_other.WrappedTermState);
- }
- }
-
- public override String ToString()
- {
- if (PostingsSize == -1)
- return "PulsingTermState: not inlined: wrapped=" + WrappedTermState;
-
- return "PulsingTermState: inlined size=" + PostingsSize + " " + base.ToString();
- }
- }
-
- internal class PulsingDocsEnum : DocsEnum
+ private class PulsingDocsEnum : DocsEnum
{
private byte[] _postingsBytes;
private readonly ByteArrayDataInput _postings = new ByteArrayDataInput();
@@ -387,7 +330,7 @@ namespace Lucene.Net.Codecs.Pulsing
_storeOffsets = _indexOptions.Value.CompareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
}
- public PulsingDocsEnum Reset(IBits liveDocs, PulsingTermState termState)
+ public virtual PulsingDocsEnum Reset(IBits liveDocs, PulsingTermState termState)
{
Debug.Assert(termState.PostingsSize != -1);
@@ -412,23 +355,18 @@ namespace Lucene.Net.Codecs.Pulsing
return this;
}
- public bool CanReuse(FieldInfo fieldInfo)
+ internal bool CanReuse(FieldInfo fieldInfo)
{
return _indexOptions == fieldInfo.IndexOptions && _storePayloads == fieldInfo.HasPayloads;
}
- public override int DocID
- {
- get { return _docId; }
- }
-
public override int NextDoc()
{
while (true)
{
if (_postings.Eof)
return _docId = NO_MORE_DOCS;
-
+
var code = _postings.ReadVInt();
if (_indexOptions == IndexOptions.DOCS_ONLY)
{
@@ -483,6 +421,16 @@ namespace Lucene.Net.Codecs.Pulsing
}
}
+ public override int Freq
+ {
+ get { return _freq; }
+ }
+
+ public override int DocID
+ {
+ get { return _docId; }
+ }
+
public override int Advance(int target)
{
return _docId = SlowAdvance(target);
@@ -492,14 +440,9 @@ namespace Lucene.Net.Codecs.Pulsing
{
return _cost;
}
-
- public override int Freq
- {
- get { return _freq; }
- }
}
- internal class PulsingDocsAndPositionsEnum : DocsAndPositionsEnum
+ private class PulsingDocsAndPositionsEnum : DocsAndPositionsEnum
{
private byte[] _postingsBytes;
private readonly ByteArrayDataInput _postings = new ByteArrayDataInput();
@@ -531,7 +474,12 @@ namespace Lucene.Net.Codecs.Pulsing
_indexOptions.Value.CompareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
}
- public PulsingDocsAndPositionsEnum Reset(IBits liveDocs, PulsingTermState termState)
+ internal bool CanReuse(FieldInfo fieldInfo)
+ {
+ return _indexOptions == fieldInfo.IndexOptions && _storePayloads == fieldInfo.HasPayloads;
+ }
+
+ public virtual PulsingDocsAndPositionsEnum Reset(IBits liveDocs, PulsingTermState termState)
{
Debug.Assert(termState.PostingsSize != -1);
@@ -558,11 +506,6 @@ namespace Lucene.Net.Codecs.Pulsing
return this;
}
- public bool CanReuse(FieldInfo fieldInfo)
- {
- return _indexOptions == fieldInfo.IndexOptions && _storePayloads == fieldInfo.HasPayloads;
- }
-
public override int NextDoc()
{
while (true)
@@ -651,13 +594,26 @@ namespace Lucene.Net.Codecs.Pulsing
get { return _startOffset + _offsetLength; }
}
+ private void SkipPositions()
+ {
+ while (_posPending != 0)
+ {
+ NextPosition();
+ }
+ if (_storePayloads && !_payloadRetrieved)
+ {
+ _postings.SkipBytes(_payloadLength);
+ _payloadRetrieved = true;
+ }
+ }
+
public override BytesRef Payload
{
get
{
if (_payloadRetrieved)
return _payload;
-
+
if (_storePayloads && _payloadLength > 0)
{
_payloadRetrieved = true;
@@ -673,37 +629,74 @@ namespace Lucene.Net.Codecs.Pulsing
_payload.Length = _payloadLength;
return _payload;
}
-
+
return null;
}
}
- private void SkipPositions()
- {
- while (_posPending != 0)
- {
- NextPosition();
- }
- if (_storePayloads && !_payloadRetrieved)
- {
- _postings.SkipBytes(_payloadLength);
- _payloadRetrieved = true;
- }
- }
-
public override long GetCost()
{
return _cost;
}
}
-
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ _wrappedPostingsReader.Dispose();
+ }
+ }
+
+ /// <summary>
+ /// for a docsenum, gets the 'other' reused enum.
+ /// Example: Pulsing(Standard).
+ /// when doing a term range query you are switching back and forth
+ /// between Pulsing and Standard
+ ///
+ /// The way the reuse works is that Pulsing.other = Standard and
+ /// Standard.other = Pulsing.
+ /// </summary>
+ private DocsEnum GetOther(DocsEnum de)
+ {
+ if (de == null)
+ return null;
+
+ var atts = de.Attributes;
+ DocsEnum result;
+ atts.AddAttribute<IPulsingEnumAttribute>().Enums().TryGetValue(this, out result);
+ return result;
+ }
+
+ /// <summary>
+ /// for a docsenum, sets the 'other' reused enum.
+ /// see GetOther for an example.
+ /// </summary>
+ private DocsEnum SetOther(DocsEnum de, DocsEnum other)
+ {
+ var atts = de.Attributes;
+ return atts.AddAttribute<IPulsingEnumAttribute>().Enums()[this] = other;
+ }
+
+ ///<summary>
+ /// A per-docsenum attribute that stores additional reuse information
+ /// so that pulsing enums can keep a reference to their wrapped enums,
+ /// and vice versa. this way we can always reuse.
+ ///
+ /// @lucene.internal
+ /// </summary>
+ public interface IPulsingEnumAttribute : IAttribute
+ {
+ Dictionary<PulsingPostingsReader, DocsEnum> Enums(); // LUCENENET TODO: Make property, change to IDictionary
+ }
+
/// <summary>
/// Implementation of {@link PulsingEnumAttribute} for reuse of
/// wrapped postings readers underneath pulsing.
///
/// @lucene.internal
/// </summary>
- internal sealed class PulsingEnumAttribute : Util.Attribute, IPulsingEnumAttribute
+ public sealed class PulsingEnumAttribute : Util.Attribute, IPulsingEnumAttribute
{
// we could store 'other', but what if someone 'chained' multiple postings readers,
// this could cause problems?
@@ -730,5 +723,15 @@ namespace Lucene.Net.Codecs.Pulsing
// we don't want to copy any stuff over to another docsenum ever!
}
}
+
+ public override long RamBytesUsed()
+ {
+ return ((_wrappedPostingsReader != null) ? _wrappedPostingsReader.RamBytesUsed() : 0);
+ }
+
+ public override void CheckIntegrity()
+ {
+ _wrappedPostingsReader.CheckIntegrity();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsWriter.cs b/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsWriter.cs
index 298eebd..f93b2b0 100644
--- a/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsWriter.cs
+++ b/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsWriter.cs
@@ -42,9 +42,8 @@ namespace Lucene.Net.Codecs.Pulsing
/// </summary>
public sealed class PulsingPostingsWriter : PostingsWriterBase
{
-
- internal static readonly String CODEC = "PulsedPostingsWriter";
- internal static readonly String SUMMARY_EXTENSION = "smy"; // recording field summary
+ internal static readonly string CODEC = "PulsedPostingsWriter";
+ internal static readonly string SUMMARY_EXTENSION = "smy"; // recording field summary
// To add a new version, increment from the last one, and
// change VERSION_CURRENT to point to your new version:
@@ -65,10 +64,10 @@ namespace Lucene.Net.Codecs.Pulsing
private class PulsingTermState : BlockTermState
{
- internal byte[] BYTES;
- internal BlockTermState WRAPPED_STATE;
+ internal byte[] BYTES; // LUCENENET TODO: Rename bytes
+ internal BlockTermState WRAPPED_STATE; // LUCENENET TODO: Rename wrappedState
- public override String ToString()
+ public override string ToString()
{
if (BYTES != null)
{
@@ -95,8 +94,8 @@ namespace Lucene.Net.Codecs.Pulsing
private class FieldMetaData
{
- public int FieldNumber { get; private set; }
- public int LongsSize { get; private set; }
+ internal int FieldNumber { get; private set; }
+ internal int LongsSize { get; private set; }
public FieldMetaData(int number, int size)
{
@@ -118,7 +117,6 @@ namespace Lucene.Net.Codecs.Pulsing
/// </summary>
public PulsingPostingsWriter(SegmentWriteState state, int maxPositions, PostingsWriterBase wrappedPostingsWriter)
{
-
_pending = new Position[maxPositions];
for (var i = 0; i < maxPositions; i++)
{
@@ -170,6 +168,8 @@ namespace Lucene.Net.Codecs.Pulsing
return 0;
}
+ private bool DEBUG;
+
public override void StartDoc(int docId, int termDocFreq)
{
Debug.Assert(docId >= 0, "Got DocID=" + docId);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/src/Lucene.Net.Codecs/RectangularArrays.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/RectangularArrays.cs b/src/Lucene.Net.Codecs/RectangularArrays.cs
index 9b41c8a..476fc1b 100644
--- a/src/Lucene.Net.Codecs/RectangularArrays.cs
+++ b/src/Lucene.Net.Codecs/RectangularArrays.cs
@@ -5,7 +5,7 @@
// This class provides the logic to simulate Java rectangular arrays, which are jagged
// arrays with inner arrays of the same length. A size of -1 indicates unknown length.
//----------------------------------------------------------------------------------------
-internal static partial class RectangularArrays
+internal static partial class RectangularArrays // LUCENENET TODO: Move to Support ?
{
internal static long[][] ReturnRectangularLongArray(int Size1, int Size2)
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/src/Lucene.Net.Codecs/Sep/IntIndexInput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Sep/IntIndexInput.cs b/src/Lucene.Net.Codecs/Sep/IntIndexInput.cs
index d08b7d4..6c46a3c 100644
--- a/src/Lucene.Net.Codecs/Sep/IntIndexInput.cs
+++ b/src/Lucene.Net.Codecs/Sep/IntIndexInput.cs
@@ -29,15 +29,15 @@ namespace Lucene.Net.Codecs.Sep
/// </summary>
public abstract class IntIndexInput : IDisposable
{
- public abstract IntIndexInputReader Reader();
+ public abstract IntIndexInputReader Reader(); // LUCENENET TODO: Rename GetReader()
public abstract void Dispose();
- public abstract IntIndexInputIndex Index();
+ public abstract IntIndexInputIndex Index(); // LUCENENET TODO: Rename GetIndex()
}
/// <summary>Reads int values</summary>
- public abstract class IntIndexInputReader
+ public abstract class IntIndexInputReader // LUCENENET TODO: Rename AbstractReader and nest within IntIndexInput
{
/// <summary>Reads next single int</summary>
public abstract int Next();
@@ -45,7 +45,7 @@ namespace Lucene.Net.Codecs.Sep
/// <summary>
/// Records a single skip-point in the <seealso cref="IntIndexInput.Reader"/>. </summary>
- public abstract class IntIndexInputIndex
+ public abstract class IntIndexInputIndex // LUCENENET TODO: Rename AbstractIndex and nest within IntIndexInput
{
public abstract void Read(DataInput indexIn, bool absolute);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/src/Lucene.Net.Codecs/Sep/IntIndexOutput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Sep/IntIndexOutput.cs b/src/Lucene.Net.Codecs/Sep/IntIndexOutput.cs
index e7c51e9..aca46c2 100644
--- a/src/Lucene.Net.Codecs/Sep/IntIndexOutput.cs
+++ b/src/Lucene.Net.Codecs/Sep/IntIndexOutput.cs
@@ -34,9 +34,6 @@ namespace Lucene.Net.Codecs.Sep
/// </remarks>
public abstract class IntIndexOutput : IDisposable
{
- protected internal IndexOutput OUTPUT;
- protected internal int _upto;
-
/// <summary>
/// Write an int to the primary file. The value must be
/// >= 0.
@@ -47,14 +44,14 @@ namespace Lucene.Net.Codecs.Sep
/// If you are indexing the primary output file, call
/// this and interact with the returned IndexWriter.
/// </summary>
- public abstract IntIndexOutputIndex Index();
+ public abstract IntIndexOutputIndex Index(); // LUCENENET TODO: Rename GetIndex()
- public abstract void Dispose();
+ public abstract void Dispose(); // LUCENENET TODO: Implement disposable pattern
}
/// <summary>Records a single skip-point in the IndexOutput. </summary>
- public abstract class IntIndexOutputIndex
+ public abstract class IntIndexOutputIndex // LUCENENET TODO: Rename AbstractIndex and nest within IntIndexOutput
{
/// <summary>Internally records the current location </summary>
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/src/Lucene.Net.Codecs/Sep/IntStreamFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Sep/IntStreamFactory.cs b/src/Lucene.Net.Codecs/Sep/IntStreamFactory.cs
index a718d27..1f84e48 100644
--- a/src/Lucene.Net.Codecs/Sep/IntStreamFactory.cs
+++ b/src/Lucene.Net.Codecs/Sep/IntStreamFactory.cs
@@ -27,7 +27,6 @@ namespace Lucene.Net.Codecs.Sep
/// </summary>
public abstract class IntStreamFactory
{
-
/// <summary>
/// Create an <seealso cref="IntIndexInput"/> on the provided fileName.
/// </summary>
@@ -38,5 +37,4 @@ namespace Lucene.Net.Codecs.Sep
/// </summary>
public abstract IntIndexOutput CreateOutput(Directory dir, string fileName, IOContext context);
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/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 797ce4c..60cbd18 100644
--- a/src/Lucene.Net.Codecs/Sep/SepPostingsReader.cs
+++ b/src/Lucene.Net.Codecs/Sep/SepPostingsReader.cs
@@ -115,6 +115,78 @@ namespace Lucene.Net.Codecs.Sep
IOUtils.Close(_freqIn, _docIn, _skipIn, _posIn, _payloadIn);
}
+ internal sealed class SepTermState : BlockTermState
+ {
+ // 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 IntIndexInputIndex DOC_INDEX;
+ internal IntIndexInputIndex POS_INDEX;
+ internal IntIndexInputIndex FREQ_INDEX;
+ internal long PAYLOAD_FP;
+ internal long SKIP_FP;
+
+ public override object Clone()
+ {
+ var other = new SepTermState();
+ other.CopyFrom(this);
+ return other;
+ }
+
+ public override void CopyFrom(TermState tsOther)
+ {
+ base.CopyFrom(tsOther);
+
+ var other = (SepTermState)tsOther;
+ if (DOC_INDEX == null)
+ {
+ DOC_INDEX = other.DOC_INDEX.Clone();
+ }
+ else
+ {
+ DOC_INDEX.CopyFrom(other.DOC_INDEX);
+ }
+ if (other.FREQ_INDEX != null)
+ {
+ if (FREQ_INDEX == null)
+ {
+ FREQ_INDEX = other.FREQ_INDEX.Clone();
+ }
+ else
+ {
+ FREQ_INDEX.CopyFrom(other.FREQ_INDEX);
+ }
+ }
+ else
+ {
+ FREQ_INDEX = null;
+ }
+ if (other.POS_INDEX != null)
+ {
+ if (POS_INDEX == null)
+ {
+ POS_INDEX = other.POS_INDEX.Clone();
+ }
+ else
+ {
+ POS_INDEX.CopyFrom(other.POS_INDEX);
+ }
+ }
+ else
+ {
+ POS_INDEX = null;
+ }
+ PAYLOAD_FP = other.PAYLOAD_FP;
+ SKIP_FP = other.SKIP_FP;
+ }
+
+ public override string ToString()
+ {
+ return base.ToString() + " docIndex=" + DOC_INDEX + " freqIndex=" + FREQ_INDEX + " posIndex=" + POS_INDEX +
+ " payloadFP=" + PAYLOAD_FP + " skipFP=" + SKIP_FP;
+ }
+ }
+
public override BlockTermState NewTermState()
{
var state = new SepTermState {DOC_INDEX = _docIn.Index()};
@@ -222,89 +294,6 @@ namespace Lucene.Net.Codecs.Sep
return postingsEnum.Init(fieldInfo, termState, liveDocs);
}
- public override long RamBytesUsed()
- {
- return 0;
- }
-
- public override void CheckIntegrity()
- {
- // TODO: remove sep layout, its fallen behind on features...
- }
-
- internal sealed class SepTermState : BlockTermState
- {
- // 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 IntIndexInputIndex DOC_INDEX;
- internal IntIndexInputIndex POS_INDEX;
- internal IntIndexInputIndex FREQ_INDEX;
- internal long PAYLOAD_FP;
- internal long SKIP_FP;
-
- public override object Clone()
- {
- var other = new SepTermState();
- other.CopyFrom(this);
- return other;
- }
-
- public override void CopyFrom(TermState tsOther)
- {
- base.CopyFrom(tsOther);
-
- var other = (SepTermState)tsOther;
- if (DOC_INDEX == null)
- {
- DOC_INDEX = other.DOC_INDEX.Clone();
- }
- else
- {
- DOC_INDEX.CopyFrom(other.DOC_INDEX);
- }
- if (other.FREQ_INDEX != null)
- {
- if (FREQ_INDEX == null)
- {
- FREQ_INDEX = other.FREQ_INDEX.Clone();
- }
- else
- {
- FREQ_INDEX.CopyFrom(other.FREQ_INDEX);
- }
- }
- else
- {
- FREQ_INDEX = null;
- }
- if (other.POS_INDEX != null)
- {
- if (POS_INDEX == null)
- {
- POS_INDEX = other.POS_INDEX.Clone();
- }
- else
- {
- POS_INDEX.CopyFrom(other.POS_INDEX);
- }
- }
- else
- {
- POS_INDEX = null;
- }
- PAYLOAD_FP = other.PAYLOAD_FP;
- SKIP_FP = other.SKIP_FP;
- }
-
- public override string ToString()
- {
- return base.ToString() + " docIndex=" + DOC_INDEX + " freqIndex=" + FREQ_INDEX + " posIndex=" + POS_INDEX +
- " payloadFP=" + PAYLOAD_FP + " skipFP=" + SKIP_FP;
- }
- }
-
-
internal class SepDocsEnum : DocsEnum
{
private readonly SepPostingsReader _outerInstance;
@@ -327,14 +316,13 @@ namespace Lucene.Net.Codecs.Sep
private readonly IntIndexInputIndex _docIndex;
private readonly IntIndexInputIndex _freqIndex;
private readonly IntIndexInputIndex _posIndex;
+ internal IntIndexInput START_DOC_IN; // LUCENENET TODO: Rename startDocIn
// TODO: -- should we do hasProx with 2 different enum classes?
private bool _skipped;
private SepSkipListReader _skipper;
- internal IntIndexInput START_DOC_IN;
-
internal SepDocsEnum(SepPostingsReader outerInstance)
{
_outerInstance = outerInstance;
@@ -389,7 +377,6 @@ namespace Lucene.Net.Codecs.Sep
public override int NextDoc()
{
-
while (true)
{
if (_count == _docFreq)
@@ -429,17 +416,15 @@ namespace Lucene.Net.Codecs.Sep
public override int Advance(int target)
{
-
if ((target - _outerInstance._skipInterval) >= _doc && _docFreq >= _outerInstance._skipMinimum)
{
-
// There are enough docs in the posting to have
// skip data, and its not too close
if (_skipper == null)
{
// This DocsEnum has never done any skipping
- _skipper = new SepSkipListReader((IndexInput) _outerInstance._skipIn.Clone(),
+ _skipper = new SepSkipListReader((IndexInput)_outerInstance._skipIn.Clone(),
_outerInstance._freqIn,
_outerInstance._docIn, _outerInstance._posIn, _outerInstance._maxSkipLevels,
_outerInstance._skipInterval);
@@ -492,7 +477,6 @@ namespace Lucene.Net.Codecs.Sep
internal class SepDocsAndPositionsEnum : DocsAndPositionsEnum
{
private readonly SepPostingsReader _outerInstance;
- private BytesRef _payload;
private int _docFreq;
private int _doc = -1;
@@ -511,6 +495,7 @@ namespace Lucene.Net.Codecs.Sep
private readonly IntIndexInputIndex _docIndex;
private readonly IntIndexInputIndex _freqIndex;
private readonly IntIndexInputIndex _posIndex;
+ internal IntIndexInput START_DOC_IN; // LUCENENET TODO: Rename startDocIn
private long _payloadFp;
@@ -524,8 +509,6 @@ namespace Lucene.Net.Codecs.Sep
private bool _payloadPending;
private bool _posSeekPending;
- internal IntIndexInput START_DOC_IN;
-
internal SepDocsAndPositionsEnum(SepPostingsReader outerInstance)
{
_outerInstance = outerInstance;
@@ -730,6 +713,8 @@ namespace Lucene.Net.Codecs.Sep
get { return -1; }
}
+ private BytesRef _payload;
+
public override BytesRef Payload
{
get
@@ -772,5 +757,15 @@ namespace Lucene.Net.Codecs.Sep
return _docFreq;
}
}
+
+ public override long RamBytesUsed()
+ {
+ return 0;
+ }
+
+ public override void CheckIntegrity()
+ {
+ // TODO: remove sep layout, its fallen behind on features...
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/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 b34c584..17f3eed 100644
--- a/src/Lucene.Net.Codecs/Sep/SepPostingsWriter.cs
+++ b/src/Lucene.Net.Codecs/Sep/SepPostingsWriter.cs
@@ -42,20 +42,20 @@ namespace Lucene.Net.Codecs.Sep
internal const int VERSION_START = 0;
internal const int VERSION_CURRENT = VERSION_START;
- internal IntIndexOutput FREQ_OUT;
- internal IntIndexOutputIndex FREQ_INDEX;
+ internal IntIndexOutput FREQ_OUT; // LUCENENET TODO: Rename freqOut
+ internal IntIndexOutputIndex FREQ_INDEX; // LUCENENET TODO: Rename camelCase
- internal IntIndexOutput POS_OUT;
- internal IntIndexOutputIndex POS_INDEX;
+ internal IntIndexOutput POS_OUT; // LUCENENET TODO: Rename camelCase
+ internal IntIndexOutputIndex POS_INDEX; // LUCENENET TODO: Rename camelCase
- internal IntIndexOutput DOC_OUT;
- internal IntIndexOutputIndex DOC_INDEX;
+ internal IntIndexOutput DOC_OUT; // LUCENENET TODO: Rename camelCase
+ internal IntIndexOutputIndex DOC_INDEX; // LUCENENET TODO: Rename camelCase
- internal IndexOutput PAYLOAD_OUT;
+ internal IndexOutput PAYLOAD_OUT; // LUCENENET TODO: Rename camelCase
- internal IndexOutput SKIP_OUT;
+ internal IndexOutput SKIP_OUT; // LUCENENET TODO: Rename camelCase
- internal readonly SepSkipListWriter SKIP_LIST_WRITER;
+ internal readonly SepSkipListWriter SKIP_LIST_WRITER; // LUCENENET TODO: Rename camelCase
/// <summary>
/// Expert: The fraction of TermDocs entries stored in skip tables,
@@ -64,37 +64,37 @@ namespace Lucene.Net.Codecs.Sep
/// smaller values result in bigger indexes, less acceleration and more
/// accelerable cases. More detailed experiments would be useful here.
/// </summary>
- internal readonly int SKIP_INTERVAL;
+ internal readonly int SKIP_INTERVAL; // LUCENENET TODO: Rename camelCase
internal const int DEFAULT_SKIP_INTERVAL = 16;
/// <summary>
/// Expert: minimum docFreq to write any skip data at all
/// </summary>
- internal readonly int SKIP_MINIMUM;
+ internal readonly int SKIP_MINIMUM; // LUCENENET TODO: Rename camelCase
/// <summary>
/// Expert: The maximum number of skip levels. Smaller values result in
/// slightly smaller indexes, but slower skipping in big posting lists.
/// </summary>
- internal readonly int MAX_SKIP_LEVELS = 10;
+ internal readonly int MAX_SKIP_LEVELS = 10; // LUCENENET TODO: Rename camelCase
- internal readonly int TOTAL_NUM_DOCS;
+ internal readonly int TOTAL_NUM_DOCS; // LUCENENET TODO: Rename camelCase
- internal bool STORE_PAYLOADS;
- internal IndexOptions INDEX_OPTIONS;
+ internal bool STORE_PAYLOADS; // LUCENENET TODO: Rename camelCase
+ internal IndexOptions INDEX_OPTIONS; // LUCENENET TODO: Rename camelCase
- internal FieldInfo FIELD_INFO;
+ internal FieldInfo FIELD_INFO; // LUCENENET TODO: Rename
- internal int LAST_PAYLOAD_LENGTH;
- internal int LAST_POSITION;
- internal long PAYLOAD_START;
- internal int LAST_DOC_ID;
- internal int DF;
+ internal int LAST_PAYLOAD_LENGTH; // LUCENENET TODO: Rename camelCase
+ internal int LAST_POSITION; // LUCENENET TODO: Rename camelCase
+ internal long PAYLOAD_START; // LUCENENET TODO: Rename camelCase
+ internal int LAST_DOC_ID; // LUCENENET TODO: Rename camelCase
+ internal int DF; // LUCENENET TODO: Rename camelCase
private SepTermState _lastState;
- internal long LAST_PAYLOAD_FP;
- internal long LAST_SKIP_FP;
+ internal long LAST_PAYLOAD_FP; // LUCENENET TODO: Rename camelCase
+ internal long LAST_SKIP_FP; // LUCENENET TODO: Rename camelCase
public SepPostingsWriter(SegmentWriteState state, IntStreamFactory factory)
: this(state, factory, DEFAULT_SKIP_INTERVAL)
@@ -407,5 +407,4 @@ namespace Lucene.Net.Codecs.Sep
IOUtils.Close(DOC_OUT, SKIP_OUT, FREQ_OUT, POS_OUT, PAYLOAD_OUT);
}
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/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 9c5642f..1491df4 100644
--- a/src/Lucene.Net.Codecs/Sep/SepSkipListReader.cs
+++ b/src/Lucene.Net.Codecs/Sep/SepSkipListReader.cs
@@ -88,7 +88,6 @@ namespace Lucene.Net.Codecs.Sep
internal virtual void Init(long skipPointer, IntIndexInputIndex docBaseIndex, IntIndexInputIndex freqBaseIndex,
IntIndexInputIndex posBaseIndex, long payloadBasePointer, int df, bool storesPayloads)
{
-
base.Init(skipPointer, df);
_currentFieldStoresPayloads = storesPayloads;
@@ -208,5 +207,4 @@ namespace Lucene.Net.Codecs.Sep
return delta;
}
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/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 639af28..13f9529 100644
--- a/src/Lucene.Net.Codecs/Sep/SepSkipListWriter.cs
+++ b/src/Lucene.Net.Codecs/Sep/SepSkipListWriter.cs
@@ -22,202 +22,202 @@ namespace Lucene.Net.Codecs.Sep
using Store;
using Support;
- /// <summary>
- /// Implements the skip list writer for the default posting list format
- /// that stores positions and payloads.
- ///
- /// @lucene.experimental
- /// </summary>
- /// <remarks>
+ /// <summary>
+ /// Implements the skip list writer for the default posting list format
+ /// that stores positions and payloads.
+ ///
+ /// @lucene.experimental
+ /// </summary>
+ /// <remarks>
/// TODO: -- skip data should somehow be more local to the particular stream
/// (doc, freq, pos, payload)
- /// </remarks>
- internal class SepSkipListWriter : MultiLevelSkipListWriter
- {
- private readonly int[] _lastSkipDoc;
- private readonly int[] _lastSkipPayloadLength;
- private readonly long[] _lastSkipPayloadPointer;
- private IndexOptions _indexOptions;
-
- private readonly IntIndexOutputIndex[] _docIndex;
- private readonly IntIndexOutputIndex[] _freqIndex;
- private readonly IntIndexOutputIndex[] _posIndex;
-
- private readonly IntIndexOutput _freqOutput;
- private IntIndexOutput _posOutput;
- private IndexOutput _payloadOutput;
-
- private int _curDoc;
- private bool _curStorePayloads;
- private int _curPayloadLength;
- private long _curPayloadPointer;
-
- internal SepSkipListWriter(int skipInterval, int numberOfSkipLevels, int docCount, IntIndexOutput freqOutput,
- IntIndexOutput docOutput, IntIndexOutput posOutput, IndexOutput payloadOutput)
- : base(skipInterval, numberOfSkipLevels, docCount)
- {
-
- _freqOutput = freqOutput;
- _posOutput = posOutput;
- _payloadOutput = payloadOutput;
-
- _lastSkipDoc = new int[numberOfSkipLevels];
- _lastSkipPayloadLength = new int[numberOfSkipLevels];
- // TODO: -- also cutover normal IndexOutput to use getIndex()?
- _lastSkipPayloadPointer = new long[numberOfSkipLevels];
-
- _freqIndex = new IntIndexOutputIndex[numberOfSkipLevels];
- _docIndex = new IntIndexOutputIndex[numberOfSkipLevels];
- _posIndex = new IntIndexOutputIndex[numberOfSkipLevels];
-
- for (var i = 0; i < numberOfSkipLevels; i++)
- {
- if (freqOutput != null)
- {
- _freqIndex[i] = freqOutput.Index();
- }
- _docIndex[i] = docOutput.Index();
- if (posOutput != null)
- {
- _posIndex[i] = posOutput.Index();
- }
- }
- }
-
- internal virtual IndexOptions IndexOptions
- {
- set { _indexOptions = value; }
- }
-
- internal virtual IntIndexOutput PosOutput
- {
- set
- {
- _posOutput = value;
+ /// </remarks>
+ internal class SepSkipListWriter : MultiLevelSkipListWriter
+ {
+ private readonly int[] _lastSkipDoc;
+ private readonly int[] _lastSkipPayloadLength;
+ private readonly long[] _lastSkipPayloadPointer;
+
+ private readonly IntIndexOutputIndex[] _docIndex;
+ private readonly IntIndexOutputIndex[] _freqIndex;
+ private readonly IntIndexOutputIndex[] _posIndex;
+
+ private readonly IntIndexOutput _freqOutput;
+ private IntIndexOutput _posOutput;
+ private IndexOutput _payloadOutput;
+
+ private int _curDoc;
+ private bool _curStorePayloads;
+ private int _curPayloadLength;
+ private long _curPayloadPointer;
+
+ internal SepSkipListWriter(int skipInterval, int numberOfSkipLevels, int docCount, IntIndexOutput freqOutput,
+ IntIndexOutput docOutput, IntIndexOutput posOutput, IndexOutput payloadOutput)
+ : base(skipInterval, numberOfSkipLevels, docCount)
+ {
+
+ _freqOutput = freqOutput;
+ _posOutput = posOutput;
+ _payloadOutput = payloadOutput;
+
+ _lastSkipDoc = new int[numberOfSkipLevels];
+ _lastSkipPayloadLength = new int[numberOfSkipLevels];
+ // TODO: -- also cutover normal IndexOutput to use getIndex()?
+ _lastSkipPayloadPointer = new long[numberOfSkipLevels];
+
+ _freqIndex = new IntIndexOutputIndex[numberOfSkipLevels];
+ _docIndex = new IntIndexOutputIndex[numberOfSkipLevels];
+ _posIndex = new IntIndexOutputIndex[numberOfSkipLevels];
+
+ for (var i = 0; i < numberOfSkipLevels; i++)
+ {
+ if (freqOutput != null)
+ {
+ _freqIndex[i] = freqOutput.Index();
+ }
+ _docIndex[i] = docOutput.Index();
+ if (posOutput != null)
+ {
+ _posIndex[i] = posOutput.Index();
+ }
+ }
+ }
+
+ private IndexOptions _indexOptions;
+
+ internal virtual IndexOptions IndexOptions // LUCENENET TODO: Make SetIndexOptions(IndexOptions v)
+ {
+ set { _indexOptions = value; }
+ }
+
+ internal virtual IntIndexOutput PosOutput // LUCENENET TODO: Make SetPosOutput(IntIndexOutput posOutput)
+ {
+ set
+ {
+ _posOutput = value;
for (var i = 0; i < m_numberOfSkipLevels; i++)
- {
- _posIndex[i] = value.Index();
- }
- }
- }
-
- internal virtual IndexOutput PayloadOutput
- {
- set { _payloadOutput = value; }
- }
-
- /// <summary>
- /// Sets the values for the current skip data.
+ {
+ _posIndex[i] = value.Index();
+ }
+ }
+ }
+
+ internal virtual IndexOutput PayloadOutput // LUCENENET TODO: Make SetPayloadOutput(IndexOutput payloadOutput)
+ {
+ set { _payloadOutput = value; }
+ }
+
+ /// <summary>
+ /// Sets the values for the current skip data.
/// Called @ every index interval (every 128th (by default) doc)
- /// </summary>
- internal virtual void SetSkipData(int doc, bool storePayloads, int payloadLength)
- {
- _curDoc = doc;
- _curStorePayloads = storePayloads;
- _curPayloadLength = payloadLength;
- if (_payloadOutput != null)
- {
- _curPayloadPointer = _payloadOutput.FilePointer;
- }
- }
-
- /// <summary>
- /// Called @ start of new term
- /// </summary>
+ /// </summary>
+ internal virtual void SetSkipData(int doc, bool storePayloads, int payloadLength)
+ {
+ _curDoc = doc;
+ _curStorePayloads = storePayloads;
+ _curPayloadLength = payloadLength;
+ if (_payloadOutput != null)
+ {
+ _curPayloadPointer = _payloadOutput.FilePointer;
+ }
+ }
+
+ /// <summary>
+ /// Called @ start of new term
+ /// </summary>
protected internal virtual void ResetSkip(IntIndexOutputIndex topDocIndex, IntIndexOutputIndex topFreqIndex,
- IntIndexOutputIndex topPosIndex)
- {
- base.ResetSkip();
-
- Arrays.Fill(_lastSkipDoc, 0);
- Arrays.Fill(_lastSkipPayloadLength, -1); // we don't have to write the first length in the skip list
- for (int i = 0; i < m_numberOfSkipLevels; i++)
- {
- _docIndex[i].CopyFrom(topDocIndex, true);
- if (_freqOutput != null)
- {
- _freqIndex[i].CopyFrom(topFreqIndex, true);
- }
- if (_posOutput != null)
- {
- _posIndex[i].CopyFrom(topPosIndex, true);
- }
- }
- if (_payloadOutput != null)
- {
- Arrays.Fill(_lastSkipPayloadPointer, _payloadOutput.FilePointer);
- }
- }
-
- protected override void WriteSkipData(int level, IndexOutput skipBuffer)
- {
- // To efficiently store payloads in the posting lists we do not store the length of
- // every payload. Instead we omit the length for a payload if the previous payload had
- // the same length.
- // However, in order to support skipping the payload length at every skip point must be known.
- // So we use the same length encoding that we use for the posting lists for the skip data as well:
- // Case 1: current field does not store payloads
- // SkipDatum --> DocSkip, FreqSkip, ProxSkip
- // DocSkip,FreqSkip,ProxSkip --> VInt
- // DocSkip records the document number before every SkipInterval th document in TermFreqs.
- // Document numbers are represented as differences from the previous value in the sequence.
- // Case 2: current field stores payloads
- // SkipDatum --> DocSkip, PayloadLength?, FreqSkip,ProxSkip
- // DocSkip,FreqSkip,ProxSkip --> VInt
- // PayloadLength --> VInt
- // In this case DocSkip/2 is the difference between
- // the current and the previous value. If DocSkip
- // is odd, then a PayloadLength encoded as VInt follows,
- // if DocSkip is even, then it is assumed that the
- // current payload length equals the length at the previous
- // skip point
+ IntIndexOutputIndex topPosIndex)
+ {
+ base.ResetSkip();
+
+ Arrays.Fill(_lastSkipDoc, 0);
+ Arrays.Fill(_lastSkipPayloadLength, -1); // we don't have to write the first length in the skip list
+ for (int i = 0; i < m_numberOfSkipLevels; i++)
+ {
+ _docIndex[i].CopyFrom(topDocIndex, true);
+ if (_freqOutput != null)
+ {
+ _freqIndex[i].CopyFrom(topFreqIndex, true);
+ }
+ if (_posOutput != null)
+ {
+ _posIndex[i].CopyFrom(topPosIndex, true);
+ }
+ }
+ if (_payloadOutput != null)
+ {
+ Arrays.Fill(_lastSkipPayloadPointer, _payloadOutput.FilePointer);
+ }
+ }
+
+ protected override void WriteSkipData(int level, IndexOutput skipBuffer)
+ {
+ // To efficiently store payloads in the posting lists we do not store the length of
+ // every payload. Instead we omit the length for a payload if the previous payload had
+ // the same length.
+ // However, in order to support skipping the payload length at every skip point must be known.
+ // So we use the same length encoding that we use for the posting lists for the skip data as well:
+ // Case 1: current field does not store payloads
+ // SkipDatum --> DocSkip, FreqSkip, ProxSkip
+ // DocSkip,FreqSkip,ProxSkip --> VInt
+ // DocSkip records the document number before every SkipInterval th document in TermFreqs.
+ // Document numbers are represented as differences from the previous value in the sequence.
+ // Case 2: current field stores payloads
+ // SkipDatum --> DocSkip, PayloadLength?, FreqSkip,ProxSkip
+ // DocSkip,FreqSkip,ProxSkip --> VInt
+ // PayloadLength --> VInt
+ // In this case DocSkip/2 is the difference between
+ // the current and the previous value. If DocSkip
+ // is odd, then a PayloadLength encoded as VInt follows,
+ // if DocSkip is even, then it is assumed that the
+ // current payload length equals the length at the previous
+ // skip point
Debug.Assert(_indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS || !_curStorePayloads);
- if (_curStorePayloads)
- {
- int delta = _curDoc - _lastSkipDoc[level];
- if (_curPayloadLength == _lastSkipPayloadLength[level])
- {
- // the current payload length equals the length at the previous skip point,
- // so we don't store the length again
- skipBuffer.WriteVInt(delta << 1);
- }
- else
- {
- // the payload length is different from the previous one. We shift the DocSkip,
- // set the lowest bit and store the current payload length as VInt.
- skipBuffer.WriteVInt(delta << 1 | 1);
- skipBuffer.WriteVInt(_curPayloadLength);
- _lastSkipPayloadLength[level] = _curPayloadLength;
- }
- }
- else
- {
- // current field does not store payloads
- skipBuffer.WriteVInt(_curDoc - _lastSkipDoc[level]);
- }
+ if (_curStorePayloads)
+ {
+ int delta = _curDoc - _lastSkipDoc[level];
+ if (_curPayloadLength == _lastSkipPayloadLength[level])
+ {
+ // the current payload length equals the length at the previous skip point,
+ // so we don't store the length again
+ skipBuffer.WriteVInt(delta << 1);
+ }
+ else
+ {
+ // the payload length is different from the previous one. We shift the DocSkip,
+ // set the lowest bit and store the current payload length as VInt.
+ skipBuffer.WriteVInt(delta << 1 | 1);
+ skipBuffer.WriteVInt(_curPayloadLength);
+ _lastSkipPayloadLength[level] = _curPayloadLength;
+ }
+ }
+ else
+ {
+ // current field does not store payloads
+ skipBuffer.WriteVInt(_curDoc - _lastSkipDoc[level]);
+ }
if (_indexOptions != IndexOptions.DOCS_ONLY)
- {
- _freqIndex[level].Mark();
- _freqIndex[level].Write(skipBuffer, false);
- }
- _docIndex[level].Mark();
- _docIndex[level].Write(skipBuffer, false);
- if (_indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)
- {
- _posIndex[level].Mark();
- _posIndex[level].Write(skipBuffer, false);
- if (_curStorePayloads)
- {
- skipBuffer.WriteVInt((int) (_curPayloadPointer - _lastSkipPayloadPointer[level]));
- }
- }
-
- _lastSkipDoc[level] = _curDoc;
- _lastSkipPayloadPointer[level] = _curPayloadPointer;
- }
- }
-
+ {
+ _freqIndex[level].Mark();
+ _freqIndex[level].Write(skipBuffer, false);
+ }
+ _docIndex[level].Mark();
+ _docIndex[level].Write(skipBuffer, false);
+ if (_indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)
+ {
+ _posIndex[level].Mark();
+ _posIndex[level].Write(skipBuffer, false);
+ if (_curStorePayloads)
+ {
+ skipBuffer.WriteVInt((int)(_curPayloadPointer - _lastSkipPayloadPointer[level]));
+ }
+ }
+
+ _lastSkipDoc[level] = _curDoc;
+ _lastSkipPayloadPointer[level] = _curPayloadPointer;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/src/Lucene.Net.Codecs/SimpleText/SimpleTextCodec.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextCodec.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextCodec.cs
index 4426e9c..d86b2d5 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextCodec.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextCodec.cs
@@ -36,7 +36,8 @@ namespace Lucene.Net.Codecs.SimpleText
private readonly LiveDocsFormat _liveDocs = new SimpleTextLiveDocsFormat();
private readonly DocValuesFormat _dvFormat = new SimpleTextDocValuesFormat();
- public SimpleTextCodec() : base("SimpleText")
+ public SimpleTextCodec()
+ : base("SimpleText")
{
}
@@ -80,5 +81,4 @@ namespace Lucene.Net.Codecs.SimpleText
get { return _dvFormat; }
}
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesFormat.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesFormat.cs
index fdbda1d..b99dc1c 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesFormat.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesFormat.cs
@@ -119,8 +119,8 @@ namespace Lucene.Net.Codecs.SimpleText
/// </summary>
public class SimpleTextDocValuesFormat : DocValuesFormat
{
-
- public SimpleTextDocValuesFormat() : base("SimpleText")
+ public SimpleTextDocValuesFormat()
+ : base("SimpleText")
{
}
@@ -128,11 +128,10 @@ namespace Lucene.Net.Codecs.SimpleText
{
return new SimpleTextDocValuesWriter(state, "dat");
}
+
public override DocValuesProducer FieldsProducer(SegmentReadState state)
{
return new SimpleTextDocValuesReader(state, "dat");
}
-
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
index fe20ff8..cdea8dc 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
@@ -43,7 +43,7 @@ namespace Lucene.Net.Codecs.SimpleText
using StringHelper = Util.StringHelper;
using System.Numerics;
- public class SimpleTextDocValuesReader : DocValuesProducer
+ public class SimpleTextDocValuesReader : DocValuesProducer // LUCENENET NOTE: Changed from internal to public because it is subclassed by a public class
{
internal class OneField
{
@@ -56,12 +56,13 @@ namespace Lucene.Net.Codecs.SimpleText
public long NumValues { get; set; }
}
- internal readonly int MAX_DOC;
- internal readonly IndexInput DATA;
- internal readonly BytesRef SCRATCH = new BytesRef();
- internal readonly IDictionary<string, OneField> FIELDS = new Dictionary<string, OneField>();
+ private readonly int MAX_DOC; // LUCENENET TODO: Rename camelCase
+ private readonly IndexInput DATA; // LUCENENET TODO: Rename camelCase
+ private readonly BytesRef SCRATCH = new BytesRef(); // LUCENENET TODO: Rename camelCase
+ private readonly IDictionary<string, OneField> FIELDS = new Dictionary<string, OneField>(); // LUCENENET TODO: Rename camelCase
- public SimpleTextDocValuesReader(SegmentReadState state, string ext)
+ // LUCENENET NOTE: Changed from public to internal because the class had to be made public, but is not for public use.
+ internal SimpleTextDocValuesReader(SegmentReadState state, string ext)
{
DATA = state.Directory.OpenInput(
IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, ext), state.Context);
@@ -153,66 +154,49 @@ namespace Lucene.Net.Codecs.SimpleText
return new NumericDocValuesAnonymousInnerClassHelper(this, field, @in, scratch);
}
- public override BinaryDocValues GetBinary(FieldInfo fieldInfo)
+ private class NumericDocValuesAnonymousInnerClassHelper : NumericDocValues
{
- var field = FIELDS[fieldInfo.Name];
- Debug.Assert(field != null);
- var input = (IndexInput)DATA.Clone();
- var scratch = new BytesRef();
-
- return new BinaryDocValuesAnonymousInnerClassHelper(this, field, input, scratch);
- }
+ private readonly SimpleTextDocValuesReader _outerInstance;
- public override SortedDocValues GetSorted(FieldInfo fieldInfo)
- {
- var field = FIELDS[fieldInfo.Name];
+ private readonly OneField _field;
+ private readonly IndexInput _input;
+ private readonly BytesRef _scratch;
- // SegmentCoreReaders already verifies this field is valid:
- Debug.Assert(field != null);
- var input = (IndexInput)DATA.Clone();
- var scratch = new BytesRef();
+ public NumericDocValuesAnonymousInnerClassHelper(SimpleTextDocValuesReader outerInstance,
+ OneField field, IndexInput input, BytesRef scratch)
+ {
+ _outerInstance = outerInstance;
+ _field = field;
+ _input = input;
+ _scratch = scratch;
+ }
- return new SortedDocValuesAnonymousInnerClassHelper(this, field, input, scratch);
- }
+ public override long Get(int docId)
+ {
+ if (docId < 0 || docId >= _outerInstance.MAX_DOC)
+ throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) +
+ "; got " + docId);
- public override SortedSetDocValues GetSortedSet(FieldInfo fieldInfo)
- {
- var field = FIELDS[fieldInfo.Name];
+ _input.Seek(_field.DataStartFilePointer + (1 + _field.Pattern.Length + 2) * docId);
+ SimpleTextUtil.ReadLine(_input, _scratch);
- // SegmentCoreReaders already verifies this field is
- // valid:
- Debug.Assert(field != null);
- var input = (IndexInput) DATA.Clone();
- var scratch = new BytesRef();
-
- return new SortedSetDocValuesAnonymousInnerClassHelper(this, field, input, scratch);
- }
+ decimal bd;
+ try
+ {
+ // LUCNENENET: .NET doesn't have a way to specify a pattern with decimal, but all of the standard ones are built in.
+ bd = decimal.Parse(_scratch.Utf8ToString(), NumberStyles.Float, CultureInfo.InvariantCulture);
+ }
+ catch (FormatException ex)
+ {
+ throw new CorruptIndexException("failed to parse long value (resource=" + _input + ")", ex);
+ }
- public override IBits GetDocsWithField(FieldInfo field)
- {
- switch (field.DocValuesType)
- {
- case DocValuesType.SORTED_SET:
- return DocValues.DocsWithValue(GetSortedSet(field), MAX_DOC);
- case DocValuesType.SORTED:
- return DocValues.DocsWithValue(GetSorted(field), MAX_DOC);
- case DocValuesType.BINARY:
- return GetBinaryDocsWithField(field);
- case DocValuesType.NUMERIC:
- return GetNumericDocsWithField(field);
- default:
- throw new ArgumentOutOfRangeException();
+ SimpleTextUtil.ReadLine(_input, _scratch); // read the line telling us if its real or not
+ return (long)BigInteger.Add(new BigInteger(_field.MinValue), new BigInteger(bd));
}
}
- protected override void Dispose(bool disposing)
- {
- if (!disposing) return;
-
- DATA.Dispose();
- }
-
private IBits GetNumericDocsWithField(FieldInfo fieldInfo)
{
var field = FIELDS[fieldInfo.Name];
@@ -221,56 +205,6 @@ namespace Lucene.Net.Codecs.SimpleText
return new BitsAnonymousInnerClassHelper(this, field, input, scratch);
}
- private IBits GetBinaryDocsWithField(FieldInfo fieldInfo)
- {
- var field = FIELDS[fieldInfo.Name];
- var input = (IndexInput)DATA.Clone();
- var scratch = new BytesRef();
-
- return new BitsAnonymousInnerClassHelper2(this, field, input, scratch);
- }
-
- /// <summary> Used only in ctor: </summary>
- private void ReadLine()
- {
- SimpleTextUtil.ReadLine(DATA, SCRATCH);
- }
-
- /// <summary> Used only in ctor: </summary>
- private bool StartsWith(BytesRef prefix)
- {
- return StringHelper.StartsWith(SCRATCH, prefix);
- }
-
- /// <summary> Used only in ctor: </summary>
- private string StripPrefix(BytesRef prefix)
- {
- return Encoding.UTF8.GetString(SCRATCH.Bytes, SCRATCH.Offset + prefix.Length, SCRATCH.Length - prefix.Length);
- }
-
- public override long RamBytesUsed()
- {
- return 0;
- }
-
- public override void CheckIntegrity()
- {
- var iScratch = new BytesRef();
- var clone = (IndexInput) DATA.Clone();
- clone.Seek(0);
- ChecksumIndexInput input = new BufferedChecksumIndexInput(clone);
- while (true)
- {
- SimpleTextUtil.ReadLine(input, iScratch);
- if (!iScratch.Equals(SimpleTextDocValuesWriter.END)) continue;
-
- SimpleTextUtil.CheckFooter(input);
- break;
- }
- }
-
-
-
private class BitsAnonymousInnerClassHelper : IBits
{
private readonly SimpleTextDocValuesReader _outerInstance;
@@ -302,6 +236,70 @@ namespace Lucene.Net.Codecs.SimpleText
}
}
+ public override BinaryDocValues GetBinary(FieldInfo fieldInfo)
+ {
+ var field = FIELDS[fieldInfo.Name];
+ Debug.Assert(field != null);
+ var input = (IndexInput)DATA.Clone();
+ var scratch = new BytesRef();
+
+ return new BinaryDocValuesAnonymousInnerClassHelper(this, field, input, scratch);
+ }
+
+ private class BinaryDocValuesAnonymousInnerClassHelper : BinaryDocValues
+ {
+ private readonly SimpleTextDocValuesReader _outerInstance;
+
+ private readonly OneField _field;
+ private readonly IndexInput _input;
+ private readonly BytesRef _scratch;
+
+ public BinaryDocValuesAnonymousInnerClassHelper(SimpleTextDocValuesReader outerInstance, OneField field,
+ IndexInput input, BytesRef scratch)
+ {
+ _outerInstance = outerInstance;
+ _field = field;
+ _input = input;
+ _scratch = scratch;
+ }
+
+ public override void Get(int docId, BytesRef result)
+ {
+ if (docId < 0 || docId >= _outerInstance.MAX_DOC)
+ throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) +
+ "; got " + docId);
+
+ _input.Seek(_field.DataStartFilePointer + (9 + _field.Pattern.Length + _field.MaxLength + 2) * docId);
+ SimpleTextUtil.ReadLine(_input, _scratch);
+ Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextDocValuesWriter.LENGTH));
+ int len;
+ try
+ {
+ // LUCNENENET: .NET doesn't have a way to specify a pattern with integer, but all of the standard ones are built in.
+ len = int.Parse(Encoding.UTF8.GetString(_scratch.Bytes, _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length,
+ _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length), NumberStyles.Integer, CultureInfo.InvariantCulture);
+ }
+ catch (FormatException ex)
+ {
+ throw new CorruptIndexException("failed to parse int value (resource=" + _input + ")", ex);
+ }
+
+ result.Bytes = new byte[len];
+ result.Offset = 0;
+ result.Length = len;
+ _input.ReadBytes(result.Bytes, 0, len);
+ }
+ }
+
+ private IBits GetBinaryDocsWithField(FieldInfo fieldInfo)
+ {
+ var field = FIELDS[fieldInfo.Name];
+ var input = (IndexInput)DATA.Clone();
+ var scratch = new BytesRef();
+
+ return new BitsAnonymousInnerClassHelper2(this, field, input, scratch);
+ }
+
private class BitsAnonymousInnerClassHelper2 : IBits
{
private readonly SimpleTextDocValuesReader _outerInstance;
@@ -349,6 +347,18 @@ namespace Lucene.Net.Codecs.SimpleText
}
}
+ public override SortedDocValues GetSorted(FieldInfo fieldInfo)
+ {
+ var field = FIELDS[fieldInfo.Name];
+
+ // SegmentCoreReaders already verifies this field is valid:
+ Debug.Assert(field != null);
+ var input = (IndexInput)DATA.Clone();
+ var scratch = new BytesRef();
+
+ return new SortedDocValuesAnonymousInnerClassHelper(this, field, input, scratch);
+ }
+
private class SortedDocValuesAnonymousInnerClassHelper : SortedDocValues
{
private readonly SimpleTextDocValuesReader _outerInstance;
@@ -430,6 +440,20 @@ namespace Lucene.Net.Codecs.SimpleText
}
}
+ public override SortedSetDocValues GetSortedSet(FieldInfo fieldInfo)
+ {
+ var field = FIELDS[fieldInfo.Name];
+
+ // SegmentCoreReaders already verifies this field is
+ // valid:
+ Debug.Assert(field != null);
+
+ var input = (IndexInput) DATA.Clone();
+ var scratch = new BytesRef();
+
+ return new SortedSetDocValuesAnonymousInnerClassHelper(this, field, input, scratch);
+ }
+
private class SortedSetDocValuesAnonymousInnerClassHelper : SortedSetDocValues
{
private readonly SimpleTextDocValuesReader _outerInstance;
@@ -510,94 +534,67 @@ namespace Lucene.Net.Codecs.SimpleText
}
}
- private class NumericDocValuesAnonymousInnerClassHelper : NumericDocValues
+ public override IBits GetDocsWithField(FieldInfo field)
{
- private readonly SimpleTextDocValuesReader _outerInstance;
-
- private readonly OneField _field;
- private readonly IndexInput _input;
- private readonly BytesRef _scratch;
-
- public NumericDocValuesAnonymousInnerClassHelper(SimpleTextDocValuesReader outerInstance,
- OneField field, IndexInput input, BytesRef scratch)
+ switch (field.DocValuesType)
{
- _outerInstance = outerInstance;
- _field = field;
- _input = input;
- _scratch = scratch;
+ case DocValuesType.SORTED_SET:
+ return DocValues.DocsWithValue(GetSortedSet(field), MAX_DOC);
+ case DocValuesType.SORTED:
+ return DocValues.DocsWithValue(GetSorted(field), MAX_DOC);
+ case DocValuesType.BINARY:
+ return GetBinaryDocsWithField(field);
+ case DocValuesType.NUMERIC:
+ return GetNumericDocsWithField(field);
+ default:
+ throw new ArgumentOutOfRangeException();
}
+ }
- public override long Get(int docId)
- {
- if (docId < 0 || docId >= _outerInstance.MAX_DOC)
- throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) +
- "; got " + docId);
-
- _input.Seek(_field.DataStartFilePointer + (1 + _field.Pattern.Length + 2) * docId);
- SimpleTextUtil.ReadLine(_input, _scratch);
+ protected override void Dispose(bool disposing)
+ {
+ if (!disposing) return;
-
- decimal bd;
- try
- {
- // LUCNENENET: .NET doesn't have a way to specify a pattern with decimal, but all of the standard ones are built in.
- bd = decimal.Parse(_scratch.Utf8ToString(), NumberStyles.Float, CultureInfo.InvariantCulture);
- }
- catch (FormatException ex)
- {
- throw new CorruptIndexException("failed to parse long value (resource=" + _input + ")", ex);
- }
+ DATA.Dispose();
+ }
- SimpleTextUtil.ReadLine(_input, _scratch); // read the line telling us if its real or not
- return (long)BigInteger.Add(new BigInteger(_field.MinValue), new BigInteger(bd));
- }
+ /// <summary> Used only in ctor: </summary>
+ private void ReadLine()
+ {
+ SimpleTextUtil.ReadLine(DATA, SCRATCH);
}
- private class BinaryDocValuesAnonymousInnerClassHelper : BinaryDocValues
+ /// <summary> Used only in ctor: </summary>
+ private bool StartsWith(BytesRef prefix)
{
- private readonly SimpleTextDocValuesReader _outerInstance;
+ return StringHelper.StartsWith(SCRATCH, prefix);
+ }
- private readonly OneField _field;
- private readonly IndexInput _input;
- private readonly BytesRef _scratch;
+ /// <summary> Used only in ctor: </summary>
+ private string StripPrefix(BytesRef prefix)
+ {
+ return Encoding.UTF8.GetString(SCRATCH.Bytes, SCRATCH.Offset + prefix.Length, SCRATCH.Length - prefix.Length);
+ }
- public BinaryDocValuesAnonymousInnerClassHelper(SimpleTextDocValuesReader outerInstance, OneField field,
- IndexInput input, BytesRef scratch)
- {
- _outerInstance = outerInstance;
- _field = field;
- _input = input;
- _scratch = scratch;
- }
+ public override long RamBytesUsed()
+ {
+ return 0;
+ }
- public override void Get(int docId, BytesRef result)
+ public override void CheckIntegrity()
+ {
+ var iScratch = new BytesRef();
+ var clone = (IndexInput) DATA.Clone();
+ clone.Seek(0);
+ ChecksumIndexInput input = new BufferedChecksumIndexInput(clone);
+ while (true)
{
- if (docId < 0 || docId >= _outerInstance.MAX_DOC)
- throw new IndexOutOfRangeException("docID must be 0 .. " + (_outerInstance.MAX_DOC - 1) +
- "; got " + docId);
-
- _input.Seek(_field.DataStartFilePointer + (9 + _field.Pattern.Length + _field.MaxLength + 2) * docId);
- SimpleTextUtil.ReadLine(_input, _scratch);
- Debug.Assert(StringHelper.StartsWith(_scratch, SimpleTextDocValuesWriter.LENGTH));
- int len;
- try
- {
- // LUCNENENET: .NET doesn't have a way to specify a pattern with integer, but all of the standard ones are built in.
- len = int.Parse(Encoding.UTF8.GetString(_scratch.Bytes, _scratch.Offset + SimpleTextDocValuesWriter.LENGTH.Length,
- _scratch.Length - SimpleTextDocValuesWriter.LENGTH.Length), NumberStyles.Integer, CultureInfo.InvariantCulture);
- }
- catch (FormatException ex)
- {
- throw new CorruptIndexException("failed to parse int value (resource=" + _input + ")", ex);
- }
+ SimpleTextUtil.ReadLine(input, iScratch);
+ if (!iScratch.Equals(SimpleTextDocValuesWriter.END)) continue;
- result.Bytes = new byte[len];
- result.Offset = 0;
- result.Length = len;
- _input.ReadBytes(result.Bytes, 0, len);
+ SimpleTextUtil.CheckFooter(input);
+ break;
}
}
-
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
index eea616d..df88f2d 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesWriter.cs
@@ -33,36 +33,47 @@ namespace Lucene.Net.Codecs.SimpleText
using BytesRef = Util.BytesRef;
using IOUtils = Util.IOUtils;
- public class SimpleTextDocValuesWriter : DocValuesConsumer
+ public class SimpleTextDocValuesWriter : DocValuesConsumer // LUCENENET NOTE: changed from internal to public because it is subclassed by a public type
{
internal static readonly BytesRef END = new BytesRef("END");
internal static readonly BytesRef FIELD = new BytesRef("field ");
internal static readonly BytesRef TYPE = new BytesRef(" type ");
-
+
// used for numerics
internal static readonly BytesRef MINVALUE = new BytesRef(" minvalue ");
internal static readonly BytesRef PATTERN = new BytesRef(" pattern ");
-
+
// used for bytes
internal static readonly BytesRef LENGTH = new BytesRef("length ");
internal static readonly BytesRef MAXLENGTH = new BytesRef(" maxlength ");
-
+
// used for sorted bytes
internal static readonly BytesRef NUMVALUES = new BytesRef(" numvalues ");
internal static readonly BytesRef ORDPATTERN = new BytesRef(" ordpattern ");
- internal IndexOutput data;
- internal readonly BytesRef scratch = new BytesRef();
- internal readonly int numDocs;
+ private IndexOutput data;
+ private readonly BytesRef scratch = new BytesRef();
+ private readonly int numDocs;
private readonly HashSet<string> _fieldsSeen = new HashSet<string>(); // for asserting
- public SimpleTextDocValuesWriter(SegmentWriteState state, string ext)
+ // LUCENENET NOTE: Changed from public to internal because the class had to be made public, but is not for public use.
+ internal SimpleTextDocValuesWriter(SegmentWriteState state, string ext)
{
data = state.Directory.CreateOutput(
IndexFileNames.SegmentFileName(state.SegmentInfo.Name, state.SegmentSuffix, ext), state.Context);
numDocs = state.SegmentInfo.DocCount;
}
+ /// <summary>
+ /// For Asserting
+ /// </summary>
+ private bool FieldSeen(string field)
+ {
+ Debug.Assert(!_fieldsSeen.Contains(field), "field \"" + field + "\" was added more than once during flush");
+ _fieldsSeen.Add(field);
+ return true;
+ }
+
public override void AddNumericField(FieldInfo field, IEnumerable<long?> values)
{
Debug.Assert(FieldSeen(field.Name));
@@ -396,6 +407,18 @@ namespace Lucene.Net.Codecs.SimpleText
}
}
+ /// <summary>Write the header for this field </summary>
+ private void WriteFieldEntry(FieldInfo field, DocValuesType type)
+ {
+ SimpleTextUtil.Write(data, FIELD);
+ SimpleTextUtil.Write(data, field.Name, scratch);
+ SimpleTextUtil.WriteNewline(data);
+
+ SimpleTextUtil.Write(data, TYPE);
+ SimpleTextUtil.Write(data, type.ToString(), scratch);
+ SimpleTextUtil.WriteNewline(data);
+ }
+
protected override void Dispose(bool disposing)
{
if (data == null || !disposing) return;
@@ -422,30 +445,5 @@ namespace Lucene.Net.Codecs.SimpleText
data = null;
}
}
-
- /// <summary>Write the header for this field </summary>
- private void WriteFieldEntry(FieldInfo field, DocValuesType type)
- {
- SimpleTextUtil.Write(data, FIELD);
- SimpleTextUtil.Write(data, field.Name, scratch);
- SimpleTextUtil.WriteNewline(data);
-
- SimpleTextUtil.Write(data, TYPE);
- SimpleTextUtil.Write(data, type.ToString(), scratch);
- SimpleTextUtil.WriteNewline(data);
- }
-
- /// <summary>
- /// For Asserting
- /// </summary>
- /// <param name="field"></param>
- /// <returns></returns>
- private bool FieldSeen(string field)
- {
- Debug.Assert(!_fieldsSeen.Contains(field), "field \"" + field + "\" was added more than once during flush");
- _fieldsSeen.Add(field);
- return true;
- }
-
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs
index 67e50b1..e3a9e47 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs
@@ -165,7 +165,7 @@ namespace Lucene.Net.Codecs.SimpleText
return "false".Equals(dvType) ? null : (Index.DocValuesType?)Enum.Parse(typeof(Index.DocValuesType), dvType);
}
- private static string ReadString(int offset, BytesRef scratch)
+ private string ReadString(int offset, BytesRef scratch)
{
return Encoding.UTF8.GetString(scratch.Bytes, scratch.Offset + offset, scratch.Length - offset);
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c602c98f/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs
index 291916b..2f151b4 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs
@@ -42,7 +42,6 @@ namespace Lucene.Net.Codecs.SimpleText
/// </summary>
public class SimpleTextFieldInfosWriter : FieldInfosWriter
{
-
/// <summary>
/// Extension of field infos </summary>
internal const string FIELD_INFOS_EXTENSION = "inf";
@@ -163,5 +162,4 @@ namespace Lucene.Net.Codecs.SimpleText
return type.HasValue ? type.ToString() : "false";
}
}
-
}
\ No newline at end of file