1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-10-23 21:49:02 +03:00
Files
sqlite/ext/vec1/test/vec1scalar.test
dan e32fbe0c23 Import vec1 sources into directory ext/vec1/ of this project.
FossilOrigin-Name: 3a0876d973868be7b6f4156a434cd09098c7ab1abdc7f0ef4f3d12a03de68b24
2026-09-30 14:49:16 +00:00

78 lines
1.8 KiB
Plaintext

# 2026-04-01
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
#
source [file join [file dirname [info script]] vec1_common.tcl]
set testprefix vec1scalar
if {[catch { vec1_load_scalar db }]} {
puts "Skipping tests... vec1testscalar.so not built"
finish_test
return
}
do_execsql_test 1.0 {
CREATE VIRTUAL TABLE docs USING vec1(embedding, title, category);
}
do_execsql_test 1.1 {
INSERT INTO docs(rowid, embedding, title, category)
SELECT i, vec1_from_json('['||(SELECT group_concat(printf('%!.9g',
sin(i*0.7+j*1.3)*0.5 + cos(i*0.11*j+0.3)*0.5),',')
FROM (WITH RECURSIVE q(j) AS (SELECT 0 UNION ALL SELECT j+1 FROM q WHERE j<31)
SELECT j FROM q))||']'),
'runbook '||i,
CASE i%4 WHEN 0 THEN 'ops' WHEN 1 THEN 'kb' WHEN 2 THEN 'sec' ELSE 'net' END
FROM (
WITH RECURSIVE r(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM r WHERE i<700)
SELECT i FROM r
);
}
do_execsql_test 1.2 {
INSERT INTO docs(cmd, arg) VALUES('rebuild', (
SELECT vec1_train(
embedding,'{nbucket:8,codesize:8,quantizer:"bq",residual:0}'
) FROM docs
));
}
do_execsql_test 1.3 {
PRAGMA integrity_check
} {ok}
db close
sqlite3 db test.db
vec1_load db
do_execsql_test 1.4 {
PRAGMA integrity_check
} {ok}
do_execsql_test 1.5 {
INSERT INTO docs(cmd, arg) VALUES('rebuild', (
SELECT vec1_train(
embedding,'{nbucket:8,codesize:8,quantizer:"bq",residual:0}'
) FROM docs
));
}
db close
sqlite3 db test.db
vec1_load_scalar db
do_execsql_test 1.6 {
PRAGMA integrity_check
} {ok}
finish_test