-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added hnsw.ef_search variable to change expansion factor during search at runtime #199
Changes from 5 commits
7a2572e
e3cbf74
f338c83
6338f11
b5b93ac
7c260fc
8c610a6
5b0dc1c
ae18eb7
79b2924
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,6 +159,8 @@ bool ldb_amgettuple(IndexScanDesc scan, ScanDirection dir) | |
// about the furtheest neighbors | ||
Assert(ScanDirectionIsForward(dir)); | ||
|
||
int ef = ldb_hnsw_ef_search; // 0 if not set, but we pass it into usearch_custom_ef anyway since 0 is also a | ||
// sentinel value there | ||
if(scanstate->first) { | ||
int num_returned; | ||
Datum value; | ||
|
@@ -193,8 +195,14 @@ bool ldb_amgettuple(IndexScanDesc scan, ScanDirection dir) | |
} | ||
|
||
ldb_dlog("LANTERN querying index for %d elements", k); | ||
num_returned = usearch_search( | ||
scanstate->usearch_index, vec, usearch_scalar_f32_k, k, scanstate->labels, scanstate->distances, &error); | ||
num_returned = usearch_search_custom_ef(scanstate->usearch_index, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be better to just add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would do this but C doesn't support optional parameters in functions. We can make The " Maybe just rename |
||
vec, | ||
usearch_scalar_f32_k, | ||
k, | ||
ef, | ||
scanstate->labels, | ||
scanstate->distances, | ||
&error); | ||
ldb_wal_retriever_area_reset(scanstate->retriever_ctx, NULL); | ||
|
||
scanstate->count = num_returned; | ||
|
@@ -228,8 +236,14 @@ bool ldb_amgettuple(IndexScanDesc scan, ScanDirection dir) | |
scanstate->labels = repalloc(scanstate->labels, k * sizeof(usearch_label_t)); | ||
|
||
ldb_dlog("LANTERN - querying index for %d elements", k); | ||
num_returned = usearch_search( | ||
scanstate->usearch_index, vec, usearch_scalar_f32_k, k, scanstate->labels, scanstate->distances, &error); | ||
num_returned = usearch_search_custom_ef(scanstate->usearch_index, | ||
vec, | ||
usearch_scalar_f32_k, | ||
k, | ||
ef, | ||
scanstate->labels, | ||
scanstate->distances, | ||
&error); | ||
ldb_wal_retriever_area_reset(scanstate->retriever_ctx, NULL); | ||
|
||
scanstate->count = num_returned; | ||
|
+18 −6 | c/lib.cpp | |
+4 −0 | c/usearch.h | |
+7 −7 | include/usearch/index_punned_dense.hpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this supposed to be commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove, doesn't impact functionality at all