interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / vec1 / test / vec1rotate.test

56 lines · 1371 bytes Raw Blame History
1# 2026-03-14
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11#
12#
13
14source [file join [file dirname [info script]] vec1_common.tcl]
15set testprefix vec1rotate
16vec1_load db
17
18do_execsql_test 1.0 {
19 CREATE VIRTUAL TABLE v1 USING vec1(v);
20 WITH s(i) AS (
21 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1000
22 )
23 INSERT INTO v1(rowid, v) SELECT i, random_vector(14) FROM s;
24
25 INSERT INTO v1(cmd, arg)
26 SELECT
27 'rebuild',
28 vec1_train(v, '{codesize:14, opq:true, svd_verify:true, distance:"cos"}')
29 FROM v1;
30}
31
32set v [db one {SELECT random_vector(14)}]
33do_execsql_test 1.1 {
34 SELECT
35 (SELECT rowid FROM v1($v, 1))==
36 (SELECT rowid FROM v1 ORDER BY vec1_cos_distance($v, v))
37 ;
38} {1}
39
40do_execsql_test 2.0 {
41 DROP TABLE IF EXISTS v1;
42 CREATE VIRTUAL TABLE v1 USING vec1(v);
43 WITH s(i) AS (
44 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10000
45 )
46 INSERT INTO v1(rowid, v) SELECT i, random_vector(64) FROM s;
47
48 INSERT INTO v1(cmd, arg)
49 SELECT
50 'rebuild',
51 vec1_train(v, '{codesize:8, opq:true, svd_verify:true}')
52 FROM v1;
53}
54
55finish_test
56