You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by pn...@apache.org on 2014/09/15 01:28:09 UTC

[1/2] git commit: Clean up Appending, Bloom and DiskDV code

Repository: lucenenet
Updated Branches:
  refs/heads/master 17db2acd2 -> 6e900565d


Clean up Appending, Bloom and DiskDV code


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

Branch: refs/heads/master
Commit: 02f232e79a11cbcaf59f4519c373f2cf7f266e26
Parents: 17db2ac
Author: Prescott Nasser <pn...@apache.org>
Authored: Sun Sep 14 15:48:19 2014 -0700
Committer: Prescott Nasser <pn...@apache.org>
Committed: Sun Sep 14 15:48:19 2014 -0700

----------------------------------------------------------------------
 .../Appending/AppendingCodec.cs                 |   2 +-
 .../Appending/AppendingPostingsFormat.cs        |  33 +--
 .../Appending/AppendingTermsReader.cs           |   4 +-
 .../Bloom/BloomFilterFactory.cs                 |   2 +-
 .../Bloom/BloomFilteringPostingsFormat.cs       | 273 +++++++++---------
 .../Bloom/DefaultBloomFilterFactory.cs          |   2 +-
 src/Lucene.Net.Codecs/Bloom/FuzzySet.cs         | 280 +++++++++----------
 src/Lucene.Net.Codecs/Bloom/HashFunction.cs     |   2 +-
 src/Lucene.Net.Codecs/Bloom/MurmurHash2.cs      |   9 +-
 .../DiskDV/DiskDocValuesFormat.cs               |   6 +-
 .../DiskDV/DiskDocValuesProducer.cs             |   8 +-
 src/Lucene.Net.Codecs/DiskDV/DiskNormsFormat.cs |   6 +-
 12 files changed, 290 insertions(+), 337 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02f232e7/src/Lucene.Net.Codecs/Appending/AppendingCodec.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Appending/AppendingCodec.cs b/src/Lucene.Net.Codecs/Appending/AppendingCodec.cs
