Skip to content

Commit

Permalink
formatted with clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
therealdarkknight committed Oct 10, 2023
1 parent 3dba819 commit 5054cf9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/hnsw.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,15 @@ static float4 array_dist(ArrayType *a, ArrayType *b, usearch_metric_kind_t metri
}

float4 result;
bool is_int_array = (metric_kind == usearch_metric_hamming_k);
bool is_int_array = (metric_kind == usearch_metric_hamming_k);

if(is_int_array) {
int32 *ax_int = (int32 *)ARR_DATA_PTR(a);
int32 *bx_int = (int32 *)ARR_DATA_PTR(b);

// calling usearch_scalar_f32_k here even though it's an integer array is fine
// the hamming distance in usearch actually ignores the scalar type
// and it will get casted appropriately in usearch even with this scalar type
// calling usearch_scalar_f32_k here even though it's an integer array is fine
// the hamming distance in usearch actually ignores the scalar type
// and it will get casted appropriately in usearch even with this scalar type
result = usearch_dist(ax_int, bx_int, metric_kind, a_dim, usearch_scalar_f32_k);

} else {
Expand Down Expand Up @@ -402,7 +402,7 @@ void *DatumGetSizedArray(Datum datum, HnswColumnType type, int dimensions)
if(array_dim != dimensions) {
elog(ERROR, "Expected int array with dimension %d, got %d", dimensions, array_dim);
}

int32 *intArray = (int32 *)ARR_DATA_PTR(array);
return (void *)intArray;
} else {
Expand Down
5 changes: 1 addition & 4 deletions src/hnsw.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ PGDLLEXPORT Datum hamming_dist(PG_FUNCTION_ARGS);
PGDLLEXPORT Datum cos_dist(PG_FUNCTION_ARGS);

HnswColumnType GetIndexColumnType(Relation index);
void *DatumGetSizedArray(Datum datum, HnswColumnType type, int dimensions);



void *DatumGetSizedArray(Datum datum, HnswColumnType type, int dimensions);

#define LDB_UNUSED(x) (void)(x)

Expand Down
2 changes: 1 addition & 1 deletion src/hnsw/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static void AddTupleToUsearchIndex(ItemPointer tid, Datum *values, HnswBuildStat
Datum value = PointerGetDatum(PG_DETOAST_DATUM(values[ 0 ]));
usearch_scalar_kind_t usearch_scalar;

void *vector = DatumGetSizedArray(value, buildstate->columnType, buildstate->dimensions);
void *vector = DatumGetSizedArray(value, buildstate->columnType, buildstate->dimensions);
switch(buildstate->columnType) {
case REAL_ARRAY:
case VECTOR:
Expand Down
4 changes: 2 additions & 2 deletions src/hnsw/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ bool ldb_amgettuple(IndexScanDesc scan, ScanDirection dir)
if(scanstate->first) {
int num_returned;
Datum value;
void *vec;
void *vec;
usearch_error_t error = NULL;
int k = ldb_hnsw_init_k;

Expand Down Expand Up @@ -209,7 +209,7 @@ bool ldb_amgettuple(IndexScanDesc scan, ScanDirection dir)
if(scanstate->current == scanstate->count) {
int num_returned;
Datum value;
void *vec;
void *vec;
usearch_error_t error = NULL;
int k = scanstate->count * 2;
int index_size = usearch_size(scanstate->usearch_index, &error);
Expand Down

0 comments on commit 5054cf9

Please sign in to comment.