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: r1098404 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g: src/core/ src/core/Search/ src/core/Search/Spans/ src/core/Store/ test/core/Index/ test/core/Store/
Date Sun, 01 May 2011 20:32:09 GMT
Author: digy
Date: Sun May  1 20:32:09 2011
New Revision: 1098404

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

Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/MultiSearcher.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Query.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Spans/FieldMaskingSpanQuery.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/FileSwitchDirectory.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/NativeFSLockFactory.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/RAMDirectory.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/SingleInstanceLockFactory.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestIndexWriter.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Store/TestFileSwitchDirectory.cs

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/MultiSearcher.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/MultiSearcher.cs?rev=1098404&r1=1098403&r2=1098404&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/MultiSearcher.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/MultiSearcher.cs Sun May
 1 20:32:09 2011
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 using Document = Lucene.Net.Documents.Document;
 using FieldSelector = Lucene.Net.Documents.FieldSelector;
@@ -81,10 +82,10 @@ namespace Lucene.Net.Search
 		/// </summary>
 		private class CachedDfSource:Searcher
 		{
-			private System.Collections.IDictionary dfMap; // Map from Terms to corresponding doc freqs
+            private IDictionary<Term, int> dfMap; // Map from Terms to corresponding
doc freqs
 			private int maxDoc; // document count
-			
-			public CachedDfSource(System.Collections.IDictionary dfMap, int maxDoc, Similarity similarity)
+
+            public CachedDfSource(IDictionary<Term, int> dfMap, int maxDoc, Similarity
similarity)
 			{
 				this.dfMap = dfMap;
 				this.maxDoc = maxDoc;
@@ -96,7 +97,7 @@ namespace Lucene.Net.Search
 				int df;
 				try
 				{
-					df = ((System.Int32) dfMap[term]);
+					df = dfMap[term];
 				}
 				catch (System.NullReferenceException e)
 				{
@@ -414,11 +415,11 @@ namespace Lucene.Net.Search
 					aggregatedDfs[j] += dfs[j];
 				}
 			}
-			
-			System.Collections.Hashtable dfMap = new System.Collections.Hashtable();
+
+            IDictionary<Term, int> dfMap = new SupportClass.Dictionary<Term, int>();
 			for (int i = 0; i < allTermsArray.Length; i++)
 			{
-				dfMap[allTermsArray[i]] = (System.Int32) aggregatedDfs[i];
+				dfMap[allTermsArray[i]] = aggregatedDfs[i];
 			}
 			
 			// step4

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Query.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Query.cs?rev=1098404&r1=1098403&r2=1098404&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Query.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Query.cs Sun May  1 20:32:09
2011
@@ -134,7 +134,7 @@ namespace Lucene.Net.Search
 		/// </summary>
 		public virtual Query Combine(Query[] queries)
 		{
-            System.Collections.Hashtable uniques = new System.Collections.Hashtable();
+            SupportClass.Set<Query> uniques = new SupportClass.Set<Query>();
 			for (int i = 0; i < queries.Length; i++)
 			{
 				Query query = queries[i];
@@ -155,26 +155,26 @@ namespace Lucene.Net.Search
 				{
 					for (int j = 0; j < clauses.Length; j++)
 					{
-						SupportClass.CollectionsHelper.AddIfNotContains(uniques, clauses[j].GetQuery());
+						uniques.Add(clauses[j].GetQuery());
 					}
 				}
 				else
 				{
-					SupportClass.CollectionsHelper.AddIfNotContains(uniques, query);
+					uniques.Add(query);
 				}
 			}
 			// optimization: if we have just one query, just return it
 			if (uniques.Count == 1)
 			{
-                foreach (object key in uniques.Keys)
+                foreach (Query key in uniques)
                 {
                     return (Query) key;
                 }
 			}
 			BooleanQuery result = new BooleanQuery(true);
-            foreach (object key in uniques.Keys)
+            foreach (Query key in uniques)
             {
-                result.Add((Query) key, BooleanClause.Occur.SHOULD);
+                result.Add(key, BooleanClause.Occur.SHOULD);
             }
 			return result;
 		}
@@ -200,22 +200,21 @@ namespace Lucene.Net.Search
 		/// </summary>
 		public static Query MergeBooleanQueries(BooleanQuery[] queries)
 		{
-            System.Collections.Hashtable allClauses = new System.Collections.Hashtable();
+            SupportClass.Set<BooleanClause> allClauses = new SupportClass.Set<BooleanClause>();
 			for (int i = 0; i < queries.Length; i++)
 			{
 				BooleanClause[] clauses = queries[i].GetClauses();
 				for (int j = 0; j < clauses.Length; j++)
 				{
-					SupportClass.CollectionsHelper.AddIfNotContains(allClauses, clauses[j]);
+					allClauses.Add(clauses[j]);
 				}
 			}
 			
 			bool coordDisabled = queries.Length == 0?false:queries[0].IsCoordDisabled();
 			BooleanQuery result = new BooleanQuery(coordDisabled);
-			System.Collections.IEnumerator i2 = allClauses.GetEnumerator();
-			while (i2.MoveNext())
+            foreach(BooleanClause bc in allClauses)
 			{
-				result.Add((BooleanClause) i2.Current);
+				result.Add(bc);
 			}
 			return result;
 		}

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Spans/FieldMaskingSpanQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Spans/FieldMaskingSpanQuery.cs?rev=1098404&r1=1098403&r2=1098404&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Spans/FieldMaskingSpanQuery.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Spans/FieldMaskingSpanQuery.cs
Sun May  1 20:32:09 2011
@@ -101,7 +101,7 @@ namespace Lucene.Net.Search.Spans
 		
 		/// <deprecated> use {@link #ExtractTerms(Set)} instead. 
 		/// </deprecated>
-        [Obsolete("use ExtractTerms(Hashtable) instead.")]
+        [Obsolete("use ExtractTerms instead.")]
         public override IList<Lucene.Net.Index.Term> GetTerms()
 		{
 			return maskedQuery.GetTerms();

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/FileSwitchDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/FileSwitchDirectory.cs?rev=1098404&r1=1098403&r2=1098404&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/FileSwitchDirectory.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/FileSwitchDirectory.cs
Sun May  1 20:32:09 2011
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 namespace Lucene.Net.Store
 {
@@ -36,10 +37,10 @@ namespace Lucene.Net.Store
 	{
 		private Directory secondaryDir;
 		private Directory primaryDir;
-		private System.Collections.Hashtable primaryExtensions;
+        private IList<String> primaryExtensions;
 		private bool doClose;
-		
-		public FileSwitchDirectory(System.Collections.Hashtable primaryExtensions, Directory primaryDir,
Directory secondaryDir, bool doClose)
+
+        public FileSwitchDirectory(IList<String> primaryExtensions, Directory primaryDir,
Directory secondaryDir, bool doClose)
 		{
 			this.primaryExtensions = primaryExtensions;
 			this.primaryDir = primaryDir;

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/NativeFSLockFactory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/NativeFSLockFactory.cs?rev=1098404&r1=1098403&r2=1098404&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/NativeFSLockFactory.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/NativeFSLockFactory.cs
Sun May  1 20:32:09 2011
@@ -168,7 +168,7 @@ namespace Lucene.Net.Store
 		* one JVM (each with their own NativeFSLockFactory
 		* instance) have set the same lock dir and lock prefix.
 		*/
-		private static System.Collections.Hashtable LOCK_HELD = new System.Collections.Hashtable();
+        private static SupportClass.Set<string> LOCK_HELD = new SupportClass.Set<string>();
 
 		[System.Obsolete("Use the constructor that takes a DirectoryInfo, this will be removed
in the 3.0 release")]
 		public NativeFSLock(System.IO.FileInfo lockDir, System.String lockFileName):this(new System.IO.DirectoryInfo(lockDir.FullName),
lockFileName)
@@ -245,7 +245,7 @@ namespace Lucene.Net.Store
 							// thread trying to obtain this lock, so we own
 							// the only instance of a channel against this
 							// file:
-                            LOCK_HELD.Add(canonicalPath, canonicalPath);
+                            LOCK_HELD.Add(canonicalPath);
 							markedHeld = true;
 						}
 					}

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/RAMDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/RAMDirectory.cs?rev=1098404&r1=1098403&r2=1098404&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/RAMDirectory.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/RAMDirectory.cs Sun May
 1 20:32:09 2011
@@ -32,8 +32,8 @@ namespace Lucene.Net.Store
 	{
 		
 		private const long serialVersionUID = 1L;
-		
-		internal protected System.Collections.Hashtable fileMap = new System.Collections.Hashtable();
+
+        internal protected SupportClass.Dictionary<string, RAMFile> fileMap = new SupportClass.Dictionary<string,
RAMFile>();
 		internal protected long sizeInBytes = 0;
 		
 		// *****
@@ -126,13 +126,11 @@ namespace Lucene.Net.Store
 			lock (this)
 			{
 				EnsureOpen();
-				System.Collections.ICollection fileNames = fileMap.Keys;
-				System.String[] result = new System.String[fileNames.Count];
+				System.String[] result = new System.String[fileMap.Count];
 				int i = 0;
-				System.Collections.IEnumerator it = fileNames.GetEnumerator();
-				while (it.MoveNext())
+                foreach(string key in fileMap.Keys)
 				{
-					result[i++] = ((System.String) it.Current);
+					result[i++] = key;
 				}
 				return result;
 			}
@@ -317,11 +315,6 @@ namespace Lucene.Net.Store
             Close();
         }
 
-        public System.Collections.Hashtable fileMap_ForNUnit
-        {
-            get { return fileMap; }
-        }
-
         public long sizeInBytes_ForNUnitTest
         {
             get { return sizeInBytes; }

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/SingleInstanceLockFactory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/SingleInstanceLockFactory.cs?rev=1098404&r1=1098403&r2=1098404&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/SingleInstanceLockFactory.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Store/SingleInstanceLockFactory.cs
Sun May  1 20:32:09 2011
@@ -34,7 +34,7 @@ namespace Lucene.Net.Store
 	public class SingleInstanceLockFactory:LockFactory
 	{
 
-        private System.Collections.Hashtable locks = new System.Collections.Hashtable();
+        private SupportClass.Set<string> locks = new SupportClass.Set<string>();
 		
 		public override Lock MakeLock(System.String lockName)
 		{
@@ -61,9 +61,9 @@ namespace Lucene.Net.Store
 	{
 		
 		internal System.String lockName;
-		private System.Collections.Hashtable locks;
-		
-		public SingleInstanceLock(System.Collections.Hashtable locks, System.String lockName)
+        private SupportClass.Set<string> locks;
+
+        public SingleInstanceLock(SupportClass.Set<string> locks, System.String lockName)
 		{
 			this.locks = locks;
 			this.lockName = lockName;
@@ -75,7 +75,7 @@ namespace Lucene.Net.Store
 			{
                 if (locks.Contains(lockName) == false)
                 {
-                    locks.Add(lockName, lockName);
+                    locks.Add(lockName);
                     return true;
                 }
 

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs?rev=1098404&r1=1098403&r2=1098404&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs Sun May  1 20:32:09
2011
@@ -1406,6 +1406,7 @@ public class SupportClass
     }
     #endregion
 
+    [Serializable]
     public class Dictionary<K, V> : System.Collections.Generic.IDictionary<K, V>
     {
         System.Collections.Generic.IDictionary<K, V> _Dict = null;

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestIndexWriter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestIndexWriter.cs?rev=1098404&r1=1098403&r2=1098404&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestIndexWriter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestIndexWriter.cs Sun
May  1 20:32:09 2011
@@ -5955,11 +5955,11 @@ namespace Lucene.Net.Index
 
             // open "first" with IndexWriter
             IndexCommit commit = null;
-            System.Collections.IEnumerator it = IndexReader.ListCommits(dir).GetEnumerator();
-            while (it.MoveNext())
+            foreach (IndexCommit c in IndexReader.ListCommits(dir))
             {
-                IndexCommit c = (IndexCommit)it.Current;
-                string tag = (String)c.GetUserData()["tag"];
+                string tag = null;
+                if(c.GetUserData().ContainsKey("tag"))
+                    tag = c.GetUserData()["tag"];
                 if ("first".Equals(tag))
                 {
                     commit = c;
@@ -5981,11 +5981,11 @@ namespace Lucene.Net.Index
 
             // make sure "second" commit is still there
             commit = null;
-            it = IndexReader.ListCommits(dir).GetEnumerator();
-            while (it.MoveNext())
+            foreach (IndexCommit c in IndexReader.ListCommits(dir))
             {
-                IndexCommit c = (IndexCommit)it.Current;
-                string tag = (String)c.GetUserData()["tag"];
+                string tag = null;
+                if (c.GetUserData().ContainsKey("tag"))
+                    tag = c.GetUserData()["tag"];
                 if ("second".Equals(tag))
                 {
                     commit = c;
@@ -6010,11 +6010,11 @@ namespace Lucene.Net.Index
 
             // make sure "third" commit is still there
             commit = null;
-            it = IndexReader.ListCommits(dir).GetEnumerator();
-            while (it.MoveNext())
+            foreach (IndexCommit c in IndexReader.ListCommits(dir))
             {
-                IndexCommit c = (IndexCommit)it.Current;
-                string tag = (String)c.GetUserData()["tag"];
+                string tag = null;
+                if (c.GetUserData().ContainsKey("tag"))
+                    tag = c.GetUserData()["tag"];
                 if ("third".Equals(tag))
                 {
                     commit = c;

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Store/TestFileSwitchDirectory.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Store/TestFileSwitchDirectory.cs?rev=1098404&r1=1098403&r2=1098404&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Store/TestFileSwitchDirectory.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Store/TestFileSwitchDirectory.cs
Sun May  1 20:32:09 2011
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 using NUnit.Framework;
 
@@ -36,9 +37,9 @@ namespace Lucene.Net.Store
         [Test]
 		public virtual void  TestBasic()
 		{
-			System.Collections.Hashtable fileExtensions = new System.Collections.Hashtable();
-			SupportClass.CollectionsHelper.AddIfNotContains(fileExtensions, "fdt");
-			SupportClass.CollectionsHelper.AddIfNotContains(fileExtensions, "fdx");
+            IList<String> fileExtensions = new SupportClass.Set<string>();
+			fileExtensions.Add("fdt");
+			fileExtensions.Add("fdx");
 			
 			Directory primaryDir = new MockRAMDirectory();
 			RAMDirectory secondaryDir = new MockRAMDirectory();



Mime
View raw message