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: r1098142 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core: Index/IndexWriter.cs Index/MergePolicy.cs QueryParser/QueryParser.cs Search/BooleanQuery.cs Search/FieldCacheImpl.cs
Date Sat, 30 Apr 2011 19:43:28 GMT
Author: digy
Date: Sat Apr 30 19:43:28 2011
New Revision: 1098142

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

Modified:
    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/MergePolicy.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/QueryParser/QueryParser.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanQuery.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/FieldCacheImpl.cs

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=1098142&r1=1098141&r2=1098142&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 Sat Apr
30 19:43:28 2011
@@ -3436,7 +3436,7 @@ namespace Lucene.Net.Index
 				{
 					int numMerges = spec.merges.Count;
 					for (int i = 0; i < numMerges; i++)
-						RegisterMerge((MergePolicy.OneMerge) spec.merges[i]);
+						RegisterMerge(spec.merges[i]);
 				}
 			}
 			
@@ -3462,7 +3462,7 @@ namespace Lucene.Net.Index
 						running = false;
 						for (int i = 0; i < numMerges; i++)
 						{
-							MergePolicy.OneMerge merge = (MergePolicy.OneMerge) spec.merges[i];
+							MergePolicy.OneMerge merge = spec.merges[i];
 							if (pendingMerges.Contains(merge) || runningMerges.Contains(merge))
 								running = true;
 							System.Exception t = merge.GetException();
@@ -3568,7 +3568,7 @@ namespace Lucene.Net.Index
 						int numMerges = spec.merges.Count;
 						for (int i = 0; i < numMerges; i++)
 						{
-							MergePolicy.OneMerge merge = ((MergePolicy.OneMerge) spec.merges[i]);
+							MergePolicy.OneMerge merge = spec.merges[i];
 							merge.optimize = true;
 							merge.maxNumSegmentsOptimize = maxNumSegmentsOptimize;
 						}
@@ -3581,7 +3581,7 @@ namespace Lucene.Net.Index
 				{
 					int numMerges = spec.merges.Count;
 					for (int i = 0; i < numMerges; i++)
-						RegisterMerge((MergePolicy.OneMerge) spec.merges[i]);
+						RegisterMerge(spec.merges[i]);
 				}
 			}
 		}

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/MergePolicy.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/MergePolicy.cs?rev=1098142&r1=1098141&r2=1098142&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/MergePolicy.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/MergePolicy.cs Sat Apr
30 19:43:28 2011
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 using Directory = Lucene.Net.Store.Directory;
 
@@ -183,8 +184,8 @@ namespace Lucene.Net.Index
 		{
 			
 			/// <summary> The subset of segments to be included in the primitive merge.</summary>
-			
-			public System.Collections.IList merges = new System.Collections.ArrayList();
+
+            public IList<OneMerge> merges = new List<OneMerge>();
 			
 			public virtual void  Add(OneMerge merge)
 			{
@@ -197,7 +198,7 @@ namespace Lucene.Net.Index
 				b.Append("MergeSpec:\n");
 				int count = merges.Count;
 				for (int i = 0; i < count; i++)
-					b.Append("  ").Append(1 + i).Append(": ").Append(((OneMerge) merges[i]).SegString(dir));
+					b.Append("  ").Append(1 + i).Append(": ").Append(merges[i].SegString(dir));
 				return b.ToString();
 			}
 		}

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/QueryParser/QueryParser.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/QueryParser/QueryParser.cs?rev=1098142&r1=1098141&r2=1098142&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/QueryParser/QueryParser.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/QueryParser/QueryParser.cs Sat
Apr 30 19:43:28 2011
@@ -743,7 +743,7 @@ namespace Lucene.Net.QueryParsers
 						// phrase query:
 						MultiPhraseQuery mpq = NewMultiPhraseQuery();
 						mpq.SetSlop(phraseSlop);
