Added HnswQuery struct for query data

This commit is contained in:
Andrew Kane
2024-10-09 23:45:47 -07:00
parent 32ab27d72a
commit fa6782985a
4 changed files with 37 additions and 25 deletions

View File

@@ -11,7 +11,7 @@
* Algorithm 5 from paper
*/
static List *
GetScanItems(IndexScanDesc scan, Datum q)
GetScanItems(IndexScanDesc scan, Datum value)
{
HnswScanOpaque so = (HnswScanOpaque) scan->opaque;
Relation index = scan->indexRelation;
@@ -21,6 +21,9 @@ GetScanItems(IndexScanDesc scan, Datum q)
int m;
HnswElement entryPoint;
char *base = NULL;
HnswQuery q;
q.value = value;
/* Get m and entry point */
HnswGetMetaPageInfo(index, &m, &entryPoint);
@@ -28,15 +31,15 @@ GetScanItems(IndexScanDesc scan, Datum q)
if (entryPoint == NULL)
return NIL;
ep = list_make1(HnswEntryCandidate(base, entryPoint, q, index, support, false));
ep = list_make1(HnswEntryCandidate(base, entryPoint, &q, index, support, false));
for (int lc = entryPoint->level; lc >= 1; lc--)
{
w = HnswSearchLayer(base, q, ep, 1, lc, index, support, m, false, NULL);
w = HnswSearchLayer(base, &q, ep, 1, lc, index, support, m, false, NULL);
ep = w;
}
return HnswSearchLayer(base, q, ep, hnsw_ef_search, 0, index, support, m, false, NULL);
return HnswSearchLayer(base, &q, ep, hnsw_ef_search, 0, index, support, m, false, NULL);
}
/*