pgvector.git / summary / log / commit / refs

commit    bf28ed8176cd19edbe30f7ccbc25fa299a8b0298
Author:   Andrew Kane <andrew@ankane.org>
Date:     Wed Jun 18 17:57:18 2025 +0000

    Set random seed for IVFFLAT_BENCH [skip ci]


src/ivfbuild.c | 4 ++++ src/ivfflat.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/ivfbuild.c b/src/ivfbuild.c index 944f07b5..c51f4088 100644 --- a/src/ivfbuild.c +++ b/src/ivfbuild.c @@ -1023,6 +1023,10 @@ ivfflatbuild(Relation heap, Relation index, IndexInfo *indexInfo) IndexBuildResult *result; IvfflatBuildState buildstate; +#ifdef IVFFLAT_BENCH + SeedRandom(42); +#endif + BuildIndex(heap, index, indexInfo, &buildstate, MAIN_FORKNUM); result = (IndexBuildResult *) palloc(sizeof(IndexBuildResult)); diff --git a/src/ivfflat.h b/src/ivfflat.h index c296b667..76608f33 100644 --- a/src/ivfflat.h +++ b/src/ivfflat.h @@ -73,9 +73,11 @@ #if PG_VERSION_NUM >= 150000 #define RandomDouble() pg_prng_double(&pg_global_prng_state) #define RandomInt() pg_prng_uint32(&pg_global_prng_state) +#define SeedRandom(seed) pg_prng_seed(&pg_global_prng_state, seed) #else #define RandomDouble() (((double) random()) / MAX_RANDOM_VALUE) #define RandomInt() random() +#define SeedRandom(seed) srandom(seed) #endif /* Variables */ [parent: 799cfebf7047]