Removed random macros [skip ci]

This commit is contained in:
Andrew Kane committed 2026-11-13 21:21:13 -08:00
1 parent 28dbea6e64
commit 10a73eceef
6 files changed
+8 -15

No files matched your search

-3
View File
@@ -112,9 +112,6 @@ typedef Pointer Item;
#define HnswBench(name, code) (code)
#endif
#define RandomDouble() pg_prng_double(&pg_global_prng_state)
#define SeedRandom(seed) pg_prng_seed(&pg_global_prng_state, seed)
#if PG_VERSION_NUM >= 190000
#define palloc_array_checked(type, count) palloc_array(type, count)
#else
+1 -1
View File
@@ -1143,7 +1143,7 @@ BuildIndex(Relation heap, Relation index, IndexInfo *indexInfo,
HnswBuildState * buildstate, ForkNumber forkNum)
{
#ifdef HNSW_MEMORY
SeedRandom(42);
pg_prng_seed(&pg_global_prng_state, 42);
#endif
InitBuildState(buildstate, heap, index, indexInfo, forkNum);
+1 -1
View File
@@ -258,7 +258,7 @@ HnswInitElement(char *base, ItemPointer heaptid, int m, double ml, int maxLevel,
{
HnswElement element = HnswAlloc(allocator, sizeof(HnswElementData));
double uniform = RandomDouble();
double uniform = pg_prng_double(&pg_global_prng_state);
int level = uniform == 0.0 ? maxLevel : (int) (-log(uniform) * ml);
/* Cap level */
+2 -2
View File
@@ -126,7 +126,7 @@ SampleRows(IvfflatBuildState * buildstate)
buildstate->samplerows = 0;
buildstate->rowstoskip = -1;
BlockSampler_Init(&buildstate->bs, totalblocks, targsamples, RandomInt());
BlockSampler_Init(&buildstate->bs, totalblocks, targsamples, pg_prng_uint32(&pg_global_prng_state));
reservoir_init_selection_state(&buildstate->rstate, targsamples);
while (BlockSampler_HasMore(&buildstate->bs))
@@ -1058,7 +1058,7 @@ ivfflatbuild(Relation heap, Relation index, IndexInfo *indexInfo)
IvfflatBuildState buildstate;
#ifdef IVFFLAT_BENCH
SeedRandom(42);
pg_prng_seed(&pg_global_prng_state, 42);
#endif
BuildIndex(heap, index, indexInfo, &buildstate, MAIN_FORKNUM);
-4
View File
@@ -89,10 +89,6 @@ typedef Pointer Item;
#define IvfflatBench(name, code) (code)
#endif
#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)
#if PG_VERSION_NUM >= 190000
#define palloc_array_checked(type, count) palloc_array(type, count)
#define palloc0_array_checked(type, count) palloc0_array(type, count)
+4 -4
View File
@@ -33,7 +33,7 @@ InitCenters(Relation index, VectorArray samples, VectorArray centers, float *low
collation = index->rd_indcollation[0];
/* Choose an initial center uniformly at random */
VectorArrayAdd(centers, VectorArrayGet(samples, RandomInt() % samples->length));
VectorArrayAdd(centers, VectorArrayGet(samples, pg_prng_uint32(&pg_global_prng_state) % samples->length));
for (int i = 0; i < numSamples; i++)
weight[i] = FLT_MAX;
@@ -74,7 +74,7 @@ InitCenters(Relation index, VectorArray samples, VectorArray centers, float *low
break;
/* Choose new center using weighted probability distribution. */
choice = sum * RandomDouble();
choice = sum * pg_prng_double(&pg_global_prng_state);
for (j = 0; j < numSamples - 1; j++)
{
choice -= weight[j];
@@ -118,7 +118,7 @@ RandomCenters(Relation index, VectorArray centers, int dimensions, const Ivfflat
Pointer center = VectorArrayGet(centers, centers->length++);
for (int i = 0; i < dimensions; i++)
x[i] = (float) RandomDouble();
x[i] = (float) pg_prng_double(&pg_global_prng_state);
typeInfo->updateCenter(center, dimensions, x);
}
@@ -192,7 +192,7 @@ ComputeNewCenters(VectorArray samples, int dimensions, float *agg, VectorArray n
{
/* TODO Handle empty centers properly */
for (int j = 0; j < dimensions; j++)
x[j] = RandomDouble();
x[j] = pg_prng_double(&pg_global_prng_state);
}
typeInfo->updateCenter(VectorArrayGet(newCenters, i), dimensions, x);