Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/vec1/test/vec1ab.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / ext / vec1 / test / vec1ab.test` 115 lines ยท 2593 bytes Raw Blame History 1 # 2026-01-17 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 14 source [file join [file dirname [info script]] vec1_common.tcl] 15 set testprefix vec1ab 16 vec1_load db 17 18 do_execsql_test 1.0 { 19 CREATE VIRTUAL TABLE v1 USING vec1; 20 WITH s(i) AS ( 21 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10000 22 ) 23 INSERT INTO v1(rowid, vector) SELECT NULL, random_vector(128) FROM s; 24 } 25 26 foreach {tn training} { 27 1.1 "flat" 28 1.2 "{ codesize: 16 }" 29 1.3 "{ codesize: 16 }" 30 1.4 "{ codesize: 8 }" 31 1.5 "{ codesize: 8 , nbucket: 32 }" 32 1.6 "{ codesize: 16 , nbucket: 32 }" 33 1.7 "{ codesize: 8 , nbucket: 32 }" 34 } { 35 do_test $tn.1 { 36 if {$training=="flat"} { 37 set T {{index:"flat"}} 38 } else { 39 set T [db one { 40 SELECT vec1_train(vector, $training) FROM v1 WHERE rowid < 1000 41 }] 42 } 43 set {} {} 44 } {} 45 46 do_execsql_test $tn.2 { 47 INSERT INTO v1(cmd, vector) VALUES('rebuild', $T); 48 } 49 50 do_execsql_test $tn.3 { 51 PRAGMA integrity_check 52 } ok 53 54 db close 55 sqlite3 db test.db 56 vec1_load db 57 58 do_execsql_test $tn.4 { 59 PRAGMA integrity_check 60 } ok 61 62 do_execsql_test $tn.5 { 63 SELECT sum(good) FROM ( 64 SELECT rowid IN ( 65 SELECT rowid FROM v1(o.vector, '{ K: 10 }') 66 ) AS good FROM v1 AS o LIMIT 100 67 ); 68 } {100} 69 } 70 71 do_execsql_test 2.0 { 72 CREATE VIRTUAL TABLE v2 USING vec1; 73 WITH s(i) AS ( 74 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10000 75 ) 76 INSERT INTO v2(rowid, vector) 77 SELECT 0x3_FFFF_FFFF + i, random_vector(128) FROM s; 78 79 WITH s(i) AS ( 80 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<50 81 ) 82 INSERT INTO v2(rowid, vector) 83 SELECT i - 0x3_FFFF_FFFF, random_vector(128) FROM s; 84 } 85 86 do_execsql_test 2.1 { 87 INSERT INTO v2(cmd, vector) VALUES('rebuild', '{index:"flat"}'); 88 } 89 90 do_execsql_test 2.2 { 91 SELECT sum(good) FROM ( 92 SELECT rowid IN ( 93 SELECT rowid FROM v2(o.vector, '{ K: 10 }') 94 ) AS good FROM v2 AS o LIMIT 100 95 ); 96 } {100} 97 98 do_execsql_test 2.3 { 99 INSERT INTO v2(cmd, vector) VALUES('rebuild', ( 100 SELECT vec1_train(vector, '{ codesize: 16 }') FROM ( 101 SELECT vector FROM v2 LIMIT 1000 102 ) 103 )); 104 } 105 106 do_execsql_test 2.4 { 107 SELECT sum(good) FROM ( 108 SELECT rowid IN ( 109 SELECT rowid FROM v2(o.vector, '{ K: 10 }') 110 ) AS good FROM v2 AS o LIMIT 100 111 ); 112 } {100} 113 114 115 finish_test