You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ar...@apache.org on 2008/06/25 04:51:26 UTC

svn commit: r671402 [1/5] - in /incubator/lucene.net/trunk/C#/src/Lucene.Net/Search: ./ Function/ Payload/ Spans/

Author: aroush
Date: Tue Jun 24 19:51:24 2008
New Revision: 671402

URL: http://svn.apache.org/viewvc?rev=671402&view=rev
Log:
Release: Apache Lucene.Net.2.3.1 build 001 "Alpha"

Added:
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/CachingSpanFilter.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ExtendedFieldCache.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ExtendedFieldCacheImpl.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FilterManager.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Function/
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Function/ByteFieldSource.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Function/CustomScoreQuery.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Function/DocValues.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Function/FieldCacheSource.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Function/FieldScoreQuery.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Function/FloatFieldSource.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Function/IntFieldSource.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Function/OrdFieldSource.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Function/Package.html
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Function/ReverseOrdFieldSource.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Function/ShortFieldSource.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Function/ValueSource.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Function/ValueSourceQuery.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Payload/
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Payload/BoostingTermQuery.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Payload/Package.html
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/QueryWrapperFilter.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/RemoteCachingWrapperFilter.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/SpanFilter.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/SpanFilterResult.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/SpanQueryFilter.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/TermSpans.cs
Modified:
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanClause.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanQuery.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanScorer.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanScorer2.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/CachingWrapperFilter.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ComplexExplanation.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ConjunctionScorer.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ConstantScoreQuery.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ConstantScoreRangeQuery.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/DisjunctionMaxQuery.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/DisjunctionMaxScorer.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ExactPhraseScorer.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Explanation.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldCache.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldCacheImpl.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldDocSortedHitQueue.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldSortedHitQueue.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FilteredQuery.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FuzzyQuery.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FuzzyTermEnum.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Hit.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/HitCollector.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Hits.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/IndexSearcher.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/MultiSearcher.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Package.html
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/PhrasePositions.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/PhraseQueue.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/PhraseScorer.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/PrefixFilter.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/PrefixQuery.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/QueryFilter.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/QueryTermVector.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/RangeFilter.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/RangeQuery.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/RemoteSearchable.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ReqOptSumScorer.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ScoreDocComparator.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Scorer.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searchable.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Searcher.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Similarity.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/SloppyPhraseScorer.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Sort.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/SortComparator.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/SortComparatorSource.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/SortField.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/NearSpansOrdered.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/NearSpansUnordered.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/Package.html
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanScorer.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanTermQuery.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Spans/SpanWeight.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/TermQuery.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/TermScorer.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/TopDocCollector.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/TopDocs.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/TopFieldDocCollector.cs
    incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/WildcardQuery.cs

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanClause.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/BooleanClause.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanClause.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanClause.cs Tue Jun 24 19:51:24 2008
@@ -48,9 +48,12 @@
 			/// <summary>Use this operator for clauses that <i>must</i> appear in the matching documents. </summary>
 			public static readonly Occur MUST = new Occur("MUST");
 			/// <summary>Use this operator for clauses that <i>should</i> appear in the 
-			/// matching documents. For a BooleanQuery with two <code>SHOULD</code> 
-			/// subqueries, at least one of the clauses must appear in the matching documents. 
+			/// matching documents. For a BooleanQuery with no <code>MUST</code> 
+			/// clauses one or more <code>SHOULD</code> clauses must match a document 
+			/// for the BooleanQuery to match.
 			/// </summary>
+			/// <seealso cref="BooleanQuery.setMinimumNumberShouldMatch">
+			/// </seealso>
 			public static readonly Occur SHOULD = new Occur("SHOULD");
 			/// <summary>Use this operator for clauses that <i>must not</i> appear in the matching documents.
 			/// Note that it is not possible to search for queries that only consist

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/BooleanQuery.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanQuery.cs Tue Jun 24 19:51:24 2008
@@ -158,27 +158,27 @@
 		}
 		
 		/// <summary> Specifies a minimum number of the optional BooleanClauses
-		/// which must be satisifed.
+		/// which must be satisfied.
 		/// 
 		/// <p>
-		/// By default no optional clauses are neccessary for a match
+		/// By default no optional clauses are necessary for a match
 		/// (unless there are no required clauses).  If this method is used,
-		/// then the specified numebr of clauses is required.
+		/// then the specified number of clauses is required.
 		/// </p>
 		/// <p>
-		/// Use of this method is totally independant of specifying that
+		/// Use of this method is totally independent of specifying that
 		/// any specific clauses are required (or prohibited).  This number will
 		/// only be compared against the number of matching optional clauses.
 		/// </p>
 		/// <p>
-		/// EXPERT NOTE: Using this method will force the use of BooleanWeight2,
-		/// regardless of wether setUseScorer14(true) has been called.
+		/// EXPERT NOTE: Using this method may force collecting docs in order,
+		/// regardless of whether setAllowDocsOutOfOrder(true) has been called.
 		/// </p>
 		/// 
 		/// </summary>
 		/// <param name="min">the number of optional clauses that must match
 		/// </param>
-		/// <seealso cref="#setUseScorer14">
+		/// <seealso cref="setAllowDocsOutOfOrder">
 		/// </seealso>
 		public virtual void  SetMinimumNumberShouldMatch(int min)
 		{
@@ -293,51 +293,18 @@
 				norm *= Enclosing_Instance.GetBoost(); // incorporate boost
 				for (int i = 0; i < weights.Count; i++)
 				{
-					BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
 					Weight w = (Weight) weights[i];
 					// normalize all clauses, (even if prohibited in case of side affects)
 					w.Normalize(norm);
 				}
 			}
 			
-			/// <returns> A good old 1.4 Scorer 
+			/// <returns> Returns BooleanScorer2 that uses and provides skipTo(),
+			/// and scores documents in document number order.
 			/// </returns>
 			public virtual Scorer Scorer(IndexReader reader)
 			{
-				// First see if the (faster) ConjunctionScorer will work.  This can be
-				// used when all clauses are required.  Also, at this point a
-				// BooleanScorer cannot be embedded in a ConjunctionScorer, as the hits
-				// from a BooleanScorer are not always sorted by document number (sigh)
-				// and hence BooleanScorer cannot implement skipTo() correctly, which is
-				// required by ConjunctionScorer.
-				bool allRequired = true;
-				bool noneBoolean = true;
-				for (int i = 0; i < weights.Count; i++)
-				{
-					BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
-					if (!c.IsRequired())
-						allRequired = false;
-					if (c.GetQuery() is BooleanQuery)
-						noneBoolean = false;
-				}
-				
-				if (allRequired && noneBoolean)
-				{
-					// ConjunctionScorer is okay
-					ConjunctionScorer result = new ConjunctionScorer(similarity);
-					for (int i = 0; i < weights.Count; i++)
-					{
-						Weight w = (Weight) weights[i];
-						Scorer subScorer = w.Scorer(reader);
-						if (subScorer == null)
-							return null;
-						result.Add(subScorer);
-					}
-					return result;
-				}
-				
-				// Use good-old BooleanScorer instead.
-				BooleanScorer result2 = new BooleanScorer(similarity);
+				BooleanScorer2 result = new BooleanScorer2(similarity, Enclosing_Instance.minNrShouldMatch, Lucene.Net.Search.BooleanQuery.allowDocsOutOfOrder);
 				
 				for (int i = 0; i < weights.Count; i++)
 				{
@@ -345,12 +312,12 @@
 					Weight w = (Weight) weights[i];
 					Scorer subScorer = w.Scorer(reader);
 					if (subScorer != null)
-						result2.Add(subScorer, c.IsRequired(), c.IsProhibited());
+						result.Add(subScorer, c.IsRequired(), c.IsProhibited());
 					else if (c.IsRequired())
 						return null;
 				}
 				
-				return result2;
+				return result;
 			}
 			
 			public virtual Explanation Explain(IndexReader reader, int doc)
@@ -431,73 +398,59 @@
 			}
 		}
 		
-		[Serializable]
-		private class BooleanWeight2 : BooleanWeight
+		/// <summary>Whether hit docs may be collected out of docid order. </summary>
+		private static bool allowDocsOutOfOrder = false;
+		
+		/// <summary> Expert: Indicates whether hit docs may be collected out of docid
+		/// order.
+		/// 
+		/// <p>
+		/// Background: although the contract of the Scorer class requires that
+		/// documents be iterated in order of doc id, this was not true in early
+		/// versions of Lucene.  Many pieces of functionality in the current
+		/// Lucene code base have undefined behavior if this contract is not
+		/// upheld, but in some specific simple cases may be faster.  (For
+		/// example: disjunction queries with less than 32 prohibited clauses;
+		/// This setting has no effect for other queries.)
+		/// </p>
+		/// 
+		/// <p>
+		/// Specifics: By setting this option to true, calls to 
+		/// {@link HitCollector#Collect(int,float)} might be
+		/// invoked first for docid N and only later for docid N-1.
+		/// Being static, this setting is system wide.
+		/// </p>
+		/// </summary>
+		public static void  SetAllowDocsOutOfOrder(bool allow)
 		{
-			private void  InitBlock(BooleanQuery enclosingInstance)
-			{
-				this.enclosingInstance = enclosingInstance;
-			}
-			private BooleanQuery enclosingInstance;
-			public new BooleanQuery Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			/* Merge into BooleanWeight in case the 1.4 BooleanScorer is dropped */
-			public BooleanWeight2(BooleanQuery enclosingInstance, Searcher searcher):base(enclosingInstance, searcher)
-			{
-				InitBlock(enclosingInstance);
-			}
-			
-			/// <returns> An alternative Scorer that uses and provides skipTo(),
-			/// and scores documents in document number order.
-			/// </returns>
-			public override Scorer Scorer(IndexReader reader)
-			{
-				BooleanScorer2 result = new BooleanScorer2(similarity, Enclosing_Instance.minNrShouldMatch);
-				
-				for (int i = 0; i < weights.Count; i++)
-				{
-					BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
-					Weight w = (Weight) weights[i];
-					Scorer subScorer = w.Scorer(reader);
-					if (subScorer != null)
-						result.Add(subScorer, c.IsRequired(), c.IsProhibited());
-					else if (c.IsRequired())
-						return null;
-				}
-				
-				return result;
-			}
+			allowDocsOutOfOrder = allow;
 		}
 		
