lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject svn commit: r1366980 - /incubator/lucene.net/trunk/src/core/Index/
Date Mon, 30 Jul 2012 01:12:55 GMT
Author: synhershko
Date: Mon Jul 30 01:12:54 2012
New Revision: 1366980

URL: http://svn.apache.org/viewvc?rev=1366980&view=rev
Log:
Cleanup work

Modified:
    incubator/lucene.net/trunk/src/core/Index/AbstractAllTermDocs.cs
    incubator/lucene.net/trunk/src/core/Index/AllTermDocs.cs
    incubator/lucene.net/trunk/src/core/Index/BufferedDeletes.cs
    incubator/lucene.net/trunk/src/core/Index/ByteBlockPool.cs
    incubator/lucene.net/trunk/src/core/Index/ByteSliceReader.cs
    incubator/lucene.net/trunk/src/core/Index/ByteSliceWriter.cs
    incubator/lucene.net/trunk/src/core/Index/CharBlockPool.cs
    incubator/lucene.net/trunk/src/core/Index/CheckIndex.cs
    incubator/lucene.net/trunk/src/core/Index/CompoundFileReader.cs
    incubator/lucene.net/trunk/src/core/Index/CompoundFileWriter.cs
    incubator/lucene.net/trunk/src/core/Index/ConcurrentMergeScheduler.cs
    incubator/lucene.net/trunk/src/core/Index/CorruptIndexException.cs
    incubator/lucene.net/trunk/src/core/Index/FieldsReader.cs
    incubator/lucene.net/trunk/src/core/Index/FieldsWriter.cs
    incubator/lucene.net/trunk/src/core/Index/IndexReader.cs
    incubator/lucene.net/trunk/src/core/Index/SegmentReader.cs
    incubator/lucene.net/trunk/src/core/Index/SegmentTermEnum.cs
    incubator/lucene.net/trunk/src/core/Index/TermInfosReader.cs

Modified: incubator/lucene.net/trunk/src/core/Index/AbstractAllTermDocs.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/AbstractAllTermDocs.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/AbstractAllTermDocs.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/AbstractAllTermDocs.cs Mon Jul 30 01:12:54 2012
@@ -16,8 +16,6 @@
  */
 
 using System;
-using System.Collections.Generic;
-using System.Text;
 
 namespace Lucene.Net.Index
 {

Modified: incubator/lucene.net/trunk/src/core/Index/AllTermDocs.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/AllTermDocs.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/AllTermDocs.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/AllTermDocs.cs Mon Jul 30 01:12:54 2012
@@ -15,8 +15,6 @@
  * limitations under the License.
  */
 
-using System;
-
 using BitVector = Lucene.Net.Util.BitVector;
 
 namespace Lucene.Net.Index

Modified: incubator/lucene.net/trunk/src/core/Index/BufferedDeletes.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/BufferedDeletes.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/BufferedDeletes.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/BufferedDeletes.cs Mon Jul 30 01:12:54 2012
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-using System;
 using System.Collections.Generic;
 using Lucene.Net.Search;
 using Lucene.Net.Support;
@@ -92,21 +91,21 @@ namespace Lucene.Net.Index
 			return numTerms + queries.Count + docIDs.Count;
 		}
 		
-		internal virtual void  Update(BufferedDeletes in_Renamed)
+		internal virtual void  Update(BufferedDeletes @in)
 		{
-			numTerms += in_Renamed.numTerms;
-			bytesUsed += in_Renamed.bytesUsed;
-		    foreach (KeyValuePair<Term, Num> term in in_Renamed.terms)
+			numTerms += @in.numTerms;
+			bytesUsed += @in.bytesUsed;
+		    foreach (KeyValuePair<Term, Num> term in @in.terms)
             {
                 terms[term.Key] = term.Value;
 		    }
-            foreach (KeyValuePair<Query, int> term in in_Renamed.queries)
+            foreach (KeyValuePair<Query, int> term in @in.queries)
             {
                 queries[term.Key] = term.Value;
             }
 
-			docIDs.AddRange(in_Renamed.docIDs);
-			in_Renamed.Clear();
+			docIDs.AddRange(@in.docIDs);
+			@in.Clear();
 		}
 		
 		internal virtual void  Clear()

Modified: incubator/lucene.net/trunk/src/core/Index/ByteBlockPool.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/ByteBlockPool.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/ByteBlockPool.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/ByteBlockPool.cs Mon Jul 30 01:12:54 2012
@@ -61,8 +61,8 @@ namespace Lucene.Net.Index
 		public byte[] buffer; // Current head buffer
 		public int byteOffset = - DocumentsWriter.BYTE_BLOCK_SIZE; // Current head offset
 		
