mirror of
https://github.com/pgvector/pgvector.git
synced 2026-06-06 05:51:21 +08:00
Updated naming [skip ci]
This commit is contained in:
28
src/hnsw.c
28
src/hnsw.c
@@ -18,18 +18,18 @@
|
||||
#define MarkGUCPrefixReserved(x) EmitWarningsOnPlaceholders(x)
|
||||
#endif
|
||||
|
||||
static const struct config_enum_entry hnsw_streaming_options[] = {
|
||||
{"off", HNSW_STREAMING_OFF, false},
|
||||
{"strict", HNSW_STREAMING_STRICT, false},
|
||||
{"relaxed", HNSW_STREAMING_RELAXED, false},
|
||||
static const struct config_enum_entry hnsw_iterative_search_options[] = {
|
||||
{"off", HNSW_ITERATIVE_SEARCH_OFF, false},
|
||||
{"strict", HNSW_ITERATIVE_SEARCH_STRICT, false},
|
||||
{"relaxed", HNSW_ITERATIVE_SEARCH_RELAXED, false},
|
||||
/* TODO Change to strict before merging */
|
||||
{"on", HNSW_STREAMING_RELAXED, false},
|
||||
{"on", HNSW_ITERATIVE_SEARCH_RELAXED, false},
|
||||
{NULL, 0, false}
|
||||
};
|
||||
|
||||
int hnsw_ef_search;
|
||||
int hnsw_ef_stream;
|
||||
int hnsw_streaming;
|
||||
int hnsw_max_iterative_tuples;
|
||||
int hnsw_iterative_search;
|
||||
int hnsw_lock_tranche_id;
|
||||
static relopt_kind hnsw_relopt_kind;
|
||||
|
||||
@@ -80,15 +80,15 @@ HnswInit(void)
|
||||
"Valid range is 1..1000.", &hnsw_ef_search,
|
||||
HNSW_DEFAULT_EF_SEARCH, HNSW_MIN_EF_SEARCH, HNSW_MAX_EF_SEARCH, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||
|
||||
/* TODO Figure out name */
|
||||
DefineCustomEnumVariable("hnsw.streaming", "Use streaming mode",
|
||||
NULL, &hnsw_streaming,
|
||||
HNSW_STREAMING_OFF, hnsw_streaming_options, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||
/* TODO Change name */
|
||||
DefineCustomEnumVariable("hnsw.streaming", "Iterative search mode",
|
||||
NULL, &hnsw_iterative_search,
|
||||
HNSW_ITERATIVE_SEARCH_OFF, hnsw_iterative_search_options, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||
|
||||
/* TODO Figure out name */
|
||||
/* TODO Use same value as ivfflat.max_probes for "all" */
|
||||
/* TODO Change name */
|
||||
/* TODO Ensure ivfflat.max_probes uses same value for "all" */
|
||||
DefineCustomIntVariable("hnsw.ef_stream", "Sets the max number of additional candidates to visit for streaming search",
|
||||
"-1 means all", &hnsw_ef_stream,
|
||||
"-1 means all", &hnsw_max_iterative_tuples,
|
||||
HNSW_DEFAULT_EF_STREAM, HNSW_MIN_EF_STREAM, HNSW_MAX_EF_STREAM, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||
|
||||
MarkGUCPrefixReserved("hnsw");
|
||||
|
||||
14
src/hnsw.h
14
src/hnsw.h
@@ -128,16 +128,16 @@
|
||||
|
||||
/* Variables */
|
||||
extern int hnsw_ef_search;
|
||||
extern int hnsw_ef_stream;
|
||||
extern int hnsw_streaming;
|
||||
extern int hnsw_max_iterative_tuples;
|
||||
extern int hnsw_iterative_search;
|
||||
extern int hnsw_lock_tranche_id;
|
||||
|
||||
typedef enum HnswStreamingMode
|
||||
typedef enum HnswIterativeSearch
|
||||
{
|
||||
HNSW_STREAMING_OFF,
|
||||
HNSW_STREAMING_STRICT,
|
||||
HNSW_STREAMING_RELAXED
|
||||
} HnswStreamingMode;
|
||||
HNSW_ITERATIVE_SEARCH_OFF,
|
||||
HNSW_ITERATIVE_SEARCH_STRICT,
|
||||
HNSW_ITERATIVE_SEARCH_RELAXED
|
||||
} HnswIterativeSearch;
|
||||
|
||||
typedef struct HnswElementData HnswElementData;
|
||||
typedef struct HnswNeighborArray HnswNeighborArray;
|
||||
|
||||
@@ -42,7 +42,7 @@ GetScanItems(IndexScanDesc scan, Datum q)
|
||||
ep = w;
|
||||
}
|
||||
|
||||
return HnswSearchLayer(base, q, ep, hnsw_ef_search, 0, index, procinfo, collation, m, false, NULL, &so->v, hnsw_streaming != HNSW_STREAMING_OFF ? &so->discarded : NULL, true, &so->tuples);
|
||||
return HnswSearchLayer(base, q, ep, hnsw_ef_search, 0, index, procinfo, collation, m, false, NULL, &so->v, hnsw_iterative_search != HNSW_ITERATIVE_SEARCH_OFF ? &so->discarded : NULL, true, &so->tuples);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -222,7 +222,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||
|
||||
if (list_length(so->w) == 0)
|
||||
{
|
||||
if (hnsw_streaming == HNSW_STREAMING_OFF)
|
||||
if (hnsw_iterative_search == HNSW_ITERATIVE_SEARCH_OFF)
|
||||
break;
|
||||
|
||||
/* Empty index */
|
||||
@@ -230,7 +230,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||
break;
|
||||
|
||||
/* Reached max number of additional tuples */
|
||||
if (hnsw_ef_stream != -1 && so->tuples >= hnsw_ef_search + hnsw_ef_stream)
|
||||
if (hnsw_max_iterative_tuples != -1 && so->tuples >= hnsw_ef_search + hnsw_max_iterative_tuples)
|
||||
{
|
||||
if (pairingheap_is_empty(so->discarded))
|
||||
break;
|
||||
@@ -288,7 +288,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||
so->w = list_delete_last(so->w);
|
||||
|
||||
/* Mark memory as free for next iteration */
|
||||
if (hnsw_streaming != HNSW_STREAMING_OFF)
|
||||
if (hnsw_iterative_search != HNSW_ITERATIVE_SEARCH_OFF)
|
||||
{
|
||||
pfree(element);
|
||||
pfree(hc);
|
||||
@@ -299,7 +299,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||
|
||||
heaptid = &element->heaptids[--element->heaptidsLength];
|
||||
|
||||
if (hnsw_streaming == HNSW_STREAMING_STRICT)
|
||||
if (hnsw_iterative_search == HNSW_ITERATIVE_SEARCH_STRICT)
|
||||
{
|
||||
if (hc->distance < so->previousDistance)
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user