lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccurr...@apache.org
Subject [Lucene.Net] svn commit: r1294875 [27/45] - in /incubator/lucene.net/trunk: ./ build/ build/vs2010/contrib/ build/vs2010/test/ doc/ src/ src/contrib/Analyzers/ src/contrib/Analyzers/AR/ src/contrib/Analyzers/BR/ src/contrib/Analyzers/CJK/ src/contrib/Analyzers/Cn/ ...
Date Tue, 28 Feb 2012 22:43:28 GMT
Modified: incubator/lucene.net/trunk/src/core/Search/ParallelMultiSearcher.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/ParallelMultiSearcher.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/ParallelMultiSearcher.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/ParallelMultiSearcher.cs Tue Feb 28 22:43:08 2012
@@ -16,20 +16,21 @@
  */
 
 using System;
-
+using System.Threading.Tasks;
+using System.Linq;
+using Lucene.Net.Support;
+using Lucene.Net.Util;
 using IndexReader = Lucene.Net.Index.IndexReader;
 using Term = Lucene.Net.Index.Term;
-using PriorityQueue = Lucene.Net.Util.PriorityQueue;
 
 namespace Lucene.Net.Search
 {
-	
 	/// <summary>Implements parallel search over a set of <c>Searchables</c>.
 	/// 
-	/// <p/>Applications usually need only call the inherited <see cref="Searcher.Search(Query)" />
-	/// or <see cref="Searcher.Search(Query,Filter)" /> methods.
+	/// <p/>Applications usually need only call the inherited <see cref="Searcher.Search(Query, int)" />
+	/// or <see cref="Searcher.Search(Query,Filter,int)" /> methods.
 	/// </summary>
-	public class ParallelMultiSearcher:MultiSearcher
+	public class ParallelMultiSearcher : MultiSearcher/*, IDisposable*/ //No need to implement IDisposable like java, nothing to dispose with the TPL
 	{
 		private class AnonymousClassCollector1:Collector
 		{
@@ -75,69 +76,64 @@ namespace Lucene.Net.Search
 		private Searchable[] searchables;
 		private int[] starts;
 		
-		/// <summary>Creates a searchable which searches <i>searchables</i>. </summary>
-		public ParallelMultiSearcher(params Searchable[] searchables):base(searchables)
+		/// <summary>Creates a <see cref="Searchable"/> which searches <i>searchables</i>. </summary>
+        public ParallelMultiSearcher(params Searchable[] searchables)
+            : base(searchables)
 		{
-			this.searchables = searchables;
-			this.starts = GetStarts();
+		    this.searchables = searchables;
+		    this.starts = GetStarts();
 		}
-		
-		/// <summary> TODO: parallelize this one too</summary>
+
+	    /// <summary>
+	    /// Executes each <see cref="Searchable"/>'s docFreq() in its own thread and 
+	    /// waits for each search to complete and merge the results back together.
+	    /// </summary>
 		public override int DocFreq(Term term)
-		{
-			return base.DocFreq(term);
-		}
-		
-		/// <summary> A search implementation which spans a new thread for each
-		/// Searchable, waits for each search to complete and merge
-		/// the results back together.
+	    {
+	        Task<int>[] tasks = new Task<int>[searchables.Length];
+            for (int i = 0; i < searchables.Length; i++)
+            {
+                Searchable searchable = searchables[i];
+                tasks[i] = Task.Factory.StartNew(() => searchable.DocFreq(term));
+            }
+
+	        Task.WaitAll(tasks);
+	        return tasks.Sum(task => task.Result);
+	    }
+		
+		/// <summary> A search implementation which executes each
+		/// <see cref="Searchable"/> in its own thread and waits for each search to complete
+		/// and merge the results back together.
 		/// </summary>
 		public override TopDocs Search(Weight weight, Filter filter, int nDocs)
 		{
-			HitQueue hq = new HitQueue(nDocs, false);
-			int totalHits = 0;
-			MultiSearcherThread[] msta = new MultiSearcherThread[searchables.Length];
-			for (int i = 0; i < searchables.Length; i++)
-			{
-				// search each searchable
-				// Assume not too many searchables and cost of creating a thread is by far inferior to a search
-				msta[i] = new MultiSearcherThread(searchables[i], weight, filter, nDocs, hq, i, starts, "MultiSearcher thread #" + (i + 1));
-				msta[i].Start();
-			}
-			
-			for (int i = 0; i < searchables.Length; i++)
-			{
-				try
-				{
-					msta[i].Join();
-				}
-				catch (System.Threading.ThreadInterruptedException ie)
-				{
-					// In 3.0 we will change this to throw
-					// InterruptedException instead
-					SupportClass.ThreadClass.Current().Interrupt();
-					throw new System.SystemException(ie.Message, ie);
-				}
-				System.IO.IOException ioe = msta[i].GetIOException();
-				if (ioe == null)
-				{
-					totalHits += msta[i].Hits();
-				}
-				else
-				{
-					// if one search produced an IOException, rethrow it
-					throw ioe;
-				}
-			}
-			
-			ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()];
-			for (int i = hq.Size() - 1; i >= 0; i--)
-			// put docs in array
-				scoreDocs[i] = (ScoreDoc) hq.Pop();
-			
-			float maxScore = (totalHits == 0)?System.Single.NegativeInfinity:scoreDocs[0].score;
-			
-			return new TopDocs(totalHits, scoreDocs, maxScore);
+		    HitQueue hq = new HitQueue(nDocs, false);
+            object lockObj = new object();
+
+            Task<TopDocs>[] tasks = new Task<TopDocs>[searchables.Length];
+            //search each searchable
+            for (int i = 0; i < searchables.Length; i++)
+            {
+                int cur = i;
+                tasks[i] =
+                    Task.Factory.StartNew(() => MultiSearcherCallableNoSort(lockObj, searchables[cur], weight, filter,
+                                                                            nDocs, hq, cur, starts));
+            }
+
+		    int totalHits = 0;
+		    float maxScore = float.NegativeInfinity;
+		    Task.WaitAll(tasks);
+            foreach(TopDocs topDocs in tasks.Select(x => x.Result))
+            {
+                totalHits += topDocs.TotalHits;
+                maxScore = Math.Max(maxScore, topDocs.GetMaxScore());
+            }
+
+            ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()];
+            for (int i = hq.Size() - 1; i >= 0; i--) // put docs in array
+                scoreDocs[i] = hq.Pop();
+
+		    return new TopDocs(totalHits, scoreDocs, maxScore);
 		}
 		
 		/// <summary> A search implementation allowing sorting which spans a new thread for each
@@ -146,52 +142,34 @@ namespace Lucene.Net.Search
 		/// </summary>
 		public override TopFieldDocs Search(Weight weight, Filter filter, int nDocs, Sort sort)
 		{
-			// don't specify the fields - we'll wait to do this until we get results
-			FieldDocSortedHitQueue hq = new FieldDocSortedHitQueue(null, nDocs);
-			int totalHits = 0;
-			MultiSearcherThread[] msta = new MultiSearcherThread[searchables.Length];
-			for (int i = 0; i < searchables.Length; i++)
-			{
-				// search each searchable
-				// Assume not too many searchables and cost of creating a thread is by far inferior to a search
-				msta[i] = new MultiSearcherThread(searchables[i], weight, filter, nDocs, hq, sort, i, starts, "MultiSearcher thread #" + (i + 1));
-				msta[i].Start();
-			}
-			
-			float maxScore = System.Single.NegativeInfinity;
-			
-			for (int i = 0; i < searchables.Length; i++)
-			{
-				try
-				{
-					msta[i].Join();
-				}
-				catch (System.Threading.ThreadInterruptedException ie)
-				{
-					// In 3.0 we will change this to throw
-					// InterruptedException instead
-					SupportClass.ThreadClass.Current().Interrupt();
-					throw new System.SystemException(ie.Message, ie);
-				}
-				System.IO.IOException ioe = msta[i].GetIOException();
-				if (ioe == null)
-				{
-					totalHits += msta[i].Hits();
-					maxScore = System.Math.Max(maxScore, msta[i].GetMaxScore());
-				}
-				else
-				{
-					// if one search produced an IOException, rethrow it
-					throw ioe;
-				}
-			}
-			
-			ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()];
-			for (int i = hq.Size() - 1; i >= 0; i--)
-			// put docs in array
-				scoreDocs[i] = (ScoreDoc) hq.Pop();
-			
-			return new TopFieldDocs(totalHits, scoreDocs, hq.GetFields(), maxScore);
+            if (sort == null) throw new ArgumentNullException("sort");
+
+		    FieldDocSortedHitQueue hq = new FieldDocSortedHitQueue(nDocs);
+            object lockObj = new object();
+
+            Task<TopFieldDocs>[] tasks = new Task<TopFieldDocs>[searchables.Length];
+            for (int i = 0; i < searchables.Length; i++) // search each searchable
+            {
+                int cur = i;
+                tasks[i] =
+                    Task.Factory.StartNew(
+                        () => MultiSearcherCallableWithSort(lockObj, searchables[cur], weight, filter, nDocs, hq, sort, cur,
+                                                      starts));
+            }
+
+		    int totalHits = 0;
+		    float maxScore = float.NegativeInfinity;
+            Task.WaitAll(tasks);
+            foreach (TopFieldDocs topFieldDocs in tasks.Select(x => x.Result))
+            {
+                totalHits += topFieldDocs.TotalHits;
+                maxScore = Math.Max(maxScore, topFieldDocs.GetMaxScore());
+            }
+            ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()];
+            for (int i = hq.Size() - 1; i >= 0; i--)
+                scoreDocs[i] = hq.Pop();
+
+		    return new TopFieldDocs(totalHits, scoreDocs, hq.GetFields(), maxScore);
 		}
 		
 		/// <summary>Lower-level search API.
@@ -199,10 +177,11 @@ namespace Lucene.Net.Search
 		/// <p/><see cref="Collector.Collect(int)" /> is called for every matching document.
 		/// 
 		/// <p/>Applications should only use this if they need <i>all</i> of the
-		/// matching documents.  The high-level search API (<see cref="Searcher.Search(Query)" />)
+		/// matching documents.  The high-level search API (<see cref="Searcher.Search(Query, int)" />)
 		/// is usually more efficient, as it skips
 		/// non-high-scoring hits.
-		/// 
+		/// <p/>This method cannot be parallelized, because <see cref="Collector"/>
+		/// supports no concurrent access.
 		/// </summary>
 		/// <param name="weight">to match documents
 		/// </param>
@@ -224,123 +203,5 @@ namespace Lucene.Net.Search
 				searchables[i].Search(weight, filter, hc);
 			}
 		}
