Add the 'merge=?,?' command to fts4. This still needs some work.

FossilOrigin-Name: 741b8f897750eac3c9774fd65de7e40bb89781b1
This commit is contained in:
dan 2012-03-08 18:39:03 +00:00
parent fd6ddf91b0
commit 593c9824bc
6 changed files with 1232 additions and 28 deletions

View File

@ -67,6 +67,9 @@ extern const sqlite3_api_routines *sqlite3_api;
#ifndef MIN
# define MIN(x,y) ((x)<(y)?(x):(y))
#endif
#ifndef MAX
# define MAX(x,y) ((x)>(y)?(x):(y))
#endif
/*
** Maximum length of a varint encoded integer. The varint format is different
@ -197,7 +200,7 @@ struct Fts3Table {
/* Precompiled statements used by the implementation. Each of these
** statements is run and reset within a single virtual table API call.
*/
sqlite3_stmt *aStmt[28];
sqlite3_stmt *aStmt[35];
char *zReadExprlist;
char *zWriteExprlist;

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
C Fix\sa\sproblem\scompiling\sthe\stest\scode\sin\sfts3_test.c\swhen\sSQLITE_ENABLE_FTS3\sis\snot\sdefined.
D 2012-03-05T16:24:26.279
C Add\sthe\s'merge=?,?'\scommand\sto\sfts4.\sThis\sstill\sneeds\ssome\swork.
D 2012-03-08T18:39:03.077
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -65,7 +65,7 @@ F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
F ext/fts3/fts3.c 806632fd0020eed966ab82ea25fe09f1a4c86907
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
F ext/fts3/fts3Int.h d1d7f964ddee067bcd16a6af4ba7ecf66220056d
F ext/fts3/fts3Int.h cc8991daf660b926ef77a004fe92b97adaf10d97
F ext/fts3/fts3_aux.c 72de4cb43db7bfc2f68fbda04b7d8095ae9a6239
F ext/fts3/fts3_expr.c dbc7ba4c3a6061adde0f38ed8e9b349568299551
F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914
@ -78,7 +78,7 @@ F ext/fts3/fts3_test.c 6b7cc68aef4efb084e1449f7d20c4b20d3bdf6b4
F ext/fts3/fts3_tokenizer.c 3da7254a9881f7e270ab28e2004e0d22b3212bce
F ext/fts3/fts3_tokenizer.h 66dec98e365854b6cd2d54f1a96bb6d428fc5a68
F ext/fts3/fts3_tokenizer1.c 0dde8f307b8045565cf63797ba9acfaff1c50c68
F ext/fts3/fts3_write.c f87bb2d27d31cb7a7bf306747079095393c9d073
F ext/fts3/fts3_write.c 81b885ef5db55c2f92b8e5a33e51eb7557084e41
F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9
F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100
F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9
@ -448,7 +448,7 @@ F test/fts2q.test b2fbbe038b7a31a52a6079b215e71226d8c6a682
F test/fts2r.test b154c30b63061d8725e320fba1a39e2201cadd5e
F test/fts2token.test d8070b241a15ff13592a9ae4a8b7c171af6f445a
F test/fts3.test 672a040ea57036fb4b6fdc09027c18d7d24ab654
F test/fts3_common.tcl 4d8eec9db565fed9098f45c378f28e1657802011
F test/fts3_common.tcl 91c29230c428443e6552add9b18cf94a3dc23074
F test/fts3aa.test 909d5f530d30a8e36b9328d67285eae6537c79c0
F test/fts3ab.test 09aeaa162aee6513d9ff336b6932211008b9d1f9
F test/fts3ac.test 636ed7486043055d4f126a0e385f2d5a82ebbf63
@ -497,6 +497,7 @@ F test/fts3sort.test 95be0b19d7e41c44b29014f13ea8bddd495fd659
F test/fts4aa.test 6e7f90420b837b2c685f3bcbe84c868492d40a68
F test/fts4content.test 17b2360f7d1a9a7e5aa8022783f5c5731b6dfd4f
F test/fts4langid.test fabdd5a8db0fa00292e0704809f566e3fb6dba3a
F test/fts4merge.test 3af8fa8fd9f27a9eb402b9ae399aa53fbaae8481
F test/func.test 6c5ce11e3a0021ca3c0649234e2d4454c89110ca
F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f
F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a
@ -992,7 +993,10 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P 99a9073b5e411ce94f38ce49608baaa15de8b850
R d0dc4635c0ac977f7342c0a0dac9e48b
P b00ccda307caae597c143ab0586f90acb77f79cf
R a895af2ffe98328624a86f767eb1318f
T *branch * fts4-incr-merge
T *sym-fts4-incr-merge *
T -sym-trunk *
U dan
Z d6573fd4e75425ab6ee13bee3b518e09
Z 1441d373e5b74aab517b4d814807ebb3

