Compare commits

...

4 Commits

Author SHA1 Message Date
Andrew Kane
1bc29ac697 Added tuple stats for HNSW [skip ci] 2024-07-13 08:47:53 -07:00
Andrew Kane
8772c8de68 Fixed compilation error with FreeBSD ARM 2024-06-30 11:23:39 -07:00
Andrew Kane
d1694a93af Added ubuntu-24.04 to CI [skip ci] 2024-06-17 10:45:58 -07:00
Andrew Kane
61870a0244 Fixed compilation warning with MSVC and Postgres 16 - fixes #598
Co-authored-by: Xing Guo <higuoxing@gmail.com>
2024-06-16 12:09:01 -07:00
14 changed files with 147 additions and 107 deletions

View File

@@ -9,9 +9,9 @@ jobs:
matrix: matrix:
include: include:
- postgres: 17 - postgres: 17
os: ubuntu-22.04 os: ubuntu-24.04
- postgres: 16 - postgres: 16
os: ubuntu-22.04 os: ubuntu-24.04
- postgres: 15 - postgres: 15
os: ubuntu-22.04 os: ubuntu-22.04
- postgres: 14 - postgres: 14

View File

@@ -1,3 +1,8 @@
## 0.7.3 (unreleased)
- Fixed compilation error with FreeBSD ARM
- Fixed compilation warning with MSVC and Postgres 16
## 0.7.2 (2024-06-11) ## 0.7.2 (2024-06-11)
- Fixed initialization fork for indexes on unlogged tables - Fixed initialization fork for indexes on unlogged tables

View File

@@ -3,6 +3,7 @@
#include "bitutils.h" #include "bitutils.h"
#include "bitvec.h" #include "bitvec.h"
#include "utils/varbit.h" #include "utils/varbit.h"
#include "vector.h"
#if PG_VERSION_NUM >= 160000 #if PG_VERSION_NUM >= 160000
#include "varatt.h" #include "varatt.h"
@@ -40,7 +41,7 @@ CheckDims(VarBit *a, VarBit *b)
/* /*
* Get the Hamming distance between two bit vectors * Get the Hamming distance between two bit vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(hamming_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(hamming_distance);
Datum Datum
hamming_distance(PG_FUNCTION_ARGS) hamming_distance(PG_FUNCTION_ARGS)
{ {
@@ -55,7 +56,7 @@ hamming_distance(PG_FUNCTION_ARGS)
/* /*
* Get the Jaccard distance between two bit vectors * Get the Jaccard distance between two bit vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(jaccard_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(jaccard_distance);
Datum Datum
jaccard_distance(PG_FUNCTION_ARGS) jaccard_distance(PG_FUNCTION_ARGS)
{ {

View File

@@ -185,7 +185,7 @@ float_underflow_error(void)
/* /*
* Convert textual representation to internal representation * Convert textual representation to internal representation
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_in); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_in);
Datum Datum
halfvec_in(PG_FUNCTION_ARGS) halfvec_in(PG_FUNCTION_ARGS)
{ {
@@ -299,7 +299,7 @@ halfvec_in(PG_FUNCTION_ARGS)
/* /*
* Convert internal representation to textual representation * Convert internal representation to textual representation
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_out); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_out);
Datum Datum
halfvec_out(PG_FUNCTION_ARGS) halfvec_out(PG_FUNCTION_ARGS)
{ {
@@ -345,7 +345,7 @@ halfvec_out(PG_FUNCTION_ARGS)
/* /*
* Convert type modifier * Convert type modifier
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_typmod_in); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_typmod_in);
Datum Datum
halfvec_typmod_in(PG_FUNCTION_ARGS) halfvec_typmod_in(PG_FUNCTION_ARGS)
{ {
@@ -376,7 +376,7 @@ halfvec_typmod_in(PG_FUNCTION_ARGS)
/* /*
* Convert external binary representation to internal representation * Convert external binary representation to internal representation
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_recv); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_recv);
Datum Datum
halfvec_recv(PG_FUNCTION_ARGS) halfvec_recv(PG_FUNCTION_ARGS)
{ {
@@ -410,7 +410,7 @@ halfvec_recv(PG_FUNCTION_ARGS)
/* /*
* Convert internal representation to the external binary representation * Convert internal representation to the external binary representation
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_send); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_send);
Datum Datum
halfvec_send(PG_FUNCTION_ARGS) halfvec_send(PG_FUNCTION_ARGS)
{ {
@@ -430,7 +430,7 @@ halfvec_send(PG_FUNCTION_ARGS)
* Convert half vector to half vector * Convert half vector to half vector
* This is needed to check the type modifier * This is needed to check the type modifier
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec);
Datum Datum
halfvec(PG_FUNCTION_ARGS) halfvec(PG_FUNCTION_ARGS)
{ {
@@ -445,7 +445,7 @@ halfvec(PG_FUNCTION_ARGS)
/* /*
* Convert array to half vector * Convert array to half vector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(array_to_halfvec); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(array_to_halfvec);
Datum Datum
array_to_halfvec(PG_FUNCTION_ARGS) array_to_halfvec(PG_FUNCTION_ARGS)
{ {
@@ -519,7 +519,7 @@ array_to_halfvec(PG_FUNCTION_ARGS)
/* /*
* Convert half vector to float4[] * Convert half vector to float4[]
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_to_float4); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_to_float4);
Datum Datum
halfvec_to_float4(PG_FUNCTION_ARGS) halfvec_to_float4(PG_FUNCTION_ARGS)
{ {
@@ -543,7 +543,7 @@ halfvec_to_float4(PG_FUNCTION_ARGS)
/* /*
* Convert vector to half vec * Convert vector to half vec
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_to_halfvec); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_to_halfvec);
Datum Datum
vector_to_halfvec(PG_FUNCTION_ARGS) vector_to_halfvec(PG_FUNCTION_ARGS)
{ {
@@ -565,7 +565,7 @@ vector_to_halfvec(PG_FUNCTION_ARGS)
/* /*
* Get the L2 distance between half vectors * Get the L2 distance between half vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_l2_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_l2_distance);
Datum Datum
halfvec_l2_distance(PG_FUNCTION_ARGS) halfvec_l2_distance(PG_FUNCTION_ARGS)
{ {
@@ -580,7 +580,7 @@ halfvec_l2_distance(PG_FUNCTION_ARGS)
/* /*
* Get the L2 squared distance between half vectors * Get the L2 squared distance between half vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_l2_squared_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_l2_squared_distance);
Datum Datum
halfvec_l2_squared_distance(PG_FUNCTION_ARGS) halfvec_l2_squared_distance(PG_FUNCTION_ARGS)
{ {
@@ -595,7 +595,7 @@ halfvec_l2_squared_distance(PG_FUNCTION_ARGS)
/* /*
* Get the inner product of two half vectors * Get the inner product of two half vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_inner_product); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_inner_product);
Datum Datum
halfvec_inner_product(PG_FUNCTION_ARGS) halfvec_inner_product(PG_FUNCTION_ARGS)
{ {
@@ -610,7 +610,7 @@ halfvec_inner_product(PG_FUNCTION_ARGS)
/* /*
* Get the negative inner product of two half vectors * Get the negative inner product of two half vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_negative_inner_product); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_negative_inner_product);
Datum Datum
halfvec_negative_inner_product(PG_FUNCTION_ARGS) halfvec_negative_inner_product(PG_FUNCTION_ARGS)
{ {
@@ -625,7 +625,7 @@ halfvec_negative_inner_product(PG_FUNCTION_ARGS)
/* /*
* Get the cosine distance between two half vectors * Get the cosine distance between two half vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_cosine_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_cosine_distance);
Datum Datum
halfvec_cosine_distance(PG_FUNCTION_ARGS) halfvec_cosine_distance(PG_FUNCTION_ARGS)
{ {
@@ -657,7 +657,7 @@ halfvec_cosine_distance(PG_FUNCTION_ARGS)
* Currently uses angular distance since needs to satisfy triangle inequality * Currently uses angular distance since needs to satisfy triangle inequality
* Assumes inputs are unit vectors (skips norm) * Assumes inputs are unit vectors (skips norm)
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_spherical_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_spherical_distance);
Datum Datum
halfvec_spherical_distance(PG_FUNCTION_ARGS) halfvec_spherical_distance(PG_FUNCTION_ARGS)
{ {
@@ -681,7 +681,7 @@ halfvec_spherical_distance(PG_FUNCTION_ARGS)
/* /*
* Get the L1 distance between two half vectors * Get the L1 distance between two half vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_l1_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_l1_distance);
Datum Datum
halfvec_l1_distance(PG_FUNCTION_ARGS) halfvec_l1_distance(PG_FUNCTION_ARGS)
{ {
@@ -696,7 +696,7 @@ halfvec_l1_distance(PG_FUNCTION_ARGS)
/* /*
* Get the dimensions of a half vector * Get the dimensions of a half vector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_vector_dims); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_vector_dims);
Datum Datum
halfvec_vector_dims(PG_FUNCTION_ARGS) halfvec_vector_dims(PG_FUNCTION_ARGS)
{ {
@@ -708,7 +708,7 @@ halfvec_vector_dims(PG_FUNCTION_ARGS)
/* /*
* Get the L2 norm of a half vector * Get the L2 norm of a half vector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_l2_norm); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_l2_norm);
Datum Datum
halfvec_l2_norm(PG_FUNCTION_ARGS) halfvec_l2_norm(PG_FUNCTION_ARGS)
{ {
@@ -730,7 +730,7 @@ halfvec_l2_norm(PG_FUNCTION_ARGS)
/* /*
* Normalize a half vector with the L2 norm * Normalize a half vector with the L2 norm
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_l2_normalize); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_l2_normalize);
Datum Datum
halfvec_l2_normalize(PG_FUNCTION_ARGS) halfvec_l2_normalize(PG_FUNCTION_ARGS)
{ {
@@ -769,7 +769,7 @@ halfvec_l2_normalize(PG_FUNCTION_ARGS)
/* /*
* Add half vectors * Add half vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_add); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_add);
Datum Datum
halfvec_add(PG_FUNCTION_ARGS) halfvec_add(PG_FUNCTION_ARGS)
{ {
@@ -808,7 +808,7 @@ halfvec_add(PG_FUNCTION_ARGS)
/* /*
* Subtract half vectors * Subtract half vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_sub); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_sub);
Datum Datum
halfvec_sub(PG_FUNCTION_ARGS) halfvec_sub(PG_FUNCTION_ARGS)
{ {
@@ -847,7 +847,7 @@ halfvec_sub(PG_FUNCTION_ARGS)
/* /*
* Multiply half vectors * Multiply half vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_mul); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_mul);
Datum Datum
halfvec_mul(PG_FUNCTION_ARGS) halfvec_mul(PG_FUNCTION_ARGS)
{ {
@@ -889,7 +889,7 @@ halfvec_mul(PG_FUNCTION_ARGS)
/* /*
* Concatenate half vectors * Concatenate half vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_concat); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_concat);
Datum Datum
halfvec_concat(PG_FUNCTION_ARGS) halfvec_concat(PG_FUNCTION_ARGS)
{ {
@@ -913,7 +913,7 @@ halfvec_concat(PG_FUNCTION_ARGS)
/* /*
* Quantize a half vector * Quantize a half vector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_binary_quantize); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_binary_quantize);
Datum Datum
halfvec_binary_quantize(PG_FUNCTION_ARGS) halfvec_binary_quantize(PG_FUNCTION_ARGS)
{ {
@@ -931,7 +931,7 @@ halfvec_binary_quantize(PG_FUNCTION_ARGS)
/* /*
* Get a subvector * Get a subvector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_subvector); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_subvector);
Datum Datum
halfvec_subvector(PG_FUNCTION_ARGS) halfvec_subvector(PG_FUNCTION_ARGS)
{ {
@@ -1005,7 +1005,7 @@ halfvec_cmp_internal(HalfVector * a, HalfVector * b)
/* /*
* Less than * Less than
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_lt); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_lt);
Datum Datum
halfvec_lt(PG_FUNCTION_ARGS) halfvec_lt(PG_FUNCTION_ARGS)
{ {
@@ -1018,7 +1018,7 @@ halfvec_lt(PG_FUNCTION_ARGS)
/* /*
* Less than or equal * Less than or equal
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_le); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_le);
Datum Datum
halfvec_le(PG_FUNCTION_ARGS) halfvec_le(PG_FUNCTION_ARGS)
{ {
@@ -1031,7 +1031,7 @@ halfvec_le(PG_FUNCTION_ARGS)
/* /*
* Equal * Equal
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_eq); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_eq);
Datum Datum
halfvec_eq(PG_FUNCTION_ARGS) halfvec_eq(PG_FUNCTION_ARGS)
{ {
@@ -1044,7 +1044,7 @@ halfvec_eq(PG_FUNCTION_ARGS)
/* /*
* Not equal * Not equal
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_ne); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_ne);
Datum Datum
halfvec_ne(PG_FUNCTION_ARGS) halfvec_ne(PG_FUNCTION_ARGS)
{ {
@@ -1057,7 +1057,7 @@ halfvec_ne(PG_FUNCTION_ARGS)
/* /*
* Greater than or equal * Greater than or equal
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_ge); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_ge);
Datum Datum
halfvec_ge(PG_FUNCTION_ARGS) halfvec_ge(PG_FUNCTION_ARGS)
{ {
@@ -1070,7 +1070,7 @@ halfvec_ge(PG_FUNCTION_ARGS)
/* /*
* Greater than * Greater than
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_gt); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_gt);
Datum Datum
halfvec_gt(PG_FUNCTION_ARGS) halfvec_gt(PG_FUNCTION_ARGS)
{ {
@@ -1083,7 +1083,7 @@ halfvec_gt(PG_FUNCTION_ARGS)
/* /*
* Compare half vectors * Compare half vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_cmp); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_cmp);
Datum Datum
halfvec_cmp(PG_FUNCTION_ARGS) halfvec_cmp(PG_FUNCTION_ARGS)
{ {
@@ -1096,7 +1096,7 @@ halfvec_cmp(PG_FUNCTION_ARGS)
/* /*
* Accumulate half vectors * Accumulate half vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_accum); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_accum);
Datum Datum
halfvec_accum(PG_FUNCTION_ARGS) halfvec_accum(PG_FUNCTION_ARGS)
{ {
@@ -1157,7 +1157,7 @@ halfvec_accum(PG_FUNCTION_ARGS)
/* /*
* Average half vectors * Average half vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_avg); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_avg);
Datum Datum
halfvec_avg(PG_FUNCTION_ARGS) halfvec_avg(PG_FUNCTION_ARGS)
{ {
@@ -1191,7 +1191,7 @@ halfvec_avg(PG_FUNCTION_ARGS)
/* /*
* Convert sparse vector to half vector * Convert sparse vector to half vector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_to_halfvec); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_to_halfvec);
Datum Datum
sparsevec_to_halfvec(PG_FUNCTION_ARGS) sparsevec_to_halfvec(PG_FUNCTION_ARGS)
{ {

View File

@@ -38,7 +38,7 @@
/* F16C has better performance than _Float16 (on x86-64) */ /* F16C has better performance than _Float16 (on x86-64) */
#if defined(__F16C__) #if defined(__F16C__)
#define F16C_SUPPORT #define F16C_SUPPORT
#elif defined(__FLT16_MAX__) && !defined(HALFVEC_DISPATCH) #elif defined(__FLT16_MAX__) && !defined(HALFVEC_DISPATCH) && !defined(__FreeBSD__)
#define FLT16_SUPPORT #define FLT16_SUPPORT
#endif #endif

