lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r1139431 - in /lucene/dev/trunk: ./ dev-tools/idea/lucene/contrib/ lucene/ lucene/contrib/queries/src/test/org/apache/lucene/search/regex/ lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/builders/ lucene/src/java/org/ap...
Date Fri, 24 Jun 2011 20:43:46 GMT
Author: uschindler
Date: Fri Jun 24 20:43:46 2011
New Revision: 1139431

URL: http://svn.apache.org/viewvc?rev=1139431&view=rev
Log:
LUCENE-3179: Fix bug in handling of indexes >= size in OpenBitSet.prevSetBit()

Modified:
    lucene/dev/trunk/   (props changed)
    lucene/dev/trunk/dev-tools/idea/lucene/contrib/   (props changed)
    lucene/dev/trunk/lucene/   (props changed)
    lucene/dev/trunk/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java
  (props changed)
    lucene/dev/trunk/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/builders/TestNumericRangeFilterBuilder.java
  (props changed)
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/OpenBitSet.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestOpenBitSet.java
    lucene/dev/trunk/solr/   (props changed)
    lucene/dev/trunk/solr/CHANGES.txt   (props changed)
    lucene/dev/trunk/solr/LICENSE.txt   (props changed)
    lucene/dev/trunk/solr/NOTICE.txt   (props changed)
    lucene/dev/trunk/solr/README.txt   (props changed)
    lucene/dev/trunk/solr/build.xml   (props changed)
    lucene/dev/trunk/solr/client/   (props changed)
    lucene/dev/trunk/solr/common-build.xml   (props changed)
    lucene/dev/trunk/solr/contrib/   (props changed)
    lucene/dev/trunk/solr/example/   (props changed)
    lucene/dev/trunk/solr/lib/   (props changed)
    lucene/dev/trunk/solr/site/   (props changed)
    lucene/dev/trunk/solr/src/   (props changed)
    lucene/dev/trunk/solr/testlogging.properties   (props changed)

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/OpenBitSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/OpenBitSet.java?rev=1139431&r1=1139430&r2=1139431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/OpenBitSet.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/OpenBitSet.java Fri Jun 24 20:43:46
2011
@@ -664,15 +664,19 @@ public class OpenBitSet extends DocIdSet
    *  -1 is returned if there are no more set bits.
    */
   public int prevSetBit(int index) {
-    if (index < 0) {
-      return -1;
-    }
-    int i = index>>6;
+    int i = index >> 6;
+    final int subIndex;
+    long word;
     if (i >= wlen) {
       i = wlen - 1;
+      if (i < 0) return -1;
+      subIndex = 63;  // last possible bit
+      word = bits[i];
+    } else {
+      if (i < 0) return -1;
+      subIndex = index & 0x3f;  // index within the word
+      word = (bits[i] << (63-subIndex));  // skip all the bits to the left of index
     }
-    final int subIndex = index & 0x3f;      // index within the word
-    long word = (bits[i] << (63-subIndex));  // skip all the bits to the left of index
 
     if (word != 0) {
       return (i << 6) + subIndex - Long.numberOfLeadingZeros(word); // See LUCENE-3197

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestOpenBitSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestOpenBitSet.java?rev=1139431&r1=1139430&r2=1139431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestOpenBitSet.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/TestOpenBitSet.java Fri Jun 24
20:43:46 2011
@@ -42,8 +42,8 @@ public class TestOpenBitSet extends Luce
   }
 
   void doPrevSetBit(BitSet a, OpenBitSet b) {
-    int aa=a.length();
-    int bb=aa;
+    int aa = a.size() + random.nextInt(100);
+    int bb = aa;
     do {
       // aa = a.prevSetBit(aa-1);
       aa--;



Mime
View raw message