mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-12 07:36:55 +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)
|
#define MarkGUCPrefixReserved(x) EmitWarningsOnPlaceholders(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const struct config_enum_entry hnsw_streaming_options[] = {
|
static const struct config_enum_entry hnsw_iterative_search_options[] = {
|
||||||
{"off", HNSW_STREAMING_OFF, false},
|
{"off", HNSW_ITERATIVE_SEARCH_OFF, false},
|
||||||
{"strict", HNSW_STREAMING_STRICT, false},
|
{"strict", HNSW_ITERATIVE_SEARCH_STRICT, false},
|
||||||
{"relaxed", HNSW_STREAMING_RELAXED, false},
|
{"relaxed", HNSW_ITERATIVE_SEARCH_RELAXED, false},
|
||||||
/* TODO Change to strict before merging */
|
/* TODO Change to strict before merging */
|
||||||
{"on", HNSW_STREAMING_RELAXED, false},
|
{"on", HNSW_ITERATIVE_SEARCH_RELAXED, false},
|
||||||
{NULL, 0, false}
|
{NULL, 0, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
int hnsw_ef_search;
|
int hnsw_ef_search;
|
||||||
int hnsw_ef_stream;
|
int hnsw_max_iterative_tuples;
|
||||||
int hnsw_streaming;
|
int hnsw_iterative_search;
|
||||||
int hnsw_lock_tranche_id;
|
int hnsw_lock_tranche_id;
|
||||||
static relopt_kind hnsw_relopt_kind;
|
static relopt_kind hnsw_relopt_kind;
|
||||||
|
|
||||||
@@ -80,15 +80,15 @@ HnswInit(void)
|
|||||||
"Valid range is 1..1000.", &hnsw_ef_search,
|
"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);
|
HNSW_DEFAULT_EF_SEARCH, HNSW_MIN_EF_SEARCH, HNSW_MAX_EF_SEARCH, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||||
|
|
||||||
/* TODO Figure out name */
|
/* TODO Change name */
|
||||||
DefineCustomEnumVariable("hnsw.streaming", "Use streaming mode",
|
DefineCustomEnumVariable("hnsw.streaming", "Iterative search mode",
|
||||||
NULL, &hnsw_streaming,
|
NULL, &hnsw_iterative_search,
|
||||||
HNSW_STREAMING_OFF, hnsw_streaming_options, PGC_USERSET, 0, NULL, NULL, NULL);
|
HNSW_ITERATIVE_SEARCH_OFF, hnsw_iterative_search_options, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||||
|
|
||||||
/* TODO Figure out name */
|
/* TODO Change name */
|
||||||
/* TODO Use same value as ivfflat.max_probes for "all" */
|
/* 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",
|
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);
|
HNSW_DEFAULT_EF_STREAM, HNSW_MIN_EF_STREAM, HNSW_MAX_EF_STREAM, PGC_USERSET, 0, NULL, NULL, NULL);
|
||||||
|
|
||||||
MarkGUCPrefixReserved("hnsw");
|
MarkGUCPrefixReserved("hnsw");
|
||||||
|
|||||||
14
src/hnsw.h
14
src/hnsw.h
@@ -128,16 +128,16 @@
|
|||||||
|
|
||||||
/* Variables */
|
/* Variables */
|
||||||
extern int hnsw_ef_search;
|
extern int hnsw_ef_search;
|
||||||
extern int hnsw_ef_stream;
|
extern int hnsw_max_iterative_tuples;
|
||||||
extern int hnsw_streaming;
|
extern int hnsw_iterative_search;
|
||||||
extern int hnsw_lock_tranche_id;
|
extern int hnsw_lock_tranche_id;
|
||||||
|
|
||||||
typedef enum HnswStreamingMode
|
typedef enum HnswIterativeSearch
|
||||||
{
|
{
|
||||||
HNSW_STREAMING_OFF,
|
HNSW_ITERATIVE_SEARCH_OFF,
|
||||||
HNSW_STREAMING_STRICT,
|
HNSW_ITERATIVE_SEARCH_STRICT,
|
||||||
HNSW_STREAMING_RELAXED
|
HNSW_ITERATIVE_SEARCH_RELAXED
|
||||||
} HnswStreamingMode;
|
} HnswIterativeSearch;
|
||||||
|
|
||||||
typedef struct HnswElementData HnswElementData;
|
typedef struct HnswElementData HnswElementData;
|
||||||
typedef struct HnswNeighborArray HnswNeighborArray;
|
typedef struct HnswNeighborArray HnswNeighborArray;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ GetScanItems(IndexScanDesc scan, Datum q)
|
|||||||
ep = w;
|
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 (list_length(so->w) == 0)
|
||||||
{
|
{
|
||||||
if (hnsw_streaming == HNSW_STREAMING_OFF)
|
if (hnsw_iterative_search == HNSW_ITERATIVE_SEARCH_OFF)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Empty index */
|
/* Empty index */
|
||||||
@@ -230,7 +230,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* Reached max number of additional tuples */
|
/* 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))
|
if (pairingheap_is_empty(so->discarded))
|
||||||
break;
|
break;
|
||||||
@@ -288,7 +288,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
|
|||||||
so->w = list_delete_last(so->w);
|
so->w = list_delete_last(so->w);
|
||||||
|
|
||||||
/* Mark memory as free for next iteration */
|
/* Mark memory as free for next iteration */
|
||||||
if (hnsw_streaming != HNSW_STREAMING_OFF)
|
if (hnsw_iterative_search != HNSW_ITERATIVE_SEARCH_OFF)
|
||||||
{
|
{
|
||||||
pfree(element);
|
pfree(element);
|
||||||
pfree(hc);
|
pfree(hc);
|
||||||
@@ -299,7 +299,7 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
|
|||||||
|
|
||||||
heaptid = &element->heaptids[--element->heaptidsLength];
|
heaptid = &element->heaptids[--element->heaptidsLength];
|
||||||
|
|
||||||
if (hnsw_streaming == HNSW_STREAMING_STRICT)
|
if (hnsw_iterative_search == HNSW_ITERATIVE_SEARCH_STRICT)
|
||||||
{
|
{
|
||||||
if (hc->distance < so->previousDistance)
|
if (hc->distance < so->previousDistance)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user