Return-Path: X-Original-To: apmail-lucenenet-commits-archive@www.apache.org Delivered-To: apmail-lucenenet-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AF3C1D1ED for ; Thu, 23 Aug 2012 15:26:36 +0000 (UTC) Received: (qmail 17391 invoked by uid 500); 23 Aug 2012 15:26:36 -0000 Delivered-To: apmail-lucenenet-commits-archive@lucenenet.apache.org Received: (qmail 17302 invoked by uid 500); 23 Aug 2012 15:26:36 -0000 Mailing-List: contact commits-help@lucenenet.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucenenet.apache.org Delivered-To: mailing list commits@lucenenet.apache.org Received: (qmail 17291 invoked by uid 500); 23 Aug 2012 15:26:36 -0000 Delivered-To: apmail-lucene-lucene-net-commits@lucene.apache.org Received: (qmail 17286 invoked by uid 99); 23 Aug 2012 15:26:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Aug 2012 15:26:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Aug 2012 15:26:33 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 17714238896F; Thu, 23 Aug 2012 15:25:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: lucene-net-commits@lucene.apache.org From: synhershko@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120823152549.17714238896F@eris.apache.org> 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 @@ - 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 @@ - 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); + } + + /// + /// A FixedBitSet Iterator implementation + /// + 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;