lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aro...@apache.org
Subject svn commit: r834339 - in /incubator/lucene.net/trunk/C#/src: Lucene.Net/Index/IndexWriter.cs Test/Store/TestRAMDirectory.cs
Date Tue, 10 Nov 2009 04:42:27 GMT
Author: aroush
Date: Tue Nov 10 04:42:26 2009
New Revision: 834339

URL: http://svn.apache.org/viewvc?rev=834339&view=rev
Log:
Fixed NUnit test-cases for: TestRAMDirectory.cs

Modified:
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Index/IndexWriter.cs
    incubator/lucene.net/trunk/C#/src/Test/Store/TestRAMDirectory.cs

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Index/IndexWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Index/IndexWriter.cs?rev=834339&r1=834338&r2=834339&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Index/IndexWriter.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Index/IndexWriter.cs Tue Nov 10 04:42:26
2009
@@ -323,7 +323,7 @@
 		private MergePolicy mergePolicy;
 		private MergeScheduler mergeScheduler = new ConcurrentMergeScheduler();
 		private System.Collections.Generic.List<MergePolicy.OneMerge> pendingMerges = new
System.Collections.Generic.List<MergePolicy.OneMerge>();
-        private System.Collections.Hashtable runningMerges = new System.Collections.Hashtable();
+		private System.Collections.Generic.List<MergePolicy.OneMerge> runningMerges = new
System.Collections.Generic.List<MergePolicy.OneMerge>();
 		private System.Collections.IList mergeExceptions = new System.Collections.ArrayList();
 		private long mergeGen;
 		private bool stopMerges;
@@ -3301,19 +3301,21 @@
 		{
 			lock (this)
 			{
-				System.Collections.IEnumerator it = pendingMerges.GetEnumerator();
-				while (it.MoveNext())
-				{
-					if (((MergePolicy.OneMerge) it.Current).optimize)
-						return true;
-				}
-				
-				it = runningMerges.GetEnumerator();
-				while (it.MoveNext())
-				{
-					if (((MergePolicy.OneMerge) it.Current).optimize)
-						return true;
-				}
+                for (int i = 0; i < pendingMerges.Count; i++)
+                {
+                    if (pendingMerges[i].optimize)
+                    {
+                        return true;
+                    }
+                }
+
+                for (int i = 0; i < runningMerges.Count; i++)
+                {
+                    if (runningMerges[i].optimize)
+                    {
+                        return true;
+                    }
+                }
 				
 				return false;
 			}
@@ -3510,7 +3512,7 @@
 					tempObject = pendingMerges[0];
 					pendingMerges.RemoveAt(0);
 					MergePolicy.OneMerge merge = (MergePolicy.OneMerge) tempObject;
-					runningMerges[merge] = merge;
+					runningMerges.Add(merge);
 					return merge;
 				}
 			}
@@ -3534,8 +3536,8 @@
 						if (merge.isExternal)
 						{
 							// Advance the merge from pending to running
-                            pendingMerges.Remove(merge);
-                            runningMerges[merge] = merge;
+                            pendingMerges.Remove(merge);  // {{Aroush-2.9}} From Mike Garski:
this is an O(n) op... is that an issue?
+                            runningMerges.Add(merge);
 							return merge;
 						}
 					}
@@ -4354,8 +4356,8 @@
 								// If this segment is not currently being
 								// merged, then advance it to running & run
 								// the merge ourself (below):
-								pendingMerges.Remove(merge);
-								runningMerges[merge] = merge;
+                                pendingMerges.Remove(merge);    // {{Aroush-2.9}} From Mike
Garski: this is an O(n) op... is that an issue?
+								runningMerges.Add(merge);
 								break;
 							}
 						}

Modified: incubator/lucene.net/trunk/C#/src/Test/Store/TestRAMDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Store/TestRAMDirectory.cs?rev=834339&r1=834338&r2=834339&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Store/TestRAMDirectory.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Store/TestRAMDirectory.cs Tue Nov 10 04:42:26 2009
@@ -245,8 +245,9 @@
 			long headerSize = bos.Length;
 	        System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
 	        formatter.Serialize(out_Renamed.BaseStream, dir);
-			out_Renamed.Close();
+			out_Renamed.Flush();  // In Java, this is Close(), but we can't do this in .NET, and the
Close() is moved to after the validation check
 			Assert.IsTrue(headerSize < bos.Length, "contains more then just header");
+            out_Renamed.Close();
 		}
 		
 		[TearDown]



Mime
View raw message