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

[Lucene.Net] svn commit: r1203769 [2/4] - in /incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk: src/core/ src/core/Analysis/ src/core/Document/ src/core/Messages/ src/core/QueryParser/ src/core/Search/ src/core/Search/Function/ src/core/Search/Payloads/ src/cor...

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldComparator.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldComparator.cs?rev=1203769&r1=1203768&r2=1203769&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldComparator.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldComparator.cs Fri Nov 18 17:54:13 2011
@@ -82,7 +82,94 @@ namespace Lucene.Net.Search
 	/// </summary>
 	public abstract class FieldComparator
 	{
-		
+        /// <summary> Compare hit at slot1 with hit at slot2.
+        /// 
+        /// </summary>
+        /// <param name="slot1">first slot to compare
+        /// </param>
+        /// <param name="slot2">second slot to compare
+        /// </param>
+        /// <returns> any N &lt; 0 if slot2's value is sorted after
+        /// slot1, any N > 0 if the slot2's value is sorted before
+        /// slot1 and 0 if they are equal
+        /// </returns>
+        public abstract int Compare(int slot1, int slot2);
+
+        /// <summary> Set the bottom slot, ie the "weakest" (sorted last)
+        /// entry in the queue.  When <see cref="CompareBottom" /> is
+        /// called, you should compare against this slot.  This
+        /// will always be called before <see cref="CompareBottom" />.
+        /// 
+        /// </summary>
+        /// <param name="slot">the currently weakest (sorted last) slot in the queue
+        /// </param>
+        public abstract void SetBottom(int slot);
+
+        /// <summary> Compare the bottom of the queue with doc.  This will
+        /// only invoked after setBottom has been called.  This
+        /// should return the same result as <see cref="Compare(int,int)" />
+        ///} as if bottom were slot1 and the new
+        /// document were slot 2.
+        /// 
+        /// <p/>For a search that hits many results, this method
+        /// will be the hotspot (invoked by far the most
+        /// frequently).<p/>
+        /// 
+        /// </summary>
+        /// <param name="doc">that was hit
+        /// </param>
+        /// <returns> any N &lt; 0 if the doc's value is sorted after
+        /// the bottom entry (not competitive), any N > 0 if the
+        /// doc's value is sorted before the bottom entry and 0 if
+        /// they are equal.
+        /// </returns>
+        public abstract int CompareBottom(int doc);
+
+        /// <summary> This method is called when a new hit is competitive.
+        /// You should copy any state associated with this document
+        /// that will be required for future comparisons, into the
+        /// specified slot.
+        /// 
+        /// </summary>
+        /// <param name="slot">which slot to copy the hit to
+        /// </param>
+        /// <param name="doc">docID relative to current reader
+        /// </param>
+        public abstract void Copy(int slot, int doc);
+
+        /// <summary> Set a new Reader. All doc correspond to the current Reader.
+        /// 
+        /// </summary>
+        /// <param name="reader">current reader
+        /// </param>
+        /// <param name="docBase">docBase of this reader 
+        /// </param>
+        /// <throws>  IOException </throws>
+        /// <throws>  IOException </throws>
+        public abstract void SetNextReader(IndexReader reader, int docBase);
+
+        /// <summary>Sets the Scorer to use in case a document's score is
+        /// needed.
+        /// 
+        /// </summary>
+        /// <param name="scorer">Scorer instance that you should use to
+        /// obtain the current hit's score, if necessary. 
+        /// </param>
+        public virtual void SetScorer(Scorer scorer)
+        {
+            // Empty implementation since most comparators don't need the score. This
+            // can be overridden by those that need it.
+        }
+
+        /// <summary> Return the actual value in the slot.
+        /// 
+        /// </summary>
+        /// <param name="slot">the value
+        /// </param>
+        /// <returns> value in this slot upgraded to Comparable
+        /// </returns>
+        public abstract System.IComparable Value(int slot);
+
 		/// <summary>Parses field's values as byte (using <see cref="FieldCache.GetBytes(Lucene.Net.Index.IndexReader,string)" />
 		/// and sorts by ascending value 
 		/// </summary>
@@ -974,93 +1061,5 @@ namespace Lucene.Net.Search
 			}
 			return - (low + 1);
 		}
-		
-		/// <summary> Compare hit at slot1 with hit at slot2.
-		/// 
-		/// </summary>
-		/// <param name="slot1">first slot to compare
-		/// </param>
-		/// <param name="slot2">second slot to compare
-		/// </param>
-        /// <returns> any N &lt; 0 if slot2's value is sorted after
-		/// slot1, any N > 0 if the slot2's value is sorted before
-		/// slot1 and 0 if they are equal
-		/// </returns>
-		public abstract int Compare(int slot1, int slot2);
-		
-		/// <summary> Set the bottom slot, ie the "weakest" (sorted last)
-		/// entry in the queue.  When <see cref="CompareBottom" /> is
-		/// called, you should compare against this slot.  This
-		/// will always be called before <see cref="CompareBottom" />.
-		/// 
-		/// </summary>
-		/// <param name="slot">the currently weakest (sorted last) slot in the queue
-		/// </param>
-		public abstract void  SetBottom(int slot);
-		
-		/// <summary> Compare the bottom of the queue with doc.  This will
-		/// only invoked after setBottom has been called.  This
-		/// should return the same result as <see cref="Compare(int,int)" />
-		///} as if bottom were slot1 and the new
-		/// document were slot 2.
-		/// 
-		/// <p/>For a search that hits many results, this method
-		/// will be the hotspot (invoked by far the most
-		/// frequently).<p/>
-		/// 
-		/// </summary>
-		/// <param name="doc">that was hit
-		/// </param>
-        /// <returns> any N &lt; 0 if the doc's value is sorted after
-		/// the bottom entry (not competitive), any N > 0 if the
-		/// doc's value is sorted before the bottom entry and 0 if
-		/// they are equal.
-		/// </returns>
-		public abstract int CompareBottom(int doc);
-		
-		/// <summary> This method is called when a new hit is competitive.
-		/// You should copy any state associated with this document
-		/// that will be required for future comparisons, into the
-		/// specified slot.
-		/// 
-		/// </summary>
-		/// <param name="slot">which slot to copy the hit to
-		/// </param>
-		/// <param name="doc">docID relative to current reader
-		/// </param>
-		public abstract void  Copy(int slot, int doc);
-		
-		/// <summary> Set a new Reader. All doc correspond to the current Reader.
-		/// 
-		/// </summary>
-		/// <param name="reader">current reader
-		/// </param>
-		/// <param name="docBase">docBase of this reader 
-		/// </param>
-		/// <throws>  IOException </throws>
-		/// <throws>  IOException </throws>
-		public abstract void  SetNextReader(IndexReader reader, int docBase);
-		
-		/// <summary>Sets the Scorer to use in case a document's score is
-		/// needed.
-		/// 
-		/// </summary>
-		/// <param name="scorer">Scorer instance that you should use to
-		/// obtain the current hit's score, if necessary. 
-		/// </param>
-		public virtual void  SetScorer(Scorer scorer)
-		{
-			// Empty implementation since most comparators don't need the score. This
-			// can be overridden by those that need it.
-		}
-		
-		/// <summary> Return the actual value in the slot.
-		/// 
-		/// </summary>
-		/// <param name="slot">the value
-		/// </param>
-		/// <returns> value in this slot upgraded to Comparable
-		/// </returns>
-		public abstract System.IComparable Value(int slot);
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldDoc.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldDoc.cs?rev=1203769&r1=1203768&r2=1203769&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldDoc.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FieldDoc.cs Fri Nov 18 17:54:13 2011
@@ -35,14 +35,8 @@ namespace Lucene.Net.Search
 	/// <p/>Created: Feb 11, 2004 1:23:38 PM
 	/// 
 	/// </summary>