-		
-        /// <summary>
-        /// <para>TODO: this one could be parallelized too</para>
-        /// <para><see cref="Lucene.Net.Search.Searchable.Rewrite(Lucene.Net.Search.Query)"/></para>
-        /// </summary>
-		public override Query Rewrite(Query original)
-		{
-			return base.Rewrite(original);
-		}
-	}
-	
-	/// <summary> A thread subclass for searching a single searchable </summary>
-	class MultiSearcherThread:SupportClass.ThreadClass
-	{
-		
-		private Searchable searchable;
-		private Weight weight;
-		private Filter filter;
-		private int nDocs;
-		private TopDocs docs;
-		private int i;
-		private PriorityQueue hq;
-		private int[] starts;
-		private System.Exception ioe;
-		private Sort sort;
-		
-		public MultiSearcherThread(Searchable searchable, Weight weight, Filter filter, int nDocs, HitQueue hq, int i, int[] starts, System.String name):base(name)
-		{
-			this.searchable = searchable;
-			this.weight = weight;
-			this.filter = filter;
-			this.nDocs = nDocs;
-			this.hq = hq;
-			this.i = i;
-			this.starts = starts;
-		}
-		
-		public MultiSearcherThread(Searchable searchable, Weight weight, Filter filter, int nDocs, FieldDocSortedHitQueue hq, Sort sort, int i, int[] starts, System.String name):base(name)
-		{
-			this.searchable = searchable;
-			this.weight = weight;
-			this.filter = filter;
-			this.nDocs = nDocs;
-			this.hq = hq;
-			this.i = i;
-			this.starts = starts;
-			this.sort = sort;
-		}
-		
-		override public void  Run()
-		{
-			try
-			{
-				docs = (sort == null)?searchable.Search(weight, filter, nDocs):searchable.Search(weight, filter, nDocs, sort);
-			}
-			// Store the IOException for later use by the caller of this thread
-			catch (System.Exception e)
-			{
-				this.ioe = e;
-			}
-			if (this.ioe == null)
-			{
-				// if we are sorting by fields, we need to tell the field sorted hit queue
-				// the actual type of fields, in case the original list contained AUTO.
-				// if the searchable returns null for fields, we'll have problems.
-				if (sort != null)
-				{
-					TopFieldDocs docsFields = (TopFieldDocs) docs;
-					// If one of the Sort fields is FIELD_DOC, need to fix its values, so that
-					// it will break ties by doc Id properly. Otherwise, it will compare to
-					// 'relative' doc Ids, that belong to two different searchables.
-					for (int j = 0; j < docsFields.fields.Length; j++)
-					{
-						if (docsFields.fields[j].GetType() == SortField.DOC)
-						{
-							// iterate over the score docs and change their fields value
-							for (int j2 = 0; j2 < docs.ScoreDocs.Length; j2++)
-							{
-								FieldDoc fd = (FieldDoc) docs.ScoreDocs[j2];
-								fd.fields[j] = (System.Int32) (((System.Int32) fd.fields[j]) + starts[i]);
-							}
-							break;
-						}
-					}
-					
-					((FieldDocSortedHitQueue) hq).SetFields(docsFields.fields);
-				}
-				ScoreDoc[] scoreDocs = docs.ScoreDocs;
-				for (int j = 0; j < scoreDocs.Length; j++)
-				{
-					// merge scoreDocs into hq
-					ScoreDoc scoreDoc = scoreDocs[j];
-					scoreDoc.doc += starts[i]; // convert doc 
-					//it would be so nice if we had a thread-safe insert 
-					lock (hq)
-					{
-						if (!hq.Insert(scoreDoc))
-							break;
-					} // no more scores > minScore
-				}
-			}
-		}
-		
-		public virtual int Hits()
-		{
-			return docs.TotalHits;
-		}
-		
-		public virtual float GetMaxScore()
-		{
-			return docs.GetMaxScore();
-		}
-		
-		public virtual System.IO.IOException GetIOException()
-		{
-            if (ioe == null) return null;
-            return new System.IO.IOException(ioe.Message);
-		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Search/Payloads/PayloadNearQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/Payloads/PayloadNearQuery.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/Payloads/PayloadNearQuery.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/Payloads/PayloadNearQuery.cs Tue Feb 28 22:43:08 2012
@@ -40,13 +40,13 @@ namespace Lucene.Net.Search.Payloads
 	/// <see cref="Lucene.Net.Search.Spans.TermSpans" /> occurs.
 	/// <p/>
 	/// In order to take advantage of this, you must override
-	/// <see cref="Lucene.Net.Search.Similarity.ScorePayload(String, byte[],int,int)" />
+	/// <see cref="Lucene.Net.Search.Similarity.ScorePayload" />
 	/// which returns 1 by default.
 	/// <p/>
 	/// Payload scores are aggregated using a pluggable <see cref="PayloadFunction" />.
 	/// 
 	/// </summary>
-	/// <seealso cref="Lucene.Net.Search.Similarity.ScorePayload(String, byte[], int,int)">
+	/// <seealso cref="Lucene.Net.Search.Similarity.ScorePayload">
 	/// </seealso>
 	[Serializable]
 	public class PayloadNearQuery:SpanNearQuery, System.ICloneable
@@ -76,8 +76,7 @@ namespace Lucene.Net.Search.Payloads
 			
 			for (int i = 0; i < sz; i++)
 			{
-				SpanQuery clause = (SpanQuery) clauses[i];
-				newClauses[i] = (SpanQuery) clause.Clone();
+				newClauses[i] = clauses[i];
 			}
 			PayloadNearQuery boostingNearQuery = new PayloadNearQuery(newClauses, slop, inOrder);
 			boostingNearQuery.SetBoost(GetBoost());
@@ -88,10 +87,10 @@ namespace Lucene.Net.Search.Payloads
 		{
 			System.Text.StringBuilder buffer = new System.Text.StringBuilder();
 			buffer.Append("payloadNear([");
-			System.Collections.IEnumerator i = clauses.GetEnumerator();
+			var i = clauses.GetEnumerator();
 			while (i.MoveNext())
 			{
-				SpanQuery clause = (SpanQuery) i.Current;
+				SpanQuery clause = i.Current;
 				buffer.Append(clause.ToString(field));
 				if (i.MoveNext())
 				{
@@ -164,12 +163,7 @@ namespace Lucene.Net.Search.Payloads
 			{
 				InitBlock(enclosingInstance);
 			}
-			
-			public virtual Scorer Scorer(IndexReader reader)
-			{
-				return new PayloadNearSpanScorer(enclosingInstance, query.GetSpans(reader), this, similarity, reader.Norms(query.GetField()));
-			}
-			
+
 			public override Scorer Scorer(IndexReader reader, bool scoreDocsInOrder, bool topScorer)
 			{
 				return new PayloadNearSpanScorer(enclosingInstance, query.GetSpans(reader), this, similarity, reader.Norms(query.GetField()));
@@ -271,7 +265,7 @@ namespace Lucene.Net.Search.Payloads
 				return base.Score() * Enclosing_Instance.function.DocScore(doc, Enclosing_Instance.fieldName, payloadsSeen, payloadScore);
 			}
 			
-			public override Explanation Explain(int doc)
+			protected internal override Explanation Explain(int doc)
 			{
 				Explanation result = new Explanation();
 				Explanation nonPayloadExpl = base.Explain(doc);
@@ -279,10 +273,10 @@ namespace Lucene.Net.Search.Payloads
 				Explanation payloadBoost = new Explanation();
 				result.AddDetail(payloadBoost);
 				float avgPayloadScore = (payloadsSeen > 0?(payloadScore / payloadsSeen):1);
-				payloadBoost.SetValue(avgPayloadScore);
-				payloadBoost.SetDescription("scorePayload(...)");
-				result.SetValue(nonPayloadExpl.GetValue() * avgPayloadScore);
-				result.SetDescription("bnq, product of:");
+				payloadBoost.Value = avgPayloadScore;
+				payloadBoost.Description = "scorePayload(...)";
+				result.Value = nonPayloadExpl.Value * avgPayloadScore;
+				result.Description = "bnq, product of:";
 				return result;
 			}
 		}

Modified: incubator/lucene.net/trunk/src/core/Search/Payloads/PayloadSpanUtil.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/Payloads/PayloadSpanUtil.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/Payloads/PayloadSpanUtil.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/Payloads/PayloadSpanUtil.cs Tue Feb 28 22:43:08 2012
@@ -17,7 +17,7 @@
 
 using System;
 using System.Collections.Generic;
-
+using System.Linq;
 using IndexReader = Lucene.Net.Index.IndexReader;
 using Term = Lucene.Net.Index.Term;
 using BooleanClause = Lucene.Net.Search.BooleanClause;
@@ -81,9 +81,9 @@ namespace Lucene.Net.Search.Payloads
 				
 				for (int i = 0; i < queryClauses.Length; i++)
 				{
-					if (!queryClauses[i].IsProhibited())
+                    if (!queryClauses[i].Prohibited)
 					{
-						QueryToSpanQuery(queryClauses[i].GetQuery(), payloads);
+						QueryToSpanQuery(queryClauses[i].Query, payloads);
 					}
 				}
 			}
@@ -124,16 +124,16 @@ namespace Lucene.Net.Search.Payloads
 			}
 			else if (query is DisjunctionMaxQuery)
 			{
-				
-				for (System.Collections.IEnumerator iterator = ((DisjunctionMaxQuery) query).Iterator(); iterator.MoveNext(); )
-				{
-					QueryToSpanQuery((Query) iterator.Current, payloads);
-				}
+
+                for (IEnumerator<Query> iterator = ((DisjunctionMaxQuery)query).GetEnumerator(); iterator.MoveNext(); )
+                {
+                    QueryToSpanQuery(iterator.Current, payloads);
+                }
 			}
 			else if (query is MultiPhraseQuery)
 			{
 				MultiPhraseQuery mpq = (MultiPhraseQuery) query;
-				System.Collections.IList termArrays = mpq.GetTermArrays();
+				System.Collections.Generic.IList<Term[]> termArrays = mpq.GetTermArrays();
 				int[] positions = mpq.GetPositions();
 				if (positions.Length > 0)
 				{
@@ -146,22 +146,22 @@ namespace Lucene.Net.Search.Payloads
 							maxPosition = positions[i];
 						}
 					}
-					
-					System.Collections.ArrayList[] disjunctLists = new System.Collections.ArrayList[maxPosition + 1];
+
+                    IList<Query>[] disjunctLists = new IList<Query>[maxPosition + 1];
 					int distinctPositions = 0;
 					
 					for (int i = 0; i < termArrays.Count; ++i)
 					{
-						Term[] termArray = (Term[]) termArrays[i];
-						System.Collections.IList disjuncts = disjunctLists[positions[i]];
+						Term[] termArray = termArrays[i];
+						IList<Query> disjuncts = disjunctLists[positions[i]];
 						if (disjuncts == null)
 						{
-							disjuncts = (disjunctLists[positions[i]] = new System.Collections.ArrayList(termArray.Length));
+							disjuncts = (disjunctLists[positions[i]] = new List<Query>(termArray.Length));
 							++distinctPositions;
 						}
-						for (int j = 0; j < termArray.Length; ++j)
+						foreach(Term term in termArray)
 						{
-							disjuncts.Add(new SpanTermQuery(termArray[j]));
+							disjuncts.Add(new SpanTermQuery(term));
 						}
 					}
 					
@@ -170,10 +170,10 @@ namespace Lucene.Net.Search.Payloads
 					SpanQuery[] clauses = new SpanQuery[distinctPositions];
 					for (int i = 0; i < disjunctLists.Length; ++i)
 					{
-						System.Collections.ArrayList disjuncts = disjunctLists[i];
+						IList<Query> disjuncts = disjunctLists[i];
 						if (disjuncts != null)
 						{
-                            clauses[position++] = new SpanOrQuery((SpanQuery[]) (disjuncts.ToArray(typeof(SpanQuery[]))));
+                            clauses[position++] = new SpanOrQuery((SpanQuery[]) (disjuncts.ToArray()));
 						}
 						else
 						{
@@ -193,15 +193,13 @@ namespace Lucene.Net.Search.Payloads
 		
 		private void  GetPayloads(ICollection<byte[]> payloads, SpanQuery query)
 		{
-			Lucene.Net.Search.Spans.Spans spans = query.GetSpans(reader);
+			Spans.Spans spans = query.GetSpans(reader);
 			
 			while (spans.Next() == true)
 			{
 				if (spans.IsPayloadAvailable())
 				{
-					//ICollection<byte[]> payload = spans.GetPayload();
-                    System.Collections.Generic.ICollection<byte[]> payload = spans.GetPayload();
-					//IEnumerator<byte[]> it = payload.GetEnumerator();
+                    ICollection<byte[]> payload = spans.GetPayload();
                     foreach (byte[] bytes in payload)
                     {
                         payloads.Add(bytes);

Modified: incubator/lucene.net/trunk/src/core/Search/Payloads/PayloadTermQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/Payloads/PayloadTermQuery.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/Payloads/PayloadTermQuery.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/Payloads/PayloadTermQuery.cs Tue Feb 28 22:43:08 2012
@@ -40,7 +40,7 @@ namespace Lucene.Net.Search.Payloads
 	/// <see cref="Lucene.Net.Index.Term" /> occurs.
 	/// <p/>
 	/// In order to take advantage of this, you must override
-	/// <see cref="Lucene.Net.Search.Similarity.ScorePayload(String, byte[],int,int)" />
+    /// <see cref="Lucene.Net.Search.Similarity.ScorePayload(int, String, int, int, byte[],int,int)" />
 	/// which returns 1 by default.
 	/// <p/>
 	/// Payload scores are aggregated using a pluggable <see cref="PayloadFunction" />.
@@ -197,7 +197,7 @@ namespace Lucene.Net.Search.Payloads
 					return Enclosing_Instance.Enclosing_Instance.function.DocScore(doc, Enclosing_Instance.Enclosing_Instance.term.Field(), payloadsSeen, payloadScore);
 				}
 				
-				public override Explanation Explain(int doc)
+				protected internal override Explanation Explain(int doc)
 				{
 					ComplexExplanation result = new ComplexExplanation();
 					Explanation nonPayloadExpl = base.Explain(doc);
@@ -208,13 +208,13 @@ namespace Lucene.Net.Search.Payloads
 					result.AddDetail(payloadBoost);
 					
 					float payloadScore = GetPayloadScore();
-					payloadBoost.SetValue(payloadScore);
+					payloadBoost.Value = payloadScore;
 					// GSI: I suppose we could toString the payload, but I don't think that
 					// would be a good idea
-					payloadBoost.SetDescription("scorePayload(...)");
-					result.SetValue(nonPayloadExpl.GetValue() * payloadScore);
-					result.SetDescription("btq, product of:");
-					result.SetMatch(nonPayloadExpl.GetValue() == 0?false:true); // LUCENE-1303
+					payloadBoost.Description = "scorePayload(...)";
+					result.Value = nonPayloadExpl.Value * payloadScore;
+					result.Description = "btq, product of:";
+					result.Match = nonPayloadExpl.Value == 0?false:true; // LUCENE-1303
 					return result;
 				}
 			}

Modified: incubator/lucene.net/trunk/src/core/Search/PhraseQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/PhraseQuery.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/PhraseQuery.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/PhraseQuery.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using Lucene.Net.Support;
 using IndexReader = Lucene.Net.Index.IndexReader;
 using Term = Lucene.Net.Index.Term;
 using TermPositions = Lucene.Net.Index.TermPositions;
@@ -35,8 +35,8 @@ namespace Lucene.Net.Search
 	public class PhraseQuery:Query
 	{
 		private System.String field;
-        private SupportClass.EquatableList<Term> terms = new SupportClass.EquatableList<Term>(4);
-        private SupportClass.EquatableList<int> positions = new SupportClass.EquatableList<int>(4);
+        private EquatableList<Term> terms = new EquatableList<Term>(4);
+        private EquatableList<int> positions = new EquatableList<int>(4);
 		private int maxPosition = 0;
 		private int slop = 0;
 		
@@ -74,7 +74,7 @@ namespace Lucene.Net.Search
 		{
 			int position = 0;
 			if (positions.Count > 0)
-				position = ((System.Int32) positions[positions.Count - 1]) + 1;
+				position = positions[positions.Count - 1] + 1;
 			
 			Add(term, position);
 		}
@@ -99,7 +99,7 @@ namespace Lucene.Net.Search
 			}
 			
 			terms.Add(term);
-			positions.Add((System.Int32) position);
+			positions.Add(position);
 			if (position > maxPosition)
 				maxPosition = position;
 		}
@@ -107,7 +107,7 @@ namespace Lucene.Net.Search
 		/// <summary>Returns the set of terms in this phrase. </summary>
 		public virtual Term[] GetTerms()
 		{
-			return (Term[])terms.ToArray();
+			return terms.ToArray();
 		}
 		
 		/// <summary> Returns the relative positions of terms in this phrase.</summary>
@@ -115,7 +115,7 @@ namespace Lucene.Net.Search
 		{
 			int[] result = new int[positions.Count];
 			for (int i = 0; i < positions.Count; i++)
-				result[i] = ((System.Int32) positions[i]);
+				result[i] = positions[i];
 			return result;
 		}
 		
@@ -147,7 +147,7 @@ namespace Lucene.Net.Search
 				InitBlock(enclosingInstance);
 				this.similarity = Enclosing_Instance.GetSimilarity(searcher);
 				
-				idfExp = similarity.idfExplain(Enclosing_Instance.terms, searcher);
+				idfExp = similarity.IdfExplain(Enclosing_Instance.terms, searcher);
 				idf = idfExp.GetIdf();
 			}
 			
@@ -187,7 +187,7 @@ namespace Lucene.Net.Search
 				TermPositions[] tps = new TermPositions[Enclosing_Instance.terms.Count];
 				for (int i = 0; i < Enclosing_Instance.terms.Count; i++)
 				{
-					TermPositions p = reader.TermPositions((Term) Enclosing_Instance.terms[i]);
+					TermPositions p = reader.TermPositions(Enclosing_Instance.terms[i]);
 					if (p == null)
 						return null;
 					tps[i] = p;
@@ -204,7 +204,7 @@ namespace Lucene.Net.Search
 			{
 				
 				Explanation result = new Explanation();
-				result.SetDescription("weight(" + GetQuery() + " in " + doc + "), product of:");
+				result.Description = "weight(" + GetQuery() + " in " + doc + "), product of:";
 				
 				System.Text.StringBuilder docFreqs = new System.Text.StringBuilder();
 				System.Text.StringBuilder query = new System.Text.StringBuilder();
@@ -217,7 +217,7 @@ namespace Lucene.Net.Search
 						query.Append(" ");
 					}
 					
-					Term term = (Term) Enclosing_Instance.terms[i];
+					Term term = Enclosing_Instance.terms[i];
 					
 					query.Append(term.Text());
 				}
@@ -227,7 +227,7 @@ namespace Lucene.Net.Search
 				
 				// explain query weight
 				Explanation queryExpl = new Explanation();
-				queryExpl.SetDescription("queryWeight(" + GetQuery() + "), product of:");
+				queryExpl.Description = "queryWeight(" + GetQuery() + "), product of:";
 				
 				Explanation boostExpl = new Explanation(Enclosing_Instance.GetBoost(), "boost");
 				if (Enclosing_Instance.GetBoost() != 1.0f)
@@ -237,38 +237,43 @@ namespace Lucene.Net.Search
 				Explanation queryNormExpl = new Explanation(queryNorm, "queryNorm");
 				queryExpl.AddDetail(queryNormExpl);
 				
-				queryExpl.SetValue(boostExpl.GetValue() * idfExpl.GetValue() * queryNormExpl.GetValue());
+				queryExpl.Value = boostExpl.Value * idfExpl.Value * queryNormExpl.Value;
 				
 				result.AddDetail(queryExpl);
 				
 				// explain field weight
 				Explanation fieldExpl = new Explanation();
-				fieldExpl.SetDescription("fieldWeight(" + Enclosing_Instance.field + ":" + query + " in " + doc + "), product of:");
+				fieldExpl.Description = "fieldWeight(" + Enclosing_Instance.field + ":" + query + " in " + doc + "), product of:";
 				
-				Scorer scorer = Scorer(reader, true, false);
+				PhraseScorer scorer = (PhraseScorer)Scorer(reader, true, false);
 				if (scorer == null)
 				{
 					return new Explanation(0.0f, "no matching docs");
 				}
-				Explanation tfExpl = scorer.Explain(doc);
-				fieldExpl.AddDetail(tfExpl);
+                Explanation tfExplanation = new Explanation();
+                int d = scorer.Advance(doc);
+                float phraseFreq = (d == doc) ? scorer.CurrentFreq() : 0.0f;
+                tfExplanation.Value = similarity.Tf(phraseFreq);
+                tfExplanation.Description = "tf(phraseFreq=" + phraseFreq + ")";
+
+                fieldExpl.AddDetail(tfExplanation);
 				fieldExpl.AddDetail(idfExpl);
 				
 				Explanation fieldNormExpl = new Explanation();
 				byte[] fieldNorms = reader.Norms(Enclosing_Instance.field);
 				float fieldNorm = fieldNorms != null?Similarity.DecodeNorm(fieldNorms[doc]):1.0f;
-				fieldNormExpl.SetValue(fieldNorm);
-				fieldNormExpl.SetDescription("fieldNorm(field=" + Enclosing_Instance.field + ", doc=" + doc + ")");
+				fieldNormExpl.Value = fieldNorm;
+				fieldNormExpl.Description = "fieldNorm(field=" + Enclosing_Instance.field + ", doc=" + doc + ")";
 				fieldExpl.AddDetail(fieldNormExpl);
-				
-				fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());
+
+                fieldExpl.Value = tfExplanation.Value * idfExpl.Value * fieldNormExpl.Value;
 				
 				result.AddDetail(fieldExpl);
 				
 				// combine them
-				result.SetValue(queryExpl.GetValue() * fieldExpl.GetValue());
+				result.Value = queryExpl.Value * fieldExpl.Value;
 				
-				if (queryExpl.GetValue() == 1.0f)
+				if (queryExpl.Value == 1.0f)
 					return fieldExpl;
 				
 				return result;
@@ -280,7 +285,7 @@ namespace Lucene.Net.Search
 			if (terms.Count == 1)
 			{
 				// optimize one-term case
-				Term term = (Term) terms[0];
+				Term term = terms[0];
 				Query termQuery = new TermQuery(term);
 				termQuery.SetBoost(GetBoost());
 				return termQuery.CreateWeight(searcher);
@@ -288,11 +293,11 @@ namespace Lucene.Net.Search
 			return new PhraseWeight(this, searcher);
 		}
 		
-		/// <seealso cref="Lucene.Net.Search.Query.ExtractTerms(System.Collections.Hashtable)">
+		/// <seealso cref="Lucene.Net.Search.Query.ExtractTerms(System.Collections.Generic.ISet{T})">
 		/// </seealso>
-		public override void  ExtractTerms(System.Collections.Hashtable queryTerms)
+		public override void ExtractTerms(System.Collections.Generic.ISet<Term> queryTerms)
 		{
-			SupportClass.CollectionsHelper.AddAllIfNotContains(queryTerms, terms);
+		    queryTerms.UnionWith(terms);
 		}
 		
 		/// <summary>Prints a user-readable version of this query. </summary>
@@ -309,15 +314,15 @@ namespace Lucene.Net.Search
 			System.String[] pieces = new System.String[maxPosition + 1];
 			for (int i = 0; i < terms.Count; i++)
 			{
-				int pos = ((System.Int32) positions[i]);
+				int pos = positions[i];
 				System.String s = pieces[pos];
 				if (s == null)
 				{
-					s = ((Term) terms[i]).Text();
+					s = terms[i].Text();
 				}
 				else
 				{
-					s = s + "|" + ((Term) terms[i]).Text();
+					s = s + "|" + terms[i].Text();
 				}
 				pieces[pos] = s;
 			}

Modified: incubator/lucene.net/trunk/src/core/Search/PhraseQueue.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/PhraseQueue.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/PhraseQueue.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/PhraseQueue.cs Tue Feb 28 22:43:08 2012
@@ -16,23 +16,20 @@
  */
 
 using System;
-
-using PriorityQueue = Lucene.Net.Util.PriorityQueue;
+using Lucene.Net.Util;
 
 namespace Lucene.Net.Search
 {
 	
-	sealed class PhraseQueue:PriorityQueue
+	sealed class PhraseQueue : PriorityQueue<PhrasePositions>
 	{
 		internal PhraseQueue(int size)
 		{
 			Initialize(size);
 		}
-		
-		public override bool LessThan(System.Object o1, System.Object o2)
+
+        public override bool LessThan(PhrasePositions pp1, PhrasePositions pp2)
 		{
-			PhrasePositions pp1 = (PhrasePositions) o1;
-			PhrasePositions pp2 = (PhrasePositions) o2;
 			if (pp1.doc == pp2.doc)
 				if (pp1.position == pp2.position)
 				// same doc and pp.position, so decide by actual term positions. 

Modified: incubator/lucene.net/trunk/src/core/Search/PhraseScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/PhraseScorer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/PhraseScorer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/PhraseScorer.cs Tue Feb 28 22:43:08 2012
@@ -75,27 +75,11 @@ namespace Lucene.Net.Search
 			first.doc = - 1;
 		}
 		
-		/// <deprecated> use <see cref="DocID()" /> instead. 
-		/// </deprecated>
-        [Obsolete("use DocID() instead.")]
-		public override int Doc()
-		{
-			return first.doc;
-		}
-		
 		public override int DocID()
 		{
 			return first.doc;
 		}
 		
-		/// <deprecated> use <see cref="NextDoc()" /> instead. 
-		/// </deprecated>
-        [Obsolete("use NextDoc() instead.")]
-		public override bool Next()
-		{
-			return NextDoc() != NO_MORE_DOCS;
-		}
-		
 		public override int NextDoc()
 		{
 			if (firstTime)
@@ -148,14 +132,6 @@ namespace Lucene.Net.Search
 			return norms == null?raw:raw * Similarity.DecodeNorm(norms[first.doc]); // normalize
 		}
 		
-		/// <deprecated> use <see cref="Advance(int)" /> instead. 
-		/// </deprecated>
-        [Obsolete("use Advance(int) instead.")]
-		public override bool SkipTo(int target)
-		{
-			return Advance(target) != NO_MORE_DOCS;
-		}
-		
 		public override int Advance(int target)
 		{
 			firstTime = false;
@@ -173,7 +149,16 @@ namespace Lucene.Net.Search
 			}
 			return first.doc;
 		}
-		
+
+        /// <summary>
+        /// Phrase frequency in current doc as computed by PhraseFreq()
+        /// </summary>
+        /// <returns></returns>
+        public float CurrentFreq()
+        {
+            return freq;
+        }
+
 		/// <summary> For a document containing all the phrase query terms, compute the
 		/// frequency of the phrase in that document. 
 		/// A non zero frequency means a match.
@@ -210,7 +195,7 @@ namespace Lucene.Net.Search
 			last = first = null;
 			while (pq.Top() != null)
 			{
-				PhrasePositions pp = (PhrasePositions) pq.Pop();
+				PhrasePositions pp = pq.Pop();
 				if (last != null)
 				{
 					// add next to end of list
@@ -231,18 +216,6 @@ namespace Lucene.Net.Search
 			last.next = null;
 		}
 		
-		public override Explanation Explain(int doc)
-		{
-			Explanation tfExplanation = new Explanation();
-			
-			int d = Advance(doc);
-			float phraseFreq = (d == doc)?freq:0.0f;
-			tfExplanation.SetValue(GetSimilarity().Tf(phraseFreq));
-			tfExplanation.SetDescription("tf(phraseFreq=" + phraseFreq + ")");
-			
-			return tfExplanation;
-		}
-		
 		public override System.String ToString()
 		{
 			return "scorer(" + weight + ")";

Modified: incubator/lucene.net/trunk/src/core/Search/PrefixFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/PrefixFilter.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/PrefixFilter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/PrefixFilter.cs Tue Feb 28 22:43:08 2012
@@ -26,7 +26,7 @@ namespace Lucene.Net.Search
 	/// field.
 	/// </summary>
 	[Serializable]
-	public class PrefixFilter:MultiTermQueryWrapperFilter
+	public class PrefixFilter:MultiTermQueryWrapperFilter<PrefixQuery>
 	{
 		
 		public PrefixFilter(Term prefix):base(new PrefixQuery(prefix))
@@ -35,7 +35,7 @@ namespace Lucene.Net.Search
 		
 		public virtual Term GetPrefix()
 		{
-			return ((PrefixQuery) query).GetPrefix();
+			return query.GetPrefix();
 		}
 		
 		/// <summary>Prints a user-readable version of this query. </summary>

Modified: incubator/lucene.net/trunk/src/core/Search/PrefixQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/PrefixQuery.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/PrefixQuery.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/PrefixQuery.cs Tue Feb 28 22:43:08 2012
@@ -37,7 +37,7 @@ namespace Lucene.Net.Search
 		private Term prefix;
 		
 		/// <summary>Constructs a query for terms starting with <c>prefix</c>. </summary>
-		public PrefixQuery(Term prefix):base(prefix)
+		public PrefixQuery(Term prefix)
 		{ //will be removed in 3.0
 			this.prefix = prefix;
 		}

Modified: incubator/lucene.net/trunk/src/core/Search/Query.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/Query.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/Query.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/Query.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,8 @@
  */
 
 using System;
-
+using System.Linq;
+using Lucene.Net.Index;
 using IndexReader = Lucene.Net.Index.IndexReader;
 
 namespace Lucene.Net.Search
@@ -34,7 +35,7 @@ namespace Lucene.Net.Search
     /// <item> <see cref="MultiPhraseQuery" /> </item>
     /// <item> <see cref="FuzzyQuery" /> </item>
     /// <item> <see cref="TermRangeQuery" /> </item>
-    /// <item> <see cref="NumericRangeQuery" /> </item>
+    /// <item> <see cref="NumericRangeQuery{T}" /> </item>
     /// <item> <see cref="Lucene.Net.Search.Spans.SpanQuery" /> </item>
 	/// </list>
 	/// <p/>A parser for queries is contained in:
@@ -134,7 +135,7 @@ namespace Lucene.Net.Search
 		/// </summary>
 		public virtual Query Combine(Query[] queries)
 		{
-            System.Collections.Hashtable uniques = new System.Collections.Hashtable();
+            var uniques = new System.Collections.Generic.HashSet<Query>();
 			for (int i = 0; i < queries.Length; i++)
 			{
 				Query query = queries[i];
@@ -155,26 +156,23 @@ namespace Lucene.Net.Search
 				{
 					for (int j = 0; j < clauses.Length; j++)
 					{
-						SupportClass.CollectionsHelper.AddIfNotContains(uniques, clauses[j].GetQuery());
+                        uniques.Add(clauses[j].Query);
 					}
 				}
 				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)
-                {
-                    return (Query) key;
-                }
+			    return uniques.First();
 			}
 			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;
 		}
@@ -185,7 +183,7 @@ namespace Lucene.Net.Search
 		/// 
 		/// </summary>
 		/// <throws>  UnsupportedOperationException if this query is not yet rewritten </throws>
-		public virtual void  ExtractTerms(System.Collections.Hashtable terms)
+		public virtual void  ExtractTerms(System.Collections.Generic.ISet<Term> terms)
 		{
 			// needs to be implemented by query subclasses
 			throw new System.NotSupportedException();
@@ -198,24 +196,22 @@ namespace Lucene.Net.Search
 		/// 
 		/// <p/>A utility for use by <see cref="Combine(Query[])" /> implementations.
 		/// </summary>
-		public static Query MergeBooleanQueries(BooleanQuery[] queries)
+		public static Query MergeBooleanQueries(params BooleanQuery[] queries)
 		{
-            System.Collections.Hashtable allClauses = new System.Collections.Hashtable();
-			for (int i = 0; i < queries.Length; i++)
+            var allClauses = new System.Collections.Generic.HashSet<BooleanClause>();
+			foreach (BooleanQuery booleanQuery in queries)
 			{
-				BooleanClause[] clauses = queries[i].GetClauses();
-				for (int j = 0; j < clauses.Length; j++)
-				{
-					SupportClass.CollectionsHelper.AddIfNotContains(allClauses, clauses[j]);
-				}
+                foreach (BooleanClause clause in booleanQuery)
+                {
+                    allClauses.Add(clause);
+                }
 			}
-			
-			bool coordDisabled = queries.Length == 0?false:queries[0].IsCoordDisabled();
+
+		    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 clause in allClauses)
 			{
-				result.Add((BooleanClause) i2.Current);
+                result.Add(clause);
 			}
 			return result;
 		}

Modified: incubator/lucene.net/trunk/src/core/Search/QueryTermVector.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/QueryTermVector.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/QueryTermVector.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/QueryTermVector.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,9 @@
  */
 
 using System;
-
+using System.Collections.Generic;
+using System.Linq;
+using Lucene.Net.Support;
 using Analyzer = Lucene.Net.Analysis.Analyzer;
 using TokenStream = Lucene.Net.Analysis.TokenStream;
 using TermAttribute = Lucene.Net.Analysis.Tokenattributes.TermAttribute;
@@ -55,13 +57,13 @@ namespace Lucene.Net.Search
 				TokenStream stream = analyzer.TokenStream("", new System.IO.StringReader(queryString));
 				if (stream != null)
 				{
-					System.Collections.ArrayList terms = new System.Collections.ArrayList();
+					IList<string> terms = new List<string>();
 					try
 					{
 						bool hasMoreTokens = false;
 						
 						stream.Reset();
-						TermAttribute termAtt = (TermAttribute) stream.AddAttribute(typeof(TermAttribute));
+                        TermAttribute termAtt = stream.AddAttribute<TermAttribute>();
 						
 						hasMoreTokens = stream.IncrementToken();
 						while (hasMoreTokens)
@@ -69,7 +71,7 @@ namespace Lucene.Net.Search
 							terms.Add(termAtt.Term());
 							hasMoreTokens = stream.IncrementToken();
 						}
-						ProcessTerms((System.String[]) terms.ToArray(typeof(System.String)));
+						ProcessTerms(terms.ToArray());
 					}
 					catch (System.IO.IOException e)
 					{
@@ -83,35 +85,33 @@ namespace Lucene.Net.Search
 			if (queryTerms != null)
 			{
 				System.Array.Sort(queryTerms);
-				System.Collections.IDictionary tmpSet = new System.Collections.Hashtable(queryTerms.Length);
+				IDictionary<string, int> tmpSet = new HashMap<string, int>(queryTerms.Length);
 				//filter out duplicates
-				System.Collections.ArrayList tmpList = new System.Collections.ArrayList(queryTerms.Length);
-				System.Collections.ArrayList tmpFreqs = new System.Collections.ArrayList(queryTerms.Length);
+				IList<string> tmpList = new List<string>(queryTerms.Length);
+				IList<int> tmpFreqs = new List<int>(queryTerms.Length);
 				int j = 0;
 				for (int i = 0; i < queryTerms.Length; i++)
 				{
-					System.String term = queryTerms[i];
-					System.Object temp_position = tmpSet[term];
-					if (temp_position == null)
+					var term = queryTerms[i];
+					var position = tmpSet[term];
+					if (!tmpSet.ContainsKey(term)) // if temp_position == null
 					{
-						tmpSet[term] = (System.Int32) j++;
+						tmpSet[term] = j++;
 						tmpList.Add(term);
 						tmpFreqs.Add(1);
 					}
 					else
 					{
-                        System.Int32 position = (System.Int32) tmpSet[term];
-						System.Int32 integer = (System.Int32) tmpFreqs[position];
-						tmpFreqs[position] = (System.Int32) (integer + 1);
+						int integer = tmpFreqs[position];
+						tmpFreqs[position] = (integer + 1);
 					}
 				}
-                terms = (System.String[]) tmpList.ToArray(typeof(System.String));
+                terms = tmpList.ToArray();
 				//termFreqs = (int[])tmpFreqs.toArray(termFreqs);
 				termFreqs = new int[tmpFreqs.Count];
 				int i2 = 0;
-				for (System.Collections.IEnumerator iter = tmpFreqs.GetEnumerator(); iter.MoveNext(); )
+                foreach (int integer in tmpFreqs)
 				{
-					System.Int32 integer = (System.Int32) iter.Current;
 					termFreqs[i2++] = integer;
 				}
 			}

Modified: incubator/lucene.net/trunk/src/core/Search/QueryWrapperFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/QueryWrapperFilter.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/QueryWrapperFilter.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/QueryWrapperFilter.cs Tue Feb 28 22:43:08 2012
@@ -37,49 +37,6 @@ namespace Lucene.Net.Search
 	[Serializable]
 	public class QueryWrapperFilter:Filter
 	{
-		private class AnonymousClassCollector:Collector
-		{
-			public AnonymousClassCollector(System.Collections.BitArray bits, QueryWrapperFilter enclosingInstance)
-			{
-				InitBlock(bits, enclosingInstance);
-			}
-			private void  InitBlock(System.Collections.BitArray bits, QueryWrapperFilter enclosingInstance)
-			{
-				this.bits = bits;
-				this.enclosingInstance = enclosingInstance;
-			}
-			private System.Collections.BitArray bits;
-			private QueryWrapperFilter enclosingInstance;
-			public QueryWrapperFilter Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			private int base_Renamed = 0;
-			public override void  SetScorer(Scorer scorer)
-			{
-				// score is not needed by this collector 
-			}
-			public override void  Collect(int doc)
-			{
-                for (int i = 0; doc + base_Renamed >= bits.Length; i =+ 64)
-                {
-                    bits.Length += i;
-                }
-                bits.Set(doc + base_Renamed, true); // set bit for hit
-			}
-			public override void  SetNextReader(IndexReader reader, int docBase)
-			{
-				base_Renamed = docBase;
-			}
-			public override bool AcceptsDocsOutOfOrder()
-			{
-				return true;
-			}
-		}
 		private class AnonymousClassDocIdSet:DocIdSet
 		{
 			public AnonymousClassDocIdSet(Lucene.Net.Search.Weight weight, Lucene.Net.Index.IndexReader reader, QueryWrapperFilter enclosingInstance)
@@ -122,17 +79,6 @@ namespace Lucene.Net.Search
 			this.query = query;
 		}
 		
-		/// <deprecated> Use <see cref="GetDocIdSet(IndexReader)" /> instead.
-		/// </deprecated>
-        [Obsolete("Use GetDocIdSet(IndexReader) instead.")]
-		public override System.Collections.BitArray Bits(IndexReader reader)
-		{
-			System.Collections.BitArray bits = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0?reader.MaxDoc() / 64:reader.MaxDoc() / 64 + 1) * 64);
-			
-			new IndexSearcher(reader).Search(query, new AnonymousClassCollector(bits, this));
-			return bits;
-		}
-		
 		public override DocIdSet GetDocIdSet(IndexReader reader)
 		{
 			Weight weight = query.Weight(new IndexSearcher(reader));

Modified: incubator/lucene.net/trunk/src/core/Search/ReqExclScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/ReqExclScorer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/ReqExclScorer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/ReqExclScorer.cs Tue Feb 28 22:43:08 2012
@@ -44,14 +44,6 @@ namespace Lucene.Net.Search
 			this.exclDisi = exclDisi;
 		}
 		
-		/// <deprecated> use <see cref="NextDoc()" /> instead. 
-		/// </deprecated>
-        [Obsolete("use NextDoc() instead. ")]
-		public override bool Next()
-		{
-			return NextDoc() != NO_MORE_DOCS;
-		}
-		
 		public override int NextDoc()
 		{
 			if (reqScorer == null)
@@ -112,14 +104,6 @@ namespace Lucene.Net.Search
 			return NO_MORE_DOCS;
 		}
 		
-		/// <deprecated> use <see cref="DocID()" /> instead. 
-		/// </deprecated>
-        [Obsolete("use DocID() instead.")]
-		public override int Doc()
-		{
-			return reqScorer.Doc(); // reqScorer may be null when next() or skipTo() already return false
-		}
-		
 		public override int DocID()
 		{
 			return doc;
@@ -135,14 +119,6 @@ namespace Lucene.Net.Search
 			return reqScorer.Score(); // reqScorer may be null when next() or skipTo() already return false
 		}
 		
-		/// <deprecated> use <see cref="Advance(int)" /> instead. 
-		/// </deprecated>
-        [Obsolete("use Advance(int) instead.")]
-		public override bool SkipTo(int target)
-		{
-			return Advance(target) != NO_MORE_DOCS;
-		}
-		
 		public override int Advance(int target)
 		{
 			if (reqScorer == null)
@@ -160,20 +136,5 @@ namespace Lucene.Net.Search
 			}
 			return doc = ToNonExcluded();
 		}
-		
-		public override Explanation Explain(int doc)
-		{
-			Explanation res = new Explanation();
-			if (exclDisi.Advance(doc) == doc)
-			{
-				res.SetDescription("excluded");
-			}
-			else
-			{
-				res.SetDescription("not excluded");
-				res.AddDetail(reqScorer.Explain(doc));
-			}
-			return res;
-		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Search/ReqOptSumScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/ReqOptSumScorer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/ReqOptSumScorer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/ReqOptSumScorer.cs Tue Feb 28 22:43:08 2012
@@ -44,40 +44,16 @@ namespace Lucene.Net.Search
 			this.optScorer = optScorer;
 		}
 		
-		/// <deprecated> use <see cref="NextDoc()" /> instead. 
-		/// </deprecated>
-        [Obsolete("use NextDoc() instead.")]
-		public override bool Next()
-		{
-			return reqScorer.Next();
-		}
-		
 		public override int NextDoc()
 		{
 			return reqScorer.NextDoc();
 		}
 		
-		/// <deprecated> use <see cref="Advance(int)" /> instead. 
-		/// </deprecated>
-        [Obsolete("use Advance(int) instead.")]
-		public override bool SkipTo(int target)
-		{
-			return reqScorer.SkipTo(target);
-		}
-		
 		public override int Advance(int target)
 		{
 			return reqScorer.Advance(target);
 		}
 		
-		/// <deprecated> use <see cref="DocID()" /> instead. 
-		/// </deprecated>
-        [Obsolete("use DocID() instead.")]
-		public override int Doc()
-		{
-			return reqScorer.Doc();
-		}
-		
 		public override int DocID()
 		{
 			return reqScorer.DocID();
@@ -107,18 +83,5 @@ namespace Lucene.Net.Search
 			
 			return optScorerDoc == curDoc?reqScore + optScorer.Score():reqScore;
 		}
-		
-		/// <summary>Explain the score of a document.
-		/// TODO: Also show the total score.
-		/// See BooleanScorer.explain() on how to do this.
-		/// </summary>
-		public override Explanation Explain(int doc)
-		{
-			Explanation res = new Explanation();
-			res.SetDescription("required, optional");
-			res.AddDetail(reqScorer.Explain(doc));
-			res.AddDetail(optScorer.Explain(doc));
-			return res;
-		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Search/ScoreCachingWrappingScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/ScoreCachingWrappingScorer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/ScoreCachingWrappingScorer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/ScoreCachingWrappingScorer.cs Tue Feb 28 22:43:08 2012
@@ -53,11 +53,6 @@ namespace Lucene.Net.Search
 			return scorer.GetSimilarity();
 		}
 		
-		public override Explanation Explain(int doc)
-		{
-			return scorer.Explain(doc);
-		}
-		
 		public override float Score()
 		{
 			int doc = scorer.DocID();
@@ -70,27 +65,11 @@ namespace Lucene.Net.Search
 			return curScore;
 		}
 		
-		/// <deprecated> use <see cref="DocID()" /> instead. 
-		/// </deprecated>
-        [Obsolete("use DocID() instead.")]
-		public override int Doc()
-		{
-			return scorer.Doc();
-		}
-		
 		public override int DocID()
 		{
 			return scorer.DocID();
 		}
 		
-		/// <deprecated> use <see cref="NextDoc()" /> instead. 
-		/// </deprecated>
-        [Obsolete("use NextDoc() instead.")]
-		public override bool Next()
-		{
-			return scorer.Next();
-		}
-		
 		public override int NextDoc()
 		{
 			return scorer.NextDoc();
@@ -101,14 +80,6 @@ namespace Lucene.Net.Search
 			scorer.Score(collector);
 		}
 		
-		/// <deprecated> use <see cref="Advance(int)" /> instead. 
-		/// </deprecated>
-        [Obsolete("use Advance(int) instead.")]
-		public override bool SkipTo(int target)
-		{
-			return scorer.SkipTo(target);
-		}
-		
 		public override int Advance(int target)
 		{
 			return scorer.Advance(target);

Modified: incubator/lucene.net/trunk/src/core/Search/Scorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/Scorer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/Scorer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/Scorer.cs Tue Feb 28 22:43:08 2012
@@ -37,10 +37,7 @@ namespace Lucene.Net.Search
 	/// not valid scores.  Certain collectors (eg <see cref="TopScoreDocCollector" />
 	///) will not properly collect hits
 	/// with these scores.
-	/// 
 	/// </summary>
-	/// <seealso cref="BooleanQuery.SetAllowDocsOutOfOrder">
-	/// </seealso>
 	public abstract class Scorer:DocIdSetIterator
 	{
 		private Similarity similarity;
@@ -60,21 +57,7 @@ namespace Lucene.Net.Search
 		}
 		
 		/// <summary>Scores and collects all matching documents.</summary>
-		/// <param name="hc">The collector to which all matching documents are passed through
-		/// <see cref="HitCollector.Collect(int, float)" />.
-		/// <br/>When this method is used the <see cref="Explain(int)" /> method should not be used.
-		/// </param>
-		/// <deprecated> use <see cref="Score(Collector)" /> instead.
-		/// </deprecated>
-        [Obsolete("use Score(Collector) instead.")]
-		public virtual void  Score(HitCollector hc)
-		{
-			Score(new HitCollectorWrapper(hc));
-		}
-		
-		/// <summary>Scores and collects all matching documents.</summary>
 		/// <param name="collector">The collector to which all matching documents are passed.
-		/// <br/>When this method is used the <see cref="Explain(int)" /> method should not be used.
 		/// </param>
 		public virtual void  Score(Collector collector)
 		{
@@ -86,25 +69,6 @@ namespace Lucene.Net.Search
 			}
 		}
 		
-		/// <summary>Expert: Collects matching documents in a range.  Hook for optimization.
-		/// Note that <see cref="DocIdSetIterator.Next()" /> must be called once before this method is called
-		/// for the first time.
-		/// </summary>
-		/// <param name="hc">The collector to which all matching documents are passed through
-		/// <see cref="HitCollector.Collect(int, float)" />.
-		/// </param>
-		/// <param name="max">Do not score documents past this.
-		/// </param>
-		/// <returns> true if more matching documents may remain.
-		/// </returns>
-		/// <deprecated> use <see cref="Score(Collector, int, int)" /> instead.
-		/// </deprecated>
-        [Obsolete("use Score(Collector, int, int) instead")]
-		protected internal virtual bool Score(HitCollector hc, int max)
-		{
-			return Score(new HitCollectorWrapper(hc), max, DocID());
-		}
-		
 		/// <summary> Expert: Collects matching documents in a range. Hook for optimization.
 		/// Note, <paramref name="firstDocID" /> is added to ensure that <see cref="DocIdSetIterator.NextDoc()" />
 		/// was called before this method.
@@ -133,25 +97,10 @@ namespace Lucene.Net.Search
 		}
 		
 		/// <summary>Returns the score of the current document matching the query.
-        /// Initially invalid, until <see cref="DocIdSetIterator.Next()" /> or <see cref="DocIdSetIterator.SkipTo(int)" />
+        /// Initially invalid, until <see cref="DocIdSetIterator.NextDoc()" /> or <see cref="DocIdSetIterator.Advance(int)" />
 		/// is called the first time, or when called from within
 		/// <see cref="Collector.Collect(int)" />.
 		/// </summary>
 		public abstract float Score();
-		
-		/// <summary>Returns an explanation of the score for a document.
-        /// <br/>When this method is used, the <see cref="DocIdSetIterator.Next()" />, <see cref="DocIdSetIterator.SkipTo(int)" /> and
-		/// <see cref="Score(HitCollector)" /> methods should not be used.
-		/// </summary>
-		/// <param name="doc">The document number for the explanation.
-		/// 
-		/// </param>
-		/// <deprecated> Please use <see cref="IndexSearcher.Explain(Lucene.Net.Search.Weight,int)" />
-		/// or <see cref="Weight.Explain(IndexReader, int)" /> instead.
-		/// </deprecated>
-		public virtual Explanation Explain(int doc)
-		{
-			throw new System.NotSupportedException();
-		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Search/Searchable.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/Searchable.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/Searchable.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/Searchable.cs Tue Feb 28 22:43:08 2012
@@ -41,33 +41,8 @@ namespace Lucene.Net.Search
 	/// expected to be implemented directly, it may be changed unexpectedly between
 	/// releases.
 	/// </summary>
-	public interface Searchable
+	public interface Searchable : IDisposable
 	{
-		
-		/// <summary>Lower-level search API.
-		/// 
-		/// <p/><see cref="HitCollector.Collect(int,float)" /> is called for every non-zero
-		/// scoring document.
-		/// <br/>HitCollector-based access to remote indexes is discouraged.
-		/// 
-		/// <p/>Applications should only use this if they need <i>all</i> of the
-		/// matching documents.  The high-level search API (<see cref="Searcher.Search(Query)" />)
-		/// is usually more efficient, as it skips
-		/// non-high-scoring hits.
-		/// 
-		/// </summary>
-		/// <param name="weight">to match documents
-		/// </param>
-		/// <param name="filter">if non-null, used to permit documents to be collected.
-		/// </param>
-		/// <param name="results">to receive hits
-		/// </param>
-		/// <throws>  BooleanQuery.TooManyClauses </throws>
-		/// <deprecated> use <see cref="Search(Weight, Filter, Collector)" /> instead.
-		/// </deprecated>
-        [Obsolete("use Search(Weight, Filter, Collector) instead.")]
-		void  Search(Weight weight, Filter filter, HitCollector results);
-		
 		/// <summary> Lower-level search API.
 		/// 
 		/// <p/>
@@ -76,7 +51,7 @@ namespace Lucene.Net.Search
 		/// 
 		/// <p/>
 		/// Applications should only use this if they need <i>all</i> of the matching
-		/// documents. The high-level search API (<see cref="Searcher.Search(Query)" />) is
+		/// documents. The high-level search API (<see cref="Searcher.Search(Query,int)" />) is
 		/// usually more efficient, as it skips non-high-scoring hits.
 		/// 
 		/// </summary>
@@ -91,7 +66,7 @@ namespace Lucene.Net.Search
 		
 		/// <summary>Frees resources associated with this Searcher.
 		/// Be careful not to call this method while you are still using objects
-		/// like <see cref="Hits" />.
+		/// that reference this searchable
 		/// </summary>
 		void  Close();
 		
@@ -120,8 +95,8 @@ namespace Lucene.Net.Search
 		/// 
 		/// <p/>Called by <see cref="Hits" />.
 		/// 
-		/// <p/>Applications should usually call <see cref="Searcher.Search(Query)" /> or
-		/// <see cref="Searcher.Search(Query,Filter)" /> instead.
+		/// <p/>Applications should usually call <see cref="Searcher.Search(Query, int)" /> or
+		/// <see cref="Searcher.Search(Query,Filter,int)" /> instead.
 		/// </summary>
 		/// <throws>  BooleanQuery.TooManyClauses </throws>
 		TopDocs Search(Weight weight, Filter filter, int n);

Modified: incubator/lucene.net/trunk/src/core/Search/Searcher.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/Searcher.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/Searcher.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/Searcher.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using Lucene.Net.Documents;
 using Document = Lucene.Net.Documents.Document;
 using CorruptIndexException = Lucene.Net.Index.CorruptIndexException;
 using Term = Lucene.Net.Index.Term;
@@ -33,7 +33,7 @@ namespace Lucene.Net.Search
 	/// </summary>
 	public abstract class Searcher : System.MarshalByRefObject, Searchable, System.IDisposable
 	{
-		public Searcher()
+	    protected Searcher()
 		{
 			InitBlock();
 		}
@@ -42,56 +42,6 @@ namespace Lucene.Net.Search
 			similarity = Similarity.GetDefault();
 		}
 		
-		/// <summary>Returns the documents matching <c>query</c>. </summary>
-		/// <throws>  BooleanQuery.TooManyClauses </throws>
-		/// <deprecated> Hits will be removed in Lucene 3.0. Use
-		/// <see cref="Search(Query, Filter, int)" /> instead.
-		/// </deprecated>
-        [Obsolete("Hits will be removed in Lucene 3.0. Use Search(Query, Filter, int) instead")]
-		public Hits Search(Query query)
-		{
-			return Search(query, (Filter) null);
-		}
-		
-		/// <summary>Returns the documents matching <c>query</c> and
-		/// <c>filter</c>.
-		/// </summary>
-		/// <throws>  BooleanQuery.TooManyClauses </throws>
-		/// <deprecated> Hits will be removed in Lucene 3.0. Use
-		/// <see cref="Search(Query, Filter, int)" /> instead.
-		/// </deprecated>
-        [Obsolete("Hits will be removed in Lucene 3.0. Use Search(Query, Filter, int) instead")]
-		public virtual Hits Search(Query query, Filter filter)
-		{
-			return new Hits(this, query, filter);
-		}
-		
-		/// <summary>Returns documents matching <c>query</c> sorted by
-		/// <c>sort</c>.
-		/// </summary>
-		/// <throws>  BooleanQuery.TooManyClauses </throws>
-		/// <deprecated> Hits will be removed in Lucene 3.0. Use 
-		/// <see cref="Search(Query, Filter, int, Sort)" /> instead.
-		/// </deprecated>
-        [Obsolete("Hits will be removed in Lucene 3.0. Use Search(Query, Filter, int, Sort) instead")]
-		public virtual Hits Search(Query query, Sort sort)
-		{
-			return new Hits(this, query, null, sort);
-		}
-		
-		/// <summary>Returns documents matching <c>query</c> and <c>filter</c>,
-		/// sorted by <c>sort</c>.
-		/// </summary>
-		/// <throws>  BooleanQuery.TooManyClauses </throws>
-		/// <deprecated> Hits will be removed in Lucene 3.0. Use 
-		/// <see cref="Search(Query, Filter, int, Sort)" /> instead.
-		/// </deprecated>
-        [Obsolete("Hits will be removed in Lucene 3.0. Use Search(Query, Filter, int, Sort) instead")]
-		public virtual Hits Search(Query query, Filter filter, Sort sort)
-		{
-			return new Hits(this, query, filter, sort);
-		}
-		
 		/// <summary>Search implementation with arbitrary sorting.  Finds
 		/// the top <c>n</c> hits for <c>query</c>, applying
 		/// <c>filter</c> if non-null, and sorting the hits by the criteria in
@@ -109,28 +59,6 @@ namespace Lucene.Net.Search
 		
 		/// <summary>Lower-level search API.
 		/// 
-		/// <p/><see cref="HitCollector.Collect(int,float)" /> is called for every matching
-		/// document.
-		/// 
-		/// <p/>Applications should only use this if they need <i>all</i> of the
-		/// matching documents.  The high-level search API (<see cref="Searcher.Search(Query)" />)
-		/// is usually more efficient, as it skips
-		/// non-high-scoring hits.
-		/// <p/>Note: The <c>score</c> passed to this method is a raw score.
-		/// In other words, the score will not necessarily be a float whose value is
-		/// between 0 and 1.
-		/// </summary>
-		/// <throws>  BooleanQuery.TooManyClauses </throws>
-		/// <deprecated> use <see cref="Search(Query, Collector)" /> instead.
-		/// </deprecated>
-        [Obsolete("use Search(Query, Collector) instead.")]
-		public virtual void  Search(Query query, HitCollector results)
-		{
-			Search(CreateWeight(query), null, new HitCollectorWrapper(results));
-		}
-		
-		/// <summary>Lower-level search API.
-		/// 
 		/// <p/><see cref="Collector.Collect(int)" /> is called for every matching document.
 		/// 
 		/// <p/>Applications should only use this if they need <i>all</i> of the matching
@@ -148,33 +76,6 @@ namespace Lucene.Net.Search
 		
 		/// <summary>Lower-level search API.
 		/// 
-		/// <p/><see cref="HitCollector.Collect(int,float)" /> is called for every matching
-		/// document.
-		/// <br/>HitCollector-based access to remote indexes is discouraged.
-		/// 
-		/// <p/>Applications should only use this if they need <i>all</i> of the
-		/// matching documents.  The high-level search API (<see cref="Searcher.Search(Query, Filter, int)" />)
-		/// is usually more efficient, as it skips
-		/// non-high-scoring hits.
-		/// 
-		/// </summary>
-		/// <param name="query">to match documents
-		/// </param>
-		/// <param name="filter">if non-null, used to permit documents to be collected.
-		/// </param>
-		/// <param name="results">to receive hits
-		/// </param>
-		/// <throws>  BooleanQuery.TooManyClauses </throws>
-		/// <deprecated> use <see cref="Search(Query, Filter, Collector)" /> instead.
-		/// </deprecated>
-        [Obsolete("use Search(Query, Filter, Collector) instead.")]
-		public virtual void  Search(Query query, Filter filter, HitCollector results)
-		{
-			Search(CreateWeight(query), filter, new HitCollectorWrapper(results));
-		}
-		
-		/// <summary>Lower-level search API.
-		/// 
 		/// <p/><see cref="Collector.Collect(int)" /> is called for every matching
 		/// document.
 		/// <br/>Collector-based access to remote indexes is discouraged.
@@ -270,28 +171,30 @@ namespace Lucene.Net.Search
 			}
 			return result;
 		}
-		
-		/* The following abstract methods were added as a workaround for GCJ bug #15411.
-		* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15411
-		*/
-		/// <deprecated> use <see cref="Search(Weight, Filter, Collector)" /> instead.
-		/// </deprecated>
-        [Obsolete("use Search(Weight, Filter, Collector) instead.")]
-		public virtual void  Search(Weight weight, Filter filter, HitCollector results)
-		{
-			Search(weight, filter, new HitCollectorWrapper(results));
-		}
-		abstract public void  Search(Weight weight, Filter filter, Collector results);
-		abstract public void  Close();
-        abstract public void Dispose();
-		abstract public int DocFreq(Term term);
-		abstract public int MaxDoc();
-		abstract public TopDocs Search(Weight weight, Filter filter, int n);
-		abstract public Document Doc(int i);
-		abstract public Query Rewrite(Query query);
-		abstract public Explanation Explain(Weight weight, int doc);
-		abstract public TopFieldDocs Search(Weight weight, Filter filter, int n, Sort sort);
+
+		public abstract void  Search(Weight weight, Filter filter, Collector results);
+
+        [Obsolete("Use Dispose() instead")]
+		public void Close()
+        {
+            Dispose();
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+        }
+
+	    protected abstract void Dispose(bool disposing);
+
+		public abstract int DocFreq(Term term);
+		public abstract int MaxDoc();
+		public abstract TopDocs Search(Weight weight, Filter filter, int n);
+		public abstract Document Doc(int i);
+	    public abstract Document Doc(int docid, FieldSelector fieldSelector);
+		public abstract Query Rewrite(Query query);
+		public abstract Explanation Explain(Weight weight, int doc);
+		public abstract TopFieldDocs Search(Weight weight, Filter filter, int n, Sort sort);
 		/* End patch for GCJ bug #15411. */
-		public abstract Lucene.Net.Documents.Document Doc(int param1, Lucene.Net.Documents.FieldSelector param2);
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Search/Similarity.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/Similarity.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/Similarity.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/Similarity.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using System.Collections.Generic;
 using FieldInvertState = Lucene.Net.Index.FieldInvertState;
 using Term = Lucene.Net.Index.Term;
 using SmallFloat = Lucene.Net.Util.SmallFloat;
@@ -291,44 +291,11 @@ namespace Lucene.Net.Search
 	[Serializable]
 	public abstract class Similarity
 	{
-		public Similarity()
+	    protected Similarity()
 		{
 			InitBlock();
 		}
 		[Serializable]
-		private class AnonymousClassIDFExplanation:IDFExplanation
-		{
-			public AnonymousClassIDFExplanation(float idf, Similarity enclosingInstance)
-			{
-				InitBlock(idf, enclosingInstance);
-			}
-			private void  InitBlock(float idf, Similarity enclosingInstance)
-			{
-				this.idf = idf;
-				this.enclosingInstance = enclosingInstance;
-			}
-			private float idf;
-			private Similarity enclosingInstance;
-			public Similarity Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			//@Override
-			public override float GetIdf()
-			{
-				return idf;
-			}
-			//@Override
-			public override System.String Explain()
-			{
-				return "Inexplicable";
-			}
-		}
-		[Serializable]
 		private class AnonymousClassIDFExplanation1:IDFExplanation
 		{
 			public AnonymousClassIDFExplanation1(int df, int max, float idf, Similarity enclosingInstance)
@@ -366,39 +333,6 @@ namespace Lucene.Net.Search
 			}
 		}
 		[Serializable]
-		private class AnonymousClassIDFExplanation2:IDFExplanation
-		{
-			public AnonymousClassIDFExplanation2(float idf, Similarity enclosingInstance)
-			{
-				InitBlock(idf, enclosingInstance);
-			}
-			private void  InitBlock(float idf, Similarity enclosingInstance)
-			{
-				this.idf = idf;
-				this.enclosingInstance = enclosingInstance;
-			}
-			private float idf;
-			private Similarity enclosingInstance;
-			public Similarity Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			//@Override
-			public override float GetIdf()
-			{
-				return idf;
-			}
-			//@Override
-			public override System.String Explain()
-			{
-				return "Inexplicable";
-			}
-		}
-		[Serializable]
 		private class AnonymousClassIDFExplanation3:IDFExplanation
 		{
 			public AnonymousClassIDFExplanation3(float fIdf, System.Text.StringBuilder exp, Similarity enclosingInstance)
@@ -435,9 +369,11 @@ namespace Lucene.Net.Search
 		}
 		private void  InitBlock()
 		{
-			SupportedMethods = GetSupportedMethods(this.GetType());
+			
 		}
-		
+
+        /// <summary>The Similarity implementation used by default.</summary>
+        private static Similarity defaultImpl = new DefaultSimilarity();
 		public const int NO_DOC_ID_PROVIDED = - 1;
 		
 		/// <summary>Set the default Similarity implementation used by indexing and search
@@ -579,7 +515,7 @@ namespace Lucene.Net.Search
 		
 		
 		/// <summary>Computes a score factor based on a term or phrase's frequency in a
-		/// document.  This value is multiplied by the <see cref="Idf(Term, Searcher)" />
+		/// document.  This value is multiplied by the <see cref="Idf(int, int)" />
 		/// factor for each term in the query and these products are then summed to
 		/// form the initial score for a document.
 		/// 
@@ -619,7 +555,7 @@ namespace Lucene.Net.Search
 		public abstract float SloppyFreq(int distance);
 		
 		/// <summary>Computes a score factor based on a term or phrase's frequency in a
-		/// document.  This value is multiplied by the <see cref="Idf(Term, Searcher)" />
+		/// document.  This value is multiplied by the <see cref="Idf(int, int)" />
 		/// factor for each term in the query and these products are then summed to
 		/// form the initial score for a document.
 		/// 
@@ -635,32 +571,6 @@ namespace Lucene.Net.Search
 		/// </returns>
 		public abstract float Tf(float freq);
 		
-		/// <summary>Computes a score factor for a simple term.
-		/// 
-		/// <p/>The default implementation is: <c>
-		/// return idf(searcher.docFreq(term), searcher.maxDoc());
-		/// </c>
-		/// 
-		/// Note that <see cref="Searcher.MaxDoc()" /> is used instead of
-		/// <see cref="Lucene.Net.Index.IndexReader.NumDocs()" /> because it is proportional to
-		/// <see cref="Searcher.DocFreq(Term)" /> , i.e., when one is inaccurate,
-		/// so is the other, and in the same direction.
-		/// 
-		/// </summary>
-		/// <param name="term">the term in question
-		/// </param>
-		/// <param name="searcher">the document collection being searched
-		/// </param>
-		/// <returns> a score factor for the term
-		/// </returns>
-		/// <deprecated> see <see cref="IdfExplain(Term, Searcher)" />
-		/// </deprecated>
-        [Obsolete("see IdfExplain(Term, Searcher)")]
-		public virtual float Idf(Term term, Searcher searcher)
-		{
-			return Idf(searcher.DocFreq(term), searcher.MaxDoc());
-		}
-		
 		/// <summary> Computes a score factor for a simple term and returns an explanation
 		/// for that score factor.
 		/// 
@@ -687,43 +597,12 @@ namespace Lucene.Net.Search
 		/// <throws>  IOException </throws>
 		public virtual IDFExplanation IdfExplain(Term term, Searcher searcher)
 		{
-			if (SupportedMethods.overridesTermIDF)
-			{
-				float idf = Idf(term, searcher);
-				return new AnonymousClassIDFExplanation(idf, this);
-			}
 			int df = searcher.DocFreq(term);
 			int max = searcher.MaxDoc();
 			float idf2 = Idf(df, max);
 			return new AnonymousClassIDFExplanation1(df, max, idf2, this);
 		}
 		
-		/// <summary>Computes a score factor for a phrase.
-		/// 
-		/// <p/>The default implementation sums the <see cref="Idf(Term,Searcher)" /> factor
-		/// for each term in the phrase.
-		/// 
-		/// </summary>
-		/// <param name="terms">the terms in the phrase
-		/// </param>
-		/// <param name="searcher">the document collection being searched
-		/// </param>
-		/// <returns> idf score factor
-		/// </returns>
-		/// <deprecated> see <see cref="idfExplain(System.Collections.ICollection, Searcher)" />
-		/// </deprecated>
-        [Obsolete("see IdfExplain(Collection, Searcher)")]
-		public virtual float Idf(System.Collections.ICollection terms, Searcher searcher)
-		{
-			float idf = 0.0f;
-			System.Collections.IEnumerator i = terms.GetEnumerator();
-			while (i.MoveNext())
-			{
-				idf += Idf((Term) i.Current, searcher);
-			}
-			return idf;
-		}
-		
 		/// <summary> Computes a score factor for a phrase.
 		/// 
 		/// <p/>
@@ -740,13 +619,8 @@ namespace Lucene.Net.Search
 		/// for each term.
 		/// </returns>
 		/// <throws>  IOException </throws>
-		public virtual IDFExplanation idfExplain(System.Collections.ICollection terms, Searcher searcher)
+		public virtual IDFExplanation IdfExplain(ICollection<Term> terms, Searcher searcher)
 		{
-			if (SupportedMethods.overridesCollectionIDF)
-			{
-				float idf = Idf(terms, searcher);
-				return new AnonymousClassIDFExplanation2(idf, this);
-			}
 			int max = searcher.MaxDoc();
 			float idf2 = 0.0f;
 			System.Text.StringBuilder exp = new System.Text.StringBuilder();
@@ -799,36 +673,6 @@ namespace Lucene.Net.Search
 		public abstract float Coord(int overlap, int maxOverlap);
 		
 		
-		
-		
-		/// <summary> Calculate a scoring factor based on the data in the payload.  Overriding implementations
-		/// are responsible for interpreting what is in the payload.  Lucene makes no assumptions about
-		/// what is in the byte array.
-		/// <p/>
-		/// The default implementation returns 1.
-		/// 
-		/// </summary>
-		/// <param name="fieldName">The fieldName of the term this payload belongs to
-		/// </param>
-		/// <param name="payload">The payload byte array to be scored
-		/// </param>
-		/// <param name="offset">The offset into the payload array
-		/// </param>
-		/// <param name="length">The length in the array
-		/// </param>
-		/// <returns> An implementation dependent float to be used as a scoring factor
-		/// 
-		/// </returns>
-		/// <deprecated> See <see cref="ScorePayload(int, String, int, int, byte[], int, int)" />
-		/// </deprecated>
-		//TODO: When removing this, set the default value below to return 1.
-        [Obsolete("See ScorePayload(int, String, int, int, byte[], int, int)")]
-		public virtual float ScorePayload(System.String fieldName, byte[] payload, int offset, int length)
-		{
-			//Do nothing
-			return 1;
-		}
-		
 		/// <summary> Calculate a scoring factor based on the data in the payload.  Overriding implementations
 		/// are responsible for interpreting what is in the payload.  Lucene makes no assumptions about
 		/// what is in the byte array.
@@ -855,92 +699,9 @@ namespace Lucene.Net.Search
 		/// </returns>
 		public virtual float ScorePayload(int docId, System.String fieldName, int start, int end, byte[] payload, int offset, int length)
 		{
-			//TODO: When removing the deprecated scorePayload above, set this to return 1
-			return ScorePayload(fieldName, payload, offset, length);
-		}
-		
-		/// <deprecated> Remove this when old API is removed! 
-		/// </deprecated>
-        [Obsolete("Remove this when old API is removed! ")]
-		private MethodSupport SupportedMethods;
-		
-		/// <deprecated> Remove this when old API is removed! 
-		/// </deprecated>
-        [Obsolete("Remove this when old API is removed! ")]
-		[Serializable]
-		private sealed class MethodSupport
-		{
-			internal bool overridesCollectionIDF;
-			internal bool overridesTermIDF;
-			
-			internal MethodSupport(System.Type clazz)
-			{
-				overridesCollectionIDF = IsMethodOverridden(clazz, "Idf", C_IDF_METHOD_PARAMS);
-				overridesTermIDF = IsMethodOverridden(clazz, "Idf", T_IDF_METHOD_PARAMS);
-			}
-			
-			private static bool IsMethodOverridden(System.Type clazz, System.String name, System.Type[] params_Renamed)
-			{
-				try
-				{
-					return clazz.GetMethod(name, (params_Renamed == null)?new System.Type[0]:(System.Type[]) params_Renamed).DeclaringType != typeof(Similarity);
-				}
-				catch (System.MethodAccessException e)
-				{
-					// should not happen
-					throw new System.SystemException(e.Message, e);
-				}
-			}
-			/// <deprecated> Remove this when old API is removed! 
-			/// </deprecated>
-            [Obsolete("Remove this when old API is removed! ")]
-			private static readonly System.Type[] T_IDF_METHOD_PARAMS = new System.Type[]{typeof(Term), typeof(Searcher)};
-			
-			/// <deprecated> Remove this when old API is removed! 
-			/// </deprecated>
-            [Obsolete("Remove this when old API is removed! ")]
-			private static readonly System.Type[] C_IDF_METHOD_PARAMS = new System.Type[]{typeof(System.Collections.ICollection), typeof(Searcher)};
+		    return 1;
 		}
-		
-		/// <deprecated> Remove this when old API is removed! 
-		/// </deprecated>
-        [Obsolete("Remove this when old API is removed! ")]
-		private static readonly System.Collections.Hashtable knownMethodSupport = new System.Collections.Hashtable();
 
-        // {{Aroush-2.9 Port issue, need to mimic java's IdentityHashMap
-        /*
-         * From Java docs:
-         * This class implements the Map interface with a hash table, using 
-         * reference-equality in place of object-equality when comparing keys 
-         * (and values). In other words, in an IdentityHashMap, two keys k1 and k2 
-         * are considered equal if and only if (k1==k2). (In normal Map 
-         * implementations (like HashMap) two keys k1 and k2 are considered 
-         * equal if and only if (k1==null ? k2==null : k1.equals(k2)).) 
-         */
-        // Aroush-2.9}}
-		
-		/// <deprecated> Remove this when old API is removed! 
-		/// </deprecated>
-        [Obsolete("Remove this when old API is removed! ")]
-		private static MethodSupport GetSupportedMethods(System.Type clazz)
-		{
-			MethodSupport supportedMethods;
-			lock (knownMethodSupport)
-			{
-				supportedMethods = (MethodSupport) knownMethodSupport[clazz];
-				if (supportedMethods == null)
-				{
-					knownMethodSupport.Add(clazz, supportedMethods = new MethodSupport(clazz));
-				}
-			}
-			return supportedMethods;
-		}
-		
-		/// <summary>The Similarity implementation used by default. 
-		/// TODO: move back to top when old API is removed! 
-		/// 
-		/// </summary>
-		private static Similarity defaultImpl = new DefaultSimilarity();
 		static Similarity()
 		{
 			{

Modified: incubator/lucene.net/trunk/src/core/Search/SimilarityDelegator.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/SimilarityDelegator.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/SimilarityDelegator.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/SimilarityDelegator.cs Tue Feb 28 22:43:08 2012
@@ -21,7 +21,6 @@ using FieldInvertState = Lucene.Net.Inde
 
 namespace Lucene.Net.Search
 {
-	
 	/// <summary>Expert: Delegating scoring implementation.  Useful in <see cref="Query.GetSimilarity(Searcher)" />
 	/// implementations, to override only certain
 	/// methods of a Searcher's Similiarty implementation.. 
@@ -29,14 +28,10 @@ namespace Lucene.Net.Search
 	[Serializable]
 	public class SimilarityDelegator:Similarity
 	{
-		
 		private Similarity delegee;
 		
-		/// <summary>Construct a <see cref="Similarity" /> that delegates all methods to another.
-		/// 
-		/// </summary>
-		/// <param name="delegee">the Similarity implementation to delegate to
-		/// </param>
+		/// <summary>Construct a <see cref="Similarity" /> that delegates all methods to another.</summary>
+		/// <param name="delegee">the Similarity implementation to delegate to</param>
 		public SimilarityDelegator(Similarity delegee)
 		{
 			this.delegee = delegee;
@@ -77,10 +72,9 @@ namespace Lucene.Net.Search
 			return delegee.Coord(overlap, maxOverlap);
 		}
 
-        [Obsolete("Lucene.Net-2.9.1. This method overrides obsolete member Lucene.Net.Search.Similarity.ScorePayload(string, byte[], int, int)")]
-		public override float ScorePayload(System.String fieldName, byte[] payload, int offset, int length)
+        public override float ScorePayload(int docId, string fieldName, int start, int end, byte[] payload, int offset, int length)
 		{
-			return delegee.ScorePayload(fieldName, payload, offset, length);
+            return delegee.ScorePayload(docId, fieldName, start, end, payload, offset, length);
 		}
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/trunk/src/core/Search/SloppyPhraseScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/SloppyPhraseScorer.cs?rev=1294875&r1=1294874&r2=1294875&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/SloppyPhraseScorer.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/SloppyPhraseScorer.cs Tue Feb 28 22:43:08 2012
@@ -16,7 +16,8 @@
  */
 
 using System;
-
+using System.Linq;
+using Lucene.Net.Support;
 using TermPositions = Lucene.Net.Index.TermPositions;
 
 namespace Lucene.Net.Search
@@ -59,9 +60,9 @@ namespace Lucene.Net.Search
 			bool done = (end < 0);
 			while (!done)
 			{
-				PhrasePositions pp = (PhrasePositions) pq.Pop();
+				PhrasePositions pp = pq.Pop();
 				int start = pp.position;
-				int next = ((PhrasePositions) pq.Top()).position;
+				int next = pq.Top().position;
 				
 				bool tpsDiffer = true;
 				for (int pos = start; pos <= next || !tpsDiffer; pos = pp.position)
@@ -87,7 +88,7 @@ namespace Lucene.Net.Search
 				
 				if (pp.position > end)
 					end = pp.position;
-				pq.Put(pp); // restore pq
+				pq.Add(pp); // restore pq
 			}
 			
 			return freq;
@@ -101,17 +102,17 @@ namespace Lucene.Net.Search
 			int n = 0;
 			PhrasePositions pp3;
 			//pop until finding pp2
-			while ((pp3 = (PhrasePositions) pq.Pop()) != pp2)
+			while ((pp3 = pq.Pop()) != pp2)
 			{
 				tmpPos[n++] = pp3;
 			}
 			//insert back all but pp2
 			for (n--; n >= 0; n--)
 			{
-				pq.Insert(tmpPos[n]);
+				pq.InsertWithOverflow(tmpPos[n]);
 			}
 			//insert pp back
-			pq.Put(pp);
+			pq.Add(pp);
 			return pp2;
 		}
 		
@@ -143,7 +144,7 @@ namespace Lucene.Net.Search
 					pp.FirstPosition();
 					if (pp.position > end)
 						end = pp.position;
-					pq.Put(pp); // build pq from list
+					pq.Add(pp); // build pq from list
 				}
 				return end;
 			}
@@ -157,7 +158,7 @@ namespace Lucene.Net.Search
 			{
 				checkedRepeats = true;
 				// check for repeats
-				System.Collections.Hashtable m = null;
+				HashMap<PhrasePositions, object> m = null;
 				for (PhrasePositions pp = first; pp != null; pp = pp.next)
 				{
 					int tpPos = pp.position + pp.offset;
@@ -168,7 +169,7 @@ namespace Lucene.Net.Search
 						{
 							if (m == null)
 							{
-								m = new System.Collections.Hashtable();
+								m = new HashMap<PhrasePositions, object>();
 							}
 							pp.repeats = true;
 							pp2.repeats = true;
@@ -179,7 +180,7 @@ namespace Lucene.Net.Search
 				}
 				if (m != null)
 				{
-					repeats = (PhrasePositions[])(new System.Collections.ArrayList(m.Keys).ToArray(typeof(PhrasePositions)));
+					repeats = m.Keys.ToArray();
 				}
 			}
 			
@@ -205,7 +206,7 @@ namespace Lucene.Net.Search
 			{
 				if (pp.position > end)
 					end = pp.position;
-				pq.Put(pp); // build pq from list
+				pq.Add(pp); // build pq from list
 			}
 			
 			if (repeats != null)



Mime
View raw message