You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by cc...@apache.org on 2011/11/09 22:03:52 UTC

[Lucene.Net] svn commit: r1199962 [11/14] - in /incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk: src/core/ src/core/Analysis/ src/core/Analysis/Standard/ src/core/Document/ src/core/Index/ src/core/QueryParser/ src/core/Search/ src/core/Search/Function/ src/co...

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/IndexSearcher.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/IndexSearcher.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/IndexSearcher.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/IndexSearcher.cs Wed Nov  9 21:03:47 2011
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using System.Linq;
 using Document = Lucene.Net.Documents.Document;
 using FieldSelector = Lucene.Net.Documents.FieldSelector;
 using CorruptIndexException = Lucene.Net.Index.CorruptIndexException;
@@ -34,9 +34,6 @@ namespace Lucene.Net.Search
 	/// or <see cref="Searcher.Search(Query,Filter)" /> methods. For performance reasons it is 
 	/// recommended to open only one IndexSearcher and use it for all of your searches.
 	/// 
-	/// <p/>Note that you can only access Hits from an IndexSearcher as long as it is
-	/// not yet closed, otherwise an IOException will be thrown. 
-	/// 
 	/// <a name="thread-safety"></a><p/><b>NOTE</b>:
 	/// <see cref="IndexSearcher" /> instances are completely
 	/// thread safe, meaning multiple threads can call any of its
@@ -50,46 +47,18 @@ namespace Lucene.Net.Search
 	{
 		internal IndexReader reader;
 		private bool closeReader;
+
+        // NOTE: these members might change in incompatible ways
+        // in the next release
 		private IndexReader[] subReaders;
 		private int[] docStarts;
 		
-		/// <summary>Creates a searcher searching the index in the named directory.</summary>
-		/// <throws>  CorruptIndexException if the index is corrupt </throws>
-		/// <throws>  IOException if there is a low-level IO error </throws>
-		/// <deprecated> Use <see cref="IndexSearcher(Directory, bool)" /> instead
-		/// </deprecated>
-        [Obsolete("Use IndexSearcher(Directory, bool) instead")]
-		public IndexSearcher(System.String path):this(IndexReader.Open(path), true)
-		{
-		}
-		
 		/// <summary>Creates a searcher searching the index in the named
-		/// directory.  You should pass readOnly=true, since it
-		/// gives much better concurrent performance, unless you
-		/// intend to do write operations (delete documents or
-		/// change norms) with the underlying IndexReader.
-		/// </summary>
-		/// <param name="path">directory where IndexReader will be opened
-		/// </param>
-		/// <param name="readOnly">if true, the underlying IndexReader
-		/// will be opened readOnly
-		/// </param>
-		/// <throws>  CorruptIndexException if the index is corrupt </throws>
-		/// <throws>  IOException if there is a low-level IO error </throws>
-		/// <deprecated> Use <see cref="IndexSearcher(Directory, bool)" /> instead
-		/// </deprecated>
-        [Obsolete("Use IndexSearcher(Directory, bool) instead")]
-		public IndexSearcher(System.String path, bool readOnly):this(IndexReader.Open(path, readOnly), true)
-		{
-		}
-		
-		/// <summary>Creates a searcher searching the index in the provided directory.</summary>
-		/// <throws>  CorruptIndexException if the index is corrupt </throws>
-		/// <throws>  IOException if there is a low-level IO error </throws>
-		/// <deprecated> Use <see cref="IndexSearcher(Directory, bool)" /> instead
-		/// </deprecated>
-        [Obsolete("Use IndexSearcher(Directory, bool) instead")]
-		public IndexSearcher(Directory directory):this(IndexReader.Open(directory), true)
+		/// directory, with readOnly=true</summary>
+		/// <throws>CorruptIndexException if the index is corrupt</throws>
+		/// <throws>IOException if there is a low-level IO error</throws>
+        public IndexSearcher(Directory path)
+            : this(IndexReader.Open(path), true)
 		{
 		}
 		
@@ -115,14 +84,30 @@ namespace Lucene.Net.Search
 		{
 		}
 		
+        /// <summary>
+        /// Expert: directly specify the reader, subReaders and their
+        /// DocID starts
+        /// <p/>
+        /// <b>NOTE:</b> This API is experimental and
+        /// might change in incompatible ways in the next
+        /// release<p/>
+        /// </summary>
+        public IndexSearcher(IndexReader reader, IndexReader[] subReaders, int[] docStarts)
+        {
+            this.reader = reader;
+            this.subReaders = subReaders;
+            this.docStarts = docStarts;
+            this.closeReader = false;
+        }
+
 		private IndexSearcher(IndexReader r, bool closeReader)
 		{
 			reader = r;
 			this.closeReader = closeReader;
-			
-			System.Collections.IList subReadersList = new System.Collections.ArrayList();
+
+		    System.Collections.Generic.IList<IndexReader> subReadersList = new System.Collections.Generic.List<IndexReader>();
 			GatherSubReaders(subReadersList, reader);
-            subReaders = (IndexReader[])new System.Collections.ArrayList(subReadersList).ToArray(typeof(IndexReader));
+            subReaders = subReadersList.ToArray();
 			docStarts = new int[subReaders.Length];
 			int maxDoc = 0;
 			for (int i = 0; i < subReaders.Length; i++)
@@ -132,7 +117,7 @@ namespace Lucene.Net.Search
 			}
 		}
 		
-		protected internal virtual void  GatherSubReaders(System.Collections.IList allSubReaders, IndexReader r)
+		protected internal virtual void  GatherSubReaders(System.Collections.Generic.IList<IndexReader> allSubReaders, IndexReader r)
 		{
 			ReaderUtil.GatherSubReaders(allSubReaders, r);
 		}
@@ -208,8 +193,7 @@ namespace Lucene.Net.Search
 		
 		/// <summary> Just like <see cref="Search(Weight, Filter, int, Sort)" />, but you choose
 		/// whether or not the fields in the returned <see cref="FieldDoc" /> instances
-		/// should be set by specifying fillFields.<br/>
-		/// 
+		/// should be set by specifying fillFields.
 		/// <p/>
 		/// NOTE: this does not compute scores by default. If you need scores, create
 		/// a <see cref="TopFieldCollector" /> instance by calling
