From 8798c1474c8cfb897c5d41492a93c3c046e403df Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 29 Sep 2024 13:45:25 -0700 Subject: [PATCH] Updated naming [skip ci] --- src/hnsw.c | 28 ++++++++++++++-------------- src/hnsw.h | 14 +++++++------- src/hnswscan.c | 10 +++++----- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/hnsw.c b/src/hnsw.c index 249719f..22e6985 100644 --- a/src/hnsw.c +++ b/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"); diff --git a/src/hnsw.h b/src/hnsw.h index 878e262..0d85f05 100644 --- a/src/hnsw.h +++ b/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; diff --git a/src/hnswscan.c b/src/hnswscan.c index 61c80cf..d449f63 100644 --- a/src/hnswscan.c +++ b/src/hnswscan.c @@ -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;