Skip to content

Commit

Permalink
add sanity checks for neighborOverflow and alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
jbellis committed Dec 19, 2024
1 parent c0ad648 commit 86f58f3
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,23 @@ public GraphIndexBuilder(BuildScoreProvider scoreProvider,
ForkJoinPool simdExecutor,
ForkJoinPool parallelExecutor)
{
this.scoreProvider = scoreProvider;
this.dimension = dimension;
this.neighborOverflow = neighborOverflow;
this.alpha = alpha;
if (M <= 0) {
throw new IllegalArgumentException("maxConn must be positive");
}
if (beamWidth <= 0) {
throw new IllegalArgumentException("beamWidth must be positive");
}
if (neighborOverflow < 1.0f) {
throw new IllegalArgumentException("neighborOverflow must be >= 1.0");
}
if (alpha <= 0) {
throw new IllegalArgumentException("alpha must be positive");
}

this.scoreProvider = scoreProvider;
this.dimension = dimension;
this.neighborOverflow = neighborOverflow;
this.alpha = alpha;
this.beamWidth = beamWidth;
this.simdExecutor = simdExecutor;
this.parallelExecutor = parallelExecutor;
Expand Down Expand Up @@ -205,7 +212,7 @@ public static GraphIndexBuilder rescore(GraphIndexBuilder other, BuildScoreProvi
var sf = newProvider.searchProviderFor(i).scoreFunction();
var newNeighbors = new NodeArray(neighbors.size());

// Copy neighbors with new scores
// Copy edges, compute new scores
for (var it = neighbors.iterator(); it.hasNext(); ) {
int neighbor = it.nextInt();
// since we're using a different score provider, use insertSorted instead of addInOrder
Expand Down

0 comments on commit 86f58f3

Please sign in to comment.