-						System.Collections.ArrayList multiTerms = new System.Collections.ArrayList();
+                        List<Term> multiTerms = new List<Index.Term>();
 						int position = - 1;
 						for (int i = 0; i < numTokens; i++)
 						{
@@ -768,11 +768,11 @@ namespace Lucene.Net.QueryParsers
 							{
 								if (enablePositionIncrements)
 								{
-                                    mpq.Add((Term[]) multiTerms.ToArray(typeof(Term)), position);
+                                    mpq.Add(multiTerms.ToArray(), position);
 								}
 								else
 								{
-                                    mpq.Add((Term[]) multiTerms.ToArray(typeof(Term)));
+                                    mpq.Add(multiTerms.ToArray());
 								}
 								multiTerms.Clear();
 							}
@@ -781,11 +781,11 @@ namespace Lucene.Net.QueryParsers
 						}
 						if (enablePositionIncrements)
 						{
-                            mpq.Add((Term[]) multiTerms.ToArray(typeof(Term)), position);
+                            mpq.Add(multiTerms.ToArray(), position);
 						}
 						else
 						{
-                            mpq.Add((Term[]) multiTerms.ToArray(typeof(Term)));
+                            mpq.Add(multiTerms.ToArray());
 						}
 						return mpq;
 					}

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanQuery.cs?rev=1098142&r1=1098141&r2=1098142&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanQuery.cs Sat Apr
30 19:43:28 2011
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 using IndexReader = Lucene.Net.Index.IndexReader;
 using ToStringUtils = Lucene.Net.Util.ToStringUtils;
@@ -210,7 +211,7 @@ namespace Lucene.Net.Search
 		/// <summary>Returns the set of clauses in this query. </summary>
 		public virtual BooleanClause[] GetClauses()
 		{
-			return (BooleanClause[]) clauses.ToArray();
+			return clauses.ToArray();
 		}
 		
 		/// <summary>Returns the list of clauses in this query. </summary>
@@ -243,16 +244,16 @@ namespace Lucene.Net.Search
 			}
 			/// <summary>The Similarity implementation. </summary>
 			protected internal Similarity similarity;
-			protected internal System.Collections.ArrayList weights;
+			protected internal List<Weight> weights;
 			
 			public BooleanWeight(BooleanQuery enclosingInstance, Searcher searcher)
 			{
 				InitBlock(enclosingInstance);
 				this.similarity = Enclosing_Instance.GetSimilarity(searcher);
-				weights = new System.Collections.ArrayList(Enclosing_Instance.clauses.Count);
+				weights = new List<Weight>(Enclosing_Instance.clauses.Count);
 				for (int i = 0; i < Enclosing_Instance.clauses.Count; i++)
 				{
-					BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
+					BooleanClause c = Enclosing_Instance.clauses[i];
 					weights.Add(c.GetQuery().CreateWeight(searcher));
 				}
 			}
