pgvector.git / summary / log / commit / refs
commit 206c42e17063eb6a107bbfa229e6d43c8398d869
Author: Andrew Kane <andrew@ankane.org>
Date: Sat Aug 19 08:22:28 2023 +0000
Cleaned up header
src/vector.c | 22 ++++++++++++++++++++++
src/vector.h | 27 +--------------------------
2 files changed, 23 insertions(+), 26 deletions(-)
diff --git a/src/vector.c b/src/vector.c
index 8a2fa54f..aae909a5 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -15,6 +15,10 @@
#include "utils/numeric.h"
#include "vector.h"
+#if PG_VERSION_NUM >= 160000
+#include "varatt.h"
+#endif
+
#if PG_VERSION_NUM >= 120000
#include "common/shortest_dec.h"
#include "utils/float.h"
@@ -35,6 +39,7 @@ PG_MODULE_MAGIC;
/*
* Initialize index options and variables
*/
+PGDLLEXPORT void _PG_init(void);
void
_PG_init(void)
{
@@ -100,6 +105,23 @@ CheckElement(float value)
errmsg("infinite value not allowed in vector")));
}
+/*
+ * Allocate and initialize a new vector
+ */
+Vector *
+InitVector(int dim)
+{
+ Vector *result;
+ int size;
+
+ size = VECTOR_SIZE(dim);
+ result = (Vector *) palloc0(size);
+ SET_VARSIZE(result, size);
+ result->dim = dim;
+
+ return result;
+}
+
/*
* Check for whitespace, since array_isspace() is static
*/
diff --git a/src/vector.h b/src/vector.h
index 292be981..e649471e 100644
--- a/src/vector.h
+++ b/src/vector.h
@@ -1,12 +1,6 @@
#ifndef VECTOR_H
#define VECTOR_H
-#include "postgres.h"
-
-#if PG_VERSION_NUM >= 160000
-#include "varatt.h"
-#endif
-
#define VECTOR_MAX_DIM 16000
#define VECTOR_SIZE(_dim) (offsetof(Vector, x) + sizeof(float)*(_dim))
@@ -14,9 +8,6 @@
#define PG_GETARG_VECTOR_P(x) DatumGetVector(PG_GETARG_DATUM(x))
#define PG_RETURN_VECTOR_P(x) PG_RETURN_POINTER(x)
-/* Exported functions */
-PGDLLEXPORT void _PG_init(void);
-
typedef struct Vector
{
int32 vl_len_; /* varlena header (do not touch directly!) */
@@ -25,24 +16,8 @@ typedef struct Vector
float x[FLEXIBLE_ARRAY_MEMBER];
} Vector;
+Vector *InitVector(int dim);
void PrintVector(char *msg, Vector * vector);
int vector_cmp_internal(Vector * a, Vector * b);
-/*
- * Allocate and initialize a new vector
- */
-static inline Vector *
-InitVector(int dim)
-{
- Vector *result;
- int size;
-
- size = VECTOR_SIZE(dim);
- result = (Vector *) palloc0(size);
- SET_VARSIZE(result, size);
- result->dim = dim;
-
- return result;
-}
-
#endif
[parent: 4f8d824280cc]