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 / vec1cat2.test

125 lines · 2675 bytes Raw Blame History
1# 2026-08-20
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 vec1cat2
16vec1_load db
17
18
19foreach {tn training expect} {
20 1 { codesize: 16 } {
21 "index": "trained",
22 "distance": "l2",
23 "nbucket": 0,
24 "quantizer": "pq",
25 "codesize": 16,
26 "residual": false,
27 "wht": false
28 }
29
30 2 { quantizer: "pq" } {
31 "index": "trained",
32 "distance": "l2",
33 "nbucket": 0,
34 "quantizer": "pq",
35 "codesize": 16,
36 "residual": false,
37 "wht": false
38 }
39
40 3 { quantizer: "opq" } {
41 "index": "trained",
42 "distance": "l2",
43 "nbucket": 0,
44 "quantizer": "opq",
45 "codesize": 32,
46 "residual": false,
47 "wht": false
48 }
49
50 4 { quantizer: "bq" } {
51 "index": "trained",
52 "distance": "l2",
53 "nbucket": 0,
54 "quantizer": "bq",
55 "codesize": 16,
56 "residual": false,
57 "wht": true
58 }
59
60 5 { nbucket: 10 } {
61 "index": "trained",
62 "distance": "l2",
63 "nbucket": 10,
64 "quantizer": "none",
65 "codesize": 0,
66 "residual": false,
67 "wht": false
68 }
69
70 6 { nbucket: 10, quantizer: "pq" } {
71 "index": "trained",
72 "distance": "l2",
73 "nbucket": 10,
74 "quantizer": "pq",
75 "codesize": 16,
76 "residual": true,
77 "wht": false
78 }
79
80 7 { quantizer: "pq", codesize: 0 } {
81 "index": "trained",
82 "distance": "l2",
83 "nbucket": 0,
84 "quantizer": "pq",
85 "codesize": 16,
86 "residual": false,
87 "wht": false
88 }
89} {
90
91 do_execsql_test 1.$tn.1 {
92 DROP TABLE IF EXISTS v1;
93 CREATE VIRTUAL TABLE v1 USING vec1 (v);
94 }
95
96 do_execsql_test 1.$tn.2 {
97
98 WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<512 ),
99 data(v) AS ( SELECT random_vector(128) FROM s)
100
101 INSERT INTO v1(cmd, arg) VALUES('rebuild', (
102 SELECT vec1_train(v, '{' || $training || '}') FROM data
103 ));
104
105 SELECT json(model) FROM vec1cat;
106 } [db eval { SELECT json( '{' || $expect || '}' )} ]
107
108 do_execsql_test 1.$tn.3 {
109
110 WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<512 ),
111 data(v) AS ( SELECT random_vector(128) FROM s)
112
113 INSERT INTO v1(cmd, arg) VALUES('rebuild', (
114 SELECT vec1_train(v, (SELECT model FROM vec1cat)) FROM data
115 ));
116
117 SELECT json(model) FROM vec1cat;
118 } [db eval { SELECT json( '{' || $expect || '}' )} ]
119
120}
121
122
123
124finish_test
125