Skip to content

Commit

Permalink
Fix Vector Headers
Browse files Browse the repository at this point in the history
Old dev box allowed for some wild linking. Need to cleanup the vector.h
file to allow for work on other machines.
  • Loading branch information
JoshInnis committed Jun 7, 2024
1 parent 63c4e5d commit 1589b96
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/backend/utils/adt/gtype_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include "utils/gtype.h"
#include "utils/gtype_typecasting.h"
#include "utils/vector.h"

static void ereport_op_str(const char *op, gtype *lhs, gtype *rhs);
static gtype *gtype_concat(gtype *agt1, gtype *agt2);
Expand Down
9 changes: 6 additions & 3 deletions src/backend/utils/adt/gtype_typecasting.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
// PostGraph
#include "utils/gtype.h"
#include "utils/gtype_typecasting.h"
#include "utils/vector.h"

#define int8_to_int4 int84
#define int8_to_int2 int82
Expand Down Expand Up @@ -413,11 +414,13 @@ Datum tovector(PG_FUNCTION_ARGS)
if (gtv->type != AGTV_STRING)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("typecastint to vector must be a string")));
errmsg("typecasting to vector must be a string")));

gtv = gtype_vector_in(gtv->val.string.val, -1);
gtype_value *result = gtype_vector_in(gtv->val.string.val, -1);
//PG_RETURN_POINTER(result);
Assert(result->type == AGTV_VECTOR);

PG_RETURN_POINTER(gtype_value_to_gtype(gtv));
PG_RETURN_POINTER(gtype_value_to_gtype(result));
}

Datum _gtype_toinet(Datum arg){
Expand Down
4 changes: 3 additions & 1 deletion src/include/access/ivfflat.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "port.h" /* for random() */
#include "utils/sampling.h"
#include "utils/tuplesort.h"
//#include "utils/vector.h"
#include "utils/vector.h"
#include "utils/gtype.h"
#if PG_VERSION_NUM >= 150000
#include "common/pg_prng.h"
Expand All @@ -28,6 +28,8 @@
#include "portability/instr_time.h"
#endif



#define IVFFLAT_MAX_DIM 2000

/* Support functions */
Expand Down
9 changes: 8 additions & 1 deletion src/include/utils/gtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@
#include "catalog/ag_namespace.h"
#include "catalog/pg_type.h"
#include "utils/graphid.h"
#include "utils/vector.h"
//#include "utils/vector.h"

typedef struct Vector
{
uint16 dim; // number of dimensions
float8 *x;
} Vector;


/* Tokens used when sequentially processing an gtype value */
typedef enum
Expand Down
13 changes: 8 additions & 5 deletions src/include/utils/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@

#define VECTOR_SIZE(_dim) (sizeof(uint32) + sizeof(uint32) + (_dim * sizeof(float8)) + sizeof(uint32))
#define DatumGetVector(x) ((Vector *) PG_DETOAST_DATUM(x))

/*
typedef struct Vector
{
uint16 dim; /* number of dimensions */
uint16 dim; // number of dimensions
float8 *x;
} Vector;

//gtype_value *gtype_vector_in(char *str, int32 typmod);
//gtype_value *InitVectorGType(int dim);
*/
gtype_value *gtype_vector_in(char *str, int32 typmod);
gtype_value *InitVectorGType(int dim);
gtype_value *gtype_vector_add(gtype *lhs, gtype *rhs);
gtype_value *gtype_vector_sub(gtype *lhs, gtype *rhs);
gtype_value *gtype_vector_mul(gtype *lhs, gtype *rhs);

static inline Vector *
InitVector(int dim)
Expand Down

0 comments on commit 1589b96

Please sign in to comment.