-		private bool trackAllocations;
-		private Allocator allocator;
+		private readonly bool trackAllocations;
+		private readonly Allocator allocator;
 		
 		public ByteBlockPool(Allocator allocator, bool trackAllocations)
 		{
@@ -100,7 +100,7 @@ namespace Lucene.Net.Index
 		{
 			if (1 + bufferUpto == buffers.Length)
 			{
-				byte[][] newBuffers = new byte[(int) (buffers.Length * 1.5)][];
+				var newBuffers = new byte[(int) (buffers.Length * 1.5)][];
 				Array.Copy(buffers, 0, newBuffers, 0, buffers.Length);
 				buffers = newBuffers;
 			}

Modified: incubator/lucene.net/trunk/src/core/Index/ByteSliceReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/ByteSliceReader.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/ByteSliceReader.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/ByteSliceReader.cs Mon Jul 30 01:12:54 2012
@@ -82,7 +82,7 @@ namespace Lucene.Net.Index
 			return buffer[upto++];
 		}
 		
-		public long WriteTo(IndexOutput out_Renamed)
+		public long WriteTo(IndexOutput @out)
 		{
 			long size = 0;
 			while (true)
@@ -90,13 +90,13 @@ namespace Lucene.Net.Index
 				if (limit + bufferOffset == endIndex)
 				{
 					System.Diagnostics.Debug.Assert(endIndex - bufferOffset >= upto);
-					out_Renamed.WriteBytes(buffer, upto, limit - upto);
+					@out.WriteBytes(buffer, upto, limit - upto);
 					size += limit - upto;
 					break;
 				}
 				else
 				{
-					out_Renamed.WriteBytes(buffer, upto, limit - upto);
+					@out.WriteBytes(buffer, upto, limit - upto);
 					size += limit - upto;
 					NextSlice();
 				}
@@ -159,16 +159,16 @@ namespace Lucene.Net.Index
 
 	    public override long FilePointer
 	    {
-	        get { throw new System.SystemException("not implemented"); }
+			get { throw new NotImplementedException(); }
 	    }
 
 	    public override long Length()
 		{
-			throw new System.SystemException("not implemented");
+			throw new NotImplementedException();
 		}
 		public override void  Seek(long pos)
 		{
-			throw new System.SystemException("not implemented");
+			throw new NotImplementedException();
 		}
 
         protected override void Dispose(bool disposing)
@@ -176,7 +176,7 @@ namespace Lucene.Net.Index
             // Do nothing...
         }
 		
-		override public System.Object Clone()
+		override public Object Clone()
 		{
             System.Diagnostics.Debug.Fail("Port issue:", "Let see if we need this ByteSliceReader.Clone()"); // {{Aroush-2.9}}
 			return null;

Modified: incubator/lucene.net/trunk/src/core/Index/ByteSliceWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/ByteSliceWriter.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/ByteSliceWriter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/ByteSliceWriter.cs Mon Jul 30 01:12:54 2012
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-using System;
 using Lucene.Net.Support;
 
 namespace Lucene.Net.Index
@@ -28,7 +27,7 @@ namespace Lucene.Net.Index
 	{
 		private byte[] slice;
 		private int upto;
-		private ByteBlockPool pool;
+		private readonly ByteBlockPool pool;
 		
 		internal int offset0;
 		

Modified: incubator/lucene.net/trunk/src/core/Index/CharBlockPool.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/CharBlockPool.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/CharBlockPool.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/CharBlockPool.cs Mon Jul 30 01:12:54 2012
@@ -35,7 +35,7 @@ namespace Lucene.Net.Index
 		
 		public char[] buffer; // Current head buffer
 		public int charOffset = - DocumentsWriter.CHAR_BLOCK_SIZE; // Current head offset
-		private DocumentsWriter docWriter;
+		private readonly DocumentsWriter docWriter;
 		
 		public CharBlockPool(DocumentsWriter docWriter)
 		{
@@ -55,7 +55,7 @@ namespace Lucene.Net.Index
 		{
 			if (1 + bufferUpto == buffers.Length)
 			{
-				char[][] newBuffers = new char[(int) (buffers.Length * 1.5)][];
+				var newBuffers = new char[(int) (buffers.Length * 1.5)][];
 				Array.Copy(buffers, 0, newBuffers, 0, buffers.Length);
 				buffers = newBuffers;
 			}

Modified: incubator/lucene.net/trunk/src/core/Index/CheckIndex.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/CheckIndex.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/CheckIndex.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/CheckIndex.cs Mon Jul 30 01:12:54 2012
@@ -17,6 +17,7 @@
 
 using System;
 using System.Collections.Generic;
+using System.IO;
 using Lucene.Net.Support;
 using AbstractField = Lucene.Net.Documents.AbstractField;
 using Document = Lucene.Net.Documents.Document;
@@ -41,8 +42,8 @@ namespace Lucene.Net.Index
 	/// </summary>
 	public class CheckIndex
 	{
-		private System.IO.StreamWriter infoStream;
-		private Directory dir;
+		private StreamWriter infoStream;
+		private readonly Directory dir;
 		
 		/// <summary> Returned from <see cref="CheckIndex_Renamed_Method()" /> detailing the health and status of the index.
 		/// 
@@ -74,9 +75,10 @@ namespace Lucene.Net.Index
 			
 			/// <summary>String description of the version of the index. </summary>
 			public System.String segmentFormat;
-			
+
 			/// <summary>Empty unless you passed specific segments list to check as optional 3rd argument.</summary>
-			/// <seealso cref="CheckIndex.CheckIndex_Renamed_Method(System.Collections.IList)">
+			/// <seealso>
+			///   <cref>CheckIndex.CheckIndex_Renamed_Method(System.Collections.IList)</cref>
 			/// </seealso>
 			public List<string> segmentsChecked = new List<string>();
 			
@@ -259,9 +261,9 @@ namespace Lucene.Net.Index
 		/// <summary>Set infoStream where messages should go.  If null, no
 		/// messages are printed 
 		/// </summary>
-		public virtual void  SetInfoStream(System.IO.StreamWriter out_Renamed)
+		public virtual void  SetInfoStream(StreamWriter @out)
 		{
-			infoStream = out_Renamed;
+			infoStream = @out;
 		}
 		
 		private void  Msg(System.String msg)
@@ -340,7 +342,7 @@ namespace Lucene.Net.Index
 			}
 			
 			int numSegments = sis.Count;
-			System.String segmentsFileName = sis.GetCurrentSegmentFileName();
+			var segmentsFileName = sis.GetCurrentSegmentFileName();
 			IndexInput input = null;
 			try
 			{
@@ -455,7 +457,7 @@ namespace Lucene.Net.Index
 				SegmentInfo info = sis.Info(i);
 				if (onlySegments != null && !onlySegments.Contains(info.name))
 					continue;
-				Status.SegmentInfoStatus segInfoStat = new Status.SegmentInfoStatus();
+				var segInfoStat = new Status.SegmentInfoStatus();
 				result.segmentInfos.Add(segInfoStat);
 				Msg("  " + (1 + i) + " of " + numSegments + ": name=" + info.name + " docCount=" + info.docCount);
 				segInfoStat.name = info.name;
@@ -565,15 +567,15 @@ namespace Lucene.Net.Index
 					//  This will cause stats for failed segments to be incremented properly
 					if (segInfoStat.fieldNormStatus.error != null)
 					{
-						throw new System.SystemException("Field Norm test failed");
+						throw new SystemException("Field Norm test failed");
 					}
 					else if (segInfoStat.termIndexStatus.error != null)
 					{
-						throw new System.SystemException("Term Index test failed");
+						throw new SystemException("Term Index test failed");
 					}
 					else if (segInfoStat.storedFieldStatus.error != null)
 					{
-						throw new System.SystemException("Stored Field test failed");
+						throw new SystemException("Stored Field test failed");
 					}
 					else if (segInfoStat.termVectorStatus.error != null)
 					{
@@ -585,8 +587,7 @@ namespace Lucene.Net.Index
 				catch (System.Exception t)
 				{
 					Msg("FAILED");
-					System.String comment;
-					comment = "fixIndex() would remove reference to this segment";
+					const string comment = "fixIndex() would remove reference to this segment";
 					Msg("    WARNING: " + comment + "; full exception:");
 					if (infoStream != null)
 						infoStream.WriteLine(t.StackTrace);
@@ -617,9 +618,9 @@ namespace Lucene.Net.Index
 		}
 		
 		/// <summary> Test field norms.</summary>
-        private Status.FieldNormStatus TestFieldNorms(ICollection<string> fieldNames, SegmentReader reader)
+        private Status.FieldNormStatus TestFieldNorms(IEnumerable<string> fieldNames, SegmentReader reader)
 		{
-			Status.FieldNormStatus status = new Status.FieldNormStatus();
+			var status = new Status.FieldNormStatus();
 			
 			try
 			{
@@ -629,7 +630,7 @@ namespace Lucene.Net.Index
 					infoStream.Write("    test: field norms.........");
 				}
 
-				byte[] b = new byte[reader.MaxDoc];
+				var b = new byte[reader.MaxDoc];
 				foreach(string fieldName in fieldNames)
 				{
                     if (reader.HasNorms(fieldName))
@@ -657,7 +658,7 @@ namespace Lucene.Net.Index
 		/// <summary> Test the term index.</summary>
 		private Status.TermIndexStatus TestTermIndex(SegmentInfo info, SegmentReader reader)
 		{
-			Status.TermIndexStatus status = new Status.TermIndexStatus();
+			var status = new Status.TermIndexStatus();
 			
 			try
 			{
@@ -670,7 +671,7 @@ namespace Lucene.Net.Index
 				TermPositions termPositions = reader.TermPositions();
 				
 				// Used only to count up # deleted docs for this term
-				MySegmentTermDocs myTermDocs = new MySegmentTermDocs(reader);
+				var myTermDocs = new MySegmentTermDocs(reader);
 				
 				int maxDoc = reader.MaxDoc;
 				
@@ -760,7 +761,7 @@ namespace Lucene.Net.Index
 		/// <summary> Test stored fields for a segment.</summary>
 		private Status.StoredFieldStatus TestStoredFields(SegmentInfo info, SegmentReader reader, System.Globalization.NumberFormatInfo format)
 		{
-			Status.StoredFieldStatus status = new Status.StoredFieldStatus();
+			var status = new Status.StoredFieldStatus();
 			
 			try
 			{
@@ -804,7 +805,7 @@ namespace Lucene.Net.Index
 		/// <summary> Test term vectors for a segment.</summary>
         private Status.TermVectorStatus TestTermVectors(SegmentInfo info, SegmentReader reader, System.Globalization.NumberFormatInfo format)
 		{
-			Status.TermVectorStatus status = new Status.TermVectorStatus();
+			var status = new Status.TermVectorStatus();
 			
 			try
 			{
@@ -908,7 +909,7 @@ namespace Lucene.Net.Index
 		{
 			
 			bool doFix = false;
-			List<string> onlySegments = new List<string>();
+			var onlySegments = new List<string>();
 			System.String indexPath = null;
 			int i = 0;
 			while (i < args.Length)
@@ -964,18 +965,17 @@ namespace Lucene.Net.Index
 			{
 				dir = FSDirectory.Open(new System.IO.DirectoryInfo(indexPath));
 			}
-			catch (System.Exception t)
+			catch (Exception t)
 			{
-				System.Console.Out.WriteLine("ERROR: could not open directory \"" + indexPath + "\"; exiting");
-				System.Console.Out.WriteLine(t.StackTrace);
-				System.Environment.Exit(1);
+				Console.Out.WriteLine("ERROR: could not open directory \"" + indexPath + "\"; exiting");
+				Console.Out.WriteLine(t.StackTrace);
+				Environment.Exit(1);
 			}
 			
-			CheckIndex checker = new CheckIndex(dir);
-			System.IO.StreamWriter temp_writer;
-			temp_writer = new System.IO.StreamWriter(System.Console.OpenStandardOutput(), System.Console.Out.Encoding);
-			temp_writer.AutoFlush = true;
-			checker.SetInfoStream(temp_writer);
+			var checker = new CheckIndex(dir);
+			var tempWriter = new System.IO.StreamWriter(System.Console.OpenStandardOutput(), System.Console.Out.Encoding)
+			                 	{AutoFlush = true};
+			checker.SetInfoStream(tempWriter);
 			
 			Status result = checker.CheckIndex_Renamed_Method(onlySegments);
 			if (result.missingSegments)
@@ -991,17 +991,17 @@ namespace Lucene.Net.Index
 				}
 				else
 				{
-					System.Console.Out.WriteLine("WARNING: " + result.totLoseDocCount + " documents will be lost\n");
-					System.Console.Out.WriteLine("NOTE: will write new segments file in 5 seconds; this will remove " + result.totLoseDocCount + " docs from the index. THIS IS YOUR LAST CHANCE TO CTRL+C!");
-					for (int s = 0; s < 5; s++)
+					Console.Out.WriteLine("WARNING: " + result.totLoseDocCount + " documents will be lost\n");
+					Console.Out.WriteLine("NOTE: will write new segments file in 5 seconds; this will remove " + result.totLoseDocCount + " docs from the index. THIS IS YOUR LAST CHANCE TO CTRL+C!");
+					for (var s = 0; s < 5; s++)
 					{
 						System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 1000));
 						System.Console.Out.WriteLine("  " + (5 - s) + "...");
 					}
-					System.Console.Out.WriteLine("Writing...");
+					Console.Out.WriteLine("Writing...");
 					checker.FixIndex(result);
-					System.Console.Out.WriteLine("OK");
-					System.Console.Out.WriteLine("Wrote new segments file \"" + result.newSegments.GetCurrentSegmentFileName() + "\"");
+					Console.Out.WriteLine("OK");
+					Console.Out.WriteLine("Wrote new segments file \"" + result.newSegments.GetCurrentSegmentFileName() + "\"");
 				}
 			}
 			System.Console.Out.WriteLine("");

Modified: incubator/lucene.net/trunk/src/core/Index/CompoundFileReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/CompoundFileReader.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/CompoundFileReader.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/CompoundFileReader.cs Mon Jul 30 01:12:54 2012
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-using System;
 using System.Linq;
 using Lucene.Net.Support;
 using BufferedIndexInput = Lucene.Net.Store.BufferedIndexInput;
@@ -35,7 +34,7 @@ namespace Lucene.Net.Index
 	public class CompoundFileReader : Directory
 	{
 		
-		private int readBufferSize;
+		private readonly int readBufferSize;
 		
 		private sealed class FileEntry
 		{
@@ -46,8 +45,8 @@ namespace Lucene.Net.Index
 	    private bool isDisposed;
 		
 		// Base info
-		private Directory directory;
-		private System.String fileName;
+		private readonly Directory directory;
+		private readonly System.String fileName;
 		
 		private IndexInput stream;
 		private HashMap<string, FileEntry> entries = new HashMap<string, FileEntry>();
@@ -82,9 +81,8 @@ namespace Lucene.Net.Index
 						// set length of the previous entry
 						entry.length = offset - entry.offset;
 					}
-					
-					entry = new FileEntry();
-					entry.offset = offset;
+
+					entry = new FileEntry {offset = offset};
 					entries[id] = entry;
 				}
 				
@@ -243,20 +241,20 @@ namespace Lucene.Net.Index
 
 		    private bool isDisposed;
 			
-			internal CSIndexInput(IndexInput base_Renamed, long fileOffset, long length):this(base_Renamed, fileOffset, length, BufferedIndexInput.BUFFER_SIZE)
+			internal CSIndexInput(IndexInput @base, long fileOffset, long length):this(@base, fileOffset, length, BufferedIndexInput.BUFFER_SIZE)
 			{
 			}
 			
-			internal CSIndexInput(IndexInput base_Renamed, long fileOffset, long length, int readBufferSize):base(readBufferSize)
+			internal CSIndexInput(IndexInput @base, long fileOffset, long length, int readBufferSize):base(readBufferSize)
 			{
-				this.base_Renamed = (IndexInput) base_Renamed.Clone();
+				this.base_Renamed = (IndexInput) @base.Clone();
 				this.fileOffset = fileOffset;
 				this.length = length;
 			}
 			
 			public override System.Object Clone()
 			{
-				CSIndexInput clone = (CSIndexInput) base.Clone();
+				var clone = (CSIndexInput) base.Clone();
 				clone.base_Renamed = (IndexInput) base_Renamed.Clone();
 				clone.fileOffset = fileOffset;
 				clone.length = length;

Modified: incubator/lucene.net/trunk/src/core/Index/CompoundFileWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/CompoundFileWriter.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/CompoundFileWriter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/CompoundFileWriter.cs Mon Jul 30 01:12:54 2012
@@ -60,12 +60,12 @@ namespace Lucene.Net.Index
 		}
 		
 		
-		private Directory directory;
-		private System.String fileName;
-        private HashSet<string> ids;
-		private LinkedList<FileEntry> entries;
+		private readonly Directory directory;
+		private readonly String fileName;
+        private readonly HashSet<string> ids;
+		private readonly LinkedList<FileEntry> entries;
 		private bool merged = false;
-		private SegmentMerger.CheckAbort checkAbort;
+		private readonly SegmentMerger.CheckAbort checkAbort;
 		
 		/// <summary>Create the compound stream in the specified file. The file name is the
 		/// entire name (no extensions are added).
@@ -109,13 +109,13 @@ namespace Lucene.Net.Index
 		/// <throws>  IllegalArgumentException if a file with the same name </throws>
 		/// <summary>   has been added already
 		/// </summary>
-		public void  AddFile(System.String file)
+		public void  AddFile(String file)
 		{
 			if (merged)
-				throw new System.SystemException("Can't add extensions after merge has been called");
+				throw new SystemException("Can't add extensions after merge has been called");
 			
 			if (file == null)
-				throw new System.NullReferenceException("file cannot be null");
+				throw new NullReferenceException("file cannot be null");
 			
             try
             {
@@ -123,12 +123,11 @@ namespace Lucene.Net.Index
             }
             catch (Exception)
             {
-				throw new System.ArgumentException("File " + file + " already added");
+				throw new ArgumentException("File " + file + " already added");
             }
-			
-			FileEntry entry = new FileEntry();
-			entry.file = file;
-			entries.AddLast(entry);
+
+	    	var entry = new FileEntry {file = file};
+	    	entries.AddLast(entry);
 		}
 		
         [Obsolete("Use Dispose() instead")]
@@ -151,10 +150,10 @@ namespace Lucene.Net.Index
 
             // TODO: Dispose shouldn't throw exceptions!
             if (merged)
-                throw new System.SystemException("Merge already performed");
+                throw new SystemException("Merge already performed");
 
             if ((entries.Count == 0))
-                throw new System.SystemException("No entries to merge have been defined");
+                throw new SystemException("No entries to merge have been defined");
 
             merged = true;
 
@@ -190,7 +189,7 @@ namespace Lucene.Net.Index
 
                 // Open the files and copy their data into the stream.
                 // Remember the locations of each file's data section.
-                byte[] buffer = new byte[16384];
+                var buffer = new byte[16384];
                 foreach (FileEntry fe in entries)
                 {
                     fe.dataOffset = os.FilePointer;
@@ -234,20 +233,20 @@ namespace Lucene.Net.Index
 		/// </summary>
 		private void  CopyFile(FileEntry source, IndexOutput os, byte[] buffer)
 		{
-			IndexInput is_Renamed = null;
+			IndexInput isRenamed = null;
 			try
 			{
 				long startPtr = os.FilePointer;
 				
-				is_Renamed = directory.OpenInput(source.file);
-				long length = is_Renamed.Length();
+				isRenamed = directory.OpenInput(source.file);
+				long length = isRenamed.Length();
 				long remainder = length;
 				int chunk = buffer.Length;
 				
 				while (remainder > 0)
 				{
-					int len = (int) System.Math.Min(chunk, remainder);
-					is_Renamed.ReadBytes(buffer, 0, len, false);
+					var len = (int) Math.Min(chunk, remainder);
+					isRenamed.ReadBytes(buffer, 0, len, false);
 					os.WriteBytes(buffer, len);
 					remainder -= len;
 					if (checkAbort != null)
@@ -268,8 +267,8 @@ namespace Lucene.Net.Index
 			}
 			finally
 			{
-				if (is_Renamed != null)
-					is_Renamed.Close();
+				if (isRenamed != null)
+					isRenamed.Close();
 			}
 		}
 	}

Modified: incubator/lucene.net/trunk/src/core/Index/ConcurrentMergeScheduler.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/ConcurrentMergeScheduler.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/ConcurrentMergeScheduler.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/ConcurrentMergeScheduler.cs Mon Jul 30 01:12:54 2012
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-using System;
 using System.Collections.Generic;
 using Lucene.Net.Support;
 using Directory = Lucene.Net.Store.Directory;
@@ -229,7 +228,6 @@ namespace Lucene.Net.Index
 				{
 					lock (this)
 					{
-						MergeThread merger;
 						while (MergeThreadCount() >= _maxThreadCount)
 						{
 							if (Verbose())
@@ -247,7 +245,7 @@ namespace Lucene.Net.Index
 												
 						// OK to spawn a new merge thread to handle this
 						// merge:
-						merger = GetMergeThread(writer, merge);
+						MergeThread merger = GetMergeThread(writer, merge);
 						mergeThreads.Add(merger);
 						if (Verbose())
 							Message("    launch new thread [" + merger.Name + "]");
@@ -277,7 +275,7 @@ namespace Lucene.Net.Index
 		{
 			lock (this)
 			{
-				MergeThread thread = new MergeThread(this, writer, merge);
+				var thread = new MergeThread(this, writer, merge);
 				thread.SetThreadPriority(mergeThreadPriority);
 				thread.IsBackground = true;
 				thread.Name = "Lucene Merge Thread #" + mergeThreadCount++;
@@ -411,9 +409,7 @@ namespace Lucene.Net.Index
 			
 			public override System.String ToString()
 			{
-				MergePolicy.OneMerge merge = RunningMerge;
-				if (merge == null)
-					merge = startMerge;
+				MergePolicy.OneMerge merge = RunningMerge ?? startMerge;
 				return "merge thread: " + merge.SegString(Enclosing_Instance.dir);
 			}
 		}

Modified: incubator/lucene.net/trunk/src/core/Index/CorruptIndexException.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/CorruptIndexException.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/CorruptIndexException.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/CorruptIndexException.cs Mon Jul 30 01:12:54 2012
@@ -26,10 +26,10 @@ namespace Lucene.Net.Index
 	[Serializable]
 	public class CorruptIndexException:System.IO.IOException
 	{
-		public CorruptIndexException(System.String message):base(message)
+		public CorruptIndexException(String message):base(message)
 		{
 		}
-		public CorruptIndexException(System.String message, Exception exp):base(message, exp)
+		public CorruptIndexException(String message, Exception exp):base(message, exp)
 		{
 		}
 	}

Modified: incubator/lucene.net/trunk/src/core/Index/FieldsReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/FieldsReader.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/FieldsReader.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/FieldsReader.cs Mon Jul 30 01:12:54 2012
@@ -25,7 +25,6 @@ using AlreadyClosedException = Lucene.Ne
 using BufferedIndexInput = Lucene.Net.Store.BufferedIndexInput;
 using Directory = Lucene.Net.Store.Directory;
 using IndexInput = Lucene.Net.Store.IndexInput;
-using StringHelper = Lucene.Net.Util.StringHelper;
 
 namespace Lucene.Net.Index
 {
@@ -37,29 +36,29 @@ namespace Lucene.Net.Index
 	/// </summary>
 	public sealed class FieldsReader : ICloneable, IDisposable
 	{
-		private FieldInfos fieldInfos;
+		private readonly FieldInfos fieldInfos;
 		
 		// The main fieldStream, used only for cloning.
-		private IndexInput cloneableFieldsStream;
+		private readonly IndexInput cloneableFieldsStream;
 		
 		// This is a clone of cloneableFieldsStream used for reading documents.
 		// It should not be cloned outside of a synchronized context.
-		private IndexInput fieldsStream;
+		private readonly IndexInput fieldsStream;
 		
-		private IndexInput cloneableIndexStream;
-		private IndexInput indexStream;
-		private int numTotalDocs;
-		private int size;
+		private readonly IndexInput cloneableIndexStream;
+		private readonly IndexInput indexStream;
+		private readonly int numTotalDocs;
+		private readonly int size;
 		private bool closed;
-		private int format;
-		private int formatSize;
+		private readonly int format;
+		private readonly int formatSize;
 		
 		// The docID offset where our docs begin in the index
 		// file.  This will be 0 if we have our own private file.
-		private int docStoreOffset;
+		private readonly int docStoreOffset;
 		
-		private CloseableThreadLocal<IndexInput> fieldsStreamTL = new CloseableThreadLocal<IndexInput>();
-		private bool isOriginal = false;
+		private readonly CloseableThreadLocal<IndexInput> fieldsStreamTL = new CloseableThreadLocal<IndexInput>();
+		private readonly bool isOriginal = false;
 		
 		/// <summary>Returns a cloned FieldsReader that shares open
 		/// IndexInputs with the original one.  It is the caller's
@@ -88,7 +87,7 @@ namespace Lucene.Net.Index
 			indexStream = (IndexInput) cloneableIndexStream.Clone();
 		}
 		
-		public /*internal*/ FieldsReader(Directory d, System.String segment, FieldInfos fn):this(d, segment, fn, BufferedIndexInput.BUFFER_SIZE, - 1, 0)
+		public /*internal*/ FieldsReader(Directory d, String segment, FieldInfos fn):this(d, segment, fn, BufferedIndexInput.BUFFER_SIZE, - 1, 0)
 		{
 		}
 		
@@ -111,18 +110,12 @@ namespace Lucene.Net.Index
 				// header, but, the first int will always be 0 in that
 				// case
 				int firstInt = cloneableIndexStream.ReadInt();
-				if (firstInt == 0)
-					format = 0;
-				else
-					format = firstInt;
+				format = firstInt == 0 ? 0 : firstInt;
 				
 				if (format > FieldsWriter.FORMAT_CURRENT)
 					throw new CorruptIndexException("Incompatible format version: " + format + " expected " + FieldsWriter.FORMAT_CURRENT + " or lower");
 				
-				if (format > FieldsWriter.FORMAT)
-					formatSize = 4;
-				else
-					formatSize = 0;
+				formatSize = format > FieldsWriter.FORMAT ? 4 : 0;
 				
 				if (format < FieldsWriter.FORMAT_VERSION_UTF8_LENGTH_IN_BYTES)
 					cloneableFieldsStream.SetModifiedUTF8StringsMode();
@@ -233,7 +226,7 @@ namespace Lucene.Net.Index
 			long position = indexStream.ReadLong();
 			fieldsStream.Seek(position);
 			
-			Document doc = new Document();
+			var doc = new Document();
 			int numFields = fieldsStream.ReadVInt();
 			for (int i = 0; i < numFields; i++)
 			{
@@ -246,7 +239,7 @@ namespace Lucene.Net.Index
 				
 				bool compressed = (bits & FieldsWriter.FIELD_IS_COMPRESSED) != 0;
 			    System.Diagnostics.Debug.Assert(
-			        (compressed ? (format < FieldsWriter.FORMAT_LUCENE_3_0_NO_COMPRESSED_FIELDS) : true),
+			        (!compressed || (format < FieldsWriter.FORMAT_LUCENE_3_0_NO_COMPRESSED_FIELDS)),
 			        "compressed fields are only allowed in indexes of version <= 2.9");
 				bool tokenize = (bits & FieldsWriter.FIELD_IS_TOKENIZED) != 0;
 				bool binary = (bits & FieldsWriter.FIELD_IS_BINARY) != 0;
@@ -347,7 +340,7 @@ namespace Lucene.Net.Index
 			}
 			else
 			{
-				Field.Store store = Field.Store.YES;
+				const Field.Store store = Field.Store.YES;
 				Field.Index index = FieldExtensions.ToIndex(fi.isIndexed, tokenize);
 				Field.TermVector termVector = FieldExtensions.ToTermVector(fi.storeTermVector, fi.storeOffsetWithTermVector, fi.storePositionWithTermVector);
 				
@@ -375,9 +368,8 @@ namespace Lucene.Net.Index
                     {
                         fieldsStream.SkipChars(length);
                     }
-				    f = new LazyField(this, fi.name, store, index, termVector, length, pointer, binary, compressed);
-					f.OmitNorms = fi.omitNorms;
-					f.OmitTermFreqAndPositions = fi.omitTermFreqAndPositions;
+					f = new LazyField(this, fi.name, store, index, termVector, length, pointer, binary, compressed)
+					    	{OmitNorms = fi.omitNorms, OmitTermFreqAndPositions = fi.omitTermFreqAndPositions};
 				}
 
 				doc.Add(f);
@@ -390,20 +382,13 @@ namespace Lucene.Net.Index
 			if (binary)
 			{
 				int toRead = fieldsStream.ReadVInt();
-				byte[] b = new byte[toRead];
+				var b = new byte[toRead];
 				fieldsStream.ReadBytes(b, 0, b.Length);
-                if (compressed)
-                {
-                    doc.Add(new Field(fi.name, Uncompress(b), Field.Store.YES));
-                }
-                else
-                {
-                    doc.Add(new Field(fi.name, b, Field.Store.YES));
-                }
+				doc.Add(compressed ? new Field(fi.name, Uncompress(b), Field.Store.YES) : new Field(fi.name, b, Field.Store.YES));
 			}
 			else
 			{
-				Field.Store store = Field.Store.YES;
+				const Field.Store store = Field.Store.YES;
 				Field.Index index = FieldExtensions.ToIndex(fi.isIndexed, tokenize);
 				Field.TermVector termVector = FieldExtensions.ToTermVector(fi.storeTermVector, fi.storeOffsetWithTermVector, fi.storePositionWithTermVector);
 				
@@ -412,17 +397,15 @@ namespace Lucene.Net.Index
 				{
 					int toRead = fieldsStream.ReadVInt();
 					
-					byte[] b = new byte[toRead];
+					var b = new byte[toRead];
 					fieldsStream.ReadBytes(b, 0, b.Length);
-					f = new Field(fi.name, false, System.Text.Encoding.GetEncoding("UTF-8").GetString(Uncompress(b)), store, index, termVector);
-					f.OmitTermFreqAndPositions = fi.omitTermFreqAndPositions;
-					f.OmitNorms = fi.omitNorms;
+					f = new Field(fi.name, false, System.Text.Encoding.GetEncoding("UTF-8").GetString(Uncompress(b)), store, index,
+					              termVector) {OmitTermFreqAndPositions = fi.omitTermFreqAndPositions, OmitNorms = fi.omitNorms};
 				}
 				else
 				{
-					f = new Field(fi.name, false, fieldsStream.ReadString(), store, index, termVector);
-					f.OmitTermFreqAndPositions = fi.omitTermFreqAndPositions;
-					f.OmitNorms = fi.omitNorms;
+					f = new Field(fi.name, false, fieldsStream.ReadString(), store, index, termVector)
+					    	{OmitTermFreqAndPositions = fi.omitTermFreqAndPositions, OmitNorms = fi.omitNorms};
 				}
 
 				doc.Add(f);
@@ -435,7 +418,7 @@ namespace Lucene.Net.Index
 		private int AddFieldSize(Document doc, FieldInfo fi, bool binary, bool compressed)
 		{
 			int size = fieldsStream.ReadVInt(), bytesize = binary || compressed?size:2 * size;
-			byte[] sizebytes = new byte[4];
+			var sizebytes = new byte[4];
 			sizebytes[0] = (byte) (Number.URShift(bytesize, 24));
 			sizebytes[1] = (byte) (Number.URShift(bytesize, 16));
 			sizebytes[2] = (byte) (Number.URShift(bytesize, 8));
@@ -448,25 +431,19 @@ namespace Lucene.Net.Index
 		/// loaded.
 		/// </summary>
 		[Serializable]
-		private sealed class LazyField : AbstractField, IFieldable
+		private sealed class LazyField : AbstractField
 		{
 			private void  InitBlock(FieldsReader enclosingInstance)
 			{
-				this.enclosingInstance = enclosingInstance;
-			}
-			private FieldsReader enclosingInstance;
-			public FieldsReader Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
+				this.Enclosing_Instance = enclosingInstance;
 			}
+
+			private FieldsReader Enclosing_Instance { get; set; }
+
 			private int toRead;
 			private long pointer;
             [Obsolete("Only kept for backward-compatbility with <3.0 indexes. Will be removed in 4.0.")]
-		    private Boolean isCompressed;
+		    private readonly Boolean isCompressed;
 			
 			public LazyField(FieldsReader enclosingInstance, System.String name, Field.Store store, int toRead, long pointer, bool isBinary, bool isCompressed):base(name, store, Field.Index.NO, Field.TermVector.NO)
 			{
@@ -540,45 +517,43 @@ namespace Lucene.Net.Index
 		            Enclosing_Instance.EnsureOpen();
 		            if (internalIsBinary)
 		                return null;
-		            else
-		            {
-		                if (fieldsData == null)
-		                {
-		                    IndexInput localFieldsStream = GetFieldStream();
-		                    try
-		                    {
-		                        localFieldsStream.Seek(pointer);
-		                        if (isCompressed)
-		                        {
-		                            byte[] b = new byte[toRead];
-		                            localFieldsStream.ReadBytes(b, 0, b.Length);
-		                            fieldsData =
-		                                System.Text.Encoding.GetEncoding("UTF-8").GetString(Enclosing_Instance.Uncompress(b));
-		                        }
-		                        else
-		                        {
-		                            if (Enclosing_Instance.format >= FieldsWriter.FORMAT_VERSION_UTF8_LENGTH_IN_BYTES)
-		                            {
-		                                byte[] bytes = new byte[toRead];
-		                                localFieldsStream.ReadBytes(bytes, 0, toRead);
-		                                fieldsData = System.Text.Encoding.GetEncoding("UTF-8").GetString(bytes);
-		                            }
-		                            else
-		                            {
-		                                //read in chars b/c we already know the length we need to read
-		                                char[] chars = new char[toRead];
-		                                localFieldsStream.ReadChars(chars, 0, toRead);
-		                                fieldsData = new System.String(chars);
-		                            }
-		                        }
-		                    }
-		                    catch (System.IO.IOException e)
-		                    {
-		                        throw new FieldReaderException(e);
-		                    }
-		                }
-		                return (System.String) fieldsData;
-		            }
+
+		        	if (fieldsData == null)
+		        	{
+		        		IndexInput localFieldsStream = GetFieldStream();
+		        		try
+		        		{
+		        			localFieldsStream.Seek(pointer);
+		        			if (isCompressed)
+		        			{
+		        				var b = new byte[toRead];
+		        				localFieldsStream.ReadBytes(b, 0, b.Length);
+		        				fieldsData =
+		        					System.Text.Encoding.GetEncoding("UTF-8").GetString(Enclosing_Instance.Uncompress(b));
+		        			}
+		        			else
+		        			{
+		        				if (Enclosing_Instance.format >= FieldsWriter.FORMAT_VERSION_UTF8_LENGTH_IN_BYTES)
+		        				{
+		        					var bytes = new byte[toRead];
+		        					localFieldsStream.ReadBytes(bytes, 0, toRead);
+		        					fieldsData = System.Text.Encoding.GetEncoding("UTF-8").GetString(bytes);
+		        				}
+		        				else
+		        				{
+		        					//read in chars b/c we already know the length we need to read
+		        					var chars = new char[toRead];
+		        					localFieldsStream.ReadChars(chars, 0, toRead);
+		        					fieldsData = new System.String(chars);
+		        				}
+		        			}
+		        		}
+		        		catch (System.IO.IOException e)
+		        		{
+		        			throw new FieldReaderException(e);
+		        		}
+		        	}
+		        	return (System.String) fieldsData;
 		        }
 		    }
 
@@ -633,16 +608,9 @@ namespace Lucene.Net.Index
 						{
 							localFieldsStream.Seek(pointer);
 							localFieldsStream.ReadBytes(b, 0, toRead);
-							if (isCompressed == true)
-							{
-								fieldsData = Enclosing_Instance.Uncompress(b);
-							}
-							else
-							{
-								fieldsData = b;
-							}
+							fieldsData = isCompressed ? Enclosing_Instance.Uncompress(b) : b;
 						}
-						catch (System.IO.IOException e)
+						catch (IOException e)
 						{
 							throw new FieldReaderException(e);
 						}
@@ -653,8 +621,7 @@ namespace Lucene.Net.Index
 					
 					return (byte[]) fieldsData;
 				}
-				else
-					return null;
+		    	return null;
 			}
 		}
 		
@@ -667,8 +634,7 @@ namespace Lucene.Net.Index
 			catch (Exception e)
 			{
 				// this will happen if the field is not compressed
-				CorruptIndexException newException = new CorruptIndexException("field data are in wrong format: " + e.ToString(), e);
-				throw newException;
+				throw new CorruptIndexException("field data are in wrong format: " + e, e);
 			}
 		}
 	}

Modified: incubator/lucene.net/trunk/src/core/Index/FieldsWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/FieldsWriter.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/FieldsWriter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/FieldsWriter.cs Mon Jul 30 01:12:54 2012
@@ -16,8 +16,8 @@
  */
 
 using System;
+using System.Linq;
 using Lucene.Net.Documents;
-using CompressionTools = Lucene.Net.Documents.CompressionTools;
 using Document = Lucene.Net.Documents.Document;
 using Directory = Lucene.Net.Store.Directory;
 using IndexInput = Lucene.Net.Store.IndexInput;
@@ -48,20 +48,20 @@ namespace Lucene.Net.Index
 		// switch to a new format!
         internal static readonly int FORMAT_CURRENT = FORMAT_LUCENE_3_0_NO_COMPRESSED_FIELDS;
 		
-		private FieldInfos fieldInfos;
+		private readonly FieldInfos fieldInfos;
 		
 		private IndexOutput fieldsStream;
 		
 		private IndexOutput indexStream;
 		
-		private bool doClose;
+		private readonly bool doClose;
 		
 		internal FieldsWriter(Directory d, System.String segment, FieldInfos fn)
 		{
 			fieldInfos = fn;
 			
 			bool success = false;
-			System.String fieldsName = segment + "." + IndexFileNames.FIELDS_EXTENSION;
+			String fieldsName = segment + "." + IndexFileNames.FIELDS_EXTENSION;
 			try
 			{
 				fieldsStream = d.CreateOutput(fieldsName);
@@ -92,7 +92,7 @@ namespace Lucene.Net.Index
 			}
 			
 			success = false;
-			System.String indexName = segment + "." + IndexFileNames.FIELDS_INDEX_EXTENSION;
+			String indexName = segment + "." + IndexFileNames.FIELDS_INDEX_EXTENSION;
 			try
 			{
 				indexStream = d.CreateOutput(indexName);
@@ -240,12 +240,9 @@ namespace Lucene.Net.Index
 			// compression is disabled for the current field
 			if (field.IsBinary)
 			{
-				byte[] data;
-				int len;
-				int offset;
-				data = field.GetBinaryValue();
-				len = field.BinaryLength;
-				offset = field.BinaryOffset;
+				byte[] data = field.GetBinaryValue();
+				int len = field.BinaryLength;
+				int offset = field.BinaryOffset;
 					
 				fieldsStream.WriteVInt(len);
 				fieldsStream.WriteBytes(data, offset, len);
@@ -278,14 +275,9 @@ namespace Lucene.Net.Index
 		internal void  AddDocument(Document doc)
 		{
 			indexStream.WriteLong(fieldsStream.FilePointer);
-			
-			int storedCount = 0;
-		    System.Collections.Generic.IList<IFieldable> fields = doc.GetFields();
-			foreach(IFieldable field in fields)
-			{
-				if (field.IsStored)
-					storedCount++;
-			}
+
+			System.Collections.Generic.IList<IFieldable> fields = doc.GetFields();
+			int storedCount = fields.Count(field => field.IsStored);
 			fieldsStream.WriteVInt(storedCount);
 			
 			foreach(IFieldable field in fields)

Modified: incubator/lucene.net/trunk/src/core/Index/IndexReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/IndexReader.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/IndexReader.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/IndexReader.cs Mon Jul 30 01:12:54 2012
@@ -86,7 +86,7 @@ namespace Lucene.Net.Index
 		/// </summary>
 		public sealed class FieldOption
 		{
-			private System.String option;
+			private readonly System.String option;
 			internal FieldOption()
 			{
 			}
@@ -258,7 +258,7 @@ namespace Lucene.Net.Index
 		{
 			return Open(directory, deletionPolicy, null, readOnly, DEFAULT_TERMS_INDEX_DIVISOR);
 		}
-		
+
 		/// <summary>Expert: returns an IndexReader reading the index in
 		/// the given Directory, with a custom <see cref="IndexDeletionPolicy" />
 		///.  You should pass readOnly=true,
@@ -275,8 +275,9 @@ namespace Lucene.Net.Index
 		/// <param name="readOnly">true if no changes (deletions, norms) will be made with this IndexReader
 		/// </param>
 		/// <param name="termInfosIndexDivisor">Subsamples which indexed
-		/// terms are loaded into RAM. This has the same effect as <see cref="IndexWriter.SetTermIndexInterval" />
-		/// except that setting
+		/// terms are loaded into RAM. This has the same effect as <see>
+		///                                                          <cref>IndexWriter.SetTermIndexInterval</cref>
+		///                                                        </see> except that setting
 		/// must be done at indexing time while this setting can be
 		/// set per reader.  When set to N, then one in every
 		/// N*termIndexInterval terms in the index is loaded into
@@ -315,7 +316,7 @@ namespace Lucene.Net.Index
 		{
 			return Open(commit.Directory, deletionPolicy, commit, readOnly, DEFAULT_TERMS_INDEX_DIVISOR);
 		}
-		
+
 		/// <summary>Expert: returns an IndexReader reading the index in
 		/// the given Directory, using a specific commit and with
 		/// a custom <see cref="IndexDeletionPolicy" />.  You should pass
@@ -334,8 +335,9 @@ namespace Lucene.Net.Index
 		/// <param name="readOnly">true if no changes (deletions, norms) will be made with this IndexReader
 		/// </param>
 		/// <param name="termInfosIndexDivisor">Subsambles which indexed
-		/// terms are loaded into RAM. This has the same effect as <see cref="IndexWriter.SetTermIndexInterval" />
-		/// except that setting
+		/// terms are loaded into RAM. This has the same effect as <see>
+		///                                                          <cref>IndexWriter.SetTermIndexInterval</cref>
+		///                                                        </see> except that setting
 		/// must be done at indexing time while this setting can be
 		/// set per reader.  When set to N, then one in every
 		/// N*termIndexInterval terms in the index is loaded into
@@ -404,7 +406,7 @@ namespace Lucene.Net.Index
 		{
 			lock (this)
 			{
-				throw new System.NotSupportedException("This reader does not support reopen().");
+				throw new NotSupportedException("This reader does not support reopen().");
 			}
 		}
 		
@@ -418,7 +420,7 @@ namespace Lucene.Net.Index
 		{
 			lock (this)
 			{
-				throw new System.NotSupportedException("This reader does not support reopen().");
+				throw new NotSupportedException("This reader does not support reopen().");
 			}
 		}
 		
@@ -433,7 +435,7 @@ namespace Lucene.Net.Index
 		{
 			lock (this)
 			{
-				throw new System.NotSupportedException("This reader does not support reopen(IndexCommit).");
+				throw new NotSupportedException("This reader does not support reopen(IndexCommit).");
 			}
 		}
 		
@@ -526,7 +528,7 @@ namespace Lucene.Net.Index
 		/// <throws>  IOException if there is a low-level IO error </throws>
 		/// <summary> 
 		/// </summary>
-		/// <seealso cref="GetCommitUserData()">
+		/// <seealso cref="GetCommitUserData(Store.Directory)">
 		/// </seealso>
         public static System.Collections.Generic.IDictionary<string, string> GetCommitUserData(Directory directory)
 		{
@@ -570,44 +572,46 @@ namespace Lucene.Net.Index
 	    /// <see cref="IndexWriter.Commit(System.Collections.Generic.IDictionary{string, string})" />
 	    /// has never been called for this index.
 	    /// </summary>
-	    /// <seealso cref="GetCommitUserData(Directory)">
+	    /// <seealso cref="GetCommitUserData(Store.Directory)">
 	    /// </seealso>
 	    public virtual IDictionary<string, string> CommitUserData
 	    {
 	        get { throw new System.NotSupportedException("This reader does not support this method."); }
 	    }
 
-	    /// <summary> Check whether any new changes have occurred to the index since this
-	    /// reader was opened.
-	    /// 
-	    /// <p/>
-	    /// If this reader is based on a Directory (ie, was created by calling
-	    /// <see cref="Open(Store.Directory)" />, or <see cref="Reopen()" /> on a reader based on a Directory), then
-	    /// this method checks if any further commits (see <see cref="IndexWriter.Commit()" />
-	    /// have occurred in that directory).
-	    /// <p/>
-	    /// 
-	    /// <p/>
-	    /// If instead this reader is a near real-time reader (ie, obtained by a call
-	    /// to <see cref="IndexWriter.GetReader()" />, or by calling <see cref="Reopen()" /> on a near
-	    /// real-time reader), then this method checks if either a new commmit has
-	    /// occurred, or any new uncommitted changes have taken place via the writer.
-	    /// Note that even if the writer has only performed merging, this method will
-	    /// still return false.
-	    /// <p/>
-	    /// 
-	    /// <p/>
-	    /// In any event, if this returns false, you should call <see cref="Reopen()" /> to
-	    /// get a new reader that sees the changes.
-	    /// <p/>
-	    /// 
-	    /// </summary>
-	    /// <throws>  CorruptIndexException if the index is corrupt </throws>
-	    /// <throws>  IOException if there is a low-level IO error </throws>
-	    /// <throws>  UnsupportedOperationException unless overridden in subclass </throws>
-	    public virtual bool IsCurrent()
+		/// <summary> Check whether any new changes have occurred to the index since this
+		/// reader was opened.
+		/// 
+		/// <p/>
+		/// If this reader is based on a Directory (ie, was created by calling
+		/// <see>
+		///   <cref>Open(Store.Directory)</cref>
+		/// </see> , or <see cref="Reopen()" /> on a reader based on a Directory), then
+		/// this method checks if any further commits (see <see cref="IndexWriter.Commit()" />
+		/// have occurred in that directory).
+		/// <p/>
+		/// 
+		/// <p/>
+		/// If instead this reader is a near real-time reader (ie, obtained by a call
+		/// to <see cref="IndexWriter.GetReader()" />, or by calling <see cref="Reopen()" /> on a near
+		/// real-time reader), then this method checks if either a new commmit has
+		/// occurred, or any new uncommitted changes have taken place via the writer.
+		/// Note that even if the writer has only performed merging, this method will
+		/// still return false.
+		/// <p/>
+		/// 
+		/// <p/>
+		/// In any event, if this returns false, you should call <see cref="Reopen()" /> to
+		/// get a new reader that sees the changes.
+		/// <p/>
+		/// 
+		/// </summary>
+		/// <throws>  CorruptIndexException if the index is corrupt </throws>
+		/// <throws>  IOException if there is a low-level IO error </throws>
+		/// <throws>  UnsupportedOperationException unless overridden in subclass </throws>
+		public virtual bool IsCurrent()
 	    {
-	        throw new System.NotSupportedException("This reader does not support this method.");
+	        throw new NotSupportedException("This reader does not support this method.");
 	    }
 
 	    /// <summary> Checks is the index is optimized (if it has a single segment and 
@@ -617,7 +621,7 @@ namespace Lucene.Net.Index
 	    /// <throws>  UnsupportedOperationException unless overridden in subclass </throws>
 	    public virtual bool IsOptimized()
 	    {
-	        throw new System.NotSupportedException("This reader does not support this method.");
+	        throw new NotSupportedException("This reader does not support this method.");
 	    }
 
 	    /// <summary> Return an array of term frequency vectors for the specified document.
@@ -657,7 +661,7 @@ namespace Lucene.Net.Index
 		/// <throws>  IOException if index cannot be accessed </throws>
 		/// <seealso cref="Lucene.Net.Documents.Field.TermVector">
 		/// </seealso>
-		abstract public ITermFreqVector GetTermFreqVector(int docNumber, System.String field);
+		abstract public ITermFreqVector GetTermFreqVector(int docNumber, String field);
 		
 		/// <summary> Load the Term Vector into a user-defined data structure instead of relying on the parallel arrays of
 		/// the <see cref="ITermFreqVector" />.
@@ -671,7 +675,7 @@ namespace Lucene.Net.Index
 		/// <throws>  IOException if term vectors cannot be accessed or if they do not exist on the field and doc. specified. </throws>
 		/// <summary> 
 		/// </summary>
-		abstract public void  GetTermFreqVector(int docNumber, System.String field, TermVectorMapper mapper);
+		abstract public void  GetTermFreqVector(int docNumber, String field, TermVectorMapper mapper);
 		
 		/// <summary> Map all the term vectors for all fields in a Document</summary>
 		/// <param name="docNumber">The number of the document to load the vector for
@@ -798,12 +802,13 @@ namespace Lucene.Net.Index
 			EnsureOpen();
 			return Norms(field) != null;
 		}
-		
+
 		/// <summary>Returns the byte-encoded normalization factor for the named field of
 		/// every document.  This is used by the search code to score documents.
 		/// 
 		/// </summary>
-		/// <seealso cref="Lucene.Net.Documents.AbstractField.SetBoost(float)">
+		/// <seealso>
+		///   <cref>Lucene.Net.Documents.AbstractField.SetBoost(float)</cref>
 		/// </seealso>
 		public abstract byte[] Norms(System.String field);
 		
@@ -837,14 +842,14 @@ namespace Lucene.Net.Index
 		/// be obtained)
 		/// </summary>
 		/// <throws>  IOException if there is a low-level IO error </throws>
-		public virtual void  SetNorm(int doc, System.String field, byte value_Renamed)
+		public virtual void  SetNorm(int doc, String field, byte value)
 		{
 			lock (this)
 			{
 				EnsureOpen();
 				AcquireWriteLock();
 				hasChanges = true;
-				DoSetNorm(doc, field, value_Renamed);
+				DoSetNorm(doc, field, value);
 			}
 		}
 		
@@ -869,10 +874,10 @@ namespace Lucene.Net.Index
 		/// be obtained)
 		/// </summary>
 		/// <throws>  IOException if there is a low-level IO error </throws>
-		public virtual void  SetNorm(int doc, System.String field, float value_Renamed)
+		public virtual void  SetNorm(int doc, System.String field, float value)
 		{
 			EnsureOpen();
-			SetNorm(doc, field, Similarity.EncodeNorm(value_Renamed));
+			SetNorm(doc, field, Similarity.EncodeNorm(value));
 		}
 		
 		/// <summary>Returns an enumeration of all the terms in the index. The
@@ -1085,7 +1090,7 @@ namespace Lucene.Net.Index
 		///.
 		/// </param>
 		/// <throws>  IOException </throws>
-        public void Flush(System.Collections.Generic.IDictionary<string, string> commitUserData)
+        public void Flush(IDictionary<string, string> commitUserData)
 		{
 			lock (this)
 			{
@@ -1118,7 +1123,7 @@ namespace Lucene.Net.Index
 		/// (transactional semantics).
 		/// </summary>
 		/// <throws>  IOException if there is a low-level IO error </throws>
-        public void Commit(System.Collections.Generic.IDictionary<string, string> commitUserData)
+        public void Commit(IDictionary<string, string> commitUserData)
 		{
 			lock (this)
 			{
@@ -1131,7 +1136,7 @@ namespace Lucene.Net.Index
 		}
 		
 		/// <summary>Implements commit.</summary>
-	    protected internal abstract void DoCommit(System.Collections.Generic.IDictionary<string, string> commitUserData);
+	    protected internal abstract void DoCommit(IDictionary<string, string> commitUserData);
 
         [Obsolete("Use Dispose() instead")]
 		public void Close()
@@ -1177,7 +1182,7 @@ namespace Lucene.Net.Index
 		/// </returns>
 		/// <seealso cref="IndexReader.FieldOption">
 		/// </seealso>
-		public abstract System.Collections.Generic.ICollection<string> GetFieldNames(FieldOption fldOption);
+		public abstract ICollection<string> GetFieldNames(FieldOption fldOption);
 
 	    /// <summary> Expert: return the IndexCommit that this reader has
 	    /// opened.  This method is only implemented by those
@@ -1189,7 +1194,7 @@ namespace Lucene.Net.Index
 	    /// </summary>
 	    public virtual IndexCommit IndexCommit
 	    {
-	        get { throw new System.NotSupportedException("This reader does not support this method."); }
+	        get { throw new NotSupportedException("This reader does not support this method."); }
 	    }
 
 	    /// <summary> Prints the filename and size of each file within a given compound file.
@@ -1200,24 +1205,24 @@ namespace Lucene.Net.Index
 		/// <param name="args">Usage: Lucene.Net.Index.IndexReader [-extract] &lt;cfsfile&gt;
 		/// </param>
 		[STAThread]
-		public static void  Main(System.String[] args)
+		public static void  Main(String[] args)
 		{
 			System.String filename = null;
 			bool extract = false;
 			
-			for (int i = 0; i < args.Length; ++i)
+			foreach (string t in args)
 			{
-				if (args[i].Equals("-extract"))
+				if (t.Equals("-extract"))
 				{
 					extract = true;
 				}
 				else if (filename == null)
 				{
-					filename = args[i];
+					filename = t;
 				}
 			}
-			
-			if (filename == null)
+
+	    	if (filename == null)
 			{
 				System.Console.Out.WriteLine("Usage: Lucene.Net.Index.IndexReader [-extract] <cfsfile>");
 				return ;
@@ -1228,7 +1233,7 @@ namespace Lucene.Net.Index
 			
 			try
 			{
-				System.IO.FileInfo file = new System.IO.FileInfo(filename);
+				var file = new System.IO.FileInfo(filename);
 				System.String dirname = new System.IO.FileInfo(file.FullName).DirectoryName;
 				filename = file.Name;
 				dir = FSDirectory.Open(new System.IO.DirectoryInfo(dirname));
@@ -1237,23 +1242,23 @@ namespace Lucene.Net.Index
 				System.String[] files = cfr.ListAll();
 				System.Array.Sort(files); // sort the array of filename so that the output is more readable
 				
-				for (int i = 0; i < files.Length; ++i)
+				foreach (string t in files)
 				{
-					long len = cfr.FileLength(files[i]);
+					long len = cfr.FileLength(t);
 					
 					if (extract)
 					{
-						System.Console.Out.WriteLine("extract " + files[i] + " with " + len + " bytes to local directory...");
-						IndexInput ii = cfr.OpenInput(files[i]);
+						System.Console.Out.WriteLine("extract " + t + " with " + len + " bytes to local directory...");
+						IndexInput ii = cfr.OpenInput(t);
 						
-						System.IO.FileStream f = new System.IO.FileStream(files[i], System.IO.FileMode.Create);
+						var f = new System.IO.FileStream(t, System.IO.FileMode.Create);
 						
 						// read and write with a small buffer, which is more effectiv than reading byte by byte
-						byte[] buffer = new byte[1024];
+						var buffer = new byte[1024];
 						int chunk = buffer.Length;
 						while (len > 0)
 						{
-							int bufLen = (int) System.Math.Min(chunk, len);
+							var bufLen = (int) System.Math.Min(chunk, len);
 							ii.ReadBytes(buffer, 0, bufLen);
 							f.Write(buffer, 0, bufLen);
 							len -= bufLen;
@@ -1263,7 +1268,7 @@ namespace Lucene.Net.Index
 						ii.Close();
 					}
 					else
-						System.Console.Out.WriteLine(files[i] + ": " + len + " bytes");
+						System.Console.Out.WriteLine(t + ": " + len + " bytes");
 				}
 			}
 			catch (System.IO.IOException ioe)

Modified: incubator/lucene.net/trunk/src/core/Index/SegmentReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/SegmentReader.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/SegmentReader.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/SegmentReader.cs Mon Jul 30 01:12:54 2012
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Linq;
 using Lucene.Net.Support;
 using Lucene.Net.Util;
 using Document = Lucene.Net.Documents.Document;
@@ -35,7 +36,7 @@ namespace Lucene.Net.Index
 	/// <summary> <p/><b>NOTE:</b> This API is new and still experimental
 	/// (subject to change suddenly in the next release)<p/>
 	/// </summary>
-	public class SegmentReader : IndexReader, System.ICloneable
+	public class SegmentReader : IndexReader
 	{
 		public SegmentReader()
 		{
@@ -82,7 +83,7 @@ namespace Lucene.Net.Index
 			// closed.  A given insance of SegmentReader may be
 			// closed, even those it shares core objects with other
 			// SegmentReaders:
-			private Ref ref_Renamed = new Ref();
+			private readonly Ref ref_Renamed = new Ref();
 			
 			internal System.String segment;
 			internal FieldInfos fieldInfos;
@@ -124,7 +125,7 @@ namespace Lucene.Net.Index
 					fieldInfos = new FieldInfos(cfsDir, segment + "." + IndexFileNames.FIELD_INFOS_EXTENSION);
 					
 					this.termsIndexDivisor = termsIndexDivisor;
-					TermInfosReader reader = new TermInfosReader(cfsDir, segment, fieldInfos, readBufferSize, termsIndexDivisor);
+					var reader = new TermInfosReader(cfsDir, segment, fieldInfos, readBufferSize, termsIndexDivisor);
 					if (termsIndexDivisor == - 1)
 					{
 						tisNoIndex = reader;
@@ -139,14 +140,7 @@ namespace Lucene.Net.Index
 					// so that if an index update removes them we'll still have them
 					freqStream = cfsDir.OpenInput(segment + "." + IndexFileNames.FREQ_EXTENSION, readBufferSize);
 					
-					if (fieldInfos.HasProx())
-					{
-						proxStream = cfsDir.OpenInput(segment + "." + IndexFileNames.PROX_EXTENSION, readBufferSize);
-					}
-					else
-					{
-						proxStream = null;
-					}
+					proxStream = fieldInfos.HasProx() ? cfsDir.OpenInput(segment + "." + IndexFileNames.PROX_EXTENSION, readBufferSize) : null;
 					success = true;
 				}
 				finally
@@ -356,16 +350,8 @@ namespace Lucene.Net.Index
 							storeDir = dir;
 							System.Diagnostics.Debug.Assert(storeDir != null);
 						}
-						
-						System.String storesSegment;
-						if (si.DocStoreOffset != - 1)
-						{
-							storesSegment = si.DocStoreSegment;
-						}
-						else
-						{
-							storesSegment = segment;
-						}
+
+						string storesSegment = si.DocStoreOffset != - 1 ? si.DocStoreSegment : segment;
 						
 						fieldsReaderOrig = new FieldsReader(storeDir, storesSegment, fieldInfos, readBufferSize, si.DocStoreOffset, si.docCount);
 						
@@ -484,7 +470,7 @@ namespace Lucene.Net.Index
 			private Norm origNorm;
 			
 			private IndexInput in_Renamed;
-			private long normSeek;
+			private readonly long normSeek;
 			
 			// null until bytes is set
 			private Ref bytesRef;
@@ -857,7 +843,7 @@ namespace Lucene.Net.Index
 		/// </returns>
 		protected internal virtual byte[] CloneNormBytes(byte[] bytes)
 		{
-			byte[] cloneBytes = new byte[bytes.Length];
+			var cloneBytes = new byte[bytes.Length];
 			Array.Copy(bytes, 0, cloneBytes, 0, bytes.Length);
 			return cloneBytes;
 		}
@@ -1469,14 +1455,7 @@ namespace Lucene.Net.Index
 			{
 				return false;
 			}
-			foreach(Norm norm in norms.Values)
-			{
-				if (norm.refCount > 0)
-				{
-					return false;
-				}
-			}
-			return true;
+			return norms.Values.All(norm => norm.refCount <= 0);
 		}
 		
 		// for testing only
@@ -1667,8 +1646,9 @@ namespace Lucene.Net.Index
 		
 		public /*internal*/ static SegmentReader GetOnlySegmentReader(IndexReader reader)
 		{
-			if (reader is SegmentReader)
-				return (SegmentReader) reader;
+			var onlySegmentReader = reader as SegmentReader;
+			if (onlySegmentReader != null)
+				return onlySegmentReader;
 			
 			if (reader is DirectoryReader)
 			{

Modified: incubator/lucene.net/trunk/src/core/Index/SegmentTermEnum.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/SegmentTermEnum.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/SegmentTermEnum.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/SegmentTermEnum.cs Mon Jul 30 01:12:54 2012
@@ -15,8 +15,6 @@
  * limitations under the License.
  */
 
-using System;
-
 using IndexInput = Lucene.Net.Store.IndexInput;
 
 namespace Lucene.Net.Index
@@ -34,13 +32,13 @@ namespace Lucene.Net.Index
 		
 		private TermInfo termInfo = new TermInfo();
 		
-		private int format;
-		private bool isIndex = false;
+		private readonly int format;
+		private readonly bool isIndex = false;
 		internal long indexPointer = 0;
 		internal int indexInterval;
 		internal int skipInterval;
 		internal int maxSkipLevels;
-		private int formatM1SkipInterval;
+		private readonly int formatM1SkipInterval;
 		
 		internal SegmentTermEnum(IndexInput i, FieldInfos fis, bool isi)
 		{

Modified: incubator/lucene.net/trunk/src/core/Index/TermInfosReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Index/TermInfosReader.cs?rev=1366980&r1=1366979&r2=1366980&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Index/TermInfosReader.cs (original)
+++ incubator/lucene.net/trunk/src/core/Index/TermInfosReader.cs Mon Jul 30 01:12:54 2012
@@ -31,21 +31,21 @@ namespace Lucene.Net.Index
 	
 	sealed class TermInfosReader : IDisposable
 	{
-		private Directory directory;
-		private System.String segment;
-		private FieldInfos fieldInfos;
+		private readonly Directory directory;
+		private readonly String segment;
+		private readonly FieldInfos fieldInfos;
 
         private bool isDisposed;
 
-		private CloseableThreadLocal<ThreadResources> threadResources = new CloseableThreadLocal<ThreadResources>();
-		private SegmentTermEnum origEnum;
-		private long size;
-		
-		private Term[] indexTerms;
-		private TermInfo[] indexInfos;
-		private long[] indexPointers;
+		private readonly CloseableThreadLocal<ThreadResources> threadResources = new CloseableThreadLocal<ThreadResources>();
+		private readonly SegmentTermEnum origEnum;
+		private readonly long size;
+		
+		private readonly Term[] indexTerms;
+		private readonly TermInfo[] indexInfos;
+		private readonly long[] indexPointers;
 		
-		private int totalIndexInterval;
+		private readonly int totalIndexInterval;
 		
 		private const int DEFAULT_CACHE_SIZE = 1024;
 		
@@ -55,7 +55,7 @@ namespace Lucene.Net.Index
 			internal SegmentTermEnum termEnum;
 			
 			// Used for caching the least recently looked-up Terms
-			internal Lucene.Net.Util.Cache.Cache<Term, TermInfo> termInfoCache;
+			internal Cache<Term, TermInfo> termInfoCache;
 		}
 		
 		internal TermInfosReader(Directory dir, System.String seg, FieldInfos fis, int readBufferSize, int indexDivisor)
@@ -81,7 +81,7 @@ namespace Lucene.Net.Index
 				{
 					// Load terms index
 					totalIndexInterval = origEnum.indexInterval * indexDivisor;
-					SegmentTermEnum indexEnum = new SegmentTermEnum(directory.OpenInput(segment + "." + IndexFileNames.TERMS_INDEX_EXTENSION, readBufferSize), fieldInfos, true);
+					var indexEnum = new SegmentTermEnum(directory.OpenInput(segment + "." + IndexFileNames.TERMS_INDEX_EXTENSION, readBufferSize), fieldInfos, true);
 					
 					try
 					{
@@ -164,10 +164,9 @@ namespace Lucene.Net.Index
 			ThreadResources resources = threadResources.Get();
 			if (resources == null)
 			{
-				resources = new ThreadResources();
-				resources.termEnum = Terms();
+				resources = new ThreadResources
+				            	{termEnum = Terms(), termInfoCache = new SimpleLRUCache<Term, TermInfo>(DEFAULT_CACHE_SIZE)};
 				// Cache does not have to be thread-safe, it is only used by one thread at the same time
-				resources.termInfoCache = new SimpleLRUCache<Term,TermInfo>(DEFAULT_CACHE_SIZE);
 				threadResources.Set(resources);
 			}
 			return resources;
@@ -215,7 +214,7 @@ namespace Lucene.Net.Index
 			
 			TermInfo ti;
 			ThreadResources resources = GetThreadResources();
-			Lucene.Net.Util.Cache.Cache<Term, TermInfo> cache = null;
+			Cache<Term, TermInfo> cache = null;
 			
 			if (useCache)
 			{
@@ -282,7 +281,7 @@ namespace Lucene.Net.Index
 		{
 			if (indexTerms == null)
 			{
-				throw new System.SystemException("terms index was not loaded when this reader was created");
+				throw new SystemException("terms index was not loaded when this reader was created");
 			}
 		}
 		



Mime
View raw message