From 078a42e82455114e060cb8d22301edb7af711c6c Mon Sep 17 00:00:00 2001 From: Oscar Laird Date: Sat, 24 Feb 2024 12:46:45 -0500 Subject: [PATCH] share pinecone_api_key between files --- src/pinecone.c | 8 ++++---- src/pinecone.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pinecone.c b/src/pinecone.c index d22851e5..bb4f48d1 100644 --- a/src/pinecone.c +++ b/src/pinecone.c @@ -49,8 +49,8 @@ typedef struct PineconeOptions int buffer_threshold; // threshold for the buffer before flushing to remote vector store. } PineconeOptions; -char *pinecone_api_key = NULL; -int *pinecone_top_k = NULL; +char* pinecone_api_key = NULL; +int pinecone_top_k = 1000; // todo: principled batch sizes. Do we ever want the buffer to be bigger than a multi-insert? Possibly if we want to let the buffer fill up when the remote index is down. static relopt_kind pinecone_relopt_kind; @@ -73,7 +73,7 @@ PineconeInit(void) &pinecone_api_key, NULL, // todo: this should default to an empty string because it is easier to deal with Not Authorized errors than it is to deal with segfaults; get rid of validate_api_key PGC_SUSET, // restrict to superusers, takes immediate effect and is not saved in the configuration file 0, NULL, NULL, NULL); - DefineCustomIntVariable("pinecone.top_k", "topK parameter for pinecone queries", "topK parameter for pinecone queries. Default is 10000. Lowering this value may improve performance but you will not be able to retrieve more than this number of results", + DefineCustomIntVariable("pinecone.top_k", "Pinecone top k", "Pinecone top k", &pinecone_top_k, 10000, 1, 10000, PGC_USERSET, @@ -572,7 +572,7 @@ pinecone_beginscan(Relation index, int nkeys, int norderbys) // prep sort // TODO allocate 10MB for the sort (we should actually need a lot less) - so->sortstate = tuplesort_begin_heap(so->tupdesc, 1, attNums, sortOperators, sortCollations, nullsFirstFlags, 10000, NULL, false); + so->sortstate = tuplesort_begin_heap(so->tupdesc, 1, attNums, sortOperators, sortCollations, nullsFirstFlags, pinecone_top_k, NULL, false); so->slot = MakeSingleTupleTableSlot(so->tupdesc, &TTSOpsMinimalTuple); // scan->opaque = so; diff --git a/src/pinecone.h b/src/pinecone.h index 6dda2be1..115da916 100644 --- a/src/pinecone.h +++ b/src/pinecone.h @@ -100,6 +100,7 @@ cJSON* index_tuple_get_pinecone_vector(Relation index, IndexTuple itup); cJSON* heap_tuple_get_pinecone_vector(Relation heap, HeapTuple htup); cJSON* tuple_get_pinecone_vector(TupleDesc tup_desc, Datum *values, bool *isnull, char *vector_id); +extern char *pinecone_api_key; extern void validate_api_key(void); VectorMetric get_opclass_metric(Relation index);