mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-02 02:31:16 +08:00
Use consistent style in TAP tests [skip ci]
This commit is contained in:
@@ -26,7 +26,8 @@ sub test_index_replay
|
||||
or die "Timed out while waiting for replica 1 to catch up";
|
||||
|
||||
my @r = ();
|
||||
for (1 .. $dim) {
|
||||
for (1 .. $dim)
|
||||
{
|
||||
push(@r, rand());
|
||||
}
|
||||
my $sql = join(",", @r);
|
||||
@@ -67,8 +68,7 @@ $node_primary->backup($backup_name);
|
||||
|
||||
# Create streaming replica linking to primary
|
||||
$node_replica = get_new_node('replica');
|
||||
$node_replica->init_from_backup($node_primary, $backup_name,
|
||||
has_streaming => 1);
|
||||
$node_replica->init_from_backup($node_primary, $backup_name, has_streaming => 1);
|
||||
$node_replica->start;
|
||||
|
||||
# Create ivfflat index on primary
|
||||
|
||||
@@ -7,7 +7,8 @@ use Test::More;
|
||||
my $dim = 3;
|
||||
|
||||
my @r = ();
|
||||
for (1 .. $dim) {
|
||||
for (1 .. $dim)
|
||||
{
|
||||
my $v = int(rand(1000)) + 1;
|
||||
push(@r, "i % $v");
|
||||
}
|
||||
|
||||
@@ -57,7 +57,8 @@ $node->safe_psql("postgres",
|
||||
);
|
||||
|
||||
# Generate queries
|
||||
for (1..20) {
|
||||
for (1 .. 20)
|
||||
{
|
||||
my $r1 = rand();
|
||||
my $r2 = rand();
|
||||
my $r3 = rand();
|
||||
@@ -67,7 +68,8 @@ for (1..20) {
|
||||
# Check each index type
|
||||
my @operators = ("<->", "<#>", "<=>");
|
||||
|
||||
foreach (@operators) {
|
||||
foreach (@operators)
|
||||
{
|
||||
my $operator = $_;
|
||||
|
||||
# Get exact results
|
||||
@@ -93,7 +95,8 @@ foreach (@operators) {
|
||||
));
|
||||
|
||||
# Test approximate results
|
||||
if ($operator ne "<#>") {
|
||||
if ($operator ne "<#>")
|
||||
{
|
||||
# TODO fix test
|
||||
test_recall(1, 0.73, $operator);
|
||||
test_recall(10, 0.95, $operator);
|
||||
@@ -113,7 +116,8 @@ foreach (@operators) {
|
||||
like($stderr, qr/using \d+ parallel workers/);
|
||||
|
||||
# Test approximate results
|
||||
if ($operator ne "<#>") {
|
||||
if ($operator ne "<#>")
|
||||
{
|
||||
# TODO fix test
|
||||
test_recall(1, 0.73, $operator);
|
||||
test_recall(10, 0.95, $operator);
|
||||
|
||||
@@ -18,7 +18,8 @@ $node->safe_psql("postgres",
|
||||
|
||||
# Check each index type
|
||||
my @operators = ("<->", "<#>", "<=>");
|
||||
foreach (@operators) {
|
||||
foreach (@operators)
|
||||
{
|
||||
my $operator = $_;
|
||||
|
||||
# Add index
|
||||
@@ -33,7 +34,8 @@ foreach (@operators) {
|
||||
$node->safe_psql("postgres", "CREATE INDEX ON tst USING ivfflat (v $opclass);");
|
||||
|
||||
# Test 100% recall
|
||||
for (1..20) {
|
||||
for (1 .. 20)
|
||||
{
|
||||
my $i = int(rand() * 100000);
|
||||
my $query = $node->safe_psql("postgres", "SELECT v FROM tst WHERE i = $i;");
|
||||
my $res = $node->safe_psql("postgres", qq(
|
||||
|
||||
@@ -30,7 +30,8 @@ sub test_aggregate
|
||||
|
||||
# Test matches real for avg
|
||||
# Cannot test sum since sum(real) varies between calls
|
||||
if ($agg eq 'avg') {
|
||||
if ($agg eq 'avg')
|
||||
{
|
||||
my $r1 = $node->safe_psql("postgres", "SELECT $agg(r1)::float4 FROM tst;");
|
||||
my $r2 = $node->safe_psql("postgres", "SELECT $agg(r2)::float4 FROM tst;");
|
||||
my $r3 = $node->safe_psql("postgres", "SELECT $agg(r3)::float4 FROM tst;");
|
||||
|
||||
@@ -52,11 +52,13 @@ my $array_sql = join(",", ('random()') x $dim);
|
||||
# Initialize primary node
|
||||
$node_primary = get_new_node('primary');
|
||||
$node_primary->init(allows_streaming => 1);
|
||||
if ($dim > 32) {
|
||||
if ($dim > 32)
|
||||
{
|
||||
# TODO use wal_keep_segments for Postgres < 13
|
||||
$node_primary->append_conf('postgresql.conf', qq(wal_keep_size = 1GB));
|
||||
}
|
||||
if ($dim > 1500) {
|
||||
if ($dim > 1500)
|
||||
{
|
||||
$node_primary->append_conf('postgresql.conf', qq(maintenance_work_mem = 128MB));
|
||||
}
|
||||
$node_primary->start;
|
||||
@@ -67,8 +69,7 @@ $node_primary->backup($backup_name);
|
||||
|
||||
# Create streaming replica linking to primary
|
||||
$node_replica = get_new_node('replica');
|
||||
$node_replica->init_from_backup($node_primary, $backup_name,
|
||||
has_streaming => 1);
|
||||
$node_replica->init_from_backup($node_primary, $backup_name, has_streaming => 1);
|
||||
$node_replica->start;
|
||||
|
||||
# Create hnsw index on primary
|
||||
|
||||
@@ -55,7 +55,8 @@ $node->safe_psql("postgres",
|
||||
);
|
||||
|
||||
# Generate queries
|
||||
for (1..20) {
|
||||
for (1 .. 20)
|
||||
{
|
||||
my $r1 = rand();
|
||||
my $r2 = rand();
|
||||
my $r3 = rand();
|
||||
@@ -65,12 +66,14 @@ for (1..20) {
|
||||
# Check each index type
|
||||
my @operators = ("<->", "<#>", "<=>");
|
||||
|
||||
foreach (@operators) {
|
||||
foreach (@operators)
|
||||
{
|
||||
my $operator = $_;
|
||||
|
||||
# Get exact results
|
||||
@expected = ();
|
||||
foreach (@queries) {
|
||||
foreach (@queries)
|
||||
{
|
||||
my $res = $node->safe_psql("postgres", "SELECT i FROM tst ORDER BY v $operator '$_' LIMIT $limit;");
|
||||
push(@expected, $res);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,8 @@ $node->safe_psql("postgres", "CREATE EXTENSION vector;");
|
||||
$node->safe_psql("postgres", "CREATE TABLE tst (i serial, v vector(3));");
|
||||
|
||||
# Generate queries
|
||||
for (1..20) {
|
||||
for (1 .. 20)
|
||||
{
|
||||
my $r1 = rand();
|
||||
my $r2 = rand();
|
||||
my $r3 = rand();
|
||||
@@ -62,7 +63,8 @@ for (1..20) {
|
||||
# Check each index type
|
||||
my @operators = ("<->", "<#>", "<=>");
|
||||
|
||||
foreach (@operators) {
|
||||
foreach (@operators)
|
||||
{
|
||||
my $operator = $_;
|
||||
|
||||
# Add index
|
||||
@@ -90,7 +92,8 @@ foreach (@operators) {
|
||||
|
||||
# Get exact results
|
||||
@expected = ();
|
||||
foreach (@queries) {
|
||||
foreach (@queries)
|
||||
{
|
||||
my $res = $node->safe_psql("postgres", qq(
|
||||
SET enable_indexscan = off;
|
||||
SELECT i FROM tst ORDER BY v $operator '$_' LIMIT $limit;
|
||||
|
||||
@@ -15,7 +15,8 @@ $node->safe_psql("postgres", "CREATE TABLE tst (v vector(3));");
|
||||
|
||||
sub insert_vectors
|
||||
{
|
||||
for my $i (1 .. 20) {
|
||||
for my $i (1 .. 20)
|
||||
{
|
||||
$node->safe_psql("postgres", "INSERT INTO tst VALUES ('[1,1,1]');");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user