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: r1099962 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g: src/core/Analysis/CachingTokenFilter.cs src/core/Document/Document.cs src/core/SupportClass.cs test/core/Index/TestIndexReader.cs test/core/Index/TestParallelReader.cs
Date Thu, 05 May 2011 20:37:20 GMT
Author: digy
Date: Thu May  5 20:37:19 2011
New Revision: 1099962

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

Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Analysis/CachingTokenFilter.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/Document.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/TestIndexReader.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestParallelReader.cs

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Analysis/CachingTokenFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Analysis/CachingTokenFilter.cs?rev=1099962&r1=1099961&r2=1099962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Analysis/CachingTokenFilter.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Analysis/CachingTokenFilter.cs
Thu May  5 20:37:19 2011
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 using AttributeSource = Lucene.Net.Util.AttributeSource;
 
@@ -32,8 +33,8 @@ namespace Lucene.Net.Analysis
 	/// </summary>
 	public class CachingTokenFilter:TokenFilter
 	{
-		private System.Collections.IList cache = null;
-		private System.Collections.IEnumerator iterator = null;
+        private IList<AttributeSource.State> cache = null;
+		private IEnumerator<AttributeSource.State> iterator = null;
 		private AttributeSource.State finalState;
 		
 		public CachingTokenFilter(TokenStream input):base(input)
@@ -63,7 +64,7 @@ namespace Lucene.Net.Analysis
 			if (cache == null)
 			{
 				// fill cache lazily
-				cache = new System.Collections.ArrayList();
+                cache = new List<AttributeSource.State>();
 				FillCache();
 				iterator = cache.GetEnumerator();
 			}
@@ -74,7 +75,7 @@ namespace Lucene.Net.Analysis
 				return false;
 			}
 			// Since the TokenFilter can be reset, the tokens need to be preserved as immutable.
-			RestoreState((AttributeSource.State) iterator.Current);
+			RestoreState(iterator.Current);
 			return true;
 		}
 		

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/Document.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/Document.cs?rev=1099962&r1=1099961&r2=1099962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/Document.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Document/Document.cs Thu May
 5 20:37:19 2011
@@ -43,58 +43,6 @@ namespace Lucene.Net.Documents
 	[Serializable]
 	public sealed class Document
 	{
-		private class AnonymousClassEnumeration : System.Collections.IEnumerator
-		{
-			public AnonymousClassEnumeration(Document enclosingInstance)
-			{
-				InitBlock(enclosingInstance);
-			}
-			private void  InitBlock(Document enclosingInstance)
-			{
-				this.enclosingInstance = enclosingInstance;
-				iter = Enclosing_Instance.fields.GetEnumerator();
-			}
-			private System.Object tempAuxObj;
-			public bool MoveNext()
-			{
-				bool result = HasMoreElements();
-				if (result)
-				{
-					tempAuxObj = NextElement();
-				}
-				return result;
-			}
-			public void  Reset()
-			{
-				tempAuxObj = null;
-			}
-			public System.Object Current
-			{
-				get
-				{
-					return tempAuxObj;
-				}
-				
-			}
-			private Document enclosingInstance;
-			public Document Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			internal System.Collections.IEnumerator iter;
-			public bool HasMoreElements()
-			{
-				return iter.MoveNext();
-			}
-			public System.Object NextElement()
-			{
-				return iter.Current;
-			}
-		}
         internal IList<Fieldable> fields = new List<Fieldable>();
 		private float boost = 1.0f;
 		
@@ -248,9 +196,9 @@ namespace Lucene.Net.Documents
 		/// <deprecated> use {@link #GetFields()} instead
 		/// </deprecated>
         [Obsolete("Use GetFields() instead")]
-		public System.Collections.IEnumerator Fields()
+		public IEnumerator<Fieldable> Fields()
 		{
-			return new AnonymousClassEnumeration(this);
+			return fields.GetEnumerator();
 		}
 		
 		/// <summary>Returns a List of all the fields in a document.

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=1099962&r1=1099961&r2=1099962&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 Thu May  5 20:37:19
2011
@@ -1639,19 +1639,6 @@ public class SupportClass
             }
         }
 
-        public static void AddAllIfNotContains(System.Collections.Hashtable hashtable, System.Collections.IList
items)
-        {
-            System.Object item;
-            for (int i = 0; i < items.Count; i++)
-            {
-                item = items[i];
-                if (hashtable.Contains(item) == false)
-                {
-                    hashtable.Add(item, item);
-                }
-            }
-        }
-
         public static void AddAllIfNotContains(System.Collections.Hashtable hashtable, System.Collections.ICollection
items)
         {
             System.Collections.IEnumerator iter = items.GetEnumerator();
@@ -1685,24 +1672,6 @@ public class SupportClass
             }
         }
 
