You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2014/11/14 12:59:17 UTC

[02/26] lucenenet git commit: Revert "Revert "Updating Lucene.Net.Codes/Pulsing""

Revert "Revert "Updating Lucene.Net.Codes/Pulsing""

This reverts commit ce4970c8b6beb9b3fff8797a2bcaada4a930269d.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/6d9a6ffa
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/6d9a6ffa
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/6d9a6ffa

Branch: refs/heads/master
Commit: 6d9a6ffac2f0ea597d60415d6ef97bf08dce31f4
Parents: ce4970c
Author: eladmarg <el...@gmail.com>
Authored: Fri Nov 7 18:33:23 2014 -0800
Committer: eladmarg <el...@gmail.com>
Committed: Fri Nov 7 18:33:23 2014 -0800

----------------------------------------------------------------------
 .../Pulsing/Pulsing41PostingsFormat.cs          |   2 +-
 .../Pulsing/PulsingPostingsFormat.cs            |  10 +-
 .../Pulsing/PulsingPostingsReader.cs            | 486 +++++++++----------
 .../Pulsing/PulsingPostingsWriter.cs            | 319 ++++++------
 src/Lucene.Net.Core/Codecs/PostingsConsumer.cs  |   2 +-
 5 files changed, 384 insertions(+), 435 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6d9a6ffa/src/Lucene.Net.Codecs/Pulsing/Pulsing41PostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Pulsing/Pulsing41PostingsFormat.cs b/src/Lucene.Net.Codecs/Pulsing/Pulsing41PostingsFormat.cs
