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/vec1stream.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 / vec1stream.test` 121 lines ยท 2796 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 14 source [file join [file dirname [info script]] vec1_common.tcl] 15 set testprefix vec1stream 16 vec1_load db 17 18 do_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(16) FROM s; 24 25 INSERT INTO v1(cmd, arg) 26 SELECT 'rebuild', vec1_train(v, '{nbucket:32, codesize:0}') FROM v1; 27 } 28 29 do_test 1.1 { 30 llength [ 31 db eval { 32 SELECT rowid FROM v1(random_vector(16), '{K:10, nprobe: 1, streaming:0}') 33 } 34 ] 35 } {10} 36 37 do_test 1.2 { 38 llength [ 39 db eval { 40 SELECT rowid FROM v1( 41 random_vector(16), '{K:1000, nprobe: 32, streaming:0}' 42 ) 43 } 44 ] 45 } {1000} 46 47 do_test 1.3 { 48 llength [ 49 db eval { 50 SELECT rowid FROM v1(random_vector(16), '{K:10, nprobe: 1, streaming:1}') 51 } 52 ] 53 } {1000} 54 55 proc repeat {str n} { 56 string repeat $str $n 57 } 58 db func repeat repeat 59 60 do_execsql_test 2.0 { 61 CREATE VIRTUAL TABLE v2 USING vec1(v, m); 62 WITH s(i) AS ( 63 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1000 64 ) 65 INSERT INTO v2(rowid, v, m) SELECT i, random_vector(16), repeat(i,200) FROM s; 66 67 INSERT INTO v2(cmd, arg) 68 SELECT 'rebuild', vec1_train(v, '{nbucket:32, codesize:0}') FROM v1; 69 } 70 71 breakpoint 72 do_test 2.1 { 73 llength [ 74 db eval { 75 SELECT rowid 76 FROM v2(random_vector(16), '{K:10, nprobe: 1, streaming:1}') 77 WHERE m=repeat(555,200) 78 } 79 ] 80 } {1} 81 82 #------------------------------------------------------------------------- 83 reset_db 84 vec1_load db 85 86 db func vec vec 87 proc vec {args} { binary format r* $args } 88 89 proc sequence {n} { 90 set ret [list] 91 for {set i 1} {$i <= $n} {incr i} { lappend ret $i } 92 set ret 93 } 94 95 do_execsql_test 3.0 { 96 CREATE VIRTUAL TABLE docs USING vec1(embedding, title, category); 97 98 WITH RECURSIVE r(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM r WHERE i<400) 99 INSERT INTO docs(rowid, embedding, title, category) 100 SELECT i, 101 vec(i%37, i%53, i%71, i%29), 102 'runbook '||i, 103 CASE WHEN i%3=0 THEN 'ops' ELSE 'kb' END 104 FROM r; 105 106 INSERT INTO docs(cmd,arg) VALUES('rebuild', ( 107 SELECT vec1_train(embedding,'{nbucket:16,quantizer:"none"}') FROM docs 108 )); 109 } 110 111 do_execsql_test 3.1 { PRAGMA integrity_check } {ok} 112 113 for {set ii 1} {$ii <= 16} {incr ii} { 114 set j "{K:10,streaming:1,nprobe:$ii}" 115 do_execsql_test 3.2.$ii { 116 SELECT rowid FROM docs(vec(5,5,5,5), $j) ORDER BY 1 117 } [sequence 400] 118 } 119 120 finish_test 121