lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r764829 - in /lucene/java/trunk/contrib/queries/src: java/org/apache/lucene/search/trie/TrieUtils.java test/org/apache/lucene/search/trie/TestTrieUtils.java
Date Tue, 14 Apr 2009 15:28:06 GMT
Author: uschindler
Date: Tue Apr 14 15:28:06 2009
New Revision: 764829

URL: http://svn.apache.org/viewvc?rev=764829&view=rev
Log:
Add a missing check for inverse ranges in splitRange() and corresponding tests for inverse
ranges and 0-length-ranges.

Modified:
    lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/trie/TrieUtils.java
    lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/trie/TestTrieUtils.java

Modified: lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/trie/TrieUtils.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/trie/TrieUtils.java?rev=764829&r1=764828&r2=764829&view=diff
==============================================================================
--- lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/trie/TrieUtils.java
(original)
+++ lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/trie/TrieUtils.java
Tue Apr 14 15:28:06 2009
@@ -336,6 +336,7 @@
     final Object builder, final int valSize,
     final int precisionStep, long minBound, long maxBound
   ) {
+    if (minBound > maxBound) return;
     for (int shift=0; ; shift += precisionStep) {
       // calculate new bounds for inner precision
       final long diff = 1L << (shift+precisionStep),

Modified: lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/trie/TestTrieUtils.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/trie/TestTrieUtils.java?rev=764829&r1=764828&r2=764829&view=diff
==============================================================================
--- lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/trie/TestTrieUtils.java
(original)
+++ lucene/java/trunk/contrib/queries/src/test/org/apache/lucene/search/trie/TestTrieUtils.java
Tue Apr 14 15:28:06 2009
@@ -21,6 +21,7 @@
 import org.apache.lucene.util.OpenBitSet;
 
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Iterator;
 
 public class TestTrieUtils extends LuceneTestCase {
@@ -243,6 +244,14 @@
     assertLongRangeSplit(Long.MIN_VALUE, Long.MAX_VALUE, 1, false, Arrays.asList(new Long[]{
       new Long(0x0L),new Long(0x1L)
     }).iterator());
+
+    // a inverse range should produce no sub-ranges
+    assertLongRangeSplit(9500L, -5000L, 4, false, Collections.EMPTY_LIST.iterator());   

+
+    // a 0-length range should reproduce the range itsself
+    assertLongRangeSplit(9500L, 9500L, 4, false, Arrays.asList(new Long[]{
+      new Long(0x800000000000251cL),new Long(0x800000000000251cL)
+    }).iterator());
   }
 
   /** Note: The neededBounds iterator must be unsigned (easier understanding what's happening)
*/
@@ -317,6 +326,14 @@
     assertIntRangeSplit(Integer.MIN_VALUE, Integer.MAX_VALUE, 1, false, Arrays.asList(new
Integer[]{
       new Integer(0x0),new Integer(0x1)
     }).iterator());
+
+    // a inverse range should produce no sub-ranges
+    assertIntRangeSplit(9500, -5000, 4, false, Collections.EMPTY_LIST.iterator());    
+
+    // a 0-length range should reproduce the range itsself
+    assertIntRangeSplit(9500, 9500, 4, false, Arrays.asList(new Integer[]{
+      new Integer(0x8000251c),new Integer(0x8000251c)
+    }).iterator());
   }
 
 }



Mime
View raw message