@@ -221,54 +205,6 @@ namespace Lucene.Net.Search
 		{
             nDocs = Math.Min(nDocs, reader.MaxDoc());
 
-			SortField[] fields = sort.fields;
-			bool legacy = false;
-			for (int i = 0; i < fields.Length; i++)
-			{
-				SortField field = fields[i];
-				System.String fieldname = field.GetField();
-				int type = field.GetType();
-				// Resolve AUTO into its true type
-				if (type == SortField.AUTO)
-				{
-					int autotype = SortField.DetectFieldType(reader, fieldname);
-					if (autotype == SortField.STRING)
-					{
-						fields[i] = new SortField(fieldname, field.GetLocale(), field.GetReverse());
-					}
-					else
-					{
-						fields[i] = new SortField(fieldname, autotype, field.GetReverse());
-					}
-				}
-				
-				if (field.GetUseLegacySearch())
-				{
-					legacy = true;
-				}
-			}
-			
-			if (legacy)
-			{
-				// Search the single top-level reader
-				TopDocCollector collector = new TopFieldDocCollector(reader, sort, nDocs);
-				HitCollectorWrapper hcw = new HitCollectorWrapper(collector);
-				hcw.SetNextReader(reader, 0);
-				if (filter == null)
-				{
-					Scorer scorer = weight.Scorer(reader, true, true);
-					if (scorer != null)
-					{
-						scorer.Score(hcw);
-					}
-				}
-				else
-				{
-					SearchWithFilter(reader, weight, filter, hcw);
-				}
-				return (TopFieldDocs) collector.TopDocs();
-			}
-			
 			TopFieldCollector collector2 = TopFieldCollector.create(sort, nDocs, fillFields, fieldSortDoTrackScores, fieldSortDoMaxScore, !weight.ScoresDocsOutOfOrder());
 			Search(weight, filter, collector2);
 			return (TopFieldDocs) collector2.TopDocs();

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MatchAllDocsQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MatchAllDocsQuery.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MatchAllDocsQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MatchAllDocsQuery.cs Wed Nov  9 21:03:47 2011
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using Lucene.Net.Index;
 using IndexReader = Lucene.Net.Index.IndexReader;
 using TermDocs = Lucene.Net.Index.TermDocs;
 using ToStringUtils = Lucene.Net.Util.ToStringUtils;
@@ -72,32 +72,11 @@ namespace Lucene.Net.Search
 				this.norms = norms;
 			}
 			
-			public override Explanation Explain(int doc)
-			{
-				return null; // not called... see MatchAllDocsWeight.explain()
-			}
-			
-			/// <deprecated> use <see cref="DocID()" /> instead. 
-			/// </deprecated>
-            [Obsolete("use DocID() instead.")]
-			public override int Doc()
-			{
-				return termDocs.Doc();
-			}
-			
 			public override int DocID()
 			{
 				return 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()
 			{
 				return doc = termDocs.Next()?termDocs.Doc():NO_MORE_DOCS;
@@ -108,14 +87,6 @@ namespace Lucene.Net.Search
 				return norms == null?score:score * Similarity.DecodeNorm(norms[DocID()]);
 			}
 			
-			/// <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)
 			{
 				return doc = termDocs.SkipTo(target)?termDocs.Doc():NO_MORE_DOCS;
@@ -199,7 +170,7 @@ namespace Lucene.Net.Search
 			return new MatchAllDocsWeight(this, searcher);
 		}
 		
-		public override void  ExtractTerms(System.Collections.Hashtable terms)
+		public override void  ExtractTerms(System.Collections.Generic.ISet<Term> terms)
 		{
 		}
 		

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiPhraseQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiPhraseQuery.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiPhraseQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiPhraseQuery.cs Wed Nov  9 21:03:47 2011
@@ -40,8 +40,8 @@ namespace Lucene.Net.Search
 	public class MultiPhraseQuery:Query
 	{
 		private System.String field;
-		private System.Collections.ArrayList termArrays = new System.Collections.ArrayList();
-		private System.Collections.ArrayList positions = new System.Collections.ArrayList();
+        private System.Collections.Generic.List<Term[]> termArrays = new System.Collections.Generic.List<Term[]>();
+        private System.Collections.Generic.List<int> positions = new System.Collections.Generic.List<int>();
 		
 		private int slop = 0;
 		
@@ -79,7 +79,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(terms, position);
 		}
@@ -107,36 +107,32 @@ namespace Lucene.Net.Search
 			}
 			
 			termArrays.Add(terms);
-			positions.Add((System.Int32) position);
+			positions.Add(position);
 		}
 
         /// <summary> Returns a List&lt;Term[]&gt; of the terms in the multiphrase.
 		/// Do not modify the List or its contents.
 		/// </summary>
-		public virtual System.Collections.IList GetTermArrays()
-		{
-			return (System.Collections.IList) System.Collections.ArrayList.ReadOnly(new System.Collections.ArrayList(termArrays));
-		}
+		public virtual System.Collections.Generic.IList<Term[]> GetTermArrays()
+        {
+            return termArrays.AsReadOnly();
+        }
 		
 		/// <summary> Returns the relative positions of terms in this phrase.</summary>
 		public virtual int[] GetPositions()
 		{
 			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;
 		}
 		
 		// inherit javadoc
-		public override void  ExtractTerms(System.Collections.Hashtable terms)
+		public override void ExtractTerms(System.Collections.Generic.ISet<Term> terms)
 		{
-			for (System.Collections.IEnumerator iter = termArrays.GetEnumerator(); iter.MoveNext(); )
+			foreach(Term[] arr in termArrays)
 			{
-				Term[] arr = (Term[]) iter.Current;
-				for (int i = 0; i < arr.Length; i++)
-				{
-					SupportClass.CollectionsHelper.AddIfNotContains(terms, arr[i]);
-				}
+			    terms.UnionWith(arr);
 			}
 		}
 		
@@ -169,15 +165,14 @@ namespace Lucene.Net.Search
 				this.similarity = Enclosing_Instance.GetSimilarity(searcher);
 				
 				// compute idf