-		/// <summary>Indicates whether to use good old 1.4 BooleanScorer. </summary>
-		private static bool useScorer14 = false;
+		/// <summary> Whether hit docs may be collected out of docid order.</summary>
+		/// <seealso cref="SetAllowDocsOutOfOrder(boolean)">
+		/// </seealso>
+		public static bool GetAllowDocsOutOfOrder()
+		{
+			return allowDocsOutOfOrder;
+		}
 		
+		/// <deprecated> Use {@link #SetAllowDocsOutOfOrder(boolean)} instead. 
+		/// </deprecated>
 		public static void  SetUseScorer14(bool use14)
 		{
-			useScorer14 = use14;
+			SetAllowDocsOutOfOrder(use14);
 		}
 		
+		/// <deprecated> Use {@link #GetAllowDocsOutOfOrder()} instead.
+		/// </deprecated>
 		public static bool GetUseScorer14()
 		{
-			return useScorer14;
+			return GetAllowDocsOutOfOrder();
 		}
 		
 		protected internal override Weight CreateWeight(Searcher searcher)
 		{
-			
-			if (0 < minNrShouldMatch)
-			{
-				// :TODO: should we throw an exception if getUseScorer14 ?
-				return new BooleanWeight2(this, searcher);
-			}
-			
-			return GetUseScorer14() ? (Weight) new BooleanWeight(this, searcher) : (Weight) new BooleanWeight2(this, searcher);
+			return new BooleanWeight(this, searcher);
 		}
 		
 		public override Query Rewrite(IndexReader reader)

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/BooleanScorer.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanScorer.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanScorer.cs Tue Jun 24 19:51:24 2008
@@ -24,7 +24,7 @@
 	{
 		private void  InitBlock()
 		{
-			bucketTable = new BucketTable(this);
+			bucketTable = new BucketTable();
 		}
 		private SubScorer scorers = null;
 		private BucketTable bucketTable;
@@ -36,9 +36,16 @@
 		private int prohibitedMask = 0;
 		private int nextMask = 1;
 		
-		internal BooleanScorer(Similarity similarity) : base(similarity)
+		private int minNrShouldMatch;
+		
+		internal BooleanScorer(Similarity similarity) : this(similarity, 1)
+		{
+		}
+		
+		internal BooleanScorer(Similarity similarity, int minNrShouldMatch) : base(similarity)
 		{
 			InitBlock();
+			this.minNrShouldMatch = minNrShouldMatch;
 		}
 		
 		internal sealed class SubScorer
@@ -131,7 +138,10 @@
 							continue;
 						}
 						
-						hc.Collect(current.doc, current.score * coordFactors[current.coord]);
+						if (current.coord >= minNrShouldMatch)
+						{
+							hc.Collect(current.doc, current.score * coordFactors[current.coord]);
+						}
 					}
 					
 					current = current.next; // pop the queue
@@ -179,8 +189,8 @@
 					current = bucketTable.first;
 					bucketTable.first = current.next; // pop the queue
 					
-					// check prohibited & required
-					if ((current.bits & prohibitedMask) == 0 && (current.bits & requiredMask) == requiredMask)
+					// check prohibited & required, and minNrShouldMatch
+					if ((current.bits & prohibitedMask) == 0 && (current.bits & requiredMask) == requiredMask && current.coord >= minNrShouldMatch)
 					{
 						return true;
 					}
@@ -237,12 +247,8 @@
 			internal Bucket[] buckets;
 			internal Bucket first = null; // head of valid list
 			
-			private BooleanScorer scorer;
-			
-			public BucketTable(BooleanScorer scorer)
+			public BucketTable()
 			{
-                InitBlock();
-				this.scorer = scorer;
 			}
 			
 			public int Size()

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanScorer2.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/BooleanScorer2.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanScorer2.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanScorer2.cs Tue Jun 24 19:51:24 2008
@@ -20,9 +20,10 @@
 namespace Lucene.Net.Search
 {
 	
-	/// <summary>An alternative to BooleanScorer.
-	/// <br>Uses ConjunctionScorer, DisjunctionScorer, ReqOptScorer and ReqExclScorer.
+	/// <summary>An alternative to BooleanScorer that also allows a minimum number
+	/// of optional scorers that should match.
 	/// <br>Implements skipTo(), and has no limitations on the numbers of added scorers.
+	/// <br>Uses ConjunctionScorer, DisjunctionScorer, ReqOptScorer and ReqExclScorer.
 	/// </summary>
 	class BooleanScorer2 : Scorer
 	{
@@ -76,7 +77,7 @@
 				}
 				
 			}
-			internal AnonymousClassConjunctionScorer(int requiredNrMatchers, BooleanScorer2 enclosingInstance, Lucene.Net.Search.Similarity Param1):base(Param1)
+			internal AnonymousClassConjunctionScorer(int requiredNrMatchers, BooleanScorer2 enclosingInstance, Lucene.Net.Search.Similarity Param1, System.Collections.ICollection scorers) : base(Param1, scorers)
 			{
 				InitBlock(requiredNrMatchers, enclosingInstance);
 			}
@@ -158,6 +159,12 @@
 		/// <summary>The number of optionalScorers that need to match (if there are any) </summary>
 		private int minNrShouldMatch;
 		
+		/// <summary>Whether it is allowed to return documents out of order.
+		/// This can accelerate the scoring of disjunction queries.  
+		/// </summary>
+		private bool allowDocsOutOfOrder;
+		
+		
 		/// <summary>Create a BooleanScorer2.</summary>
 		/// <param name="similarity">The similarity to be used.
 		/// </param>
@@ -167,7 +174,10 @@
 		/// at least one of the optional scorers will have to
 		/// match during the search.
 		/// </param>
-		public BooleanScorer2(Similarity similarity, int minNrShouldMatch) : base(similarity)
+		/// <param name="allowDocsOutOfOrder">Whether it is allowed to return documents out of order.
+		/// This can accelerate the scoring of disjunction queries.                         
+		/// </param>
+		public BooleanScorer2(Similarity similarity, int minNrShouldMatch, bool allowDocsOutOfOrder) : base(similarity)
 		{
 			if (minNrShouldMatch < 0)
 			{
@@ -175,6 +185,23 @@
 			}
 			coordinator = new Coordinator(this);
 			this.minNrShouldMatch = minNrShouldMatch;
+			this.allowDocsOutOfOrder = allowDocsOutOfOrder;
+		}
+		
+		/// <summary>Create a BooleanScorer2.
+		/// In no required scorers are added,
+		/// at least one of the optional scorers will have to match during the search.
+		/// </summary>
+		/// <param name="similarity">The similarity to be used.
+		/// </param>
+		/// <param name="minNrShouldMatch">The minimum number of optional added scorers
+		/// that should match during the search.
+		/// In case no required scorers are added,
+		/// at least one of the optional scorers will have to
+		/// match during the search.
+		/// </param>
+		public BooleanScorer2(Similarity similarity, int minNrShouldMatch) : this(similarity, minNrShouldMatch, false)
+		{
 		}
 		
 		/// <summary>Create a BooleanScorer2.
@@ -183,7 +210,7 @@
 		/// </summary>
 		/// <param name="similarity">The similarity to be used.
 		/// </param>
-		public BooleanScorer2(Similarity similarity) : this(similarity, 0)
+		public BooleanScorer2(Similarity similarity):this(similarity, 0, false)
 		{
 		}
 		
