|
41 | 41 | public class DefaultIVFVectorsReader extends IVFVectorsReader implements OffHeapStats { |
42 | 42 |
|
43 | 43 | // How many extra centroids we need to collect for each visited centroid for hierarchical centroids. |
44 | | - public static final float CENTROID_OVERSAMPLING = 8.0f; |
| 44 | + public final float centroidOversampling; |
45 | 45 |
|
46 | | - public DefaultIVFVectorsReader(SegmentReadState state, FlatVectorsReader rawVectorsReader) throws IOException { |
| 46 | + public DefaultIVFVectorsReader(SegmentReadState state, FlatVectorsReader rawVectorsReader, int centroidsPerParentCluster) |
| 47 | + throws IOException { |
47 | 48 | super(state, rawVectorsReader); |
| 49 | + centroidOversampling = (float) centroidsPerParentCluster / 2; |
48 | 50 | } |
49 | 51 |
|
50 | 52 | CentroidIterator getPostingListPrefetchIterator(CentroidIterator centroidIterator, IndexInput postingListSlice) throws IOException { |
@@ -124,7 +126,7 @@ CentroidIterator getCentroidIterator( |
124 | 126 | quantized, |
125 | 127 | queryParams, |
126 | 128 | globalCentroidDp, |
127 | | - visitRatio |
| 129 | + visitRatio * centroidOversampling |
128 | 130 | ); |
129 | 131 | } else { |
130 | 132 | centroidIterator = getCentroidIteratorNoParent( |
@@ -188,13 +190,13 @@ private static CentroidIterator getCentroidIteratorWithParents( |
188 | 190 | byte[] quantizeQuery, |
189 | 191 | OptimizedScalarQuantizer.QuantizationResult queryParams, |
190 | 192 | float globalCentroidDp, |
191 | | - float visitRatio |
| 193 | + float centroidRatio |
192 | 194 | ) throws IOException { |
193 | 195 | // build the three queues we are going to use |
194 | 196 | final NeighborQueue parentsQueue = new NeighborQueue(numParents, true); |
195 | 197 | final int maxChildrenSize = centroids.readVInt(); |
196 | 198 | final NeighborQueue currentParentQueue = new NeighborQueue(maxChildrenSize, true); |
197 | | - final int bufferSize = (int) Math.min(Math.max(visitRatio * numCentroids * CENTROID_OVERSAMPLING, 1), numCentroids); |
| 199 | + final int bufferSize = (int) Math.min(Math.max(centroidRatio * numCentroids, 1), numCentroids); |
198 | 200 | final NeighborQueue neighborQueue = new NeighborQueue(bufferSize, true); |
199 | 201 | // score the parents |
200 | 202 | final float[] scores = new float[ES92Int7VectorsScorer.BULK_SIZE]; |
|
0 commit comments