diff --git a/src/hnsw.c b/src/hnsw.c index e1c568506..d6128f107 100644 --- a/src/hnsw.c +++ b/src/hnsw.c @@ -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 { @@ -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 { diff --git a/src/hnsw.h b/src/hnsw.h index 892cf9dae..d2566bbff 100644 --- a/src/hnsw.h +++ b/src/hnsw.h @@ -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) diff --git a/src/hnsw/build.c b/src/hnsw/build.c index 39a5005d3..5774f9202 100644 --- a/src/hnsw/build.c +++ b/src/hnsw/build.c @@ -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: diff --git a/src/hnsw/scan.c b/src/hnsw/scan.c index 6c2efe8a4..175b0063c 100644 --- a/src/hnsw/scan.c +++ b/src/hnsw/scan.c @@ -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; @@ -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);