View File

@@ -20,6 +20,10 @@ int hnsw_ef_search;
int hnsw_lock_tranche_id; int hnsw_lock_tranche_id;
static relopt_kind hnsw_relopt_kind; static relopt_kind hnsw_relopt_kind;
#ifdef HNSW_STATS
int hnsw_tuples;
#endif
/* /*
* Assign a tranche ID for our LWLocks. This only needs to be done by one * Assign a tranche ID for our LWLocks. This only needs to be done by one
* backend, as the tranche ID is remembered in shared memory. * backend, as the tranche ID is remembered in shared memory.
@@ -135,6 +139,10 @@ hnswcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
genericcostestimate(root, path, loop_count, &costs); genericcostestimate(root, path, loop_count, &costs);
#ifdef HNSW_STATS
elog(INFO, "estimated tuples = %0.f", costs.numIndexTuples);
#endif
/* Use total cost since most work happens before first tuple is returned */ /* Use total cost since most work happens before first tuple is returned */
*indexStartupCost = costs.indexTotalCost; *indexStartupCost = costs.indexTotalCost;
*indexTotalCost = costs.indexTotalCost; *indexTotalCost = costs.indexTotalCost;
@@ -187,7 +195,7 @@ hnswvalidate(Oid opclassoid)
* *
* See https://www.postgresql.org/docs/current/index-api.html * See https://www.postgresql.org/docs/current/index-api.html
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(hnswhandler); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(hnswhandler);
Datum Datum
hnswhandler(PG_FUNCTION_ARGS) hnswhandler(PG_FUNCTION_ARGS)
{ {

View File

@@ -113,6 +113,10 @@
extern int hnsw_ef_search; extern int hnsw_ef_search;
extern int hnsw_lock_tranche_id; extern int hnsw_lock_tranche_id;
#ifdef HNSW_STATS
extern int hnsw_tuples;
#endif
typedef struct HnswElementData HnswElementData; typedef struct HnswElementData HnswElementData;
typedef struct HnswNeighborArray HnswNeighborArray; typedef struct HnswNeighborArray HnswNeighborArray;

View File

@@ -31,13 +31,23 @@ GetScanItems(IndexScanDesc scan, Datum q)
ep = list_make1(HnswEntryCandidate(base, entryPoint, q, index, procinfo, collation, false)); ep = list_make1(HnswEntryCandidate(base, entryPoint, q, index, procinfo, collation, false));
#ifdef HNSW_STATS
hnsw_tuples = 1;
#endif
for (int lc = entryPoint->level; lc >= 1; lc--) for (int lc = entryPoint->level; lc >= 1; lc--)
{ {
w = HnswSearchLayer(base, q, ep, 1, lc, index, procinfo, collation, m, false, NULL); w = HnswSearchLayer(base, q, ep, 1, lc, index, procinfo, collation, m, false, NULL);
ep = w; ep = w;
} }
return HnswSearchLayer(base, q, ep, hnsw_ef_search, 0, index, procinfo, collation, m, false, NULL); w = HnswSearchLayer(base, q, ep, hnsw_ef_search, 0, index, procinfo, collation, m, false, NULL);
#ifdef HNSW_STATS
elog(INFO, "total tuples = %d", hnsw_tuples);
#endif
return w;
} }
/* /*

View File

@@ -801,6 +801,11 @@ HnswSearchLayer(char *base, Datum q, List *ep, int ef, int lc, Relation index, F
HnswElement eElement = HnswPtrAccess(base, e->element); HnswElement eElement = HnswPtrAccess(base, e->element);
bool alwaysAdd = wlen < ef; bool alwaysAdd = wlen < ef;
#ifdef HNSW_STATS
if (!inserting)
hnsw_tuples++;
#endif
f = ((HnswPairingHeapNode *) pairingheap_first(W))->inner; f = ((HnswPairingHeapNode *) pairingheap_first(W))->inner;
if (index == NULL) if (index == NULL)
@@ -1305,7 +1310,7 @@ HnswGetTypeInfo(Relation index)
return (const HnswTypeInfo *) DatumGetPointer(FunctionCall0Coll(procinfo, InvalidOid)); return (const HnswTypeInfo *) DatumGetPointer(FunctionCall0Coll(procinfo, InvalidOid));
} }
PGDLLEXPORT PG_FUNCTION_INFO_V1(hnsw_halfvec_support); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(hnsw_halfvec_support);
Datum Datum
hnsw_halfvec_support(PG_FUNCTION_ARGS) hnsw_halfvec_support(PG_FUNCTION_ARGS)
{ {
@@ -1318,7 +1323,7 @@ hnsw_halfvec_support(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(&typeInfo); PG_RETURN_POINTER(&typeInfo);
}; };
PGDLLEXPORT PG_FUNCTION_INFO_V1(hnsw_bit_support); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(hnsw_bit_support);
Datum Datum
hnsw_bit_support(PG_FUNCTION_ARGS) hnsw_bit_support(PG_FUNCTION_ARGS)
{ {
@@ -1331,7 +1336,7 @@ hnsw_bit_support(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(&typeInfo); PG_RETURN_POINTER(&typeInfo);
}; };
PGDLLEXPORT PG_FUNCTION_INFO_V1(hnsw_sparsevec_support); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(hnsw_sparsevec_support);
Datum Datum
hnsw_sparsevec_support(PG_FUNCTION_ARGS) hnsw_sparsevec_support(PG_FUNCTION_ARGS)
{ {

View File

@@ -181,7 +181,7 @@ ivfflatvalidate(Oid opclassoid)
* *
* See https://www.postgresql.org/docs/current/index-api.html * See https://www.postgresql.org/docs/current/index-api.html
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(ivfflathandler); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(ivfflathandler);
Datum Datum
ivfflathandler(PG_FUNCTION_ARGS) ivfflathandler(PG_FUNCTION_ARGS)
{ {

View File

@@ -342,7 +342,7 @@ IvfflatGetTypeInfo(Relation index)
return (const IvfflatTypeInfo *) DatumGetPointer(FunctionCall0Coll(procinfo, InvalidOid)); return (const IvfflatTypeInfo *) DatumGetPointer(FunctionCall0Coll(procinfo, InvalidOid));
} }
PGDLLEXPORT PG_FUNCTION_INFO_V1(ivfflat_halfvec_support); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(ivfflat_halfvec_support);
Datum Datum
ivfflat_halfvec_support(PG_FUNCTION_ARGS) ivfflat_halfvec_support(PG_FUNCTION_ARGS)
{ {
@@ -357,7 +357,7 @@ ivfflat_halfvec_support(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(&typeInfo); PG_RETURN_POINTER(&typeInfo);
}; };
PGDLLEXPORT PG_FUNCTION_INFO_V1(ivfflat_bit_support); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(ivfflat_bit_support);
Datum Datum
ivfflat_bit_support(PG_FUNCTION_ARGS) ivfflat_bit_support(PG_FUNCTION_ARGS)
{ {

View File

@@ -188,7 +188,7 @@ CompareIndices(const void *a, const void *b)
/* /*
* Convert textual representation to internal representation * Convert textual representation to internal representation
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_in); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_in);
Datum Datum
sparsevec_in(PG_FUNCTION_ARGS) sparsevec_in(PG_FUNCTION_ARGS)
{ {
@@ -409,7 +409,7 @@ sparsevec_in(PG_FUNCTION_ARGS)
/* /*
* Convert internal representation to textual representation * Convert internal representation to textual representation
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_out); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_out);
Datum Datum
sparsevec_out(PG_FUNCTION_ARGS) sparsevec_out(PG_FUNCTION_ARGS)
{ {
@@ -462,7 +462,7 @@ sparsevec_out(PG_FUNCTION_ARGS)
/* /*
* Convert type modifier * Convert type modifier
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_typmod_in); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_typmod_in);
Datum Datum
sparsevec_typmod_in(PG_FUNCTION_ARGS) sparsevec_typmod_in(PG_FUNCTION_ARGS)
{ {
@@ -493,7 +493,7 @@ sparsevec_typmod_in(PG_FUNCTION_ARGS)
/* /*
* Convert external binary representation to internal representation * Convert external binary representation to internal representation
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_recv); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_recv);
Datum Datum
sparsevec_recv(PG_FUNCTION_ARGS) sparsevec_recv(PG_FUNCTION_ARGS)
{ {
@@ -545,7 +545,7 @@ sparsevec_recv(PG_FUNCTION_ARGS)
/* /*
* Convert internal representation to the external binary representation * Convert internal representation to the external binary representation
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_send); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_send);
Datum Datum
sparsevec_send(PG_FUNCTION_ARGS) sparsevec_send(PG_FUNCTION_ARGS)
{ {
@@ -572,7 +572,7 @@ sparsevec_send(PG_FUNCTION_ARGS)
* Convert sparse vector to sparse vector * Convert sparse vector to sparse vector
* This is needed to check the type modifier * This is needed to check the type modifier
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec);
Datum Datum
sparsevec(PG_FUNCTION_ARGS) sparsevec(PG_FUNCTION_ARGS)
{ {
@@ -587,7 +587,7 @@ sparsevec(PG_FUNCTION_ARGS)
/* /*
* Convert dense vector to sparse vector * Convert dense vector to sparse vector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_to_sparsevec); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_to_sparsevec);
Datum Datum
vector_to_sparsevec(PG_FUNCTION_ARGS) vector_to_sparsevec(PG_FUNCTION_ARGS)
{ {
@@ -630,7 +630,7 @@ vector_to_sparsevec(PG_FUNCTION_ARGS)
/* /*
* Convert half vector to sparse vector * Convert half vector to sparse vector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_to_sparsevec); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_to_sparsevec);
Datum Datum
halfvec_to_sparsevec(PG_FUNCTION_ARGS) halfvec_to_sparsevec(PG_FUNCTION_ARGS)
{ {
@@ -721,7 +721,7 @@ SparsevecL2SquaredDistance(SparseVector * a, SparseVector * b)
/* /*
* Get the L2 distance between sparse vectors * Get the L2 distance between sparse vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_l2_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_l2_distance);
Datum Datum
sparsevec_l2_distance(PG_FUNCTION_ARGS) sparsevec_l2_distance(PG_FUNCTION_ARGS)
{ {
@@ -737,7 +737,7 @@ sparsevec_l2_distance(PG_FUNCTION_ARGS)
* Get the L2 squared distance between sparse vectors * Get the L2 squared distance between sparse vectors
* This saves a sqrt calculation * This saves a sqrt calculation
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_l2_squared_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_l2_squared_distance);
Datum Datum
sparsevec_l2_squared_distance(PG_FUNCTION_ARGS) sparsevec_l2_squared_distance(PG_FUNCTION_ARGS)
{ {
@@ -788,7 +788,7 @@ SparsevecInnerProduct(SparseVector * a, SparseVector * b)
/* /*
* Get the inner product of two sparse vectors * Get the inner product of two sparse vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_inner_product); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_inner_product);
Datum Datum
sparsevec_inner_product(PG_FUNCTION_ARGS) sparsevec_inner_product(PG_FUNCTION_ARGS)
{ {
@@ -803,7 +803,7 @@ sparsevec_inner_product(PG_FUNCTION_ARGS)
/* /*
* Get the negative inner product of two sparse vectors * Get the negative inner product of two sparse vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_negative_inner_product); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_negative_inner_product);
Datum Datum
sparsevec_negative_inner_product(PG_FUNCTION_ARGS) sparsevec_negative_inner_product(PG_FUNCTION_ARGS)
{ {
@@ -818,7 +818,7 @@ sparsevec_negative_inner_product(PG_FUNCTION_ARGS)
/* /*
* Get the cosine distance between two sparse vectors * Get the cosine distance between two sparse vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_cosine_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_cosine_distance);
Datum Datum
sparsevec_cosine_distance(PG_FUNCTION_ARGS) sparsevec_cosine_distance(PG_FUNCTION_ARGS)
{ {
@@ -863,7 +863,7 @@ sparsevec_cosine_distance(PG_FUNCTION_ARGS)
/* /*
* Get the L1 distance between two sparse vectors * Get the L1 distance between two sparse vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_l1_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_l1_distance);
Datum Datum
sparsevec_l1_distance(PG_FUNCTION_ARGS) sparsevec_l1_distance(PG_FUNCTION_ARGS)
{ {
@@ -912,7 +912,7 @@ sparsevec_l1_distance(PG_FUNCTION_ARGS)
/* /*
* Get the L2 norm of a sparse vector * Get the L2 norm of a sparse vector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_l2_norm); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_l2_norm);
Datum Datum
sparsevec_l2_norm(PG_FUNCTION_ARGS) sparsevec_l2_norm(PG_FUNCTION_ARGS)
{ {
@@ -930,7 +930,7 @@ sparsevec_l2_norm(PG_FUNCTION_ARGS)
/* /*
* Normalize a sparse vector with the L2 norm * Normalize a sparse vector with the L2 norm
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_l2_normalize); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_l2_normalize);
Datum Datum
sparsevec_l2_normalize(PG_FUNCTION_ARGS) sparsevec_l2_normalize(PG_FUNCTION_ARGS)
{ {
@@ -1040,7 +1040,7 @@ sparsevec_cmp_internal(SparseVector * a, SparseVector * b)
/* /*
* Less than * Less than
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_lt); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_lt);
Datum Datum
sparsevec_lt(PG_FUNCTION_ARGS) sparsevec_lt(PG_FUNCTION_ARGS)
{ {
@@ -1053,7 +1053,7 @@ sparsevec_lt(PG_FUNCTION_ARGS)
/* /*
* Less than or equal * Less than or equal
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_le); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_le);
Datum Datum
sparsevec_le(PG_FUNCTION_ARGS) sparsevec_le(PG_FUNCTION_ARGS)
{ {
@@ -1066,7 +1066,7 @@ sparsevec_le(PG_FUNCTION_ARGS)
/* /*
* Equal * Equal
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_eq); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_eq);
Datum Datum
sparsevec_eq(PG_FUNCTION_ARGS) sparsevec_eq(PG_FUNCTION_ARGS)
{ {
@@ -1079,7 +1079,7 @@ sparsevec_eq(PG_FUNCTION_ARGS)
/* /*
* Not equal * Not equal
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_ne); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_ne);
Datum Datum
sparsevec_ne(PG_FUNCTION_ARGS) sparsevec_ne(PG_FUNCTION_ARGS)
{ {
@@ -1092,7 +1092,7 @@ sparsevec_ne(PG_FUNCTION_ARGS)
/* /*
* Greater than or equal * Greater than or equal
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_ge); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_ge);
Datum Datum
sparsevec_ge(PG_FUNCTION_ARGS) sparsevec_ge(PG_FUNCTION_ARGS)
{ {
@@ -1105,7 +1105,7 @@ sparsevec_ge(PG_FUNCTION_ARGS)
/* /*
* Greater than * Greater than
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_gt); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_gt);
Datum Datum
sparsevec_gt(PG_FUNCTION_ARGS) sparsevec_gt(PG_FUNCTION_ARGS)
{ {
@@ -1118,7 +1118,7 @@ sparsevec_gt(PG_FUNCTION_ARGS)
/* /*
* Compare sparse vectors * Compare sparse vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_cmp); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_cmp);
Datum Datum
sparsevec_cmp(PG_FUNCTION_ARGS) sparsevec_cmp(PG_FUNCTION_ARGS)
{ {

View File

@@ -181,7 +181,7 @@ float_underflow_error(void)
/* /*
* Convert textual representation to internal representation * Convert textual representation to internal representation
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_in); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_in);
Datum Datum
vector_in(PG_FUNCTION_ARGS) vector_in(PG_FUNCTION_ARGS)
{ {
@@ -294,7 +294,7 @@ vector_in(PG_FUNCTION_ARGS)
/* /*
* Convert internal representation to textual representation * Convert internal representation to textual representation
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_out); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_out);
Datum Datum
vector_out(PG_FUNCTION_ARGS) vector_out(PG_FUNCTION_ARGS)
{ {
@@ -348,7 +348,7 @@ PrintVector(char *msg, Vector * vector)
/* /*
* Convert type modifier * Convert type modifier
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_typmod_in); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_typmod_in);
Datum Datum
vector_typmod_in(PG_FUNCTION_ARGS) vector_typmod_in(PG_FUNCTION_ARGS)
{ {
@@ -379,7 +379,7 @@ vector_typmod_in(PG_FUNCTION_ARGS)
/* /*
* Convert external binary representation to internal representation * Convert external binary representation to internal representation
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_recv); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_recv);
Datum Datum
vector_recv(PG_FUNCTION_ARGS) vector_recv(PG_FUNCTION_ARGS)
{ {
@@ -413,7 +413,7 @@ vector_recv(PG_FUNCTION_ARGS)
/* /*
* Convert internal representation to the external binary representation * Convert internal representation to the external binary representation
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_send); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_send);
Datum Datum
vector_send(PG_FUNCTION_ARGS) vector_send(PG_FUNCTION_ARGS)
{ {
@@ -433,7 +433,7 @@ vector_send(PG_FUNCTION_ARGS)
* Convert vector to vector * Convert vector to vector
* This is needed to check the type modifier * This is needed to check the type modifier
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector);
Datum Datum
vector(PG_FUNCTION_ARGS) vector(PG_FUNCTION_ARGS)
{ {
@@ -448,7 +448,7 @@ vector(PG_FUNCTION_ARGS)
/* /*
* Convert array to vector * Convert array to vector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(array_to_vector); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(array_to_vector);
Datum Datum
array_to_vector(PG_FUNCTION_ARGS) array_to_vector(PG_FUNCTION_ARGS)
{ {
@@ -522,7 +522,7 @@ array_to_vector(PG_FUNCTION_ARGS)
/* /*
* Convert vector to float4[] * Convert vector to float4[]
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_to_float4); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_to_float4);
Datum Datum
vector_to_float4(PG_FUNCTION_ARGS) vector_to_float4(PG_FUNCTION_ARGS)
{ {
@@ -546,7 +546,7 @@ vector_to_float4(PG_FUNCTION_ARGS)
/* /*
* Convert half vector to vector * Convert half vector to vector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(halfvec_to_vector); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(halfvec_to_vector);
Datum Datum
halfvec_to_vector(PG_FUNCTION_ARGS) halfvec_to_vector(PG_FUNCTION_ARGS)
{ {
@@ -584,7 +584,7 @@ VectorL2SquaredDistance(int dim, float *ax, float *bx)
/* /*
* Get the L2 distance between vectors * Get the L2 distance between vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(l2_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(l2_distance);
Datum Datum
l2_distance(PG_FUNCTION_ARGS) l2_distance(PG_FUNCTION_ARGS)
{ {
@@ -600,7 +600,7 @@ l2_distance(PG_FUNCTION_ARGS)
* Get the L2 squared distance between vectors * Get the L2 squared distance between vectors
* This saves a sqrt calculation * This saves a sqrt calculation
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_l2_squared_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_l2_squared_distance);
Datum Datum
vector_l2_squared_distance(PG_FUNCTION_ARGS) vector_l2_squared_distance(PG_FUNCTION_ARGS)
{ {
@@ -627,7 +627,7 @@ VectorInnerProduct(int dim, float *ax, float *bx)
/* /*
* Get the inner product of two vectors * Get the inner product of two vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(inner_product); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(inner_product);
Datum Datum
inner_product(PG_FUNCTION_ARGS) inner_product(PG_FUNCTION_ARGS)
{ {
@@ -642,7 +642,7 @@ inner_product(PG_FUNCTION_ARGS)
/* /*
* Get the negative inner product of two vectors * Get the negative inner product of two vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_negative_inner_product); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_negative_inner_product);
Datum Datum
vector_negative_inner_product(PG_FUNCTION_ARGS) vector_negative_inner_product(PG_FUNCTION_ARGS)
{ {
@@ -676,7 +676,7 @@ VectorCosineSimilarity(int dim, float *ax, float *bx)
/* /*
* Get the cosine distance between two vectors * Get the cosine distance between two vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(cosine_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(cosine_distance);
Datum Datum
cosine_distance(PG_FUNCTION_ARGS) cosine_distance(PG_FUNCTION_ARGS)
{ {
@@ -708,7 +708,7 @@ cosine_distance(PG_FUNCTION_ARGS)
* Currently uses angular distance since needs to satisfy triangle inequality * Currently uses angular distance since needs to satisfy triangle inequality
* Assumes inputs are unit vectors (skips norm) * Assumes inputs are unit vectors (skips norm)
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_spherical_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_spherical_distance);
Datum Datum
vector_spherical_distance(PG_FUNCTION_ARGS) vector_spherical_distance(PG_FUNCTION_ARGS)
{ {
@@ -745,7 +745,7 @@ VectorL1Distance(int dim, float *ax, float *bx)
/* /*
* Get the L1 distance between two vectors * Get the L1 distance between two vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(l1_distance); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(l1_distance);
Datum Datum
l1_distance(PG_FUNCTION_ARGS) l1_distance(PG_FUNCTION_ARGS)
{ {
@@ -760,7 +760,7 @@ l1_distance(PG_FUNCTION_ARGS)
/* /*
* Get the dimensions of a vector * Get the dimensions of a vector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_dims); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_dims);
Datum Datum
vector_dims(PG_FUNCTION_ARGS) vector_dims(PG_FUNCTION_ARGS)
{ {
@@ -772,7 +772,7 @@ vector_dims(PG_FUNCTION_ARGS)
/* /*
* Get the L2 norm of a vector * Get the L2 norm of a vector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_norm); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_norm);
Datum Datum
vector_norm(PG_FUNCTION_ARGS) vector_norm(PG_FUNCTION_ARGS)
{ {
@@ -790,7 +790,7 @@ vector_norm(PG_FUNCTION_ARGS)
/* /*
* Normalize a vector with the L2 norm * Normalize a vector with the L2 norm
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(l2_normalize); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(l2_normalize);
Datum Datum
l2_normalize(PG_FUNCTION_ARGS) l2_normalize(PG_FUNCTION_ARGS)
{ {
@@ -829,7 +829,7 @@ l2_normalize(PG_FUNCTION_ARGS)
/* /*
* Add vectors * Add vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_add); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_add);
Datum Datum
vector_add(PG_FUNCTION_ARGS) vector_add(PG_FUNCTION_ARGS)
{ {
@@ -862,7 +862,7 @@ vector_add(PG_FUNCTION_ARGS)
/* /*
* Subtract vectors * Subtract vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_sub); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_sub);
Datum Datum
vector_sub(PG_FUNCTION_ARGS) vector_sub(PG_FUNCTION_ARGS)
{ {
@@ -895,7 +895,7 @@ vector_sub(PG_FUNCTION_ARGS)
/* /*
* Multiply vectors * Multiply vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_mul); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_mul);
Datum Datum
vector_mul(PG_FUNCTION_ARGS) vector_mul(PG_FUNCTION_ARGS)
{ {
@@ -931,7 +931,7 @@ vector_mul(PG_FUNCTION_ARGS)
/* /*
* Concatenate vectors * Concatenate vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_concat); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_concat);
Datum Datum
vector_concat(PG_FUNCTION_ARGS) vector_concat(PG_FUNCTION_ARGS)
{ {
@@ -955,7 +955,7 @@ vector_concat(PG_FUNCTION_ARGS)
/* /*
* Quantize a vector * Quantize a vector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(binary_quantize); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(binary_quantize);
Datum Datum
binary_quantize(PG_FUNCTION_ARGS) binary_quantize(PG_FUNCTION_ARGS)
{ {
@@ -973,7 +973,7 @@ binary_quantize(PG_FUNCTION_ARGS)
/* /*
* Get a subvector * Get a subvector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(subvector); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(subvector);
Datum Datum
subvector(PG_FUNCTION_ARGS) subvector(PG_FUNCTION_ARGS)
{ {
@@ -1047,7 +1047,7 @@ vector_cmp_internal(Vector * a, Vector * b)
/* /*
* Less than * Less than
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_lt); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_lt);
Datum Datum
vector_lt(PG_FUNCTION_ARGS) vector_lt(PG_FUNCTION_ARGS)
{ {
@@ -1060,7 +1060,7 @@ vector_lt(PG_FUNCTION_ARGS)
/* /*
* Less than or equal * Less than or equal
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_le); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_le);
Datum Datum
vector_le(PG_FUNCTION_ARGS) vector_le(PG_FUNCTION_ARGS)
{ {
@@ -1073,7 +1073,7 @@ vector_le(PG_FUNCTION_ARGS)
/* /*
* Equal * Equal
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_eq); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_eq);
Datum Datum
vector_eq(PG_FUNCTION_ARGS) vector_eq(PG_FUNCTION_ARGS)
{ {
@@ -1086,7 +1086,7 @@ vector_eq(PG_FUNCTION_ARGS)
/* /*
* Not equal * Not equal
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_ne); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_ne);
Datum Datum
vector_ne(PG_FUNCTION_ARGS) vector_ne(PG_FUNCTION_ARGS)
{ {
@@ -1099,7 +1099,7 @@ vector_ne(PG_FUNCTION_ARGS)
/* /*
* Greater than or equal * Greater than or equal
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_ge); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_ge);
Datum Datum
vector_ge(PG_FUNCTION_ARGS) vector_ge(PG_FUNCTION_ARGS)
{ {
@@ -1112,7 +1112,7 @@ vector_ge(PG_FUNCTION_ARGS)
/* /*
* Greater than * Greater than
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_gt); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_gt);
Datum Datum
vector_gt(PG_FUNCTION_ARGS) vector_gt(PG_FUNCTION_ARGS)
{ {
@@ -1125,7 +1125,7 @@ vector_gt(PG_FUNCTION_ARGS)
/* /*
* Compare vectors * Compare vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_cmp); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_cmp);
Datum Datum
vector_cmp(PG_FUNCTION_ARGS) vector_cmp(PG_FUNCTION_ARGS)
{ {
@@ -1138,7 +1138,7 @@ vector_cmp(PG_FUNCTION_ARGS)
/* /*
* Accumulate vectors * Accumulate vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_accum); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_accum);
Datum Datum
vector_accum(PG_FUNCTION_ARGS) vector_accum(PG_FUNCTION_ARGS)
{ {
@@ -1199,7 +1199,7 @@ vector_accum(PG_FUNCTION_ARGS)
/* /*
* Combine vectors or half vectors (also used for halfvec_combine) * Combine vectors or half vectors (also used for halfvec_combine)
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_combine); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_combine);
Datum Datum
vector_combine(PG_FUNCTION_ARGS) vector_combine(PG_FUNCTION_ARGS)
{ {
@@ -1270,7 +1270,7 @@ vector_combine(PG_FUNCTION_ARGS)
/* /*
* Average vectors * Average vectors
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(vector_avg); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(vector_avg);
Datum Datum
vector_avg(PG_FUNCTION_ARGS) vector_avg(PG_FUNCTION_ARGS)
{ {
@@ -1304,7 +1304,7 @@ vector_avg(PG_FUNCTION_ARGS)
/* /*
* Convert sparse vector to dense vector * Convert sparse vector to dense vector
*/ */
PGDLLEXPORT PG_FUNCTION_INFO_V1(sparsevec_to_vector); FUNCTION_PREFIX PG_FUNCTION_INFO_V1(sparsevec_to_vector);
Datum Datum
sparsevec_to_vector(PG_FUNCTION_ARGS) sparsevec_to_vector(PG_FUNCTION_ARGS)
{ {

View File

@@ -20,4 +20,11 @@ Vector *InitVector(int dim);
void PrintVector(char *msg, Vector * vector); void PrintVector(char *msg, Vector * vector);
int vector_cmp_internal(Vector * a, Vector * b); int vector_cmp_internal(Vector * a, Vector * b);
/* TODO Move to better place */
#if PG_VERSION_NUM >= 160000
#define FUNCTION_PREFIX
#else
#define FUNCTION_PREFIX PGDLLEXPORT
#endif
#endif #endif