pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] PR #873: housekeeping: improve ax and bx args by making them constants
3+ messages / 2 participants
[nested] [flat]

* [pgvector/pgvector] PR #873: housekeeping: improve ax and bx args by making them constants
@ 2025-07-09 12:55 "fractalliter (@fractalliter)" <noreply+fractalliter@github.com>
  0 siblings, 0 replies; 3+ messages in thread

From: fractalliter (@fractalliter) @ 2025-07-09 12:55 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

# Description

I am getting onboarded on this project and had a quick look at the bit utils file and thought to change the ax and bx reference parameters to a const.

It's a housekeeping PR anyways.

inline patch 1: src/bitutils.c, src/bitutils.h (+8/-8 lines) download inline-1.patchdiff --git a/src/bitutils.c b/src/bitutils.c index 578bcad1d..76cb795e6 100644 --- a/src/bitutils.c +++ b/src/bitutils.c @@ -41,11 +41,11 @@ #define popcount64(x) pg_popcount64(x) #endif -uint64 (*BitHammingDistance) (uint32 bytes, unsigned char *ax, unsigned char *bx, uint64 distance); -double (*BitJaccardDistance) (uint32 bytes, unsigned char *ax, unsigned char *bx, uint64 ab, uint64 aa, uint64 bb); +uint64 (*BitHammingDistance) (uint32 bytes, const unsigned char *ax, const unsigned char *bx, uint64 distance); +double (*BitJaccardDistance) (uint32 bytes, const unsigned char *ax, const unsigned char *bx, uint64 ab, uint64 aa, uint64 bb); BIT_TARGET_CLONES static uint64 -BitHammingDistanceDefault(uint32 bytes, unsigned char *ax, unsigned char *bx, uint64 distance) +BitHammingDistanceDefault(uint32 bytes, const unsigned char *ax, const unsigned char *bx, uint64 distance) { #ifdef popcount64 for (; bytes >= sizeof(uint64); bytes -= sizeof(uint64)) @@ -72,7 +72,7 @@ BitHammingDistanceDefault(uint32 bytes, unsigned char *ax, unsigned char *bx, ui #ifdef BIT_DISPATCH TARGET_AVX512_POPCOUNT static uint64 -BitHammingDistanceAvx512Popcount(uint32 bytes, unsigned char *ax, unsigned char *bx, uint64 distance) +BitHammingDistanceAvx512Popcount(uint32 bytes, const unsigned char *ax, const unsigned char *bx, uint64 distance) { __m512i dist = _mm512_setzero_si512(); @@ -94,7 +94,7 @@ BitHammingDistanceAvx512Popcount(uint32 bytes, unsigned char *ax, unsigned char #endif BIT_TARGET_CLONES static double -BitJaccardDistanceDefault(uint32 bytes, unsigned char *ax, unsigned char *bx, uint64 ab, uint64 aa, uint64 bb) +BitJaccardDistanceDefault(uint32 bytes, const unsigned char *ax, const unsigned char *bx, uint64 ab, uint64 aa, uint64 bb) { #ifdef popcount64 for (; bytes >= sizeof(uint64); bytes -= sizeof(uint64)) @@ -130,7 +130,7 @@ BitJaccardDistanceDefault(uint32 bytes, unsigned char *ax, unsigned char *bx, ui #ifdef BIT_DISPATCH TARGET_AVX512_POPCOUNT static double -BitJaccardDistanceAvx512Popcount(uint32 bytes, unsigned char *ax, unsigned char *bx, uint64 ab, uint64 aa, uint64 bb) +BitJaccardDistanceAvx512Popcount(uint32 bytes, const unsigned char *ax, const unsigned char *bx, uint64 ab, uint64 aa, uint64 bb) { __m512i abx = _mm512_setzero_si512(); __m512i aax = _mm512_setzero_si512(); diff --git a/src/bitutils.h b/src/bitutils.h index b4d85bb1c..f7b13c49c 100644 --- a/src/bitutils.h +++ b/src/bitutils.h @@ -8,8 +8,8 @@ #error "Requires PostgreSQL 13+" #endif -extern uint64 (*BitHammingDistance) (uint32 bytes, unsigned char *ax, unsigned char *bx, uint64 distance); -extern double (*BitJaccardDistance) (uint32 bytes, unsigned char *ax, unsigned char *bx, uint64 ab, uint64 aa, uint64 bb); +extern uint64 (*BitHammingDistance) (uint32 bytes, const unsigned char *ax, const unsigned char *bx, uint64 distance); +extern double (*BitJaccardDistance) (uint32 bytes, const unsigned char *ax, const unsigned char *bx, uint64 ab, uint64 aa, uint64 bb); void BitvecInit(void);
^ permalink raw [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] PR #873: housekeeping: improve ax and bx args by making them constants
@ 2025-07-09 13:11 ` "ankane (@ankane)" <noreply+ankane@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: ankane (@ankane) @ 2025-07-09 13:11 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi @fractalliter, thanks for the PR, but this isn't something I'd like to change (as it isn't needed).

^ permalink  raw  [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] PR #873: housekeeping: improve ax and bx args by making them constants
@ 2025-07-09 13:11 ` "ankane (@ankane)" <noreply+ankane@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: ankane (@ankane) @ 2025-07-09 13:11 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane closed this.

^ permalink  raw  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2025-07-09 13:11 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-07-09 12:55 [pgvector/pgvector] PR #873: housekeeping: improve ax and bx args by making them constants "fractalliter (@fractalliter)" <noreply+fractalliter@github.com>
2025-07-09 13:11 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-07-09 13:11 ` "ankane (@ankane)" <noreply+ankane@github.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox