You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by di...@apache.org on 2011/04/30 23:43:10 UTC

[Lucene.Net] svn commit: r1098175 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core: Index/ Search/ Search/Spans/

Author: digy
Date: Sat Apr 30 21:43:10 2011
New Revision: 1098175

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

Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexReader.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/MultipleTermPositions.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanQuery.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanScorer.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanScorer2.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/ConjunctionScorer.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/DisjunctionSumScorer.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/QueryTermVector.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Spans/NearSpansOrdered.cs

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexReader.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexReader.cs?rev=1098175&r1=1098174&r2=1098175&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexReader.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/IndexReader.cs Sat Apr 30 21:43:10 2011
@@ -1685,7 +1685,7 @@ namespace Lucene.Net.Index
 				cfr = new CompoundFileReader(dir, filename);
 				
 				System.String[] files = cfr.List();
-				System.Array.Sort(files); // sort the array of filename so that the output is more readable
+				System.Array.Sort<string>(files); // sort the array of filename so that the output is more readable
 				
 				for (int i = 0; i < files.Length; ++i)
 				{

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/MultipleTermPositions.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/MultipleTermPositions.cs?rev=1098175&r1=1098174&r2=1098175&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/MultipleTermPositions.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/MultipleTermPositions.cs Sat Apr 30 21:43:10 2011
@@ -84,7 +84,7 @@ namespace Lucene.Net.Index
 			
 			internal void  sort()
 			{
-				System.Array.Sort(_array, _index, _lastIndex - _index);
+				System.Array.Sort<int>(_array, _index, _lastIndex - _index);
 			}
 			
 			internal void  clear()

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanQuery.cs?rev=1098175&r1=1098174&r2=1098175&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanQuery.cs Sat Apr 30 21:43:10 2011
@@ -382,9 +382,9 @@ namespace Lucene.Net.Search
 			
 			public override Scorer Scorer(IndexReader reader, bool scoreDocsInOrder, bool topScorer)
 			{
-				System.Collections.IList required = new System.Collections.ArrayList();
-				System.Collections.IList prohibited = new System.Collections.ArrayList();
-				System.Collections.IList optional = new System.Collections.ArrayList();
+                List<Scorer> required = new List<Scorer>();
+                List<Scorer> prohibited = new List<Scorer>();
+                List<Scorer> optional = new List<Scorer>();
 				for (System.Collections.IEnumerator wIter = weights.GetEnumerator(), cIter = Enclosing_Instance.clauses.GetEnumerator(); wIter.MoveNext(); )
 				{
                     cIter.MoveNext();

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanScorer.cs?rev=1098175&r1=1098174&r2=1098175&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanScorer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanScorer.cs Sat Apr 30 21:43:10 2011
@@ -260,9 +260,8 @@ namespace Lucene.Net.Search
 			
 			if (optionalScorers != null && optionalScorers.Count > 0)
 			{
-				for (System.Collections.IEnumerator si = optionalScorers.GetEnumerator(); si.MoveNext(); )
-				{
-					Scorer scorer = (Scorer) si.Current;
+                foreach(Scorer scorer in optionalScorers)
+                {
 					maxCoord++;
 					if (scorer.NextDoc() != NO_MORE_DOCS)
 					{
@@ -273,9 +272,8 @@ namespace Lucene.Net.Search
 			
 			if (prohibitedScorers != null && prohibitedScorers.Count > 0)
 			{
-				for (System.Collections.IEnumerator si = prohibitedScorers.GetEnumerator(); si.MoveNext(); )
-				{
-					Scorer scorer = (Scorer) si.Current;
+                foreach(Scorer scorer in prohibitedScorers)
+                {
 					int mask = nextMask;
 					nextMask = nextMask << 1;
 					prohibitedMask |= mask; // update prohibited mask

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanScorer2.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanScorer2.cs?rev=1098175&r1=1098174&r2=1098175&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanScorer2.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/BooleanScorer2.cs Sat Apr 30 21:43:10 2011
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 namespace Lucene.Net.Search
 {
@@ -45,7 +46,7 @@ namespace Lucene.Net.Search
 				}
 				
 			}
-			internal AnonymousClassDisjunctionSumScorer(BooleanScorer2 enclosingInstance, System.Collections.IList Param1, int Param2):base(Param1, Param2)
+			internal AnonymousClassDisjunctionSumScorer(BooleanScorer2 enclosingInstance, IList<Scorer> Param1, int Param2):base(Param1, Param2)
 			{
 				InitBlock(enclosingInstance);
 			}
@@ -85,7 +86,7 @@ namespace Lucene.Net.Search
 				}
 				
 			}
-			internal AnonymousClassConjunctionScorer(int requiredNrMatchers, BooleanScorer2 enclosingInstance, Lucene.Net.Search.Similarity Param1, System.Collections.ICollection Param2):base(Param1, Param2)
+            internal AnonymousClassConjunctionScorer(int requiredNrMatchers, BooleanScorer2 enclosingInstance, Lucene.Net.Search.Similarity Param1, List<Scorer> Param2) : base(Param1, Param2)
 			{
 				InitBlock(requiredNrMatchers, enclosingInstance);
 			}
@@ -112,10 +113,10 @@ namespace Lucene.Net.Search
 				return lastDocScore;
 			}
 		}
-		
-		private System.Collections.IList requiredScorers;
-		private System.Collections.IList optionalScorers;
-		private System.Collections.IList prohibitedScorers;
+
+        private List<Scorer> requiredScorers;
+        private List<Scorer> optionalScorers;
+        private List<Scorer> prohibitedScorers;
 		
 		private class Coordinator
 		{
@@ -181,7 +182,7 @@ namespace Lucene.Net.Search
 		/// </param>
 		/// <param name="optional">the list of optional scorers.
 		/// </param>
-		public BooleanScorer2(Similarity similarity, int minNrShouldMatch, System.Collections.IList required, System.Collections.IList prohibited, System.Collections.IList optional):base(similarity)
+        public BooleanScorer2(Similarity similarity, int minNrShouldMatch, List<Scorer> required, List<Scorer> prohibited, List<Scorer> optional) : base(similarity)
 		{
 			if (minNrShouldMatch < 0)
 			{
@@ -281,16 +282,16 @@ namespace Lucene.Net.Search
 				return scorer.Explain(docNr);
 			}
 		}
-		
-		private Scorer CountingDisjunctionSumScorer(System.Collections.IList scorers, int minNrShouldMatch)
+
+        private Scorer CountingDisjunctionSumScorer(IList<Scorer> scorers, int minNrShouldMatch)
 		{
 			// each scorer from the list counted as a single matcher
 			return new AnonymousClassDisjunctionSumScorer(this, scorers, minNrShouldMatch);
 		}
 		
 		private static readonly Similarity defaultSimilarity;
-		
-		private Scorer CountingConjunctionSumScorer(System.Collections.IList requiredScorers)
+
+        private Scorer CountingConjunctionSumScorer(List<Scorer> requiredScorers)
 		{
 			// each scorer from the list counted as a single matcher
 			int requiredNrMatchers = requiredScorers.Count;
@@ -325,7 +326,7 @@ namespace Lucene.Net.Search
 			if (optionalScorers.Count > nrOptRequired)
 				requiredCountingSumScorer = CountingDisjunctionSumScorer(optionalScorers, nrOptRequired);
 			else if (optionalScorers.Count == 1)
-				requiredCountingSumScorer = new SingleMatchScorer(this, (Scorer) optionalScorers[0]);
+				requiredCountingSumScorer = new SingleMatchScorer(this, optionalScorers[0]);
 			else
 				requiredCountingSumScorer = CountingConjunctionSumScorer(optionalScorers);
 			return AddProhibitedScorers(requiredCountingSumScorer);
@@ -337,14 +338,14 @@ namespace Lucene.Net.Search
 			if (optionalScorers.Count == minNrShouldMatch)
 			{
 				// all optional scorers also required.
-				System.Collections.ArrayList allReq = new System.Collections.ArrayList(requiredScorers);
+                List<Scorer> allReq = new List<Scorer>(requiredScorers);
 				allReq.AddRange(optionalScorers);
 				return AddProhibitedScorers(CountingConjunctionSumScorer(allReq));
 			}
 			else
 			{
 				// optionalScorers.size() > minNrShouldMatch, and at least one required scorer
-				Scorer requiredCountingSumScorer = requiredScorers.Count == 1?new SingleMatchScorer(this, (Scorer) requiredScorers[0]):CountingConjunctionSumScorer(requiredScorers);
+				Scorer requiredCountingSumScorer = requiredScorers.Count == 1?new SingleMatchScorer(this, requiredScorers[0]):CountingConjunctionSumScorer(requiredScorers);
 				if (minNrShouldMatch > 0)
 				{
 					// use a required disjunction scorer over the optional scorers
@@ -353,7 +354,7 @@ namespace Lucene.Net.Search
 				else
 				{
 					// minNrShouldMatch == 0
-					return new ReqOptSumScorer(AddProhibitedScorers(requiredCountingSumScorer), optionalScorers.Count == 1?new SingleMatchScorer(this, (Scorer) optionalScorers[0]):CountingDisjunctionSumScorer(optionalScorers, 1));
+					return new ReqOptSumScorer(AddProhibitedScorers(requiredCountingSumScorer), optionalScorers.Count == 1?new SingleMatchScorer(this, optionalScorers[0]):CountingDisjunctionSumScorer(optionalScorers, 1));
 				}
 			}
 		}
@@ -365,7 +366,7 @@ namespace Lucene.Net.Search
 		/// </param>
 		private Scorer AddProhibitedScorers(Scorer requiredCountingSumScorer)
 		{
-			return (prohibitedScorers.Count == 0)?requiredCountingSumScorer:new ReqExclScorer(requiredCountingSumScorer, ((prohibitedScorers.Count == 1)?(Scorer) prohibitedScorers[0]:new DisjunctionSumScorer(prohibitedScorers)));
+			return (prohibitedScorers.Count == 0)?requiredCountingSumScorer:new ReqExclScorer(requiredCountingSumScorer, ((prohibitedScorers.Count == 1)?prohibitedScorers[0]:new DisjunctionSumScorer(prohibitedScorers)));
 		}
 		
 		/// <summary>Scores and collects all matching documents.</summary>

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/ConjunctionScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/ConjunctionScorer.cs?rev=1098175&r1=1098174&r2=1098175&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/ConjunctionScorer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/ConjunctionScorer.cs Sat Apr 30 21:43:10 2011
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 namespace Lucene.Net.Search
 {
@@ -23,37 +24,11 @@ namespace Lucene.Net.Search
 	/// <summary>Scorer for conjunctions, sets of queries, all of which are required. </summary>
 	class ConjunctionScorer:Scorer
 	{
-		private class AnonymousClassComparator : System.Collections.IComparer
-		{
-			public AnonymousClassComparator(ConjunctionScorer enclosingInstance)
-			{
-				InitBlock(enclosingInstance);
-			}
-			private void  InitBlock(ConjunctionScorer enclosingInstance)
-			{
-				this.enclosingInstance = enclosingInstance;
-			}
-			private ConjunctionScorer enclosingInstance;
-			public ConjunctionScorer Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			// sort the array
-			public virtual int Compare(System.Object o1, System.Object o2)
-			{
-				return ((Scorer) o1).DocID() - ((Scorer) o2).DocID();
-			}
-		}
-		
 		private Scorer[] scorers;
 		private float coord;
 		private int lastDoc = - 1;
-		
-		public ConjunctionScorer(Similarity similarity, System.Collections.ICollection scorers):this(similarity, (Scorer[]) new System.Collections.ArrayList(scorers).ToArray(typeof(Scorer)))
+
+        public ConjunctionScorer(Similarity similarity, List<Scorer> scorers) : this(similarity, scorers.ToArray())
 		{
 		}
 		
@@ -78,7 +53,7 @@ namespace Lucene.Net.Search
 			// it will already start off sorted (all scorers on same doc).
 			
 			// note that this comparator is not consistent with equals!
-			System.Array.Sort(scorers, new AnonymousClassComparator(this));
+            Array.Sort<Scorer>(scorers,(x,y)=>x.DocID() - y.DocID()); 
 			
 			// NOTE: doNext() must be called before the re-sorting of the array later on.
 			// The reason is this: assume there are 5 scorers, whose first docs are 1,

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/DisjunctionSumScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/DisjunctionSumScorer.cs?rev=1098175&r1=1098174&r2=1098175&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/DisjunctionSumScorer.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/DisjunctionSumScorer.cs Sat Apr 30 21:43:10 2011
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 using ScorerDocQueue = Lucene.Net.Util.ScorerDocQueue;
 
@@ -32,7 +33,7 @@ namespace Lucene.Net.Search
 		private int nrScorers;
 		
 		/// <summary>The subscorers. </summary>
-		protected internal System.Collections.IList subScorers;
+		protected internal IList<Scorer> subScorers;
 		
 		/// <summary>The minimum number of scorers that should match. </summary>
 		private int minimumNrMatchers;
@@ -70,7 +71,7 @@ namespace Lucene.Net.Search
 		/// <br/>When minimumNrMatchers equals the number of subScorers,
 		/// it more efficient to use <code>ConjunctionScorer</code>.
 		/// </param>
-		public DisjunctionSumScorer(System.Collections.IList subScorers, int minimumNrMatchers):base(null)
+        public DisjunctionSumScorer(IList<Scorer> subScorers, int minimumNrMatchers) : base(null)
 		{
 			
 			nrScorers = subScorers.Count;
@@ -93,7 +94,7 @@ namespace Lucene.Net.Search
 		/// <summary>Construct a <code>DisjunctionScorer</code>, using one as the minimum number
 		/// of matching subscorers.
 		/// </summary>
-		public DisjunctionSumScorer(System.Collections.IList subScorers):this(subScorers, 1)
+        public DisjunctionSumScorer(IList<Scorer> subScorers) : this(subScorers, 1)
 		{
 		}
 		
@@ -102,11 +103,9 @@ namespace Lucene.Net.Search
 		/// </summary>
 		private void  InitScorerDocQueue()
 		{
-			System.Collections.IEnumerator si = subScorers.GetEnumerator();
 			scorerDocQueue = new ScorerDocQueue(nrScorers);
-			while (si.MoveNext())
-			{
-				Scorer se = (Scorer) si.Current;
+            foreach(Scorer se in subScorers)
+            {
 				if (se.NextDoc() != NO_MORE_DOCS)
 				{
 					// doc() method will be used in scorerDocQueue.
@@ -352,12 +351,11 @@ namespace Lucene.Net.Search
 		public override Explanation Explain(int doc)
 		{
 			Explanation res = new Explanation();
-			System.Collections.IEnumerator ssi = subScorers.GetEnumerator();
 			float sumScore = 0.0f;
 			int nrMatches = 0;
-			while (ssi.MoveNext())
-			{
-				Explanation es = ((Scorer) ssi.Current).Explain(doc);
+            foreach(Scorer s in subScorers)
+            {
+				Explanation es = s.Explain(doc);
 				if (es.GetValue() > 0.0f)
 				{
 					// indicates match

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/QueryTermVector.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/QueryTermVector.cs?rev=1098175&r1=1098174&r2=1098175&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/QueryTermVector.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/QueryTermVector.cs Sat Apr 30 21:43:10 2011
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 using Analyzer = Lucene.Net.Analysis.Analyzer;
 using TokenStream = Lucene.Net.Analysis.TokenStream;
@@ -82,11 +83,11 @@ namespace Lucene.Net.Search
 		{
 			if (queryTerms != null)
 			{
-				System.Array.Sort(queryTerms);
-				System.Collections.IDictionary tmpSet = new System.Collections.Hashtable(queryTerms.Length);
+				System.Array.Sort<string>(queryTerms);
+                SupportClass.Dictionary<string, int?> tmpSet = new SupportClass.Dictionary<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);
+                List<String> tmpList = new List<String>(queryTerms.Length);
+                List<int> tmpFreqs = new List<int>(queryTerms.Length);
 				int j = 0;
 				for (int i = 0; i < queryTerms.Length; i++)
 				{
@@ -94,18 +95,18 @@ namespace Lucene.Net.Search
 					System.Object temp_position = tmpSet[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? position = tmpSet[term];
+						int integer = tmpFreqs[position.Value];
+						tmpFreqs[position.Value] = (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;

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Spans/NearSpansOrdered.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Spans/NearSpansOrdered.cs?rev=1098175&r1=1098174&r2=1098175&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Spans/NearSpansOrdered.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/Spans/NearSpansOrdered.cs Sat Apr 30 21:43:10 2011
@@ -47,34 +47,6 @@ namespace Lucene.Net.Search.Spans
 	/// </summary>
 	public class NearSpansOrdered:Spans
 	{
-		internal class AnonymousClassComparator : System.Collections.IComparer
-		{
-			public AnonymousClassComparator(NearSpansOrdered enclosingInstance)
-			{
-				InitBlock(enclosingInstance);
-			}
-			private void  InitBlock(NearSpansOrdered enclosingInstance)
-			{
-				this.enclosingInstance = enclosingInstance;
-			}
-			private NearSpansOrdered enclosingInstance;
-			public NearSpansOrdered Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			public virtual int Compare(System.Object o1, System.Object o2)
-			{
-				return ((Spans) o1).Doc() - ((Spans) o2).Doc();
-			}
-		}
-		private void  InitBlock()
-		{
-			spanDocComparator = new AnonymousClassComparator(this);
-		}
 		private int allowedSlop;
 		private bool firstTime = true;
 		private bool more = false;
@@ -91,7 +63,7 @@ namespace Lucene.Net.Search.Spans
 		private List<byte[]> matchPayload;
 		
 		private Spans[] subSpansByDoc;
-		private System.Collections.IComparer spanDocComparator;
+        private Comparison<Spans> spanDocComparator = (s1, s2) => s1.Doc() - s2.Doc();
 		
 		private SpanNearQuery query;
 		private bool collectPayloads = true;
@@ -102,7 +74,6 @@ namespace Lucene.Net.Search.Spans
 		
 		public NearSpansOrdered(SpanNearQuery spanNearQuery, IndexReader reader, bool collectPayloads)
 		{
-			InitBlock();
 			if (spanNearQuery.GetClauses().Length < 2)
 			{
 				throw new System.ArgumentException("Less than 2 clauses: " + spanNearQuery);
@@ -236,7 +207,7 @@ namespace Lucene.Net.Search.Spans
 		/// <summary>Advance the subSpans to the same document </summary>
 		private bool ToSameDoc()
 		{
-			System.Array.Sort(subSpansByDoc, spanDocComparator);
+			Array.Sort<Spans>(subSpansByDoc, spanDocComparator);
 			int firstIndex = 0;
 			int maxDoc = subSpansByDoc[subSpansByDoc.Length - 1].Doc();
 			while (subSpansByDoc[firstIndex].Doc() != maxDoc)