Skip to content

Commit

Permalink
share pinecone_api_key between files
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarlaird committed Feb 24, 2024
1 parent 8a2fe09 commit 078a42e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pinecone.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/pinecone.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 078a42e

Please sign in to comment.