Skip to content

Commit

Permalink
chore: added warning message on HNSB index if corrupted
Browse files Browse the repository at this point in the history
  • Loading branch information
lvca committed Sep 20, 2023
1 parent 616843d commit 08123a1
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,10 @@ public boolean add(Vertex vertex) {
if (currObj != null) {
if (vertexMaxLevel < entryPointCopyMaxLevel) {
final TVector vector = getVectorFromVertex(currObj);
if (vector == null)
if (vector == null) {
LogManager.instance().log(this, Level.WARNING, "Vector not found in vertex %s", currObj);
throw new IndexException("Embeddings not found in object " + currObj);
}

TDistance curDist = distanceFunction.distance(vertexVector, vector);
for (int activeLevel = entryPointCopyMaxLevel; activeLevel > vertexMaxLevel; activeLevel--) {
Expand All @@ -368,9 +370,11 @@ public boolean add(Vertex vertex) {
final Vertex candidateNode = candidateConnections.next();

final TVector candidateNodeVector = getVectorFromVertex(candidateNode);
if (candidateNodeVector == null)
if (candidateNodeVector == null) {
// INVALID
LogManager.instance().log(this, Level.WARNING, "Vector not found in vertex %s", candidateNode);
continue;
}

final TDistance candidateDistance = distanceFunction.distance(vertexVector, candidateNodeVector);

Expand Down Expand Up @@ -512,8 +516,10 @@ public List<SearchResult<Vertex, TDistance>> findNearest(final TVector destinati
Vertex currObj = entryPointCopy;

final TVector vector = getVectorFromVertex(currObj);
if (vector == null)
if (vector == null) {
LogManager.instance().log(this, Level.WARNING, "Vector not found in vertex %s", currObj);
return Collections.emptyList();
}

TDistance curDist = distanceFunction.distance(destination, vector);

Expand Down Expand Up @@ -598,9 +604,11 @@ private PriorityQueue<NodeIdAndDistance<TDistance>> searchBaseLayer(final Vertex
visitedNodes.add(candidateNode.getIdentity());

final TVector vector = getVectorFromVertex(candidateNode);
if (vector == null)
if (vector == null) {
// INVALID
LogManager.instance().log(this, Level.WARNING, "Vector not found in vertex %s", candidateNode);
continue;
}

final TDistance candidateDistance = distanceFunction.distance(destination, vector);
if (topCandidates.size() < k || gt(lowerBound, candidateDistance)) {
Expand Down

0 comments on commit 08123a1

Please sign in to comment.