Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ public long addGraphNode(int node, SearchScoreProvider searchScoreProvider) {
insertionsInProgress.remove(nodeLevel);
}

return IntStream.range(0, nodeLevel.level).mapToLong(graph::ramBytesUsedOneNode).sum();
return IntStream.rangeClosed(0, nodeLevel.level).mapToLong(graph::ramBytesUsedOneNode).sum();
}

private void updateNeighborsOneLayer(int layer, int node, NodeScore[] neighbors, NodeArray naturalScratchPooled, ConcurrentSkipListSet<NodeAtLevel> inProgressBefore, NodeArray concurrentScratchPooled, SearchScoreProvider ssp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ public void tearDown() {
TestUtil.deleteQuietly(testDirectory);
}

@Test
public void testEstimatedBytes() throws IOException {
// Create test vectors where each vector is [node_id, 0]
var vectors = new ArrayList<VectorFloat<?>>();
vectors.add(vts.createFloatVector(new float[] {0, 0}));
vectors.add(vts.createFloatVector(new float[] {0, 1}));
vectors.add(vts.createFloatVector(new float[] {2, 0}));
var ravv = new ListRandomAccessVectorValues(vectors, 2);
var bsp = BuildScoreProvider.randomAccessScoreProvider(ravv, VectorSimilarityFunction.EUCLIDEAN);
try (var builder = new GraphIndexBuilder(bsp, 2, 2, 10, 1.0f, 1.0f, false)) {
var bytesUsed = builder.addGraphNode(0, ravv.getVector(0));
// The actual value is not critical, but this confirms we do not get unexpected changes (for this config)
assertEquals(92, bytesUsed);
}
}

@Test
public void testRescore() {
testRescore(false);
Expand Down
Loading