-				System.Collections.IEnumerator i = Enclosing_Instance.termArrays.GetEnumerator();
-				while (i.MoveNext())
-				{
-					Term[] terms = (Term[]) i.Current;
-					for (int j = 0; j < terms.Length; j++)
-					{
-						idf += Enclosing_Instance.GetSimilarity(searcher).Idf(terms[j], searcher);
-					}
-				}
+			    int maxDoc = searcher.MaxDoc();
+                foreach (Term[] terms in enclosingInstance.termArrays)
+                {
+                    foreach (Term term in terms)
+                    {
+                        idf += similarity.Idf(searcher.DocFreq(term), maxDoc);
+                    }
+                }
 			}
 			
 			public override Query GetQuery()
@@ -211,7 +206,7 @@ namespace Lucene.Net.Search
 				TermPositions[] tps = new TermPositions[Enclosing_Instance.termArrays.Count];
 				for (int i = 0; i < tps.Length; i++)
 				{
-					Term[] terms = (Term[]) Enclosing_Instance.termArrays[i];
+					Term[] terms = Enclosing_Instance.termArrays[i];
 					
 					TermPositions p;
 					if (terms.Length > 1)
@@ -258,14 +253,18 @@ namespace Lucene.Net.Search
 				// explain field weight
 				ComplexExplanation fieldExpl = new ComplexExplanation();
 				fieldExpl.SetDescription("fieldWeight(" + GetQuery() + " 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.SetValue(similarity.Tf(phraseFreq));
+                tfExplanation.SetDescription("tf(phraseFreq=" + phraseFreq + ")");
+                fieldExpl.AddDetail(tfExplanation);
 				fieldExpl.AddDetail(idfExpl);
 				
 				Explanation fieldNormExpl = new Explanation();
@@ -275,8 +274,8 @@ namespace Lucene.Net.Search
 				fieldNormExpl.SetDescription("fieldNorm(field=" + Enclosing_Instance.field + ", doc=" + doc + ")");
 				fieldExpl.AddDetail(fieldNormExpl);
 				
-				fieldExpl.SetMatch(tfExpl.IsMatch());
-				fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());
+				fieldExpl.SetMatch(tfExplanation.IsMatch());
+                fieldExpl.SetValue(tfExplanation.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());
 				
 				result.AddDetail(fieldExpl);
 				System.Boolean? tempAux = fieldExpl.GetMatch();
@@ -297,7 +296,7 @@ namespace Lucene.Net.Search
 			if (termArrays.Count == 1)
 			{
 				// optimize one-term case
-				Term[] terms = (Term[]) termArrays[0];
+				Term[] terms = termArrays[0];
 				BooleanQuery boq = new BooleanQuery(true);
 				for (int i = 0; i < terms.Length; i++)
 				{
@@ -328,7 +327,7 @@ namespace Lucene.Net.Search
 			}
 			
 			buffer.Append("\"");
-			System.Collections.IEnumerator i = termArrays.GetEnumerator();
+			System.Collections.Generic.IEnumerator<Term[]> i = termArrays.GetEnumerator();
             bool first = true;
 			while (i.MoveNext())
 			{
@@ -341,7 +340,7 @@ namespace Lucene.Net.Search
                     buffer.Append(" ");
                 }
 
-				Term[] terms = (Term[]) i.Current;
+				Term[] terms = i.Current;
 				if (terms.Length > 1)
 				{
 					buffer.Append("(");
@@ -430,11 +429,10 @@ namespace Lucene.Net.Search
 		private int TermArraysHashCode()
 		{
 			int hashCode = 1;
-			System.Collections.IEnumerator iterator = termArrays.GetEnumerator();
-			while (iterator.MoveNext())
+			foreach(Term[] termArray in termArrays)
 			{
-				Term[] termArray = (Term[]) iterator.Current;
-				hashCode = 31 * hashCode + (termArray == null?0:ArraysHashCode(termArray));
+                // Java uses Arrays.hashCode(termArray)
+			    hashCode = 31*hashCode + (termArray == null ? 0 : ArraysHashCode(termArray));
 			}
 			return hashCode;
 		}
@@ -456,18 +454,18 @@ namespace Lucene.Net.Search
 		}
 		
 		// Breakout calculation of the termArrays equals
-		private bool TermArraysEquals(System.Collections.IList termArrays1, System.Collections.IList termArrays2)
+        private bool TermArraysEquals(System.Collections.Generic.List<Term[]> termArrays1, System.Collections.Generic.List<Term[]> termArrays2)
 		{
 			if (termArrays1.Count != termArrays2.Count)
 			{
 				return false;
 			}
-			System.Collections.IEnumerator iterator1 = termArrays1.GetEnumerator();
-			System.Collections.IEnumerator iterator2 = termArrays2.GetEnumerator();
+			var iterator1 = termArrays1.GetEnumerator();
+			var iterator2 = termArrays2.GetEnumerator();
 			while (iterator1.MoveNext())
 			{
-				Term[] termArray1 = (Term[]) iterator1.Current;
-				Term[] termArray2 = (Term[]) iterator2.Current;
+				Term[] termArray1 = iterator1.Current;
+				Term[] termArray2 = iterator2.Current;
 				if (!(termArray1 == null ? termArray2 == null : TermEquals(termArray1, termArray2)))
 				{
 					return false;

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiTermQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiTermQuery.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiTermQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiTermQuery.cs Wed Nov  9 21:03:47 2011
@@ -401,16 +401,6 @@ namespace Lucene.Net.Search
 		{
 		}
 		
-		/// <summary> Returns the pattern term.</summary>
-		/// <deprecated> check sub class for possible term access - getTerm does not
-		/// make sense for all MultiTermQuerys and will be removed.
-		/// </deprecated>
-        [Obsolete("check sub class for possible term access - getTerm does not make sense for all MultiTermQuerys and will be removed.")]
-		public virtual Term GetTerm()
-		{
-			return term;
-		}
-		
 		/// <summary>Construct the enumeration to be used, expanding the pattern term. </summary>
 		public /*protected internal*/ abstract FilteredTermEnum GetEnum(IndexReader reader);
 		

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ParallelMultiSearcher.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ParallelMultiSearcher.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ParallelMultiSearcher.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ParallelMultiSearcher.cs Wed Nov  9 21:03:47 2011
@@ -16,18 +16,17 @@
  */
 
 using System;
-
+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
 	{
@@ -147,7 +146,7 @@ namespace Lucene.Net.Search
 		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);
+			FieldDocSortedHitQueue hq = new FieldDocSortedHitQueue(nDocs);
 			int totalHits = 0;
 			MultiSearcherThread[] msta = new MultiSearcherThread[searchables.Length];
 			for (int i = 0; i < searchables.Length; i++)
@@ -189,7 +188,7 @@ namespace Lucene.Net.Search
 			ScoreDoc[] scoreDocs = new ScoreDoc[hq.Size()];
 			for (int i = hq.Size() - 1; i >= 0; i--)
 			// put docs in array
-				scoreDocs[i] = (ScoreDoc) hq.Pop();
+				scoreDocs[i] = hq.Pop();
 			
 			return new TopFieldDocs(totalHits, scoreDocs, hq.GetFields(), maxScore);
 		}
@@ -245,7 +244,7 @@ namespace Lucene.Net.Search
 		private int nDocs;
 		private TopDocs docs;
 		private int i;
-		private PriorityQueue hq;
+        private HitQueue hq;
 		private int[] starts;
 		private System.Exception ioe;
 		private Sort sort;

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Payloads/PayloadSpanUtil.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Payloads/PayloadSpanUtil.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Payloads/PayloadSpanUtil.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Payloads/PayloadSpanUtil.cs Wed Nov  9 21:03:47 2011
@@ -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;
@@ -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/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseQuery.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseQuery.cs Wed Nov  9 21:03:47 2011
@@ -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;
 		}
 		
@@ -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;
@@ -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());
 				}
@@ -245,13 +245,18 @@ namespace Lucene.Net.Search
 				Explanation fieldExpl = new Explanation();
 				fieldExpl.SetDescription("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.SetValue(similarity.Tf(phraseFreq));
+                tfExplanation.SetDescription("tf(phraseFreq=" + phraseFreq + ")");
+
+                fieldExpl.AddDetail(tfExplanation);
 				fieldExpl.AddDetail(idfExpl);
 				
 				Explanation fieldNormExpl = new Explanation();
@@ -260,8 +265,8 @@ namespace Lucene.Net.Search
 				fieldNormExpl.SetValue(fieldNorm);
 				fieldNormExpl.SetDescription("fieldNorm(field=" + Enclosing_Instance.field + ", doc=" + doc + ")");
 				fieldExpl.AddDetail(fieldNormExpl);
-				
-				fieldExpl.SetValue(tfExpl.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());
+
+                fieldExpl.SetValue(tfExplanation.GetValue() * idfExpl.GetValue() * fieldNormExpl.GetValue());
 				
 				result.AddDetail(fieldExpl);
 				
@@ -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/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseQueue.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseQueue.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseQueue.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseQueue.cs Wed Nov  9 21:03:47 2011
@@ -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/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseScorer.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseScorer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PhraseScorer.cs Wed Nov  9 21:03:47 2011
@@ -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;
@@ -174,6 +150,14 @@ namespace Lucene.Net.Search
 			return first.doc;
 		}
 		
+        /// <summary>
+        /// phrase frequency in current doc as computed by phraseFreq().
+        /// </summary>
+        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 +194,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

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Query.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Query.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Query.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Query.cs Wed Nov  9 21:03:47 2011
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using Lucene.Net.Index;
 using IndexReader = Lucene.Net.Index.IndexReader;
 
 namespace Lucene.Net.Search
@@ -134,7 +134,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 +155,26 @@ namespace Lucene.Net.Search
 				{
 					for (int j = 0; j < clauses.Length; j++)
 					{
-						SupportClass.CollectionsHelper.AddIfNotContains(uniques, clauses[j].GetQuery());
+					    uniques.Add(clauses[j].GetQuery());
 					}
 				}
 				else
 				{
-					SupportClass.CollectionsHelper.AddIfNotContains(uniques, query);
+				    uniques.Add(query);
 				}
 			}
 			// optimization: if we have just one query, just return it
 			if (uniques.Count == 1)
 			{
-                foreach (object key in uniques.Keys)
+                foreach (Query key in uniques)
                 {
-                    return (Query) key;
+                    return key;
                 }
 			}
 			BooleanQuery result = new BooleanQuery(true);
