mirror of
https://github.com/pgvector/pgvector.git
synced 2026-12-04 00:08:30 +00:00
Improved random_sparsevec subroutine [skip ci]
This commit is contained in:
1 parent
3cb6da44fa
commit
aced364bb2
1 file changed
+3
-2
@@ -16,9 +16,10 @@ $node->safe_psql("postgres", "CREATE INDEX ON tst USING hnsw (v sparsevec_l2_ops
|
||||
|
||||
sub random_sparsevec
|
||||
{
|
||||
my ($nnz) = @_;
|
||||
my @elements;
|
||||
my %indices;
|
||||
for (1 .. int(rand(1001)))
|
||||
while (keys %indices < $nnz)
|
||||
{
|
||||
my $index = int(rand(100000)) + 1;
|
||||
if (!exists($indices{$index}))
|
||||
@@ -37,7 +38,7 @@ for (1 .. 3)
|
||||
{
|
||||
for (1 .. 100)
|
||||
{
|
||||
my $embedding = random_sparsevec();
|
||||
my $embedding = random_sparsevec(int(rand(1001)));
|
||||
$node->safe_psql("postgres", "INSERT INTO tst (v) VALUES ('$embedding');");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user