lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject svn commit: r1376544 - in /incubator/lucene.net/trunk/src: contrib/Spatial/ contrib/Spatial/Util/ core/Search/ core/Util/
Date Thu, 23 Aug 2012 15:25:48 GMT
Author: synhershko
Date: Thu Aug 23 15:25:48 2012
New Revision: 1376544

URL: http://svn.apache.org/viewvc?rev=1376544&view=rev
Log:
Better bitset iterators

Removed:
    incubator/lucene.net/trunk/src/contrib/Spatial/Util/OpenBitSetIterator.cs
Modified:
    incubator/lucene.net/trunk/src/contrib/Spatial/Contrib.Spatial.NTS.csproj
    incubator/lucene.net/trunk/src/contrib/Spatial/Contrib.Spatial.csproj
    incubator/lucene.net/trunk/src/contrib/Spatial/Util/FixedBitSet.cs
    incubator/lucene.net/trunk/src/core/Search/DocIdSetIterator.cs
    incubator/lucene.net/trunk/src/core/Util/OpenBitSetIterator.cs

Modified: incubator/lucene.net/trunk/src/contrib/Spatial/Contrib.Spatial.NTS.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/contrib/Spatial/Contrib.Spatial.NTS.csproj?rev=1376544&r1=1376543&r2=1376544&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/contrib/Spatial/Contrib.Spatial.NTS.csproj (original)
+++ incubator/lucene.net/trunk/src/contrib/Spatial/Contrib.Spatial.NTS.csproj Thu Aug 23 15:25:48
2012
@@ -150,7 +150,6 @@
     <Compile Include="Util\CompatibilityExtensions.cs" />
     <Compile Include="Util\FixedBitSet.cs" />
     <Compile Include="Util\FunctionQuery.cs" />
-    <Compile Include="Util\OpenBitSetIterator.cs" />
     <Compile Include="Util\ShapeFieldCache.cs" />
     <Compile Include="Util\ShapeFieldCacheProvider.cs" />
     <Compile Include="Util\TermsEnumCompatibility.cs" />

Modified: incubator/lucene.net/trunk/src/contrib/Spatial/Contrib.Spatial.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/contrib/Spatial/Contrib.Spatial.csproj?rev=1376544&r1=1376543&r2=1376544&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/contrib/Spatial/Contrib.Spatial.csproj (original)
+++ incubator/lucene.net/trunk/src/contrib/Spatial/Contrib.Spatial.csproj Thu Aug 23 15:25:48
2012
@@ -151,7 +151,6 @@
     <Compile Include="Util\CompatibilityExtensions.cs" />
     <Compile Include="Util\FixedBitSet.cs" />
     <Compile Include="Util\FunctionQuery.cs" />
-    <Compile Include="Util\OpenBitSetIterator.cs" />
     <Compile Include="Util\ShapeFieldCache.cs" />
     <Compile Include="Util\ShapeFieldCacheProvider.cs" />
     <Compile Include="Util\TermsEnumCompatibility.cs" />

Modified: incubator/lucene.net/trunk/src/contrib/Spatial/Util/FixedBitSet.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/contrib/Spatial/Util/FixedBitSet.cs?rev=1376544&r1=1376543&r2=1376544&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/contrib/Spatial/Util/FixedBitSet.cs (original)
+++ incubator/lucene.net/trunk/src/contrib/Spatial/Util/FixedBitSet.cs Thu Aug 23 15:25:48
2012
@@ -410,13 +410,45 @@ namespace Lucene.Net.Spatial.Util
 
 		public override DocIdSetIterator Iterator()
 		{
-			// TODO: avoid copying, create a FixedBitSetIterator instead
-			var a = new OpenBitSet();
-			for (var i = 0; i < bits.Count; i++)
+			return new FixedBitSetIterator(this);
+		}
+
+		/// <summary>
+		/// A FixedBitSet Iterator implementation
+		/// </summary>
+		public class FixedBitSetIterator : DocIdSetIterator
+		{
+			private int curDocId = -1;
+			private readonly IEnumerator enumerator;
+
+			public FixedBitSetIterator(FixedBitSet bitset)
+			{
+				enumerator = bitset.bits.GetEnumerator();
+			}
+
+			public override int DocID()
+			{
+				return curDocId;
+			}
+
+			public override int NextDoc()
+			{
+				while (enumerator.MoveNext())
+				{
+					++curDocId;
+					if ((bool)enumerator.Current) return curDocId;
+				}
+				return curDocId = NO_MORE_DOCS;
+			}
+
+			public override int Advance(int target)
 			{
-				if (bits[i]) a.Set(i);
+				int doc;
+				while ((doc = NextDoc()) < target)
+				{
+				}
+				return doc;
 			}
-			return a.Iterator();
 		}
 	}
 }

Modified: incubator/lucene.net/trunk/src/core/Search/DocIdSetIterator.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Search/DocIdSetIterator.cs?rev=1376544&r1=1376543&r2=1376544&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Search/DocIdSetIterator.cs (original)
+++ incubator/lucene.net/trunk/src/core/Search/DocIdSetIterator.cs Thu Aug 23 15:25:48 2012
@@ -15,8 +15,6 @@
  * limitations under the License.
  */
 
-using System;
-
 namespace Lucene.Net.Search
 {
 	

Modified: incubator/lucene.net/trunk/src/core/Util/OpenBitSetIterator.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Util/OpenBitSetIterator.cs?rev=1376544&r1=1376543&r2=1376544&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Util/OpenBitSetIterator.cs (original)
+++ incubator/lucene.net/trunk/src/core/Util/OpenBitSetIterator.cs Thu Aug 23 15:25:48 2012
@@ -15,8 +15,6 @@
  * limitations under the License.
  */
 
-using System;
-
 using DocIdSetIterator = Lucene.Net.Search.DocIdSetIterator;
 
 namespace Lucene.Net.Util
@@ -100,8 +98,8 @@ namespace Lucene.Net.Util
 		// for efficiency, or have a common root interface?  (or
 		// maybe both?  could ask for a SetBitsIterator, etc...
 		
-		private long[] arr;
-		private int words;
+		private readonly long[] arr;
+		private readonly int words;
 		private int i = - 1;
 		private long word;
 		private int wordShift;



Mime
View raw message