@@ -251,7 +278,7 @@
 			}
 			public override float Score()
 			{
-				if (this.Doc() > lastScoredDoc)
+				if (this.Doc() >= lastScoredDoc)
 				{
 					lastScoredDoc = this.Doc();
 					Enclosing_Instance.coordinator.nrMatchers++;
@@ -284,31 +311,21 @@
 		
 		private static Similarity defaultSimilarity = new DefaultSimilarity();
 		
-		private Scorer countingConjunctionSumScorer(System.Collections.IList requiredScorers)
+		private Scorer CountingConjunctionSumScorer(System.Collections.IList requiredScorers)
 		{
 			// each scorer from the list counted as a single matcher
 			int requiredNrMatchers = requiredScorers.Count;
-			ConjunctionScorer cs = new AnonymousClassConjunctionScorer(requiredNrMatchers, this, defaultSimilarity);
-			System.Collections.IEnumerator rsi = requiredScorers.GetEnumerator();
-			while (rsi.MoveNext())
-			{
-				cs.Add((Scorer) rsi.Current);
-			}
-			return cs;
+			return new AnonymousClassConjunctionScorer(requiredNrMatchers, this, defaultSimilarity, requiredScorers);
 		}
 		
 		private Scorer DualConjunctionSumScorer(Scorer req1, Scorer req2)
 		{
 			// non counting. 
-			int requiredNrMatchers = requiredScorers.Count;
-			ConjunctionScorer cs = new ConjunctionScorer(defaultSimilarity);
-			// All scorers match, so defaultSimilarity super.score() always has 1 as
+			return new ConjunctionScorer(defaultSimilarity, new Scorer[]{req1, req2});
+			// All scorers match, so defaultSimilarity always has 1 as
 			// the coordination factor.
 			// Therefore the sum of the scores of two scorers
 			// is used as score.
-			cs.Add(req1);
-			cs.Add(req2);
-			return cs;
 		}
 		
 		/// <summary>Returns the scorer to be used for match counting and score summing.
@@ -317,7 +334,7 @@
 		private Scorer MakeCountingSumScorer()
 		{
 			// each scorer counted as a single matcher
-			return (requiredScorers.Count == 0)?MakeCountingSumScorerNoReq():MakeCountingSumScorerSomeReq();
+			return (requiredScorers.Count == 0) ? MakeCountingSumScorerNoReq() : MakeCountingSumScorerSomeReq();
 		}
 		
 		private Scorer MakeCountingSumScorerNoReq()
@@ -331,7 +348,7 @@
 			{
 				// No required scorers. At least one optional scorer.
 				// minNrShouldMatch optional scorers are required, but at least 1
-				int nrOptRequired = (minNrShouldMatch < 1)?1:minNrShouldMatch;
+				int nrOptRequired = (minNrShouldMatch < 1) ? 1 : minNrShouldMatch;
 				if (optionalScorers.Count < nrOptRequired)
 				{
 					return new NonMatchingScorer(); // fewer optional clauses than minimum (at least 1) that should match
@@ -339,7 +356,7 @@
 				else
 				{
 					// optionalScorers.size() >= nrOptRequired, no required scorers
-					Scorer requiredCountingSumScorer = (optionalScorers.Count > nrOptRequired)?countingDisjunctionSumScorer(optionalScorers, nrOptRequired):((optionalScorers.Count == 1)?new SingleMatchScorer(this, (Scorer) optionalScorers[0]):countingConjunctionSumScorer(optionalScorers));
+					Scorer requiredCountingSumScorer = (optionalScorers.Count > nrOptRequired) ? countingDisjunctionSumScorer(optionalScorers, nrOptRequired) : ((optionalScorers.Count == 1) ? new SingleMatchScorer(this, (Scorer) optionalScorers[0]) : CountingConjunctionSumScorer(optionalScorers));
 					return AddProhibitedScorers(requiredCountingSumScorer);
 				}
 			}
@@ -357,12 +374,12 @@
 				// all optional scorers also required.
 				System.Collections.ArrayList allReq = new System.Collections.ArrayList(requiredScorers);
 				allReq.AddRange(optionalScorers);
-				return AddProhibitedScorers(countingConjunctionSumScorer(allReq));
+				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, (Scorer) requiredScorers[0]) : CountingConjunctionSumScorer(requiredScorers);
 				if (minNrShouldMatch > 0)
 				{
 					// use a required disjunction scorer over the optional scorers
@@ -393,13 +410,32 @@
 		/// </param>
 		public override void  Score(HitCollector hc)
 		{
-			if (countingSumScorer == null)
+			if (allowDocsOutOfOrder && requiredScorers.Count == 0 && prohibitedScorers.Count < 32)
 			{
-				InitCountingSumScorer();
+				// fall back to BooleanScorer, scores documents somewhat out of order
+				BooleanScorer bs = new BooleanScorer(GetSimilarity(), minNrShouldMatch);
+				System.Collections.IEnumerator si = optionalScorers.GetEnumerator();
+				while (si.MoveNext())
+				{
+					bs.Add((Scorer) si.Current, false, false);
+				}
+				si = prohibitedScorers.GetEnumerator();
+				while (si.MoveNext())
+				{
+					bs.Add((Scorer) si.Current, false, true);
+				}
+				bs.Score(hc);
 			}
-			while (countingSumScorer.Next())
+			else
 			{
-				hc.Collect(countingSumScorer.Doc(), Score());
+				if (countingSumScorer == null)
+				{
+					InitCountingSumScorer();
+				}
+				while (countingSumScorer.Next())
+				{
+					hc.Collect(countingSumScorer.Doc(), Score());
+				}
 			}
 		}
 		

Added: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/CachingSpanFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/CachingSpanFilter.cs?rev=671402&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/CachingSpanFilter.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/CachingSpanFilter.cs Tue Jun 24 19:51:24 2008
@@ -0,0 +1,97 @@
+/*
+ * 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 System;
+
+using System.Runtime.InteropServices;
+using IndexReader = Lucene.Net.Index.IndexReader;
+
+namespace Lucene.Net.Search
+{
+	
+	/// <summary> Wraps another SpanFilter's result and caches it.  The purpose is to allow
+	/// filters to simply filter, and then wrap with this class to add caching.
+	/// </summary>
+	[Serializable]
+	public class CachingSpanFilter : SpanFilter
+	{
+		protected internal SpanFilter filter;
+		
+		/// <summary> A transient Filter cache.  To cache Filters even when using {@link Lucene.Net.Search.RemoteSearchable} use
+		/// {@link Lucene.Net.Search.RemoteCachingWrapperFilter} instead.
+		/// </summary>
+		[NonSerialized]
+		protected internal System.Collections.IDictionary cache;
+		
+		/// <param name="filter">Filter to cache results of
+		/// </param>
+		public CachingSpanFilter(SpanFilter filter)
+		{
+			this.filter = filter;
+		}
+		
+		public override System.Collections.BitArray Bits(IndexReader reader)
+		{
+			SpanFilterResult result = GetCachedResult(reader);
+			return result != null ? result.GetBits() : null;
+		}
+		
+		private SpanFilterResult GetCachedResult(IndexReader reader)
+		{
+			SpanFilterResult result = null;
+			if (cache == null)
+			{
+				cache = new System.Collections.Hashtable();
+			}
+			
+			lock (cache.SyncRoot)
+			{
+				// check cache
+				result = (SpanFilterResult) cache[reader];
+				if (result == null)
+				{
+					result = filter.BitSpans(reader);
+					cache[reader] = result;
+				}
+			}
+			return result;
+		}
+		
+		
+		public override SpanFilterResult BitSpans(IndexReader reader)
+		{
+			return GetCachedResult(reader);
+		}
+		
+		public override System.String ToString()
+		{
+			return "CachingSpanFilter(" + filter + ")";
+		}
+		
+		public  override bool Equals(System.Object o)
+		{
+			if (!(o is CachingSpanFilter))
+				return false;
+			return this.filter.Equals(((CachingSpanFilter) o).filter);
+		}
+		
+		public override int GetHashCode()
+		{
+			return filter.GetHashCode() ^ 0x1117BF25;
+		}
+	}
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/CachingWrapperFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/CachingWrapperFilter.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/CachingWrapperFilter.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/CachingWrapperFilter.cs Tue Jun 24 19:51:24 2008
@@ -23,21 +23,19 @@
 namespace Lucene.Net.Search
 {
 	
-	/// <summary> Wraps another filter's result and caches it.  The caching
-	/// behavior is like {@link QueryFilter}.  The purpose is to allow
-	/// filters to simply filter, and then wrap with this class to add
-	/// caching, keeping the two concerns decoupled yet composable.
+	/// <summary> Wraps another filter's result and caches it.  The purpose is to allow
+	/// filters to simply filter, and then wrap with this class to add caching.
 	/// </summary>
 	[Serializable]
 	public class CachingWrapperFilter : Filter
 	{
-		private Filter filter;
+		protected internal Filter filter;
 		
-		/// <todo>  What about serialization in RemoteSearchable?  Caching won't work. </todo>
-		/// <summary>       Should transient be removed?
+		/// <summary> A transient Filter cache.  To cache Filters even when using {@link RemoteSearchable} use
+		/// {@link RemoteCachingWrapperFilter} instead.
 		/// </summary>
 		[NonSerialized]
-		private System.Collections.IDictionary cache;
+		protected internal System.Collections.IDictionary cache;
 		
 		/// <param name="filter">Filter to cache results of
 		/// </param>

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ComplexExplanation.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/ComplexExplanation.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ComplexExplanation.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ComplexExplanation.cs Tue Jun 24 19:51:24 2008
@@ -59,7 +59,7 @@
 		/// uses it; otherwise it defers to the superclass.
 		/// </p>
 		/// </summary>
-		/// <seealso cref="#GetMatch">
+		/// <seealso cref="GetMatch">
 		/// </seealso>
 		public override bool IsMatch()
 		{
@@ -69,7 +69,7 @@
 		
 		protected internal override System.String GetSummary()
 		{
-			if (isMatchSet == false)
+            if (isMatchSet == false)
 				return base.GetSummary();
 			
 			return GetValue() + " = " + (IsMatch() ? "(MATCH) " : "(NON-MATCH) ") + GetDescription();

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ConjunctionScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/ConjunctionScorer.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ConjunctionScorer.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ConjunctionScorer.cs Tue Jun 24 19:51:24 2008
@@ -48,133 +48,107 @@
 				return ((Scorer) o1).Doc() - ((Scorer) o2).Doc();
 			}
 		}
-		private Scorer[] scorers = new Scorer[2];
-		private int length = 0;
-		private int first = 0;
-		private int last = - 1;
+		private Scorer[] scorers;
+		
 		private bool firstTime = true;
-		private bool more = true;
+		private bool more;
 		private float coord;
+		private int lastDoc = - 1;
 		
-		public ConjunctionScorer(Similarity similarity):base(similarity)
+		public ConjunctionScorer(Similarity similarity, System.Collections.ICollection scorers) : this(similarity, (Scorer[]) new System.Collections.ArrayList(scorers).ToArray(typeof(Scorer)))
 		{
 		}
 		
-		internal void  Add(Scorer scorer)
+		public ConjunctionScorer(Similarity similarity, Scorer[] scorers):base(similarity)
 		{
-			if (length >= scorers.Length)
-			{
-				// grow the array
-				Scorer[] temps = new Scorer[scorers.Length * 2];
-				Array.Copy(scorers, 0, temps, 0, length);
-				scorers = temps;
-			}
-			last += 1;
-			length += 1;
-			scorers[last] = scorer;
+			this.scorers = scorers;
+			coord = GetSimilarity().Coord(this.scorers.Length, this.scorers.Length);
 		}
 		
 		public override int Doc()
 		{
-			return scorers[first].Doc();
+			return lastDoc;
 		}
 		
 		public override bool Next()
 		{
 			if (firstTime)
-			{
-				Init(true);
-			}
+				return Init(0);
 			else if (more)
-			{
-				more = scorers[last].Next(); // trigger further scanning
-			}
+				more = scorers[(scorers.Length - 1)].Next();
 			return DoNext();
 		}
 		
 		private bool DoNext()
 		{
-			while (more && scorers[first].Doc() < scorers[last].Doc())
-			{
-				// find doc w/ all clauses
-				more = scorers[first].SkipTo(scorers[last].Doc()); // skip first upto last
-				last = first; // move first to last
-				first = (first == length - 1) ? 0 : first + 1;
+			int first = 0;
+			Scorer lastScorer = scorers[scorers.Length - 1];
+			Scorer firstScorer;
+			while (more && (firstScorer = scorers[first]).Doc() < (lastDoc = lastScorer.Doc()))
+			{
+				more = firstScorer.SkipTo(lastDoc);
+				lastScorer = firstScorer;
+				first = (first == (scorers.Length - 1)) ? 0 : first + 1;
 			}
-			return more; // found a doc with all clauses
+			return more;
 		}
 		
 		public override bool SkipTo(int target)
 		{
 			if (firstTime)
-			{
-				Init(false);
-			}
-			
-			for (int i = 0, pos = first; i < length; i++)
-			{
-				if (!more)
-					break;
-				more = scorers[pos].SkipTo(target);
-				pos = (pos == length - 1) ? 0 : pos + 1;
-			}
-			
-			if (more)
-				SortScorers(); // re-sort scorers
-			
+				return Init(target);
+			else if (more)
+				more = scorers[(scorers.Length - 1)].SkipTo(target);
 			return DoNext();
 		}
 		
-		public override float Score()
+		// Note... most of this could be done in the constructor
+		// thus skipping a check for firstTime per call to next() and skipTo()
+		private bool Init(int target)
 		{
-			float sum = 0.0f;
-			for (int i = 0; i < length; i++)
+			firstTime = false;
+			more = scorers.Length > 1;
+			for (int i = 0; i < scorers.Length; i++)
 			{
-				sum += scorers[i].Score();
+				more = target == 0 ? scorers[i].Next() : scorers[i].SkipTo(target);
+				if (!more)
+					return false;
 			}
-			return sum * coord;
-		}
-		
-		private void  Init(bool initScorers)
-		{
-			//  compute coord factor
-			coord = GetSimilarity().Coord(length, length);
 			
-			more = length > 0;
+			// Sort the array the first time...
+			// We don't need to sort the array in any future calls because we know
+			// it will already start off sorted (all scorers on same doc).
 			
-			if (initScorers)
-			{
-				// move each scorer to its first entry
-				for (int i = 0, pos = first; i < length; i++)
-				{
-					if (!more)
-						break;
-					more = scorers[pos].Next();
-					pos = (pos == length - 1) ? 0 : pos + 1;
-				}
-				// initial sort of simulated list
-				if (more)
-					SortScorers();
+			// note that this comparator is not consistent with equals!
+			System.Array.Sort(scorers, new AnonymousClassComparator(this));
+			
+			DoNext();
+			
+			// If first-time skip distance is any predictor of
+			// scorer sparseness, then we should always try to skip first on
+			// those scorers.
+			// Keep last scorer in it's last place (it will be the first
+			// to be skipped on), but reverse all of the others so that
+			// they will be skipped on in order of original high skip.
+			int end = (scorers.Length - 1) - 1;
+			for (int i = 0; i < (end >> 1); i++)
+			{
+				Scorer tmp = scorers[i];
+				scorers[i] = scorers[end - i];
+				scorers[end - i] = tmp;
 			}
 			
-			firstTime = false;
+			return more;
 		}
 		
-		private void  SortScorers()
+		public override float Score()
 		{
-			// squeeze the array down for the sort
-			if (length != scorers.Length)
+			float sum = 0.0f;
+			for (int i = 0; i < scorers.Length; i++)
 			{
-				Scorer[] temps = new Scorer[length];
-				Array.Copy(scorers, 0, temps, 0, length);
-				scorers = temps;
+				sum += scorers[i].Score();
 			}
-			
-			// note that this comparator is not consistent with equals!
-			System.Array.Sort(scorers, new AnonymousClassComparator(this));
-			
-			first = 0;
-			last = length - 1;
+			return sum * coord;
 		}
 		
 		public override Explanation Explain(int doc)

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ConstantScoreQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/ConstantScoreQuery.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ConstantScoreQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ConstantScoreQuery.cs Tue Jun 24 19:51:24 2008
@@ -25,10 +25,9 @@
 	/// <summary> A query that wraps a filter and simply returns a constant score equal to the
 	/// query boost for every document in the filter.
 	/// 
+	/// 
 	/// </summary>
-	/// <author>  yonik
-	/// </author>
-	/// <version>  $Id: ConstantScoreQuery.java 507374 2007-02-14 03:12:50Z yonik $
+	/// <version>  $Id: ConstantScoreQuery.java 564236 2007-08-09 15:21:19Z gsingers $
 	/// </version>
 	[Serializable]
 	public class ConstantScoreQuery : Query

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ConstantScoreRangeQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/ConstantScoreRangeQuery.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ConstantScoreRangeQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ConstantScoreRangeQuery.cs Tue Jun 24 19:51:24 2008
@@ -31,10 +31,9 @@
 	/// Either or both endpoints may be open.  Open endpoints may not be exclusive
 	/// (you can't select all but the first or last term without explicitly specifying the term to exclude.)
 	/// 
+	/// 
 	/// </summary>
-	/// <author>  yonik
-	/// </author>
-	/// <version>  $Id: ConstantScoreRangeQuery.java 472959 2006-11-09 16:21:50Z yonik $
+	/// <version>  $Id: ConstantScoreRangeQuery.java 564236 2007-08-09 15:21:19Z gsingers $
 	/// </version>
 	
 	[Serializable]

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/DisjunctionMaxQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/DisjunctionMaxQuery.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/DisjunctionMaxQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/DisjunctionMaxQuery.cs Tue Jun 24 19:51:24 2008
@@ -108,15 +108,15 @@
 				}
 				
 			}
-			
-			private Searcher searcher; // The searcher with which we are associated.
+
+			private Similarity similarity;
 			private System.Collections.ArrayList weights = new System.Collections.ArrayList(); // The Weight's for our subqueries, in 1-1 correspondence with disjuncts
 			
 			/* Construct the Weight for this Query searched by searcher.  Recursively construct subquery weights. */
 			public DisjunctionMaxWeight(DisjunctionMaxQuery enclosingInstance, Searcher searcher)
 			{
 				InitBlock(enclosingInstance);
-				this.searcher = searcher;
+				this.similarity = searcher.GetSimilarity();
 				for (int i = 0; i < Enclosing_Instance.disjuncts.Count; i++)
 					weights.Add(((Query) Enclosing_Instance.disjuncts[i]).CreateWeight(searcher));
 			}
@@ -157,7 +157,7 @@
 			/* Create the scorer used to score our associated DisjunctionMaxQuery */
 			public virtual Scorer Scorer(IndexReader reader)
 			{
-				DisjunctionMaxScorer result = new DisjunctionMaxScorer(Enclosing_Instance.tieBreakerMultiplier, Enclosing_Instance.GetSimilarity(searcher));
+				DisjunctionMaxScorer result = new DisjunctionMaxScorer(Enclosing_Instance.tieBreakerMultiplier, similarity);
 				for (int i = 0; i < weights.Count; i++)
 				{
 					Weight w = (Weight) weights[i];

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/DisjunctionMaxScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/DisjunctionMaxScorer.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/DisjunctionMaxScorer.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/DisjunctionMaxScorer.cs Tue Jun 24 19:51:24 2008
@@ -139,7 +139,6 @@
 					return false;
 				Heapify();
 				firstTime = false;
-				return true; // more would have been false if no subScorers had any docs
 			}
 			
 			while (subScorers.Count > 0 && ((Scorer) subScorers[0]).Doc() < target)

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ExactPhraseScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/ExactPhraseScorer.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ExactPhraseScorer.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ExactPhraseScorer.cs Tue Jun 24 19:51:24 2008
@@ -25,13 +25,14 @@
 	sealed class ExactPhraseScorer : PhraseScorer
 	{
 		
-		internal ExactPhraseScorer(Weight weight, TermPositions[] tps, int[] positions, Similarity similarity, byte[] norms) : base(weight, tps, positions, similarity, norms)
+		internal ExactPhraseScorer(Weight weight, TermPositions[] tps, int[] offsets, Similarity similarity, byte[] norms) : base(weight, tps, offsets, similarity, norms)
 		{
 		}
 		
 		protected internal override float PhraseFreq()
 		{
 			// sort list with pq
+			pq.Clear();
 			for (PhrasePositions pp = first; pp != null; pp = pp.next)
 			{
 				pp.FirstPosition();
@@ -39,6 +40,8 @@
 			}
 			PqToList(); // rebuild list from pq
 			
+			// for counting how many times the exact phrase is found in current document,
+			// just count how many times all PhrasePosition's have exactly the same position.   
 			int freq = 0;
 			do 
 			{

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Explanation.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/Explanation.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Explanation.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/Explanation.cs Tue Jun 24 19:51:24 2008
@@ -38,13 +38,13 @@
 			this.description = description;
 		}
 		
-		/// <summary> Indicates wether or not this Explanation models a good match.
+		/// <summary> Indicates whether or not this Explanation models a good match.
 		/// 
 		/// <p>
 		/// By default, an Explanation represents a "match" if the value is positive.
 		/// </p>
 		/// </summary>
-		/// <seealso cref="#getValue">
+		/// <seealso cref="GetValue">
 		/// </seealso>
 		public virtual bool IsMatch()
 		{

Added: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ExtendedFieldCache.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/ExtendedFieldCache.cs?rev=671402&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ExtendedFieldCache.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ExtendedFieldCache.cs Tue Jun 24 19:51:24 2008
@@ -0,0 +1,116 @@
+/*
+ * 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 System;
+
+using IndexReader = Lucene.Net.Index.IndexReader;
+
+namespace Lucene.Net.Search
+{
+	
+	
+	/// <summary> 
+	/// 
+	/// 
+	/// </summary>
+	public struct ExtendedFieldCache_Fields{
+		public readonly static ExtendedFieldCache EXT_DEFAULT;
+		static ExtendedFieldCache_Fields()
+		{
+			EXT_DEFAULT = new ExtendedFieldCacheImpl();
+		}
+	}
+	public interface ExtendedFieldCache : FieldCache
+	{
+		/// <summary> Checks the internal cache for an appropriate entry, and if none is
+		/// found, reads the terms in <code>field</code> as longs and returns an array
+		/// of size <code>reader.maxDoc()</code> of the value each document
+		/// has in the given field.
+		/// 
+		/// </summary>
+		/// <param name="reader">Used to get field values.
+		/// </param>
+		/// <param name="field"> Which field contains the longs.
+		/// </param>
+		/// <returns> The values in the given field for each document.
+		/// </returns>
+		/// <throws>  java.io.IOException If any error occurs. </throws>
+		long[] GetLongs(IndexReader reader, System.String field);
+		
+		/// <summary> Checks the internal cache for an appropriate entry, and if none is found,
+		/// reads the terms in <code>field</code> as longs and returns an array of
+		/// size <code>reader.maxDoc()</code> of the value each document has in the
+		/// given field.
+		/// 
+		/// </summary>
+		/// <param name="reader">Used to get field values.
+		/// </param>
+		/// <param name="field"> Which field contains the longs.
+		/// </param>
+		/// <param name="parser">Computes integer for string values.
+		/// </param>
+		/// <returns> The values in the given field for each document.
+		/// </returns>
+		/// <throws>  IOException If any error occurs. </throws>
+		long[] GetLongs(IndexReader reader, System.String field, LongParser parser);
+		
+		
+		/// <summary> Checks the internal cache for an appropriate entry, and if none is
+		/// found, reads the terms in <code>field</code> as integers and returns an array
+		/// of size <code>reader.maxDoc()</code> of the value each document
+		/// has in the given field.
+		/// 
+		/// </summary>
+		/// <param name="reader">Used to get field values.
+		/// </param>
+		/// <param name="field"> Which field contains the doubles.
+		/// </param>
+		/// <returns> The values in the given field for each document.
+		/// </returns>
+		/// <throws>  IOException If any error occurs. </throws>
+		double[] GetDoubles(IndexReader reader, System.String field);
+		
+		/// <summary> Checks the internal cache for an appropriate entry, and if none is found,
+		/// reads the terms in <code>field</code> as doubles and returns an array of
+		/// size <code>reader.maxDoc()</code> of the value each document has in the
+		/// given field.
+		/// 
+		/// </summary>
+		/// <param name="reader">Used to get field values.
+		/// </param>
+		/// <param name="field"> Which field contains the doubles.
+		/// </param>
+		/// <param name="parser">Computes integer for string values.
+		/// </param>
+		/// <returns> The values in the given field for each document.
+		/// </returns>
+		/// <throws>  IOException If any error occurs. </throws>
+		double[] GetDoubles(IndexReader reader, System.String field, DoubleParser parser);
+	}
+	
+	public interface LongParser
+	{
+		/// <summary> Return an long representation of this field's value.</summary>
+		long ParseLong(System.String string_Renamed);
+	}
+	
+	public interface DoubleParser
+	{
+		/// <summary> Return an long representation of this field's value.</summary>
+		double ParseDouble(System.String string_Renamed);
+	}
+}
\ No newline at end of file

Added: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ExtendedFieldCacheImpl.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/ExtendedFieldCacheImpl.cs?rev=671402&view=auto
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ExtendedFieldCacheImpl.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ExtendedFieldCacheImpl.cs Tue Jun 24 19:51:24 2008
@@ -0,0 +1,297 @@
+/*
+ * 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 System;
+
+using IndexReader = Lucene.Net.Index.IndexReader;
+using Term = Lucene.Net.Index.Term;
+using TermDocs = Lucene.Net.Index.TermDocs;
+using TermEnum = Lucene.Net.Index.TermEnum;
+
+namespace Lucene.Net.Search
+{
+	
+	
+	/// <summary> 
+	/// 
+	/// 
+	/// </summary>
+	class ExtendedFieldCacheImpl : FieldCacheImpl, ExtendedFieldCache
+	{
+		public ExtendedFieldCacheImpl()
+		{
+			InitBlock();
+		}
+		public class AnonymousClassLongParser : LongParser
+		{
+			public virtual long ParseLong(System.String value_Renamed)
+			{
+				return System.Int64.Parse(value_Renamed);
+			}
+		}
+		public class AnonymousClassDoubleParser : DoubleParser
+		{
+			public virtual double ParseDouble(System.String value_Renamed)
+			{
+				return System.Double.Parse(value_Renamed);
+			}
+		}
+		
+		new internal class AnonymousClassCache : Cache
+		{
+			public AnonymousClassCache(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			{
+				InitBlock(enclosingInstance);
+			}
+			private void  InitBlock(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			{
+				this.enclosingInstance = enclosingInstance;
+			}
+			private Lucene.Net.Search.FieldCacheImpl enclosingInstance;
+			public Lucene.Net.Search.FieldCacheImpl Enclosing_Instance
+			{
+				get
+				{
+					return enclosingInstance;
+				}
+				
+			}
+			
+			protected internal override System.Object CreateValue(IndexReader reader, System.Object entryKey)
+			{
+				Entry entry = (Entry) entryKey;
+				System.String field = entry.field;
+				LongParser parser = (LongParser) entry.custom;
+				long[] retArray = new long[reader.MaxDoc()];
+				TermDocs termDocs = reader.TermDocs();
+				TermEnum termEnum = reader.Terms(new Term(field, ""));
+				try
+				{
+					do 
+					{
+						Term term = termEnum.Term();
+						if (term == null || (System.Object) term.Field() != (System.Object) field)
+							break;
+						long termval = parser.ParseLong(term.Text());
+						termDocs.Seek(termEnum);
+						while (termDocs.Next())
+						{
+							retArray[termDocs.Doc()] = termval;
+						}
+					}
+					while (termEnum.Next());
+				}
+				finally
+				{
+					termDocs.Close();
+					termEnum.Close();
+				}
+				return retArray;
+			}
+		}
+		
+		new internal class AnonymousClassCache1:Cache
+		{
+			public AnonymousClassCache1(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			{
+				InitBlock(enclosingInstance);
+			}
+			private void  InitBlock(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			{
+				this.enclosingInstance = enclosingInstance;
+			}
+			private Lucene.Net.Search.FieldCacheImpl enclosingInstance;
+			public Lucene.Net.Search.FieldCacheImpl Enclosing_Instance
+			{
+				get
+				{
+					return enclosingInstance;
+				}
+				
+			}
+			
+			protected internal override System.Object CreateValue(IndexReader reader, System.Object entryKey)
+			{
+				Entry entry = (Entry) entryKey;
+				System.String field = entry.field;
+				DoubleParser parser = (DoubleParser) entry.custom;
+				double[] retArray = new double[reader.MaxDoc()];
+				TermDocs termDocs = reader.TermDocs();
+				TermEnum termEnum = reader.Terms(new Term(field, ""));
+				try
+				{
+					do 
+					{
+						Term term = termEnum.Term();
+						if (term == null || (System.Object) term.Field() != (System.Object) field)
+							break;
+						double termval = parser.ParseDouble(term.Text());
+						termDocs.Seek(termEnum);
+						while (termDocs.Next())
+						{
+							retArray[termDocs.Doc()] = termval;
+						}
+					}
+					while (termEnum.Next());
+				}
+				finally
+				{
+					termDocs.Close();
+					termEnum.Close();
+				}
+				return retArray;
+			}
+		}
+		
+		new internal class AnonymousClassCache2:Cache
+		{
+			public AnonymousClassCache2(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			{
+				InitBlock(enclosingInstance);
+			}
+			private void  InitBlock(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			{
+				this.enclosingInstance = enclosingInstance;
+			}
+			private Lucene.Net.Search.FieldCacheImpl enclosingInstance;
+			public Lucene.Net.Search.FieldCacheImpl Enclosing_Instance
+			{
+				get
+				{
+					return enclosingInstance;
+				}
+				
+			}
+			
+			protected internal override System.Object CreateValue(IndexReader reader, System.Object fieldKey)
+			{
+				System.String field = String.Intern(((System.String) fieldKey));
+				TermEnum enumerator = reader.Terms(new Term(field, ""));
+				try
+				{
+					Term term = enumerator.Term();
+					if (term == null)
+					{
+						throw new System.SystemException("no terms in field " + field + " - cannot determine sort type");
+					}
+					System.Object ret = null;
+					if ((System.Object) term.Field() == (System.Object) field)
+					{
+						System.String termtext = term.Text().Trim();
+						
+						/**
+						* Java 1.4 level code:
+						
+						if (pIntegers.matcher(termtext).matches())
+						return IntegerSortedHitQueue.comparator (reader, enumerator, field);
+						
+						else if (pFloats.matcher(termtext).matches())
+						return FloatSortedHitQueue.comparator (reader, enumerator, field);
+						*/
+						
+						// Java 1.3 level code:
+						try
+						{
+							System.Int32.Parse(termtext);
+							ret = Enclosing_Instance.GetInts(reader, field);
+						}
+						catch (System.FormatException nfe1)
+						{
+							try
+							{
+								System.Int64.Parse(termtext);
+								ret = ((ExtendedFieldCacheImpl) Enclosing_Instance).GetLongs(reader, field);
+							}
+							catch (System.FormatException nfe2)
+							{
+								try
+								{
+									System.Single.Parse(termtext);
+									ret = Enclosing_Instance.GetFloats(reader, field);
+								}
+								catch (System.FormatException nfe3)
+								{
+									ret = Enclosing_Instance.GetStringIndex(reader, field);
+								}
+							}
+						}
+					}
+					else
+					{
+						throw new System.SystemException("field \"" + field + "\" does not appear to be indexed");
+					}
+					return ret;
+				}
+				finally
+				{
+					enumerator.Close();
+				}
+			}
+		}
+		private void  InitBlock()
+		{
+			longsCache = new AnonymousClassCache(this);
+			doublesCache = new AnonymousClassCache1(this);
+			autoCache = new AnonymousClassCache2(this);
+		}
+		private static readonly LongParser LONG_PARSER;
+		
+		private static readonly DoubleParser DOUBLE_PARSER;
+		
+		
+		public virtual long[] GetLongs(IndexReader reader, System.String field)
+		{
+			return GetLongs(reader, field, LONG_PARSER);
+		}
+		
+		// inherit javadocs
+		public virtual long[] GetLongs(IndexReader reader, System.String field, LongParser parser)
+		{
+			return (long[]) longsCache.Get(reader, new Entry(field, parser));
+		}
+		
+		internal Cache longsCache;
+		
+		// inherit javadocs
+		public virtual double[] GetDoubles(IndexReader reader, System.String field)
+		{
+			return GetDoubles(reader, field, DOUBLE_PARSER);
+		}
+		
+		// inherit javadocs
+		public virtual double[] GetDoubles(IndexReader reader, System.String field, DoubleParser parser)
+		{
+			return (double[]) doublesCache.Get(reader, new Entry(field, parser));
+		}
+		
+		internal Cache doublesCache;
+		
+		
+		// inherit javadocs
+		public override System.Object GetAuto(IndexReader reader, System.String field)
+		{
+			return autoCache.Get(reader, field);
+		}
+		
+		new internal Cache autoCache;
+		static ExtendedFieldCacheImpl()
+		{
+			LONG_PARSER = new AnonymousClassLongParser();
+			DOUBLE_PARSER = new AnonymousClassDoubleParser();
+		}
+	}
+}
\ No newline at end of file

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldCache.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/FieldCache.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldCache.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldCache.cs Tue Jun 24 19:51:24 2008
@@ -31,7 +31,7 @@
 	/// </author>
 	/// <since>   lucene 1.4
 	/// </since>
-	/// <version>  $Id: FieldCache.java 472959 2006-11-09 16:21:50Z yonik $
+	/// <version>  $Id: FieldCache.java 544546 2007-06-05 16:29:35Z doronc $
 	/// </version>
 	/// <summary>Expert: Stores term text values and document ordering data. </summary>
 	public class StringIndex
@@ -50,8 +50,7 @@
 			this.lookup = lookup;
 		}
 	}
