lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [Lucene.Net] svn commit: r1097920 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index: ConcurrentMergeScheduler.cs DocumentsWriter.cs IndexWriter.cs SegmentMerger.cs
Date Fri, 29 Apr 2011 19:20:41 GMT
Author: digy
Date: Fri Apr 29 19:20:41 2011
New Revision: 1097920

URL: http://svn.apache.org/viewvc?rev=1097920&view=rev
Log:
[LUCENENET-412] Some ArrayLists

Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ConcurrentMergeScheduler.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexWriter.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentMerger.cs

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ConcurrentMergeScheduler.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ConcurrentMergeScheduler.cs?rev=1097920&r1=1097919&r2=1097920&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ConcurrentMergeScheduler.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/ConcurrentMergeScheduler.cs
Fri Apr 29 19:20:41 2011
@@ -479,13 +479,13 @@ namespace Lucene.Net.Index
 			{
 				throw new System.SystemException("setTestMode() was not called; often this is because
your test case's setUp method fails to call super.setUp in LuceneTestCase");
 			}
-			lock (allInstances.SyncRoot)
+			lock (allInstances)
 			{
 				int count = allInstances.Count;
 				// Make sure all outstanding threads are done so we see
 				// any exceptions they may produce:
 				for (int i = 0; i < count; i++)
-					((ConcurrentMergeScheduler) allInstances[i]).Sync();
+					allInstances[i].Sync();
 				bool v = anyExceptions;
 				anyExceptions = false;
 				return v;
@@ -494,7 +494,7 @@ namespace Lucene.Net.Index
 		
 		public static void  ClearUnhandledExceptions()
 		{
-			lock (allInstances.SyncRoot)
+			lock (allInstances)
 			{
 				anyExceptions = false;
 			}
@@ -503,7 +503,7 @@ namespace Lucene.Net.Index
 		/// <summary>Used for testing </summary>
 		private void  AddMyself()
 		{
-			lock (allInstances.SyncRoot)
+			lock (allInstances)
 			{
 				int size = allInstances.Count;
 				int upto = 0;
@@ -515,7 +515,7 @@ namespace Lucene.Net.Index
 					// may spawn new threads
 						allInstances[upto++] = other;
 				}
-				((System.Collections.IList) ((System.Collections.ArrayList) allInstances).GetRange(upto,
allInstances.Count - upto)).Clear();
+                allInstances.RemoveRange(upto, allInstances.Count - upto);
 				allInstances.Add(this);
 			}
 		}
@@ -535,10 +535,10 @@ namespace Lucene.Net.Index
 		}
 		
 		/// <summary>Used for testing </summary>
-		private static System.Collections.IList allInstances;
+        private static List<ConcurrentMergeScheduler> allInstances;
 		public static void  SetTestMode()
 		{
-			allInstances = new System.Collections.ArrayList();
+            allInstances = new List<ConcurrentMergeScheduler>();
 		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs?rev=1097920&r1=1097919&r2=1097920&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/DocumentsWriter.cs Fri
Apr 29 19:20:41 2011
@@ -1687,8 +1687,8 @@ namespace Lucene.Net.Index
 		internal const int INT_BLOCK_SHIFT = 13;
 		internal static readonly int INT_BLOCK_SIZE = 1 << INT_BLOCK_SHIFT;
 		internal static readonly int INT_BLOCK_MASK = INT_BLOCK_SIZE - 1;
-		
-		private System.Collections.ArrayList freeIntBlocks = new System.Collections.ArrayList();
+
+        private List<int[]> freeIntBlocks = new List<int[]>();
 		
 		/* Allocate another int[] from the shared pool */
 		internal int[] GetIntBlock(bool trackAllocations)
@@ -1769,8 +1769,8 @@ namespace Lucene.Net.Index
 		internal static readonly int CHAR_BLOCK_MASK = CHAR_BLOCK_SIZE - 1;
 		
 		internal static readonly int MAX_TERM_LENGTH = CHAR_BLOCK_SIZE - 1;
-		
-		private System.Collections.ArrayList freeCharBlocks = new System.Collections.ArrayList();
+
+        private List<char[]> freeCharBlocks = new List<char[]>();
 		
 		/* Allocate another char[] from the shared pool */
 		internal char[] GetCharBlock()

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexWriter.cs?rev=1097920&r1=1097919&r2=1097920&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexWriter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexWriter.cs Fri Apr
29 19:20:41 2011
@@ -328,7 +328,7 @@ namespace Lucene.Net.Index
 		private MergeScheduler mergeScheduler = new ConcurrentMergeScheduler();
         private LinkedList<MergePolicy.OneMerge> pendingMerges = new LinkedList<MergePolicy.OneMerge>();
 		private List<MergePolicy.OneMerge> runningMerges = new List<MergePolicy.OneMerge>();
-		private System.Collections.IList mergeExceptions = new System.Collections.ArrayList();
+        private List<MergePolicy.OneMerge> mergeExceptions = new List<MergePolicy.OneMerge>();
 		private long mergeGen;
 		private bool stopMerges;
 		
@@ -3354,7 +3354,7 @@ namespace Lucene.Net.Index
 							int size = mergeExceptions.Count;
 							for (int i = 0; i < size; i++)
 							{
-								MergePolicy.OneMerge merge = (MergePolicy.OneMerge) mergeExceptions[0];
+								MergePolicy.OneMerge merge = mergeExceptions[0];
 								if (merge.optimize)
 								{
                                     System.IO.IOException err;
@@ -4246,7 +4246,7 @@ namespace Lucene.Net.Index
 		{
 			lock (this)
 			{
-				mergeExceptions = new System.Collections.ArrayList();
+                mergeExceptions = new List<MergePolicy.OneMerge>();
 				mergeGen++;
 			}
 		}
@@ -5758,8 +5758,6 @@ namespace Lucene.Net.Index
 			diagnostics["java.vendor"] = Constants.JAVA_VENDOR + "";
 			if (details != null)
 			{
-				//System.Collections.ArrayList keys = new System.Collections.ArrayList(details.Keys);
-				//System.Collections.ArrayList values = new System.Collections.ArrayList(details.Values);
                 foreach (string key in details.Keys)
                 {
                     diagnostics[key] = details[key];

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentMerger.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentMerger.cs?rev=1097920&r1=1097919&r2=1097920&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentMerger.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/SegmentMerger.cs Fri Apr
29 19:20:41 2011
@@ -128,8 +128,8 @@ namespace Lucene.Net.Index
 		private Directory directory;
 		private System.String segment;
 		private int termIndexInterval;
-		
-		private System.Collections.IList readers = new System.Collections.ArrayList();
+
+        private List<IndexReader> readers = new List<IndexReader>();
 		private FieldInfos fieldInfos;
 		
 		private int mergedDocs;
@@ -198,7 +198,7 @@ namespace Lucene.Net.Index
 		/// </returns>
 		internal IndexReader SegmentReader(int i)
 		{
-			return (IndexReader) readers[i];
+			return readers[i];
 		}
 		
 		/// <summary> Merges the readers specified by the {@link #add} method into the directory
passed to the constructor</summary>
@@ -249,10 +249,10 @@ namespace Lucene.Net.Index
 		/// <throws>  IOException </throws>
 		public /*internal*/ void  CloseReaders()
 		{
-			for (System.Collections.IEnumerator iter = readers.GetEnumerator(); iter.MoveNext(); )
-			{
-				((IndexReader) iter.Current).Close();
-			}
+            foreach (IndexReader reader in readers)
+            {
+                reader.Close();
+            }
 		}
 
         public /*internal*/ ICollection<string> GetMergedFiles()
@@ -340,7 +340,7 @@ namespace Lucene.Net.Index
 			// stored fields:
 			for (int i = 0; i < numReaders; i++)
 			{
-				IndexReader reader = (IndexReader) readers[i];
+				IndexReader reader = readers[i];
 				if (reader is SegmentReader)
 				{
 					SegmentReader segmentReader = (SegmentReader) reader;
@@ -387,9 +387,8 @@ namespace Lucene.Net.Index
 				fieldInfos = new FieldInfos(); // merge field names
 			}
 			
-			for (System.Collections.IEnumerator iter = readers.GetEnumerator(); iter.MoveNext(); )
-			{
-				IndexReader reader = (IndexReader) iter.Current;
+            foreach(IndexReader reader in readers)
+            {
 				if (reader is SegmentReader)
 				{
 					SegmentReader segmentReader = (SegmentReader) reader;
@@ -432,9 +431,8 @@ namespace Lucene.Net.Index
 				try
 				{
 					int idx = 0;
-					for (System.Collections.IEnumerator iter = readers.GetEnumerator(); iter.MoveNext();
)
-					{
-						IndexReader reader = (IndexReader) iter.Current;
+                    foreach(IndexReader reader in readers)
+                    {
 						SegmentReader matchingSegmentReader = matchingSegmentReaders[idx++];
 						FieldsReader matchingFieldsReader = null;
 						if (matchingSegmentReader != null)
@@ -476,10 +474,10 @@ namespace Lucene.Net.Index
 			// just sum numDocs() of each segment to get total docCount
 			else
 			{
-				for (System.Collections.IEnumerator iter = readers.GetEnumerator(); iter.MoveNext();
)
-				{
-					docCount += ((IndexReader) iter.Current).NumDocs();
-				}
+                foreach (IndexReader reader in readers)
+                {
+                    docCount += reader.NumDocs();
+                }
 			}
 			
 			return docCount;
@@ -582,7 +580,7 @@ namespace Lucene.Net.Index
 			try
 			{
 				int idx = 0;
-				for (System.Collections.IEnumerator iter = readers.GetEnumerator(); iter.MoveNext();
)
+                foreach(IndexReader reader in readers)
 				{
 					SegmentReader matchingSegmentReader = matchingSegmentReaders[idx++];
 					TermVectorsReader matchingVectorsReader = null;
@@ -596,7 +594,7 @@ namespace Lucene.Net.Index
 							matchingVectorsReader = vectorsReader;
 						}
 					}
-					IndexReader reader = (IndexReader) iter.Current;
+					
 					if (reader.HasDeletions())
 					{
 						CopyVectorsWithDeletions(termVectorsWriter, matchingVectorsReader, reader);
@@ -739,7 +737,7 @@ namespace Lucene.Net.Index
 			int readerCount = readers.Count;
 			for (int i = 0; i < readerCount; i++)
 			{
-				IndexReader reader = (IndexReader) readers[i];
+				IndexReader reader = readers[i];
 				TermEnum termEnum = reader.Terms();
 				SegmentMergeInfo smi = new SegmentMergeInfo(base_Renamed, termEnum, reader);
 				int[] docMap = smi.GetDocMap();
@@ -899,9 +897,8 @@ namespace Lucene.Net.Index
 							output = directory.CreateOutput(segment + "." + IndexFileNames.NORMS_EXTENSION);
 							output.WriteBytes(NORMS_HEADER, NORMS_HEADER.Length);
 						}
-						for (System.Collections.IEnumerator iter = readers.GetEnumerator(); iter.MoveNext();
)
+                        foreach(IndexReader reader in readers)
 						{
-							IndexReader reader = (IndexReader) iter.Current;
 							int maxDoc = reader.MaxDoc();
 							if (normBuffer == null || normBuffer.Length < maxDoc)
 							{



Mime
View raw message