-            foreach (object key in uniques.Keys)
+            foreach (Query key in uniques)
             {
-                result.Add((Query) key, BooleanClause.Occur.SHOULD);
+                result.Add(key, BooleanClause.Occur.SHOULD);
             }
 			return result;
 		}
@@ -185,7 +185,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 +198,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/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ReqExclScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ReqExclScorer.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ReqExclScorer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ReqExclScorer.cs Wed Nov  9 21:03:47 2011
@@ -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/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ReqOptSumScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ReqOptSumScorer.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ReqOptSumScorer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ReqOptSumScorer.cs Wed Nov  9 21:03:47 2011
@@ -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/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ScoreCachingWrappingScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ScoreCachingWrappingScorer.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ScoreCachingWrappingScorer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/ScoreCachingWrappingScorer.cs Wed Nov  9 21:03:47 2011
@@ -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/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Similarity.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Similarity.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Similarity.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Similarity.cs Wed Nov  9 21:03:47 2011
@@ -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;
@@ -296,39 +296,6 @@ namespace Lucene.Net.Search
 			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/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SimilarityDelegator.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SimilarityDelegator.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SimilarityDelegator.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SimilarityDelegator.cs Wed Nov  9 21:03:47 2011
@@ -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;
@@ -78,9 +73,9 @@ namespace Lucene.Net.Search
 		}
 
         [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

Added: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SingleTermEnum.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SingleTermEnum.cs?rev=1199962&view=auto
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SingleTermEnum.cs (added)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SingleTermEnum.cs Wed Nov  9 21:03:47 2011
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using Lucene.Net.Index;
+
+namespace Lucene.Net.Search
+{
+    /// <summary>
+    /// Subclass of FilteredTermEnum for enumerating a single term.
+    /// <p/>
+    /// This can be used by <see cref="MultiTermQuery"/>s that need only visit one term,
+    /// but want to preserve MultiTermQuery semantics such as
+    /// <see cref="MultiTermQuery.RewriteMethod"/>.
+    /// </summary>
+    public class SingleTermEnum : FilteredTermEnum
+    {
+        private Term singleTerm;
+        private bool _endEnum = false;
+
+        /// <summary>
+        /// Creates a new <code>SingleTermEnum</code>.
+        /// <p/>
+        /// After calling the constructor the enumeration is already pointing to the term,
+        ///  if it exists.
+        /// </summary>
+        public SingleTermEnum(IndexReader reader, Term singleTerm)
+        {
+            this.singleTerm = singleTerm;
+            SetEnum(reader.Terms(singleTerm));
+        }
+
+        public override float Difference()
+        {
+            return 1.0F;
+        }
+
+        public override bool EndEnum()
+        {
+            return _endEnum;
+        }
+
+        public override bool TermCompare(Term term)
+        {
+            if (term.Equals(singleTerm))
+            {
+                return true;
+            }
+            else
+            {
+                _endEnum = true;
+                return false;
+            }
+        }
+    }
+}

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SloppyPhraseScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SloppyPhraseScorer.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SloppyPhraseScorer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/SloppyPhraseScorer.cs Wed Nov  9 21:03:47 2011
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using System.Linq;
 using TermPositions = Lucene.Net.Index.TermPositions;
 
 namespace Lucene.Net.Search
@@ -59,9 +59,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 +87,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 +101,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 +143,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 +157,7 @@ namespace Lucene.Net.Search
 			{
 				checkedRepeats = true;
 				// check for repeats
-				System.Collections.Hashtable m = null;
+				SupportClass.HashMap<PhrasePositions, object> m = null;
 				for (PhrasePositions pp = first; pp != null; pp = pp.next)
 				{
 					int tpPos = pp.position + pp.offset;
@@ -168,7 +168,7 @@ namespace Lucene.Net.Search
 						{
 							if (m == null)
 							{
-								m = new System.Collections.Hashtable();
+								m = new SupportClass.HashMap<PhrasePositions, object>();
 							}
 							pp.repeats = true;
 							pp2.repeats = true;
@@ -179,7 +179,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 +205,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)

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/FieldMaskingSpanQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/FieldMaskingSpanQuery.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/FieldMaskingSpanQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/FieldMaskingSpanQuery.cs Wed Nov  9 21:03:47 2011
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using Lucene.Net.Index;
 using IndexReader = Lucene.Net.Index.IndexReader;
 using ToStringUtils = Lucene.Net.Util.ToStringUtils;
 using Query = Lucene.Net.Search.Query;
@@ -98,15 +98,7 @@ namespace Lucene.Net.Search.Spans
 			return maskedQuery.GetSpans(reader);
 		}
 		
-		/// <deprecated> use <see cref="ExtractTerms(System.Collections.Hashtable)" /> instead. 
-		/// </deprecated>
-        [Obsolete("use ExtractTerms(Hashtable) instead.")]
-		public override System.Collections.ICollection GetTerms()
-		{
-			return maskedQuery.GetTerms();
-		}
-		
-		public override void  ExtractTerms(System.Collections.Hashtable terms)
+		public override void  ExtractTerms(System.Collections.Generic.ISet<Term> terms)
 		{
 			maskedQuery.ExtractTerms(terms);
 		}

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/NearSpansUnordered.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/NearSpansUnordered.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/NearSpansUnordered.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/NearSpansUnordered.cs Wed Nov  9 21:03:47 2011
@@ -16,9 +16,8 @@
  */
 
 using System;
-
+using Lucene.Net.Util;
 using IndexReader = Lucene.Net.Index.IndexReader;
-using PriorityQueue = Lucene.Net.Util.PriorityQueue;
 
 namespace Lucene.Net.Search.Spans
 {
@@ -28,11 +27,11 @@ namespace Lucene.Net.Search.Spans
 	/// Expert:
 	/// Only public for subclassing.  Most implementations should not need this class
 	/// </summary>
-	public class NearSpansUnordered:Spans
+	public class NearSpansUnordered : Spans
 	{
 		private SpanNearQuery query;
 		
-		private System.Collections.IList ordered = new System.Collections.ArrayList(); // spans in query order
+		private System.Collections.Generic.IList<SpansCell> ordered = new System.Collections.Generic.List<SpansCell>(); // spans in query order
 		private Spans[] subSpans;
 		private int slop; // from query
 		
@@ -47,7 +46,7 @@ namespace Lucene.Net.Search.Spans
 		private bool more = true; // true iff not done
 		private bool firstTime = true; // true before first next()
 		
-		private class CellQueue:PriorityQueue
+		private class CellQueue : PriorityQueue<SpansCell>
 		{
 			private void  InitBlock(NearSpansUnordered enclosingInstance)
 			{
@@ -67,11 +66,9 @@ namespace Lucene.Net.Search.Spans
 				InitBlock(enclosingInstance);
 				Initialize(size);
 			}
-			
-			public override bool LessThan(System.Object o1, System.Object o2)
+
+            public override bool LessThan(SpansCell spans1, SpansCell spans2)
 			{
-				SpansCell spans1 = (SpansCell) o1;
-				SpansCell spans2 = (SpansCell) o2;
 				if (spans1.Doc() == spans2.Doc())
 				{
 					return NearSpansOrdered.DocSpansOrdered(spans1, spans2);
@@ -205,7 +202,7 @@ namespace Lucene.Net.Search.Spans
 				if (Min().Next())
 				{
 					// trigger further scanning
-					queue.AdjustTop(); // maintain queue
+					queue.UpdateTop(); // maintain queue
 				}
 				else
 				{
@@ -254,7 +251,7 @@ namespace Lucene.Net.Search.Spans
 				more = Min().Next();
 				if (more)
 				{
-					queue.AdjustTop(); // maintain queue
+					queue.UpdateTop(); // maintain queue
 				}
 			}
 			return false; // no more matches
@@ -284,7 +281,7 @@ namespace Lucene.Net.Search.Spans
 					// skip as needed
 					if (Min().SkipTo(target))
 					{
-						queue.AdjustTop();
+						queue.UpdateTop();
 					}
 					else
 					{
@@ -297,7 +294,7 @@ namespace Lucene.Net.Search.Spans
 		
 		private SpansCell Min()
 		{
-			return (SpansCell) queue.Top();
+			return queue.Top();
 		}
 		
 		public override int Doc()
@@ -320,23 +317,15 @@ namespace Lucene.Net.Search.Spans
 		/// <throws>  IOException </throws>
 		public override System.Collections.Generic.ICollection<byte[]> GetPayload()
 		{
-            //mgarski: faking out another HashSet<T>...
-			System.Collections.Generic.Dictionary<byte[], byte[]> matchPayload = new System.Collections.Generic.Dictionary<byte[], byte[]>(); 
+			System.Collections.Generic.ISet<byte[]> matchPayload = new System.Collections.Generic.HashSet<byte[]>(); 
 			for (SpansCell cell = first; cell != null; cell = cell.next)
 			{
 				if (cell.IsPayloadAvailable())
 				{
-                    System.Collections.Generic.ICollection<byte[]> cellPayload = cell.GetPayload();
-                    foreach (byte[] val in cellPayload)
-                    {
-                        if (!matchPayload.ContainsKey(val))
-                        {
-                            matchPayload.Add(val, val);
-                        }
-                    }
+                    matchPayload.UnionWith(cell.GetPayload());
 				}
 			}
-			return matchPayload.Keys;
+			return matchPayload;
 		}
 		
 		// TODO: Remove warning after API has been finalized
@@ -364,7 +353,7 @@ namespace Lucene.Net.Search.Spans
 		{
 			for (int i = 0; more && i < ordered.Count; i++)
 			{
-				SpansCell cell = (SpansCell) ordered[i];
+				SpansCell cell = ordered[i];
 				if (next)
 					more = cell.Next(); // move to first entry
 				if (more)
@@ -400,7 +389,7 @@ namespace Lucene.Net.Search.Spans
 			last = first = null;
 			while (queue.Top() != null)
 			{
-				AddToList((SpansCell) queue.Pop());
+				AddToList(queue.Pop());
 			}
 		}
 		
@@ -409,7 +398,7 @@ namespace Lucene.Net.Search.Spans
 			queue.Clear(); // rebuild queue
 			for (SpansCell cell = first; cell != null; cell = cell.next)
 			{
-				queue.Put(cell); // add to queue from list
+				queue.Add(cell); // add to queue from list
 			}
 		}
 		

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanFirstQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanFirstQuery.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanFirstQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanFirstQuery.cs Wed Nov  9 21:03:47 2011
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using Lucene.Net.Index;
 using IndexReader = Lucene.Net.Index.IndexReader;
 using ToStringUtils = Lucene.Net.Util.ToStringUtils;
 using Query = Lucene.Net.Search.Query;
@@ -26,7 +26,7 @@ namespace Lucene.Net.Search.Spans
 	
 	/// <summary>Matches spans near the beginning of a field. </summary>
 	[Serializable]
-	public class SpanFirstQuery:SpanQuery, System.ICloneable
+	public class SpanFirstQuery : SpanQuery, System.ICloneable
 	{
 		private class AnonymousClassSpans : Spans
 		{
@@ -135,17 +135,6 @@ namespace Lucene.Net.Search.Spans
 			return match.GetField();
 		}
 		
-		/// <summary>Returns a collection of all terms matched by this query.</summary>
-		/// <deprecated> use extractTerms instead
-		/// </deprecated>
-        /// <seealso cref="ExtractTerms(System.Collections.Hashtable)">
-		/// </seealso>
-        [Obsolete("use ExtractTerms instead")]
-		public override System.Collections.ICollection GetTerms()
-		{
-			return match.GetTerms();
-		}
-		
 		public override System.String ToString(System.String field)
 		{
 			System.Text.StringBuilder buffer = new System.Text.StringBuilder();
@@ -165,7 +154,7 @@ namespace Lucene.Net.Search.Spans
 			return spanFirstQuery;
 		}
 		
-		public override void  ExtractTerms(System.Collections.Hashtable terms)
+		public override void  ExtractTerms(System.Collections.Generic.ISet<Term> terms)
 		{
 			match.ExtractTerms(terms);
 		}

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNearQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNearQuery.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNearQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNearQuery.cs Wed Nov  9 21:03:47 2011
@@ -16,7 +16,8 @@
  */
 
 using System;
-
+using System.Linq;
+using Lucene.Net.Index;
 using IndexReader = Lucene.Net.Index.IndexReader;
 using ToStringUtils = Lucene.Net.Util.ToStringUtils;
 using Query = Lucene.Net.Search.Query;
@@ -29,9 +30,9 @@ namespace Lucene.Net.Search.Spans
 	/// matches are required to be in-order. 
 	/// </summary>
 	[Serializable]
-	public class SpanNearQuery:SpanQuery, System.ICloneable
+	public class SpanNearQuery : SpanQuery, System.ICloneable
 	{
-		protected internal System.Collections.ArrayList clauses;
+		protected internal System.Collections.Generic.IList<SpanQuery> clauses;
 		protected internal int slop;
 		protected internal bool inOrder;
 		
@@ -51,7 +52,7 @@ namespace Lucene.Net.Search.Spans
 		{
 			
 			// copy clauses array into an ArrayList
-			this.clauses = new System.Collections.ArrayList(clauses.Length);
+			this.clauses = new System.Collections.Generic.List<SpanQuery>(clauses.Length);
 			for (int i = 0; i < clauses.Length; i++)
 			{
 				SpanQuery clause = clauses[i];
@@ -74,7 +75,7 @@ namespace Lucene.Net.Search.Spans
 		/// <summary>Return the clauses whose spans are matched. </summary>
 		public virtual SpanQuery[] GetClauses()
 		{
-			return (SpanQuery[]) clauses.ToArray(typeof(SpanQuery));
+			return clauses.ToArray();
 		}
 		
 		/// <summary>Return the maximum number of intervening unmatched positions permitted.</summary>
@@ -94,25 +95,7 @@ namespace Lucene.Net.Search.Spans
 			return field;
 		}
 		
-		/// <summary>Returns a collection of all terms matched by this query.</summary>
-		/// <deprecated> use extractTerms instead
-		/// </deprecated>
-        /// <seealso cref="ExtractTerms(System.Collections.Hashtable)">
-		/// </seealso>
-        [Obsolete("use ExtractTerms instead")]
-		public override System.Collections.ICollection GetTerms()
-		{
-			System.Collections.ArrayList terms = new System.Collections.ArrayList();
-			System.Collections.IEnumerator i = clauses.GetEnumerator();
-			while (i.MoveNext())
-			{
-				SpanQuery clause = (SpanQuery) i.Current;
-				terms.AddRange(clause.GetTerms());
-			}
-			return terms;
-		}
-		
-		public override void  ExtractTerms(System.Collections.Hashtable terms)
+		public override void  ExtractTerms(System.Collections.Generic.ISet<Term> terms)
 		{
             foreach (SpanQuery clause in clauses)
             {
@@ -125,10 +108,10 @@ namespace Lucene.Net.Search.Spans
 		{
 			System.Text.StringBuilder buffer = new System.Text.StringBuilder();
 			buffer.Append("spanNear([");
-			System.Collections.IEnumerator i = clauses.GetEnumerator();
+			System.Collections.Generic.IEnumerator<SpanQuery> i = clauses.GetEnumerator();
 			while (i.MoveNext())
 			{
-				SpanQuery clause = (SpanQuery) i.Current;
+				SpanQuery clause = i.Current;
 				buffer.Append(clause.ToString(field));
                 buffer.Append(", ");
 			}
@@ -150,7 +133,7 @@ namespace Lucene.Net.Search.Spans
 			
 			if (clauses.Count == 1)
 			// optimize 1-clause case
-				return ((SpanQuery) clauses[0]).GetSpans(reader);
+				return clauses[0].GetSpans(reader);
 			
 			return inOrder?(Spans) new NearSpansOrdered(this, reader, collectPayloads):(Spans) new NearSpansUnordered(this, reader);
 		}
@@ -160,7 +143,7 @@ namespace Lucene.Net.Search.Spans
 			SpanNearQuery clone = null;
 			for (int i = 0; i < clauses.Count; i++)
 			{
-				SpanQuery c = (SpanQuery) clauses[i];
+				SpanQuery c = clauses[i];
 				SpanQuery query = (SpanQuery) c.Rewrite(reader);
 				if (query != c)
 				{
@@ -187,7 +170,7 @@ namespace Lucene.Net.Search.Spans
 			
 			for (int i = 0; i < sz; i++)
 			{
-				SpanQuery clause = (SpanQuery) clauses[i];
+				SpanQuery clause = clauses[i];
 				newClauses[i] = (SpanQuery) clause.Clone();
 			}
 			SpanNearQuery spanNearQuery = new SpanNearQuery(newClauses, slop, inOrder);

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNotQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNotQuery.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNotQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanNotQuery.cs Wed Nov  9 21:03:47 2011
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using Lucene.Net.Index;
 using IndexReader = Lucene.Net.Index.IndexReader;
 using ToStringUtils = Lucene.Net.Util.ToStringUtils;
 using Query = Lucene.Net.Search.Query;
@@ -174,18 +174,7 @@ namespace Lucene.Net.Search.Spans
 			return include.GetField();
 		}
 		
-		/// <summary>Returns a collection of all terms matched by this query.</summary>
-		/// <deprecated> use extractTerms instead
-		/// </deprecated>
-        /// <seealso cref="ExtractTerms(System.Collections.Hashtable)">
-		/// </seealso>
-        [Obsolete("use ExtractTerms instead")]
-		public override System.Collections.ICollection GetTerms()
-		{
-			return include.GetTerms();
-		}
-		
-		public override void  ExtractTerms(System.Collections.Hashtable terms)
+		public override void  ExtractTerms(System.Collections.Generic.ISet<Term> terms)
 		{
 			include.ExtractTerms(terms);
 		}

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanOrQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanOrQuery.cs?rev=1199962&r1=1199961&r2=1199962&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanOrQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Spans/SpanOrQuery.cs Wed Nov  9 21:03:47 2011
@@ -16,9 +16,9 @@
  */
 
 using System;
-
+using Lucene.Net.Index;
+using Lucene.Net.Util;
 using IndexReader = Lucene.Net.Index.IndexReader;
-using PriorityQueue = Lucene.Net.Util.PriorityQueue;
 using ToStringUtils = Lucene.Net.Util.ToStringUtils;
 using Query = Lucene.Net.Search.Query;
 
@@ -27,7 +27,7 @@ namespace Lucene.Net.Search.Spans
 	
 	/// <summary>Matches the union of its clauses.</summary>
 	[Serializable]
-	public class SpanOrQuery:SpanQuery, System.ICloneable
+	public class SpanOrQuery : SpanQuery, System.ICloneable
 	{
 		private class AnonymousClassSpans : Spans
 		{
@@ -55,13 +55,13 @@ namespace Lucene.Net.Search.Spans
 			private bool InitSpanQueue(int target)
 			{
 				queue = new SpanQueue(enclosingInstance, Enclosing_Instance.clauses.Count);
-				System.Collections.IEnumerator i = Enclosing_Instance.clauses.GetEnumerator();
+				System.Collections.Generic.IEnumerator<SpanQuery> i = Enclosing_Instance.clauses.GetEnumerator();
 				while (i.MoveNext())
 				{
-					Spans spans = ((SpanQuery) i.Current).GetSpans(reader);
+					Spans spans = i.Current.GetSpans(reader);
 					if (((target == - 1) && spans.Next()) || ((target != - 1) && spans.SkipTo(target)))
 					{
-						queue.Put(spans);
+						queue.Add(spans);
 					}
 				}
 				return queue.Size() != 0;
@@ -83,7 +83,7 @@ namespace Lucene.Net.Search.Spans
 				if (Top().Next())
 				{
 					// move to next
-					queue.AdjustTop();
+					queue.UpdateTop();
 					return true;
 				}
 				
@@ -93,7 +93,7 @@ namespace Lucene.Net.Search.Spans
 			
 			private Spans Top()
 			{
-				return (Spans) queue.Top();
+				return queue.Top();
 			}
 			
 			public override bool SkipTo(int target)
@@ -108,7 +108,7 @@ namespace Lucene.Net.Search.Spans
 				{
 					if (Top().SkipTo(target))
 					{
-						queue.AdjustTop();
+						queue.UpdateTop();
 					}
 					else
 					{
@@ -137,7 +137,6 @@ namespace Lucene.Net.Search.Spans
 				return Top().End();
 			}
 			
-			// TODO: Remove warning after API has been finalized
 			public override System.Collections.Generic.ICollection<byte[]> GetPayload()
 			{
 				System.Collections.Generic.ICollection<byte[]> result = null;
@@ -149,7 +148,6 @@ namespace Lucene.Net.Search.Spans
 				return result;
 			}
 			
-			// TODO: Remove warning after API has been finalized
 			public override bool IsPayloadAvailable()
 			{
 				Spans top = Top();
@@ -161,11 +159,12 @@ namespace Lucene.Net.Search.Spans
 				return "spans(" + Enclosing_Instance + ")@" + ((queue == null)?"START":(queue.Size() > 0?(Doc() + ":" + Start() + "-" + End()):"END"));
 			}
 		}
+
 		private SupportClass.EquatableList<SpanQuery> clauses;
 		private System.String field;
 		
 		/// <summary>Construct a SpanOrQuery merging the provided clauses. </summary>
-		public SpanOrQuery(SpanQuery[] clauses)
+		public SpanOrQuery(params SpanQuery[] clauses)
 		{
 			
 			// copy clauses array into an ArrayList
@@ -189,7 +188,7 @@ namespace Lucene.Net.Search.Spans
 		/// <summary>Return the clauses whose spans are matched. </summary>
 		public virtual SpanQuery[] GetClauses()
 		{
-			return (SpanQuery[]) clauses.ToArray();
+			return clauses.ToArray();
 		}
 		
 		public override System.String GetField()
@@ -197,30 +196,10 @@ namespace Lucene.Net.Search.Spans
 			return field;
 		}
 		
-		/// <summary>Returns a collection of all terms matched by this query.</summary>
-		/// <deprecated> use extractTerms instead
-		/// </deprecated>
-        /// <seealso cref="ExtractTerms(System.Collections.Hashtable)">
-		/// </seealso>
-        [Obsolete("use ExtractTerms instead")]
-		public override System.Collections.ICollection GetTerms()
-		{
-			System.Collections.ArrayList terms = new System.Collections.ArrayList();
-			System.Collections.IEnumerator i = clauses.GetEnumerator();
-			while (i.MoveNext())
-			{
-				SpanQuery clause = (SpanQuery) i.Current;
-				terms.AddRange(clause.GetTerms());
-			}
-			return terms;
-		}
-		
-		public override void  ExtractTerms(System.Collections.Hashtable terms)
+		public override void  ExtractTerms(System.Collections.Generic.ISet<Term> terms)
 		{
-			System.Collections.IEnumerator i = clauses.GetEnumerator();
-			while (i.MoveNext())
-			{
-				SpanQuery clause = (SpanQuery) i.Current;
+			foreach(SpanQuery clause in clauses)
+            {
 				clause.ExtractTerms(terms);
 			}
 		}
@@ -232,8 +211,7 @@ namespace Lucene.Net.Search.Spans
 			
 			for (int i = 0; i < sz; i++)
 			{
-				SpanQuery clause = (SpanQuery) clauses[i];
-				newClauses[i] = (SpanQuery) clause.Clone();
+                newClauses[i] = (SpanQuery) clauses[i].Clone();
 			}
 			SpanOrQuery soq = new SpanOrQuery(newClauses);
 			soq.SetBoost(GetBoost());
@@ -245,7 +223,7 @@ namespace Lucene.Net.Search.Spans
 			SpanOrQuery clone = null;
 			for (int i = 0; i < clauses.Count; i++)
 			{
-				SpanQuery c = (SpanQuery) clauses[i];
+				SpanQuery c = clauses[i];
 				SpanQuery query = (SpanQuery) c.Rewrite(reader);
 				if (query != c)
 				{
@@ -269,12 +247,12 @@ namespace Lucene.Net.Search.Spans
 		{
 			System.Text.StringBuilder buffer = new System.Text.StringBuilder();
 			buffer.Append("spanOr([");
-			System.Collections.IEnumerator i = clauses.GetEnumerator();
+			System.Collections.Generic.IEnumerator<SpanQuery> i = clauses.GetEnumerator();
             int j = 0;
 			while (i.MoveNext())
 			{
                 j++;
-				SpanQuery clause = (SpanQuery) i.Current;
+				SpanQuery clause = i.Current;
 				buffer.Append(clause.ToString(field));
                 if (j < clauses.Count)
                 {
@@ -312,7 +290,7 @@ namespace Lucene.Net.Search.Spans
 		}
 		
 		
-		private class SpanQueue:PriorityQueue
+		private class SpanQueue : PriorityQueue<Spans>
 		{
 			private void  InitBlock(SpanOrQuery enclosingInstance)
 			{
@@ -332,11 +310,9 @@ namespace Lucene.Net.Search.Spans
 				InitBlock(enclosingInstance);
 				Initialize(size);
 			}
-			
-			public override bool LessThan(System.Object o1, System.Object o2)
+
+            public override bool LessThan(Spans spans1, Spans spans2)
 			{
-				Spans spans1 = (Spans) o1;
-				Spans spans2 = (Spans) o2;
 				if (spans1.Doc() == spans2.Doc())
 				{
 					if (spans1.Start() == spans2.Start())
@@ -359,7 +335,7 @@ namespace Lucene.Net.Search.Spans
 		{
 			if (clauses.Count == 1)
 			// optimize 1-clause case
-				return ((SpanQuery) clauses[0]).GetSpans(reader);
+				return (clauses[0]).GetSpans(reader);
 			
 			return new AnonymousClassSpans(reader, this);
 		}