View File

@ -1 +1 @@
b00ccda307caae597c143ab0586f90acb77f79cf
741b8f897750eac3c9774fd65de7e40bb89781b1

View File

@ -46,6 +46,7 @@ proc fts3_integrity_check {tbl} {
fts3_read2 $tbl 1 A
foreach zTerm [array names A] {
#puts $zTerm
foreach doclist $A($zTerm) {
set docid 0
while {[string length $doclist]>0} {
@ -233,7 +234,8 @@ proc fts3_readleaf {blob} {
set zTerm [string range $zPrev 0 [expr $nPrefix-1]]
append zTerm [gobble_string blob $nSuffix]
set doclist [gobble_string blob [gobble_varint blob]]
set nDoclist [gobble_varint blob]
set doclist [gobble_string blob $nDoclist]
lappend terms $zTerm $doclist
set zPrev $zTerm
@ -249,7 +251,9 @@ proc fts3_read2 {tbl where varname} {
FROM ${tbl}_segdir WHERE $where
ORDER BY level ASC, idx DESC
" {
if {$start_block == 0} {
set c 0
binary scan $root c c
if {$c==0} {
foreach {t d} [fts3_readleaf $root] { lappend a($t) $d }
} else {
db eval " SELECT block
@ -258,7 +262,6 @@ proc fts3_read2 {tbl where varname} {
ORDER BY blockid
" {
foreach {t d} [fts3_readleaf $block] { lappend a($t) $d }
}
}
}

103
test/fts4merge.test Normal file
View File

@ -0,0 +1,103 @@
# 2012 March 06
#
# 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.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The
# focus of this script is testing the incremental merge function.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/fts3_common.tcl
set ::testprefix fts4merge
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
ifcapable !fts3 {
finish_test
return
}
proc fts3_build_db_1 {n} {
if {$n > 10000} {error "n must be <= 10000"}
db eval { CREATE VIRTUAL TABLE t1 USING fts4(x, y) }
set xwords [list zero one two three four five six seven eight nine ten]
set ywords [list alpha beta gamma delta epsilon zeta eta theta iota kappa]
for {set i 0} {$i < $n} {incr i} {
set x ""
set y ""
set x [list]
lappend x [lindex $xwords [expr ($i / 1000) % 10]]
lappend x [lindex $xwords [expr ($i / 100) % 10]]
lappend x [lindex $xwords [expr ($i / 10) % 10]]
lappend x [lindex $xwords [expr ($i / 1) % 10]]
set y [list]
lappend y [lindex $ywords [expr ($i / 1000) % 10]]
lappend y [lindex $ywords [expr ($i / 100) % 10]]
lappend y [lindex $ywords [expr ($i / 10) % 10]]
lappend y [lindex $ywords [expr ($i / 1) % 10]]
db eval { INSERT INTO t1(docid, x, y) VALUES($i, $x, $y) }
}
}
#-------------------------------------------------------------------------
# Test cases 1.*
#
do_test 1.0 { fts3_build_db_1 1004 } {}
do_test 1.1 { fts3_integrity_check t1 } {ok}
do_execsql_test 1.1 {
SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level
} {
0 {0 1 2 3 4 5 6 7 8 9 10 11}
1 {0 1 2 3 4 5 6 7 8 9 10 11 12 13}
2 {0 1 2}
}
for {set i 0} {$i<20} {incr i} {
do_execsql_test 1.2.$i.1 { INSERT INTO t1(t1) VALUES('merge=1') }
do_test 1.2.$i.2 { fts3_integrity_check t1 } ok
do_execsql_test 1.2.$i.3 {
SELECT docid FROM t1 WHERE t1 MATCH 'zero one two three'
} {123 132 213 231 312 321}
}
do_execsql_test 1.3 {
SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level
} {
0 {0 1 2 3 4 5 6 7}
1 {0 1 2 3 4 5 6 7}
2 {0 1 2 3 4 5 6}
}
for {set i 0} {$i<100} {incr i} {
do_execsql_test 1.4.$i { INSERT INTO t1(t1) VALUES('merge=1,4') }
do_test 1.4.$i.2 { fts3_integrity_check t1 } ok
do_execsql_test 1.4.$i.3 {
SELECT docid FROM t1 WHERE t1 MATCH 'zero one two three'
} {123 132 213 231 312 321}
}
do_execsql_test 1.5 {
SELECT level, group_concat(idx, ' ') FROM t1_segdir GROUP BY level
} {
0 {0 1 2 3}
1 {0 1 2 3}
2 {0 1 2 3}
3 {0 1 2}
}
finish_test