LUCENE-1457: fix possible overflow bugs during binary search

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@723149 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2008-12-03 23:46:19 +00:00
parent 481f8080ab
commit 1fb2d4f280
5 changed files with 5 additions and 5 deletions

View File

@ -85,7 +85,7 @@ final class MergeDocIDRemapper {
int hi = docMaps.length - 1; // for first element less int hi = docMaps.length - 1; // for first element less
while (hi >= lo) { while (hi >= lo) {
int mid = (lo + hi) >> 1; int mid = (lo + hi) >>> 1;
int midValue = starts[mid]; int midValue = starts[mid];
if (oldDocID < midValue) if (oldDocID < midValue)
hi = mid - 1; hi = mid - 1;

View File

@ -295,7 +295,7 @@ class MultiSegmentReader extends DirectoryIndexReader {
int hi = numSubReaders - 1; // for first element less int hi = numSubReaders - 1; // for first element less
while (hi >= lo) { while (hi >= lo) {
int mid = (lo + hi) >> 1; int mid = (lo + hi) >>> 1;
int midValue = starts[mid]; int midValue = starts[mid];
if (n < midValue) if (n < midValue)
hi = mid - 1; hi = mid - 1;

View File

@ -195,7 +195,7 @@ final class TermInfosReader {
int hi = indexTerms.length - 1; int hi = indexTerms.length - 1;
while (hi >= lo) { while (hi >= lo) {
int mid = (lo + hi) >> 1; int mid = (lo + hi) >>> 1;
int delta = term.compareTo(indexTerms[mid]); int delta = term.compareTo(indexTerms[mid]);
if (delta < 0) if (delta < 0)
hi = mid - 1; hi = mid - 1;

View File

@ -48,7 +48,7 @@ public interface FieldCache {
int high = lookup.length-1; int high = lookup.length-1;
while (low <= high) { while (low <= high) {
int mid = (low + high) >> 1; int mid = (low + high) >>> 1;
int cmp = lookup[mid].compareTo(key); int cmp = lookup[mid].compareTo(key);
if (cmp < 0) if (cmp < 0)

View File

@ -168,7 +168,7 @@ public class MultiSearcher extends Searcher {
int hi = searchables.length - 1; // for first element less int hi = searchables.length - 1; // for first element less
// than n, return its index // than n, return its index
while (hi >= lo) { while (hi >= lo) {
int mid = (lo + hi) >> 1; int mid = (lo + hi) >>> 1;
int midValue = starts[mid]; int midValue = starts[mid];
if (n < midValue) if (n < midValue)
hi = mid - 1; hi = mid - 1;