-	public struct FieldCache_Fields
-    {
+	public struct FieldCache_Fields{
 		/// <summary>Indicator for StringIndex values in the cache. </summary>
 		// NOTE: the value assigned to this constant must not be
 		// the same as any of those in SortField!!
@@ -65,7 +64,66 @@
 	}
 	public interface FieldCache
 	{
-		void Close(IndexReader reader);
+		
+		/// <summary>Checks the internal cache for an appropriate entry, and if none is
+		/// found, reads the terms in <code>field</code> as a single byte and returns an array
+		/// of size <code>reader.maxDoc()</code> of the value each document
+		/// has in the given field.
+		/// </summary>
+		/// <param name="reader"> Used to get field values.
+		/// </param>
+		/// <param name="field">  Which field contains the single byte values.
+		/// </param>
+		/// <returns> The values in the given field for each document.
+		/// </returns>
+		/// <throws>  IOException  If any error occurs. </throws>
+		byte[] GetBytes(IndexReader reader, System.String field);
+		
+		/// <summary>Checks the internal cache for an appropriate entry, and if none is found,
+		/// reads the terms in <code>field</code> as bytes and returns an array of
+		/// size <code>reader.maxDoc()</code> of the value each document has in the
+		/// given field.
+		/// </summary>
+		/// <param name="reader"> Used to get field values.
+		/// </param>
+		/// <param name="field">  Which field contains the bytes.
+		/// </param>
+		/// <param name="parser"> Computes byte for string values.
+		/// </param>
+		/// <returns> The values in the given field for each document.
+		/// </returns>
+		/// <throws>  IOException  If any error occurs. </throws>
+		byte[] GetBytes(IndexReader reader, System.String field, ByteParser parser);
+		
+		/// <summary>Checks the internal cache for an appropriate entry, and if none is
+		/// found, reads the terms in <code>field</code> as shorts and returns an array
+		/// of size <code>reader.maxDoc()</code> of the value each document
+		/// has in the given field.
+		/// </summary>
+		/// <param name="reader"> Used to get field values.
+		/// </param>
+		/// <param name="field">  Which field contains the shorts.
+		/// </param>
+		/// <returns> The values in the given field for each document.
+		/// </returns>
+		/// <throws>  IOException  If any error occurs. </throws>
+		short[] GetShorts(IndexReader reader, System.String field);
+		
+		/// <summary>Checks the internal cache for an appropriate entry, and if none is found,
+		/// reads the terms in <code>field</code> as shorts and returns an array of
+		/// size <code>reader.maxDoc()</code> of the value each document has in the
+		/// given field.
+		/// </summary>
+		/// <param name="reader"> Used to get field values.
+		/// </param>
+		/// <param name="field">  Which field contains the shorts.
+		/// </param>
+		/// <param name="parser"> Computes short for string values.
+		/// </param>
+		/// <returns> The values in the given field for each document.
+		/// </returns>
+		/// <throws>  IOException  If any error occurs. </throws>
+		short[] GetShorts(IndexReader reader, System.String field, ShortParser parser);
 		
 		/// <summary>Checks the internal cache for an appropriate entry, and if none is
 		/// found, reads the terms in <code>field</code> as integers and returns an array
@@ -189,8 +247,26 @@
 		System.IComparable[] GetCustom(IndexReader reader, System.String field, SortComparator comparator);
 	}
 	
+	/// <summary>Interface to parse bytes from document fields.</summary>
+	/// <seealso cref="FieldCache.GetBytes(IndexReader, String, FieldCache.ByteParser)">
+	/// </seealso>
+	public interface ByteParser
+	{
+		/// <summary>Return a single Byte representation of this field's value. </summary>
+		byte ParseByte(System.String string_Renamed);
+	}
+	
+	/// <summary>Interface to parse shorts from document fields.</summary>
+	/// <seealso cref="FieldCache.GetShorts(IndexReader, String, FieldCache.ShortParser)">
+	/// </seealso>
+	public interface ShortParser
+	{
+		/// <summary>Return a short representation of this field's value. </summary>
+		short ParseShort(System.String string_Renamed);
+	}
+	
 	/// <summary>Interface to parse ints from document fields.</summary>
-	/// <seealso cref="String, IntParser)">
+	/// <seealso cref="FieldCache.GetInts(IndexReader, String, FieldCache.IntParser)">
 	/// </seealso>
 	public interface IntParser
 	{
@@ -199,7 +275,7 @@
 	}
 	
 	/// <summary>Interface to parse floats from document fields.</summary>
-	/// <seealso cref="String, FloatParser)">
+	/// <seealso cref="FieldCache.GetFloats(IndexReader, String, FieldCache.FloatParser)">
 	/// </seealso>
 	public interface FloatParser
 	{

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldCacheImpl.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/FieldCacheImpl.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldCacheImpl.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldCacheImpl.cs Tue Jun 24 19:51:24 2008
@@ -35,7 +35,7 @@
 	/// </author>
 	/// <since>   lucene 1.4
 	/// </since>
-	/// <version>  $Id: FieldCacheImpl.java 488908 2006-12-20 03:47:09Z yonik $
+	/// <version>  $Id: FieldCacheImpl.java 605225 2007-12-18 15:13:05Z gsingers $
 	/// </version>
 	class FieldCacheImpl : FieldCache
 	{
@@ -47,7 +47,20 @@
 		{
 			InitBlock();
 		}
-
+		public class AnonymousClassByteParser : ByteParser
+		{
+			public virtual byte ParseByte(System.String value_Renamed)
+			{
+				return (byte) System.Byte.Parse(value_Renamed);
+			}
+		}
+		public class AnonymousClassShortParser : ShortParser
+		{
+			public virtual short ParseShort(System.String value_Renamed)
+			{
+				return System.Int16.Parse(value_Renamed);
+			}
+		}
 		public class AnonymousClassIntParser : IntParser
 		{
 			public virtual int ParseInt(System.String value_Renamed)
@@ -55,12 +68,11 @@
 				return System.Int32.Parse(value_Renamed);
 			}
 		}
-
 		public class AnonymousClassFloatParser : FloatParser
 		{
 			public virtual float ParseFloat(System.String value_Renamed)
 			{
-                return SupportClass.Single.Parse(value_Renamed);
+				return System.Single.Parse(value_Renamed);
 			}
 		}
 		
@@ -88,6 +100,112 @@
 			{
 				Entry entry = (Entry) entryKey;
 				System.String field = entry.field;
+				ByteParser parser = (ByteParser) entry.custom;
+				byte[] retArray = new byte[reader.MaxDoc()];
+				TermDocs termDocs = reader.TermDocs();
+				TermEnum termEnum = reader.Terms(new Term(field, ""));
+				try
+				{
+					do 
+					{
+						Term term = termEnum.Term();
+						if (term == null || (System.Object) term.Field() != (System.Object) field)
+							break;
+						byte termval = parser.ParseByte(term.Text());
+						termDocs.Seek(termEnum);
+						while (termDocs.Next())
+						{
+							retArray[termDocs.Doc()] = termval;
+						}
+					}
+					while (termEnum.Next());
+				}
+				finally
+				{
+					termDocs.Close();
+					termEnum.Close();
+				}
+				return retArray;
+			}
+		}
+		
+		internal class AnonymousClassCache1 : Cache
+		{
+			public AnonymousClassCache1(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			{
+				InitBlock(enclosingInstance);
+			}
+			private void  InitBlock(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			{
+				this.enclosingInstance = enclosingInstance;
+			}
+			private Lucene.Net.Search.FieldCacheImpl enclosingInstance;
+			public Lucene.Net.Search.FieldCacheImpl Enclosing_Instance
+			{
+				get
+				{
+					return enclosingInstance;
+				}
+				
+			}
+			
+			protected internal override System.Object CreateValue(IndexReader reader, System.Object entryKey)
+			{
+				Entry entry = (Entry) entryKey;
+				System.String field = entry.field;
+				ShortParser parser = (ShortParser) entry.custom;
+				short[] retArray = new short[reader.MaxDoc()];
+				TermDocs termDocs = reader.TermDocs();
+				TermEnum termEnum = reader.Terms(new Term(field, ""));
+				try
+				{
+					do 
+					{
+						Term term = termEnum.Term();
+						if (term == null || (System.Object) term.Field() != (System.Object) field)
+							break;
+						short termval = parser.ParseShort(term.Text());
+						termDocs.Seek(termEnum);
+						while (termDocs.Next())
+						{
+							retArray[termDocs.Doc()] = termval;
+						}
+					}
+					while (termEnum.Next());
+				}
+				finally
+				{
+					termDocs.Close();
+					termEnum.Close();
+				}
+				return retArray;
+			}
+		}
+		
+		internal class AnonymousClassCache2 : Cache
+		{
+			public AnonymousClassCache2(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			{
+				InitBlock(enclosingInstance);
+			}
+			private void  InitBlock(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			{
+				this.enclosingInstance = enclosingInstance;
+			}
+			private Lucene.Net.Search.FieldCacheImpl enclosingInstance;
+			public Lucene.Net.Search.FieldCacheImpl Enclosing_Instance
+			{
+				get
+				{
+					return enclosingInstance;
+				}
+				
+			}
+			
+			protected internal override System.Object CreateValue(IndexReader reader, System.Object entryKey)
+			{
+				Entry entry = (Entry) entryKey;
+				System.String field = entry.field;
 				IntParser parser = (IntParser) entry.custom;
 				int[] retArray = new int[reader.MaxDoc()];
 				TermDocs termDocs = reader.TermDocs();
@@ -117,9 +235,9 @@
 			}
 		}
 		
-		internal class AnonymousClassCache1:Cache
+		internal class AnonymousClassCache3 : Cache
 		{
-			public AnonymousClassCache1(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			public AnonymousClassCache3(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
 			{
 				InitBlock(enclosingInstance);
 			}
@@ -170,9 +288,9 @@
 			}
 		}
 		
-		internal class AnonymousClassCache2 : Cache
+		internal class AnonymousClassCache4 : Cache
 		{
-			public AnonymousClassCache2(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			public AnonymousClassCache4(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
 			{
 				InitBlock(enclosingInstance);
 			}
@@ -221,9 +339,9 @@
 			}
 		}
 		
-		internal class AnonymousClassCache3 : Cache
+		internal class AnonymousClassCache5 : Cache
 		{
-			public AnonymousClassCache3(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			public AnonymousClassCache5(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
 			{
 				InitBlock(enclosingInstance);
 			}
@@ -306,9 +424,9 @@
 			}
 		}
 		
-		internal class AnonymousClassCache4 : Cache
+		internal class AnonymousClassCache6 : Cache
 		{
-			public AnonymousClassCache4(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			public AnonymousClassCache6(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
 			{
 				InitBlock(enclosingInstance);
 			}
@@ -342,12 +460,15 @@
 					{
 						System.String termtext = term.Text().Trim();
 						
-						/// <summary> Java 1.4 level code:
-						/// if (pIntegers.matcher(termtext).matches())
-						/// return IntegerSortedHitQueue.comparator (reader, enumerator, field);
-						/// else if (pFloats.matcher(termtext).matches())
-						/// return FloatSortedHitQueue.comparator (reader, enumerator, field);
-						/// </summary>
+						/**
+						* Java 1.4 level code:
+						
+						if (pIntegers.matcher(termtext).matches())
+						return IntegerSortedHitQueue.comparator (reader, enumerator, field);
+						
+						else if (pFloats.matcher(termtext).matches())
+						return FloatSortedHitQueue.comparator (reader, enumerator, field);
+						*/
 						
 						// Java 1.3 level code:
 						try
@@ -362,7 +483,7 @@
 								System.Single.Parse(termtext);
 								ret = Enclosing_Instance.GetFloats(reader, field);
 							}
-							catch (System.FormatException nfe2)
+							catch (System.FormatException nfe3)
 							{
 								ret = Enclosing_Instance.GetStringIndex(reader, field);
 							}
@@ -381,9 +502,9 @@
 			}
 		}
 		
-		internal class AnonymousClassCache5 : Cache
+		internal class AnonymousClassCache7 : Cache
 		{
-			public AnonymousClassCache5(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
+			public AnonymousClassCache7(Lucene.Net.Search.FieldCacheImpl enclosingInstance)
 			{
 				InitBlock(enclosingInstance);
 			}
@@ -435,12 +556,14 @@
 		}
 		private void  InitBlock()
 		{
-			intsCache = new AnonymousClassCache(this);
-			floatsCache = new AnonymousClassCache1(this);
-			stringsCache = new AnonymousClassCache2(this);
-			stringsIndexCache = new AnonymousClassCache3(this);
-			autoCache = new AnonymousClassCache4(this);
-			customCache = new AnonymousClassCache5(this);
+			bytesCache = new AnonymousClassCache(this);
+			shortsCache = new AnonymousClassCache1(this);
+			intsCache = new AnonymousClassCache2(this);
+			floatsCache = new AnonymousClassCache3(this);
+			stringsCache = new AnonymousClassCache4(this);
+			stringsIndexCache = new AnonymousClassCache5(this);
+			autoCache = new AnonymousClassCache6(this);
+			customCache = new AnonymousClassCache7(this);
 		}
 		
 		/// <summary>Expert: Internal cache. </summary>
@@ -532,7 +655,7 @@
 					Entry other = (Entry) o;
 					if ((System.Object) other.field == (System.Object) field && other.type == type)
 					{
-						if (other.locale == null?locale == null:other.locale.Equals(locale))
+						if (other.locale == null ? locale == null : other.locale.Equals(locale))
 						{
 							if (other.custom == null)
 							{
@@ -556,11 +679,44 @@
 			}
 		}
 		
+		private static readonly ByteParser BYTE_PARSER;
+		
+		private static readonly ShortParser SHORT_PARSER;
+		
 		private static readonly IntParser INT_PARSER;
 		
+		
 		private static readonly FloatParser FLOAT_PARSER;
 		
 		// inherit javadocs
+		public virtual byte[] GetBytes(IndexReader reader, System.String field)
+		{
+			return GetBytes(reader, field, BYTE_PARSER);
+		}
+		
+		// inherit javadocs
+		public virtual byte[] GetBytes(IndexReader reader, System.String field, ByteParser parser)
+		{
+			return (byte[]) bytesCache.Get(reader, new Entry(field, parser));
+		}
+		
+		internal Cache bytesCache;
+		
+		// inherit javadocs
+		public virtual short[] GetShorts(IndexReader reader, System.String field)
+		{
+			return GetShorts(reader, field, SHORT_PARSER);
+		}
+		
+		// inherit javadocs
+		public virtual short[] GetShorts(IndexReader reader, System.String field, ShortParser parser)
+		{
+			return (short[]) shortsCache.Get(reader, new Entry(field, parser));
+		}
+		
+		internal Cache shortsCache;
+		
+		// inherit javadocs
 		public virtual int[] GetInts(IndexReader reader, System.String field)
 		{
 			return GetInts(reader, field, INT_PARSER);
@@ -574,6 +730,7 @@
 		
 		internal Cache intsCache;
 		
+		
 		// inherit javadocs
 		public virtual float[] GetFloats(IndexReader reader, System.String field)
 		{
@@ -632,6 +789,8 @@
 		internal Cache customCache;
 		static FieldCacheImpl()
 		{
+			BYTE_PARSER = new AnonymousClassByteParser();
+			SHORT_PARSER = new AnonymousClassShortParser();
 			INT_PARSER = new AnonymousClassIntParser();
 			FLOAT_PARSER = new AnonymousClassFloatParser();
 		}

Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldDocSortedHitQueue.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/FieldDocSortedHitQueue.cs?rev=671402&r1=671401&r2=671402&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldDocSortedHitQueue.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/FieldDocSortedHitQueue.cs Tue Jun 24 19:51:24 2008
@@ -32,8 +32,8 @@
 	/// </author>
 	/// <since>   lucene 1.4
 	/// </since>
-	/// <version>  $Id: FieldDocSortedHitQueue.java 472959 2006-11-09 16:21:50Z yonik $
-	/// </version>
+    /// <version>  $Id: FieldDocSortedHitQueue.java 590530 2007-10-31 01:28:25Z gsingers $
+    /// </version>
 	class FieldDocSortedHitQueue : PriorityQueue
 	{
 		
@@ -128,68 +128,95 @@
 				switch (type)
 				{
 					
-					case SortField.SCORE: 
-						float r1 = (float) ((System.Single) docA.fields[i]);
-						float r2 = (float) ((System.Single) docB.fields[i]);
-						if (r1 > r2)
-							c = - 1;
-						if (r1 < r2)
-							c = 1;
-						break;
+					case SortField.SCORE:  {
+							float r1 = (float) ((System.Single) docA.fields[i]);
+							float r2 = (float) ((System.Single) docB.fields[i]);
+							if (r1 > r2)
+								c = - 1;
+							if (r1 < r2)
+								c = 1;
+							break;
+						}
 					
 					case SortField.DOC: 
-					case SortField.INT: 
-						int i1 = ((System.Int32) docA.fields[i]);
-						int i2 = ((System.Int32) docB.fields[i]);
-						if (i1 < i2)
-							c = - 1;
-						if (i1 > i2)
-							c = 1;
-						break;
-					
-					case SortField.STRING: 
-						System.String s1 = (System.String) docA.fields[i];
-						System.String s2 = (System.String) docB.fields[i];
-						// null values need to be sorted first, because of how FieldCache.getStringIndex()
-						// works - in that routine, any documents without a value in the given field are
-						// put first.  If both are null, the next SortField is used
-						if (s1 == null)
-							c = (s2 == null)?0:- 1;
-						else if (s2 == null)
-							c = 1;
-						// 
-						else if (fields[i].GetLocale() == null)
-						{
-							c = String.CompareOrdinal(s1, s2);
-						}
-						else
-						{
-							c = collators[i].Compare(s1.ToString(), s2.ToString());
-						}
-						break;
-					
-					case SortField.FLOAT: 
-						float f1 = (float) ((System.Single) docA.fields[i]);
-						float f2 = (float) ((System.Single) docB.fields[i]);
-						if (f1 < f2)
-							c = - 1;
-						if (f1 > f2)
-							c = 1;
-						break;
-					
-					case SortField.CUSTOM: 
-						c = docA.fields[i].CompareTo(docB.fields[i]);
-						break;
-					
-					case SortField.AUTO: 
-						// we cannot handle this - even if we determine the type of object (Float or
-						// Integer), we don't necessarily know how to compare them (both SCORE and
-						// FLOAT contain floats, but are sorted opposite of each other). Before
-						// we get here, each AUTO should have been replaced with its actual value.
-						throw new System.SystemException("FieldDocSortedHitQueue cannot use an AUTO SortField");
+					case SortField.INT:  {
+							int i1 = ((System.Int32) docA.fields[i]);
+							int i2 = ((System.Int32) docB.fields[i]);
+							if (i1 < i2)
+								c = - 1;
+							if (i1 > i2)
+								c = 1;
+							break;
+						}
+					
+					case SortField.LONG:  {
+							long l1 = (long) ((System.Int64) docA.fields[i]);
+							long l2 = (long) ((System.Int64) docB.fields[i]);
+							if (l1 < l2)
+								c = - 1;
+							if (l1 > l2)
+								c = 1;
+							break;
+						}
+					
+					case SortField.STRING:  {
+							System.String s1 = (System.String) docA.fields[i];
+							System.String s2 = (System.String) docB.fields[i];
+							// null values need to be sorted first, because of how FieldCache.getStringIndex()
+							// works - in that routine, any documents without a value in the given field are
+							// put first.  If both are null, the next SortField is used
+							if (s1 == null)
+								c = (s2 == null) ? 0 : - 1;
+							else if (s2 == null)
+								c = 1;
+							// 
+							else if (fields[i].GetLocale() == null)
+							{
+								c = String.CompareOrdinal(s1, s2);
+							}
+							else
+							{
+								c = collators[i].Compare(s1.ToString(), s2.ToString());
+							}
+							break;
+						}
+					
+					case SortField.FLOAT:  {
+							float f1 = (float) ((System.Single) docA.fields[i]);
+							float f2 = (float) ((System.Single) docB.fields[i]);
+							if (f1 < f2)
+								c = - 1;
+							if (f1 > f2)
+								c = 1;
+							break;
+						}
 					
-					default: 
-						throw new System.SystemException("invalid SortField type: " + type);
+					case SortField.DOUBLE:  {
+							double d1 = ((System.Double) docA.fields[i]);
+							double d2 = ((System.Double) docB.fields[i]);
+							if (d1 < d2)
+								c = - 1;
+							if (d1 > d2)
+								c = 1;
+							break;
+						}
+					
+					case SortField.CUSTOM:  {
+							c = docA.fields[i].CompareTo(docB.fields[i]);
+							break;
+						}
+					
+					case SortField.AUTO:  {
+							// we cannot handle this - even if we determine the type of object (Float or
+							// Integer), we don't necessarily know how to compare them (both SCORE and
+							// FLOAT contain floats, but are sorted opposite of each other). Before
+							// we get here, each AUTO should have been replaced with its actual value.
+							throw new System.SystemException("FieldDocSortedHitQueue cannot use an AUTO SortField");
+						}
+					
+					default:  {
+							throw new System.SystemException("invalid SortField type: " + type);
+						}
 					
 				}
 				if (fields[i].GetReverse())