-        public static bool Contains(System.Collections.Generic.ICollection<string>
col, string item)
-        {
-            foreach (string s in col) if (s == item) return true;
-            return false;
-        }
-
-        public static bool Contains(System.Collections.ICollection col, System.Object item)
-        {
-            System.Collections.IEnumerator iter = col.GetEnumerator();
-            while (iter.MoveNext())
-            {
-                if (iter.Current.Equals(item))
-                    return true;
-            }
-            return false;
-        }
-
-
         public static System.String CollectionToString<T>(System.Collections.Generic.IList<T>
c)
         {
             System.Text.StringBuilder sb = new System.Text.StringBuilder();
@@ -1802,43 +1771,11 @@ public class SupportClass
             return true;
         }
 
-        /// <summary>
-        /// Sorts an IList collections
-        /// </summary>
-        /// <param name="list">The System.Collections.IList instance that will be sorted</param>
-        /// <param name="Comparator">The Comparator criteria, null to use natural comparator.</param>
-        public static void Sort(System.Collections.IList list, System.Collections.IComparer
Comparator)
-        {
-            if (((System.Collections.ArrayList)list).IsReadOnly)
-                throw new System.NotSupportedException();
-
-            if ((Comparator == null) || (Comparator is System.Collections.Comparer))
-            {
-                try
-                {
-                    ((System.Collections.ArrayList)list).Sort();
-                }
-                catch (System.InvalidOperationException e)
-                {
-                    throw new System.InvalidCastException(e.Message);
-                }
-            }
-            else
-            {
-                try
-                {
-                    ((System.Collections.ArrayList)list).Sort(Comparator);
-                }
-                catch (System.InvalidOperationException e)
-                {
-                    throw new System.InvalidCastException(e.Message);
-                }
-            }
-        }
+        
 