index f2634f4..458771e 100644
--- a/src/Lucene.Net.Codecs/Pulsing/Pulsing41PostingsFormat.cs
+++ b/src/Lucene.Net.Codecs/Pulsing/Pulsing41PostingsFormat.cs
@@ -17,7 +17,7 @@
 
 namespace Lucene.Net.Codecs.Pulsing
 {
-    using Lucene.Net.Codecs.Lucene41;
+    using Lucene41;
 
     /// <summary>
     /// Concrete pulsing implementation over {@link Lucene41PostingsFormat}.

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6d9a6ffa/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 552ecbc..9ab1706 100644
--- a/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsFormat.cs
+++ b/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsFormat.cs
@@ -15,14 +15,12 @@
  * limitations under the License.
  */
 
-
-
 namespace Lucene.Net.Codecs.Pulsing
 {
     using System;
     using System.Diagnostics;
-    using Lucene.Net.Index;
-    using Lucene.Net.Util;
+    using Index;
+    using Util;
 
     /// <summary>
     /// This postings format "inlines" the postings for terms that have
@@ -49,11 +47,11 @@ namespace Lucene.Net.Codecs.Pulsing
         {
         }
 
-        /// <summary>Terms with freq <= freqCutoff are inlined into terms dict.</summary>
+        /// <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)
         {
-            Debug.Debug.Assert((minBlockSize > 1);
+            Debug.Assert(minBlockSize > 1);
 
             _freqCutoff = freqCutoff;
             _minBlockSize = minBlockSize;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6d9a6ffa/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 9f4599b..75334e6 100644
--- a/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsReader.cs
+++ b/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsReader.cs
@@ -21,9 +21,9 @@ namespace Lucene.Net.Codecs.Pulsing
     using System;
     using System.Collections.Generic;
     using System.Diagnostics;
-    using Lucene.Net.Index;
-    using Lucene.Net.Store;
-    using Lucene.Net.Util;
+    using Index;
+    using Store;
+    using Util;
 
     /// <summary>
     /// Concrete class that reads the current doc/freq/skip postings format 
@@ -39,52 +39,52 @@ namespace Lucene.Net.Codecs.Pulsing
 
         // Fallback reader for non-pulsed terms:
         private readonly PostingsReaderBase _wrappedPostingsReader;
-        private readonly SegmentReadState segmentState;
-        private int maxPositions;
-        private int version;
-        private SortedDictionary<int, int> fields;
+        private readonly SegmentReadState _segmentState;
+        private int _maxPositions;
+        private int _version;
+        private SortedDictionary<int, int> _fields;
 
         public PulsingPostingsReader(SegmentReadState state, PostingsReaderBase wrappedPostingsReader)
         {
-            this._wrappedPostingsReader = wrappedPostingsReader;
-            this.segmentState = state;
+            _wrappedPostingsReader = wrappedPostingsReader;
+            _segmentState = state;
         }
 
         public override void Init(IndexInput termsIn)
         {
-            version = CodecUtil.CheckHeader(termsIn, PulsingPostingsWriter.CODEC,
+            _version = CodecUtil.CheckHeader(termsIn, PulsingPostingsWriter.CODEC,
                 PulsingPostingsWriter.VERSION_START,
                 PulsingPostingsWriter.VERSION_CURRENT);
 
-            maxPositions = termsIn.ReadVInt();
+            _maxPositions = termsIn.ReadVInt();
             _wrappedPostingsReader.Init(termsIn);
 
-            if (_wrappedPostingsReader is PulsingPostingsReader || version < PulsingPostingsWriter.VERSION_META_ARRAY)
+            if (_wrappedPostingsReader is PulsingPostingsReader || _version < PulsingPostingsWriter.VERSION_META_ARRAY)
             {
-                fields = null;
+                _fields = null;
             }
             else
             {
-                fields = new SortedDictionary<int, int>();
-                String summaryFileName = IndexFileNames.SegmentFileName(segmentState.SegmentInfo.Name,
-                    segmentState.SegmentSuffix, PulsingPostingsWriter.SUMMARY_EXTENSION);
+                _fields = new SortedDictionary<int, int>();
+                var summaryFileName = IndexFileNames.SegmentFileName(_segmentState.SegmentInfo.Name,
+                    _segmentState.SegmentSuffix, PulsingPostingsWriter.SUMMARY_EXTENSION);
                 IndexInput input = null;
 
                 try
                 {
                     input =
-                        segmentState.Directory.OpenInput(summaryFileName, segmentState.Context);
+                        _segmentState.Directory.OpenInput(summaryFileName, _segmentState.Context);
                     CodecUtil.CheckHeader(input,
                         PulsingPostingsWriter.CODEC,
-                        version,
+                        _version,
                         PulsingPostingsWriter.VERSION_CURRENT);
 
-                    int numField = input.ReadVInt();
-                    for (int i = 0; i < numField; i++)
+                    var numField = input.ReadVInt();
+                    for (var i = 0; i < numField; i++)
                     {
-                        int fieldNum = input.ReadVInt();
-                        int longsSize = input.ReadVInt();
-                        fields.Add(fieldNum, longsSize);
+                        var fieldNum = input.ReadVInt();
+                        var longsSize = input.ReadVInt();
+                        _fields.Add(fieldNum, longsSize);
                     }
                 }
                 finally
@@ -96,25 +96,24 @@ namespace Lucene.Net.Codecs.Pulsing
 
         public override BlockTermState NewTermState()
         {
-            var state = new PulsingTermState {WrappedTermState = _wrappedPostingsReader.NewTermState()};
-            return state;
+            return new PulsingTermState {WrappedTermState = _wrappedPostingsReader.NewTermState()};
         }
 
         public override void DecodeTerm(long[] empty, DataInput input, FieldInfo fieldInfo, BlockTermState _termState,
             bool absolute)
         {
-            PulsingTermState termState = (PulsingTermState) _termState;
+            var termState = (PulsingTermState) _termState;
+
+            Debug.Assert(empty.Length == 0);
 
-            Debug.Debug.Assert((empty.Length == 0);
             termState.Absolute = termState.Absolute || absolute;
             // if we have positions, its total TF, otherwise its computed based on docFreq.
             // TODO Double check this is right..
-            long count = FieldInfo.IndexOptions_e.DOCS_AND_FREQS_AND_POSITIONS.CompareTo(fieldInfo.IndexOptions) <= 0
+            long count = FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS.CompareTo(fieldInfo.FieldIndexOptions) <= 0
                 ? termState.TotalTermFreq
                 : termState.DocFreq;
-            //System.out.println("  count=" + count + " threshold=" + maxPositions);
-
-            if (count <= maxPositions)
+           
+            if (count <= _maxPositions)
             {
                 // Inlined into terms dict -- just read the byte[] blob in,
                 // but don't decode it now (we only decode when a DocsEnum
@@ -134,12 +133,12 @@ namespace Lucene.Net.Codecs.Pulsing
             }
             else
             {
-                int longsSize = fields == null ? 0 : fields[fieldInfo.Number];
+                var longsSize = _fields == null ? 0 : _fields[fieldInfo.Number];
                 if (termState.Longs == null)
                 {
                     termState.Longs = new long[longsSize];
                 }
-                for (int i = 0; i < longsSize; i++)
+                for (var i = 0; i < longsSize; i++)
                 {
                     termState.Longs[i] = input.ReadVLong();
                 }
@@ -156,7 +155,7 @@ namespace Lucene.Net.Codecs.Pulsing
         public override DocsEnum Docs(FieldInfo field, BlockTermState _termState, Bits liveDocs, DocsEnum reuse,
             int flags)
         {
-            PulsingTermState termState = (PulsingTermState) _termState;
+            var termState = (PulsingTermState) _termState;
             if (termState.PostingsSize != -1)
             {
                 PulsingDocsEnum postings;
@@ -171,7 +170,7 @@ namespace Lucene.Net.Codecs.Pulsing
                 else
                 {
                     // the 'reuse' is actually the wrapped enum
-                    PulsingDocsEnum previous = (PulsingDocsEnum) GetOther(reuse);
+                    var previous = (PulsingDocsEnum) GetOther(reuse);
                     if (previous != null && previous.CanReuse(field))
                     {
                         postings = previous;
@@ -181,26 +180,21 @@ namespace Lucene.Net.Codecs.Pulsing
                         postings = new PulsingDocsEnum(field);
                     }
                 }
+                
                 if (reuse != postings)
-                {
                     SetOther(postings, reuse); // postings.other = reuse
-                }
+                
                 return postings.Reset(liveDocs, termState);
             }
-            else
-            {
-                if (reuse is PulsingDocsEnum)
-                {
-                    DocsEnum wrapped = _wrappedPostingsReader.Docs(field, termState.WrappedTermState, liveDocs,
-                        GetOther(reuse), flags);
-                    SetOther(wrapped, reuse); // wrapped.other = reuse
-                    return wrapped;
-                }
-                else
-                {
-                    return _wrappedPostingsReader.Docs(field, termState.WrappedTermState, liveDocs, reuse, flags);
-                }
-            }
+
+            if (!(reuse is PulsingDocsEnum))
+                return _wrappedPostingsReader.Docs(field, termState.WrappedTermState, liveDocs, reuse, flags);
+
+            var wrapped = _wrappedPostingsReader.Docs(field, termState.WrappedTermState, liveDocs,
+                GetOther(reuse), flags);
+
+            SetOther(wrapped, reuse); // wrapped.other = reuse
+            return wrapped;
         }
 
         public override DocsAndPositionsEnum DocsAndPositions(FieldInfo field, BlockTermState _termState, Bits liveDocs,
@@ -208,7 +202,7 @@ namespace Lucene.Net.Codecs.Pulsing
             int flags)
         {
 
-            PulsingTermState termState = (PulsingTermState) _termState;
+            var termState = (PulsingTermState) _termState;
 
             if (termState.PostingsSize != -1)
             {
@@ -224,7 +218,7 @@ namespace Lucene.Net.Codecs.Pulsing
                 else
                 {
                     // the 'reuse' is actually the wrapped enum
-                    PulsingDocsAndPositionsEnum previous = (PulsingDocsAndPositionsEnum) GetOther(reuse);
+                    var previous = (PulsingDocsAndPositionsEnum) GetOther(reuse);
                     if (previous != null && previous.CanReuse(field))
                     {
                         postings = previous;
@@ -238,25 +232,19 @@ namespace Lucene.Net.Codecs.Pulsing
                 {
                     SetOther(postings, reuse); // postings.other = reuse 
                 }
-                return postings.reset(liveDocs, termState);
-            }
-            else
-            {
-                if (reuse is PulsingDocsAndPositionsEnum)
-                {
-                    DocsAndPositionsEnum wrapped = _wrappedPostingsReader.DocsAndPositions(field,
-                        termState.WrappedTermState,
-                        liveDocs, (DocsAndPositionsEnum) GetOther(reuse),
-                        flags);
-                    SetOther(wrapped, reuse); // wrapped.other = reuse
-                    return wrapped;
-                }
-                else
-                {
-                    return _wrappedPostingsReader.DocsAndPositions(field, termState.WrappedTermState, liveDocs, reuse,
-                        flags);
-                }
+                return postings.Reset(liveDocs, termState);
             }
+
+            if (!(reuse is PulsingDocsAndPositionsEnum))
+                return _wrappedPostingsReader.DocsAndPositions(field, termState.WrappedTermState, liveDocs, reuse,
+                    flags);
+
+            var wrapped = _wrappedPostingsReader.DocsAndPositions(field,
+                termState.WrappedTermState,
+                liveDocs, (DocsAndPositionsEnum) GetOther(reuse),
+                flags);
+            SetOther(wrapped, reuse); // wrapped.other = reuse
+            return wrapped;
         }
 
         public override long RamBytesUsed()
@@ -287,14 +275,10 @@ namespace Lucene.Net.Codecs.Pulsing
         private DocsEnum GetOther(DocsEnum de)
         {
             if (de == null)
-            {
                 return null;
-            }
-            else
-            {
-                AttributeSource atts = de.Attributes();
-                return atts.AddAttribute(PulsingEnumAttribute.Enums().get(this);
-            }
+            
+            var atts = de.Attributes();
+            return atts.AddAttribute(PulsingEnumAttribute.class).Enums().get(this);
         }
 
         /// <summary>
@@ -303,8 +287,8 @@ namespace Lucene.Net.Codecs.Pulsing
         /// </summary>
         private DocsEnum SetOther(DocsEnum de, DocsEnum other)
         {
-            AttributeSource atts = de.Attributes();
-            return atts.AddAttribute(PulsingEnumAttributeImpl.Enums().put(this, other));
+            var atts = de.Attributes();
+            return atts.AddAttribute(PulsingEnumAttribute.class).Enums().put(this, other);
         }
 
         ///<summary>
@@ -329,7 +313,7 @@ namespace Lucene.Net.Codecs.Pulsing
 
             public override object Clone()
             {
-                PulsingTermState clone = (PulsingTermState) base.Clone();
+                var clone = (PulsingTermState) base.Clone();
                 if (PostingsSize != -1)
                 {
                     clone.Postings = new byte[PostingsSize];
@@ -337,14 +321,14 @@ namespace Lucene.Net.Codecs.Pulsing
                 }
                 else
                 {
-                    Debug.Debug.Assert((WrappedTermState != null);
+                    Debug.Assert(WrappedTermState != null);
                     clone.WrappedTermState = (BlockTermState) WrappedTermState.Clone();
                     clone.Absolute = Absolute;
-                    if (Longs != null)
-                    {
-                        clone.Longs = new long[Longs.Length];
-                        Array.Copy(Longs, 0, clone.Longs, 0, Longs.Length);
-                    }
+                    
+                    if (Longs == null) return clone;
+
+                    clone.Longs = new long[Longs.Length];
+                    Array.Copy(Longs, 0, clone.Longs, 0, Longs.Length);
                 }
                 return clone;
             }
@@ -360,7 +344,7 @@ namespace Lucene.Net.Codecs.Pulsing
                     {
                         Postings = new byte[ArrayUtil.Oversize(_other.PostingsSize, 1)];
                     }
-                    System.Array.Copy(_other.Postings, 0, Postings, 0, _other.PostingsSize);
+                    Array.Copy(_other.Postings, 0, Postings, 0, _other.PostingsSize);
                 }
                 else
                 {
@@ -371,373 +355,341 @@ namespace Lucene.Net.Codecs.Pulsing
             public override String ToString()
             {
                 if (PostingsSize == -1)
-                {
                     return "PulsingTermState: not inlined: wrapped=" + WrappedTermState;
-                }
-                else
-                {
-                    return "PulsingTermState: inlined size=" + PostingsSize + " " + base.ToString();
-                }
+                
+                return "PulsingTermState: inlined size=" + PostingsSize + " " + base.ToString();
             }
         }
 
         internal class PulsingDocsEnum : DocsEnum
         {
-            private byte[] postingsBytes;
-            private readonly ByteArrayDataInput postings = new ByteArrayDataInput();
-            private readonly FieldInfo.IndexOptions_e? indexOptions;
-            private readonly bool storePayloads;
-            private readonly bool storeOffsets;
-            private Bits liveDocs;
-
-            private int docID = -1;
-            private int accum;
-            private int freq;
-            private int payloadLength;
-            private int cost;
+            private byte[] _postingsBytes;
+            private readonly ByteArrayDataInput _postings = new ByteArrayDataInput();
+            private readonly FieldInfo.IndexOptions? _indexOptions;
+            private readonly bool _storePayloads;
+            private readonly bool _storeOffsets;
+            private Bits _liveDocs;
+
+            private int _docId = -1;
+            private int _accum;
+            private int _freq;
+            private int _payloadLength;
+            private int _cost;
 
             public PulsingDocsEnum(FieldInfo fieldInfo)
             {
-                indexOptions = fieldInfo.IndexOptions;
-                storePayloads = fieldInfo.HasPayloads();
-                storeOffsets = indexOptions.Value.CompareTo(FieldInfo.IndexOptions_e.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
+                _indexOptions = fieldInfo.FieldIndexOptions;
+                _storePayloads = fieldInfo.HasPayloads();
+                _storeOffsets = _indexOptions.Value.CompareTo(FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
             }
 
             public PulsingDocsEnum Reset(Bits liveDocs, PulsingTermState termState)
             {
-                Debug.Debug.Assert((termState.PostingsSize != -1);
+                Debug.Assert(termState.PostingsSize != -1);
 
                 // Must make a copy of termState's byte[] so that if
                 // app does TermsEnum.next(), this DocsEnum is not affected
-                if (postingsBytes == null)
+                if (_postingsBytes == null)
                 {
-                    postingsBytes = new byte[termState.PostingsSize];
+                    _postingsBytes = new byte[termState.PostingsSize];
                 }
-                else if (postingsBytes.Length < termState.PostingsSize)
+                else if (_postingsBytes.Length < termState.PostingsSize)
                 {
-                    postingsBytes = ArrayUtil.Grow(postingsBytes, termState.PostingsSize);
+                    _postingsBytes = ArrayUtil.Grow(_postingsBytes, termState.PostingsSize);
                 }
-                System.Array.Copy(termState.Postings, 0, postingsBytes, 0, termState.PostingsSize);
-                postings.Reset(postingsBytes, 0, termState.PostingsSize);
-                docID = -1;
-                accum = 0;
-                freq = 1;
-                cost = termState.DocFreq;
-                payloadLength = 0;
-                this.liveDocs = liveDocs;
+                System.Array.Copy(termState.Postings, 0, _postingsBytes, 0, termState.PostingsSize);
+                _postings.Reset(_postingsBytes, 0, termState.PostingsSize);
+                _docId = -1;
+                _accum = 0;
+                _freq = 1;
+                _cost = termState.DocFreq;
+                _payloadLength = 0;
+                this._liveDocs = liveDocs;
                 return this;
             }
 
             public bool CanReuse(FieldInfo fieldInfo)
             {
-                return indexOptions == fieldInfo.IndexOptions && storePayloads == fieldInfo.HasPayloads();
+                return _indexOptions == fieldInfo.FieldIndexOptions && _storePayloads == fieldInfo.HasPayloads();
             }
 
             public override int DocID()
             {
-                return docID;
+                return _docId;
             }
 
             public override int NextDoc()
             {
-                //System.out.println("PR nextDoc this= "+ this);
                 while (true)
                 {
-                    if (postings.Eof())
+                    if (_postings.Eof())
+                        return _docId = NO_MORE_DOCS;
+                    
+                    var code = _postings.ReadVInt();
+                    if (_indexOptions == FieldInfo.IndexOptions.DOCS_ONLY)
                     {
-                        return docID = NO_MORE_DOCS;
-                    }
-
-                    int code = postings.ReadVInt();
-                    if (indexOptions == FieldInfo.IndexOptions_e.DOCS_ONLY)
-                    {
-                        accum += code;
+                        _accum += code;
                     }
                     else
                     {
-                        accum += (int)((uint)code >> 1); ; // shift off low bit
-                        if ((code & 1) != 0)
-                        {
-                            // if low bit is set
-                            freq = 1; // freq is one
-                        }
-                        else
-                        {
-                            freq = postings.ReadVInt(); // else read freq
-                        }
+                        _accum += (int)((uint)code >> 1); ; // shift off low bit
+                        _freq = (code & 1) != 0 ? 1 : _postings.ReadVInt();
 
-                        if (indexOptions.Value.CompareTo(FieldInfo.IndexOptions_e.DOCS_AND_FREQS_AND_POSITIONS) >= 0)
+                        if (_indexOptions.Value.CompareTo(FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0)
                         {
                             // Skip positions
-                            if (storePayloads)
+                            if (_storePayloads)
                             {
-                                for (int pos = 0; pos < freq; pos++)
+                                for (var pos = 0; pos < _freq; pos++)
                                 {
-                                    int posCode = postings.ReadVInt();
+                                    var posCode = _postings.ReadVInt();
                                     if ((posCode & 1) != 0)
                                     {
-                                        payloadLength = postings.ReadVInt();
+                                        _payloadLength = _postings.ReadVInt();
                                     }
-                                    if (storeOffsets && (postings.ReadVInt() & 1) != 0)
+                                    if (_storeOffsets && (_postings.ReadVInt() & 1) != 0)
                                     {
                                         // new offset length
-                                        postings.ReadVInt();
+                                        _postings.ReadVInt();
                                     }
-                                    if (payloadLength != 0)
+                                    if (_payloadLength != 0)
                                     {
-                                        postings.SkipBytes(payloadLength);
+                                        _postings.SkipBytes(_payloadLength);
                                     }
                                 }
                             }
                             else
                             {
-                                for (int pos = 0; pos < freq; pos++)
+                                for (var pos = 0; pos < _freq; pos++)
                                 {
                                     // TODO: skipVInt
-                                    postings.ReadVInt();
-                                    if (storeOffsets && (postings.ReadVInt() & 1) != 0)
+                                    _postings.ReadVInt();
+                                    if (_storeOffsets && (_postings.ReadVInt() & 1) != 0)
                                     {
                                         // new offset length
-                                        postings.ReadVInt();
+                                        _postings.ReadVInt();
                                     }
                                 }
                             }
                         }
                     }
 
-                    if (liveDocs == null || liveDocs.Get(accum))
-                    {
-                        return (docID = accum);
-                    }
-
+                    if (_liveDocs == null || _liveDocs.Get(_accum))
+                        return (_docId = _accum);
                 }
             }
 
             public override int Advance(int target)
             {
-                return docID = SlowAdvance(target);
+                return _docId = SlowAdvance(target);
             }
 
             public override long Cost()
             {
-                return cost;
+                return _cost;
             }
 
             public override int Freq()
             {
-                return freq;
+                return _freq;
             }
         }
 
         internal class PulsingDocsAndPositionsEnum : DocsAndPositionsEnum
         {
-            private byte[] postingsBytes;
-            private readonly ByteArrayDataInput postings = new ByteArrayDataInput();
-            private readonly bool storePayloads;
-            private readonly bool storeOffsets;
+            private byte[] _postingsBytes;
+            private readonly ByteArrayDataInput _postings = new ByteArrayDataInput();
+            private readonly bool _storePayloads;
+            private readonly bool _storeOffsets;
             // note: we could actually reuse across different options, if we passed this to reset()
             // and re-init'ed storeOffsets accordingly (made it non-final)
-            private readonly FieldInfo.IndexOptions_e? indexOptions;
-
-            private Bits liveDocs;
-            private int docID = -1;
-            private int accum;
-            private int freq;
-            private int posPending;
-            private int position;
-            private int payloadLength;
-            private BytesRef payload;
-            private int startOffset;
-            private int offsetLength;
-
-            private bool payloadRetrieved;
-            private int cost;
+            private readonly FieldInfo.IndexOptions? _indexOptions;
+
+            private Bits _liveDocs;
+            private int _docId = -1;
+            private int _accum;
+            private int _freq;
+            private int _posPending;
+            private int _position;
+            private int _payloadLength;
+            private BytesRef _payload;
+            private int _startOffset;
+            private int _offsetLength;
+
+            private bool _payloadRetrieved;
+            private int _cost;
 
             public PulsingDocsAndPositionsEnum(FieldInfo fieldInfo)
             {
-                indexOptions = fieldInfo.IndexOptions;
-                storePayloads = fieldInfo.HasPayloads();
-                storeOffsets =
-                    indexOptions.Value.CompareTo(FieldInfo.IndexOptions_e.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
+                _indexOptions = fieldInfo.FieldIndexOptions;
+                _storePayloads = fieldInfo.HasPayloads();
+                _storeOffsets =
+                    _indexOptions.Value.CompareTo(FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
             }
 
-            public PulsingDocsAndPositionsEnum reset(Bits liveDocs, PulsingTermState termState)
+            public PulsingDocsAndPositionsEnum Reset(Bits liveDocs, PulsingTermState termState)
             {
-                Debug.Debug.Assert((termState.PostingsSize != -1);
+                Debug.Assert(termState.PostingsSize != -1);
 
-                if (postingsBytes == null)
+                if (_postingsBytes == null)
                 {
-                    postingsBytes = new byte[termState.PostingsSize];
+                    _postingsBytes = new byte[termState.PostingsSize];
                 }
-                else if (postingsBytes.Length < termState.PostingsSize)
+                else if (_postingsBytes.Length < termState.PostingsSize)
                 {
-                    postingsBytes = ArrayUtil.Grow(postingsBytes, termState.PostingsSize);
+                    _postingsBytes = ArrayUtil.Grow(_postingsBytes, termState.PostingsSize);
                 }
 
-                System.Array.Copy(termState.Postings, 0, postingsBytes, 0, termState.PostingsSize);
-                postings.Reset(postingsBytes, 0, termState.PostingsSize);
-                this.liveDocs = liveDocs;
-                payloadLength = 0;
-                posPending = 0;
-                docID = -1;
-                accum = 0;
-                cost = termState.DocFreq;
-                startOffset = storeOffsets ? 0 : -1; // always return -1 if no offsets are stored
-                offsetLength = 0;
+                Array.Copy(termState.Postings, 0, _postingsBytes, 0, termState.PostingsSize);
+                _postings.Reset(_postingsBytes, 0, termState.PostingsSize);
+                this._liveDocs = liveDocs;
+                _payloadLength = 0;
+                _posPending = 0;
+                _docId = -1;
+                _accum = 0;
+                _cost = termState.DocFreq;
+                _startOffset = _storeOffsets ? 0 : -1; // always return -1 if no offsets are stored
+                _offsetLength = 0;
                 //System.out.println("PR d&p reset storesPayloads=" + storePayloads + " bytes=" + bytes.length + " this=" + this);
                 return this;
             }
 
             public bool CanReuse(FieldInfo fieldInfo)
             {
-                return indexOptions == fieldInfo.IndexOptions && storePayloads == fieldInfo.HasPayloads();
+                return _indexOptions == fieldInfo.FieldIndexOptions && _storePayloads == fieldInfo.HasPayloads();
             }
 
             public override int NextDoc()
             {
-
                 while (true)
                 {
-
                     SkipPositions();
 
-                    if (postings.Eof())
+                    if (_postings.Eof())
                     {
-                        return docID = NO_MORE_DOCS;
+                        return _docId = NO_MORE_DOCS;
                     }
 
-                    int code = postings.ReadVInt();
-                    accum += (int)((uint)code >> 1); // shift off low bit 
-                    if ((code & 1) != 0)
-                    {
-                        // if low bit is set
-                        freq = 1; // freq is one
-                    }
-                    else
-                    {
-                        freq = postings.ReadVInt(); // else read freq
-                    }
-                    posPending = freq;
-                    startOffset = storeOffsets ? 0 : -1; // always return -1 if no offsets are stored
+                    var code = _postings.ReadVInt();
+                    _accum += (int)((uint)code >> 1); // shift off low bit 
+                    _freq = (code & 1) != 0 ? 1 : _postings.ReadVInt();
+                    _posPending = _freq;
+                    _startOffset = _storeOffsets ? 0 : -1; // always return -1 if no offsets are stored
 
-                    if (liveDocs == null || liveDocs.Get(accum))
-                    {
-                        position = 0;
-                        return (docID = accum);
-                    }
+                    if (_liveDocs != null && !_liveDocs.Get(_accum)) continue;
+
+                    _position = 0;
+                    return (_docId = _accum);
                 }
             }
 
             public override int Freq()
             {
-                return freq;
+                return _freq;
             }
 
             public override int DocID()
             {
-                return docID;
+                return _docId;
             }
 
             public override int Advance(int target)
             {
-                return docID = SlowAdvance(target);
+                return _docId = SlowAdvance(target);
             }
 
             public override int NextPosition()
             {
-                Debug.Debug.Assert((posPending > 0);
+                Debug.Assert(_posPending > 0);
 
-                posPending--;
+                _posPending--;
 
-                if (storePayloads)
+                if (_storePayloads)
                 {
-                    if (!payloadRetrieved)
+                    if (!_payloadRetrieved)
                     {
-                        postings.SkipBytes(payloadLength);
+                        _postings.SkipBytes(_payloadLength);
                     }
-                    int code = postings.ReadVInt();
+                    int code = _postings.ReadVInt();
                     if ((code & 1) != 0)
                     {
-                        payloadLength = postings.ReadVInt();
+                        _payloadLength = _postings.ReadVInt();
                     }
-                    position += (int)((uint)code >> 1);
-                    payloadRetrieved = false;
+                    _position += (int)((uint)code >> 1);
+                    _payloadRetrieved = false;
                 }
                 else
                 {
-                    position += postings.ReadVInt();
+                    _position += _postings.ReadVInt();
                 }
 
-                if (storeOffsets)
+                if (_storeOffsets)
                 {
-                    int offsetCode = postings.ReadVInt();
+                    int offsetCode = _postings.ReadVInt();
                     if ((offsetCode & 1) != 0)
                     {
                         // new offset length
-                        offsetLength = postings.ReadVInt();
+                        _offsetLength = _postings.ReadVInt();
                     }
-                    startOffset += (int)((uint)offsetCode >> 1);
+                    _startOffset += (int)((uint)offsetCode >> 1);
                 }
 
-                return position;
+                return _position;
             }
 
             public override int StartOffset()
             {
-                return startOffset;
+                return _startOffset;
             }
 
             public override int EndOffset()
             {
-                return startOffset + offsetLength;
+                return _startOffset + _offsetLength;
             }
 
             public override BytesRef Payload
             {
                 get
                 {
-                    if (payloadRetrieved)
-                    {
-                        return payload;
-                    }
-                    else if (storePayloads && payloadLength > 0)
+                    if (_payloadRetrieved)
+                        return _payload;
+                    
+                    if (_storePayloads && _payloadLength > 0)
                     {
-                        payloadRetrieved = true;
-                        if (payload == null)
+                        _payloadRetrieved = true;
+                        if (_payload == null)
                         {
-                            payload = new BytesRef(payloadLength);
+                            _payload = new BytesRef(_payloadLength);
                         }
                         else
                         {
-                            payload.Grow(payloadLength);
+                            _payload.Grow(_payloadLength);
                         }
-                        postings.ReadBytes(payload.Bytes, 0, payloadLength);
-                        payload.Length = payloadLength;
-                        return payload;
-                    }
-                    else
-                    {
-                        return null;
+                        _postings.ReadBytes(_payload.Bytes, 0, _payloadLength);
+                        _payload.Length = _payloadLength;
+                        return _payload;
                     }
+                    
+                    return null;
                 }
             }
 
             private void SkipPositions()
             {
-                while (posPending != 0)
+                while (_posPending != 0)
                 {
                     NextPosition();
                 }
-                if (storePayloads && !payloadRetrieved)
+                if (_storePayloads && !_payloadRetrieved)
                 {
-                    postings.SkipBytes(payloadLength);
-                    payloadRetrieved = true;
+                    _postings.SkipBytes(_payloadLength);
+                    _payloadRetrieved = true;
                 }
             }
             
             public override long Cost()
             {
-                return cost;
+                return _cost;
             }
         }
         

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6d9a6ffa/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 528f8de..82fe52a 100644
--- a/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsWriter.cs
+++ b/src/Lucene.Net.Codecs/Pulsing/PulsingPostingsWriter.cs
@@ -15,15 +15,14 @@
  * limitations under the License.
  */
 
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using Lucene.Net.Index;
-using Lucene.Net.Store;
-using Lucene.Net.Util;
-
 namespace Lucene.Net.Codecs.Pulsing
 {
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using Index;
+    using Store;
+    using Util;
 
     /// <summary>
     /// TODO: we now inline based on total TF of the term,
@@ -53,36 +52,36 @@ namespace Lucene.Net.Codecs.Pulsing
         internal static readonly int VERSION_META_ARRAY = 1;
         internal static readonly int VERSION_CURRENT = VERSION_META_ARRAY;
 
-        private SegmentWriteState segmentState;
-        private IndexOutput termsOut;
-        private List<FieldMetaData> fields;
-        private FieldInfo.IndexOptions_e? indexOptions;
-        private bool storePayloads;
+        private readonly SegmentWriteState _segmentState;
+        private IndexOutput _termsOut;
+        private readonly List<FieldMetaData> _fields;
+        private FieldInfo.IndexOptions? _indexOptions;
+        private bool _storePayloads;
 
         // information for wrapped PF, in current field
-        private int longsSize;
-        private long[] longs;
-        private bool absolute;
+        private int _longsSize;
+        private long[] _longs;
+        private bool _absolute;
 
         private class PulsingTermState : BlockTermState
         {
-            internal byte[] bytes;
-            internal BlockTermState wrappedState;
+            internal byte[] BYTES;
+            internal BlockTermState WRAPPED_STATE;
 
             public override String ToString()
             {
-                if (bytes != null)
+                if (BYTES != null)
                 {
                     return "inlined";
                 }
-                return "not inlined wrapped=" + wrappedState;
+                return "not inlined wrapped=" + WRAPPED_STATE;
             }
         }
 
         // one entry per position
-        private Position[] pending;
-        private int pendingCount = 0;   // -1 once we've hit too many positions
-        private Position currentDoc;    // first Position entry of current doc
+        private readonly Position[] _pending;
+        private int _pendingCount = 0;   // -1 once we've hit too many positions
+        private Position _currentDoc;    // first Position entry of current doc
 
         private sealed class Position
         {
@@ -114,43 +113,42 @@ namespace Lucene.Net.Codecs.Pulsing
 
         /// <summary>
         /// If the total number of positions (summed across all docs
-        /// for this term) is <= maxPositions, then the postings are
+        /// for this term) is less than or equal maxPositions, then the postings are
         /// inlined into terms dict
         /// </summary>
         public PulsingPostingsWriter(SegmentWriteState state, int maxPositions, PostingsWriterBase wrappedPostingsWriter)
         {
 
-            pending = new Position[maxPositions];
-            for (int i = 0; i < maxPositions; i++)
+            _pending = new Position[maxPositions];
+            for (var i = 0; i < maxPositions; i++)
             {
-                pending[i] = new Position();
+                _pending[i] = new Position();
             }
-            fields = new List<FieldMetaData>();
+            _fields = new List<FieldMetaData>();
 
             // We simply wrap another postings writer, but only call
             // on it when tot positions is >= the cutoff:
-            this._wrappedPostingsWriter = wrappedPostingsWriter;
-            this.segmentState = state;
+            _wrappedPostingsWriter = wrappedPostingsWriter;
+            _segmentState = state;
         }
 
         public override void Init(IndexOutput termsOut)
         {
-            this.termsOut = termsOut;
+            _termsOut = termsOut;
             CodecUtil.WriteHeader(termsOut, CODEC, VERSION_CURRENT);
-            termsOut.WriteVInt(pending.Length); // encode maxPositions in header
+            termsOut.WriteVInt(_pending.Length); // encode maxPositions in header
             _wrappedPostingsWriter.Init(termsOut);
         }
 
         public override BlockTermState NewTermState()
         {
-            PulsingTermState state = new PulsingTermState();
-            state.wrappedState = _wrappedPostingsWriter.NewTermState();
+            var state = new PulsingTermState {WRAPPED_STATE = _wrappedPostingsWriter.NewTermState()};
             return state;
         }
 
         public override void StartTerm()
         {
-            Debug.Debug.Assert((pendingCount == 0);
+            Debug.Assert(_pendingCount == 0);
         }
 
         /// <summary>
@@ -163,61 +161,61 @@ namespace Lucene.Net.Codecs.Pulsing
         /// <returns></returns>
         public override int SetField(FieldInfo fieldInfo)
         {
-            this.indexOptions = fieldInfo.IndexOptions;
-            storePayloads = fieldInfo.HasPayloads();
-            absolute = false;
-            longsSize = _wrappedPostingsWriter.SetField(fieldInfo);
-            longs = new long[longsSize];
-            fields.Add(new FieldMetaData(fieldInfo.Number, longsSize));
+            _indexOptions = fieldInfo.FieldIndexOptions;
+            _storePayloads = fieldInfo.HasPayloads();
+            _absolute = false;
+            _longsSize = _wrappedPostingsWriter.SetField(fieldInfo);
+            _longs = new long[_longsSize];
+            _fields.Add(new FieldMetaData(fieldInfo.Number, _longsSize));
             return 0;
         }
 
-        public override void StartDoc(int docID, int termDocFreq)
+        public override void StartDoc(int docId, int termDocFreq)
         {
-            Debug.Debug.Assert((docID >= 0, "Got DocID=" + docID);
+            Debug.Assert(docId >= 0, "Got DocID=" + docId);
 
-            if (pendingCount == pending.Length)
+            if (_pendingCount == _pending.Length)
             {
-                push();
+                Push();
                 _wrappedPostingsWriter.FinishDoc();
             }
 
-            if (pendingCount != -1)
+            if (_pendingCount != -1)
             {
-                Debug.Debug.Assert((pendingCount < pending.Length);
-                currentDoc = pending[pendingCount];
-                currentDoc.docID = docID;
-                if (indexOptions == FieldInfo.IndexOptions_e.DOCS_ONLY)
+                Debug.Assert(_pendingCount < _pending.Length);
+                _currentDoc = _pending[_pendingCount];
+                _currentDoc.docID = docId;
+                if (_indexOptions == FieldInfo.IndexOptions.DOCS_ONLY)
                 {
-                    pendingCount++;
+                    _pendingCount++;
                 }
-                else if (indexOptions == FieldInfo.IndexOptions_e.DOCS_AND_FREQS)
+                else if (_indexOptions == FieldInfo.IndexOptions.DOCS_AND_FREQS)
                 {
-                    pendingCount++;
-                    currentDoc.termFreq = termDocFreq;
+                    _pendingCount++;
+                    _currentDoc.termFreq = termDocFreq;
                 }
                 else
                 {
-                    currentDoc.termFreq = termDocFreq;
+                    _currentDoc.termFreq = termDocFreq;
                 }
             }
             else
             {
                 // We've already seen too many docs for this term --
                 // just forward to our fallback writer
-                _wrappedPostingsWriter.StartDoc(docID, termDocFreq);
+                _wrappedPostingsWriter.StartDoc(docId, termDocFreq);
             }
         }
 
         public override void AddPosition(int position, BytesRef payload, int startOffset, int endOffset)
         {
 
-            if (pendingCount == pending.Length)
+            if (_pendingCount == _pending.Length)
             {
-                push();
+                Push();
             }
 
-            if (pendingCount == -1)
+            if (_pendingCount == -1)
             {
                 // We've already seen too many docs for this term --
                 // just forward to our fallback writer
@@ -226,11 +224,11 @@ namespace Lucene.Net.Codecs.Pulsing
             else
             {
                 // buffer up
-                Position pos = pending[pendingCount++];
+                Position pos = _pending[_pendingCount++];
                 pos.pos = position;
                 pos.startOffset = startOffset;
                 pos.endOffset = endOffset;
-                pos.docID = currentDoc.docID;
+                pos.docID = _currentDoc.docID;
                 if (payload != null && payload.Length > 0)
                 {
                     if (pos.payload == null)
@@ -251,13 +249,13 @@ namespace Lucene.Net.Codecs.Pulsing
 
         public override void FinishDoc()
         {
-            if (pendingCount == -1)
+            if (_pendingCount == -1)
             {
                 _wrappedPostingsWriter.FinishDoc();
             }
         }
 
-        private readonly RAMOutputStream buffer = new RAMOutputStream();
+        private readonly RAMOutputStream _buffer = new RAMOutputStream();
 
         /// <summary>
         /// Called when we are done adding docs to this term
@@ -265,16 +263,16 @@ namespace Lucene.Net.Codecs.Pulsing
         /// <param name="_state"></param>
         public override void FinishTerm(BlockTermState _state)
         {
-            PulsingTermState state = (PulsingTermState) _state;
+            var state = (PulsingTermState) _state;
 
-            Debug.Debug.Assert((pendingCount > 0 || pendingCount == -1);
+            Debug.Assert(_pendingCount > 0 || _pendingCount == -1);
 
-            if (pendingCount == -1)
+            if (_pendingCount == -1)
             {
-                state.wrappedState.DocFreq = state.DocFreq;
-                state.wrappedState.TotalTermFreq = state.TotalTermFreq;
-                state.bytes = null;
-                _wrappedPostingsWriter.FinishTerm(state.wrappedState);
+                state.WRAPPED_STATE.DocFreq = state.DocFreq;
+                state.WRAPPED_STATE.TotalTermFreq = state.TotalTermFreq;
+                state.BYTES = null;
+                _wrappedPostingsWriter.FinishTerm(state.WRAPPED_STATE);
             }
             else
             {
@@ -288,72 +286,72 @@ namespace Lucene.Net.Codecs.Pulsing
                 // given codec wants to store other interesting
                 // stuff, it could use this pulsing codec to do so
 
-                if (indexOptions.Value.CompareTo(FieldInfo.IndexOptions_e.DOCS_AND_FREQS_AND_POSITIONS) >= 0)
+                if (_indexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)
                 {
-                    int lastDocID = 0;
-                    int pendingIDX = 0;
-                    int lastPayloadLength = -1;
-                    int lastOffsetLength = -1;
-                    while (pendingIDX < pendingCount)
+                    var lastDocID = 0;
+                    var pendingIDX = 0;
+                    var lastPayloadLength = -1;
+                    var lastOffsetLength = -1;
+                    while (pendingIDX < _pendingCount)
                     {
-                        Position doc = pending[pendingIDX];
+                        var doc = _pending[pendingIDX];
 
-                        int delta = doc.docID - lastDocID;
+                        var delta = doc.docID - lastDocID;
                         lastDocID = doc.docID;
 
                         // if (DEBUG) System.out.println("  write doc=" + doc.docID + " freq=" + doc.termFreq);
 
                         if (doc.termFreq == 1)
                         {
-                            buffer.WriteVInt((delta << 1) | 1);
+                            _buffer.WriteVInt((delta << 1) | 1);
                         }
                         else
                         {
-                            buffer.WriteVInt(delta << 1);
-                            buffer.WriteVInt(doc.termFreq);
+                            _buffer.WriteVInt(delta << 1);
+                            _buffer.WriteVInt(doc.termFreq);
                         }
 
-                        int lastPos = 0;
-                        int lastOffset = 0;
-                        for (int posIDX = 0; posIDX < doc.termFreq; posIDX++)
+                        var lastPos = 0;
+                        var lastOffset = 0;
+                        for (var posIDX = 0; posIDX < doc.termFreq; posIDX++)
                         {
-                            Position pos = pending[pendingIDX++];
-                            Debug.Debug.Assert((pos.docID == doc.docID);
-                            int posDelta = pos.pos - lastPos;
+                            var pos = _pending[pendingIDX++];
+                            Debug.Assert(pos.docID == doc.docID);
+                            var posDelta = pos.pos - lastPos;
                             lastPos = pos.pos;
                             
-                            int payloadLength = pos.payload == null ? 0 : pos.payload.Length;
-                            if (storePayloads)
+                            var payloadLength = pos.payload == null ? 0 : pos.payload.Length;
+                            if (_storePayloads)
                             {
                                 if (payloadLength != lastPayloadLength)
                                 {
-                                    buffer.WriteVInt((posDelta << 1) | 1);
-                                    buffer.WriteVInt(payloadLength);
+                                    _buffer.WriteVInt((posDelta << 1) | 1);
+                                    _buffer.WriteVInt(payloadLength);
                                     lastPayloadLength = payloadLength;
                                 }
                                 else
                                 {
-                                    buffer.WriteVInt(posDelta << 1);
+                                    _buffer.WriteVInt(posDelta << 1);
                                 }
                             }
                             else
                             {
-                                buffer.WriteVInt(posDelta);
+                                _buffer.WriteVInt(posDelta);
                             }
 
-                            if (indexOptions.Value.CompareTo(FieldInfo.IndexOptions_e.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0)
+                            if (_indexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS)
                             {
                                 //System.out.println("write=" + pos.startOffset + "," + pos.endOffset);
-                                int offsetDelta = pos.startOffset - lastOffset;
-                                int offsetLength = pos.endOffset - pos.startOffset;
+                                var offsetDelta = pos.startOffset - lastOffset;
+                                var offsetLength = pos.endOffset - pos.startOffset;
                                 if (offsetLength != lastOffsetLength)
                                 {
-                                    buffer.WriteVInt(offsetDelta << 1 | 1);
-                                    buffer.WriteVInt(offsetLength);
+                                    _buffer.WriteVInt(offsetDelta << 1 | 1);
+                                    _buffer.WriteVInt(offsetLength);
                                 }
                                 else
                                 {
-                                    buffer.WriteVInt(offsetDelta << 1);
+                                    _buffer.WriteVInt(offsetDelta << 1);
                                 }
                                 lastOffset = pos.startOffset;
                                 lastOffsetLength = offsetLength;
@@ -361,73 +359,79 @@ namespace Lucene.Net.Codecs.Pulsing
 
                             if (payloadLength > 0)
                             {
-                                Debug.Debug.Assert((storePayloads);
-                                buffer.WriteBytes(pos.payload.Bytes, 0, pos.payload.Length);
+                                Debug.Assert(_storePayloads);
+                                _buffer.WriteBytes(pos.payload.Bytes, 0, pos.payload.Length);
                             }
                         }
                     }
                 }
-                else if (indexOptions == FieldInfo.IndexOptions_e.DOCS_AND_FREQS)
+                else switch (_indexOptions)
                 {
-                    int lastDocID = 0;
-                    for (int posIDX = 0; posIDX < pendingCount; posIDX++)
+                    case FieldInfo.IndexOptions.DOCS_AND_FREQS:
                     {
-                        Position doc = pending[posIDX];
-                        int delta = doc.docID - lastDocID;
-                        Debug.Debug.Assert((doc.termFreq != 0);
-
-                        if (doc.termFreq == 1)
-                        {
-                            buffer.WriteVInt((delta << 1) | 1);
-                        }
-                        else
+                        var lastDocId = 0;
+                        for (var posIdx = 0; posIdx < _pendingCount; posIdx++)
                         {
-                            buffer.WriteVInt(delta << 1);
-                            buffer.WriteVInt(doc.termFreq);
+                            var doc = _pending[posIdx];
+                            var delta = doc.docID - lastDocId;
+
+                            Debug.Assert(doc.termFreq != 0);
+
+                            if (doc.termFreq == 1)
+                            {
+                                _buffer.WriteVInt((delta << 1) | 1);
+                            }
+                            else
+                            {
+                                _buffer.WriteVInt(delta << 1);
+                                _buffer.WriteVInt(doc.termFreq);
+                            }
+                            lastDocId = doc.docID;
                         }
-                        lastDocID = doc.docID;
                     }
-                }
-                else if (indexOptions == FieldInfo.IndexOptions_e.DOCS_ONLY)
-                {
-                    int lastDocID = 0;
-                    for (int posIDX = 0; posIDX < pendingCount; posIDX++)
+                        break;
+                    case FieldInfo.IndexOptions.DOCS_ONLY:
                     {
-                        Position doc = pending[posIDX];
-                        buffer.WriteVInt(doc.docID - lastDocID);
-                        lastDocID = doc.docID;
+                        var lastDocId = 0;
+                        for (var posIdx = 0; posIdx < _pendingCount; posIdx++)
+                        {
+                            var doc = _pending[posIdx];
+                            _buffer.WriteVInt(doc.docID - lastDocId);
+                            lastDocId = doc.docID;
+                        }
                     }
+                        break;
                 }
 
-                state.bytes = new byte[(int) buffer.FilePointer];
-                buffer.WriteTo((sbyte[])(Array)state.bytes, 0);
-                buffer.Reset();
+                state.BYTES = new byte[(int) _buffer.FilePointer];
+                _buffer.WriteTo((sbyte[])(Array)state.BYTES, 0);
+                _buffer.Reset();
             }
-            pendingCount = 0;
+            _pendingCount = 0;
         }
 
-        public override void EncodeTerm(long[] empty, DataOutput output, FieldInfo fieldInfo, BlockTermState _state,
-            bool absolute)
+        public override void EncodeTerm(long[] empty, DataOutput output, FieldInfo fieldInfo, BlockTermState state,
+            bool abs)
         {
-            PulsingTermState state = (PulsingTermState) _state;
-            Debug.Debug.Assert((empty.Length == 0);
-            this.absolute = this.absolute || absolute;
-            if (state.bytes == null)
+            var _state = (PulsingTermState) state;
+            Debug.Assert(empty.Length == 0);
+            _absolute = _absolute || abs;
+            if (_state.BYTES == null)
             {
-                _wrappedPostingsWriter.EncodeTerm(longs, buffer, fieldInfo, state.wrappedState, this.absolute);
-                for (int i = 0; i < longsSize; i++)
+                _wrappedPostingsWriter.EncodeTerm(_longs, _buffer, fieldInfo, _state.WRAPPED_STATE, _absolute);
+                for (var i = 0; i < _longsSize; i++)
                 {
-                    output.WriteVLong(longs[i]);
+                    output.WriteVLong(_longs[i]);
                 }
-                buffer.WriteTo(output);
-                buffer.Reset();
-                this.absolute = false;
+                _buffer.WriteTo(output);
+                _buffer.Reset();
+                _absolute = false;
             }
             else
             {
-                output.WriteVInt(state.bytes.Length);
-                output.WriteBytes(state.bytes, 0, state.bytes.Length);
-                this.absolute = this.absolute || absolute;
+                output.WriteVInt(_state.BYTES.Length);
+                output.WriteBytes(_state.BYTES, 0, _state.BYTES.Length);
+                _absolute = _absolute || abs;
             }
         }
 
@@ -441,16 +445,16 @@ namespace Lucene.Net.Codecs.Pulsing
                 return;
             }
 
-            String summaryFileName = IndexFileNames.SegmentFileName(segmentState.SegmentInfo.Name,
-                segmentState.SegmentSuffix, SUMMARY_EXTENSION);
+            var summaryFileName = IndexFileNames.SegmentFileName(_segmentState.SegmentInfo.Name,
+                _segmentState.SegmentSuffix, SUMMARY_EXTENSION);
             IndexOutput output = null;
             try
             {
                 output =
-                    segmentState.Directory.CreateOutput(summaryFileName, segmentState.Context);
+                    _segmentState.Directory.CreateOutput(summaryFileName, _segmentState.Context);
                 CodecUtil.WriteHeader(output, CODEC, VERSION_CURRENT);
-                output.WriteVInt(fields.Count);
-                foreach (FieldMetaData field in fields)
+                output.WriteVInt(_fields.Count);
+                foreach (var field in _fields)
                 {
                     output.WriteVInt(field.FieldNumber);
                     output.WriteVInt(field.LongsSize);
@@ -464,48 +468,43 @@ namespace Lucene.Net.Codecs.Pulsing
         }
 
         // Pushes pending positions to the wrapped codec
-        private void push()
+        private void Push()
         {
-            // if (DEBUG) System.out.println("PW now push @ " + pendingCount + " wrapped=" + wrappedPostingsWriter);
-            Debug.Debug.Assert((pendingCount == pending.Length);
+            Debug.Assert(_pendingCount == _pending.Length);
 
             _wrappedPostingsWriter.StartTerm();
 
             // Flush all buffered docs
-            if (indexOptions.Value.CompareTo(FieldInfo.IndexOptions_e.DOCS_AND_FREQS_AND_POSITIONS) >= 0)
+            if (_indexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS)
             {
                 Position doc = null;
 
-                foreach(Position pos in pending)
+                foreach(var pos in _pending)
                 {
                     if (doc == null)
                     {
                         doc = pos;
-                        // if (DEBUG) System.out.println("PW: wrapped.startDoc docID=" + doc.docID + " tf=" + doc.termFreq);
                         _wrappedPostingsWriter.StartDoc(doc.docID, doc.termFreq);
                     }
                     else if (doc.docID != pos.docID)
                     {
-                        Debug.Debug.Assert((pos.docID > doc.docID);
-                        // if (DEBUG) System.out.println("PW: wrapped.finishDoc");
+                        Debug.Assert(pos.docID > doc.docID);
                         _wrappedPostingsWriter.FinishDoc();
                         doc = pos;
-                        // if (DEBUG) System.out.println("PW: wrapped.startDoc docID=" + doc.docID + " tf=" + doc.termFreq);
                         _wrappedPostingsWriter.StartDoc(doc.docID, doc.termFreq);
                     }
-                    // if (DEBUG) System.out.println("PW:   wrapped.addPos pos=" + pos.pos);
                     _wrappedPostingsWriter.AddPosition(pos.pos, pos.payload, pos.startOffset, pos.endOffset);
                 }
                 //wrappedPostingsWriter.finishDoc();
             }
             else
             {
-                foreach(Position doc in pending)
+                foreach(var doc in _pending)
                 {
-                    _wrappedPostingsWriter.StartDoc(doc.docID, indexOptions == FieldInfo.IndexOptions_e.DOCS_ONLY ? 0 : doc.termFreq);
+                    _wrappedPostingsWriter.StartDoc(doc.docID, _indexOptions == FieldInfo.IndexOptions.DOCS_ONLY ? 0 : doc.termFreq);
                 }
             }
-            pendingCount = -1;
+            _pendingCount = -1;
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6d9a6ffa/src/Lucene.Net.Core/Codecs/PostingsConsumer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/PostingsConsumer.cs b/src/Lucene.Net.Core/Codecs/PostingsConsumer.cs
index 8515972..65710df 100644
--- a/src/Lucene.Net.Core/Codecs/PostingsConsumer.cs
+++ b/src/Lucene.Net.Core/Codecs/PostingsConsumer.cs
@@ -63,7 +63,7 @@ namespace Lucene.Net.Codecs
         /// <code>freq</code> will be -1 when term frequencies are omitted
         /// for the field.
         /// </summary>
-        public abstract void StartDoc(int docID, int freq);
+        public abstract void StartDoc(int docId, int freq);
 
         /// <summary>
         /// Add a new position & payload, and start/end offset.  A