fix bkd test logic error and doc error (#863)

This commit is contained in:
xiaoping 2022-05-10 19:10:00 +08:00 committed by GitHub
parent f431511cb7
commit 102483bc57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -56,7 +56,7 @@ public abstract class RadixSelector extends Selector {
/** /**
* Return the k-th byte of the entry at index {@code i}, or {@code -1} if its length is less than * Return the k-th byte of the entry at index {@code i}, or {@code -1} if its length is less than
* or equal to {@code k}. This may only be called with a value of {@code i} between {@code 0} * or equal to {@code k}. This may only be called with a value of {@code k} between {@code 0}
* included and {@code maxLength} excluded. * included and {@code maxLength} excluded.
*/ */
protected abstract int byteAt(int i, int k); protected abstract int byteAt(int i, int k);

View File

@ -1674,6 +1674,7 @@ public class TestBKD extends LuceneTestCase {
final int numValues = 10; final int numValues = 10;
final int numBytesPerDim = TestUtil.nextInt(random(), 1, 4); final int numBytesPerDim = TestUtil.nextInt(random(), 1, 4);
final byte[][] pointValue = new byte[11][numBytesPerDim]; final byte[][] pointValue = new byte[11][numBytesPerDim];
final int[] docId = new int[11];
BKDWriter w = BKDWriter w =
new BKDWriter( new BKDWriter(
numValues + 1, numValues + 1,
@ -1684,6 +1685,7 @@ public class TestBKD extends LuceneTestCase {
numValues); numValues);
for (int i = 0; i < numValues + 1; i++) { for (int i = 0; i < numValues + 1; i++) {
random().nextBytes(pointValue[i]); random().nextBytes(pointValue[i]);
docId[i] = i;
} }
MutablePointTree val = MutablePointTree val =
new MutablePointTree() { new MutablePointTree() {
@ -1701,7 +1703,7 @@ public class TestBKD extends LuceneTestCase {
@Override @Override
public int getDocID(int i) { public int getDocID(int i) {
return i; return docId[i];
} }
@Override @Override
@ -1709,6 +1711,9 @@ public class TestBKD extends LuceneTestCase {
byte[] temp = pointValue[i]; byte[] temp = pointValue[i];
pointValue[i] = pointValue[j]; pointValue[i] = pointValue[j];
pointValue[j] = temp; pointValue[j] = temp;
int tempDocId = docId[i];
docId[i] = docId[j];
docId[j] = tempDocId;
} }
@Override @Override
@ -1729,7 +1734,7 @@ public class TestBKD extends LuceneTestCase {
@Override @Override
public void visitDocValues(IntersectVisitor visitor) throws IOException { public void visitDocValues(IntersectVisitor visitor) throws IOException {
for (int i = 0; i < size(); i++) { for (int i = 0; i < size(); i++) {
visitor.visit(i, pointValue[i]); visitor.visit(docId[i], pointValue[i]);
} }
} }
}; };