-        public static void Sort<T1>(System.Collections.Generic.IList<T1> list,System.Collections.Generic.IComparer<T1>
Comparator)
+        public static void Sort<T1>(System.Collections.Generic.IList<T1> list,
System.Collections.Generic.IComparer<T1> Comparator)
         {
-            if(list.IsReadOnly) throw new System.NotSupportedException();
+            if (list.IsReadOnly) throw new System.NotSupportedException();
             if (Comparator == null) ((System.Collections.Generic.List<T1>)list).Sort();
             else ((System.Collections.Generic.List<T1>)list).Sort(Comparator);
         }

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestIndexReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestIndexReader.cs?rev=1099962&r1=1099961&r2=1099962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestIndexReader.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestIndexReader.cs Thu
May  5 20:37:19 2011
@@ -157,10 +157,10 @@ namespace Lucene.Net.Index
 			// set up reader
 			IndexReader reader = IndexReader.Open(d);
 			System.Collections.Generic.ICollection<string> fieldNames = reader.GetFieldNames(IndexReader.FieldOption.ALL);
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "keyword"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "text"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "unindexed"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "unstored"));
+			Assert.IsTrue(fieldNames.Contains("keyword"));
+			Assert.IsTrue(fieldNames.Contains("text"));
+			Assert.IsTrue(fieldNames.Contains("unindexed"));
+			Assert.IsTrue(fieldNames.Contains("unstored"));
 			reader.Close();
 			// add more documents
 			writer = new IndexWriter(d, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
@@ -185,57 +185,57 @@ namespace Lucene.Net.Index
 			reader = IndexReader.Open(d);
 			fieldNames = reader.GetFieldNames(IndexReader.FieldOption.ALL);
 			Assert.AreEqual(13, fieldNames.Count); // the following fields
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "keyword"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "text"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "unindexed"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "unstored"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "keyword2"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "text2"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "unindexed2"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "unstored2"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "tvnot"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "termvector"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "tvposition"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "tvoffset"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "tvpositionoffset"));
+			Assert.IsTrue(fieldNames.Contains("keyword"));
+			Assert.IsTrue(fieldNames.Contains("text"));
+			Assert.IsTrue(fieldNames.Contains("unindexed"));
+			Assert.IsTrue(fieldNames.Contains("unstored"));
+			Assert.IsTrue(fieldNames.Contains("keyword2"));
+			Assert.IsTrue(fieldNames.Contains("text2"));
+			Assert.IsTrue(fieldNames.Contains("unindexed2"));
+			Assert.IsTrue(fieldNames.Contains("unstored2"));
+			Assert.IsTrue(fieldNames.Contains("tvnot"));
+			Assert.IsTrue(fieldNames.Contains("termvector"));
+			Assert.IsTrue(fieldNames.Contains("tvposition"));
+			Assert.IsTrue(fieldNames.Contains("tvoffset"));
+			Assert.IsTrue(fieldNames.Contains("tvpositionoffset"));
 			
 			// verify that only indexed fields were returned
 			fieldNames = reader.GetFieldNames(IndexReader.FieldOption.INDEXED);
 			Assert.AreEqual(11, fieldNames.Count); // 6 original + the 5 termvector fields 
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "keyword"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "text"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "unstored"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "keyword2"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "text2"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "unstored2"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "tvnot"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "termvector"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "tvposition"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "tvoffset"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "tvpositionoffset"));
+			Assert.IsTrue(fieldNames.Contains("keyword"));
+			Assert.IsTrue(fieldNames.Contains("text"));
+			Assert.IsTrue(fieldNames.Contains("unstored"));
+			Assert.IsTrue(fieldNames.Contains("keyword2"));
+			Assert.IsTrue(fieldNames.Contains("text2"));
+			Assert.IsTrue(fieldNames.Contains("unstored2"));
+			Assert.IsTrue(fieldNames.Contains("tvnot"));
+			Assert.IsTrue(fieldNames.Contains("termvector"));
+			Assert.IsTrue(fieldNames.Contains("tvposition"));
+			Assert.IsTrue(fieldNames.Contains("tvoffset"));
+			Assert.IsTrue(fieldNames.Contains("tvpositionoffset"));
 			
 			// verify that only unindexed fields were returned
 			fieldNames = reader.GetFieldNames(IndexReader.FieldOption.UNINDEXED);
 			Assert.AreEqual(2, fieldNames.Count); // the following fields
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "unindexed"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "unindexed2"));
+			Assert.IsTrue(fieldNames.Contains("unindexed"));
+			Assert.IsTrue(fieldNames.Contains("unindexed2"));
 			
 			// verify index term vector fields  
 			fieldNames = reader.GetFieldNames(IndexReader.FieldOption.TERMVECTOR);
 			Assert.AreEqual(1, fieldNames.Count); // 1 field has term vector only
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "termvector"));
+			Assert.IsTrue(fieldNames.Contains("termvector"));
 			
 			fieldNames = reader.GetFieldNames(IndexReader.FieldOption.TERMVECTOR_WITH_POSITION);
 			Assert.AreEqual(1, fieldNames.Count); // 4 fields are indexed with term vectors
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "tvposition"));
+			Assert.IsTrue(fieldNames.Contains("tvposition"));
 			
 			fieldNames = reader.GetFieldNames(IndexReader.FieldOption.TERMVECTOR_WITH_OFFSET);
 			Assert.AreEqual(1, fieldNames.Count); // 4 fields are indexed with term vectors
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "tvoffset"));
+			Assert.IsTrue(fieldNames.Contains("tvoffset"));
 			
 			fieldNames = reader.GetFieldNames(IndexReader.FieldOption.TERMVECTOR_WITH_POSITION_OFFSET);
 			Assert.AreEqual(1, fieldNames.Count); // 4 fields are indexed with term vectors
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "tvpositionoffset"));
+			Assert.IsTrue(fieldNames.Contains("tvpositionoffset"));
 			reader.Close();
 			d.Close();
 		}

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestParallelReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestParallelReader.cs?rev=1099962&r1=1099961&r2=1099962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestParallelReader.cs
(original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/Index/TestParallelReader.cs
Thu May  5 20:37:19 2011
@@ -81,10 +81,10 @@ namespace Lucene.Net.Index
 			pr.Add(IndexReader.Open(dir2));
             System.Collections.Generic.ICollection<string> fieldNames = pr.GetFieldNames(IndexReader.FieldOption.ALL);
 			Assert.AreEqual(4, fieldNames.Count);
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "f1"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "f2"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "f3"));
-			Assert.IsTrue(SupportClass.CollectionsHelper.Contains(fieldNames, "f4"));
+			Assert.IsTrue(fieldNames.Contains("f1"));
+			Assert.IsTrue(fieldNames.Contains("f2"));
+			Assert.IsTrue(fieldNames.Contains("f3"));
+			Assert.IsTrue(fieldNames.Contains("f4"));
 		}
 		
 		[Test]



Mime
View raw message