-	/// <since>   lucene 1.4
-	/// </since>
-	/// <version>  $Id: FieldDoc.java 773194 2009-05-09 10:36:41Z mikemccand $
-	/// </version>
-	/// <seealso cref="ScoreDoc">
-	/// </seealso>
-	/// <seealso cref="TopFieldDocs">
-	/// </seealso>
+	/// <seealso cref="ScoreDoc"></seealso>
+	/// <seealso cref="TopFieldDocs"></seealso>
 	[Serializable]
 	public class FieldDoc:ScoreDoc
 	{

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Filter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Filter.cs?rev=1203769&r1=1203768&r2=1203769&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Filter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Filter.cs Fri Nov 18 17:54:13 2011
@@ -23,58 +23,32 @@ using DocIdBitSet = Lucene.Net.Util.DocI
 namespace Lucene.Net.Search
 {
 	
-	/// <summary>Abstract base class for restricting which documents may be returned during searching.
-	/// <p/>
-	/// <b>Note:</b> In Lucene 3.0 <see cref="Bits(IndexReader)" /> will be removed
-	/// and <see cref="GetDocIdSet(IndexReader)" /> will be defined as abstract.
-	/// All implementing classes must therefore implement <see cref="GetDocIdSet(IndexReader)" />
-	/// in order to work with Lucene 3.0.
-	/// </summary>
+	/// <summary>Abstract base class for restricting which documents may be returned during searching.</summary>
 	[Serializable]
 	public abstract class Filter
-	{ 
-        
-
-        /// <summary><b>NOTE:</b> See <see cref="GetDocIdSet(IndexReader)" /> for
-        /// handling of multi-segment indexes (which applies to
-        /// this method as well.
-        /// </summary>
-		/// <returns> A BitSet with true for documents which should be permitted in
-		/// search results, and false for those that should not.
-		/// </returns>
-		/// <deprecated> Use <see cref="GetDocIdSet(IndexReader)" /> instead.
-		/// </deprecated>
-        [Obsolete("Use GetDocIdSet(IndexReader) instead.")]
-		public virtual System.Collections.BitArray Bits(IndexReader reader)
-		{
-			throw new System.NotSupportedException();
-		}
-		
-        ///<summary>
-        ///  <para>Creates a <see cref="DocIdSet" /> enumerating the documents that should be
-        ///  permitted in search results. <b>NOTE:</b> null can be
-        ///  returned if no documents are accepted by this Filter.</para>
-        ///  <p/>
-        ///  <para>Note: This method will be called once per segment in
-        ///  the index during searching.  The returned <see cref="DocIdSet" />
-        ///  must refer to document IDs for that segment, not for
-        ///  the top-level reader.</para>
-        ///</summary>
-		/// <returns> a DocIdSet that provides the documents which should be permitted or
-		/// prohibited in search results. <b>NOTE:</b> null can be returned if
-		/// no documents will be accepted by this Filter.
-        /// </returns>
-        /// <param name="reader">
-        /// A <see cref="IndexReader" /> instance opened on the index currently
-        /// searched on. Note, it is likely that the provided reader does not
-        /// represent the whole underlying index i.e. if the index has more than
-        /// one segment the given reader only represents a single segment.
-        /// </param>
-		/// <seealso cref="DocIdBitSet">
-		/// </seealso>
-		public virtual DocIdSet GetDocIdSet(IndexReader reader)
-		{
-			return new DocIdBitSet(Bits(reader));
-		}
+	{
+	    ///<summary>
+	    ///  <para>Creates a <see cref="DocIdSet" /> enumerating the documents that should be
+	    ///  permitted in search results. <b>NOTE:</b> null can be
+	    ///  returned if no documents are accepted by this Filter.</para>
+	    ///  <p/>
+	    ///  <para>Note: This method will be called once per segment in
+	    ///  the index during searching.  The returned <see cref="DocIdSet" />
+	    ///  must refer to document IDs for that segment, not for
+	    ///  the top-level reader.</para>
+	    ///</summary>
+	    /// <returns> a DocIdSet that provides the documents which should be permitted or
+	    /// prohibited in search results. <b>NOTE:</b> null can be returned if
+	    /// no documents will be accepted by this Filter.
+	    /// </returns>
+	    /// <param name="reader">
+	    /// A <see cref="IndexReader" /> instance opened on the index currently
+	    /// searched on. Note, it is likely that the provided reader does not
+	    /// represent the whole underlying index i.e. if the index has more than
+	    /// one segment the given reader only represents a single segment.
+	    /// </param>
+	    /// <seealso cref="DocIdBitSet">
+	    /// </seealso>
+	    public abstract DocIdSet GetDocIdSet(IndexReader reader);
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FilterManager.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FilterManager.cs?rev=1203769&r1=1203768&r2=1203769&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FilterManager.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/FilterManager.cs Fri Nov 18 17:54:13 2011
@@ -17,6 +17,7 @@
 
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using Lucene.Net.Support;
 
 namespace Lucene.Net.Search
@@ -44,7 +45,7 @@ namespace Lucene.Net.Search
 		protected internal const long DEFAULT_CACHE_SLEEP_TIME = 1000 * 60 * 10;
 		
 		/// <summary>The cache itself </summary>
-		protected internal System.Collections.IDictionary cache;
+		protected internal IDictionary<int, FilterItem> cache;
 		/// <summary>Maximum allowed cache size </summary>
 		protected internal int cacheCleanSize;
 		/// <summary>Cache cleaning frequency </summary>
@@ -67,7 +68,7 @@ namespace Lucene.Net.Search
 		/// <summary> Sets up the FilterManager singleton.</summary>
 		protected internal FilterManager()
 		{
-			cache = new System.Collections.Hashtable();
+			cache = new HashMap<int, FilterItem>();
 			cacheCleanSize = DEFAULT_CACHE_CLEAN_SIZE; // Let the cache get to 100 items
 			cleanSleepTime = DEFAULT_CACHE_SLEEP_TIME; // 10 minutes between cleanings
 			
@@ -105,16 +106,16 @@ namespace Lucene.Net.Search
 		/// </returns>
 		public virtual Filter GetFilter(Filter filter)
 		{
-			lock (cache.SyncRoot)
+			lock (cache)
 			{
 				FilterItem fi = null;
-				fi = (FilterItem) cache[(System.Int32) filter.GetHashCode()];
+				fi = cache[filter.GetHashCode()];
 				if (fi != null)
 				{
 					fi.timestamp = System.DateTime.Now.Ticks;
 					return fi.filter;
 				}
-				cache[(System.Int32) filter.GetHashCode()] = new FilterItem(this, filter);
+				cache[filter.GetHashCode()] = new FilterItem(filter);
 				return filter;
 			}
 		}
@@ -125,25 +126,11 @@ namespace Lucene.Net.Search
 		/// </summary>
 		protected internal class FilterItem
 		{
-			private void  InitBlock(FilterManager enclosingInstance)
-			{
-				this.enclosingInstance = enclosingInstance;
-			}
-			private FilterManager enclosingInstance;
-			public FilterManager Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
 			public Filter filter;
 			public long timestamp;
 			
-			public FilterItem(FilterManager enclosingInstance, Filter filter)
+			public FilterItem(Filter filter)
 			{
-				InitBlock(enclosingInstance);
 				this.filter = filter;
 				this.timestamp = System.DateTime.Now.Ticks;
 			}
@@ -165,13 +152,13 @@ namespace Lucene.Net.Search
 		/// </summary>
 		protected internal class FilterCleaner : IThreadRunnable
 		{
-            private class FilterItemComparer : IComparer<FilterItem>
+            private class FilterItemComparer : IComparer<KeyValuePair<int, FilterItem>>
             {
                 #region IComparer<FilterItem> Members
 
-                public int Compare(FilterItem x, FilterItem y)
+                public int Compare(KeyValuePair<int, FilterItem> x, KeyValuePair<int, FilterItem> y)
                 {
-                    return x.timestamp.CompareTo(y.timestamp);
+                    return x.Value.timestamp.CompareTo(y.Value.timestamp);
                 }
 
                 #endregion
@@ -179,42 +166,34 @@ namespace Lucene.Net.Search
 			
 			private bool running = true;
             private FilterManager manager;
-            private List<FilterItem> filterItems;
+            private SortedSet<KeyValuePair<int, FilterItem>> sortedFilterItems;
 			
 			public FilterCleaner(FilterManager enclosingInstance)
 			{
                 this.manager = enclosingInstance;
-                filterItems = new List<FilterItem>();
+                sortedFilterItems = new SortedSet<KeyValuePair<int, FilterItem>>(new FilterItemComparer());
             }
 			
 			public virtual void  Run()
 			{
 				while (running)
 				{
-					
 					// sort items from oldest to newest 
 					// we delete the oldest filters 
                     if (this.manager.cache.Count > this.manager.cacheCleanSize)
 					{
 						// empty the temporary set
-						filterItems.Clear();
-                        lock (this.manager.cache.SyncRoot)
+						sortedFilterItems.Clear();
+                        lock (this.manager.cache)
 						{
-                            foreach (FilterItem item in this.manager.cache.Values)
-                            {
-                                filterItems.Add(item);
-                            }
-                            filterItems.Sort(new FilterItemComparer());
-
+                            sortedFilterItems.UnionWith(this.manager.cache);
                             int numToDelete = (int)((this.manager.cache.Count - this.manager.cacheCleanSize) * 1.5);
-							// loop over the set and delete all of the cache entries not used in a while
-                            for(int i = 0; i < numToDelete; i++)
-                            {
-                                this.manager.cache.Remove(filterItems[i].filter.GetHashCode());
-                            }
+
+                            //delete all of the cache entries not used in a while
+                            sortedFilterItems.ExceptWith(sortedFilterItems.Take(numToDelete).ToArray());
 						}
 						// empty the set so we don't tie up the memory
-                        filterItems.Clear();
+                        sortedFilterItems.Clear();
 					}
 					// take a nap
 					try
@@ -223,8 +202,7 @@ namespace Lucene.Net.Search
 					}
 					catch (System.Threading.ThreadInterruptedException ie)
 					{
-						ThreadClass.Current().Interrupt();
-						throw new System.SystemException(ie.Message, ie);
+					    throw;
 					}
 				}
 			}

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Function/FieldCacheSource.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Function/FieldCacheSource.cs?rev=1203769&r1=1203768&r2=1203769&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Function/FieldCacheSource.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Function/FieldCacheSource.cs Fri Nov 18 17:54:13 2011
@@ -44,10 +44,7 @@ namespace Lucene.Net.Search.Function
 	/// composite (multi-segment) reader, this can easily cause
 	/// double RAM usage for the values in the FieldCache.  It's
 	/// best to switch your application to pass only atomic
-	/// (single segment) readers to this API.  Alternatively, for
-	/// a short-term fix, you could wrap your ValueSource using
-	/// <see cref="MultiValueSource" />, which costs more CPU per lookup
-	/// but will not consume double the FieldCache RAM.<p/>
+	/// (single segment) readers to this API.<p/>
 	/// </summary>
 	[Serializable]
 	public abstract class FieldCacheSource:ValueSource

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Function/OrdFieldSource.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Function/OrdFieldSource.cs?rev=1203769&r1=1203768&r2=1203769&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Function/OrdFieldSource.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Function/OrdFieldSource.cs Fri Nov 18 17:54:13 2011
@@ -49,10 +49,7 @@ namespace Lucene.Net.Search.Function
 	/// composite (multi-segment) reader, this can easily cause
 	/// double RAM usage for the values in the FieldCache.  It's
 	/// best to switch your application to pass only atomic
-	/// (single segment) readers to this API.  Alternatively, for
-	/// a short-term fix, you could wrap your ValueSource using
-	/// <see cref="MultiValueSource" />, which costs more CPU per lookup
-	/// but will not consume double the FieldCache RAM.<p/>
+	/// (single segment) readers to this API.<p/>
 	/// </summary>
 	
 	[Serializable]

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Function/ReverseOrdFieldSource.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Function/ReverseOrdFieldSource.cs?rev=1203769&r1=1203768&r2=1203769&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Function/ReverseOrdFieldSource.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Function/ReverseOrdFieldSource.cs Fri Nov 18 17:54:13 2011
@@ -50,10 +50,7 @@ namespace Lucene.Net.Search.Function
 	/// composite (multi-segment) reader, this can easily cause
 	/// double RAM usage for the values in the FieldCache.  It's
 	/// best to switch your application to pass only atomic
-	/// (single segment) readers to this API.  Alternatively, for
-	/// a short-term fix, you could wrap your ValueSource using
-	/// <see cref="MultiValueSource" />, which costs more CPU per lookup
-	/// but will not consume double the FieldCache RAM.<p/>
+	/// (single segment) readers to this API.<p/>
 	/// </summary>
 	
 	[Serializable]

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiTermQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiTermQuery.cs?rev=1203769&r1=1203768&r2=1203769&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiTermQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiTermQuery.cs Fri Nov 18 17:54:13 2011
@@ -16,7 +16,7 @@
  */
 
 using System;
-
+using System.Collections.Generic;
 using System.Runtime.InteropServices;
 using IndexReader = Lucene.Net.Index.IndexReader;
 using Term = Lucene.Net.Index.Term;
@@ -76,8 +76,6 @@ namespace Lucene.Net.Search
 				return Lucene.Net.Search.MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT;
 			}
 		}
-		// @deprecated move to sub class
-		protected internal Term term;
 		protected internal RewriteMethod rewriteMethod = CONSTANT_SCORE_AUTO_REWRITE_DEFAULT;
 		[NonSerialized]
 		internal int numberOfTerms = 0;
@@ -94,7 +92,7 @@ namespace Lucene.Net.Search
 		{
 			public override Query Rewrite(IndexReader reader, MultiTermQuery query)
 			{
-				Query result = new ConstantScoreQuery(new MultiTermQueryWrapperFilter(query));
+				Query result = new ConstantScoreQuery(new MultiTermQueryWrapperFilter<MultiTermQuery>(query));
 				result.SetBoost(query.GetBoost());
 				return result;
 			}
@@ -285,7 +283,7 @@ namespace Lucene.Net.Search
 				// exhaust the enum before hitting either of the
 				// cutoffs, we use ConstantBooleanQueryRewrite; else,
 				// ConstantFilterRewrite:
-				System.Collections.ArrayList pendingTerms = new System.Collections.ArrayList();
+				ICollection<Term> pendingTerms = new List<Term>();
 				int docCountCutoff = (int) ((docCountPercent / 100.0) * reader.MaxDoc());
 				int termCountLimit = System.Math.Min(BooleanQuery.GetMaxClauseCount(), termCountCutoff);
 				int docVisitCount = 0;
@@ -309,7 +307,7 @@ namespace Lucene.Net.Search
 						if (pendingTerms.Count >= termCountLimit || docVisitCount >= docCountCutoff)
 						{
 							// Too many terms -- make a filter.
-							Query result = new ConstantScoreQuery(new MultiTermQueryWrapperFilter(query));
+							Query result = new ConstantScoreQuery(new MultiTermQueryWrapperFilter<MultiTermQuery>(query));
 							result.SetBoost(query.GetBoost());
 							return result;
 						}
@@ -318,11 +316,10 @@ namespace Lucene.Net.Search
 							// Enumeration is done, and we hit a small
 							// enough number of terms & docs -- just make a
 							// BooleanQuery, now
-							System.Collections.IEnumerator it = pendingTerms.GetEnumerator();
 							BooleanQuery bq = new BooleanQuery(true);
-							while (it.MoveNext())
+							foreach(Term term in pendingTerms)
 							{
-								TermQuery tq = new TermQuery((Term) it.Current);
+								TermQuery tq = new TermQuery(term);
 								bq.Add(tq, BooleanClause.Occur.SHOULD);
 							}
 							// Strip scores
@@ -384,16 +381,6 @@ namespace Lucene.Net.Search
 		/// </summary>
 		public static readonly RewriteMethod CONSTANT_SCORE_AUTO_REWRITE_DEFAULT;
 		
-		/// <summary> Constructs a query for terms matching <c>term</c>.</summary>
-		/// <deprecated> check sub class for possible term access - the Term does not
-		/// make sense for all MultiTermQuerys and will be removed.
-		/// </deprecated>
-        [Obsolete("check sub class for possible term access - the Term does not make sense for all MultiTermQuerys and will be removed.")]
-		public MultiTermQuery(Term term)
-		{
-			this.term = term;
-		}
-		
 		/// <summary> Constructs a query matching terms that cannot be represented with a single
 		/// Term.
 		/// </summary>
@@ -444,31 +431,6 @@ namespace Lucene.Net.Search
 			return rewriteMethod.Rewrite(reader, this);
 		}
 		
-		
-		/* Prints a user-readable version of this query.
-		* Implemented for back compat in case MultiTermQuery
-		* subclasses do no implement.
-		*/
-		public override System.String ToString(System.String field)
-		{
-			System.Text.StringBuilder buffer = new System.Text.StringBuilder();
-			if (term != null)
-			{
-				if (!term.Field().Equals(field))
-				{
-					buffer.Append(term.Field());
-					buffer.Append(":");
-				}
-				buffer.Append(term.Text());
-			}
-			else
-			{
-				buffer.Append("termPattern:unknown");
-			}
-			buffer.Append(ToStringUtils.Boost(GetBoost()));
-			return buffer.ToString();
-		}
-		
 		/// <seealso cref="SetRewriteMethod">
 		/// </seealso>
 		public virtual RewriteMethod GetRewriteMethod()

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiTermQueryWrapperFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiTermQueryWrapperFilter.cs?rev=1203769&r1=1203768&r2=1203769&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiTermQueryWrapperFilter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/MultiTermQueryWrapperFilter.cs Fri Nov 18 17:54:13 2011
@@ -40,66 +40,13 @@ namespace Lucene.Net.Search
 	/// this is why it is not abstract.
 	/// </summary>
 	[Serializable]
-	public class MultiTermQueryWrapperFilter:Filter
+    public class MultiTermQueryWrapperFilter<T> : Filter
+        where T : MultiTermQuery
 	{
-		private class AnonymousClassTermGenerator:TermGenerator
-		{
-			public AnonymousClassTermGenerator(System.Collections.BitArray bitSet, MultiTermQueryWrapperFilter enclosingInstance)
-			{
-				InitBlock(bitSet, enclosingInstance);
-			}
-			private void  InitBlock(System.Collections.BitArray bitSet, MultiTermQueryWrapperFilter enclosingInstance)
-			{
-				this.bitSet = bitSet;
-				this.enclosingInstance = enclosingInstance;
-			}
-			private System.Collections.BitArray bitSet;
-			private MultiTermQueryWrapperFilter enclosingInstance;
-			public MultiTermQueryWrapperFilter Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			public override void  HandleDoc(int doc)
-			{
-				bitSet.Set(doc, true);
-			}
-		}
-
-		private class AnonymousClassTermGenerator1:TermGenerator
-		{
-			public AnonymousClassTermGenerator1(Lucene.Net.Util.OpenBitSet bitSet, MultiTermQueryWrapperFilter enclosingInstance)
-			{
-				InitBlock(bitSet, enclosingInstance);
-			}
-			private void  InitBlock(Lucene.Net.Util.OpenBitSet bitSet, MultiTermQueryWrapperFilter enclosingInstance)
-			{
-				this.bitSet = bitSet;
-				this.enclosingInstance = enclosingInstance;
-			}
-			private Lucene.Net.Util.OpenBitSet bitSet;
-			private MultiTermQueryWrapperFilter enclosingInstance;
-			public MultiTermQueryWrapperFilter Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			public override void  HandleDoc(int doc)
-			{
-				bitSet.Set(doc);
-			}
-		}
-		
-		protected internal MultiTermQuery query;
+        protected internal T query;
 		
 		/// <summary> Wrap a <see cref="MultiTermQuery" /> as a Filter.</summary>
-		protected internal MultiTermQueryWrapperFilter(MultiTermQuery query)
+        protected internal MultiTermQueryWrapperFilter(T query)
 		{
 			this.query = query;
 		}
@@ -120,7 +67,7 @@ namespace Lucene.Net.Search
 				return false;
 			if (this.GetType().Equals(o.GetType()))
 			{
-				return this.query.Equals(((MultiTermQueryWrapperFilter) o).query);
+				return this.query.Equals(((MultiTermQueryWrapperFilter<T>) o).query);
 			}
 			return false;
 		}
@@ -155,90 +102,54 @@ namespace Lucene.Net.Search
 		{
 			query.ClearTotalNumberOfTerms();
 		}
-		
-		internal abstract class TermGenerator
-		{
-            public virtual void Generate(MultiTermQuery query, IndexReader reader, TermEnum enumerator)
-			{
-				int[] docs = new int[32];
-				int[] freqs = new int[32];
-				TermDocs termDocs = reader.TermDocs();
-				try
-				{
-					int termCount = 0;
-					do 
-					{
-						Term term = enumerator.Term();
-						if (term == null)
-							break;
-						termCount++;
-						termDocs.Seek(term);
-						while (true)
-						{
-							int count = termDocs.Read(docs, freqs);
-							if (count != 0)
-							{
-								for (int i = 0; i < count; i++)
-								{
-									HandleDoc(docs[i]);
-								}
-							}
-							else
-							{
-								break;
-							}
-						}
-					}
-					while (enumerator.Next());
-					
-					query.IncTotalNumberOfTerms(termCount); // {{Aroush-2.9}} is the use of 'temp' as is right?
-				}
-				finally
-				{
-					termDocs.Close();
-				}
-			}
-			abstract public void  HandleDoc(int doc);
-		}
-		
-		/// <summary> Returns a BitSet with true for documents which should be
-		/// permitted in search results, and false for those that should
-		/// not.
-		/// </summary>
-		/// <deprecated> Use <see cref="GetDocIdSet(IndexReader)" /> instead.
-		/// </deprecated>
-		//@Override
-        [Obsolete("Use GetDocIdSet(IndexReader) instead.")]
-		public override System.Collections.BitArray Bits(IndexReader reader)
-		{
-			TermEnum enumerator = query.GetEnum(reader);
-			try
-			{
-				System.Collections.BitArray bitSet = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0?reader.MaxDoc() / 64:reader.MaxDoc() / 64 + 1) * 64);
-				new AnonymousClassTermGenerator(bitSet, this).Generate(query, reader, enumerator);
-				return bitSet;
-			}
-			finally
-			{
-				enumerator.Close();
-			}
-		}
-		
-		/// <summary> Returns a DocIdSet with documents that should be
-		/// permitted in search results.
-		/// </summary>
-		//@Override
-		public override DocIdSet GetDocIdSet(IndexReader reader)
-		{
-			TermEnum enumerator = query.GetEnum(reader);
-			try
-			{
-				// if current term in enum is null, the enum is empty -> shortcut
-				if (enumerator.Term() == null)
-					return DocIdSet.EMPTY_DOCIDSET;
-				// else fill into a OpenBitSet
-				OpenBitSet bitSet = new OpenBitSet(reader.MaxDoc());
-				new AnonymousClassTermGenerator1(bitSet, this).Generate(query, reader, enumerator);
+
+        public override DocIdSet GetDocIdSet(IndexReader reader)
+        {
+            TermEnum enumerator = query.GetEnum(reader);
+            try
+            {
+                // if current term in enum is null, the enum is empty -> shortcut
+                if (enumerator.Term() == null)
+                    return DocIdSet.EMPTY_DOCIDSET;
+                // else fill into an OpenBitSet
+                OpenBitSet bitSet = new OpenBitSet(reader.MaxDoc());
+                int[] docs = new int[32];
+                int[] freqs = new int[32];
+                TermDocs termDocs = reader.TermDocs();
+                try
+                {
+                    int termCount = 0;
+                    do
+                    {
+                        Term term = enumerator.Term();
+                        if (term == null)
+                            break;
+                        termCount++;
+                        termDocs.Seek(term);
+                        while (true)
+                        {
+                            int count = termDocs.Read(docs, freqs);
+                            if (count != 0)
+                            {
+                                for (int i = 0; i < count; i++)
+                                {
+                                    bitSet.Set(docs[i]);
+                                }
+                            }
+                            else
+                            {
+                                break;
+                            }
+                        }
+                    } while (enumerator.Next());
+
+                    query.IncTotalNumberOfTerms(termCount); // {{Aroush-2.9}} is the use of 'temp' as is right?
+                }
+                finally
+                {
+                    termDocs.Close();
+                }
+
 				return bitSet;
 			}
 			finally

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/NumericRangeFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/NumericRangeFilter.cs?rev=1203769&r1=1203768&r2=1203769&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/NumericRangeFilter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/NumericRangeFilter.cs Fri Nov 18 17:54:13 2011
@@ -23,158 +23,163 @@ using NumericUtils = Lucene.Net.Util.Num
 
 namespace Lucene.Net.Search
 {
-	
-	/// <summary> A <see cref="Filter" /> that only accepts numeric values within
-	/// a specified range. To use this, you must first index the
-	/// numeric values using <see cref="NumericField" /> (expert: <see cref="NumericTokenStream" />
-	///).
-	/// 
-	/// <p/>You create a new NumericRangeFilter with the static
-	/// factory methods, eg:
-	/// 
+
+    /// <summary> A <see cref="Filter" /> that only accepts numeric values within
+    /// a specified range. To use this, you must first index the
+    /// numeric values using <see cref="NumericField" /> (expert: <see cref="NumericTokenStream" />
+    ///).
+    /// 
+    /// <p/>You create a new NumericRangeFilter with the static
+    /// factory methods, eg:
+    /// 
     /// <code>
-	/// Filter f = NumericRangeFilter.newFloatRange("weight",
-	///             new Float(0.3f), new Float(0.10f),
-	///             true, true);
+    /// Filter f = NumericRangeFilter.newFloatRange("weight",
+    ///             new Float(0.3f), new Float(0.10f),
+    ///             true, true);
     /// </code>
-	/// 
-	/// accepts all documents whose float valued "weight" field
-	/// ranges from 0.3 to 0.10, inclusive.
-	/// See <see cref="NumericRangeQuery" /> for details on how Lucene
-	/// indexes and searches numeric valued fields.
-	/// 
-	/// <p/><font color="red"><b>NOTE:</b> This API is experimental and
-	/// might change in incompatible ways in the next
-	/// release.</font>
-	/// 
-	/// </summary>
-	/// <since> 2.9
-	/// 
-	/// </since>
-	[Serializable]
-	public sealed class NumericRangeFilter:MultiTermQueryWrapperFilter
-	{
-		
-		private NumericRangeFilter(NumericRangeQuery query):base(query)
-		{
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeFilter</c>, that filters a <c>long</c>
-		/// range using the given <a href="NumericRangeQuery.html#precisionStepDesc"><c>precisionStep</c></a>.
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeFilter NewLongRange(System.String field, int precisionStep, System.ValueType min, System.ValueType max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeFilter(NumericRangeQuery.NewLongRange(field, precisionStep, min, max, minInclusive, maxInclusive));
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeFilter</c>, that queries a <c>long</c>
-		/// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeFilter NewLongRange(System.String field, System.ValueType min, System.ValueType max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeFilter(NumericRangeQuery.NewLongRange(field, min, max, minInclusive, maxInclusive));
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeFilter</c>, that filters a <c>int</c>
-		/// range using the given <a href="NumericRangeQuery.html#precisionStepDesc"><c>precisionStep</c></a>.
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeFilter NewIntRange(System.String field, int precisionStep, System.ValueType min, System.ValueType max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeFilter(NumericRangeQuery.NewIntRange(field, precisionStep, min, max, minInclusive, maxInclusive));
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeFilter</c>, that queries a <c>int</c>
-		/// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeFilter NewIntRange(System.String field, System.ValueType min, System.ValueType max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeFilter(NumericRangeQuery.NewIntRange(field, min, max, minInclusive, maxInclusive));
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeFilter</c>, that filters a <c>double</c>
-		/// range using the given <a href="NumericRangeQuery.html#precisionStepDesc"><c>precisionStep</c></a>.
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeFilter NewDoubleRange(System.String field, int precisionStep, System.Double min, System.Double max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeFilter(NumericRangeQuery.NewDoubleRange(field, precisionStep, min, max, minInclusive, maxInclusive));
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeFilter</c>, that queries a <c>double</c>
-		/// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeFilter NewDoubleRange(System.String field, System.Double min, System.Double max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeFilter(NumericRangeQuery.NewDoubleRange(field, min, max, minInclusive, maxInclusive));
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeFilter</c>, that filters a <c>float</c>
-		/// range using the given <a href="NumericRangeQuery.html#precisionStepDesc"><c>precisionStep</c></a>.
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeFilter NewFloatRange(System.String field, int precisionStep, System.Single min, System.Single max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeFilter(NumericRangeQuery.NewFloatRange(field, precisionStep, min, max, minInclusive, maxInclusive));
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeFilter</c>, that queries a <c>float</c>
-		/// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeFilter NewFloatRange(System.String field, System.Single min, System.Single max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeFilter(NumericRangeQuery.NewFloatRange(field, min, max, minInclusive, maxInclusive));
-		}
-		
-		/// <summary>Returns the field name for this filter </summary>
+    /// 
+    /// accepts all documents whose float valued "weight" field
+    /// ranges from 0.3 to 0.10, inclusive.
+    /// See <see cref="NumericRangeQuery{T}" /> for details on how Lucene
+    /// indexes and searches numeric valued fields.
+    /// 
+    /// <p/><font color="red"><b>NOTE:</b> This API is experimental and
+    /// might change in incompatible ways in the next
+    /// release.</font>
+    /// 
+    /// </summary>
+    /// <since> 2.9
+    /// 
+    /// </since>
+    [Serializable]
+    public sealed class NumericRangeFilter<T> : MultiTermQueryWrapperFilter<NumericRangeQuery<T>>
+        where T : struct, IComparable<T>
+        // real numbers in C# are structs and IComparable with themselves, best constraint we have
+    {
+        internal NumericRangeFilter(NumericRangeQuery<T> query)
+            : base(query)
+        {
+        }
+
+        /// <summary>Returns the field name for this filter </summary>
 		public System.String GetField()
 		{
-			return ((NumericRangeQuery) query).GetField();
+			return query.GetField();
 		}
 		
 		/// <summary>Returns <c>true</c> if the lower endpoint is inclusive </summary>
 		public bool IncludesMin()
 		{
-			return ((NumericRangeQuery) query).IncludesMin();
+			return query.IncludesMin();
 		}
 		
 		/// <summary>Returns <c>true</c> if the upper endpoint is inclusive </summary>
 		public bool IncludesMax()
 		{
-			return ((NumericRangeQuery) query).IncludesMax();
+			return query.IncludesMax();
 		}
 		
 		/// <summary>Returns the lower value of this range filter </summary>
-		public System.ValueType GetMin()
+		public T? GetMin()
 		{
-			return ((NumericRangeQuery) query).GetMin();
+			return query.GetMin();
 		}
 		
 		/// <summary>Returns the upper value of this range filter </summary>
-		public System.ValueType GetMax()
+		public T? GetMax()
 		{
-			return ((NumericRangeQuery) query).GetMax();
+			return query.GetMax();
 		}
 	}
+
+    public static class NumericRangeFilter
+    {
+        /// <summary> Factory that creates a <c>NumericRangeFilter</c>, that filters a <c>long</c>
+        /// range using the given <a href="NumericRangeQuery.html#precisionStepDesc"><c>precisionStep</c></a>.
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeFilter<long> NewLongRange(System.String field, int precisionStep, long? min, long? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeFilter<long>(NumericRangeQuery.NewLongRange(field, precisionStep, min, max, minInclusive, maxInclusive));
+        }
+
+        /// <summary> Factory that creates a <c>NumericRangeFilter</c>, that queries a <c>long</c>
+        /// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeFilter<long> NewLongRange(System.String field, long? min, long? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeFilter<long>(NumericRangeQuery.NewLongRange(field, min, max, minInclusive, maxInclusive));
+        }
+
+        /// <summary> Factory that creates a <c>NumericRangeFilter</c>, that filters a <c>int</c>
+        /// range using the given <a href="NumericRangeQuery.html#precisionStepDesc"><c>precisionStep</c></a>.
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeFilter<int> NewIntRange(System.String field, int precisionStep, int? min, int? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeFilter<int>(NumericRangeQuery.NewIntRange(field, precisionStep, min, max, minInclusive, maxInclusive));
+        }
+
+        /// <summary> Factory that creates a <c>NumericRangeFilter</c>, that queries a <c>int</c>
+        /// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeFilter<int> NewIntRange(System.String field, int? min, int? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeFilter<int>(NumericRangeQuery.NewIntRange(field, min, max, minInclusive, maxInclusive));
+        }
+
+        /// <summary> Factory that creates a <c>NumericRangeFilter</c>, that filters a <c>double</c>
+        /// range using the given <a href="NumericRangeQuery.html#precisionStepDesc"><c>precisionStep</c></a>.
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeFilter<double> NewDoubleRange(System.String field, int precisionStep, double? min, double? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeFilter<double>(NumericRangeQuery.NewDoubleRange(field, precisionStep, min, max, minInclusive, maxInclusive));
+        }
+
+        /// <summary> Factory that creates a <c>NumericRangeFilter</c>, that queries a <c>double</c>
+        /// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeFilter<double> NewDoubleRange(System.String field, double? min, double? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeFilter<double>(NumericRangeQuery.NewDoubleRange(field, min, max, minInclusive, maxInclusive));
+        }
+
+        /// <summary> Factory that creates a <c>NumericRangeFilter</c>, that filters a <c>float</c>
+        /// range using the given <a href="NumericRangeQuery.html#precisionStepDesc"><c>precisionStep</c></a>.
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeFilter<float> NewFloatRange(System.String field, int precisionStep, float? min, float? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeFilter<float>(NumericRangeQuery.NewFloatRange(field, precisionStep, min, max, minInclusive, maxInclusive));
+        }
+
+        /// <summary> Factory that creates a <c>NumericRangeFilter</c>, that queries a <c>float</c>
+        /// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeFilter<float> NewFloatRange(System.String field, float? min, float? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeFilter<float>(NumericRangeQuery.NewFloatRange(field, min, max, minInclusive, maxInclusive));
+        }
+    }
 }
\ No newline at end of file

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/NumericRangeQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/NumericRangeQuery.cs?rev=1203769&r1=1203768&r2=1203769&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/NumericRangeQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/NumericRangeQuery.cs Fri Nov 18 17:54:13 2011
@@ -16,7 +16,8 @@
  */
 
 using System;
-
+using System.Collections.Generic;
+using Lucene.Net.Index;
 using NumericTokenStream = Lucene.Net.Analysis.NumericTokenStream;
 using NumericField = Lucene.Net.Documents.NumericField;
 using IndexReader = Lucene.Net.Index.IndexReader;
@@ -32,7 +33,7 @@ namespace Lucene.Net.Search
 	/// specified range.  To use this, you must first index the
 	/// numeric values using <see cref="NumericField" /> (expert: <see cref="NumericTokenStream" />
 	///).  If your terms are instead textual,
-	/// you should use <see cref="TermRangeQuery" />.  <see cref="NumericRangeFilter" />
+	/// you should use <see cref="TermRangeQuery" />.  <see cref="NumericRangeFilter{T}" />
 	/// is the filter equivalent of this
 	/// query.<p/>
 	/// 
@@ -152,10 +153,11 @@ namespace Lucene.Net.Search
 	/// 
 	/// </since>
 	[Serializable]
-	public sealed class NumericRangeQuery:MultiTermQuery
+	public sealed class NumericRangeQuery<T> : MultiTermQuery
+        where T : struct, IComparable<T> // best equiv constraint for java's number class
 	{
 		
-		private NumericRangeQuery(System.String field, int precisionStep, int valSize, System.ValueType min, System.ValueType max, bool minInclusive, bool maxInclusive)
+		protected internal NumericRangeQuery(System.String field, int precisionStep, int valSize, T? min, T? max, bool minInclusive, bool maxInclusive)
 		{
 			System.Diagnostics.Debug.Assert((valSize == 32 || valSize == 64));
 			if (precisionStep < 1)
@@ -196,94 +198,6 @@ namespace Lucene.Net.Search
 			}
 		}
 		
-		/// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>long</c>
-		/// range using the given <a href="#precisionStepDesc"><c>precisionStep</c></a>.
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeQuery NewLongRange(System.String field, int precisionStep, System.ValueType min, System.ValueType max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeQuery(field, precisionStep, 64, min, max, minInclusive, maxInclusive);
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>long</c>
-		/// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeQuery NewLongRange(System.String field, System.ValueType min, System.ValueType max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeQuery(field, NumericUtils.PRECISION_STEP_DEFAULT, 64, min, max, minInclusive, maxInclusive);
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>int</c>
-		/// range using the given <a href="#precisionStepDesc"><c>precisionStep</c></a>.
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeQuery NewIntRange(System.String field, int precisionStep, System.ValueType min, System.ValueType max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeQuery(field, precisionStep, 32, min, max, minInclusive, maxInclusive);
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>int</c>
-		/// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeQuery NewIntRange(System.String field, System.ValueType min, System.ValueType max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeQuery(field, NumericUtils.PRECISION_STEP_DEFAULT, 32, min, max, minInclusive, maxInclusive);
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>double</c>
-		/// range using the given <a href="#precisionStepDesc"><c>precisionStep</c></a>.
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeQuery NewDoubleRange(System.String field, int precisionStep, System.Double min, System.Double max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeQuery(field, precisionStep, 64, min, max, minInclusive, maxInclusive);
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>double</c>
-		/// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeQuery NewDoubleRange(System.String field, System.Double min, System.Double max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeQuery(field, NumericUtils.PRECISION_STEP_DEFAULT, 64, min, max, minInclusive, maxInclusive);
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>float</c>
-		/// range using the given <a href="#precisionStepDesc"><c>precisionStep</c></a>.
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeQuery NewFloatRange(System.String field, int precisionStep, System.Single min, System.Single max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeQuery(field, precisionStep, 32, min, max, minInclusive, maxInclusive);
-		}
-		
-		/// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>float</c>
-		/// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
-        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
-		/// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
-		/// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
-		/// </summary>
-		public static NumericRangeQuery NewFloatRange(System.String field, System.Single min, System.Single max, bool minInclusive, bool maxInclusive)
-		{
-			return new NumericRangeQuery(field, NumericUtils.PRECISION_STEP_DEFAULT, 32, min, max, minInclusive, maxInclusive);
-		}
-		
 		//@Override
 		public /*protected internal*/ override FilteredTermEnum GetEnum(IndexReader reader)
 		{
@@ -309,13 +223,13 @@ namespace Lucene.Net.Search
 		}
 		
 		/// <summary>Returns the lower value of this range query </summary>
-		public System.ValueType GetMin()
+		public T? GetMin()
 		{
 			return min;
 		}
 		
 		/// <summary>Returns the upper value of this range query </summary>
-		public System.ValueType GetMax()
+		public T? GetMax()
 		{
 			return max;
 		}
@@ -326,8 +240,8 @@ namespace Lucene.Net.Search
 			System.Text.StringBuilder sb = new System.Text.StringBuilder();
 			if (!this.field.Equals(field))
 				sb.Append(this.field).Append(':');
-			return sb.Append(minInclusive?'[':'{').Append((min == null)?"*":min.ToString()).Append(" TO ").Append((max == null)?"*":max.ToString()).Append(maxInclusive?']':'}').Append(ToStringUtils.Boost(GetBoost())).ToString();
-		}
+            return sb.Append(minInclusive ? '[' : '{').Append((min == null) ? "*" : min.ToString()).Append(" TO ").Append((max == null) ? "*" : max.ToString()).Append(maxInclusive ? ']' : '}').Append(ToStringUtils.Boost(GetBoost())).ToString();
+        }
 		
 		//@Override
 		public  override bool Equals(System.Object o)
@@ -336,11 +250,11 @@ namespace Lucene.Net.Search
 				return true;
 			if (!base.Equals(o))
 				return false;
-			if (o is NumericRangeQuery)
+			if (o is NumericRangeQuery<T>)
 			{
-				NumericRangeQuery q = (NumericRangeQuery) o;
-				return ((System.Object) field == (System.Object) q.field && (q.min == null?min == null:q.min.Equals(min)) && (q.max == null?max == null:q.max.Equals(max)) && minInclusive == q.minInclusive && maxInclusive == q.maxInclusive && precisionStep == q.precisionStep);
-			}
+                NumericRangeQuery<T> q = (NumericRangeQuery<T>)o;
+                return ((System.Object)field == (System.Object)q.field && (q.min == null ? min == null : q.min.Equals(min)) && (q.max == null ? max == null : q.max.Equals(max)) && minInclusive == q.minInclusive && maxInclusive == q.maxInclusive && precisionStep == q.precisionStep);
+            }
 			return false;
 		}
 		
@@ -348,11 +262,11 @@ namespace Lucene.Net.Search
 		public override int GetHashCode()
 		{
 			int hash = base.GetHashCode();
-			hash += (field.GetHashCode() ^ 0x4565fd66 + precisionStep ^ 0x64365465);
-			if (min != null)
-				hash += (min.GetHashCode() ^ 0x14fa55fb);
-			if (max != null)
-				hash += (max.GetHashCode() ^ 0x733fa5fe);
+            hash += (field.GetHashCode() ^ 0x4565fd66 + precisionStep ^ 0x64365465);
+            if (min != null)
+                hash += (min.GetHashCode() ^ 0x14fa55fb);
+            if (max != null)
+                hash += (max.GetHashCode() ^ 0x733fa5fe);
 			return hash + (minInclusive.GetHashCode() ^ 0x14fa55fb) + (maxInclusive.GetHashCode() ^ 0x733fa5fe);
 		}
 
@@ -374,8 +288,8 @@ namespace Lucene.Net.Search
 		internal System.String field;
 		internal int precisionStep;
 		internal int valSize;
-		internal System.ValueType min;
-		internal System.ValueType max;
+		internal T? min;
+		internal T? max;
 		internal bool minInclusive;
 		internal bool maxInclusive;
 		
@@ -412,8 +326,8 @@ namespace Lucene.Net.Search
 				//@Override
 				public override void  AddRange(System.String minPrefixCoded, System.String maxPrefixCoded)
 				{
-					Enclosing_Instance.rangeBounds.Add(minPrefixCoded);
-					Enclosing_Instance.rangeBounds.Add(maxPrefixCoded);
+					Enclosing_Instance.rangeBounds.AddLast(minPrefixCoded);
+                    Enclosing_Instance.rangeBounds.AddLast(maxPrefixCoded);
 				}
 			}
 			private class AnonymousClassIntRangeBuilder:NumericUtils.IntRangeBuilder
@@ -438,16 +352,17 @@ namespace Lucene.Net.Search
 				//@Override
 				public override void  AddRange(System.String minPrefixCoded, System.String maxPrefixCoded)
 				{
-					Enclosing_Instance.rangeBounds.Add(minPrefixCoded);
-					Enclosing_Instance.rangeBounds.Add(maxPrefixCoded);
+                    Enclosing_Instance.rangeBounds.AddLast(minPrefixCoded);
+                    Enclosing_Instance.rangeBounds.AddLast(maxPrefixCoded);
 				}
 			}
-			private void  InitBlock(NumericRangeQuery enclosingInstance)
+			private void  InitBlock(NumericRangeQuery<T> enclosingInstance)
 			{
 				this.enclosingInstance = enclosingInstance;
+                termTemplate = new Term(Enclosing_Instance.field);
 			}
-			private NumericRangeQuery enclosingInstance;
-			public NumericRangeQuery Enclosing_Instance
+            private NumericRangeQuery<T> enclosingInstance;
+            public NumericRangeQuery<T> Enclosing_Instance
 			{
 				get
 				{
@@ -457,29 +372,34 @@ namespace Lucene.Net.Search
 			}
 			
 			private IndexReader reader;
-			private System.Collections.ArrayList rangeBounds = new System.Collections.ArrayList();
+            private LinkedList<string> rangeBounds = new LinkedList<string>();
+		    private Term termTemplate;
 			private System.String currentUpperBound = null;
-			
-			internal NumericRangeTermEnum(NumericRangeQuery enclosingInstance, IndexReader reader)
+
+            internal NumericRangeTermEnum(NumericRangeQuery<T> enclosingInstance, IndexReader reader)
 			{
 				InitBlock(enclosingInstance);
 				this.reader = reader;
 				
+				Type rangeType = Nullable.GetUnderlyingType(typeof(T?));
 				switch (Enclosing_Instance.valSize)
 				{
-					
 					case 64:  {
 							// lower
 							long minBound = System.Int64.MinValue;
-							if (Enclosing_Instance.min is System.Int64)
-							{
-								minBound = System.Convert.ToInt64(Enclosing_Instance.min);
-							}
-							else if (Enclosing_Instance.min is System.Double)
-							{
-								minBound = NumericUtils.DoubleToSortableLong(System.Convert.ToDouble(Enclosing_Instance.min));
+                            if (rangeType == typeof(System.Int64))
+                            {
+                                // added in these checks to emulate java.  passing null give it no type (in old code), 
+                                // but .net can identifies it with generics and sets the bounds to 0, causing tests to fail
+                                if (Enclosing_Instance.min != null) 
+								    minBound = System.Convert.ToInt64(Enclosing_Instance.min);
+							}
+                            else if (rangeType == typeof(System.Double))
+                            {
+                                if (Enclosing_Instance.min != null)
+								    minBound = NumericUtils.DoubleToSortableLong(System.Convert.ToDouble(Enclosing_Instance.min));
 							}
-							if (!Enclosing_Instance.minInclusive && Enclosing_Instance.min != null)
+                            if (!Enclosing_Instance.minInclusive && Enclosing_Instance.min != null)
 							{
 								if (minBound == System.Int64.MaxValue)
 									break;
@@ -488,15 +408,17 @@ namespace Lucene.Net.Search
 							
 							// upper
 							long maxBound = System.Int64.MaxValue;
-							if (Enclosing_Instance.max is System.Int64)
-							{
-								maxBound = System.Convert.ToInt64(Enclosing_Instance.max);
-							}
-							else if (Enclosing_Instance.max is System.Double)
-							{
-								maxBound = NumericUtils.DoubleToSortableLong(System.Convert.ToDouble(Enclosing_Instance.max));
+                            if (rangeType == typeof(System.Int64))
+                            {
+                                if (Enclosing_Instance.max != null)
+								    maxBound = System.Convert.ToInt64(Enclosing_Instance.max);
+							}
+                            else if (rangeType == typeof(System.Double))
+                            {
+                                if (Enclosing_Instance.max != null)
+								    maxBound = NumericUtils.DoubleToSortableLong(System.Convert.ToDouble(Enclosing_Instance.max));
 							}
-							if (!Enclosing_Instance.maxInclusive && Enclosing_Instance.max != null)
+                            if (!Enclosing_Instance.maxInclusive && Enclosing_Instance.max != null)
 							{
 								if (maxBound == System.Int64.MinValue)
 									break;
@@ -511,15 +433,17 @@ namespace Lucene.Net.Search
 					case 32:  {
 							// lower
 							int minBound = System.Int32.MinValue;
-							if (Enclosing_Instance.min is System.Int32)
+                            if (rangeType == typeof(System.Int32))
 							{
-								minBound = System.Convert.ToInt32(Enclosing_Instance.min);
+                                if (Enclosing_Instance.min != null)
+								    minBound = System.Convert.ToInt32(Enclosing_Instance.min);
+                            }
+                            else if (rangeType == typeof(System.Single))
+                            {
+                                if (Enclosing_Instance.min != null)
+								    minBound = NumericUtils.FloatToSortableInt(System.Convert.ToSingle(Enclosing_Instance.min));
 							}
-							else if (Enclosing_Instance.min is System.Single)
-							{
-								minBound = NumericUtils.FloatToSortableInt(System.Convert.ToSingle(Enclosing_Instance.min));
-							}
-							if (!Enclosing_Instance.minInclusive && Enclosing_Instance.min != null)
+                            if (!Enclosing_Instance.minInclusive && Enclosing_Instance.min != null)
 							{
 								if (minBound == System.Int32.MaxValue)
 									break;
@@ -527,16 +451,18 @@ namespace Lucene.Net.Search
 							}
 							
 							// upper
-							int maxBound = System.Int32.MaxValue;
-							if (Enclosing_Instance.max is System.Int32)
-							{
-								maxBound = System.Convert.ToInt32(Enclosing_Instance.max);
+                            int maxBound = System.Int32.MaxValue;
+                            if (rangeType == typeof(System.Int32))
+                            {
+                                if (Enclosing_Instance.max != null)
+								    maxBound = System.Convert.ToInt32(Enclosing_Instance.max);
+							}
+                            else if (rangeType == typeof(System.Single))
+                            {
+                                if (Enclosing_Instance.max != null)
+								    maxBound = NumericUtils.FloatToSortableInt(System.Convert.ToSingle(Enclosing_Instance.max));
 							}
-							else if (Enclosing_Instance.max is System.Single)
-							{
-								maxBound = NumericUtils.FloatToSortableInt(System.Convert.ToSingle(Enclosing_Instance.max));
-							}
-							if (!Enclosing_Instance.maxInclusive && Enclosing_Instance.max != null)
+                            if (!Enclosing_Instance.maxInclusive && Enclosing_Instance.max != null)
 							{
 								if (maxBound == System.Int32.MinValue)
 									break;
@@ -568,9 +494,14 @@ namespace Lucene.Net.Search
 			//@Override
 			public override bool EndEnum()
 			{
-				System.Diagnostics.Debug.Assert(false); // should never be called
-				return (currentTerm != null);
+			    throw new NotSupportedException("not implemented");
 			}
+
+            /// <summary>this is a dummy, it is not used by this class. </summary>
+            protected internal override void SetEnum(TermEnum tenum)
+            {
+                throw new NotSupportedException("not implemented");
+            }
 			
 			/// <summary> Compares if current upper bound is reached,
 			/// this also updates the term count for statistics.
@@ -581,53 +512,55 @@ namespace Lucene.Net.Search
 			//@Override
 			public /*protected internal*/ override bool TermCompare(Term term)
 			{
-				return ((System.Object) term.Field() == (System.Object) Enclosing_Instance.field && String.CompareOrdinal(term.Text(), currentUpperBound) <= 0);
+				return (term.Field() == Enclosing_Instance.field && String.CompareOrdinal(term.Text(), currentUpperBound) <= 0);
 			}
 			
 			/// <summary>Increments the enumeration to the next element.  True if one exists. </summary>
 			//@Override
-			public override bool Next()
+            public override bool Next()
 			{
-				// if a current term exists, the actual enum is initialized:
-				// try change to next term, if no such term exists, fall-through
-				if (currentTerm != null)
-				{
-					System.Diagnostics.Debug.Assert(actualEnum != null);
-					if (actualEnum.Next())
-					{
-						currentTerm = actualEnum.Term();
-						if (TermCompare(currentTerm))
-							return true;
-					}
-				}
-				// if all above fails, we go forward to the next enum,
-				// if one is available
-				currentTerm = null;
-				if (rangeBounds.Count < 2)
-					return false;
-				// close the current enum and read next bounds
-				if (actualEnum != null)
-				{
-					actualEnum.Close();
-					actualEnum = null;
-				}
-				System.Object tempObject;
-				tempObject = rangeBounds[0];
-				rangeBounds.RemoveAt(0);
-				System.String lowerBound = (System.String) tempObject;
-				System.Object tempObject2;
-				tempObject2 = rangeBounds[0];
-				rangeBounds.RemoveAt(0);
-				this.currentUpperBound = ((System.String) tempObject2);
-				// this call recursively uses next(), if no valid term in
-				// next enum found.
-				// if this behavior is changed/modified in the superclass,
-				// this enum will not work anymore!
-				SetEnum(reader.Terms(new Term(Enclosing_Instance.field, lowerBound)));
-				return (currentTerm != null);
+			    // if a current term exists, the actual enum is initialized:
+			    // try change to next term, if no such term exists, fall-through
+			    if (currentTerm != null)
+			    {
+			        System.Diagnostics.Debug.Assert(actualEnum != null);
+			        if (actualEnum.Next())
+			        {
+			            currentTerm = actualEnum.Term();
+			            if (TermCompare(currentTerm))
+			                return true;
+			        }
+			    }
+			    // if all above fails, we go forward to the next enum,
+			    // if one is available
+			    currentTerm = null;
+			    while (rangeBounds.Count >= 2)
+			    {
+			        // close the current enum and read next bounds
+			        if (actualEnum != null)
+			        {
+			            actualEnum.Close();
+			            actualEnum = null;
+			        }
+			        string lowerBound = rangeBounds.First.Value;
+			        rangeBounds.RemoveFirst();
+			        this.currentUpperBound = rangeBounds.First.Value;
+			        rangeBounds.RemoveFirst();
+			        // create a new enum
+			        actualEnum = reader.Terms(termTemplate.CreateTerm(lowerBound));
+			        currentTerm = actualEnum.Term();
+			        if (currentTerm != null && TermCompare(currentTerm))
+			            return true;
+			        // clear the current term for next iteration
+			        currentTerm = null;
+			    }
+
+			    // no more sub-range enums available
+			    System.Diagnostics.Debug.Assert(rangeBounds.Count == 0 && currentTerm == null);
+			    return false;
 			}
-			
-			/// <summary>Closes the enumeration to further activity, freeing resources.  </summary>
+
+		    /// <summary>Closes the enumeration to further activity, freeing resources.  </summary>
 			//@Override
 			public override void  Close()
 			{
@@ -642,4 +575,95 @@ namespace Lucene.Net.Search
 		    }
 		}
 	}
+
+    public static class NumericRangeQuery
+    {
+        /// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>long</c>
+        /// range using the given <a href="#precisionStepDesc"><c>precisionStep</c></a>.
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeQuery<long> NewLongRange(System.String field, int precisionStep, long? min, long? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeQuery<long>(field, precisionStep, 64, min, max, minInclusive, maxInclusive);
+        }
+
+        /// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>long</c>
+        /// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeQuery<long> NewLongRange(System.String field, long? min, long? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeQuery<long>(field, NumericUtils.PRECISION_STEP_DEFAULT, 64, min, max, minInclusive, maxInclusive);
+        }
+
+        /// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>int</c>
+        /// range using the given <a href="#precisionStepDesc"><c>precisionStep</c></a>.
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeQuery<int> NewIntRange(System.String field, int precisionStep, int? min, int? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeQuery<int>(field, precisionStep, 32, min, max, minInclusive, maxInclusive);
+        }
+
+        /// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>int</c>
+        /// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeQuery<int> NewIntRange(System.String field, int? min, int? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeQuery<int>(field, NumericUtils.PRECISION_STEP_DEFAULT, 32, min, max, minInclusive, maxInclusive);
+        }
+
+        /// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>double</c>
+        /// range using the given <a href="#precisionStepDesc"><c>precisionStep</c></a>.
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeQuery<double> NewDoubleRange(System.String field, int precisionStep, double? min, double? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeQuery<double>(field, precisionStep, 64, min, max, minInclusive, maxInclusive);
+        }
+
+        /// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>double</c>
+        /// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeQuery<double> NewDoubleRange(System.String field, double? min, double? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeQuery<double>(field, NumericUtils.PRECISION_STEP_DEFAULT, 64, min, max, minInclusive, maxInclusive);
+        }
+
+        /// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>float</c>
+        /// range using the given <a href="#precisionStepDesc"><c>precisionStep</c></a>.
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeQuery<float> NewFloatRange(System.String field, int precisionStep, float? min, float? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeQuery<float>(field, precisionStep, 32, min, max, minInclusive, maxInclusive);
+        }
+
+        /// <summary> Factory that creates a <c>NumericRangeQuery</c>, that queries a <c>float</c>
+        /// range using the default <c>precisionStep</c> <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4).
+        /// You can have half-open ranges (which are in fact &lt;/&#8804; or &gt;/&#8805; queries)
+        /// by setting the min or max value to <c>null</c>. By setting inclusive to false, it will
+        /// match all documents excluding the bounds, with inclusive on, the boundaries are hits, too.
+        /// </summary>
+        public static NumericRangeQuery<float> NewFloatRange(System.String field, float? min, float? max, bool minInclusive, bool maxInclusive)
+        {
+            return new NumericRangeQuery<float>(field, NumericUtils.PRECISION_STEP_DEFAULT, 32, min, max, minInclusive, maxInclusive);
+        }
+    }
 }
\ No newline at end of file

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Payloads/PayloadNearQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Payloads/PayloadNearQuery.cs?rev=1203769&r1=1203768&r2=1203769&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Payloads/PayloadNearQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Payloads/PayloadNearQuery.cs Fri Nov 18 17:54:13 2011
@@ -40,13 +40,13 @@ namespace Lucene.Net.Search.Payloads
 	/// <see cref="Lucene.Net.Search.Spans.TermSpans" /> occurs.
 	/// <p/>
 	/// In order to take advantage of this, you must override
-	/// <see cref="Lucene.Net.Search.Similarity.ScorePayload(String, byte[],int,int)" />
+	/// <see cref="Lucene.Net.Search.Similarity.ScorePayload" />
 	/// which returns 1 by default.
 	/// <p/>
 	/// Payload scores are aggregated using a pluggable <see cref="PayloadFunction" />.
 	/// 
 	/// </summary>
-	/// <seealso cref="Lucene.Net.Search.Similarity.ScorePayload(String, byte[], int,int)">
+	/// <seealso cref="Lucene.Net.Search.Similarity.ScorePayload">
 	/// </seealso>
 	[Serializable]
 	public class PayloadNearQuery:SpanNearQuery, System.ICloneable
@@ -76,8 +76,7 @@ namespace Lucene.Net.Search.Payloads
 			
 			for (int i = 0; i < sz; i++)
 			{
-				SpanQuery clause = (SpanQuery) clauses[i];
-				newClauses[i] = (SpanQuery) clause.Clone();
+				newClauses[i] = clauses[i];
 			}
 			PayloadNearQuery boostingNearQuery = new PayloadNearQuery(newClauses, slop, inOrder);
 			boostingNearQuery.SetBoost(GetBoost());
@@ -88,10 +87,10 @@ namespace Lucene.Net.Search.Payloads
 		{
 			System.Text.StringBuilder buffer = new System.Text.StringBuilder();
 			buffer.Append("payloadNear([");
-			System.Collections.IEnumerator i = clauses.GetEnumerator();
+			var i = clauses.GetEnumerator();
 			while (i.MoveNext())
 			{
-				SpanQuery clause = (SpanQuery) i.Current;
+				SpanQuery clause = i.Current;
 				buffer.Append(clause.ToString(field));
 				if (i.MoveNext())
 				{
@@ -164,12 +163,7 @@ namespace Lucene.Net.Search.Payloads
 			{
 				InitBlock(enclosingInstance);
 			}
-			
-			public virtual Scorer Scorer(IndexReader reader)
-			{
-				return new PayloadNearSpanScorer(enclosingInstance, query.GetSpans(reader), this, similarity, reader.Norms(query.GetField()));
-			}
-			
+
 			public override Scorer Scorer(IndexReader reader, bool scoreDocsInOrder, bool topScorer)
 			{
 				return new PayloadNearSpanScorer(enclosingInstance, query.GetSpans(reader), this, similarity, reader.Norms(query.GetField()));

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Payloads/PayloadTermQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Payloads/PayloadTermQuery.cs?rev=1203769&r1=1203768&r2=1203769&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Payloads/PayloadTermQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/Payloads/PayloadTermQuery.cs Fri Nov 18 17:54:13 2011
@@ -40,7 +40,7 @@ namespace Lucene.Net.Search.Payloads
 	/// <see cref="Lucene.Net.Index.Term" /> occurs.
 	/// <p/>
 	/// In order to take advantage of this, you must override
-	/// <see cref="Lucene.Net.Search.Similarity.ScorePayload(String, byte[],int,int)" />
+    /// <see cref="Lucene.Net.Search.Similarity.ScorePayload(int, String, int, int, byte[],int,int)" />
 	/// which returns 1 by default.
 	/// <p/>
 	/// Payload scores are aggregated using a pluggable <see cref="PayloadFunction" />.

Modified: incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PrefixFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PrefixFilter.cs?rev=1203769&r1=1203768&r2=1203769&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PrefixFilter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net.3.0.3/trunk/src/core/Search/PrefixFilter.cs Fri Nov 18 17:54:13 2011
@@ -26,7 +26,7 @@ namespace Lucene.Net.Search
 	/// field.
 	/// </summary>
 	[Serializable]
-	public class PrefixFilter:MultiTermQueryWrapperFilter
+	public class PrefixFilter:MultiTermQueryWrapperFilter<PrefixQuery>
 	{
 		
 		public PrefixFilter(Term prefix):base(new PrefixQuery(prefix))
@@ -35,7 +35,7 @@ namespace Lucene.Net.Search
 		
 		public virtual Term GetPrefix()
 		{
-			return ((PrefixQuery) query).GetPrefix();
+			return query.GetPrefix();
 		}
 		
 		/// <summary>Prints a user-readable version of this query. </summary>