mirror of
https://github.com/pgvector/pgvector.git
synced 2026-12-05 08:48:38 +00:00
Fixed zero handling for HNSW level selection - resolves #1023
Co-authored-by: cuishuang <imcusg@gmail.com>
This commit is contained in:
1 parent
e48241b4dc
commit
efa08fda9e
1 file changed
+2
-1
+2
-1
@@ -246,7 +246,8 @@ HnswInitElement(char *base, ItemPointer heaptid, int m, double ml, int maxLevel,
|
||||
{
|
||||
HnswElement element = HnswAlloc(allocator, sizeof(HnswElementData));
|
||||
|
||||
int level = (int) (-log(RandomDouble()) * ml);
|
||||
double uniform = RandomDouble();
|
||||
int level = uniform == 0.0 ? maxLevel : (int) (-log(uniform) * ml);
|
||||
|
||||
/* Cap level */
|
||||
if (level > maxLevel)
|
||||
|
||||
Reference in new issue
Block a user