diff --git a/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java b/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java index 9ddd0a397a5..05be0c3bec6 100644 --- a/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java +++ b/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java @@ -616,16 +616,17 @@ public final class ArrayUtil { } /** - * Reorganize {@code arr[from:to[} so that the elements at the offsets included in {@code k} are at the same position as if - * {@code arr[from:to]} was sorted, and all elements on their left are less than or equal to them, and - * all elements on their right are greater than or equal to them. + * Reorganize {@code arr[from:to[} so that the elements at the offsets included in {@code k} are + * at the same position as if {@code arr[from:to]} was sorted, and all elements on their left are + * less than or equal to them, and all elements on their right are greater than or equal to them. * *
This runs in linear time on average and in {@code n log(n)} time in the worst case.
*
* @param arr Array to be re-organized.
* @param from Starting index for re-organization. Elements before this index will be left as is.
* @param to Ending index. Elements after this index will be left as is.
- * @param k Array containing the Indexes of elements to sort from. Values must be less than 'to' and greater than or equal to 'from'. This list will be sorted during the call.
+ * @param k Array containing the Indexes of elements to sort from. Values must be less than 'to'
+ * and greater than or equal to 'from'. This list will be sorted during the call.
* @param comparator Comparator to use for sorting
*/
public static The array {@code k} will be sorted, so {@code kFrom} and {@code kTo} must be referring to
+ * the sorted order.
*/
public void multiSelect(int from, int to, int[] k, int kFrom, int kTo) {
// Default implementation only uses select(), so it is not optimal
diff --git a/lucene/core/src/java/org/apache/lucene/util/quantization/ScalarQuantizer.java b/lucene/core/src/java/org/apache/lucene/util/quantization/ScalarQuantizer.java
index 74bb8f5af3e..3d27992c045 100644
--- a/lucene/core/src/java/org/apache/lucene/util/quantization/ScalarQuantizer.java
+++ b/lucene/core/src/java/org/apache/lucene/util/quantization/ScalarQuantizer.java
@@ -439,7 +439,8 @@ public class ScalarQuantizer {
double[] lowerSum) {
assert confidenceIntervals.length == upperSum.length
&& confidenceIntervals.length == lowerSum.length;
- float[][] upperAndLowerQuantiles = getUpperAndLowerQuantiles(quantileGatheringScratch, confidenceIntervals);
+ float[][] upperAndLowerQuantiles =
+ getUpperAndLowerQuantiles(quantileGatheringScratch, confidenceIntervals);
for (int i = 0; i < confidenceIntervals.length; i++) {
upperSum[i] += upperAndLowerQuantiles[i][1];
lowerSum[i] += upperAndLowerQuantiles[i][0];
@@ -591,8 +592,8 @@ public class ScalarQuantizer {
// After the selection process, pick out the given quantile values
for (int i = 0; i < confidenceIntervals.length; i++) {
- minAndMaxPerInterval[i][0] = arr[selectorIndexes[2*i]];
- minAndMaxPerInterval[i][1] = arr[selectorIndexes[2*i + 1]];
+ minAndMaxPerInterval[i][0] = arr[selectorIndexes[2 * i]];
+ minAndMaxPerInterval[i][1] = arr[selectorIndexes[2 * i + 1]];
}
return minAndMaxPerInterval;
}
diff --git a/lucene/core/src/test/org/apache/lucene/util/quantization/TestScalarQuantizer.java b/lucene/core/src/test/org/apache/lucene/util/quantization/TestScalarQuantizer.java
index 8f7a8c66f19..9bc6ed5823b 100644
--- a/lucene/core/src/test/org/apache/lucene/util/quantization/TestScalarQuantizer.java
+++ b/lucene/core/src/test/org/apache/lucene/util/quantization/TestScalarQuantizer.java
@@ -125,22 +125,23 @@ public class TestScalarQuantizer extends LuceneTestCase {
percs[i] = (float) i;
}
shuffleArray(percs);
- float[][] upperAndLower = ScalarQuantizer.getUpperAndLowerQuantiles(percs, new float[]{0.9f});
+ float[][] upperAndLower = ScalarQuantizer.getUpperAndLowerQuantiles(percs, new float[] {0.9f});
assertEquals(50f, upperAndLower[0][0], 1e-7);
assertEquals(949f, upperAndLower[0][1], 1e-7);
shuffleArray(percs);
- upperAndLower = ScalarQuantizer.getUpperAndLowerQuantiles(percs, new float[]{0.95f});
+ upperAndLower = ScalarQuantizer.getUpperAndLowerQuantiles(percs, new float[] {0.95f});
assertEquals(25f, upperAndLower[0][0], 1e-7);
assertEquals(974f, upperAndLower[0][1], 1e-7);
shuffleArray(percs);
- upperAndLower = ScalarQuantizer.getUpperAndLowerQuantiles(percs, new float[]{0.99f});
+ upperAndLower = ScalarQuantizer.getUpperAndLowerQuantiles(percs, new float[] {0.99f});
assertEquals(5f, upperAndLower[0][0], 1e-7);
assertEquals(994f, upperAndLower[0][1], 1e-7);
}
public void testEdgeCase() {
float[][] upperAndLower =
- ScalarQuantizer.getUpperAndLowerQuantiles(new float[] {1.0f, 1.0f, 1.0f, 1.0f, 1.0f}, new float[]{0.9f});
+ ScalarQuantizer.getUpperAndLowerQuantiles(
+ new float[] {1.0f, 1.0f, 1.0f, 1.0f, 1.0f}, new float[] {0.9f});
assertEquals(1f, upperAndLower[0][0], 1e-7f);
assertEquals(1f, upperAndLower[0][1], 1e-7f);
}
@@ -194,7 +195,7 @@ public class TestScalarQuantizer extends LuceneTestCase {
public void testFromVectorsAutoInterval4Bit() throws IOException {
int dims = 128;
- int numVecs = 100;
+ int numVecs = 1000;
VectorSimilarityFunction similarityFunction = VectorSimilarityFunction.DOT_PRODUCT;
float[][] floats = randomFloats(numVecs, dims);