index 01248d6..0fc3589 100644
--- a/src/Lucene.Net.Codecs/Appending/AppendingCodec.cs
+++ b/src/Lucene.Net.Codecs/Appending/AppendingCodec.cs
@@ -18,7 +18,7 @@
 namespace Lucene.Net.Codecs.Appending
 {
     using System;
-    using Lucene.Net.Codecs.Lucene40;
+    using Lucene40;
 
     /// <summary>
     /// This codec uses an index format that is very similar to Lucene40Codec 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02f232e7/src/Lucene.Net.Codecs/Appending/AppendingPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Appending/AppendingPostingsFormat.cs b/src/Lucene.Net.Codecs/Appending/AppendingPostingsFormat.cs
index 8e3f770..ff427dc 100644
--- a/src/Lucene.Net.Codecs/Appending/AppendingPostingsFormat.cs
+++ b/src/Lucene.Net.Codecs/Appending/AppendingPostingsFormat.cs
@@ -18,8 +18,8 @@
 namespace Lucene.Net.Codecs.Appending
 {
     using System;
-    using Lucene.Net.Codecs.Lucene40;
-    using Lucene.Net.Index;
+    using Lucene40;
+    using Index;
 
     /// <summary>
     /// Appending Postigns Implementation
@@ -38,26 +38,21 @@ namespace Lucene.Net.Codecs.Appending
 
         public override FieldsProducer FieldsProducer(SegmentReadState state)
         {
-            PostingsReaderBase postings = new Lucene40PostingsReader(state.Directory, state.FieldInfos,
+            using (var postings = new Lucene40PostingsReader(state.Directory, state.FieldInfos,
                 state.SegmentInfo,
-                state.Context, state.SegmentSuffix);
-
-            var success = false;
-            FieldsProducer ret;
-            using (ret = new AppendingTermsReader(
-                state.Directory,
-                state.FieldInfos,
-                state.SegmentInfo,
-                postings,
-                state.Context,
-                state.SegmentSuffix,
-                state.TermsIndexDivisor))
+                state.Context, state.SegmentSuffix))
             {
-                success = true;
+                var ret = new AppendingTermsReader(
+                    state.Directory,
+                    state.FieldInfos,
+                    state.SegmentInfo,
+                    postings,
+                    state.Context,
+                    state.SegmentSuffix,
+                    state.TermsIndexDivisor);
+
+                return ret;
             }
-
-            return ret;
-            
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02f232e7/src/Lucene.Net.Codecs/Appending/AppendingTermsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Appending/AppendingTermsReader.cs b/src/Lucene.Net.Codecs/Appending/AppendingTermsReader.cs
index da4e33f..b309f5d 100644
--- a/src/Lucene.Net.Codecs/Appending/AppendingTermsReader.cs
+++ b/src/Lucene.Net.Codecs/Appending/AppendingTermsReader.cs
@@ -18,8 +18,8 @@
 namespace Lucene.Net.Codecs.Appending
 {
     using System;
-    using Lucene.Net.Index;
-    using Lucene.Net.Store;
+    using Index;
+    using Store;
 
     /// <summary>
     /// Reads append-only terms from AppendingTermsWriter.

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02f232e7/src/Lucene.Net.Codecs/Bloom/BloomFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Bloom/BloomFilterFactory.cs b/src/Lucene.Net.Codecs/Bloom/BloomFilterFactory.cs
index 6bac454..d443f6e 100644
--- a/src/Lucene.Net.Codecs/Bloom/BloomFilterFactory.cs
+++ b/src/Lucene.Net.Codecs/Bloom/BloomFilterFactory.cs
@@ -18,7 +18,7 @@
 namespace Lucene.Net.Codecs.Bloom
 {
 
-    using Lucene.Net.Index;
+    using Index;
 
     /// <summary>
     /// Class used to create index-time {@link FuzzySet} appropriately configured for

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02f232e7/src/Lucene.Net.Codecs/Bloom/BloomFilteringPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Bloom/BloomFilteringPostingsFormat.cs b/src/Lucene.Net.Codecs/Bloom/BloomFilteringPostingsFormat.cs
index eb710b8..5cd2f21 100644
--- a/src/Lucene.Net.Codecs/Bloom/BloomFilteringPostingsFormat.cs
+++ b/src/Lucene.Net.Codecs/Bloom/BloomFilteringPostingsFormat.cs
@@ -15,18 +15,19 @@
  * limitations under the License.
  */
 
+using System.Linq;
+
 namespace Lucene.Net.Codecs.Bloom
 {
 
     using System;
     using System.Collections.Generic;
     using System.Diagnostics;
-    using Lucene.Net.Index;
-    using Lucene.Net.Search;
-    using Lucene.Net.Store;
-    using Lucene.Net.Support;
-    using Lucene.Net.Util;
-    using Lucene.Net.Util.Automaton;
+    using Index;
+    using Store;
+    using Support;
+    using Util;
+    using Util.Automaton;
 
     /// <summary>
     /// 
@@ -66,10 +67,10 @@ namespace Lucene.Net.Codecs.Bloom
         public static readonly int VERSION_CURRENT = VERSION_CHECKSUM;
 
         /** Extension of Bloom Filters file */
-        private static readonly String BLOOM_EXTENSION = "blm";
+        private const String BLOOM_EXTENSION = "blm";
 
-        private BloomFilterFactory bloomFilterFactory = new DefaultBloomFilterFactory();
-        private PostingsFormat delegatePostingsFormat;
+        private readonly BloomFilterFactory _bloomFilterFactory = new DefaultBloomFilterFactory();
+        private readonly PostingsFormat _delegatePostingsFormat;
         
         /// <summary>
         ///  Creates Bloom filters for a selection of fields created in the index. This
@@ -82,8 +83,8 @@ namespace Lucene.Net.Codecs.Bloom
         public BloomFilteringPostingsFormat(PostingsFormat delegatePostingsFormat,
             BloomFilterFactory bloomFilterFactory) : base(BLOOM_CODEC_NAME)
         {
-            this.delegatePostingsFormat = delegatePostingsFormat;
-            this.bloomFilterFactory = bloomFilterFactory;
+            _delegatePostingsFormat = delegatePostingsFormat;
+            _bloomFilterFactory = bloomFilterFactory;
         }
 
         /// <summary>
@@ -110,13 +111,12 @@ namespace Lucene.Net.Codecs.Bloom
 
         public override FieldsConsumer FieldsConsumer(SegmentWriteState state)
         {
-            if (delegatePostingsFormat == null)
+            if (_delegatePostingsFormat == null)
             {
                 throw new InvalidOperationException("Error - constructed without a choice of PostingsFormat");
             }
             return new BloomFilteredFieldsConsumer(
-                delegatePostingsFormat.FieldsConsumer(state), state,
-                delegatePostingsFormat);
+                _delegatePostingsFormat.FieldsConsumer(state), state, this);
         }
 
         public override FieldsProducer FieldsProducer(SegmentReadState state)
@@ -126,36 +126,36 @@ namespace Lucene.Net.Codecs.Bloom
 
         internal class BloomFilteredFieldsProducer : FieldsProducer
         {
-            private FieldsProducer delegateFieldsProducer;
-            private HashMap<String, FuzzySet> bloomsByFieldName = new HashMap<String, FuzzySet>();
+            private readonly FieldsProducer _delegateFieldsProducer;
+            private readonly HashMap<String, FuzzySet> _bloomsByFieldName = new HashMap<String, FuzzySet>();
 
             public BloomFilteredFieldsProducer(SegmentReadState state)
             {
 
-                String bloomFileName = IndexFileNames.SegmentFileName(
+                var bloomFileName = IndexFileNames.SegmentFileName(
                     state.SegmentInfo.Name, state.SegmentSuffix, BLOOM_EXTENSION);
                 ChecksumIndexInput bloomIn = null;
-                bool success = false;
+                var success = false;
                 try
                 {
                     bloomIn = state.Directory.OpenChecksumInput(bloomFileName, state.Context);
-                    int version = CodecUtil.CheckHeader(bloomIn, BLOOM_CODEC_NAME, VERSION_START, VERSION_CURRENT);
-                    // // Load the hash function used in the BloomFilter
+                    var version = CodecUtil.CheckHeader(bloomIn, BLOOM_CODEC_NAME, VERSION_START, VERSION_CURRENT);
+                    // Load the hash function used in the BloomFilter
                     // hashFunction = HashFunction.forName(bloomIn.readString());
                     // Load the delegate postings format
-                    PostingsFormat delegatePostingsFormat = PostingsFormat.ForName(bloomIn
-                        .ReadString());
+                    var delegatePostingsFormat = ForName(bloomIn.ReadString());
 
-                    this.delegateFieldsProducer = delegatePostingsFormat
+                    _delegateFieldsProducer = delegatePostingsFormat
                         .FieldsProducer(state);
-                    int numBlooms = bloomIn.ReadInt();
-                    for (int i = 0; i < numBlooms; i++)
+                    var numBlooms = bloomIn.ReadInt();
+                    for (var i = 0; i < numBlooms; i++)
                     {
-                        int fieldNum = bloomIn.ReadInt();
-                        FuzzySet bloom = FuzzySet.Deserialize(bloomIn);
-                        FieldInfo fieldInfo = state.FieldInfos.FieldInfo(fieldNum);
-                        bloomsByFieldName.Add(fieldInfo.Name, bloom);
+                        var fieldNum = bloomIn.ReadInt();
+                        var bloom = FuzzySet.Deserialize(bloomIn);
+                        var fieldInfo = state.FieldInfos.FieldInfo(fieldNum);
+                        _bloomsByFieldName.Add(fieldInfo.Name, bloom);
                     }
+                    
                     if (version >= VERSION_CHECKSUM)
                     {
                         CodecUtil.CheckFooter(bloomIn);
@@ -164,6 +164,7 @@ namespace Lucene.Net.Codecs.Bloom
                     {
                         CodecUtil.CheckEOF(bloomIn);
                     }
+                    
                     IOUtils.Close(bloomIn);
                     success = true;
                 }
@@ -171,53 +172,46 @@ namespace Lucene.Net.Codecs.Bloom
                 {
                     if (!success)
                     {
-                        IOUtils.CloseWhileHandlingException(bloomIn, delegateFieldsProducer);
+                        IOUtils.CloseWhileHandlingException(bloomIn, _delegateFieldsProducer);
                     }
                 }
             }
 
             public override IEnumerator<string> GetEnumerator()
             {
-                return delegateFieldsProducer.GetEnumerator();
+                return _delegateFieldsProducer.GetEnumerator();
             }
 
             public override Terms Terms(String field)
             {
-                FuzzySet filter = bloomsByFieldName[field];
+                var filter = _bloomsByFieldName[field];
                 if (filter == null)
-                {
-                    return delegateFieldsProducer.Terms(field);
-                }
-                else
-                {
-                    Terms result = delegateFieldsProducer.Terms(field);
-                    if (result == null)
-                    {
-                        return null;
-                    }
-                    return new BloomFilteredTerms(result, filter);
-                }
+                    return _delegateFieldsProducer.Terms(field);
+                
+                var result = _delegateFieldsProducer.Terms(field);
+                return result == null ? null : new BloomFilteredTerms(result, filter);
             }
 
             public override int Size()
             {
-                return delegateFieldsProducer.Size();
+                return _delegateFieldsProducer.Size();
             }
 
+            [Obsolete("iterate fields and add their size() instead.")]
             public override long UniqueTermCount
             {
-                get { return delegateFieldsProducer.UniqueTermCount; }
+                get { return _delegateFieldsProducer.UniqueTermCount; }
             }
 
             public override void Dispose()
             {
-                delegateFieldsProducer.Dispose();
+                _delegateFieldsProducer.Dispose();
             }
 
             public override long RamBytesUsed()
             {
-                long sizeInBytes = ((delegateFieldsProducer != null) ? delegateFieldsProducer.RamBytesUsed() : 0);
-                foreach (var entry in bloomsByFieldName.EntrySet())
+                var sizeInBytes = ((_delegateFieldsProducer != null) ? _delegateFieldsProducer.RamBytesUsed() : 0);
+                foreach (var entry in _bloomsByFieldName.EntrySet())
                 {
                     sizeInBytes += entry.Key.Length*RamUsageEstimator.NUM_BYTES_CHAR;
                     sizeInBytes += entry.Value.RamBytesUsed();
@@ -227,123 +221,117 @@ namespace Lucene.Net.Codecs.Bloom
 
             public override void CheckIntegrity()
             {
-                delegateFieldsProducer.CheckIntegrity();
+                _delegateFieldsProducer.CheckIntegrity();
             }
 
             internal class BloomFilteredTerms : Terms
             {
-                private Terms delegateTerms;
-                private FuzzySet filter;
+                private readonly Terms _delegateTerms;
+                private readonly FuzzySet _filter;
 
                 public BloomFilteredTerms(Terms terms, FuzzySet filter)
                 {
-                    this.delegateTerms = terms;
-                    this.filter = filter;
+                    _delegateTerms = terms;
+                    _filter = filter;
                 }
 
                 public override TermsEnum Intersect(CompiledAutomaton compiled,
                     BytesRef startTerm)
                 {
-                    return delegateTerms.Intersect(compiled, startTerm);
+                    return _delegateTerms.Intersect(compiled, startTerm);
                 }
 
                 public override TermsEnum Iterator(TermsEnum reuse)
                 {
-                    if ((reuse != null) && (reuse is BloomFilteredTermsEnum))
-                    {
-                        // recycle the existing BloomFilteredTermsEnum by asking the delegate
-                        // to recycle its contained TermsEnum
-                        BloomFilteredTermsEnum bfte = (BloomFilteredTermsEnum) reuse;
-                        if (bfte.filter == filter)
-                        {
-                            bfte.Reset(delegateTerms, bfte.delegateTermsEnum);
-                            return bfte;
-                        }
-                    }
+                    if (!(reuse is BloomFilteredTermsEnum))
+                        return new BloomFilteredTermsEnum(_delegateTerms, reuse, _filter);
+
+                    // recycle the existing BloomFilteredTermsEnum by asking the delegate
+                    // to recycle its contained TermsEnum
+                    var bfte = (BloomFilteredTermsEnum) reuse;
+
                     // We have been handed something we cannot reuse (either null, wrong
                     // class or wrong filter) so allocate a new object
-                    return new BloomFilteredTermsEnum(delegateTerms, reuse, filter);
+                    if (bfte.FILTER != _filter) return new BloomFilteredTermsEnum(_delegateTerms, reuse, _filter);
+                    bfte.Reset(_delegateTerms, bfte.DELEGATE_TERMS_ENUM);
+                    return bfte;
+                    
                 }
 
                 public override IComparer<BytesRef> Comparator
                 {
-                    get { return delegateTerms.Comparator; }
+                    get { return _delegateTerms.Comparator; }
                 }
 
                 public override long Size()
                 {
-                    return delegateTerms.Size();
+                    return _delegateTerms.Size();
                 }
 
                 public override long SumTotalTermFreq
                 {
-                    get { return delegateTerms.SumTotalTermFreq; }
+                    get { return _delegateTerms.SumTotalTermFreq; }
                 }
 
                 public override long SumDocFreq
                 {
-                    get { return delegateTerms.SumDocFreq; }
+                    get { return _delegateTerms.SumDocFreq; }
                 }
 
                 public override int DocCount
                 {
-                    get { return delegateTerms.DocCount; }
+                    get { return _delegateTerms.DocCount; }
                 }
 
                 public override bool HasFreqs()
                 {
-                    return delegateTerms.HasFreqs();
+                    return _delegateTerms.HasFreqs();
                 }
 
                 public override bool HasOffsets()
                 {
-                    return delegateTerms.HasOffsets();
+                    return _delegateTerms.HasOffsets();
                 }
 
                 public override bool HasPositions()
                 {
-                    return delegateTerms.HasPositions();
+                    return _delegateTerms.HasPositions();
                 }
 
                 public override bool HasPayloads()
                 {
-                    return delegateTerms.HasPayloads();
+                    return _delegateTerms.HasPayloads();
                 }
             }
 
             internal sealed class BloomFilteredTermsEnum : TermsEnum
             {
-                private Terms delegateTerms;
-                internal TermsEnum delegateTermsEnum;
-                private TermsEnum reuseDelegate;
-                internal readonly FuzzySet filter;
+                private Terms _delegateTerms;
+                internal TermsEnum DELEGATE_TERMS_ENUM;
+                private TermsEnum _reuseDelegate;
+                internal readonly FuzzySet FILTER;
 
                 public BloomFilteredTermsEnum(Terms delegateTerms, TermsEnum reuseDelegate, FuzzySet filter)
                 {
-                    this.delegateTerms = delegateTerms;
-                    this.reuseDelegate = reuseDelegate;
-                    this.filter = filter;
+                    _delegateTerms = delegateTerms;
+                    _reuseDelegate = reuseDelegate;
+                    FILTER = filter;
                 }
 
                 internal void Reset(Terms delegateTerms, TermsEnum reuseDelegate)
                 {
-                    this.delegateTerms = delegateTerms;
-                    this.reuseDelegate = reuseDelegate;
-                    this.delegateTermsEnum = null;
+                    _delegateTerms = delegateTerms;
+                    _reuseDelegate = reuseDelegate;
+                    DELEGATE_TERMS_ENUM = null;
                 }
 
                 private TermsEnum Delegate()
                 {
-                    if (delegateTermsEnum == null)
-                    {
-                        /* pull the iterator only if we really need it -
-                    * this can be a relativly heavy operation depending on the 
-                    * delegate postings format and they underlying directory
-                    * (clone IndexInput) */
-                        delegateTermsEnum = delegateTerms.Iterator(reuseDelegate);
-                    }
-
-                    return delegateTermsEnum;
+                    // pull the iterator only if we really need it -
+                    // this can be a relativly heavy operation depending on the 
+                    // delegate postings format and they underlying directory
+                    // (clone IndexInput)
+                    return DELEGATE_TERMS_ENUM ?? (DELEGATE_TERMS_ENUM = _delegateTerms.Iterator(_reuseDelegate));
                 }
 
                 public override BytesRef Next()
@@ -353,7 +341,7 @@ namespace Lucene.Net.Codecs.Bloom
 
                 public override IComparer<BytesRef> Comparator
                 {
-                    get { return delegateTerms.Comparator; }
+                    get { return _delegateTerms.Comparator; }
                 }
 
                 public override bool SeekExact(BytesRef text)
@@ -363,7 +351,7 @@ namespace Lucene.Net.Codecs.Bloom
                     // structure
                     // that may occasionally give a false positive but guaranteed no false
                     // negatives
-                    if (filter.Contains(text) == FuzzySet.ContainsResult.No)
+                    if (FILTER.Contains(text) == FuzzySet.ContainsResult.No)
                     {
                         return false;
                     }
@@ -416,66 +404,58 @@ namespace Lucene.Net.Codecs.Bloom
 
         internal class BloomFilteredFieldsConsumer : FieldsConsumer
         {
-            private FieldsConsumer delegateFieldsConsumer;
-            private Dictionary<FieldInfo, FuzzySet> bloomFilters = new Dictionary<FieldInfo, FuzzySet>();
-            private SegmentWriteState state;
+            private readonly FieldsConsumer _delegateFieldsConsumer;
+            private readonly Dictionary<FieldInfo, FuzzySet> _bloomFilters = new Dictionary<FieldInfo, FuzzySet>();
+            private readonly SegmentWriteState _state;
+            private readonly BloomFilteringPostingsFormat _bfpf;
 
             public BloomFilteredFieldsConsumer(FieldsConsumer fieldsConsumer,
-                SegmentWriteState state, PostingsFormat delegatePostingsFormat)
+                SegmentWriteState state, BloomFilteringPostingsFormat bfpf)
             {
-                this.delegateFieldsConsumer = fieldsConsumer;
-                this.state = state;
+                _delegateFieldsConsumer = fieldsConsumer;
+                _state = state;
+                _bfpf = bfpf;
             }
 
             public override TermsConsumer AddField(FieldInfo field)
             {
-                FuzzySet bloomFilter = bloomFilterFactory.GetSetForField(state, field);
+                var bloomFilter = _bfpf._bloomFilterFactory.GetSetForField(_state, field);
                 if (bloomFilter != null)
                 {
-                    Debug.Debug.Assert((bloomFilters.ContainsKey(field) == false);
-                    bloomFilters.Add(field, bloomFilter);
-                    return new WrappedTermsConsumer(delegateFieldsConsumer.AddField(field), bloomFilter);
-                }
-                else
-                {
-                    // No, use the unfiltered fieldsConsumer - we are not interested in
-                    // recording any term Bitsets.
-                    return delegateFieldsConsumer.AddField(field);
+                    Debug.Assert((_bloomFilters.ContainsKey(field) == false));
+
+                    _bloomFilters.Add(field, bloomFilter);
+                    return new WrappedTermsConsumer(_delegateFieldsConsumer.AddField(field), bloomFilter);
                 }
+
+                // No, use the unfiltered fieldsConsumer - we are not interested in
+                // recording any term Bitsets.
+                return _delegateFieldsConsumer.AddField(field);
             }
 
             public override void Dispose()
             {
-                delegateFieldsConsumer.Dispose();
+                _delegateFieldsConsumer.Dispose();
                 // Now we are done accumulating values for these fields
-                var nonSaturatedBlooms = new List<KeyValuePair<FieldInfo, FuzzySet>>();
+                var nonSaturatedBlooms = (from entry in _bloomFilters.EntrySet() let bloomFilter = entry.Value where !_bfpf._bloomFilterFactory.IsSaturated(bloomFilter, entry.Key) select entry).ToList();
 
-                foreach (var entry in bloomFilters.EntrySet())
-                {
-                    FuzzySet bloomFilter = entry.Value;
-                    if (!bloomFilterFactory.IsSaturated(bloomFilter, entry.Key))
-                    {
-                        nonSaturatedBlooms.Add(entry);
-                    }
-                }
-
-                String bloomFileName = IndexFileNames.SegmentFileName(
-                    state.SegmentInfo.Name, state.SegmentSuffix, BLOOM_EXTENSION);
+                var bloomFileName = IndexFileNames.SegmentFileName(
+                    _state.SegmentInfo.Name, _state.SegmentSuffix, BLOOM_EXTENSION);
                 IndexOutput bloomOutput = null;
 
                 try
                 {
-                    bloomOutput = state.Directory.CreateOutput(bloomFileName, state.Context);
+                    bloomOutput = _state.Directory.CreateOutput(bloomFileName, _state.Context);
                     CodecUtil.WriteHeader(bloomOutput, BLOOM_CODEC_NAME, VERSION_CURRENT);
                     // remember the name of the postings format we will delegate to
-                    bloomOutput.WriteString(delegatePostingsFormat.Name);
+                    bloomOutput.WriteString(_bfpf._delegatePostingsFormat.Name);
 
                     // First field in the output file is the number of fields+blooms saved
                     bloomOutput.WriteInt(nonSaturatedBlooms.Count);
                     foreach (var entry in nonSaturatedBlooms)
                     {
-                        FieldInfo fieldInfo = entry.Key;
-                        FuzzySet bloomFilter = entry.Value;
+                        var fieldInfo = entry.Key;
+                        var bloomFilter = entry.Value;
                         bloomOutput.WriteInt(fieldInfo.Number);
                         SaveAppropriatelySizedBloomFilter(bloomOutput, bloomFilter, fieldInfo);
                     }
@@ -487,19 +467,16 @@ namespace Lucene.Net.Codecs.Bloom
                     IOUtils.Close(bloomOutput);
                 }
                 //We are done with large bitsets so no need to keep them hanging around
-                bloomFilters.Clear();
+                _bloomFilters.Clear();
             }
 
-            private void SaveAppropriatelySizedBloomFilter(IndexOutput bloomOutput,
+            private void SaveAppropriatelySizedBloomFilter(DataOutput bloomOutput,
                 FuzzySet bloomFilter, FieldInfo fieldInfo)
             {
 
-                FuzzySet rightSizedSet = bloomFilterFactory.Downsize(fieldInfo,
-                    bloomFilter);
-                if (rightSizedSet == null)
-                {
-                    rightSizedSet = bloomFilter;
-                }
+                var rightSizedSet = _bfpf._bloomFilterFactory.Downsize(fieldInfo,
+                    bloomFilter) ?? bloomFilter;
+
                 rightSizedSet.Serialize(bloomOutput);
             }
 
@@ -507,18 +484,18 @@ namespace Lucene.Net.Codecs.Bloom
 
         internal class WrappedTermsConsumer : TermsConsumer
         {
-            private TermsConsumer delegateTermsConsumer;
-            private FuzzySet bloomFilter;
+            private readonly TermsConsumer _delegateTermsConsumer;
+            private readonly FuzzySet _bloomFilter;
 
             public WrappedTermsConsumer(TermsConsumer termsConsumer, FuzzySet bloomFilter)
             {
-                this.delegateTermsConsumer = termsConsumer;
-                this.bloomFilter = bloomFilter;
+                _delegateTermsConsumer = termsConsumer;
+                _bloomFilter = bloomFilter;
             }
 
             public override PostingsConsumer StartTerm(BytesRef text)
             {
-                return delegateTermsConsumer.StartTerm(text);
+                return _delegateTermsConsumer.StartTerm(text);
             }
 
             public override void FinishTerm(BytesRef text, TermStats stats)
@@ -526,19 +503,19 @@ namespace Lucene.Net.Codecs.Bloom
                 // Record this term in our BloomFilter
                 if (stats.DocFreq > 0)
                 {
-                    bloomFilter.AddValue(text);
+                    _bloomFilter.AddValue(text);
                 }
-                delegateTermsConsumer.FinishTerm(text, stats);
+                _delegateTermsConsumer.FinishTerm(text, stats);
             }
 
             public override void Finish(long sumTotalTermFreq, long sumDocFreq, int docCount)
             {
-                delegateTermsConsumer.Finish(sumTotalTermFreq, sumDocFreq, docCount);
+                _delegateTermsConsumer.Finish(sumTotalTermFreq, sumDocFreq, docCount);
             }
 
             public override IComparer<BytesRef> Comparator
             {
-                get { return delegateTermsConsumer.Comparator; }
+                get { return _delegateTermsConsumer.Comparator; }
             }
 
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02f232e7/src/Lucene.Net.Codecs/Bloom/DefaultBloomFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Bloom/DefaultBloomFilterFactory.cs b/src/Lucene.Net.Codecs/Bloom/DefaultBloomFilterFactory.cs
index 6d1bb54..3e49add 100644
--- a/src/Lucene.Net.Codecs/Bloom/DefaultBloomFilterFactory.cs
+++ b/src/Lucene.Net.Codecs/Bloom/DefaultBloomFilterFactory.cs
@@ -17,7 +17,7 @@
 
 namespace Lucene.Net.Codecs.Bloom
 {
-    using Lucene.Net.Index;
+    using Index;
 
     /// <summary>
     /// Default policy is to allocate a bitset with 10% saturation given a unique term per document.

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02f232e7/src/Lucene.Net.Codecs/Bloom/FuzzySet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Bloom/FuzzySet.cs b/src/Lucene.Net.Codecs/Bloom/FuzzySet.cs
index 5a97564..aa0a036 100644
--- a/src/Lucene.Net.Codecs/Bloom/FuzzySet.cs
+++ b/src/Lucene.Net.Codecs/Bloom/FuzzySet.cs
@@ -20,8 +20,9 @@ namespace Lucene.Net.Codecs.Bloom
 
     using System;
     using System.Diagnostics;
-    using Lucene.Net.Store;
-    using Lucene.Net.Util;
+    using System.Linq;
+    using Store;
+    using Util;
 
     /// <summary>
     /// A class used to represent a set of many, potentially large, values (e.g. many
@@ -49,18 +50,16 @@ namespace Lucene.Net.Codecs.Bloom
         public static readonly int VERSION_START = VERSION_SPI;
         public static readonly int VERSION_CURRENT = 2;
 
-        public static HashFunction hashFunctionForVersion(int version)
+        public static HashFunction HashFunctionForVersion(int version)
         {
             if (version < VERSION_START)
-            {
                 throw new ArgumentException("Version " + version + " is too old, expected at least " +
                                                    VERSION_START);
-            }
-            else if (version > VERSION_CURRENT)
-            {
+            
+            if (version > VERSION_CURRENT)
                 throw new ArgumentException("Version " + version + " is too new, expected at most " +
                                                    VERSION_CURRENT);
-            }
+            
             return MurmurHash2.INSTANCE;
         }
 
@@ -75,9 +74,9 @@ namespace Lucene.Net.Codecs.Bloom
             No
         };
 
-        private readonly HashFunction hashFunction;
-        private readonly FixedBitSet filter;
-        private readonly int bloomSize;
+        private readonly HashFunction _hashFunction;
+        private readonly FixedBitSet _filter;
+        private readonly int _bloomSize;
 
         //The sizes of BitSet used are all numbers that, when expressed in binary form,
         //are all ones. This is to enable fast downsizing from one bitset to another
@@ -86,92 +85,94 @@ namespace Lucene.Net.Codecs.Bloom
         // a large bitset and then mapped to a smaller set can be looked up using a single
         // AND operation of the query term's hash rather than needing to perform a 2-step
         // translation of the query term that mirrors the stored content's reprojections.
-        private static int[] usableBitSetSizes;
+        private static int[] _usableBitSetSizes;
 
-        private static 
+        private static int[] UsableBitSetSizes
         {
-            usableBitSetSizes = new int[30];
-            int mask = 1;
-            int size = mask;
-            for (int i = 0; i < usableBitSetSizes.Length; i++)
+            get
             {
-                size = (size << 1) | mask;
-                usableBitSetSizes[i] = size;
+                if (_usableBitSetSizes == null)
+                    InitializeUsableBitSetSizes();
+
+                return _usableBitSetSizes;
             }
+            set { _usableBitSetSizes = value; }
         }
 
-        /**
-   * Rounds down required maxNumberOfBits to the nearest number that is made up
-   * of all ones as a binary number.  
-   * Use this method where controlling memory use is paramount.
-   */
+        private static void InitializeUsableBitSetSizes()
+        {
+            UsableBitSetSizes = new int[30];
+            const int mask = 1;
+            var size = mask;
+            for (var i = 0; i < UsableBitSetSizes.Length; i++)
+            {
+                size = (size << 1) | mask;
+                UsableBitSetSizes[i] = size;
+            }
+        }
 
+        /// <summary>
+        /// Rounds down required maxNumberOfBits to the nearest number that is made up
+        /// of all ones as a binary number.  
+        /// Use this method where controlling memory use is paramount.
+        /// </summary>
         public static int GetNearestSetSize(int maxNumberOfBits)
         {
-            int result = usableBitSetSizes[0];
-            for (int i = 0; i < usableBitSetSizes.Length; i++)
+            var result = UsableBitSetSizes[0];
+            foreach (var t in UsableBitSetSizes.Where(t => t <= maxNumberOfBits))
             {
-                if (usableBitSetSizes[i] <= maxNumberOfBits)
-                {
-                    result = usableBitSetSizes[i];
-                }
+                result = t;
             }
             return result;
         }
 
-        /**
-   * Use this method to choose a set size where accuracy (low content saturation) is more important
-   * than deciding how much memory to throw at the problem.
-   * @param desiredSaturation A number between 0 and 1 expressing the % of bits set once all values have been recorded
-   * @return The size of the set nearest to the required size
-   */
-
+        /// <summary>
+        /// Use this method to choose a set size where accuracy (low content saturation) is more important
+        /// than deciding how much memory to throw at the problem.
+        /// </summary>
+        /// <param name="maxNumberOfValuesExpected"></param>
+        /// <param name="desiredSaturation">A number between 0 and 1 expressing the % of bits set once all values have been recorded</param>
+        /// <returns>The size of the set nearest to the required size</returns>
         public static int GetNearestSetSize(int maxNumberOfValuesExpected,
             float desiredSaturation)
         {
             // Iterate around the various scales of bitset from smallest to largest looking for the first that
             // satisfies value volumes at the chosen saturation level
-            for (int i = 0; i < usableBitSetSizes.Length; i++)
+            foreach (var t in from t in UsableBitSetSizes let numSetBitsAtDesiredSaturation = (int) (t*desiredSaturation) let estimatedNumUniqueValues = GetEstimatedNumberUniqueValuesAllowingForCollisions(
+                t, numSetBitsAtDesiredSaturation) where estimatedNumUniqueValues > maxNumberOfValuesExpected select t)
             {
-                int numSetBitsAtDesiredSaturation = (int) (usableBitSetSizes[i]*desiredSaturation);
-                int estimatedNumUniqueValues = GetEstimatedNumberUniqueValuesAllowingForCollisions(
-                    usableBitSetSizes[i], numSetBitsAtDesiredSaturation);
-                if (estimatedNumUniqueValues > maxNumberOfValuesExpected)
-                {
-                    return usableBitSetSizes[i];
-                }
+                return t;
             }
             return -1;
         }
 
         public static FuzzySet CreateSetBasedOnMaxMemory(int maxNumBytes)
         {
-            int setSize = GetNearestSetSize(maxNumBytes);
-            return new FuzzySet(new FixedBitSet(setSize + 1), setSize, hashFunctionForVersion(VERSION_CURRENT));
+            var setSize = GetNearestSetSize(maxNumBytes);
+            return new FuzzySet(new FixedBitSet(setSize + 1), setSize, HashFunctionForVersion(VERSION_CURRENT));
         }
 
         public static FuzzySet CreateSetBasedOnQuality(int maxNumUniqueValues, float desiredMaxSaturation)
         {
-            int setSize = GetNearestSetSize(maxNumUniqueValues, desiredMaxSaturation);
-            return new FuzzySet(new FixedBitSet(setSize + 1), setSize, hashFunctionForVersion(VERSION_CURRENT));
+            var setSize = GetNearestSetSize(maxNumUniqueValues, desiredMaxSaturation);
+            return new FuzzySet(new FixedBitSet(setSize + 1), setSize, HashFunctionForVersion(VERSION_CURRENT));
         }
 
         private FuzzySet(FixedBitSet filter, int bloomSize, HashFunction hashFunction)
         {
-            this.filter = filter;
-            this.bloomSize = bloomSize;
-            this.hashFunction = hashFunction;
+            _filter = filter;
+            _bloomSize = bloomSize;
+            _hashFunction = hashFunction;
         }
 
-        /**
-   * The main method required for a Bloom filter which, given a value determines set membership.
-   * Unlike a conventional set, the fuzzy set returns NO or MAYBE rather than true or false.
-   * @return NO or MAYBE
-   */
-
+        /// <summary>
+        /// The main method required for a Bloom filter which, given a value determines set membership.
+        /// Unlike a conventional set, the fuzzy set returns NO or MAYBE rather than true or false.
+        /// </summary>
+        /// <returns>NO or MAYBE</returns>
         public ContainsResult Contains(BytesRef value)
         {
-            int hash = hashFunction.Hash(value);
+            var hash = _hashFunction.Hash(value);
             if (hash < 0)
             {
                 hash = hash*-1;
@@ -179,147 +180,128 @@ namespace Lucene.Net.Codecs.Bloom
             return MayContainValue(hash);
         }
 
-        /**
-   * Serializes the data set to file using the following format:
-   * <ul>
-   *  <li>FuzzySet --&gt;FuzzySetVersion,HashFunctionName,BloomSize,
-   * NumBitSetWords,BitSetWord<sup>NumBitSetWords</sup></li> 
-   * <li>HashFunctionName --&gt; {@link DataOutput#writeString(String) String} The
-   * name of a ServiceProvider registered {@link HashFunction}</li>
-   * <li>FuzzySetVersion --&gt; {@link DataOutput#writeInt Uint32} The version number of the {@link FuzzySet} class</li>
-   * <li>BloomSize --&gt; {@link DataOutput#writeInt Uint32} The modulo value used
-   * to project hashes into the field's Bitset</li>
-   * <li>NumBitSetWords --&gt; {@link DataOutput#writeInt Uint32} The number of
-   * longs (as returned from {@link FixedBitSet#getBits})</li>
-   * <li>BitSetWord --&gt; {@link DataOutput#writeLong Long} A long from the array
-   * returned by {@link FixedBitSet#getBits}</li>
-   * </ul>
-   * @param out Data output stream
-   * @ If there is a low-level I/O error
-   */
-
+        /// <summary>
+        ///  Serializes the data set to file using the following format:
+        ///  <ul>
+        ///   <li>FuzzySet --&gt;FuzzySetVersion,HashFunctionName,BloomSize,
+        ///  NumBitSetWords,BitSetWord<sup>NumBitSetWords</sup></li> 
+        ///  <li>HashFunctionName --&gt; {@link DataOutput#writeString(String) String} The
+        ///  name of a ServiceProvider registered {@link HashFunction}</li>
+        ///  <li>FuzzySetVersion --&gt; {@link DataOutput#writeInt Uint32} The version number of the {@link FuzzySet} class</li>
+        ///  <li>BloomSize --&gt; {@link DataOutput#writeInt Uint32} The modulo value used
+        ///  to project hashes into the field's Bitset</li>
+        ///  <li>NumBitSetWords --&gt; {@link DataOutput#writeInt Uint32} The number of
+        ///  longs (as returned from {@link FixedBitSet#getBits})</li>
+        ///  <li>BitSetWord --&gt; {@link DataOutput#writeLong Long} A long from the array
+        ///  returned by {@link FixedBitSet#getBits}</li>
+        ///  </ul>
+        ///  @param out Data output stream
+        ///  @ If there is a low-level I/O error
+        /// </summary>
         public void Serialize(DataOutput output)
         {
             output.WriteInt(VERSION_CURRENT);
-            output.WriteInt(bloomSize);
-            long[] bits = filter.GetBits();
+            output.WriteInt(_bloomSize);
+            var bits = _filter.Bits;
             output.WriteInt(bits.Length);
-            for (int i = 0; i < bits.Length; i++)
+            foreach (var t in bits)
             {
                 // Can't used VLong encoding because cant cope with negative numbers
                 // output by FixedBitSet
-                output.WriteLong(bits[i]);
+                output.WriteLong(t);
             }
         }
 
         public static FuzzySet Deserialize(DataInput input)
         {
-            int version = input.ReadInt();
+            var version = input.ReadInt();
             if (version == VERSION_SPI)
-            {
                 input.ReadString();
-            }
-            HashFunction hashFunction = hashFunctionForVersion(version);
-            int bloomSize = input.ReadInt();
-            int numLongs = input.ReadInt();
-            long[] longs = new long[numLongs];
-            for (int i = 0; i < numLongs; i++)
+           
+            var hashFunction = HashFunctionForVersion(version);
+            var bloomSize = input.ReadInt();
+            var numLongs = input.ReadInt();
+            var longs = new long[numLongs];
+            for (var i = 0; i < numLongs; i++)
             {
                 longs[i] = input.ReadLong();
             }
-            FixedBitSet bits = new FixedBitSet(longs, bloomSize + 1);
+            var bits = new FixedBitSet(longs, bloomSize + 1);
             return new FuzzySet(bits, bloomSize, hashFunction);
         }
 
         private ContainsResult MayContainValue(int positiveHash)
         {
-            Debug.Debug.Assert((positiveHash >= 0);
+            Debug.Assert((positiveHash >= 0));
 
             // Bloom sizes are always base 2 and so can be ANDed for a fast modulo
-            int pos = positiveHash & bloomSize;
-            if (filter.Get(pos))
-            {
-                // This term may be recorded in this index (but could be a collision)
-                return ContainsResult.Maybe;
-            }
-            // definitely NOT in this segment
-            return ContainsResult.No;
+            var pos = positiveHash & _bloomSize;
+            return _filter.Get(pos) ? ContainsResult.Maybe : ContainsResult.No;
         }
 
-        /**
-   * Records a value in the set. The referenced bytes are hashed and then modulo n'd where n is the
-   * chosen size of the internal bitset.
-   * @param value the key value to be hashed
-   * @ If there is a low-level I/O error
-   */
-
+        /// <summary>
+        /// Records a value in the set. The referenced bytes are hashed and then modulo n'd where n is the
+        /// chosen size of the internal bitset.
+        /// </summary>
+        /// <param name="value">The Key value to be hashed</param>
         public void AddValue(BytesRef value)
         {
-            int hash = hashFunction.Hash(value);
+            var hash = _hashFunction.Hash(value);
             if (hash < 0)
             {
                 hash = hash*-1;
             }
             // Bitmasking using bloomSize is effectively a modulo operation.
-            int bloomPos = hash & bloomSize;
-            filter.Set(bloomPos);
+            var bloomPos = hash & _bloomSize;
+            _filter.Set(bloomPos);
         }
 
-
-        /**
-   * 
-   * @param targetMaxSaturation A number between 0 and 1 describing the % of bits that would ideally be set in the 
-   * result. Lower values have better accuracy but require more space.
-   * @return a smaller FuzzySet or null if the current set is already over-saturated
-   */
-
+        /// <param name="targetMaxSaturation">
+        /// A number between 0 and 1 describing the % of bits that would ideally be set in the result. 
+        /// Lower values have better accuracy but require more space.
+        /// </param>
+        /// <return>A smaller FuzzySet or null if the current set is already over-saturated</return>
         public FuzzySet Downsize(float targetMaxSaturation)
         {
-            int numBitsSet = filter.Cardinality();
-            FixedBitSet rightSizedBitSet = filter;
-            int rightSizedBitSetSize = bloomSize;
+            var numBitsSet = _filter.Cardinality();
+            FixedBitSet rightSizedBitSet;
+            var rightSizedBitSetSize = _bloomSize;
             //Hopefully find a smaller size bitset into which we can project accumulated values while maintaining desired saturation level
-            for (int i = 0; i < usableBitSetSizes.Length; i++)
+            foreach (var candidateBitsetSize in from candidateBitsetSize in UsableBitSetSizes let candidateSaturation = numBitsSet
+                                                                                                                         /(float) candidateBitsetSize where candidateSaturation <= targetMaxSaturation select candidateBitsetSize)
             {
-                int candidateBitsetSize = usableBitSetSizes[i];
-                float candidateSaturation = (float) numBitsSet
-                                            /(float) candidateBitsetSize;
-                if (candidateSaturation <= targetMaxSaturation)
-                {
-                    rightSizedBitSetSize = candidateBitsetSize;
-                    break;
-                }
+                rightSizedBitSetSize = candidateBitsetSize;
+                break;
             }
             // Re-project the numbers to a smaller space if necessary
-            if (rightSizedBitSetSize < bloomSize)
+            if (rightSizedBitSetSize < _bloomSize)
             {
                 // Reset the choice of bitset to the smaller version
                 rightSizedBitSet = new FixedBitSet(rightSizedBitSetSize + 1);
                 // Map across the bits from the large set to the smaller one
-                int bitIndex = 0;
+                var bitIndex = 0;
                 do
                 {
-                    bitIndex = filter.NextSetBit(bitIndex);
-                    if (bitIndex >= 0)
-                    {
-                        // Project the larger number into a smaller one effectively
-                        // modulo-ing by using the target bitset size as a mask
-                        int downSizedBitIndex = bitIndex & rightSizedBitSetSize;
-                        rightSizedBitSet.Set(downSizedBitIndex);
-                        bitIndex++;
-                    }
-                } while ((bitIndex >= 0) && (bitIndex <= bloomSize));
+                    bitIndex = _filter.NextSetBit(bitIndex);
+                    if (bitIndex < 0) continue;
+
+                    // Project the larger number into a smaller one effectively
+                    // modulo-ing by using the target bitset size as a mask
+                    var downSizedBitIndex = bitIndex & rightSizedBitSetSize;
+                    rightSizedBitSet.Set(downSizedBitIndex);
+                    bitIndex++;
+                } while ((bitIndex >= 0) && (bitIndex <= _bloomSize));
             }
             else
             {
                 return null;
             }
-            return new FuzzySet(rightSizedBitSet, rightSizedBitSetSize, hashFunction);
+            return new FuzzySet(rightSizedBitSet, rightSizedBitSetSize, _hashFunction);
         }
 
         public int GetEstimatedUniqueValues()
         {
-            return GetEstimatedNumberUniqueValuesAllowingForCollisions(bloomSize, filter.Cardinality());
+            return GetEstimatedNumberUniqueValuesAllowingForCollisions(_bloomSize, _filter.Cardinality());
         }
 
         // Given a set size and a the number of set bits, produces an estimate of the number of unique values recorded
@@ -328,20 +310,20 @@ namespace Lucene.Net.Codecs.Bloom
         {
             double setSizeAsDouble = setSize;
             double numRecordedBitsAsDouble = numRecordedBits;
-            double saturation = numRecordedBitsAsDouble/setSizeAsDouble;
-            double logInverseSaturation = Math.Log(1 - saturation)*-1;
+            var saturation = numRecordedBitsAsDouble/setSizeAsDouble;
+            var logInverseSaturation = Math.Log(1 - saturation)*-1;
             return (int) (setSizeAsDouble*logInverseSaturation);
         }
 
         public float GetSaturation()
         {
-            int numBitsSet = filter.Cardinality();
-            return (float) numBitsSet/(float) bloomSize;
+            var numBitsSet = _filter.Cardinality();
+            return numBitsSet/(float) _bloomSize;
         }
 
         public long RamBytesUsed()
         {
-            return RamUsageEstimator.SizeOf(filter.GetBits());
+            return RamUsageEstimator.SizeOf(_filter.GetBits());
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02f232e7/src/Lucene.Net.Codecs/Bloom/HashFunction.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Bloom/HashFunction.cs b/src/Lucene.Net.Codecs/Bloom/HashFunction.cs
index 9431e1b..af1a608 100644
--- a/src/Lucene.Net.Codecs/Bloom/HashFunction.cs
+++ b/src/Lucene.Net.Codecs/Bloom/HashFunction.cs
@@ -17,7 +17,7 @@
 
 namespace Lucene.Net.Codecs.Bloom
 {
-    using Lucene.Net.Util;
+    using Util;
 
     /// <summary>
     /// Base class for hashing functions that can be referred to by name.

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02f232e7/src/Lucene.Net.Codecs/Bloom/MurmurHash2.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/Bloom/MurmurHash2.cs b/src/Lucene.Net.Codecs/Bloom/MurmurHash2.cs
index cb70d5d..2054a5e 100644
--- a/src/Lucene.Net.Codecs/Bloom/MurmurHash2.cs
+++ b/src/Lucene.Net.Codecs/Bloom/MurmurHash2.cs
@@ -15,12 +15,11 @@
  * limitations under the License.
  */
 
-using System;
-
 namespace Lucene.Net.Codecs.Bloom
 {
 
-    using Lucene.Net.Util;
+    using System;
+    using Util;
 
     /// <summary>
     /// This is a very fast, non-cryptographic hash suitable for general hash-based
@@ -66,8 +65,8 @@ namespace Lucene.Net.Codecs.Bloom
                 h *= m;
                 h ^= k;
             }
-            int len_m = len_4 << 2;
-            int left = len - len_m;
+            var len_m = len_4 << 2;
+            var left = len - len_m;
             if (left != 0)
             {
                 if (left >= 3)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02f232e7/src/Lucene.Net.Codecs/DiskDV/DiskDocValuesFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/DiskDV/DiskDocValuesFormat.cs b/src/Lucene.Net.Codecs/DiskDV/DiskDocValuesFormat.cs
index c71295c..75dd484 100644
--- a/src/Lucene.Net.Codecs/DiskDV/DiskDocValuesFormat.cs
+++ b/src/Lucene.Net.Codecs/DiskDV/DiskDocValuesFormat.cs
@@ -18,9 +18,9 @@
 
 namespace Lucene.Net.Codecs.DiskDV
 {
-    using Lucene.Net.Codecs;
-    using Lucene.Net.Codecs.Lucene45;
-    using Lucene.Net.Index;
+    using Codecs;
+    using Lucene45;
+    using Index;
     using System;
 
     /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02f232e7/src/Lucene.Net.Codecs/DiskDV/DiskDocValuesProducer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/DiskDV/DiskDocValuesProducer.cs b/src/Lucene.Net.Codecs/DiskDV/DiskDocValuesProducer.cs
index a5241be..95d58ee 100644
--- a/src/Lucene.Net.Codecs/DiskDV/DiskDocValuesProducer.cs
+++ b/src/Lucene.Net.Codecs/DiskDV/DiskDocValuesProducer.cs
@@ -18,10 +18,10 @@
 namespace Lucene.Net.Codecs.DiskDV
 {
     using System;
-    using Lucene.Net.Codecs.Lucene45;
-    using Lucene.Net.Index;
-    using Lucene.Net.Store;
-    using Lucene.Net.Util.Packed;
+    using Lucene45;
+    using Index;
+    using Store;
+    using Util.Packed;
 
     public class DiskDocValuesProducer : Lucene45DocValuesProducer
     {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/02f232e7/src/Lucene.Net.Codecs/DiskDV/DiskNormsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/DiskDV/DiskNormsFormat.cs b/src/Lucene.Net.Codecs/DiskDV/DiskNormsFormat.cs
index 91dd77b..cb688c2 100644
--- a/src/Lucene.Net.Codecs/DiskDV/DiskNormsFormat.cs
+++ b/src/Lucene.Net.Codecs/DiskDV/DiskNormsFormat.cs
@@ -19,9 +19,9 @@ namespace Lucene.Net.Codecs.DiskDV
 {
 
     using System;
-    using Lucene.Net.Codecs;
-    using Lucene.Net.Codecs.Lucene45;
-    using Lucene.Net.Index;
+    using Codecs;
+    using Lucene45;
+    using Index;
 
     /// <summary>
     /// Norms format that keeps all norms on disk


[2/2] git commit: Updating Lucene.Net.Codes/Pulsing

Posted by pn...@apache.org.
Updating Lucene.Net.Codes/Pulsing


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

Branch: refs/heads/master
Commit: 6e900565dc22706fd946c01c024ec96ca82f2ed1
Parents: 02f232e
Author: Prescott Nasser <pn...@apache.org>
Authored: Sun Sep 14 16:27:37 2014 -0700
Committer: Prescott Nasser <pn...@apache.org>
Committed: Sun Sep 14 16:27:37 2014 -0700

----------------------------------------------------------------------
 .../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/6e900565/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/6e900565/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/6e900565/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/6e900565/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/6e900565/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