@@ -271,8 +272,8 @@ namespace Lucene.Net.Search
 				float sum = 0.0f;
 				for (int i = 0; i < weights.Count; i++)
 				{
-					BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
-					Weight w = (Weight) weights[i];
+					BooleanClause c = Enclosing_Instance.clauses[i];
+					Weight w = weights[i];
 					// call sumOfSquaredWeights for all clauses in case of side effects
 					float s = w.SumOfSquaredWeights(); // sum sub weights
 					if (!c.IsProhibited())
@@ -289,9 +290,8 @@ namespace Lucene.Net.Search
 			public override void  Normalize(float norm)
 			{
 				norm *= Enclosing_Instance.GetBoost(); // incorporate boost
-				for (System.Collections.IEnumerator iter = weights.GetEnumerator(); iter.MoveNext();
)
-				{
-					Weight w = (Weight) iter.Current;
+                foreach(Weight w in weights)
+                {
 					// normalize all clauses, (even if prohibited in case of side affects)
 					w.Normalize(norm);
 				}
@@ -440,9 +440,8 @@ namespace Lucene.Net.Search
 			public override bool ScoresDocsOutOfOrder()
 			{
 				int numProhibited = 0;
-				for (System.Collections.IEnumerator cIter = Enclosing_Instance.clauses.GetEnumerator();
cIter.MoveNext(); )
-				{
-					BooleanClause c = (BooleanClause) cIter.Current;
+                foreach(BooleanClause c in Enclosing_Instance.clauses)
+                {
 					if (c.IsRequired())
 					{
 						return false; // BS2 (in-order) will be used by scorer()
@@ -544,7 +543,7 @@ namespace Lucene.Net.Search
 			if (minNrShouldMatch == 0 && clauses.Count == 1)
 			{
 				// optimize 1-clause queries
-				BooleanClause c = (BooleanClause) clauses[0];
+				BooleanClause c = clauses[0];
 				if (!c.IsProhibited())
 				{
 					// just return clause
@@ -567,7 +566,7 @@ namespace Lucene.Net.Search
 			BooleanQuery clone = null; // recursively rewrite
 			for (int i = 0; i < clauses.Count; i++)
 			{
-				BooleanClause c = (BooleanClause) clauses[i];
+				BooleanClause c = clauses[i];
 				Query query = c.GetQuery().Rewrite(reader);
 				if (query != c.GetQuery())
 				{
@@ -588,9 +587,8 @@ namespace Lucene.Net.Search
 		// inherit javadoc
 		public override void  ExtractTerms(SupportClass.Set<Lucene.Net.Index.Term> terms)
 		{
-			for (System.Collections.IEnumerator i = clauses.GetEnumerator(); i.MoveNext(); )
-			{
-				BooleanClause clause = (BooleanClause) i.Current;
+            foreach(BooleanClause clause in clauses)
+            {
 				clause.GetQuery().ExtractTerms(terms);
 			}
 		}
@@ -614,7 +612,7 @@ namespace Lucene.Net.Search
 			
 			for (int i = 0; i < clauses.Count; i++)
 			{
-				BooleanClause c = (BooleanClause) clauses[i];
+				BooleanClause c = clauses[i];
 				if (c.IsProhibited())
 					buffer.Append("-");
 				else if (c.IsRequired())

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/FieldCacheImpl.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/FieldCacheImpl.cs?rev=1098142&r1=1098141&r2=1098142&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/FieldCacheImpl.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/FieldCacheImpl.cs Sat
Apr 30 19:43:28 2011
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 using NumericField = Lucene.Net.Documents.NumericField;
 using IndexReader = Lucene.Net.Index.IndexReader;
@@ -42,7 +43,7 @@ namespace Lucene.Net.Search
 	class FieldCacheImpl : ExtendedFieldCache_old.ExtendedFieldCache
 	{
 		
-		private System.Collections.IDictionary caches;
+		private SupportClass.Dictionary<Type,Cache> caches;
 		internal FieldCacheImpl()
 		{
 			Init();
@@ -51,14 +52,14 @@ namespace Lucene.Net.Search
 		{
 			lock (this)
 			{
-                System.Collections.Hashtable caches2 = new System.Collections.Hashtable(7);
-                caches2[System.Type.GetType("System.SByte")] = new ByteCache(this);
-                caches2[System.Type.GetType("System.Int16")] = new ShortCache(this);
-                caches2[System.Type.GetType("System.Int32")] = new IntCache(this);
-                caches2[System.Type.GetType("System.Single")] = new FloatCache(this);
-                caches2[System.Type.GetType("System.Int64")] = new LongCache(this);
-                caches2[System.Type.GetType("System.Double")] = new DoubleCache(this);
-                caches2[typeof(System.String)] = new StringCache(this);
+                SupportClass.Dictionary<Type, Cache> caches2 = new SupportClass.Dictionary<Type,
Cache>();
+                caches2[typeof(sbyte)] = new ByteCache(this);
+                caches2[typeof(short)] = new ShortCache(this);
+                caches2[typeof(int)] = new IntCache(this);
+                caches2[typeof(float)] = new FloatCache(this);
+                caches2[typeof(long)] = new LongCache(this);
+                caches2[typeof(double)] = new DoubleCache(this);
+                caches2[typeof(string)] = new StringCache(this);
                 caches2[typeof(StringIndex)] = new StringIndexCache(this);
                 caches2[typeof(System.IComparable)] = new CustomCache(this);
                 caches2[typeof(System.Object)] = new AutoCache(this);
@@ -81,12 +82,10 @@ namespace Lucene.Net.Search
 		
 		public virtual CacheEntry[] GetCacheEntries()
 		{
-			System.Collections.IList result = new System.Collections.ArrayList(17);
-			System.Collections.IEnumerator outerKeys = caches.Keys.GetEnumerator();
-			while (outerKeys.MoveNext())
+            List<CacheEntry> result = new List<CacheEntry>();
+            foreach(Type cacheType in caches.Keys)
 			{
-				System.Type cacheType = (System.Type) outerKeys.Current;
-				Cache cache = (Cache) caches[cacheType];
+				Cache cache = caches[cacheType];
 				System.Collections.IEnumerator innerKeys = cache.readerCache.Keys.GetEnumerator();
 				while (innerKeys.MoveNext())
 				{
@@ -107,7 +106,7 @@ namespace Lucene.Net.Search
 					}
 				}
 			}
-			return (CacheEntry[]) new System.Collections.ArrayList(result).ToArray(typeof(CacheEntry));
+			return result.ToArray();
 		}
 		
 		private sealed class CacheEntryImpl:CacheEntry
@@ -391,7 +390,7 @@ namespace Lucene.Net.Search
 		// inherit javadocs
 		public virtual sbyte[] GetBytes(IndexReader reader, System.String field, ByteParser parser)
 		{
-			return (sbyte[]) ((Cache) caches[System.Type.GetType("System.SByte")]).Get(reader, new
Entry(field, parser));
+			return (sbyte[]) caches[typeof(sbyte)].Get(reader, new Entry(field, parser));
 		}
 		
 		internal sealed class ByteCache:Cache
@@ -449,7 +448,7 @@ namespace Lucene.Net.Search
 		// inherit javadocs
 		public virtual short[] GetShorts(IndexReader reader, System.String field, ShortParser parser)
 		{
-			return (short[]) ((Cache) caches[System.Type.GetType("System.Int16")]).Get(reader, new
Entry(field, parser));
+			return (short[]) caches[typeof(short)].Get(reader, new Entry(field, parser));
 		}
 		
 		internal sealed class ShortCache:Cache
@@ -508,7 +507,7 @@ namespace Lucene.Net.Search
 		// inherit javadocs
 		public virtual int[] GetInts(IndexReader reader, System.String field, IntParser parser)
 		{
-			return (int[]) ((Cache) caches[System.Type.GetType("System.Int32")]).Get(reader, new Entry(field,
parser));
+			return (int[]) caches[typeof(int)].Get(reader, new Entry(field, parser));
 		}
 		
 		internal sealed class IntCache:Cache
@@ -582,7 +581,7 @@ namespace Lucene.Net.Search
 		public virtual float[] GetFloats(IndexReader reader, System.String field, FloatParser parser)
 		{
 			
-			return (float[]) ((Cache) caches[System.Type.GetType("System.Single")]).Get(reader, new
Entry(field, parser));
+			return (float[]) caches[typeof(float)].Get(reader, new Entry(field, parser));
 		}
 		
 		internal sealed class FloatCache:Cache
@@ -654,7 +653,7 @@ namespace Lucene.Net.Search
 		// inherit javadocs
 		public virtual long[] GetLongs(IndexReader reader, System.String field, Lucene.Net.Search.LongParser
parser)
 		{
-			return (long[]) ((Cache) caches[System.Type.GetType("System.Int64")]).Get(reader, new
Entry(field, parser));
+			return (long[]) caches[typeof(long)].Get(reader, new Entry(field, parser));
 		}
 		
 		/// <deprecated> Will be removed in 3.0, this is for binary compatibility only 
@@ -662,7 +661,7 @@ namespace Lucene.Net.Search
         [Obsolete("Will be removed in 3.0, this is for binary compatibility only ")]
 		public virtual long[] GetLongs(IndexReader reader, System.String field, Lucene.Net.Search.ExtendedFieldCache_old.LongParser
parser)
 		{
-			return (long[]) ((Cache) caches[System.Type.GetType("System.Int64")]).Get(reader, new
Entry(field, parser));
+			return (long[]) caches[typeof(long)].Get(reader, new Entry(field, parser));
 		}
 		
 		internal sealed class LongCache:Cache
@@ -734,7 +733,7 @@ namespace Lucene.Net.Search
 		// inherit javadocs
 		public virtual double[] GetDoubles(IndexReader reader, System.String field, Lucene.Net.Search.DoubleParser
parser)
 		{
-			return (double[]) ((Cache) caches[System.Type.GetType("System.Double")]).Get(reader, new
Entry(field, parser));
+			return (double[]) caches[typeof(double)].Get(reader, new Entry(field, parser));
 		}
 		
 		/// <deprecated> Will be removed in 3.0, this is for binary compatibility only 
@@ -742,7 +741,7 @@ namespace Lucene.Net.Search
         [Obsolete("Will be removed in 3.0, this is for binary compatibility only ")]
 		public virtual double[] GetDoubles(IndexReader reader, System.String field, Lucene.Net.Search.ExtendedFieldCache_old.DoubleParser
parser)
 		{
-			return (double[]) ((Cache) caches[System.Type.GetType("System.Double")]).Get(reader, new
Entry(field, parser));
+			return (double[]) caches[typeof(double)].Get(reader, new Entry(field, parser));
 		}
 		
 		internal sealed class DoubleCache:Cache
@@ -806,9 +805,9 @@ namespace Lucene.Net.Search
 		
 		
 		// inherit javadocs
-		public virtual System.String[] GetStrings(IndexReader reader, System.String field)
+		public virtual string[] GetStrings(IndexReader reader, System.String field)
 		{
-			return (System.String[]) ((Cache) caches[typeof(System.String)]).Get(reader, new Entry(field,
(Parser) null));
+			return (string[]) caches[typeof(string)].Get(reader, new Entry(field, (Parser) null));
 		}
 		
 		internal sealed class StringCache:Cache
@@ -852,7 +851,7 @@ namespace Lucene.Net.Search
 		// inherit javadocs
 		public virtual StringIndex GetStringIndex(IndexReader reader, System.String field)
 		{
-			return (StringIndex) ((Cache) caches[typeof(StringIndex)]).Get(reader, new Entry(field,
(Parser) null));
+			return (StringIndex) caches[typeof(StringIndex)].Get(reader, new Entry(field, (Parser)
null));
 		}
 		
 		internal sealed class StringIndexCache:Cache
@@ -935,9 +934,9 @@ namespace Lucene.Net.Search
 		/// </summary>
 		
 		// inherit javadocs
-		public virtual System.Object GetAuto(IndexReader reader, System.String field)
+		public virtual object GetAuto(IndexReader reader, System.String field)
 		{
-			return ((Cache) caches[typeof(System.Object)]).Get(reader, new Entry(field, (Parser) null));
+			return caches[typeof(object)].Get(reader, new Entry(field, (Parser) null));
 		}
 		
 		/// <deprecated> Please specify the exact type, instead.
@@ -1012,7 +1011,7 @@ namespace Lucene.Net.Search
         [Obsolete]
 		public virtual System.IComparable[] GetCustom(IndexReader reader, System.String field,
SortComparator comparator)
 		{
-			return (System.IComparable[]) ((Cache) caches[typeof(System.IComparable)]).Get(reader,
new Entry(field, comparator));
+			return (System.IComparable[]) caches[typeof(System.IComparable)].Get(reader, new Entry(field,
comparator));
 		}
 		
 		/// <deprecated> 



Mime
View raw message