lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mhern...@apache.org
Subject [17/50] [abbrv] Massive cleanup, reducing compiler errors
Date Tue, 24 Sep 2013 18:32:53 GMT
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/FieldMaskingSpanQuery.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/FieldMaskingSpanQuery.cs b/src/core/Search/Spans/FieldMaskingSpanQuery.cs
index 86c7c62..8abf847 100644
--- a/src/core/Search/Spans/FieldMaskingSpanQuery.cs
+++ b/src/core/Search/Spans/FieldMaskingSpanQuery.cs
@@ -95,7 +95,7 @@ namespace Lucene.Net.Search.Spans
         // :NOTE: getBoost and setBoost are not proxied to the maskedQuery
         // ...this is done to be more consistent with thigns like SpanFirstQuery
 
-        public override Spans GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
+        public override SpansBase GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
         {
             return maskedQuery.GetSpans(context, acceptDocs, termContexts);
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/NearSpansOrdered.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/NearSpansOrdered.cs b/src/core/Search/Spans/NearSpansOrdered.cs
index 8a9dfe8..a22ff84 100644
--- a/src/core/Search/Spans/NearSpansOrdered.cs
+++ b/src/core/Search/Spans/NearSpansOrdered.cs
@@ -27,412 +27,415 @@ using IndexReader = Lucene.Net.Index.IndexReader;
 
 namespace Lucene.Net.Search.Spans
 {
-	
-	/// <summary>A Spans that is formed from the ordered subspans of a SpanNearQuery
-	/// where the subspans do not overlap and have a maximum slop between them.
-	/// <p/>
-	/// The formed spans only contains minimum slop matches.<br/>
-	/// The matching slop is computed from the distance(s) between
-	/// the non overlapping matching Spans.<br/>
-	/// Successive matches are always formed from the successive Spans
-	/// of the SpanNearQuery.
-	/// <p/>
-	/// The formed spans may contain overlaps when the slop is at least 1.
-	/// For example, when querying using
-	/// <c>t1 t2 t3</c>
-	/// with slop at least 1, the fragment:
-	/// <c>t1 t2 t1 t3 t2 t3</c>
-	/// matches twice:
-	/// <c>t1 t2 .. t3      </c>
-	/// <c>      t1 .. t2 t3</c>
-	/// 
-	/// 
-	/// Expert:
-	/// Only public for subclassing.  Most implementations should not need this class
-	/// </summary>
-	public class NearSpansOrdered:Spans
-	{
-		internal class AnonymousClassComparator : System.Collections.IComparer
-		{
-			public AnonymousClassComparator(NearSpansOrdered enclosingInstance)
-			{
-			    this.enclosingInstance = enclosingInstance;
-			}
-
-			private NearSpansOrdered enclosingInstance;
-
-			public NearSpansOrdered Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
+
+    /// <summary>A Spans that is formed from the ordered subspans of a SpanNearQuery
+    /// where the subspans do not overlap and have a maximum slop between them.
+    /// <p/>
+    /// The formed spans only contains minimum slop matches.<br/>
+    /// The matching slop is computed from the distance(s) between
+    /// the non overlapping matching Spans.<br/>
+    /// Successive matches are always formed from the successive Spans
+    /// of the SpanNearQuery.
+    /// <p/>
+    /// The formed spans may contain overlaps when the slop is at least 1.
+    /// For example, when querying using
+    /// <c>t1 t2 t3</c>
+    /// with slop at least 1, the fragment:
+    /// <c>t1 t2 t1 t3 t2 t3</c>
+    /// matches twice:
+    /// <c>t1 t2 .. t3      </c>
+    /// <c>      t1 .. t2 t3</c>
+    /// 
+    /// 
+    /// Expert:
+    /// Only public for subclassing.  Most implementations should not need this class
+    /// </summary>
+    public class NearSpansOrdered : SpansBase
+    {
+        internal class AnonymousClassComparator : System.Collections.IComparer
+        {
+            public AnonymousClassComparator(NearSpansOrdered enclosingInstance)
+            {
+                this.enclosingInstance = enclosingInstance;
+            }
+
+            private NearSpansOrdered enclosingInstance;
+
+            public NearSpansOrdered Enclosing_Instance
+            {
+                get
+                {
+                    return enclosingInstance;
+                }
+
+            }
 
             public virtual int Compare(object o1, object o2)
-			{
-				return ((Spans) o1).Doc - ((Spans) o2).Doc;
-			}
-		}
-
-		private int allowedSlop;
-		private bool firstTime = true;
-		private bool more = false;
-		
-		/// <summary>The spans in the same order as the SpanNearQuery </summary>
-		private Spans[] subSpans;
-		
-		/// <summary>Indicates that all subSpans have same doc() </summary>
-		private bool inSameDoc = false;
-		
-		private int matchDoc = - 1;
-		private int matchStart = - 1;
-		private int matchEnd = - 1;
-		private IList<sbyte[]> matchPayload;
-		
-		private Spans[] subSpansByDoc;
-		private IComparer spanDocComparator;
-		
-		private SpanNearQuery query;
-		private bool collectPayloads = true;
-		
-		public NearSpansOrdered(SpanNearQuery spanNearQuery, AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
+            {
+                return ((SpansBase)o1).Doc - ((SpansBase)o2).Doc;
+            }
+        }
+
+        private int allowedSlop;
+        private bool firstTime = true;
+        private bool more = false;
+
+        /// <summary>The spans in the same order as the SpanNearQuery </summary>
+        private SpansBase[] subSpans;
+
+        /// <summary>Indicates that all subSpans have same doc() </summary>
+        private bool inSameDoc = false;
+
+        private int matchDoc = -1;
+        private int matchStart = -1;
+        private int matchEnd = -1;
+        private IList<sbyte[]> matchPayload;
+
+        private SpansBase[] subSpansByDoc;
+        private IComparer spanDocComparator;
+
+        private SpanNearQuery query;
+        private bool collectPayloads = true;
+
+        public NearSpansOrdered(SpanNearQuery spanNearQuery, AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
             : this(spanNearQuery, context, acceptDocs, termContexts, true)
-		{
-		}
+        {
+        }
 
         public NearSpansOrdered(SpanNearQuery spanNearQuery, AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts, bool collectPayloads)
-		{
+        {
             spanDocComparator = new AnonymousClassComparator(this);
-			if (spanNearQuery.GetClauses().Length < 2)
-			{
-				throw new ArgumentException("Less than 2 clauses: " + spanNearQuery);
-			}
-			this.collectPayloads = collectPayloads;
-			allowedSlop = spanNearQuery.Slop;
-			SpanQuery[] clauses = spanNearQuery.GetClauses();
-			subSpans = new Spans[clauses.Length];
-			matchPayload = new List<sbyte[]>();
-			subSpansByDoc = new Spans[clauses.Length];
-			for (int i = 0; i < clauses.Length; i++)
-			{
-				subSpans[i] = clauses[i].GetSpans(context, acceptDocs, termContexts);
-				subSpansByDoc[i] = subSpans[i]; // used in toSameDoc()
-			}
-			query = spanNearQuery; // kept for toString() only.
-		}
-		
-		// inherit javadocs
-
-	    public override int Doc
-	    {
-	        get { return matchDoc; }
-	    }
-
-	    // inherit javadocs
-
-	    public override int Start
-	    {
-	        get { return matchStart; }
-	    }
-
-	    // inherit javadocs
-
-	    public override int End
-	    {
-	        get { return matchEnd; }
-	    }
-
-	    public virtual Spans[] GetSubSpans()
-		{
-			return subSpans;
-		}
-		
-		// TODO: Remove warning after API has been finalized
-		// TODO: Would be nice to be able to lazy load payloads
-
-	    public override ICollection<sbyte[]> GetPayload()
-	    {
-	        return matchPayload;
-	    }
-
-	    // TODO: Remove warning after API has been finalized
-
-	    public override bool IsPayloadAvailable()
-	    {
-	        return matchPayload.Any();
-	    }
-
-        public override long Cost()
+            if (spanNearQuery.GetClauses().Length < 2)
+            {
+                throw new ArgumentException("Less than 2 clauses: " + spanNearQuery);
+            }
+            this.collectPayloads = collectPayloads;
+            allowedSlop = spanNearQuery.Slop;
+            SpanQuery[] clauses = spanNearQuery.GetClauses();
+            subSpans = new SpansBase[clauses.Length];
+            matchPayload = new List<sbyte[]>();
+            subSpansByDoc = new SpansBase[clauses.Length];
+            for (int i = 0; i < clauses.Length; i++)
+            {
+                subSpans[i] = clauses[i].GetSpans(context, acceptDocs, termContexts);
+                subSpansByDoc[i] = subSpans[i]; // used in toSameDoc()
+            }
+            query = spanNearQuery; // kept for toString() only.
+        }
+
+        // inherit javadocs
+
+        public override int Doc
+        {
+            get { return matchDoc; }
+        }
+
+        // inherit javadocs
+
+        public override int Start
+        {
+            get { return matchStart; }
+        }
+
+        // inherit javadocs
+
+        public override int End
+        {
+            get { return matchEnd; }
+        }
+
+        public virtual SpansBase[] GetSubSpans()
+        {
+            return subSpans;
+        }
+
+        // TODO: Remove warning after API has been finalized
+        // TODO: Would be nice to be able to lazy load payloads
+
+        public override ICollection<sbyte[]> GetPayload()
         {
-            var result = long.MaxValue;
-            foreach (var span in subSpans)
-                result = Math.Min(result, span.Cost());
-            return result;
+            return matchPayload;
         }
 
-	    // inherit javadocs
-		public override bool Next()
-		{
-			if (firstTime)
-			{
-				firstTime = false;
-			    foreach (Spans t in subSpans)
-			    {
-			        if (!t.Next())
-			        {
-			            more = false;
-			            return false;
-			        }
-			    }
-			    more = true;
-			}
-			if (collectPayloads)
-			{
-				matchPayload.Clear();
-			}
-			return AdvanceAfterOrdered();
-		}
-		
-		// inherit javadocs
-		public override bool SkipTo(int target)
-		{
-			if (firstTime)
-			{
-				firstTime = false;
-				for (int i = 0; i < subSpans.Length; i++)
-				{
-					if (!subSpans[i].SkipTo(target))
-					{
-						more = false;
-						return false;
-					}
-				}
-				more = true;
-			}
-			else if (more && (subSpans[0].Doc < target))
-			{
-				if (subSpans[0].SkipTo(target))
-				{
-					inSameDoc = false;
-				}
-				else
-				{
-					more = false;
-					return false;
-				}
-			}
-			if (collectPayloads)
-			{
-				matchPayload.Clear();
-			}
-			return AdvanceAfterOrdered();
-		}
-		
-		/// <summary>Advances the subSpans to just after an ordered match with a minimum slop
-		/// that is smaller than the slop allowed by the SpanNearQuery.
-		/// </summary>
-		/// <returns> true iff there is such a match.
-		/// </returns>
-		private bool AdvanceAfterOrdered()
-		{
-			while (more && (inSameDoc || ToSameDoc()))
-			{
-				if (StretchToOrder() && ShrinkToAfterShortestMatch())
-				{
-					return true;
-				}
-			}
-			return false; // no more matches
-		}
-		
-		
-		/// <summary>Advance the subSpans to the same document </summary>
-		private bool ToSameDoc()
-		{
-			Array.Sort(subSpansByDoc, spanDocComparator);
-			int firstIndex = 0;
-			int maxDoc = subSpansByDoc[subSpansByDoc.Length - 1].Doc;
-			while (subSpansByDoc[firstIndex].Doc != maxDoc)
-			{
-				if (!subSpansByDoc[firstIndex].SkipTo(maxDoc))
-				{
-					more = false;
-					inSameDoc = false;
-					return false;
-				}
-				maxDoc = subSpansByDoc[firstIndex].Doc;
-				if (++firstIndex == subSpansByDoc.Length)
-				{
-					firstIndex = 0;
-				}
-			}
-			for (int i = 0; i < subSpansByDoc.Length; i++)
-			{
-				Debug.Assert((subSpansByDoc [i].Doc == maxDoc)
-					, "NearSpansOrdered.toSameDoc() spans " + subSpansByDoc [0] 
-					+ "\n at doc " + subSpansByDoc [i].Doc 
-					+ ", but should be at " + maxDoc);
-			}
-			inSameDoc = true;
-			return true;
-		}
-		
-		/// <summary>Check whether two Spans in the same document are ordered.</summary>
-		/// <param name="spans1">
-		/// </param>
-		/// <param name="spans2">
-		/// </param>
-		/// <returns> true iff spans1 starts before spans2
-		/// or the spans start at the same position,
-		/// and spans1 ends before spans2.
-		/// </returns>
-		internal static bool DocSpansOrdered(Spans spans1, Spans spans2)
-		{
-			Debug.Assert(spans1.Doc == spans2.Doc, "doc1 " + spans1.Doc + " != doc2 " + spans2.Doc);
-			int start1 = spans1.Start;
-			int start2 = spans2.Start;
-			/* Do not call docSpansOrdered(int,int,int,int) to avoid invoking .end() : */
-			return (start1 == start2)?(spans1.End < spans2.End):(start1 < start2);
-		}
-		
-		/// <summary>Like <see cref="DocSpansOrdered(Spans,Spans)" />, but use the spans
-		/// starts and ends as parameters.
-		/// </summary>
-		private static bool DocSpansOrdered(int start1, int end1, int start2, int end2)
-		{
-			return (start1 == start2)?(end1 < end2):(start1 < start2);
-		}
-		
-		/// <summary>Order the subSpans within the same document by advancing all later spans
-		/// after the previous one.
-		/// </summary>
-		private bool StretchToOrder()
-		{
-			matchDoc = subSpans[0].Doc;
-			for (int i = 1; inSameDoc && (i < subSpans.Length); i++)
-			{
-				while (!DocSpansOrdered(subSpans[i - 1], subSpans[i]))
-				{
-					if (!subSpans[i].Next())
-					{
-						inSameDoc = false;
-						more = false;
-						break;
-					}
-					else if (matchDoc != subSpans[i].Doc)
-					{
-						inSameDoc = false;
-						break;
-					}
-				}
-			}
-			return inSameDoc;
-		}
-		
-		/// <summary>The subSpans are ordered in the same doc, so there is a possible match.
-		/// Compute the slop while making the match as short as possible by advancing
-		/// all subSpans except the last one in reverse order.
-		/// </summary>
-		private bool ShrinkToAfterShortestMatch()
-		{
-			matchStart = subSpans[subSpans.Length - 1].Start;
-			matchEnd = subSpans[subSpans.Length - 1].End;
+        // TODO: Remove warning after API has been finalized
+
+        public override bool IsPayloadAvailable()
+        {
+            return matchPayload.Any();
+        }
+
+        public override long Cost
+        {
+            get
+            {
+                var result = long.MaxValue;
+                foreach (var span in subSpans)
+                    result = Math.Min(result, span.Cost);
+                return result;
+            }
+        }
+
+        // inherit javadocs
+        public override bool Next()
+        {
+            if (firstTime)
+            {
+                firstTime = false;
+                foreach (Spans t in subSpans)
+                {
+                    if (!t.Next())
+                    {
+                        more = false;
+                        return false;
+                    }
+                }
+                more = true;
+            }
+            if (collectPayloads)
+            {
+                matchPayload.Clear();
+            }
+            return AdvanceAfterOrdered();
+        }
+
+        // inherit javadocs
+        public override bool SkipTo(int target)
+        {
+            if (firstTime)
+            {
+                firstTime = false;
+                for (int i = 0; i < subSpans.Length; i++)
+                {
+                    if (!subSpans[i].SkipTo(target))
+                    {
+                        more = false;
+                        return false;
+                    }
+                }
+                more = true;
+            }
+            else if (more && (subSpans[0].Doc < target))
+            {
+                if (subSpans[0].SkipTo(target))
+                {
+                    inSameDoc = false;
+                }
+                else
+                {
+                    more = false;
+                    return false;
+                }
+            }
+            if (collectPayloads)
+            {
+                matchPayload.Clear();
+            }
+            return AdvanceAfterOrdered();
+        }
+
+        /// <summary>Advances the subSpans to just after an ordered match with a minimum slop
+        /// that is smaller than the slop allowed by the SpanNearQuery.
+        /// </summary>
+        /// <returns> true iff there is such a match.
+        /// </returns>
+        private bool AdvanceAfterOrdered()
+        {
+            while (more && (inSameDoc || ToSameDoc()))
+            {
+                if (StretchToOrder() && ShrinkToAfterShortestMatch())
+                {
+                    return true;
+                }
+            }
+            return false; // no more matches
+        }
+
+
+        /// <summary>Advance the subSpans to the same document </summary>
+        private bool ToSameDoc()
+        {
+            Array.Sort(subSpansByDoc, spanDocComparator);
+            int firstIndex = 0;
+            int maxDoc = subSpansByDoc[subSpansByDoc.Length - 1].Doc;
+            while (subSpansByDoc[firstIndex].Doc != maxDoc)
+            {
+                if (!subSpansByDoc[firstIndex].SkipTo(maxDoc))
+                {
+                    more = false;
+                    inSameDoc = false;
+                    return false;
+                }
+                maxDoc = subSpansByDoc[firstIndex].Doc;
+                if (++firstIndex == subSpansByDoc.Length)
+                {
+                    firstIndex = 0;
+                }
+            }
+            for (int i = 0; i < subSpansByDoc.Length; i++)
+            {
+                Debug.Assert((subSpansByDoc[i].Doc == maxDoc)
+                    , "NearSpansOrdered.toSameDoc() spans " + subSpansByDoc[0]
+                    + "\n at doc " + subSpansByDoc[i].Doc
+                    + ", but should be at " + maxDoc);
+            }
+            inSameDoc = true;
+            return true;
+        }
+
+        /// <summary>Check whether two Spans in the same document are ordered.</summary>
+        /// <param name="spans1">
+        /// </param>
+        /// <param name="spans2">
+        /// </param>
+        /// <returns> true iff spans1 starts before spans2
+        /// or the spans start at the same position,
+        /// and spans1 ends before spans2.
+        /// </returns>
+        internal static bool DocSpansOrdered(SpansBase spans1, SpansBase spans2)
+        {
+            Debug.Assert(spans1.Doc == spans2.Doc, "doc1 " + spans1.Doc + " != doc2 " + spans2.Doc);
+            int start1 = spans1.Start;
+            int start2 = spans2.Start;
+            /* Do not call docSpansOrdered(int,int,int,int) to avoid invoking .end() : */
+            return (start1 == start2) ? (spans1.End < spans2.End) : (start1 < start2);
+        }
+
+        /// <summary>Like <see cref="DocSpansOrdered(Spans,Spans)" />, but use the spans
+        /// starts and ends as parameters.
+        /// </summary>
+        private static bool DocSpansOrdered(int start1, int end1, int start2, int end2)
+        {
+            return (start1 == start2) ? (end1 < end2) : (start1 < start2);
+        }
+
+        /// <summary>Order the subSpans within the same document by advancing all later spans
+        /// after the previous one.
+        /// </summary>
+        private bool StretchToOrder()
+        {
+            matchDoc = subSpans[0].Doc;
+            for (int i = 1; inSameDoc && (i < subSpans.Length); i++)
+            {
+                while (!DocSpansOrdered(subSpans[i - 1], subSpans[i]))
+                {
+                    if (!subSpans[i].Next())
+                    {
+                        inSameDoc = false;
+                        more = false;
+                        break;
+                    }
+                    else if (matchDoc != subSpans[i].Doc)
+                    {
+                        inSameDoc = false;
+                        break;
+                    }
+                }
+            }
+            return inSameDoc;
+        }
+
+        /// <summary>The subSpans are ordered in the same doc, so there is a possible match.
+        /// Compute the slop while making the match as short as possible by advancing
+        /// all subSpans except the last one in reverse order.
+        /// </summary>
+        private bool ShrinkToAfterShortestMatch()
+        {
+            matchStart = subSpans[subSpans.Length - 1].Start;
+            matchEnd = subSpans[subSpans.Length - 1].End;
 
             ISet<sbyte[]> possibleMatchPayloads = new HashSet<sbyte[]>();
             if (subSpans[subSpans.Length - 1].IsPayloadAvailable())
             {
                 possibleMatchPayloads.UnionWith(subSpans[subSpans.Length - 1].GetPayload());
             }
-			
-		    IList<sbyte[]> possiblePayload = null;
-			
-			int matchSlop = 0;
-			int lastStart = matchStart;
-			int lastEnd = matchEnd;
-			for (int i = subSpans.Length - 2; i >= 0; i--)
-			{
-				Spans prevSpans = subSpans[i];
-				if (collectPayloads && prevSpans.IsPayloadAvailable())
-				{
-					ICollection<sbyte[]> payload = prevSpans.GetPayload();
-					possiblePayload = new List<sbyte[]>(payload.Count);
-					possiblePayload.AddRange(payload);
-				}
-				
-				int prevStart = prevSpans.Start;
-				int prevEnd = prevSpans.End;
-				while (true)
-				{
-					// Advance prevSpans until after (lastStart, lastEnd)
-					if (!prevSpans.Next())
-					{
-						inSameDoc = false;
-						more = false;
-						break; // Check remaining subSpans for final match.
-					}
-					else if (matchDoc != prevSpans.Doc)
-					{
-						inSameDoc = false; // The last subSpans is not advanced here.
-						break; // Check remaining subSpans for last match in this document.
-					}
-					else
-					{
-						int ppStart = prevSpans.Start;
-						int ppEnd = prevSpans.End; // Cannot avoid invoking .end()
-						if (!DocSpansOrdered(ppStart, ppEnd, lastStart, lastEnd))
-						{
-							break; // Check remaining subSpans.
-						}
-						else
-						{
-							// prevSpans still before (lastStart, lastEnd)
-							prevStart = ppStart;
-							prevEnd = ppEnd;
-							if (collectPayloads && prevSpans.IsPayloadAvailable())
-							{
-								ICollection<sbyte[]> payload = prevSpans.GetPayload();
-								possiblePayload = new List<sbyte[]>(payload.Count);
-								possiblePayload.AddRange(payload);
-							}
-						}
-					}
-				}
-				
-				if (collectPayloads && possiblePayload != null)
-				{
+
+            IList<sbyte[]> possiblePayload = null;
+
+            int matchSlop = 0;
+            int lastStart = matchStart;
+            int lastEnd = matchEnd;
+            for (int i = subSpans.Length - 2; i >= 0; i--)
+            {
+                Spans prevSpans = subSpans[i];
+                if (collectPayloads && prevSpans.IsPayloadAvailable())
+                {
+                    ICollection<sbyte[]> payload = prevSpans.GetPayload();
+                    possiblePayload = new List<sbyte[]>(payload.Count);
+                    possiblePayload.AddRange(payload);
+                }
+
+                int prevStart = prevSpans.Start;
+                int prevEnd = prevSpans.End;
+                while (true)
+                {
+                    // Advance prevSpans until after (lastStart, lastEnd)
+                    if (!prevSpans.Next())
+                    {
+                        inSameDoc = false;
+                        more = false;
+                        break; // Check remaining subSpans for final match.
+                    }
+                    else if (matchDoc != prevSpans.Doc)
+                    {
+                        inSameDoc = false; // The last subSpans is not advanced here.
+                        break; // Check remaining subSpans for last match in this document.
+                    }
+                    else
+                    {
+                        int ppStart = prevSpans.Start;
+                        int ppEnd = prevSpans.End; // Cannot avoid invoking .end()
+                        if (!DocSpansOrdered(ppStart, ppEnd, lastStart, lastEnd))
+                        {
+                            break; // Check remaining subSpans.
+                        }
+                        else
+                        {
+                            // prevSpans still before (lastStart, lastEnd)
+                            prevStart = ppStart;
+                            prevEnd = ppEnd;
+                            if (collectPayloads && prevSpans.IsPayloadAvailable())
+                            {
+                                ICollection<sbyte[]> payload = prevSpans.GetPayload();
+                                possiblePayload = new List<sbyte[]>(payload.Count);
+                                possiblePayload.AddRange(payload);
+                            }
+                        }
+                    }
+                }
+
+                if (collectPayloads && possiblePayload != null)
+                {
                     possibleMatchPayloads.UnionWith(possiblePayload);
-				}
-				
-				Debug.Assert(prevStart <= matchStart);
-				if (matchStart > prevEnd)
-				{
-					// Only non overlapping spans add to slop.
-					matchSlop += (matchStart - prevEnd);
-				}
-				
-				/* Do not break on (matchSlop > allowedSlop) here to make sure
-				* that subSpans[0] is advanced after the match, if any.
-				*/
-				matchStart = prevStart;
-				lastStart = prevStart;
-				lastEnd = prevEnd;
-			}
-			
-			bool match = matchSlop <= allowedSlop;
-			
-			if (collectPayloads && match && possibleMatchPayloads.Count > 0)
-			{
+                }
+
+                Debug.Assert(prevStart <= matchStart);
+                if (matchStart > prevEnd)
+                {
+                    // Only non overlapping spans add to slop.
+                    matchSlop += (matchStart - prevEnd);
+                }
+
+                /* Do not break on (matchSlop > allowedSlop) here to make sure
+                * that subSpans[0] is advanced after the match, if any.
+                */
+                matchStart = prevStart;
+                lastStart = prevStart;
+                lastEnd = prevEnd;
+            }
+
+            bool match = matchSlop <= allowedSlop;
+
+            if (collectPayloads && match && possibleMatchPayloads.Count > 0)
+            {
                 matchPayload.AddRange(possibleMatchPayloads);
-			}
-			
-			return match; // ordered and allowed slop
-		}
-		
-		public override string ToString()
-		{
-			return GetType().FullName + "(" + query.ToString() + ")@" + (firstTime?"START":(more?(Doc + ":" + Start + "-" + End):"END"));
-		}
-	}
+            }
+
+            return match; // ordered and allowed slop
+        }
+
+        public override string ToString()
+        {
+            return GetType().FullName + "(" + query.ToString() + ")@" + (firstTime ? "START" : (more ? (Doc + ":" + Start + "-" + End) : "END"));
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/NearSpansUnordered.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/NearSpansUnordered.cs b/src/core/Search/Spans/NearSpansUnordered.cs
index 4e2750d..d472b87 100644
--- a/src/core/Search/Spans/NearSpansUnordered.cs
+++ b/src/core/Search/Spans/NearSpansUnordered.cs
@@ -24,399 +24,408 @@ using IndexReader = Lucene.Net.Index.IndexReader;
 
 namespace Lucene.Net.Search.Spans
 {
-	
-	/// <summary> Similar to <see cref="NearSpansOrdered" />, but for the unordered case.
-	/// 
-	/// Expert:
-	/// Only public for subclassing.  Most implementations should not need this class
-	/// </summary>
-	public class NearSpansUnordered : Spans
-	{
-		private SpanNearQuery query;
-		
-		private IList<SpansCell> ordered = new List<SpansCell>(); // spans in query order
-		private Spans[] subSpans;
-		private int slop; // from query
-		
-		private SpansCell first; // linked list of spans
-		private SpansCell last; // sorted by doc only
-		
-		private int totalLength; // sum of current lengths
-		
-		private CellQueue queue; // sorted queue of spans
-		private SpansCell max; // max element in queue
-		
-		private bool more = true; // true iff not done
-		private bool firstTime = true; // true before first next()
-		
-		private class CellQueue : PriorityQueue<SpansCell>
-		{
-			private NearSpansUnordered enclosingInstance;
-			public NearSpansUnordered Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			public CellQueue(NearSpansUnordered enclosingInstance, int size) : base(size)
-			{
-			    this.enclosingInstance = enclosingInstance;
-			}
+
+    /// <summary> Similar to <see cref="NearSpansOrdered" />, but for the unordered case.
+    /// 
+    /// Expert:
+    /// Only public for subclassing.  Most implementations should not need this class
+    /// </summary>
+    public class NearSpansUnordered : SpansBase
+    {
+        private SpanNearQuery query;
+
+        private IList<SpansCell> ordered = new List<SpansCell>(); // spans in query order
+        private SpansBase[] subSpans;
+        private int slop; // from query
+
+        private SpansCell first; // linked list of spans
+        private SpansCell last; // sorted by doc only
+
+        private int totalLength; // sum of current lengths
+
+        private CellQueue queue; // sorted queue of spans
+        private SpansCell max; // max element in queue
+
+        private bool more = true; // true iff not done
+        private bool firstTime = true; // true before first next()
+
+        private class CellQueue : PriorityQueue<SpansCell>
+        {
+            private NearSpansUnordered enclosingInstance;
+            public NearSpansUnordered Enclosing_Instance
+            {
+                get
+                {
+                    return enclosingInstance;
+                }
+
+            }
+            public CellQueue(NearSpansUnordered enclosingInstance, int size)
+                : base(size)
+            {
+                this.enclosingInstance = enclosingInstance;
+            }
 
             public override bool LessThan(SpansCell spans1, SpansCell spans2)
-			{
-				if (spans1.Doc == spans2.Doc)
-				{
-					return NearSpansOrdered.DocSpansOrdered(spans1, spans2);
-				}
-				else
-				{
-					return spans1.Doc < spans2.Doc;
-				}
-			}
-		}
-		
-		
-		/// <summary>Wraps a Spans, and can be used to form a linked list. </summary>
-		private class SpansCell:Spans
-		{
-			private NearSpansUnordered enclosingInstance;
-			public NearSpansUnordered Enclosing_Instance
-			{
-				get
-				{
-					return enclosingInstance;
-				}
-				
-			}
-			internal /*private*/ Spans spans;
-			internal /*private*/ SpansCell next;
-			private int length = - 1;
-			private int index;
-			
-			public SpansCell(NearSpansUnordered enclosingInstance, Spans spans, int index)
-			{
-			    this.enclosingInstance = enclosingInstance;
-				this.spans = spans;
-				this.index = index;
-			}
-			
-			public override bool Next()
-			{
-				return Adjust(spans.Next());
-			}
-			
-			public override bool SkipTo(int target)
-			{
-				return Adjust(spans.SkipTo(target));
-			}
-			
-			private bool Adjust(bool condition)
-			{
-				if (length != - 1)
-				{
-					Enclosing_Instance.totalLength -= length; // subtract old length
-				}
-				if (condition)
-				{
-					length = End - Start;
-					Enclosing_Instance.totalLength += length; // add new length
-					
-					if (Enclosing_Instance.max == null || Doc > Enclosing_Instance.max.Doc 
+            {
+                if (spans1.Doc == spans2.Doc)
+                {
+                    return NearSpansOrdered.DocSpansOrdered(spans1, spans2);
+                }
+                else
+                {
+                    return spans1.Doc < spans2.Doc;
+                }
+            }
+        }
+
+
+        /// <summary>Wraps a Spans, and can be used to form a linked list. </summary>
+        private class SpansCell : SpansBase
+        {
+            private NearSpansUnordered enclosingInstance;
+            public NearSpansUnordered Enclosing_Instance
+            {
+                get
+                {
+                    return enclosingInstance;
+                }
+
+            }
+            internal /*private*/ SpansBase spans;
+            internal /*private*/ SpansCell next;
+            private int length = -1;
+            private int index;
+
+            public SpansCell(NearSpansUnordered enclosingInstance, SpansBase spans, int index)
+            {
+                this.enclosingInstance = enclosingInstance;
+                this.spans = spans;
+                this.index = index;
+            }
+
+            public override bool Next()
+            {
+                return Adjust(spans.Next());
+            }
+
+            public override bool SkipTo(int target)
+            {
+                return Adjust(spans.SkipTo(target));
+            }
+
+            private bool Adjust(bool condition)
+            {
+                if (length != -1)
+                {
+                    Enclosing_Instance.totalLength -= length; // subtract old length
+                }
+                if (condition)
+                {
+                    length = End - Start;
+                    Enclosing_Instance.totalLength += length; // add new length
+
+                    if (Enclosing_Instance.max == null || Doc > Enclosing_Instance.max.Doc
                         || (Doc == Enclosing_Instance.max.Doc) && (End > Enclosing_Instance.max.End))
-					{
-						Enclosing_Instance.max = this;
-					}
-				}
-				Enclosing_Instance.more = condition;
-				return condition;
-			}
-
-		    public override int Doc
-		    {
-		        get { return spans.Doc; }
-		    }
-
-		    public override int Start
-		    {
-		        get { return spans.Start; }
-		    }
-
-		    public override int End
-		    {
-		        get { return spans.End; }
-		    }
-
-		    // TODO: Remove warning after API has been finalized
-
-		    public override ICollection<sbyte[]> GetPayload()
-		    {
-		        return spans.GetPayload().ToArray();
-		    }
-
-		    // TODO: Remove warning after API has been finalized
-
-		    public override bool IsPayloadAvailable()
-		    {
-		        return spans.IsPayloadAvailable();
-		    }
-
-		    public override string ToString()
-			{
-				return spans.ToString() + "#" + index;
-			}
-		}
-		
-		
-		public NearSpansUnordered(SpanNearQuery query, AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
-		{
-			this.query = query;
-			this.slop = query.Slop;
-			
-			SpanQuery[] clauses = query.GetClauses();
-			queue = new CellQueue(this, clauses.Length);
-			subSpans = new Spans[clauses.Length];
-			for (int i = 0; i < clauses.Length; i++)
-			{
-				SpansCell cell = new SpansCell(this, clauses[i].GetSpans(context, acceptDocs, termContexts), i);
-				ordered.Add(cell);
-				subSpans[i] = cell.spans;
-			}
-		}
-		public virtual Spans[] GetSubSpans()
-		{
-			return subSpans;
-		}
-		public override bool Next()
-		{
-			if (firstTime)
-			{
-				InitList(true);
-				ListToQueue(); // initialize queue
-				firstTime = false;
-			}
-			else if (more)
-			{
-				if (Min().Next())
-				{
-					// trigger further scanning
-					queue.UpdateTop(); // maintain queue
-				}
-				else
-				{
-					more = false;
-				}
-			}
-			
-			while (more)
-			{
-				
-				bool queueStale = false;
-				
-				if (Min().Doc != max.Doc)
-				{
-					// maintain list
-					QueueToList();
-					queueStale = true;
-				}
-				
-				// skip to doc w/ all clauses
-				
-				while (more && first.Doc < last.Doc)
-				{
-					more = first.SkipTo(last.Doc); // skip first upto last
-					FirstToLast(); // and move it to the end
-					queueStale = true;
-				}
-				
-				if (!more)
-					return false;
-				
-				// found doc w/ all clauses
-				
-				if (queueStale)
-				{
-					// maintain the queue
-					ListToQueue();
-					queueStale = false;
-				}
-				
-				if (AtMatch())
-				{
-					return true;
-				}
-				
-				more = Min().Next();
-				if (more)
-				{
-					queue.UpdateTop(); // maintain queue
-				}
-			}
-			return false; // no more matches
-		}
-		
-		public override bool SkipTo(int target)
-		{
-			if (firstTime)
-			{
-				// initialize
-				InitList(false);
-				for (SpansCell cell = first; more && cell != null; cell = cell.next)
-				{
-					more = cell.SkipTo(target); // skip all
-				}
-				if (more)
-				{
-					ListToQueue();
-				}
-				firstTime = false;
-			}
-			else
-			{
-				// normal case
-				while (more && Min().Doc < target)
-				{
-					// skip as needed
-					if (Min().SkipTo(target))
-					{
-						queue.UpdateTop();
-					}
-					else
-					{
-						more = false;
-					}
-				}
-			}
-			return more && (AtMatch() || Next());
-		}
-		
-		private SpansCell Min()
-		{
-			return queue.Top();
-		}
-
-	    public override int Doc
-	    {
-	        get { return Min().Doc; }
-	    }
-
-	    public override int Start
-	    {
-	        get { return Min().Start; }
-	    }
-
-	    public override int End
-	    {
-	        get { return max.End; }
-	    }
-
-	    // TODO: Remove warning after API has been finalized
-
-	    /// <summary> WARNING: The List is not necessarily in order of the the positions</summary>
-	    /// <returns> Collection of &amp;lt;c&amp;gt;byte[]&amp;lt;/c&amp;gt; payloads </returns>
-	    /// <throws>  IOException </throws>
-	    public override ICollection<sbyte[]> GetPayload()
-	    {
+                    {
+                        Enclosing_Instance.max = this;
+                    }
+                }
+                Enclosing_Instance.more = condition;
+                return condition;
+            }
+
+            public override int Doc
+            {
+                get { return spans.Doc; }
+            }
+
+            public override int Start
+            {
+                get { return spans.Start; }
+            }
+
+            public override int End
+            {
+                get { return spans.End; }
+            }
+
+            // TODO: Remove warning after API has been finalized
+
+            public override ICollection<sbyte[]> GetPayload()
+            {
+                return spans.GetPayload().ToArray();
+            }
+
+            // TODO: Remove warning after API has been finalized
+
+            public override bool IsPayloadAvailable()
+            {
+                return spans.IsPayloadAvailable();
+            }
+
+            public override long Cost
+            {
+                get { return spans.Cost; }
+            }
+
+            public override string ToString()
+            {
+                return spans.ToString() + "#" + index;
+            }
+        }
+
+
+        public NearSpansUnordered(SpanNearQuery query, AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
+        {
+            this.query = query;
+            this.slop = query.Slop;
+
+            SpanQuery[] clauses = query.GetClauses();
+            queue = new CellQueue(this, clauses.Length);
+            subSpans = new Spans[clauses.Length];
+            for (int i = 0; i < clauses.Length; i++)
+            {
+                SpansCell cell = new SpansCell(this, clauses[i].GetSpans(context, acceptDocs, termContexts), i);
+                ordered.Add(cell);
+                subSpans[i] = cell.spans;
+            }
+        }
+        public virtual SpansBase[] GetSubSpans()
+        {
+            return subSpans;
+        }
+        public override bool Next()
+        {
+            if (firstTime)
+            {
+                InitList(true);
+                ListToQueue(); // initialize queue
+                firstTime = false;
+            }
+            else if (more)
+            {
+                if (Min().Next())
+                {
+                    // trigger further scanning
+                    queue.UpdateTop(); // maintain queue
+                }
+                else
+                {
+                    more = false;
+                }
+            }
+
+            while (more)
+            {
+
+                bool queueStale = false;
+
+                if (Min().Doc != max.Doc)
+                {
+                    // maintain list
+                    QueueToList();
+                    queueStale = true;
+                }
+
+                // skip to doc w/ all clauses
+
+                while (more && first.Doc < last.Doc)
+                {
+                    more = first.SkipTo(last.Doc); // skip first upto last
+                    FirstToLast(); // and move it to the end
+                    queueStale = true;
+                }
+
+                if (!more)
+                    return false;
+
+                // found doc w/ all clauses
+
+                if (queueStale)
+                {
+                    // maintain the queue
+                    ListToQueue();
+                    queueStale = false;
+                }
+
+                if (AtMatch())
+                {
+                    return true;
+                }
+
+                more = Min().Next();
+                if (more)
+                {
+                    queue.UpdateTop(); // maintain queue
+                }
+            }
+            return false; // no more matches
+        }
+
+        public override bool SkipTo(int target)
+        {
+            if (firstTime)
+            {
+                // initialize
+                InitList(false);
+                for (SpansCell cell = first; more && cell != null; cell = cell.next)
+                {
+                    more = cell.SkipTo(target); // skip all
+                }
+                if (more)
+                {
+                    ListToQueue();
+                }
+                firstTime = false;
+            }
+            else
+            {
+                // normal case
+                while (more && Min().Doc < target)
+                {
+                    // skip as needed
+                    if (Min().SkipTo(target))
+                    {
+                        queue.UpdateTop();
+                    }
+                    else
+                    {
+                        more = false;
+                    }
+                }
+            }
+            return more && (AtMatch() || Next());
+        }
+
+        private SpansCell Min()
+        {
+            return queue.Top();
+        }
+
+        public override int Doc
+        {
+            get { return Min().Doc; }
+        }
+
+        public override int Start
+        {
+            get { return Min().Start; }
+        }
+
+        public override int End
+        {
+            get { return max.End; }
+        }
+
+        // TODO: Remove warning after API has been finalized
+
+        /// <summary> WARNING: The List is not necessarily in order of the the positions</summary>
+        /// <returns> Collection of &amp;lt;c&amp;gt;byte[]&amp;lt;/c&amp;gt; payloads </returns>
+        /// <throws>  IOException </throws>
+        public override ICollection<sbyte[]> GetPayload()
+        {
             ISet<sbyte[]> matchPayload = Support.Compatibility.SetFactory.CreateHashSet<sbyte[]>();
-	        for (SpansCell cell = first; cell != null; cell = cell.next)
-	        {
-	            if (cell.IsPayloadAvailable())
-	            {
-	                matchPayload.UnionWith(cell.GetPayload());
-	            }
-	        }
-	        return matchPayload;
-	    }
-
-	    // TODO: Remove warning after API has been finalized
-
-	    public override bool IsPayloadAvailable()
-	    {
-	        SpansCell pointer = Min();
-	        while (pointer != null)
-	        {
-	            if (pointer.IsPayloadAvailable())
-	            {
-	                return true;
-	            }
-	            pointer = pointer.next;
-	        }
-
-	        return false;
-	    }
-
-        public override long Cost()
+            for (SpansCell cell = first; cell != null; cell = cell.next)
+            {
+                if (cell.IsPayloadAvailable())
+                {
+                    matchPayload.UnionWith(cell.GetPayload());
+                }
+            }
+            return matchPayload;
+        }
+
+        // TODO: Remove warning after API has been finalized
+
+        public override bool IsPayloadAvailable()
+        {
+            SpansCell pointer = Min();
+            while (pointer != null)
+            {
+                if (pointer.IsPayloadAvailable())
+                {
+                    return true;
+                }
+                pointer = pointer.next;
+            }
+
+            return false;
+        }
+
+        public override long Cost
+        {
+            get
+            {
+                var minCost = long.MaxValue;
+                foreach (var item in subSpans)
+                    minCost = Math.Min(minCost, item.Cost);
+
+                return minCost;
+            }
+        }
+
+        public override string ToString()
+        {
+            return GetType().FullName + "(" + query.ToString() + ")@" + (firstTime ? "START" : (more ? (Doc + ":" + Start + "-" + End) : "END"));
+        }
+
+        private void InitList(bool next)
         {
-            var minCost = long.MaxValue;
-            foreach (var item in subSpans)
-                minCost = Math.Min(minCost, item.Cost());
+            for (int i = 0; more && i < ordered.Count; i++)
+            {
+                SpansCell cell = ordered[i];
+                if (next)
+                    more = cell.Next(); // move to first entry
+                if (more)
+                {
+                    AddToList(cell); // add to list
+                }
+            }
+        }
 
-            return minCost;
+        private void AddToList(SpansCell cell)
+        {
+            if (last != null)
+            {
+                // add next to end of list
+                last.next = cell;
+            }
+            else
+                first = cell;
+            last = cell;
+            cell.next = null;
         }
 
-	    public override string ToString()
-		{
-			return GetType().FullName + "(" + query.ToString() + ")@" + (firstTime?"START":(more?(Doc + ":" + Start + "-" + End):"END"));
-		}
-		
-		private void  InitList(bool next)
-		{
-			for (int i = 0; more && i < ordered.Count; i++)
-			{
-				SpansCell cell = ordered[i];
-				if (next)
-					more = cell.Next(); // move to first entry
-				if (more)
-				{
-					AddToList(cell); // add to list
-				}
-			}
-		}
-		
-		private void  AddToList(SpansCell cell)
-		{
-			if (last != null)
-			{
-				// add next to end of list
-				last.next = cell;
-			}
-			else
-				first = cell;
-			last = cell;
-			cell.next = null;
-		}
-		
-		private void  FirstToLast()
-		{
-			last.next = first; // move first to end of list
-			last = first;
-			first = first.next;
-			last.next = null;
-		}
-		
-		private void  QueueToList()
-		{
-			last = first = null;
-			while (queue.Top() != null)
-			{
-				AddToList(queue.Pop());
-			}
-		}
-		
-		private void  ListToQueue()
-		{
-			queue.Clear(); // rebuild queue
-			for (SpansCell cell = first; cell != null; cell = cell.next)
-			{
-				queue.Add(cell); // add to queue from list
-			}
-		}
-		
-		private bool AtMatch()
-		{
-			return (Min().Doc == max.Doc) && ((max.End - Min().Start - totalLength) <= slop);
-		}
-	}
+        private void FirstToLast()
+        {
+            last.next = first; // move first to end of list
+            last = first;
+            first = first.next;
+            last.next = null;
+        }
+
+        private void QueueToList()
+        {
+            last = first = null;
+            while (queue.Top() != null)
+            {
+                AddToList(queue.Pop());
+            }
+        }
+
+        private void ListToQueue()
+        {
+            queue.Clear(); // rebuild queue
+            for (SpansCell cell = first; cell != null; cell = cell.next)
+            {
+                queue.Add(cell); // add to queue from list
+            }
+        }
+
+        private bool AtMatch()
+        {
+            return (Min().Doc == max.Doc) && ((max.End - Min().Start - totalLength) <= slop);
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/SpanFirstQuery.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/SpanFirstQuery.cs b/src/core/Search/Spans/SpanFirstQuery.cs
index 92914cb..a0357e6 100644
--- a/src/core/Search/Spans/SpanFirstQuery.cs
+++ b/src/core/Search/Spans/SpanFirstQuery.cs
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 
+using Lucene.Net.Support;
 using System;
 using System.Text;
 using ToStringUtils = Lucene.Net.Util.ToStringUtils;
@@ -29,7 +30,7 @@ namespace Lucene.Net.Search.Spans
         {
         }
 
-        protected override AcceptStatus AcceptPosition(Spans spans)
+        protected override AcceptStatus AcceptPosition(SpansBase spans)
         {
             //assert spans.start() != spans.end() : "start equals end: " + spans.start();
             if (spans.Start >= end)
@@ -53,7 +54,7 @@ namespace Lucene.Net.Search.Spans
             return buffer.ToString();
         }
 
-        public override SpanFirstQuery Clone()
+        public override object Clone()
         {
             SpanFirstQuery spanFirstQuery = new SpanFirstQuery((SpanQuery) match.clone(), end);
             spanFirstQuery.Boost = Boost;
@@ -74,7 +75,7 @@ namespace Lucene.Net.Search.Spans
         public override int GetHashCode()
         {
             int h = match.hashCode();
-            h ^= (h << 8) | (h >> > 25); // reversible
+            h ^= (h << 8) | Number.URShift(h, 25); // reversible
             h ^= Float.floatToRawIntBits(Boost) ^ end;
             return h;
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/SpanMultiTermQueryWrapper.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/SpanMultiTermQueryWrapper.cs b/src/core/Search/Spans/SpanMultiTermQueryWrapper.cs
index 7902bee..4234488 100644
--- a/src/core/Search/Spans/SpanMultiTermQueryWrapper.cs
+++ b/src/core/Search/Spans/SpanMultiTermQueryWrapper.cs
@@ -15,7 +15,7 @@ namespace Lucene.Net.Search.Spans
         {
             this.query = query;
 
-            MultiTermQuery.RewriteMethod method = query.RewriteMethod;
+            MultiTermQuery.RewriteMethod method = query.GetRewriteMethod();
             if (method is TopTermsRewrite<Q>)
             {
                 int pqsize = ((TopTermsRewrite<Q>) method).Size;
@@ -31,7 +31,7 @@ namespace Lucene.Net.Search.Spans
         {
             get
             {
-                MultiTermQuery.RewriteMethod m = query.RewriteMethod;
+                MultiTermQuery.RewriteMethod m = query.GetRewriteMethod();
                 if (!(m is SpanRewriteMethod))
                     throw new NotSupportedException(
                         "You can only use SpanMultiTermQueryWrapper with a suitable SpanRewriteMethod.");
@@ -39,11 +39,11 @@ namespace Lucene.Net.Search.Spans
             }
             set
             {
-                query.RewriteMethod = value;
+                query.SetRewriteMethod(value);
             }
         }
 
-        public override Spans GetSpans(AtomicReaderContext context, IBits acceptDocs,
+        public override SpansBase GetSpans(AtomicReaderContext context, IBits acceptDocs,
                                        IDictionary<Term, TermContext> termContexts)
         {
             throw new NotSupportedException("Query should have been rewritten");
@@ -68,7 +68,7 @@ namespace Lucene.Net.Search.Spans
             var q = query.Rewrite(reader);
             if (!(q is SpanQuery))
                 throw new NotSupportedException(
-                    "You can only use SpanMultiTermQueryWrapper with a suitable SpanRewriteMethod.") 
+                    "You can only use SpanMultiTermQueryWrapper with a suitable SpanRewriteMethod.");
             return q;
         }
 
@@ -88,16 +88,19 @@ namespace Lucene.Net.Search.Spans
 
         public abstract class SpanRewriteMethod : MultiTermQuery.RewriteMethod
         {
-            public abstract override SpanQuery Rewrite(IndexReader reader, MultiTermQuery query);
+            public abstract override Query Rewrite(IndexReader reader, MultiTermQuery query);
         }
 
         private sealed class AnonymousScoringSpanQueryRewrite : SpanRewriteMethod
         {
             private sealed class AnonymousScoringRewrite : ScoringRewrite<SpanOrQuery>
             {
-                protected override SpanOrQuery GetTopLevelQuery()
+                protected override SpanOrQuery TopLevelQuery
                 {
-                    return new SpanOrQuery();
+                    get
+                    {
+                        return new SpanOrQuery();
+                    }
                 }
 
                 protected override void CheckMaxClauseCount(int count)
@@ -118,7 +121,7 @@ namespace Lucene.Net.Search.Spans
 
             private readonly ScoringRewrite<SpanOrQuery> _delegate = new AnonymousScoringRewrite();
 
-            public override SpanQuery Rewrite(IndexReader reader, MultiTermQuery query)
+            public override Query Rewrite(IndexReader reader, MultiTermQuery query)
             {
                 return _delegate.Rewrite(reader, query);
             }
@@ -141,9 +144,12 @@ namespace Lucene.Net.Search.Spans
                     get { return Int32.MaxValue; }
                 }
 
-                protected override SpanOrQuery GetTopLevelQuery()
+                protected override SpanOrQuery TopLevelQuery
                 {
-                    return new SpanOrQuery();
+                    get
+                    {
+                        return new SpanOrQuery();
+                    }
                 }
 
                 protected override void AddClause(SpanOrQuery topLevel, Term term, int docFreq, float boost,
@@ -167,7 +173,7 @@ namespace Lucene.Net.Search.Spans
                 return _delegate.Size;
             }
 
-            public override SpanQuery Rewrite(IndexReader reader, MultiTermQuery query)
+            public override Query Rewrite(IndexReader reader, MultiTermQuery query)
             {
                 return _delegate.Rewrite(reader, query);
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/SpanNearPayloadCheckQuery.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/SpanNearPayloadCheckQuery.cs b/src/core/Search/Spans/SpanNearPayloadCheckQuery.cs
index 081f902..f6224e3 100644
--- a/src/core/Search/Spans/SpanNearPayloadCheckQuery.cs
+++ b/src/core/Search/Spans/SpanNearPayloadCheckQuery.cs
@@ -16,7 +16,7 @@ namespace Lucene.Net.Search.Spans
             this.payloadToMatch = payloadToMatch;
         }
 
-        protected override AcceptStatus AcceptPosition(Spans spans)
+        protected override AcceptStatus AcceptPosition(SpansBase spans)
         {
             var result = spans.IsPayloadAvailable();
             if (result == true)
@@ -62,7 +62,7 @@ namespace Lucene.Net.Search.Spans
             return buffer.ToString();
         }
 
-        public override SpanNearPayloadCheckQuery Clone()
+        public override object Clone()
         {
             var result = new SpanNearPayloadCheckQuery((SpanNearQuery) match.clone(), payloadToMatch);
             result.Boost = Boost;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/SpanNearQuery.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/SpanNearQuery.cs b/src/core/Search/Spans/SpanNearQuery.cs
index de83a8b..b945f29 100644
--- a/src/core/Search/Spans/SpanNearQuery.cs
+++ b/src/core/Search/Spans/SpanNearQuery.cs
@@ -129,7 +129,7 @@ namespace Lucene.Net.Search.Spans
             return buffer.ToString();
         }
 
-        public override Spans GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
+        public override SpansBase GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
         {
             if (clauses.Count == 0)
                 // optimize 0-clause case
@@ -139,7 +139,7 @@ namespace Lucene.Net.Search.Spans
                 // optimize 1-clause case
                 return clauses[0].GetSpans(context, acceptDocs, termContexts);
 
-            return inOrder ? (Spans)new NearSpansOrdered(this, context, collectPayloads) : (Spans)new NearSpansUnordered(this, context);
+            return inOrder ? (SpansBase)new NearSpansOrdered(this, context, collectPayloads) : (SpansBase)new NearSpansUnordered(this, context);
         }
 
         public override Query Rewrite(IndexReader reader)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/SpanNotQuery.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/SpanNotQuery.cs b/src/core/Search/Spans/SpanNotQuery.cs
index 7173480..1502742 100644
--- a/src/core/Search/Spans/SpanNotQuery.cs
+++ b/src/core/Search/Spans/SpanNotQuery.cs
@@ -31,7 +31,7 @@ namespace Lucene.Net.Search.Spans
 	[Serializable]
 	public class SpanNotQuery:SpanQuery, ICloneable
 	{
-		private class AnonymousClassSpans : Spans
+		private class AnonymousClassSpans : SpansBase
 		{
 			public AnonymousClassSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts, SpanNotQuery enclosingInstance)
 			{
@@ -52,10 +52,10 @@ namespace Lucene.Net.Search.Spans
 				}
 				
 			}
-			private Spans includeSpans;
+			private SpansBase includeSpans;
 			private bool moreInclude = true;
 			
-			private Spans excludeSpans;
+			private SpansBase excludeSpans;
 			private bool moreExclude;
 			
 			public override bool Next()
@@ -141,9 +141,12 @@ namespace Lucene.Net.Search.Spans
 		        return includeSpans.IsPayloadAvailable();
 		    }
 
-            public override long Cost()
+            public override long Cost
             {
-                return includeSpans.Cost();
+                get
+                {
+                    return includeSpans.Cost;
+                }
             }
 
 		    public override string ToString()
@@ -206,7 +209,7 @@ namespace Lucene.Net.Search.Spans
 		    return spanNotQuery;
 		}
 		
-		public override Spans GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
+		public override SpansBase GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
 		{
 			return new AnonymousClassSpans(context, acceptDocs, termContexts, this);
 		}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/SpanOrQuery.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/SpanOrQuery.cs b/src/core/Search/Spans/SpanOrQuery.cs
index a717ee9..5f41b47 100644
--- a/src/core/Search/Spans/SpanOrQuery.cs
+++ b/src/core/Search/Spans/SpanOrQuery.cs
@@ -32,7 +32,7 @@ namespace Lucene.Net.Search.Spans
 	[Serializable]
 	public class SpanOrQuery : SpanQuery, ICloneable
 	{
-		private class AnonymousClassSpans : Spans
+		private class AnonymousClassSpans : SpansBase
 		{
 			public AnonymousClassSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts, SpanOrQuery enclosingInstance)
 			{
@@ -95,7 +95,7 @@ namespace Lucene.Net.Search.Spans
 				return queue.Size != 0;
 			}
 			
-			private Spans Top()
+			private SpansBase Top()
 			{
 				return queue.Top();
 			}
@@ -143,9 +143,12 @@ namespace Lucene.Net.Search.Spans
 		        get { return Top().End; }
 		    }
 
-		    public override long Cost()
+		    public override long Cost
             {
-                return cost;
+                get
+                {
+                    return cost;
+                }
             }
 
 		    public override ICollection<sbyte[]> GetPayload()
@@ -304,7 +307,7 @@ namespace Lucene.Net.Search.Spans
 		}
 		
 		
-		private class SpanQueue : Util.PriorityQueue<Spans>
+		private class SpanQueue : Util.PriorityQueue<SpansBase>
 		{
 			private SpanOrQuery enclosingInstance;
 			public SpanOrQuery Enclosing_Instance
@@ -320,7 +323,7 @@ namespace Lucene.Net.Search.Spans
                 this.enclosingInstance = enclosingInstance;
 			}
 
-            public override bool LessThan(Spans spans1, Spans spans2)
+            public override bool LessThan(SpansBase spans1, SpansBase spans2)
 			{
 				if (spans1.Doc == spans2.Doc)
 				{
@@ -340,7 +343,7 @@ namespace Lucene.Net.Search.Spans
 			}
 		}
 		
-		public override Spans GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
+		public override SpansBase GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
 		{
 			if (clauses.Count == 1)
 			// optimize 1-clause case

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/SpanPayloadCheckQuery.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/SpanPayloadCheckQuery.cs b/src/core/Search/Spans/SpanPayloadCheckQuery.cs
index f1483d4..d56a91c 100644
--- a/src/core/Search/Spans/SpanPayloadCheckQuery.cs
+++ b/src/core/Search/Spans/SpanPayloadCheckQuery.cs
@@ -18,7 +18,7 @@ namespace Lucene.Net.Search.Spans
             this.payloadToMatch = payloadToMatch;
         }
 
-        protected override AcceptStatus AcceptPosition(Spans spans)
+        protected override AcceptStatus AcceptPosition(SpansBase spans)
         {
             var result = spans.IsPayloadAvailable();
             if (result == true)
@@ -45,11 +45,11 @@ namespace Lucene.Net.Search.Spans
             return AcceptStatus.YES;
         }
 
-        public override string ToString()
+        public override string ToString(string field)
         {
             var buffer = new StringBuilder();
             buffer.Append("spanPayCheck(");
-            buffer.Append(Match.ToString(Field));
+            buffer.Append(Match.ToString(field));
             buffer.Append(", payloadRef: ");
             foreach (var bytes in payloadToMatch)
             {
@@ -61,7 +61,7 @@ namespace Lucene.Net.Search.Spans
             return buffer.ToString();
         }
 
-        public override SpanPayloadCheckQuery Clone()
+        public override object Clone()
         {
             return new SpanPayloadCheckQuery((SpanQuery) Match.Clone(), payloadToMatch) { Boost = Boost };
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/SpanPositionCheckQuery.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/SpanPositionCheckQuery.cs b/src/core/Search/Spans/SpanPositionCheckQuery.cs
index a5c20ae..b24c9ef 100644
--- a/src/core/Search/Spans/SpanPositionCheckQuery.cs
+++ b/src/core/Search/Spans/SpanPositionCheckQuery.cs
@@ -10,18 +10,20 @@ namespace Lucene.Net.Search.Spans
     /// </summary>
     public abstract class SpanPositionCheckQuery : SpanQuery, ICloneable
     {
-        public virtual SpanQuery Match { get; protected set; }
+        protected SpanQuery match;
 
         protected SpanPositionCheckQuery(SpanQuery match)
         {
-            Match = match;
+            this.match = match;
         }
 
-        public override string Field { get { return Match.Field; } }
+        public SpanQuery Match { get { return match; } }
+
+        public override string Field { get { return match.Field; } }
 
         public override void ExtractTerms(ISet<Term> terms)
         {
-            Match.ExtractTerms(terms);
+            match.ExtractTerms(terms);
         }
         
         protected enum AcceptStatus
@@ -43,9 +45,9 @@ namespace Lucene.Net.Search.Spans
             NO_AND_ADVANCE
         }
 
-        protected abstract AcceptStatus AcceptPosition(Spans spans);
+        protected abstract AcceptStatus AcceptPosition(SpansBase spans);
 
-        public override Spans GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
+        public override SpansBase GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
         {
             return new PositionCheckSpan(context, acceptDocs, termContexts);
         }
@@ -58,7 +60,7 @@ namespace Lucene.Net.Search.Spans
             if (rewritten != Match)
             {
                 clone = (SpanPositionCheckQuery) this.Clone();
-                clone.Match = rewritten;
+                clone.match = rewritten;
             }
 
             if (clone != null)
@@ -71,9 +73,9 @@ namespace Lucene.Net.Search.Spans
             }
         }
 
-        protected class PositionCheckSpan : Spans
+        protected class PositionCheckSpan : SpansBase
         {
-            private Spans spans;
+            private SpansBase spans;
 
             private SpanPositionCheckQuery parent;
 
@@ -143,9 +145,12 @@ namespace Lucene.Net.Search.Spans
                 return spans.IsPayloadAvailable();
             }
 
-            public override long Cost()
+            public override long Cost
             {
-                return spans.Cost();
+                get
+                {
+                    return spans.Cost;
+                }
             }
 
             public override string ToString()

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/SpanPositionRangeQuery.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/SpanPositionRangeQuery.cs b/src/core/Search/Spans/SpanPositionRangeQuery.cs
index c763b12..3f6bb75 100644
--- a/src/core/Search/Spans/SpanPositionRangeQuery.cs
+++ b/src/core/Search/Spans/SpanPositionRangeQuery.cs
@@ -9,24 +9,24 @@ namespace Lucene.Net.Search.Spans
     /// </summary>
     public class SpanPositionRangeQuery : SpanPositionCheckQuery
     {
-        public int Start { get; protected set; }
-        public int End { get; protected set; }
+        protected int start = 0;
+        protected int end;
 
         public SpanPositionRangeQuery(SpanQuery match, int start, int end)
             : base(match)
         {
-            Start = start;
-            End = end;
+            this.start = start;
+            this.end = end;
         }
 
-        protected override AcceptStatus AcceptPosition(Spans spans)
+        protected override AcceptStatus AcceptPosition(SpansBase spans)
         {
             // assert spans.start() != spans.end();
-            if (spans.Start >= End)
+            if (spans.Start >= end)
             {
                 return AcceptStatus.NO_AND_ADVANCE;
             }
-            else if (spans.Start >= Start && spans.End <= End)
+            else if (spans.Start >= start && spans.End <= end)
             {
                 return AcceptStatus.YES;
             }
@@ -36,13 +36,23 @@ namespace Lucene.Net.Search.Spans
             }
         }
 
+        public int Start
+        {
+            get { return start; }
+        }
+
+        public int End
+        {
+            get { return end; }
+        }
+
         public override string ToString(string field)
         {
             var buffer = new StringBuilder();
             buffer.Append("spanPosRange(");
             buffer.Append(Match.ToString(field));
-            buffer.Append(", ").Append(Start).Append(", ");
-            buffer.Append(End);
+            buffer.Append(", ").Append(start).Append(", ");
+            buffer.Append(end);
             buffer.Append(")");
             buffer.Append(ToStringUtils.Boost(Boost));
             return buffer.ToString();
@@ -50,7 +60,7 @@ namespace Lucene.Net.Search.Spans
 
         public override object Clone()
         {
-            return new SpanPositionRangeQuery((SpanQuery) Match.Clone(), Start, End) {Boost = Boost};
+            return new SpanPositionRangeQuery((SpanQuery) Match.Clone(), start, end) {Boost = Boost};
         }
 
         public override bool Equals(object obj)
@@ -59,7 +69,7 @@ namespace Lucene.Net.Search.Spans
             if (!(obj is SpanPositionRangeQuery)) return false;
 
             var other = obj as SpanPositionRangeQuery;
-            return this.End == other.End && this.Start == other.Start
+            return this.end == other.end && this.start == other.start
                    && this.Match.Equals(other.Match)
                    && this.Boost == other.Boost;
         }
@@ -68,7 +78,7 @@ namespace Lucene.Net.Search.Spans
         {
             int h = Match.GetHashCode();
             h ^= (h << 8) | Number.URShift(h, 25);
-            h ^= Number.FloatToIntBits(Boost) ^ End ^ Start;
+            h ^= Number.FloatToIntBits(Boost) ^ end ^ start;
             return h;
         }
     }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/SpanQuery.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/SpanQuery.cs b/src/core/Search/Spans/SpanQuery.cs
index 9a93d98..9770345 100644
--- a/src/core/Search/Spans/SpanQuery.cs
+++ b/src/core/Search/Spans/SpanQuery.cs
@@ -30,7 +30,7 @@ namespace Lucene.Net.Search.Spans
 		/// <summary>Expert: Returns the matches for this query in an index.  Used internally
 		/// to search for spans. 
 		/// </summary>
-		public abstract Spans GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts);
+		public abstract SpansBase GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts);
 
 	    /// <summary>Returns the name of the field matched by this query.</summary>
 	    public abstract string Field { get; }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/SpanScorer.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/SpanScorer.cs b/src/core/Search/Spans/SpanScorer.cs
index 0a417bb..2657542 100644
--- a/src/core/Search/Spans/SpanScorer.cs
+++ b/src/core/Search/Spans/SpanScorer.cs
@@ -22,7 +22,7 @@ namespace Lucene.Net.Search.Spans
     /// <summary> Public for extension only.</summary>
     public class SpanScorer : Scorer
     {
-        protected Spans spans;
+        protected SpansBase spans;
 
         protected bool more = true;
 
@@ -33,7 +33,7 @@ namespace Lucene.Net.Search.Spans
 
 
 
-        public SpanScorer(Spans spans, Weight weight, Similarity.SloppySimScorer docScorer)
+        public SpanScorer(SpansBase spans, Weight weight, Similarity.SloppySimScorer docScorer)
             : base(weight)
         {
             this.docScorer = docScorer;
@@ -99,9 +99,12 @@ namespace Lucene.Net.Search.Spans
             return docScorer.Score(doc, freq);
         }
 
-        public override int Freq()
+        public override int Freq
         {
-            return numMatches;
+            get
+            {
+                return numMatches;
+            }
         }
 
         public float SloppyFreq()

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/SpanTermQuery.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/SpanTermQuery.cs b/src/core/Search/Spans/SpanTermQuery.cs
index 6855a42..0c6fd7f 100644
--- a/src/core/Search/Spans/SpanTermQuery.cs
+++ b/src/core/Search/Spans/SpanTermQuery.cs
@@ -94,7 +94,7 @@ namespace Lucene.Net.Search.Spans
             return true;
         }
 
-        public override Spans GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
+        public override SpansBase GetSpans(AtomicReaderContext context, IBits acceptDocs, IDictionary<Term, TermContext> termContexts)
         {
             var termContext = termContexts[Term];
             TermState state;
@@ -102,7 +102,7 @@ namespace Lucene.Net.Search.Spans
             {
                 // this happens with span-not query, as it doesn't include the NOT side in extractTerms()
                 // so we seek to the term now in this segment..., this sucks because its ugly mostly!
-                var fields = context.Reader.Fields;
+                var fields = ((AtomicReader)context.Reader).Fields;
                 if (fields != null)
                 {
                     var terms = fields.Terms(Term.Field);
@@ -138,7 +138,7 @@ namespace Lucene.Net.Search.Spans
                 return TermSpans.EMPTY_TERM_SPANS;
             }
 
-            var termsIter = context.Reader.Terms(Term.Field).Iterator(null);
+            var termsIter = ((AtomicReader)context.Reader).Terms(Term.Field).Iterator(null);
             termsIter.SeekExact(Term.Bytes, state);
 
             var postings = termsIter.DocsAndPositions(acceptDocs, null, DocsAndPositionsEnum.FLAG_PAYLOADS);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/SpanWeight.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/SpanWeight.cs b/src/core/Search/Spans/SpanWeight.cs
index 30da178..c4c693b 100644
--- a/src/core/Search/Spans/SpanWeight.cs
+++ b/src/core/Search/Spans/SpanWeight.cs
@@ -66,9 +66,12 @@ namespace Lucene.Net.Search.Spans
             get { return query; }
         }
 
-        public override float GetValueForNormalization()
+        public override float ValueForNormalization
         {
-            return stats == null ? 1.0f : stats.GetValueForNormalization();
+            get
+            {
+                return stats == null ? 1.0f : stats.ValueForNormalization;
+            }
         }
 
         public override void Normalize(float queryNorm, float topLevelBoost)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/Spans.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/Spans.cs b/src/core/Search/Spans/Spans.cs
index 727094a..63704e3 100644
--- a/src/core/Search/Spans/Spans.cs
+++ b/src/core/Search/Spans/Spans.cs
@@ -25,7 +25,8 @@ namespace Lucene.Net.Search.Spans
 	/// are enumerated in order, by increasing document number, within that by
 	/// increasing start position and finally by increasing end position. 
 	/// </summary>
-	public abstract class Spans
+    // .NET Port: Renamed from Spans to SpansBase to avoid Namespace conflict
+	public abstract class SpansBase
 	{
 		/// <summary>Move to the next match, returning true iff any such exists. </summary>
 		public abstract bool Next();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/Spans/TermSpans.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/Spans/TermSpans.cs b/src/core/Search/Spans/TermSpans.cs
index c19620f..fddd161 100644
--- a/src/core/Search/Spans/TermSpans.cs
+++ b/src/core/Search/Spans/TermSpans.cs
@@ -27,7 +27,7 @@ namespace Lucene.Net.Search.Spans
     /// <summary> Expert:
     /// Public for extension only
     /// </summary>
-    public class TermSpans : Spans
+    public class TermSpans : SpansBase
     {
         protected readonly DocsAndPositionsEnum postings;
         protected readonly Term term;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/TermCollectingRewrite.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/TermCollectingRewrite.cs b/src/core/Search/TermCollectingRewrite.cs
index 12dd239..2ed41c5 100644
--- a/src/core/Search/TermCollectingRewrite.cs
+++ b/src/core/Search/TermCollectingRewrite.cs
@@ -23,7 +23,7 @@ namespace Lucene.Net.Search
             IComparer<BytesRef> lastTermComp = null;
             foreach (AtomicReaderContext context in topReaderContext.Leaves)
             {
-                Fields fields = context.Reader.Fields;
+                Fields fields = ((AtomicReader)context.Reader).Fields;
                 if (fields == null)
                 {
                     // reader has no fields
@@ -79,6 +79,6 @@ namespace Lucene.Net.Search
             public abstract void SetNextEnum(TermsEnum termsEnum);
         }
 
-        public abstract Query Rewrite(IndexReader reader, MultiTermQuery query);
+        public abstract override Query Rewrite(IndexReader reader, MultiTermQuery query);
     }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Search/TopFieldCollector.cs
----------------------------------------------------------------------
diff --git a/src/core/Search/TopFieldCollector.cs b/src/core/Search/TopFieldCollector.cs
index 0b34309..5ea70e5 100644
--- a/src/core/Search/TopFieldCollector.cs
+++ b/src/core/Search/TopFieldCollector.cs
@@ -233,7 +233,7 @@ namespace Lucene.Net.Search
         private class OutOfOrderOneComparatorScoringNoMaxScoreCollector : OneComparatorScoringNoMaxScoreCollector
         {
 
-            public OutOfOrderOneComparatorScoringNoMaxScoreCollector(FieldValueHitQueue queue, int numHits, bool fillFields)
+            public OutOfOrderOneComparatorScoringNoMaxScoreCollector(FieldValueHitQueue<Entry> queue, int numHits, bool fillFields)
                 : base(queue, numHits, fillFields)
             {
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Support/ByteBuffer.cs
----------------------------------------------------------------------
diff --git a/src/core/Support/ByteBuffer.cs b/src/core/Support/ByteBuffer.cs
index db06fa2..db50787 100644
--- a/src/core/Support/ByteBuffer.cs
+++ b/src/core/Support/ByteBuffer.cs
@@ -22,13 +22,9 @@ namespace Lucene.Net.Support
         {
         }
 
-        public byte[] Array
+        public override object Array
         {
             get { return _data; }
-            private set
-            {
-                _data = value;
-            }
         }
 
         public override int ArrayOffset
@@ -41,15 +37,15 @@ namespace Lucene.Net.Support
             get { return _data != null; }
         }
 
-        public abstract bool IsDirect { get; }
+        public abstract override bool IsDirect { get; }
 
-        public abstract bool IsReadOnly { get; }
+        public abstract override bool IsReadOnly { get; }
 
         public static ByteBuffer Allocate(int capacity)
         {
             return new WrappedByteBuffer(-1, 0, capacity, capacity)
             {
-                Array = new byte[capacity],
+                _data = new byte[capacity],
                 _offset = 0
             };
         }
@@ -60,7 +56,7 @@ namespace Lucene.Net.Support
         {
             return new WrappedByteBuffer(-1, offset, offset + length, array.Length)
             {
-                Array = array,
+                _data = array,
                 _offset = 0
             };
         }
@@ -69,7 +65,7 @@ namespace Lucene.Net.Support
         {
             return new WrappedByteBuffer(-1, 0, array.Length, array.Length)
             {
-                Array = array,
+                _data = array,
                 _offset = 0
             };
         }
@@ -213,7 +209,7 @@ namespace Lucene.Net.Support
             {
                 return new WrappedByteBuffer(-1, 0, Remaining, Remaining)
                 {
-                    Array = this._data,
+                    _data = this._data,
                     _offset = this._offset
                 };
             }
@@ -222,7 +218,7 @@ namespace Lucene.Net.Support
             {
                 return new WrappedByteBuffer(Mark, Position, Limit, Capacity)
                 {
-                    Array = this._data,
+                    _data = this._data,
                     _offset = this._offset
                 };
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Util/Automaton/State.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/Automaton/State.cs b/src/core/Util/Automaton/State.cs
index 88d6a4c..e113105 100644
--- a/src/core/Util/Automaton/State.cs
+++ b/src/core/Util/Automaton/State.cs
@@ -89,6 +89,11 @@ namespace Lucene.Net.Util.Automaton
             {
                 return new TransitionsEnumerator(transitionsArray, numTransitions);
             }
+
+            System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+            {
+                return GetEnumerator();
+            }
         }
 
         public IEnumerable<Transition> GetTransitions()

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Util/ByteBlockPool.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/ByteBlockPool.cs b/src/core/Util/ByteBlockPool.cs
index 7dde649..4cdbc70 100644
--- a/src/core/Util/ByteBlockPool.cs
+++ b/src/core/Util/ByteBlockPool.cs
@@ -70,12 +70,12 @@ namespace Lucene.Net.Util
                 this.bytesUsed = bytesUsed;
             }
 
-            public override byte[] ByteBlock
+            public override sbyte[] ByteBlock
             {
                 get
                 {
                     bytesUsed.AddAndGet(blockSize);
-                    return new byte[blockSize];
+                    return new sbyte[blockSize];
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Util/DocIdBitSet.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/DocIdBitSet.cs b/src/core/Util/DocIdBitSet.cs
index ea6500a..8ff840d 100644
--- a/src/core/Util/DocIdBitSet.cs
+++ b/src/core/Util/DocIdBitSet.cs
@@ -71,9 +71,12 @@ namespace Lucene.Net.Util
                 this.docId = -1;
             }
 
-            public override int DocID()
+            public override int DocID
             {
-                return docId;
+                get
+                {
+                    return docId;
+                }
             }
 
             public override int NextDoc()
@@ -93,9 +96,12 @@ namespace Lucene.Net.Util
                 return docId;
             }
 
-            public override long Cost()
+            public override long Cost
             {
-                return bitSet.Length;
+                get
+                {
+                    return bitSet.Length;
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Util/Fst/BytesStore.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/Fst/BytesStore.cs b/src/core/Util/Fst/BytesStore.cs
index 1ec0a24..ba1c6ce 100644
--- a/src/core/Util/Fst/BytesStore.cs
+++ b/src/core/Util/Fst/BytesStore.cs
@@ -310,17 +310,17 @@ namespace Lucene.Net.Util.Fst
                 nextRead = _parent.blockSize;
             }
 
-            public override sbyte ReadByte()
+            public override byte ReadByte()
             {
                 if (nextRead == _parent.blockSize)
                 {
                     current = _parent.blocks[nextBuffer++];
                     nextRead = 0;
                 }
-                return current[nextRead++];
+                return (byte)current[nextRead++];
             }
 
-            public void SkipBytes(int count)
+            public override void SkipBytes(int count)
             {
                 Position = Position + count;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Util/Fst/FSTEnum.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/Fst/FSTEnum.cs b/src/core/Util/Fst/FSTEnum.cs
index 46e875d..5c4839a 100644
--- a/src/core/Util/Fst/FSTEnum.cs
+++ b/src/core/Util/Fst/FSTEnum.cs
@@ -4,7 +4,6 @@ using System.Diagnostics;
 namespace Lucene.Net.Util.Fst
 {
     public abstract class FSTEnum<T>
-        where T : class
     {
         protected readonly FST<T> fst;
 
@@ -416,7 +415,7 @@ namespace Lucene.Net.Util.Fst
             }
             if (output.Length <= upto)
             {
-                var newOutput = (T[])new Object[ArrayUtil.Oversize(1 + upto, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
+                var newOutput = new T[ArrayUtil.Oversize(1 + upto, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
                 Array.Copy(output, 0, newOutput, 0, output.Length);
                 output = newOutput;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Util/Fst/ForwardBytesReader.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/Fst/ForwardBytesReader.cs b/src/core/Util/Fst/ForwardBytesReader.cs
index fa18c84..bcbb357 100644
--- a/src/core/Util/Fst/ForwardBytesReader.cs
+++ b/src/core/Util/Fst/ForwardBytesReader.cs
@@ -23,12 +23,12 @@ namespace Lucene.Net.Util.Fst
             Position += count;
         }
 
-        public override sbyte ReadByte()
+        public override byte ReadByte()
         {
             return bytes[Position++];
         }
 
-        public override void ReadBytes(sbyte[] bytes, int offset, int len)
+        public override void ReadBytes(byte[] bytes, int offset, int len)
         {
             Array.Copy(this.bytes, Position, bytes, offset, len);
             Position += len;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Util/Fst/ReverseBytesReader.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/Fst/ReverseBytesReader.cs b/src/core/Util/Fst/ReverseBytesReader.cs
index afb4197..ad9c4d1 100644
--- a/src/core/Util/Fst/ReverseBytesReader.cs
+++ b/src/core/Util/Fst/ReverseBytesReader.cs
@@ -10,12 +10,12 @@
             this.bytes = bytes;
         }
 
-        public override sbyte ReadByte()
+        public override byte ReadByte()
         {
             return bytes[Position--];
         }
 
-        public override void ReadBytes(sbyte[] b, int offset, int len)
+        public override void ReadBytes(byte[] b, int offset, int len)
         {
             for (var i = 0; i < len; i++)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Util/NamedThreadFactory.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/NamedThreadFactory.cs b/src/core/Util/NamedThreadFactory.cs
index 7592d3e..cb13e04 100644
--- a/src/core/Util/NamedThreadFactory.cs
+++ b/src/core/Util/NamedThreadFactory.cs
@@ -26,7 +26,7 @@ namespace Lucene.Net.Util
             return prefix == null || prefix.Length == 0 ? "Lucene" : prefix;
         }
 
-        public Thread NewThread(IThreadRunnable r)
+        public override Thread NewThread(IThreadRunnable r)
         {
             Thread t = new Thread(r.Run) 
             { 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Util/OpenBitSetIterator.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/OpenBitSetIterator.cs b/src/core/Util/OpenBitSetIterator.cs
index 6a88ee2..febdd83 100644
--- a/src/core/Util/OpenBitSetIterator.cs
+++ b/src/core/Util/OpenBitSetIterator.cs
@@ -214,14 +214,20 @@ namespace Lucene.Net.Util
             return curDocId = (i << 6) + bitIndex;
         }
 
-        public override int DocID()
+        public override int DocID
         {
-            return curDocId;
+            get
+            {
+                return curDocId;
+            }
         }
 
-        public override long Cost()
+        public override long Cost
         {
-            return words / 64;
+            get
+            {
+                return words / 64;
+            }
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/80561f72/src/core/Util/Packed/AppendingLongBuffer.cs
----------------------------------------------------------------------
diff --git a/src/core/Util/Packed/AppendingLongBuffer.cs b/src/core/Util/Packed/AppendingLongBuffer.cs
index 0f46775..86f0d89 100644
--- a/src/core/Util/Packed/AppendingLongBuffer.cs
+++ b/src/core/Util/Packed/AppendingLongBuffer.cs
@@ -29,7 +29,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        internal void PackPendingValues()
+        internal override void PackPendingValues()
         {
             //assert pendingOff == MAX_PENDING_COUNT;
 
@@ -61,7 +61,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        internal override Iterator GetIterator()
+        internal override AbstractAppendingLongBuffer.Iterator GetIterator()
         {
             return new Iterator(this);
         }
@@ -76,7 +76,7 @@ namespace Lucene.Net.Util.Packed
                 this.parent = parent;
             }
 
-            void FillValues()
+            internal override void FillValues()
             {
                 if (vOff == parent.valuesOff)
                 {


Mime
View raw message