You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by cc...@apache.org on 2013/04/03 19:39:50 UTC

[07/51] [partial] Mass convert mixed tabs to spaces

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/core/Index/MergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/core/Index/MergePolicy.cs b/src/core/Index/MergePolicy.cs
index cdc2060..63876c8 100644
--- a/src/core/Index/MergePolicy.cs
+++ b/src/core/Index/MergePolicy.cs
@@ -22,319 +22,319 @@ using Directory = Lucene.Net.Store.Directory;
 
 namespace Lucene.Net.Index
 {
-	
-	/// <summary> <p/>Expert: a MergePolicy determines the sequence of
-	/// primitive merge operations to be used for overall merge
-	/// and optimize operations.<p/>
-	/// 
-	/// <p/>Whenever the segments in an index have been altered by
-	/// <see cref="IndexWriter" />, either the addition of a newly
-	/// flushed segment, addition of many segments from
-	/// addIndexes* calls, or a previous merge that may now need
-	/// to cascade, <see cref="IndexWriter" /> invokes <see cref="FindMerges" />
-	/// to give the MergePolicy a chance to pick
-	/// merges that are now required.  This method returns a
-	/// <see cref="MergeSpecification" /> instance describing the set of
-	/// merges that should be done, or null if no merges are
-	/// necessary.  When IndexWriter.optimize is called, it calls
-	/// <see cref="FindMergesForOptimize" /> and the MergePolicy should
-	/// then return the necessary merges.<p/>
-	/// 
-	/// <p/>Note that the policy can return more than one merge at
-	/// a time.  In this case, if the writer is using <see cref="SerialMergeScheduler" />
-	///, the merges will be run
-	/// sequentially but if it is using <see cref="ConcurrentMergeScheduler" />
-	/// they will be run concurrently.<p/>
-	/// 
-	/// <p/>The default MergePolicy is <see cref="LogByteSizeMergePolicy" />
-	///.<p/>
-	/// 
-	/// <p/><b>NOTE:</b> This API is new and still experimental
-	/// (subject to change suddenly in the next release)<p/>
-	/// 
-	/// <p/><b>NOTE</b>: This class typically requires access to
-	/// package-private APIs (e.g. <c>SegmentInfos</c>) to do its job;
-	/// if you implement your own MergePolicy, you'll need to put
-	/// it in package Lucene.Net.Index in order to use
-	/// these APIs.
-	/// </summary>
-	
-	public abstract class MergePolicy : IDisposable
-	{
-		
-		/// <summary>OneMerge provides the information necessary to perform
-		/// an individual primitive merge operation, resulting in
-		/// a single new segment.  The merge spec includes the
-		/// subset of segments to be merged as well as whether the
-		/// new segment should use the compound file format. 
-		/// </summary>
-		
-		public class OneMerge
-		{
-			
-			internal SegmentInfo info;              // used by IndexWriter
-			internal bool mergeDocStores;           // used by IndexWriter
-			internal bool optimize;                 // used by IndexWriter
-			internal bool registerDone;             // used by IndexWriter
-			internal long mergeGen;                 // used by IndexWriter
-			internal bool isExternal;               // used by IndexWriter
-			internal int maxNumSegmentsOptimize;    // used by IndexWriter
-			internal SegmentReader[] readers;       // used by IndexWriter
-			internal SegmentReader[] readersClone;  // used by IndexWriter
-			internal SegmentInfos segments;
-			internal bool useCompoundFile;
-			internal bool aborted;
-			internal System.Exception error;
-			
-			public OneMerge(SegmentInfos segments, bool useCompoundFile)
-			{
-				if (0 == segments.Count)
-					throw new ArgumentException("segments must include at least one segment", "segments");
-				this.segments = segments;
-				this.useCompoundFile = useCompoundFile;
-			}
-			
-			/// <summary>Record that an exception occurred while executing
-			/// this merge 
-			/// </summary>
-			internal virtual void  SetException(System.Exception error)
-			{
-				lock (this)
-				{
-					this.error = error;
-				}
-			}
-			
-			/// <summary>Retrieve previous exception set by <see cref="SetException" />
-			///. 
-			/// </summary>
-			internal virtual System.Exception GetException()
-			{
-				lock (this)
-				{
-					return error;
-				}
-			}
-			
-			/// <summary>Mark this merge as aborted.  If this is called
-			/// before the merge is committed then the merge will
-			/// not be committed. 
-			/// </summary>
-			internal virtual void  Abort()
-			{
-				lock (this)
-				{
-					aborted = true;
-				}
-			}
-			
-			/// <summary>Returns true if this merge was aborted. </summary>
-			internal virtual bool IsAborted()
-			{
-				lock (this)
-				{
-					return aborted;
-				}
-			}
-			
-			internal virtual void  CheckAborted(Directory dir)
-			{
-				lock (this)
-				{
-					if (aborted)
-						throw new MergeAbortedException("merge is aborted: " + SegString(dir));
-				}
-			}
-			
-			internal virtual String SegString(Directory dir)
-			{
-				var b = new System.Text.StringBuilder();
-				int numSegments = segments.Count;
-				for (int i = 0; i < numSegments; i++)
-				{
-					if (i > 0)
-						b.Append(' ');
-					b.Append(segments.Info(i).SegString(dir));
-				}
-				if (info != null)
-					b.Append(" into ").Append(info.name);
-				if (optimize)
-					b.Append(" [optimize]");
-				if (mergeDocStores)
-				{
-					b.Append(" [mergeDocStores]");
-				}
-				return b.ToString();
-			}
+    
+    /// <summary> <p/>Expert: a MergePolicy determines the sequence of
+    /// primitive merge operations to be used for overall merge
+    /// and optimize operations.<p/>
+    /// 
+    /// <p/>Whenever the segments in an index have been altered by
+    /// <see cref="IndexWriter" />, either the addition of a newly
+    /// flushed segment, addition of many segments from
+    /// addIndexes* calls, or a previous merge that may now need
+    /// to cascade, <see cref="IndexWriter" /> invokes <see cref="FindMerges" />
+    /// to give the MergePolicy a chance to pick
+    /// merges that are now required.  This method returns a
+    /// <see cref="MergeSpecification" /> instance describing the set of
+    /// merges that should be done, or null if no merges are
+    /// necessary.  When IndexWriter.optimize is called, it calls
+    /// <see cref="FindMergesForOptimize" /> and the MergePolicy should
+    /// then return the necessary merges.<p/>
+    /// 
+    /// <p/>Note that the policy can return more than one merge at
+    /// a time.  In this case, if the writer is using <see cref="SerialMergeScheduler" />
+    ///, the merges will be run
+    /// sequentially but if it is using <see cref="ConcurrentMergeScheduler" />
+    /// they will be run concurrently.<p/>
+    /// 
+    /// <p/>The default MergePolicy is <see cref="LogByteSizeMergePolicy" />
+    ///.<p/>
+    /// 
+    /// <p/><b>NOTE:</b> This API is new and still experimental
+    /// (subject to change suddenly in the next release)<p/>
+    /// 
+    /// <p/><b>NOTE</b>: This class typically requires access to
+    /// package-private APIs (e.g. <c>SegmentInfos</c>) to do its job;
+    /// if you implement your own MergePolicy, you'll need to put
+    /// it in package Lucene.Net.Index in order to use
+    /// these APIs.
+    /// </summary>
+    
+    public abstract class MergePolicy : IDisposable
+    {
+        
+        /// <summary>OneMerge provides the information necessary to perform
+        /// an individual primitive merge operation, resulting in
+        /// a single new segment.  The merge spec includes the
+        /// subset of segments to be merged as well as whether the
+        /// new segment should use the compound file format. 
+        /// </summary>
+        
+        public class OneMerge
+        {
+            
+            internal SegmentInfo info;              // used by IndexWriter
+            internal bool mergeDocStores;           // used by IndexWriter
+            internal bool optimize;                 // used by IndexWriter
+            internal bool registerDone;             // used by IndexWriter
+            internal long mergeGen;                 // used by IndexWriter
+            internal bool isExternal;               // used by IndexWriter
+            internal int maxNumSegmentsOptimize;    // used by IndexWriter
+            internal SegmentReader[] readers;       // used by IndexWriter
+            internal SegmentReader[] readersClone;  // used by IndexWriter
+            internal SegmentInfos segments;
+            internal bool useCompoundFile;
+            internal bool aborted;
+            internal System.Exception error;
+            
+            public OneMerge(SegmentInfos segments, bool useCompoundFile)
+            {
+                if (0 == segments.Count)
+                    throw new ArgumentException("segments must include at least one segment", "segments");
+                this.segments = segments;
+                this.useCompoundFile = useCompoundFile;
+            }
+            
+            /// <summary>Record that an exception occurred while executing
+            /// this merge 
+            /// </summary>
+            internal virtual void  SetException(System.Exception error)
+            {
+                lock (this)
+                {
+                    this.error = error;
+                }
+            }
+            
+            /// <summary>Retrieve previous exception set by <see cref="SetException" />
+            ///. 
+            /// </summary>
+            internal virtual System.Exception GetException()
+            {
+                lock (this)
+                {
+                    return error;
+                }
+            }
+            
+            /// <summary>Mark this merge as aborted.  If this is called
+            /// before the merge is committed then the merge will
+            /// not be committed. 
+            /// </summary>
+            internal virtual void  Abort()
+            {
+                lock (this)
+                {
+                    aborted = true;
+                }
+            }
+            
+            /// <summary>Returns true if this merge was aborted. </summary>
+            internal virtual bool IsAborted()
+            {
+                lock (this)
+                {
+                    return aborted;
+                }
+            }
+            
+            internal virtual void  CheckAborted(Directory dir)
+            {
+                lock (this)
+                {
+                    if (aborted)
+                        throw new MergeAbortedException("merge is aborted: " + SegString(dir));
+                }
+            }
+            
+            internal virtual String SegString(Directory dir)
+            {
+                var b = new System.Text.StringBuilder();
+                int numSegments = segments.Count;
+                for (int i = 0; i < numSegments; i++)
+                {
+                    if (i > 0)
+                        b.Append(' ');
+                    b.Append(segments.Info(i).SegString(dir));
+                }
+                if (info != null)
+                    b.Append(" into ").Append(info.name);
+                if (optimize)
+                    b.Append(" [optimize]");
+                if (mergeDocStores)
+                {
+                    b.Append(" [mergeDocStores]");
+                }
+                return b.ToString();
+            }
 
             public SegmentInfos segments_ForNUnit
             {
                 get { return segments; }
             }
-		}
-		
-		/// <summary> A MergeSpecification instance provides the information
-		/// necessary to perform multiple merges.  It simply
-		/// contains a list of <see cref="OneMerge" /> instances.
-		/// </summary>
-		
-		public class MergeSpecification
-		{
-			
-			/// <summary> The subset of segments to be included in the primitive merge.</summary>
-			
-			public IList<OneMerge> merges = new List<OneMerge>();
-			
-			public virtual void  Add(OneMerge merge)
-			{
-				merges.Add(merge);
-			}
-			
-			public virtual String SegString(Directory dir)
-			{
-				var b = new System.Text.StringBuilder();
-				b.Append("MergeSpec:\n");
-				int count = merges.Count;
-				for (int i = 0; i < count; i++)
-					b.Append("  ").Append(1 + i).Append(": ").Append(merges[i].SegString(dir));
-				return b.ToString();
-			}
-		}
-		
-		/// <summary>Exception thrown if there are any problems while
-		/// executing a merge. 
-		/// </summary>
-		[Serializable]
-		public class MergeException:System.SystemException
-		{
-			private readonly Directory dir;
+        }
+        
+        /// <summary> A MergeSpecification instance provides the information
+        /// necessary to perform multiple merges.  It simply
+        /// contains a list of <see cref="OneMerge" /> instances.
+        /// </summary>
+        
+        public class MergeSpecification
+        {
+            
+            /// <summary> The subset of segments to be included in the primitive merge.</summary>
+            
+            public IList<OneMerge> merges = new List<OneMerge>();
+            
+            public virtual void  Add(OneMerge merge)
+            {
+                merges.Add(merge);
+            }
+            
+            public virtual String SegString(Directory dir)
+            {
+                var b = new System.Text.StringBuilder();
+                b.Append("MergeSpec:\n");
+                int count = merges.Count;
+                for (int i = 0; i < count; i++)
+                    b.Append("  ").Append(1 + i).Append(": ").Append(merges[i].SegString(dir));
+                return b.ToString();
+            }
+        }
+        
+        /// <summary>Exception thrown if there are any problems while
+        /// executing a merge. 
+        /// </summary>
+        [Serializable]
+        public class MergeException:System.SystemException
+        {
+            private readonly Directory dir;
 
-			public MergeException(System.String message, Directory dir):base(message)
-			{
-				this.dir = dir;
-			}
+            public MergeException(System.String message, Directory dir):base(message)
+            {
+                this.dir = dir;
+            }
 
-			public MergeException(System.Exception exc, Directory dir):base(null, exc)
-			{
-				this.dir = dir;
-			}
+            public MergeException(System.Exception exc, Directory dir):base(null, exc)
+            {
+                this.dir = dir;
+            }
 
-		    public MergeException()
-		    {
+            public MergeException()
+            {
             }
 
-		    public MergeException(string message) : base(message)
-		    {
+            public MergeException(string message) : base(message)
+            {
             }
 
-		    public MergeException(string message, Exception ex) : base(message, ex)
-		    {
+            public MergeException(string message, Exception ex) : base(message, ex)
+            {
             }
 
             protected MergeException(
-	                SerializationInfo info,
-	                StreamingContext context) : base(info, context)
-	        {
-	        }
+                    SerializationInfo info,
+                    StreamingContext context) : base(info, context)
+            {
+            }
 
-		    /// <summary>Returns the <see cref="Directory" /> of the index that hit
-		    /// the exception. 
-		    /// </summary>
-		    public virtual Directory Directory
-		    {
-		        get { return dir; }
-		    }
-		}
+            /// <summary>Returns the <see cref="Directory" /> of the index that hit
+            /// the exception. 
+            /// </summary>
+            public virtual Directory Directory
+            {
+                get { return dir; }
+            }
+        }
 
-	    [Serializable]
+        [Serializable]
         public class MergeAbortedException : System.IO.IOException
-	    {
+        {
             public MergeAbortedException()
                 : base("merge is aborted")
-	        {
-	        }
+            {
+            }
 
-	        public MergeAbortedException(string message) : base(message)
-	        {
-	        }
+            public MergeAbortedException(string message) : base(message)
+            {
+            }
 
-	        public MergeAbortedException(string message, Exception inner) : base(message, inner)
-	        {
-	        }
+            public MergeAbortedException(string message, Exception inner) : base(message, inner)
+            {
+            }
 
-	        protected MergeAbortedException(
-	                SerializationInfo info,
-	                StreamingContext context) : base(info, context)
-	        {
-	        }
-	    }
-		
-		protected internal IndexWriter writer;
+            protected MergeAbortedException(
+                    SerializationInfo info,
+                    StreamingContext context) : base(info, context)
+            {
+            }
+        }
+        
+        protected internal IndexWriter writer;
 
-	    protected MergePolicy(IndexWriter writer)
-		{
-			this.writer = writer;
-		}
-		
-		/// <summary> Determine what set of merge operations are now necessary on the index.
-		/// <see cref="IndexWriter" /> calls this whenever there is a change to the segments.
-		/// This call is always synchronized on the <see cref="IndexWriter" /> instance so
-		/// only one thread at a time will call this method.
-		/// 
-		/// </summary>
-		/// <param name="segmentInfos">the total set of segments in the index
-		/// </param>
-		public abstract MergeSpecification FindMerges(SegmentInfos segmentInfos);
+        protected MergePolicy(IndexWriter writer)
+        {
+            this.writer = writer;
+        }
+        
+        /// <summary> Determine what set of merge operations are now necessary on the index.
+        /// <see cref="IndexWriter" /> calls this whenever there is a change to the segments.
+        /// This call is always synchronized on the <see cref="IndexWriter" /> instance so
+        /// only one thread at a time will call this method.
+        /// 
+        /// </summary>
+        /// <param name="segmentInfos">the total set of segments in the index
+        /// </param>
+        public abstract MergeSpecification FindMerges(SegmentInfos segmentInfos);
 
-	    /// <summary> Determine what set of merge operations is necessary in order to optimize
-	    /// the index. <see cref="IndexWriter" /> calls this when its
-	    /// <see cref="IndexWriter.Optimize()" /> method is called. This call is always
-	    /// synchronized on the <see cref="IndexWriter" /> instance so only one thread at a
-	    /// time will call this method.
-	    /// 
-	    /// </summary>
-	    /// <param name="segmentInfos">the total set of segments in the index
-	    /// </param>
-	    /// <param name="maxSegmentCount">requested maximum number of segments in the index (currently this
-	    /// is always 1)
-	    /// </param>
-	    /// <param name="segmentsToOptimize">contains the specific SegmentInfo instances that must be merged
-	    /// away. This may be a subset of all SegmentInfos.
-	    /// </param>
-	    public abstract MergeSpecification FindMergesForOptimize(SegmentInfos segmentInfos, int maxSegmentCount,
-	                                                             ISet<SegmentInfo> segmentsToOptimize);
-		
-		/// <summary> Determine what set of merge operations is necessary in order to expunge all
-		/// deletes from the index.
-		/// 
-		/// </summary>
-		/// <param name="segmentInfos">the total set of segments in the index
-		/// </param>
-		public abstract MergeSpecification FindMergesToExpungeDeletes(SegmentInfos segmentInfos);
+        /// <summary> Determine what set of merge operations is necessary in order to optimize
+        /// the index. <see cref="IndexWriter" /> calls this when its
+        /// <see cref="IndexWriter.Optimize()" /> method is called. This call is always
+        /// synchronized on the <see cref="IndexWriter" /> instance so only one thread at a
+        /// time will call this method.
+        /// 
+        /// </summary>
+        /// <param name="segmentInfos">the total set of segments in the index
+        /// </param>
+        /// <param name="maxSegmentCount">requested maximum number of segments in the index (currently this
+        /// is always 1)
+        /// </param>
+        /// <param name="segmentsToOptimize">contains the specific SegmentInfo instances that must be merged
+        /// away. This may be a subset of all SegmentInfos.
+        /// </param>
+        public abstract MergeSpecification FindMergesForOptimize(SegmentInfos segmentInfos, int maxSegmentCount,
+                                                                 ISet<SegmentInfo> segmentsToOptimize);
+        
+        /// <summary> Determine what set of merge operations is necessary in order to expunge all
+        /// deletes from the index.
+        /// 
+        /// </summary>
+        /// <param name="segmentInfos">the total set of segments in the index
+        /// </param>
+        public abstract MergeSpecification FindMergesToExpungeDeletes(SegmentInfos segmentInfos);
 
         /// <summary> Release all resources for the policy.</summary>
         [Obsolete("Use Dispose() instead")]
-		public void Close()
+        public void Close()
         {
             Dispose();
         }
 
         /// <summary> Release all resources for the policy.</summary>
-	    public void Dispose()
-	    {
-	        Dispose(true);
-	    }
+        public void Dispose()
+        {
+            Dispose(true);
+        }
 
-	    protected abstract void Dispose(bool disposing);
-		
-		/// <summary> Returns true if a newly flushed (not from merge)
-		/// segment should use the compound file format.
-		/// </summary>
-		public abstract bool UseCompoundFile(SegmentInfos segments, SegmentInfo newSegment);
-		
-		/// <summary> Returns true if the doc store files should use the
-		/// compound file format.
-		/// </summary>
-		public abstract bool UseCompoundDocStore(SegmentInfos segments);
-	}
+        protected abstract void Dispose(bool disposing);
+        
+        /// <summary> Returns true if a newly flushed (not from merge)
+        /// segment should use the compound file format.
+        /// </summary>
+        public abstract bool UseCompoundFile(SegmentInfos segments, SegmentInfo newSegment);
+        
+        /// <summary> Returns true if the doc store files should use the
+        /// compound file format.
+        /// </summary>
+        public abstract bool UseCompoundDocStore(SegmentInfos segments);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/core/Index/MergeScheduler.cs
----------------------------------------------------------------------
diff --git a/src/core/Index/MergeScheduler.cs b/src/core/Index/MergeScheduler.cs
index 7fbf83d..b619db2 100644
--- a/src/core/Index/MergeScheduler.cs
+++ b/src/core/Index/MergeScheduler.cs
@@ -19,30 +19,30 @@ using System;
 
 namespace Lucene.Net.Index
 {
-	
-	/// <summary><p/>Expert: <see cref="IndexWriter" /> uses an instance
-	/// implementing this interface to execute the merges
-	/// selected by a <see cref="MergePolicy" />.  The default
-	/// MergeScheduler is <see cref="ConcurrentMergeScheduler" />.<p/>
-	/// 
-	/// <p/><b>NOTE:</b> This API is new and still experimental
-	/// (subject to change suddenly in the next release)<p/>
-	/// 
-	/// <p/><b>NOTE</b>: This class typically requires access to
-	/// package-private APIs (eg, SegmentInfos) to do its job;
-	/// if you implement your own MergePolicy, you'll need to put
-	/// it in package Lucene.Net.Index in order to use
-	/// these APIs.
-	/// </summary>
-	
-	public abstract class MergeScheduler : IDisposable
-	{
-		
-		/// <summary>Run the merges provided by <see cref="IndexWriter.GetNextMerge()" />. </summary>
-		public abstract void  Merge(IndexWriter writer);
-		
+    
+    /// <summary><p/>Expert: <see cref="IndexWriter" /> uses an instance
+    /// implementing this interface to execute the merges
+    /// selected by a <see cref="MergePolicy" />.  The default
+    /// MergeScheduler is <see cref="ConcurrentMergeScheduler" />.<p/>
+    /// 
+    /// <p/><b>NOTE:</b> This API is new and still experimental
+    /// (subject to change suddenly in the next release)<p/>
+    /// 
+    /// <p/><b>NOTE</b>: This class typically requires access to
+    /// package-private APIs (eg, SegmentInfos) to do its job;
+    /// if you implement your own MergePolicy, you'll need to put
+    /// it in package Lucene.Net.Index in order to use
+    /// these APIs.
+    /// </summary>
+    
+    public abstract class MergeScheduler : IDisposable
+    {
+        
+        /// <summary>Run the merges provided by <see cref="IndexWriter.GetNextMerge()" />. </summary>
+        public abstract void  Merge(IndexWriter writer);
+        
         [Obsolete("Use Dispose() instead")]
-		public void Close()
+        public void Close()
         {
             Dispose();
         }
@@ -52,7 +52,7 @@ namespace Lucene.Net.Index
             Dispose(true);
         }
 
-	    /// <summary>Close this MergeScheduler. </summary>
-	    protected abstract void Dispose(bool disposing);
-	}
+        /// <summary>Close this MergeScheduler. </summary>
+        protected abstract void Dispose(bool disposing);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/core/Index/MultiLevelSkipListReader.cs
----------------------------------------------------------------------
diff --git a/src/core/Index/MultiLevelSkipListReader.cs b/src/core/Index/MultiLevelSkipListReader.cs
index 28b4fd5..408ecfa 100644
--- a/src/core/Index/MultiLevelSkipListReader.cs
+++ b/src/core/Index/MultiLevelSkipListReader.cs
@@ -22,161 +22,161 @@ using IndexInput = Lucene.Net.Store.IndexInput;
 
 namespace Lucene.Net.Index
 {
-	
-	/// <summary> This abstract class reads skip lists with multiple levels.
-	/// 
-	/// See <see cref="MultiLevelSkipListWriter" /> for the information about the encoding 
-	/// of the multi level skip lists. 
-	/// 
-	/// Subclasses must implement the abstract method <see cref="ReadSkipData(int, IndexInput)" />
-	/// which defines the actual format of the skip data.
-	/// </summary>
-	abstract class MultiLevelSkipListReader : IDisposable
-	{
-		// the maximum number of skip levels possible for this index
-		private readonly int maxNumberOfSkipLevels;
-		
-		// number of levels in this skip list
-		private int numberOfSkipLevels;
-		
-		// Expert: defines the number of top skip levels to buffer in memory.
-		// Reducing this number results in less memory usage, but possibly
-		// slower performance due to more random I/Os.
-		// Please notice that the space each level occupies is limited by
-		// the skipInterval. The top level can not contain more than
-		// skipLevel entries, the second top level can not contain more
-		// than skipLevel^2 entries and so forth.
-		private const int numberOfLevelsToBuffer = 1;
+    
+    /// <summary> This abstract class reads skip lists with multiple levels.
+    /// 
+    /// See <see cref="MultiLevelSkipListWriter" /> for the information about the encoding 
+    /// of the multi level skip lists. 
+    /// 
+    /// Subclasses must implement the abstract method <see cref="ReadSkipData(int, IndexInput)" />
+    /// which defines the actual format of the skip data.
+    /// </summary>
+    abstract class MultiLevelSkipListReader : IDisposable
+    {
+        // the maximum number of skip levels possible for this index
+        private readonly int maxNumberOfSkipLevels;
+        
+        // number of levels in this skip list
+        private int numberOfSkipLevels;
+        
+        // Expert: defines the number of top skip levels to buffer in memory.
+        // Reducing this number results in less memory usage, but possibly
+        // slower performance due to more random I/Os.
+        // Please notice that the space each level occupies is limited by
+        // the skipInterval. The top level can not contain more than
+        // skipLevel entries, the second top level can not contain more
+        // than skipLevel^2 entries and so forth.
+        private const int numberOfLevelsToBuffer = 1;
 
-		private int docCount;
-		private bool haveSkipped;
+        private int docCount;
+        private bool haveSkipped;
 
-	    private bool isDisposed;
-		
-		private readonly IndexInput[] skipStream; // skipStream for each level
-		private readonly long[] skipPointer; // the start pointer of each skip level
-		private readonly int[] skipInterval; // skipInterval of each level
-		private readonly int[] numSkipped; // number of docs skipped per level
-		
-		private readonly int[] skipDoc; // doc id of current skip entry per level 
-		private int lastDoc; // doc id of last read skip entry with docId <= target
-		private readonly long[] childPointer; // child pointer of current skip entry per level
-		private long lastChildPointer; // childPointer of last read skip entry with docId <= target
-		
-		private readonly bool inputIsBuffered;
+        private bool isDisposed;
+        
+        private readonly IndexInput[] skipStream; // skipStream for each level
+        private readonly long[] skipPointer; // the start pointer of each skip level
+        private readonly int[] skipInterval; // skipInterval of each level
+        private readonly int[] numSkipped; // number of docs skipped per level
+        
+        private readonly int[] skipDoc; // doc id of current skip entry per level 
+        private int lastDoc; // doc id of last read skip entry with docId <= target
+        private readonly long[] childPointer; // child pointer of current skip entry per level
+        private long lastChildPointer; // childPointer of last read skip entry with docId <= target
+        
+        private readonly bool inputIsBuffered;
 
-		protected MultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval)
-		{
-			this.skipStream = new IndexInput[maxSkipLevels];
-			this.skipPointer = new long[maxSkipLevels];
-			this.childPointer = new long[maxSkipLevels];
-			this.numSkipped = new int[maxSkipLevels];
-			this.maxNumberOfSkipLevels = maxSkipLevels;
-			this.skipInterval = new int[maxSkipLevels];
-			this.skipStream[0] = skipStream;
-			this.inputIsBuffered = (skipStream is BufferedIndexInput);
-			this.skipInterval[0] = skipInterval;
-			for (int i = 1; i < maxSkipLevels; i++)
-			{
-				// cache skip intervals
-				this.skipInterval[i] = this.skipInterval[i - 1] * skipInterval;
-			}
-			skipDoc = new int[maxSkipLevels];
-		}
-		
-		
-		/// <summary>Returns the id of the doc to which the last call of <see cref="SkipTo(int)" />
-		/// has skipped.  
-		/// </summary>
-		internal virtual int GetDoc()
-		{
-			return lastDoc;
-		}
-		
-		
-		/// <summary>Skips entries to the first beyond the current whose document number is
-		/// greater than or equal to <i>target</i>. Returns the current doc count. 
-		/// </summary>
-		internal virtual int SkipTo(int target)
-		{
-			if (!haveSkipped)
-			{
-				// first time, load skip levels
-				LoadSkipLevels();
-				haveSkipped = true;
-			}
-			
-			// walk up the levels until highest level is found that has a skip
-			// for this target
-			int level = 0;
-			while (level < numberOfSkipLevels - 1 && target > skipDoc[level + 1])
-			{
-				level++;
-			}
-			
-			while (level >= 0)
-			{
-				if (target > skipDoc[level])
-				{
-					if (!LoadNextSkip(level))
-					{
-						continue;
-					}
-				}
-				else
-				{
-					// no more skips on this level, go down one level
-					if (level > 0 && lastChildPointer > skipStream[level - 1].FilePointer)
-					{
-						SeekChild(level - 1);
-					}
-					level--;
-				}
-			}
-			
-			return numSkipped[0] - skipInterval[0] - 1;
-		}
-		
-		private bool LoadNextSkip(int level)
-		{
-			// we have to skip, the target document is greater than the current
-			// skip list entry        
-			SetLastSkipData(level);
-			
-			numSkipped[level] += skipInterval[level];
-			
-			if (numSkipped[level] > docCount)
-			{
-				// this skip list is exhausted
-				skipDoc[level] = System.Int32.MaxValue;
-				if (numberOfSkipLevels > level)
-					numberOfSkipLevels = level;
-				return false;
-			}
-			
-			// read next skip entry
-			skipDoc[level] += ReadSkipData(level, skipStream[level]);
-			
-			if (level != 0)
-			{
-				// read the child pointer if we are not on the leaf level
-				childPointer[level] = skipStream[level].ReadVLong() + skipPointer[level - 1];
-			}
-			
-			return true;
-		}
-		
-		/// <summary>Seeks the skip entry on the given level </summary>
-		protected internal virtual void  SeekChild(int level)
-		{
-			skipStream[level].Seek(lastChildPointer);
-			numSkipped[level] = numSkipped[level + 1] - skipInterval[level + 1];
-			skipDoc[level] = lastDoc;
-			if (level > 0)
-			{
-				childPointer[level] = skipStream[level].ReadVLong() + skipPointer[level - 1];
-			}
-		}
+        protected MultiLevelSkipListReader(IndexInput skipStream, int maxSkipLevels, int skipInterval)
+        {
+            this.skipStream = new IndexInput[maxSkipLevels];
+            this.skipPointer = new long[maxSkipLevels];
+            this.childPointer = new long[maxSkipLevels];
+            this.numSkipped = new int[maxSkipLevels];
+            this.maxNumberOfSkipLevels = maxSkipLevels;
+            this.skipInterval = new int[maxSkipLevels];
+            this.skipStream[0] = skipStream;
+            this.inputIsBuffered = (skipStream is BufferedIndexInput);
+            this.skipInterval[0] = skipInterval;
+            for (int i = 1; i < maxSkipLevels; i++)
+            {
+                // cache skip intervals
+                this.skipInterval[i] = this.skipInterval[i - 1] * skipInterval;
+            }
+            skipDoc = new int[maxSkipLevels];
+        }
+        
+        
+        /// <summary>Returns the id of the doc to which the last call of <see cref="SkipTo(int)" />
+        /// has skipped.  
+        /// </summary>
+        internal virtual int GetDoc()
+        {
+            return lastDoc;
+        }
+        
+        
+        /// <summary>Skips entries to the first beyond the current whose document number is
+        /// greater than or equal to <i>target</i>. Returns the current doc count. 
+        /// </summary>
+        internal virtual int SkipTo(int target)
+        {
+            if (!haveSkipped)
+            {
+                // first time, load skip levels
+                LoadSkipLevels();
+                haveSkipped = true;
+            }
+            
+            // walk up the levels until highest level is found that has a skip
+            // for this target
+            int level = 0;
+            while (level < numberOfSkipLevels - 1 && target > skipDoc[level + 1])
+            {
+                level++;
+            }
+            
+            while (level >= 0)
+            {
+                if (target > skipDoc[level])
+                {
+                    if (!LoadNextSkip(level))
+                    {
+                        continue;
+                    }
+                }
+                else
+                {
+                    // no more skips on this level, go down one level
+                    if (level > 0 && lastChildPointer > skipStream[level - 1].FilePointer)
+                    {
+                        SeekChild(level - 1);
+                    }
+                    level--;
+                }
+            }
+            
+            return numSkipped[0] - skipInterval[0] - 1;
+        }
+        
+        private bool LoadNextSkip(int level)
+        {
+            // we have to skip, the target document is greater than the current
+            // skip list entry        
+            SetLastSkipData(level);
+            
+            numSkipped[level] += skipInterval[level];
+            
+            if (numSkipped[level] > docCount)
+            {
+                // this skip list is exhausted
+                skipDoc[level] = System.Int32.MaxValue;
+                if (numberOfSkipLevels > level)
+                    numberOfSkipLevels = level;
+                return false;
+            }
+            
+            // read next skip entry
+            skipDoc[level] += ReadSkipData(level, skipStream[level]);
+            
+            if (level != 0)
+            {
+                // read the child pointer if we are not on the leaf level
+                childPointer[level] = skipStream[level].ReadVLong() + skipPointer[level - 1];
+            }
+            
+            return true;
+        }
+        
+        /// <summary>Seeks the skip entry on the given level </summary>
+        protected internal virtual void  SeekChild(int level)
+        {
+            skipStream[level].Seek(lastChildPointer);
+            numSkipped[level] = numSkipped[level + 1] - skipInterval[level + 1];
+            skipDoc[level] = lastDoc;
+            if (level > 0)
+            {
+                childPointer[level] = skipStream[level].ReadVLong() + skipPointer[level - 1];
+            }
+        }
 
         public void Dispose()
         {
@@ -200,99 +200,99 @@ namespace Lucene.Net.Index
 
             isDisposed = true;
         }
-		
-		/// <summary>initializes the reader </summary>
-		internal virtual void  Init(long skipPointer, int df)
-		{
-			this.skipPointer[0] = skipPointer;
-			this.docCount = df;
+        
+        /// <summary>initializes the reader </summary>
+        internal virtual void  Init(long skipPointer, int df)
+        {
+            this.skipPointer[0] = skipPointer;
+            this.docCount = df;
             System.Array.Clear(skipDoc, 0, skipDoc.Length);
-			System.Array.Clear(numSkipped, 0, numSkipped.Length);
+            System.Array.Clear(numSkipped, 0, numSkipped.Length);
             System.Array.Clear(childPointer, 0, childPointer.Length);
-			
-			haveSkipped = false;
-			for (int i = 1; i < numberOfSkipLevels; i++)
-			{
-				skipStream[i] = null;
-			}
-		}
-		
-		/// <summary>Loads the skip levels  </summary>
-		private void  LoadSkipLevels()
-		{
-			numberOfSkipLevels = docCount == 0?0:(int) System.Math.Floor(System.Math.Log(docCount) / System.Math.Log(skipInterval[0]));
-			if (numberOfSkipLevels > maxNumberOfSkipLevels)
-			{
-				numberOfSkipLevels = maxNumberOfSkipLevels;
-			}
-			
-			skipStream[0].Seek(skipPointer[0]);
-			
-			int toBuffer = numberOfLevelsToBuffer;
-			
-			for (int i = numberOfSkipLevels - 1; i > 0; i--)
-			{
-				// the length of the current level
-				long length = skipStream[0].ReadVLong();
-				
-				// the start pointer of the current level
-				skipPointer[i] = skipStream[0].FilePointer;
-				if (toBuffer > 0)
-				{
-					// buffer this level
-					skipStream[i] = new SkipBuffer(skipStream[0], (int) length);
-					toBuffer--;
-				}
-				else
-				{
-					// clone this stream, it is already at the start of the current level
-					skipStream[i] = (IndexInput) skipStream[0].Clone();
-					if (inputIsBuffered && length < BufferedIndexInput.BUFFER_SIZE)
-					{
-						((BufferedIndexInput) skipStream[i]).SetBufferSize((int) length);
-					}
-					
-					// move base stream beyond the current level
-					skipStream[0].Seek(skipStream[0].FilePointer + length);
-				}
-			}
-			
-			// use base stream for the lowest level
-			skipPointer[0] = skipStream[0].FilePointer;
-		}
-		
-		/// <summary> Subclasses must implement the actual skip data encoding in this method.
-		/// 
-		/// </summary>
-		/// <param name="level">the level skip data shall be read from
-		/// </param>
-		/// <param name="skipStream">the skip stream to read from
-		/// </param>
-		protected internal abstract int ReadSkipData(int level, IndexInput skipStream);
-		
-		/// <summary>Copies the values of the last read skip entry on this level </summary>
-		protected internal virtual void  SetLastSkipData(int level)
-		{
-			lastDoc = skipDoc[level];
-			lastChildPointer = childPointer[level];
-		}
-		
-		
-		/// <summary>used to buffer the top skip levels </summary>
-		private sealed class SkipBuffer : IndexInput
-		{
-			private byte[] data;
-			private readonly long pointer;
-			private int pos;
+            
+            haveSkipped = false;
+            for (int i = 1; i < numberOfSkipLevels; i++)
+            {
+                skipStream[i] = null;
+            }
+        }
+        
+        /// <summary>Loads the skip levels  </summary>
+        private void  LoadSkipLevels()
+        {
+            numberOfSkipLevels = docCount == 0?0:(int) System.Math.Floor(System.Math.Log(docCount) / System.Math.Log(skipInterval[0]));
+            if (numberOfSkipLevels > maxNumberOfSkipLevels)
+            {
+                numberOfSkipLevels = maxNumberOfSkipLevels;
+            }
+            
+            skipStream[0].Seek(skipPointer[0]);
+            
+            int toBuffer = numberOfLevelsToBuffer;
+            
+            for (int i = numberOfSkipLevels - 1; i > 0; i--)
+            {
+                // the length of the current level
+                long length = skipStream[0].ReadVLong();
+                
+                // the start pointer of the current level
+                skipPointer[i] = skipStream[0].FilePointer;
+                if (toBuffer > 0)
+                {
+                    // buffer this level
+                    skipStream[i] = new SkipBuffer(skipStream[0], (int) length);
+                    toBuffer--;
+                }
+                else
+                {
+                    // clone this stream, it is already at the start of the current level
+                    skipStream[i] = (IndexInput) skipStream[0].Clone();
+                    if (inputIsBuffered && length < BufferedIndexInput.BUFFER_SIZE)
+                    {
+                        ((BufferedIndexInput) skipStream[i]).SetBufferSize((int) length);
+                    }
+                    
+                    // move base stream beyond the current level
+                    skipStream[0].Seek(skipStream[0].FilePointer + length);
+                }
+            }
+            
+            // use base stream for the lowest level
+            skipPointer[0] = skipStream[0].FilePointer;
+        }
+        
+        /// <summary> Subclasses must implement the actual skip data encoding in this method.
+        /// 
+        /// </summary>
+        /// <param name="level">the level skip data shall be read from
+        /// </param>
+        /// <param name="skipStream">the skip stream to read from
+        /// </param>
+        protected internal abstract int ReadSkipData(int level, IndexInput skipStream);
+        
+        /// <summary>Copies the values of the last read skip entry on this level </summary>
+        protected internal virtual void  SetLastSkipData(int level)
+        {
+            lastDoc = skipDoc[level];
+            lastChildPointer = childPointer[level];
+        }
+        
+        
+        /// <summary>used to buffer the top skip levels </summary>
+        private sealed class SkipBuffer : IndexInput
+        {
+            private byte[] data;
+            private readonly long pointer;
+            private int pos;
 
-		    private bool isDisposed;
-			
-			internal SkipBuffer(IndexInput input, int length)
-			{
-				data = new byte[length];
-				pointer = input.FilePointer;
-				input.ReadBytes(data, 0, length);
-			}
+            private bool isDisposed;
+            
+            internal SkipBuffer(IndexInput input, int length)
+            {
+                data = new byte[length];
+                pointer = input.FilePointer;
+                input.ReadBytes(data, 0, length);
+            }
 
             protected override void Dispose(bool disposing)
             {
@@ -305,37 +305,37 @@ namespace Lucene.Net.Index
                 isDisposed = true;
             }
 
-		    public override long FilePointer
-		    {
-		        get { return pointer + pos; }
-		    }
+            public override long FilePointer
+            {
+                get { return pointer + pos; }
+            }
 
-		    public override long Length()
-			{
-				return data.Length;
-			}
-			
-			public override byte ReadByte()
-			{
-				return data[pos++];
-			}
-			
-			public override void  ReadBytes(byte[] b, int offset, int len)
-			{
-				Array.Copy(data, pos, b, offset, len);
-				pos += len;
-			}
-			
-			public override void  Seek(long pos)
-			{
-				this.pos = (int) (pos - pointer);
-			}
-			
-			override public System.Object Clone()
-			{
+            public override long Length()
+            {
+                return data.Length;
+            }
+            
+            public override byte ReadByte()
+            {
+                return data[pos++];
+            }
+            
+            public override void  ReadBytes(byte[] b, int offset, int len)
+            {
+                Array.Copy(data, pos, b, offset, len);
+                pos += len;
+            }
+            
+            public override void  Seek(long pos)
+            {
+                this.pos = (int) (pos - pointer);
+            }
+            
+            override public System.Object Clone()
+            {
                 System.Diagnostics.Debug.Fail("Port issue:", "Lets see if we need this FilterIndexReader.Clone()"); // {{Aroush-2.9}}
-				return null;
-			}
-		}
-	}
+                return null;
+            }
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/core/Index/MultiLevelSkipListWriter.cs
----------------------------------------------------------------------
diff --git a/src/core/Index/MultiLevelSkipListWriter.cs b/src/core/Index/MultiLevelSkipListWriter.cs
index 00543f2..4afe04f 100644
--- a/src/core/Index/MultiLevelSkipListWriter.cs
+++ b/src/core/Index/MultiLevelSkipListWriter.cs
@@ -22,150 +22,150 @@ using RAMOutputStream = Lucene.Net.Store.RAMOutputStream;
 
 namespace Lucene.Net.Index
 {
-	
-	/// <summary> This abstract class writes skip lists with multiple levels.
-	/// 
-	/// Example for skipInterval = 3:
-	/// c            (skip level 2)
-	/// c                 c                 c            (skip level 1) 
-	/// x     x     x     x     x     x     x     x     x     x      (skip level 0)
-	/// d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d  (posting list)
-	/// 3     6     9     12    15    18    21    24    27    30     (df)
-	/// 
-	/// d - document
-	/// x - skip data
-	/// c - skip data with child pointer
-	/// 
-	/// Skip level i contains every skipInterval-th entry from skip level i-1.
-	/// Therefore the number of entries on level i is: floor(df / ((skipInterval ^ (i + 1))).
-	/// 
-	/// Each skip entry on a level i>0 contains a pointer to the corresponding skip entry in list i-1.
-	/// This guarantess a logarithmic amount of skips to find the target document.
-	/// 
-	/// While this class takes care of writing the different skip levels,
-	/// subclasses must define the actual format of the skip data.
-	/// 
-	/// </summary>
-	abstract class MultiLevelSkipListWriter
-	{
-		// number of levels in this skip list
-		private int numberOfSkipLevels;
-		
-		// the skip interval in the list with level = 0
-		private int skipInterval;
-		
-		// for every skip level a different buffer is used 
-		private RAMOutputStream[] skipBuffer;
-		
-		protected internal MultiLevelSkipListWriter(int skipInterval, int maxSkipLevels, int df)
-		{
-			this.skipInterval = skipInterval;
-			
-			// calculate the maximum number of skip levels for this document frequency
-			numberOfSkipLevels = df == 0?0:(int) System.Math.Floor(System.Math.Log(df) / System.Math.Log(skipInterval));
-			
-			// make sure it does not exceed maxSkipLevels
-			if (numberOfSkipLevels > maxSkipLevels)
-			{
-				numberOfSkipLevels = maxSkipLevels;
-			}
-		}
-		
-		protected internal virtual void  Init()
-		{
-			skipBuffer = new RAMOutputStream[numberOfSkipLevels];
-			for (int i = 0; i < numberOfSkipLevels; i++)
-			{
-				skipBuffer[i] = new RAMOutputStream();
-			}
-		}
-		
-		protected internal virtual void  ResetSkip()
-		{
-			// creates new buffers or empties the existing ones
-			if (skipBuffer == null)
-			{
-				Init();
-			}
-			else
-			{
-				for (int i = 0; i < skipBuffer.Length; i++)
-				{
-					skipBuffer[i].Reset();
-				}
-			}
-		}
-		
-		/// <summary> Subclasses must implement the actual skip data encoding in this method.
-		/// 
-		/// </summary>
-		/// <param name="level">the level skip data shall be writting for
-		/// </param>
-		/// <param name="skipBuffer">the skip buffer to write to
-		/// </param>
-		protected internal abstract void  WriteSkipData(int level, IndexOutput skipBuffer);
-		
-		/// <summary> Writes the current skip data to the buffers. The current document frequency determines
-		/// the max level is skip data is to be written to. 
-		/// 
-		/// </summary>
-		/// <param name="df">the current document frequency 
-		/// </param>
-		/// <throws>  IOException </throws>
-		internal virtual void  BufferSkip(int df)
-		{
-			int numLevels;
-			
-			// determine max level
-			for (numLevels = 0; (df % skipInterval) == 0 && numLevels < numberOfSkipLevels; df /= skipInterval)
-			{
-				numLevels++;
-			}
-			
-			long childPointer = 0;
-			
-			for (int level = 0; level < numLevels; level++)
-			{
-				WriteSkipData(level, skipBuffer[level]);
-				
-				long newChildPointer = skipBuffer[level].FilePointer;
-				
-				if (level != 0)
-				{
-					// store child pointers for all levels except the lowest
-					skipBuffer[level].WriteVLong(childPointer);
-				}
-				
-				//remember the childPointer for the next level
-				childPointer = newChildPointer;
-			}
-		}
-		
-		/// <summary> Writes the buffered skip lists to the given output.
-		/// 
-		/// </summary>
-		/// <param name="output">the IndexOutput the skip lists shall be written to 
-		/// </param>
-		/// <returns> the pointer the skip list starts
-		/// </returns>
-		internal virtual long WriteSkip(IndexOutput output)
-		{
-			long skipPointer = output.FilePointer;
-			if (skipBuffer == null || skipBuffer.Length == 0)
-				return skipPointer;
-			
-			for (int level = numberOfSkipLevels - 1; level > 0; level--)
-			{
-				long length = skipBuffer[level].FilePointer;
-				if (length > 0)
-				{
-					output.WriteVLong(length);
-					skipBuffer[level].WriteTo(output);
-				}
-			}
-			skipBuffer[0].WriteTo(output);
-			
-			return skipPointer;
-		}
-	}
+    
+    /// <summary> This abstract class writes skip lists with multiple levels.
+    /// 
+    /// Example for skipInterval = 3:
+    /// c            (skip level 2)
+    /// c                 c                 c            (skip level 1) 
+    /// x     x     x     x     x     x     x     x     x     x      (skip level 0)
+    /// d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d d  (posting list)
+    /// 3     6     9     12    15    18    21    24    27    30     (df)
+    /// 
+    /// d - document
+    /// x - skip data
+    /// c - skip data with child pointer
+    /// 
+    /// Skip level i contains every skipInterval-th entry from skip level i-1.
+    /// Therefore the number of entries on level i is: floor(df / ((skipInterval ^ (i + 1))).
+    /// 
+    /// Each skip entry on a level i>0 contains a pointer to the corresponding skip entry in list i-1.
+    /// This guarantess a logarithmic amount of skips to find the target document.
+    /// 
+    /// While this class takes care of writing the different skip levels,
+    /// subclasses must define the actual format of the skip data.
+    /// 
+    /// </summary>
+    abstract class MultiLevelSkipListWriter
+    {
+        // number of levels in this skip list
+        private int numberOfSkipLevels;
+        
+        // the skip interval in the list with level = 0
+        private int skipInterval;
+        
+        // for every skip level a different buffer is used 
+        private RAMOutputStream[] skipBuffer;
+        
+        protected internal MultiLevelSkipListWriter(int skipInterval, int maxSkipLevels, int df)
+        {
+            this.skipInterval = skipInterval;
+            
+            // calculate the maximum number of skip levels for this document frequency
+            numberOfSkipLevels = df == 0?0:(int) System.Math.Floor(System.Math.Log(df) / System.Math.Log(skipInterval));
+            
+            // make sure it does not exceed maxSkipLevels
+            if (numberOfSkipLevels > maxSkipLevels)
+            {
+                numberOfSkipLevels = maxSkipLevels;
+            }
+        }
+        
+        protected internal virtual void  Init()
+        {
+            skipBuffer = new RAMOutputStream[numberOfSkipLevels];
+            for (int i = 0; i < numberOfSkipLevels; i++)
+            {
+                skipBuffer[i] = new RAMOutputStream();
+            }
+        }
+        
+        protected internal virtual void  ResetSkip()
+        {
+            // creates new buffers or empties the existing ones
+            if (skipBuffer == null)
+            {
+                Init();
+            }
+            else
+            {
+                for (int i = 0; i < skipBuffer.Length; i++)
+                {
+                    skipBuffer[i].Reset();
+                }
+            }
+        }
+        
+        /// <summary> Subclasses must implement the actual skip data encoding in this method.
+        /// 
+        /// </summary>
+        /// <param name="level">the level skip data shall be writting for
+        /// </param>
+        /// <param name="skipBuffer">the skip buffer to write to
+        /// </param>
+        protected internal abstract void  WriteSkipData(int level, IndexOutput skipBuffer);
+        
+        /// <summary> Writes the current skip data to the buffers. The current document frequency determines
+        /// the max level is skip data is to be written to. 
+        /// 
+        /// </summary>
+        /// <param name="df">the current document frequency 
+        /// </param>
+        /// <throws>  IOException </throws>
+        internal virtual void  BufferSkip(int df)
+        {
+            int numLevels;
+            
+            // determine max level
+            for (numLevels = 0; (df % skipInterval) == 0 && numLevels < numberOfSkipLevels; df /= skipInterval)
+            {
+                numLevels++;
+            }
+            
+            long childPointer = 0;
+            
+            for (int level = 0; level < numLevels; level++)
+            {
+                WriteSkipData(level, skipBuffer[level]);
+                
+                long newChildPointer = skipBuffer[level].FilePointer;
+                
+                if (level != 0)
+                {
+                    // store child pointers for all levels except the lowest
+                    skipBuffer[level].WriteVLong(childPointer);
+                }
+                
+                //remember the childPointer for the next level
+                childPointer = newChildPointer;
+            }
+        }
+        
+        /// <summary> Writes the buffered skip lists to the given output.
+        /// 
+        /// </summary>
+        /// <param name="output">the IndexOutput the skip lists shall be written to 
+        /// </param>
+        /// <returns> the pointer the skip list starts
+        /// </returns>
+        internal virtual long WriteSkip(IndexOutput output)
+        {
+            long skipPointer = output.FilePointer;
+            if (skipBuffer == null || skipBuffer.Length == 0)
+                return skipPointer;
+            
+            for (int level = numberOfSkipLevels - 1; level > 0; level--)
+            {
+                long length = skipBuffer[level].FilePointer;
+                if (length > 0)
+                {
+                    output.WriteVLong(length);
+                    skipBuffer[level].WriteTo(output);
+                }
+            }
+            skipBuffer[0].WriteTo(output);
+            
+            return skipPointer;
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/core/Index/MultipleTermPositions.cs
----------------------------------------------------------------------
diff --git a/src/core/Index/MultipleTermPositions.cs b/src/core/Index/MultipleTermPositions.cs
index eab3dd5..34f3d65 100644
--- a/src/core/Index/MultipleTermPositions.cs
+++ b/src/core/Index/MultipleTermPositions.cs
@@ -21,175 +21,175 @@ using Lucene.Net.Util;
 
 namespace Lucene.Net.Index
 {
-	
-	/// <summary> Allows you to iterate over the <see cref="TermPositions" /> for multiple <see cref="Term" />s as
-	/// a single <see cref="TermPositions" />.
-	/// 
-	/// </summary>
-	public class MultipleTermPositions : TermPositions
-	{
-		private sealed class TermPositionsQueue : PriorityQueue<TermPositions>
-		{
-			internal TermPositionsQueue(LinkedList<TermPositions> termPositions)
-			{
-				Initialize(termPositions.Count);
-				
-				foreach(TermPositions tp in termPositions)
-					if (tp.Next())
-						Add(tp);
-			}
-			
-			internal TermPositions Peek()
-			{
-				return Top();
-			}
-			
-			public override bool LessThan(TermPositions a, TermPositions b)
-			{
-				return a.Doc < b.Doc;
-			}
-		}
-		
-		private sealed class IntQueue
-		{
-			public IntQueue()
-			{
-				InitBlock();
-			}
-			private void  InitBlock()
-			{
-				_array = new int[_arraySize];
-			}
-			private int _arraySize = 16;
-			private int _index = 0;
-			private int _lastIndex = 0;
-			private int[] _array;
-			
-			internal void  add(int i)
-			{
-				if (_lastIndex == _arraySize)
-					growArray();
-				
-				_array[_lastIndex++] = i;
-			}
-			
-			internal int next()
-			{
-				return _array[_index++];
-			}
-			
-			internal void  sort()
-			{
-				System.Array.Sort(_array, _index, _lastIndex - _index);
-			}
-			
-			internal void  clear()
-			{
-				_index = 0;
-				_lastIndex = 0;
-			}
-			
-			internal int size()
-			{
-				return (_lastIndex - _index);
-			}
-			
-			private void  growArray()
-			{
-				int[] newArray = new int[_arraySize * 2];
-				Array.Copy(_array, 0, newArray, 0, _arraySize);
-				_array = newArray;
-				_arraySize *= 2;
-			}
-		}
-		
-		private int _doc;
-		private int _freq;
-		private TermPositionsQueue _termPositionsQueue;
-		private IntQueue _posList;
+    
+    /// <summary> Allows you to iterate over the <see cref="TermPositions" /> for multiple <see cref="Term" />s as
+    /// a single <see cref="TermPositions" />.
+    /// 
+    /// </summary>
+    public class MultipleTermPositions : TermPositions
+    {
+        private sealed class TermPositionsQueue : PriorityQueue<TermPositions>
+        {
+            internal TermPositionsQueue(LinkedList<TermPositions> termPositions)
+            {
+                Initialize(termPositions.Count);
+                
+                foreach(TermPositions tp in termPositions)
+                    if (tp.Next())
+                        Add(tp);
+            }
+            
+            internal TermPositions Peek()
+            {
+                return Top();
+            }
+            
+            public override bool LessThan(TermPositions a, TermPositions b)
+            {
+                return a.Doc < b.Doc;
+            }
+        }
+        
+        private sealed class IntQueue
+        {
+            public IntQueue()
+            {
+                InitBlock();
+            }
+            private void  InitBlock()
+            {
+                _array = new int[_arraySize];
+            }
+            private int _arraySize = 16;
+            private int _index = 0;
+            private int _lastIndex = 0;
+            private int[] _array;
+            
+            internal void  add(int i)
+            {
+                if (_lastIndex == _arraySize)
+                    growArray();
+                
+                _array[_lastIndex++] = i;
+            }
+            
+            internal int next()
+            {
+                return _array[_index++];
+            }
+            
+            internal void  sort()
+            {
+                System.Array.Sort(_array, _index, _lastIndex - _index);
+            }
+            
+            internal void  clear()
+            {
+                _index = 0;
+                _lastIndex = 0;
+            }
+            
+            internal int size()
+            {
+                return (_lastIndex - _index);
+            }
+            
+            private void  growArray()
+            {
+                int[] newArray = new int[_arraySize * 2];
+                Array.Copy(_array, 0, newArray, 0, _arraySize);
+                _array = newArray;
+                _arraySize *= 2;
+            }
+        }
+        
+        private int _doc;
+        private int _freq;
+        private TermPositionsQueue _termPositionsQueue;
+        private IntQueue _posList;
 
-	    private bool isDisposed;
-		/// <summary> Creates a new <c>MultipleTermPositions</c> instance.
-		/// 
-		/// </summary>
-		/// <exception cref="System.IO.IOException">
-		/// </exception>
-		public MultipleTermPositions(IndexReader indexReader, Term[] terms)
-		{
-			var termPositions = new System.Collections.Generic.LinkedList<TermPositions>();
-			
-			for (int i = 0; i < terms.Length; i++)
-				termPositions.AddLast(indexReader.TermPositions(terms[i]));
-			
-			_termPositionsQueue = new TermPositionsQueue(termPositions);
-			_posList = new IntQueue();
-		}
-		
-		public bool Next()
-		{
-			if (_termPositionsQueue.Size() == 0)
-				return false;
-			
-			_posList.clear();
-			_doc = _termPositionsQueue.Peek().Doc;
-			
-			TermPositions tp;
-			do 
-			{
-				tp = _termPositionsQueue.Peek();
-				
-				for (int i = 0; i < tp.Freq; i++)
-					_posList.add(tp.NextPosition());
-				
-				if (tp.Next())
-					_termPositionsQueue.UpdateTop();
-				else
-				{
-					_termPositionsQueue.Pop();
-					tp.Close();
-				}
-			}
-			while (_termPositionsQueue.Size() > 0 && _termPositionsQueue.Peek().Doc == _doc);
-			
-			_posList.sort();
-			_freq = _posList.size();
-			
-			return true;
-		}
-		
-		public int NextPosition()
-		{
-			return _posList.next();
-		}
-		
-		public bool SkipTo(int target)
-		{
-			while (_termPositionsQueue.Peek() != null && target > _termPositionsQueue.Peek().Doc)
-			{
-				TermPositions tp = _termPositionsQueue.Pop();
-				if (tp.SkipTo(target))
-					_termPositionsQueue.Add(tp);
-				else
-					tp.Close();
-			}
-			return Next();
-		}
+        private bool isDisposed;
+        /// <summary> Creates a new <c>MultipleTermPositions</c> instance.
+        /// 
+        /// </summary>
+        /// <exception cref="System.IO.IOException">
+        /// </exception>
+        public MultipleTermPositions(IndexReader indexReader, Term[] terms)
+        {
+            var termPositions = new System.Collections.Generic.LinkedList<TermPositions>();
+            
+            for (int i = 0; i < terms.Length; i++)
+                termPositions.AddLast(indexReader.TermPositions(terms[i]));
+            
+            _termPositionsQueue = new TermPositionsQueue(termPositions);
+            _posList = new IntQueue();
+        }
+        
+        public bool Next()
+        {
+            if (_termPositionsQueue.Size() == 0)
+                return false;
+            
+            _posList.clear();
+            _doc = _termPositionsQueue.Peek().Doc;
+            
+            TermPositions tp;
+            do 
+            {
+                tp = _termPositionsQueue.Peek();
+                
+                for (int i = 0; i < tp.Freq; i++)
+                    _posList.add(tp.NextPosition());
+                
+                if (tp.Next())
+                    _termPositionsQueue.UpdateTop();
+                else
+                {
+                    _termPositionsQueue.Pop();
+                    tp.Close();
+                }
+            }
+            while (_termPositionsQueue.Size() > 0 && _termPositionsQueue.Peek().Doc == _doc);
+            
+            _posList.sort();
+            _freq = _posList.size();
+            
+            return true;
+        }
+        
+        public int NextPosition()
+        {
+            return _posList.next();
+        }
+        
+        public bool SkipTo(int target)
+        {
+            while (_termPositionsQueue.Peek() != null && target > _termPositionsQueue.Peek().Doc)
+            {
+                TermPositions tp = _termPositionsQueue.Pop();
+                if (tp.SkipTo(target))
+                    _termPositionsQueue.Add(tp);
+                else
+                    tp.Close();
+            }
+            return Next();
+        }
 
-	    public int Doc
-	    {
-	        get { return _doc; }
-	    }
+        public int Doc
+        {
+            get { return _doc; }
+        }
 
-	    public int Freq
-	    {
-	        get { return _freq; }
-	    }
+        public int Freq
+        {
+            get { return _freq; }
+        }
 
-	    [Obsolete("Use Dispose() instead")]
-		public void  Close()
-		{
-		    Dispose();
-		}
+        [Obsolete("Use Dispose() instead")]
+        public void  Close()
+        {
+            Dispose();
+        }
 
         public void Dispose()
         {
@@ -208,49 +208,49 @@ namespace Lucene.Net.Index
 
             isDisposed = true;
         }
-		
-		/// <summary> Not implemented.</summary>
-		/// <throws>  UnsupportedOperationException </throws>
-		public virtual void Seek(Term arg0)
-		{
-			throw new System.NotSupportedException();
-		}
-		
-		/// <summary> Not implemented.</summary>
-		/// <throws>  UnsupportedOperationException </throws>
-		public virtual void Seek(TermEnum termEnum)
-		{
-			throw new System.NotSupportedException();
-		}
-		
-		/// <summary> Not implemented.</summary>
-		/// <throws>  UnsupportedOperationException </throws>
-		public virtual int Read(int[] arg0, int[] arg1)
-		{
-			throw new System.NotSupportedException();
-		}
+        
+        /// <summary> Not implemented.</summary>
+        /// <throws>  UnsupportedOperationException </throws>
+        public virtual void Seek(Term arg0)
+        {
+            throw new System.NotSupportedException();
+        }
+        
+        /// <summary> Not implemented.</summary>
+        /// <throws>  UnsupportedOperationException </throws>
+        public virtual void Seek(TermEnum termEnum)
+        {
+            throw new System.NotSupportedException();
+        }
+        
+        /// <summary> Not implemented.</summary>
+        /// <throws>  UnsupportedOperationException </throws>
+        public virtual int Read(int[] arg0, int[] arg1)
+        {
+            throw new System.NotSupportedException();
+        }
 
 
-	    /// <summary> Not implemented.</summary>
-	    /// <throws>  UnsupportedOperationException </throws>
-	    public virtual int PayloadLength
-	    {
-	        get { throw new System.NotSupportedException(); }
-	    }
+        /// <summary> Not implemented.</summary>
+        /// <throws>  UnsupportedOperationException </throws>
+        public virtual int PayloadLength
+        {
+            get { throw new System.NotSupportedException(); }
+        }
 
-	    /// <summary> Not implemented.</summary>
-		/// <throws>  UnsupportedOperationException </throws>
-		public virtual byte[] GetPayload(byte[] data, int offset)
-		{
-			throw new System.NotSupportedException();
-		}
+        /// <summary> Not implemented.</summary>
+        /// <throws>  UnsupportedOperationException </throws>
+        public virtual byte[] GetPayload(byte[] data, int offset)
+        {
+            throw new System.NotSupportedException();
+        }
 
-	    /// <summary> </summary>
-	    /// <value> false </value>
+        /// <summary> </summary>
+        /// <value> false </value>
 // TODO: Remove warning after API has been finalized
-	    public virtual bool IsPayloadAvailable
-	    {
-	        get { return false; }
-	    }
-	}
+        public virtual bool IsPayloadAvailable
+        {
+            get { return false; }
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/core/Index/NormsWriter.cs
----------------------------------------------------------------------
diff --git a/src/core/Index/NormsWriter.cs b/src/core/Index/NormsWriter.cs
index 507d69c..46bb941 100644
--- a/src/core/Index/NormsWriter.cs
+++ b/src/core/Index/NormsWriter.cs
@@ -23,184 +23,184 @@ using Similarity = Lucene.Net.Search.Similarity;
 
 namespace Lucene.Net.Index
 {
-	
-	// TODO FI: norms could actually be stored as doc store
-	
-	/// <summary>Writes norms.  Each thread X field accumulates the norms
-	/// for the doc/fields it saw, then the flush method below
-	/// merges all of these together into a single _X.nrm file.
-	/// </summary>
-	
-	sealed class NormsWriter : InvertedDocEndConsumer
-	{
-		
-		private static readonly byte defaultNorm;
-		private FieldInfos fieldInfos;
-		public override InvertedDocEndConsumerPerThread AddThread(DocInverterPerThread docInverterPerThread)
-		{
-			return new NormsWriterPerThread(docInverterPerThread, this);
-		}
-		
-		public override void  Abort()
-		{
-		}
-		
-		// We only write the _X.nrm file at flush
-		internal void  Files(ICollection<string> files)
-		{
-		}
-		
-		internal override void  SetFieldInfos(FieldInfos fieldInfos)
-		{
-			this.fieldInfos = fieldInfos;
-		}
-		
-		/// <summary>Produce _X.nrm if any document had a field with norms
-		/// not disabled 
-		/// </summary>
+    
+    // TODO FI: norms could actually be stored as doc store
+    
+    /// <summary>Writes norms.  Each thread X field accumulates the norms
+    /// for the doc/fields it saw, then the flush method below
+    /// merges all of these together into a single _X.nrm file.
+    /// </summary>
+    
+    sealed class NormsWriter : InvertedDocEndConsumer
+    {
+        
+        private static readonly byte defaultNorm;
+        private FieldInfos fieldInfos;
+        public override InvertedDocEndConsumerPerThread AddThread(DocInverterPerThread docInverterPerThread)
+        {
+            return new NormsWriterPerThread(docInverterPerThread, this);
+        }
+        
+        public override void  Abort()
+        {
+        }
+        
+        // We only write the _X.nrm file at flush
+        internal void  Files(ICollection<string> files)
+        {
+        }
+        
+        internal override void  SetFieldInfos(FieldInfos fieldInfos)
+        {
+            this.fieldInfos = fieldInfos;
+        }
+        
+        /// <summary>Produce _X.nrm if any document had a field with norms
+        /// not disabled 
+        /// </summary>
         public override void Flush(IDictionary<InvertedDocEndConsumerPerThread,ICollection<InvertedDocEndConsumerPerField>> threadsAndFields, SegmentWriteState state)
-		{
+        {
 
             IDictionary<FieldInfo, IList<NormsWriterPerField>> byField = new HashMap<FieldInfo, IList<NormsWriterPerField>>();
-			
-			// Typically, each thread will have encountered the same
-			// field.  So first we collate by field, ie, all
-			// per-thread field instances that correspond to the
-			// same FieldInfo
-			foreach(var entry in threadsAndFields)
-			{
-				ICollection<InvertedDocEndConsumerPerField> fields = entry.Value;
-				IEnumerator<InvertedDocEndConsumerPerField> fieldsIt = fields.GetEnumerator();
-			    var fieldsToRemove = new HashSet<NormsWriterPerField>();
-				while (fieldsIt.MoveNext())
-				{
-					NormsWriterPerField perField = (NormsWriterPerField) fieldsIt.Current;
-					
-					if (perField.upto > 0)
-					{
-						// It has some norms
-						IList<NormsWriterPerField> l = byField[perField.fieldInfo];
-						if (l == null)
-						{
-							l = new List<NormsWriterPerField>();
-							byField[perField.fieldInfo] = l;
-						}
-						l.Add(perField);
-					}
-					// Remove this field since we haven't seen it
-					// since the previous flush
-					else
-					{
+            
+            // Typically, each thread will have encountered the same
+            // field.  So first we collate by field, ie, all
+            // per-thread field instances that correspond to the
+            // same FieldInfo
+            foreach(var entry in threadsAndFields)
+            {
+                ICollection<InvertedDocEndConsumerPerField> fields = entry.Value;
+                IEnumerator<InvertedDocEndConsumerPerField> fieldsIt = fields.GetEnumerator();
+                var fieldsToRemove = new HashSet<NormsWriterPerField>();
+                while (fieldsIt.MoveNext())
+                {
+                    NormsWriterPerField perField = (NormsWriterPerField) fieldsIt.Current;
+                    
+                    if (perField.upto > 0)
+                    {
+                        // It has some norms
+                        IList<NormsWriterPerField> l = byField[perField.fieldInfo];
+                        if (l == null)
+                        {
+                            l = new List<NormsWriterPerField>();
+                            byField[perField.fieldInfo] = l;
+                        }
+                        l.Add(perField);
+                    }
+                    // Remove this field since we haven't seen it
+                    // since the previous flush
+                    else
+                    {
                         fieldsToRemove.Add(perField);
-					}
-				}
+                    }
+                }
                 foreach (var field in fieldsToRemove)
                 {
                     fields.Remove(field);
                 }
-			}
-			
-			System.String normsFileName = state.segmentName + "." + IndexFileNames.NORMS_EXTENSION;
-			state.flushedFiles.Add(normsFileName);
-			IndexOutput normsOut = state.directory.CreateOutput(normsFileName);
-			
-			try
-			{
-				normsOut.WriteBytes(SegmentMerger.NORMS_HEADER, 0, SegmentMerger.NORMS_HEADER.Length);
-				
-				int numField = fieldInfos.Size();
-				
-				int normCount = 0;
-				
-				for (int fieldNumber = 0; fieldNumber < numField; fieldNumber++)
-				{
-					
-					FieldInfo fieldInfo = fieldInfos.FieldInfo(fieldNumber);
-					
-					IList<NormsWriterPerField> toMerge = byField[fieldInfo];
-					int upto = 0;
-					if (toMerge != null)
-					{
-						
-						int numFields = toMerge.Count;
-						
-						normCount++;
-						
-						NormsWriterPerField[] fields = new NormsWriterPerField[numFields];
-						int[] uptos = new int[numFields];
-						
-						for (int j = 0; j < numFields; j++)
-							fields[j] = toMerge[j];
-						
-						int numLeft = numFields;
-						
-						while (numLeft > 0)
-						{
-							
-							System.Diagnostics.Debug.Assert(uptos [0] < fields [0].docIDs.Length, " uptos[0]=" + uptos [0] + " len=" +(fields [0].docIDs.Length));
-							
-							int minLoc = 0;
-							int minDocID = fields[0].docIDs[uptos[0]];
-							
-							for (int j = 1; j < numLeft; j++)
-							{
-								int docID = fields[j].docIDs[uptos[j]];
-								if (docID < minDocID)
-								{
-									minDocID = docID;
-									minLoc = j;
-								}
-							}
-							
-							System.Diagnostics.Debug.Assert(minDocID < state.numDocs);
-							
-							// Fill hole
-							for (; upto < minDocID; upto++)
-								normsOut.WriteByte(defaultNorm);
-							
-							normsOut.WriteByte(fields[minLoc].norms[uptos[minLoc]]);
-							(uptos[minLoc])++;
-							upto++;
-							
-							if (uptos[minLoc] == fields[minLoc].upto)
-							{
-								fields[minLoc].Reset();
-								if (minLoc != numLeft - 1)
-								{
-									fields[minLoc] = fields[numLeft - 1];
-									uptos[minLoc] = uptos[numLeft - 1];
-								}
-								numLeft--;
-							}
-						}
-						
-						// Fill final hole with defaultNorm
-						for (; upto < state.numDocs; upto++)
-							normsOut.WriteByte(defaultNorm);
-					}
-					else if (fieldInfo.isIndexed && !fieldInfo.omitNorms)
-					{
-						normCount++;
-						// Fill entire field with default norm:
-						for (; upto < state.numDocs; upto++)
-							normsOut.WriteByte(defaultNorm);
-					}
-					
-					System.Diagnostics.Debug.Assert(4 + normCount * state.numDocs == normsOut.FilePointer, ".nrm file size mismatch: expected=" +(4 + normCount * state.numDocs) + " actual=" + normsOut.FilePointer);
-				}
-			}
-			finally
-			{
-				normsOut.Close();
-			}
-		}
-		
-		internal override void  CloseDocStore(SegmentWriteState state)
-		{
-		}
-		static NormsWriter()
-		{
-			defaultNorm = Similarity.EncodeNorm(1.0f);
-		}
-	}
+            }
+            
+            System.String normsFileName = state.segmentName + "." + IndexFileNames.NORMS_EXTENSION;
+            state.flushedFiles.Add(normsFileName);
+            IndexOutput normsOut = state.directory.CreateOutput(normsFileName);
+            
+            try
+            {
+                normsOut.WriteBytes(SegmentMerger.NORMS_HEADER, 0, SegmentMerger.NORMS_HEADER.Length);
+                
+                int numField = fieldInfos.Size();
+                
+                int normCount = 0;
+                
+                for (int fieldNumber = 0; fieldNumber < numField; fieldNumber++)
+                {
+                    
+                    FieldInfo fieldInfo = fieldInfos.FieldInfo(fieldNumber);
+                    
+                    IList<NormsWriterPerField> toMerge = byField[fieldInfo];
+                    int upto = 0;
+                    if (toMerge != null)
+                    {
+                        
+                        int numFields = toMerge.Count;
+                        
+                        normCount++;
+                        
+                        NormsWriterPerField[] fields = new NormsWriterPerField[numFields];
+                        int[] uptos = new int[numFields];
+                        
+                        for (int j = 0; j < numFields; j++)
+                            fields[j] = toMerge[j];
+                        
+                        int numLeft = numFields;
+                        
+                        while (numLeft > 0)
+                        {
+                            
+                            System.Diagnostics.Debug.Assert(uptos [0] < fields [0].docIDs.Length, " uptos[0]=" + uptos [0] + " len=" +(fields [0].docIDs.Length));
+                            
+                            int minLoc = 0;
+                            int minDocID = fields[0].docIDs[uptos[0]];
+                            
+                            for (int j = 1; j < numLeft; j++)
+                            {
+                                int docID = fields[j].docIDs[uptos[j]];
+                                if (docID < minDocID)
+                                {
+                                    minDocID = docID;
+                                    minLoc = j;
+                                }
+                            }
+                            
+                            System.Diagnostics.Debug.Assert(minDocID < state.numDocs);
+                            
+                            // Fill hole
+                            for (; upto < minDocID; upto++)
+                                normsOut.WriteByte(defaultNorm);
+                            
+                            normsOut.WriteByte(fields[minLoc].norms[uptos[minLoc]]);
+                            (uptos[minLoc])++;
+                            upto++;
+                            
+                            if (uptos[minLoc] == fields[minLoc].upto)
+                            {
+                                fields[minLoc].Reset();
+                                if (minLoc != numLeft - 1)
+                                {
+                                    fields[minLoc] = fields[numLeft - 1];
+                                    uptos[minLoc] = uptos[numLeft - 1];
+                                }
+                                numLeft--;
+                            }
+                        }
+                        
+                        // Fill final hole with defaultNorm
+                        for (; upto < state.numDocs; upto++)
+                            normsOut.WriteByte(defaultNorm);
+                    }
+                    else if (fieldInfo.isIndexed && !fieldInfo.omitNorms)
+                    {
+                        normCount++;
+                        // Fill entire field with default norm:
+                        for (; upto < state.numDocs; upto++)
+                            normsOut.WriteByte(defaultNorm);
+                    }
+                    
+                    System.Diagnostics.Debug.Assert(4 + normCount * state.numDocs == normsOut.FilePointer, ".nrm file size mismatch: expected=" +(4 + normCount * state.numDocs) + " actual=" + normsOut.FilePointer);
+                }
+            }
+            finally
+            {
+                normsOut.Close();
+            }
+        }
+        
+        internal override void  CloseDocStore(SegmentWriteState state)
+        {
+        }
+        static NormsWriter()
+        {
+            defaultNorm = Similarity.EncodeNorm(1.0f);
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/core/Index/NormsWriterPerField.cs
----------------------------------------------------------------------
diff --git a/src/core/Index/NormsWriterPerField.cs b/src/core/Index/NormsWriterPerField.cs
index 81d45df..9d2153d 100644
--- a/src/core/Index/NormsWriterPerField.cs
+++ b/src/core/Index/NormsWriterPerField.cs
@@ -22,69 +22,69 @@ using Similarity = Lucene.Net.Search.Similarity;
 
 namespace Lucene.Net.Index
 {
-	
-	/// <summary>Taps into DocInverter, as an InvertedDocEndConsumer,
-	/// which is called at the end of inverting each field.  We
-	/// just look at the length for the field (docState.length)
-	/// and record the norm. 
-	/// </summary>
-	
-	sealed class NormsWriterPerField:InvertedDocEndConsumerPerField, System.IComparable<NormsWriterPerField>
-	{
-		
-		internal NormsWriterPerThread perThread;
-		internal FieldInfo fieldInfo;
-		internal DocumentsWriter.DocState docState;
-		
-		// Holds all docID/norm pairs we've seen
-		internal int[] docIDs = new int[1];
-		internal byte[] norms = new byte[1];
-		internal int upto;
-		
-		internal FieldInvertState fieldState;
-		
-		public void  Reset()
-		{
-			// Shrink back if we are overallocated now:
-			docIDs = ArrayUtil.Shrink(docIDs, upto);
-			norms = ArrayUtil.Shrink(norms, upto);
-			upto = 0;
-		}
-		
-		public NormsWriterPerField(DocInverterPerField docInverterPerField, NormsWriterPerThread perThread, FieldInfo fieldInfo)
-		{
-			this.perThread = perThread;
-			this.fieldInfo = fieldInfo;
-			docState = perThread.docState;
-			fieldState = docInverterPerField.fieldState;
-		}
-		
-		internal override void  Abort()
-		{
-			upto = 0;
-		}
-		
-		public int CompareTo(NormsWriterPerField other)
-		{
-			return String.CompareOrdinal(fieldInfo.name, other.fieldInfo.name);
-		}
-		
-		internal override void  Finish()
-		{
-			System.Diagnostics.Debug.Assert(docIDs.Length == norms.Length);
-			if (fieldInfo.isIndexed && !fieldInfo.omitNorms)
-			{
-				if (docIDs.Length <= upto)
-				{
-					System.Diagnostics.Debug.Assert(docIDs.Length == upto);
-					docIDs = ArrayUtil.Grow(docIDs, 1 + upto);
-					norms = ArrayUtil.Grow(norms, 1 + upto);
-				}
-				float norm = docState.similarity.ComputeNorm(fieldInfo.name, fieldState);
-				norms[upto] = Similarity.EncodeNorm(norm);
-				docIDs[upto] = docState.docID;
-				upto++;
-			}
-		}
-	}
+    
+    /// <summary>Taps into DocInverter, as an InvertedDocEndConsumer,
+    /// which is called at the end of inverting each field.  We
+    /// just look at the length for the field (docState.length)
+    /// and record the norm. 
+    /// </summary>
+    
+    sealed class NormsWriterPerField:InvertedDocEndConsumerPerField, System.IComparable<NormsWriterPerField>
+    {
+        
+        internal NormsWriterPerThread perThread;
+        internal FieldInfo fieldInfo;
+        internal DocumentsWriter.DocState docState;
+        
+        // Holds all docID/norm pairs we've seen
+        internal int[] docIDs = new int[1];
+        internal byte[] norms = new byte[1];
+        internal int upto;
+        
+        internal FieldInvertState fieldState;
+        
+        public void  Reset()
+        {
+            // Shrink back if we are overallocated now:
+            docIDs = ArrayUtil.Shrink(docIDs, upto);
+            norms = ArrayUtil.Shrink(norms, upto);
+            upto = 0;
+        }
+        
+        public NormsWriterPerField(DocInverterPerField docInverterPerField, NormsWriterPerThread perThread, FieldInfo fieldInfo)
+        {
+            this.perThread = perThread;
+            this.fieldInfo = fieldInfo;
+            docState = perThread.docState;
+            fieldState = docInverterPerField.fieldState;
+        }
+        
+        internal override void  Abort()
+        {
+            upto = 0;
+        }
+        
+        public int CompareTo(NormsWriterPerField other)
+        {
+            return String.CompareOrdinal(fieldInfo.name, other.fieldInfo.name);
+        }
+        
+        internal override void  Finish()
+        {
+            System.Diagnostics.Debug.Assert(docIDs.Length == norms.Length);
+            if (fieldInfo.isIndexed && !fieldInfo.omitNorms)
+            {
+                if (docIDs.Length <= upto)
+                {
+                    System.Diagnostics.Debug.Assert(docIDs.Length == upto);
+                    docIDs = ArrayUtil.Grow(docIDs, 1 + upto);
+                    norms = ArrayUtil.Grow(norms, 1 + upto);
+                }
+                float norm = docState.similarity.ComputeNorm(fieldInfo.name, fieldState);
+                norms[upto] = Similarity.EncodeNorm(norm);
+                docIDs[upto] = docState.docID;
+                upto++;
+            }
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/core/Index/NormsWriterPerThread.cs
----------------------------------------------------------------------
diff --git a/src/core/Index/NormsWriterPerThread.cs b/src/core/Index/NormsWriterPerThread.cs
index d5cd5ed..6d83f84 100644
--- a/src/core/Index/NormsWriterPerThread.cs
+++ b/src/core/Index/NormsWriterPerThread.cs
@@ -19,37 +19,37 @@ using System;
 
 namespace Lucene.Net.Index
 {
-	
-	sealed class NormsWriterPerThread:InvertedDocEndConsumerPerThread
-	{
-		internal NormsWriter normsWriter;
-		internal DocumentsWriter.DocState docState;
-		
-		public NormsWriterPerThread(DocInverterPerThread docInverterPerThread, NormsWriter normsWriter)
-		{
-			this.normsWriter = normsWriter;
-			docState = docInverterPerThread.docState;
-		}
-		
-		internal override InvertedDocEndConsumerPerField AddField(DocInverterPerField docInverterPerField, FieldInfo fieldInfo)
-		{
-			return new NormsWriterPerField(docInverterPerField, this, fieldInfo);
-		}
-		
-		internal override void  Abort()
-		{
-		}
-		
-		internal override void  StartDocument()
-		{
-		}
-		internal override void  FinishDocument()
-		{
-		}
-		
-		internal bool FreeRAM()
-		{
-			return false;
-		}
-	}
+    
+    sealed class NormsWriterPerThread:InvertedDocEndConsumerPerThread
+    {
+        internal NormsWriter normsWriter;
+        internal DocumentsWriter.DocState docState;
+        
+        public NormsWriterPerThread(DocInverterPerThread docInverterPerThread, NormsWriter normsWriter)
+        {
+            this.normsWriter = normsWriter;
+            docState = docInverterPerThread.docState;
+        }
+        
+        internal override InvertedDocEndConsumerPerField AddField(DocInverterPerField docInverterPerField, FieldInfo fieldInfo)
+        {
+            return new NormsWriterPerField(docInverterPerField, this, fieldInfo);
+        }
+        
+        internal override void  Abort()
+        {
+        }
+        
+        internal override void  StartDocument()
+        {
+        }
+        internal override void  FinishDocument()
+        {
+        }
+        
+        internal bool FreeRAM()
+        {
+            return false;
+        }
+    }
 }
\ No newline at end of file