From: dan Date: Wed, 2 Oct 2013 08:04:27 +0000 (+0000) Subject: Add a test to check that the new multi-token phrase optimization is actually helping. X-Git-Tag: version-3.8.1~45^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eb26672d0e1d9e854c89811492195c498131fc32;p=thirdparty%2Fsqlite.git Add a test to check that the new multi-token phrase optimization is actually helping. FossilOrigin-Name: bc3a2ed5fb2402805928b0002457eebf06f87c47 --- diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 7b55afe003..2965bced37 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -4046,6 +4046,10 @@ static int fts3EvalPhraseStart(Fts3Cursor *pCsr, int bOptOk, Fts3Phrase *p){ int bIncrOk = (bOptOk && pCsr->bDesc==pTab->bDescIdx && p->nToken<=MAX_INCR_PHRASE_TOKENS && p->nToken>0 + && p->nToken<=MAX_INCR_PHRASE_TOKENS && p->nToken>0 +#ifdef SQLITE_TEST + && pTab->bNoIncrDoclist==0 +#endif ); for(i=0; bIncrOk==1 && inToken; i++){ Fts3PhraseToken *pToken = &p->aToken[i]; @@ -4265,12 +4269,12 @@ static int fts3EvalIncrPhraseNext( /* Check if the current entries really are a phrase match */ if( bEof==0 ){ + int nList = 0; int nByte = a[p->nToken-1].nList; char *aDoclist = sqlite3_malloc(nByte+1); if( !aDoclist ) return SQLITE_NOMEM; memcpy(aDoclist, a[p->nToken-1].pList, nByte+1); - int nList; for(i=0; i<(p->nToken-1); i++){ char *pLeft = a[i].pList; char *pRight = aDoclist; diff --git a/ext/fts3/fts3Int.h b/ext/fts3/fts3Int.h index 6e44d9a48b..6986acdec6 100644 --- a/ext/fts3/fts3Int.h +++ b/ext/fts3/fts3Int.h @@ -267,6 +267,12 @@ struct Fts3Table { int inTransaction; /* True after xBegin but before xCommit/xRollback */ int mxSavepoint; /* Largest valid xSavepoint integer */ #endif + +#ifdef SQLITE_TEST + /* True to disable the incremental doclist optimization. This is controled + ** by special insert command 'test-no-incr-doclist'. */ + int bNoIncrDoclist; +#endif }; /* diff --git a/ext/fts3/fts3_write.c b/ext/fts3/fts3_write.c index cb1d1cb266..22dd797c49 100644 --- a/ext/fts3/fts3_write.c +++ b/ext/fts3/fts3_write.c @@ -5050,6 +5050,9 @@ static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){ }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){ p->nMaxPendingData = atoi(&zVal[11]); rc = SQLITE_OK; + }else if( nVal>21 && 0==sqlite3_strnicmp(zVal, "test-no-incr-doclist=", 21) ){ + p->bNoIncrDoclist = atoi(&zVal[21]); + rc = SQLITE_OK; #endif }else{ rc = SQLITE_ERROR; diff --git a/manifest b/manifest index 1a062affcc..3f64e7d97f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\strunk\schanges\swith\sthis\sbranch. -D 2013-10-01T20:10:26.229 +C Add\sa\stest\sto\scheck\sthat\sthe\snew\smulti-token\sphrase\soptimization\sis\sactually\shelping. +D 2013-10-02T08:04:27.690 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -78,9 +78,9 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c e781a0147f26b4055c650861060b24792f4f0fb1 +F ext/fts3/fts3.c a6b015359e8f5911e4b23b5b80375544e8f00b60 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe -F ext/fts3/fts3Int.h 0634f768e7f6d5767972014e1ca83055ad2e09e3 +F ext/fts3/fts3Int.h 8689f7cf85020e7f88d1e761eeac480c3b0ea7ad F ext/fts3/fts3_aux.c b02632f6dd0e375ce97870206d914ea6d8df5ccd F ext/fts3/fts3_expr.c f8eb1046063ba342c7114eba175cabb31c4a64e7 F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 @@ -96,7 +96,7 @@ F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 F ext/fts3/fts3_unicode.c 92391b4b4fb043564c6539ea9b8661e3bcba47b9 F ext/fts3/fts3_unicode2.c 0113d3acf13429e6dc38e0647d1bc71211c31a4d -F ext/fts3/fts3_write.c ce45c3ea578464f26b0293ea8e54a39694f18b64 +F ext/fts3/fts3_write.c 851e65f413576055f2e86a63d45b7d67c829db56 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 F ext/fts3/tool/fts3view.c 6cfc5b67a5f0e09c0d698f9fd012c784bfaa9197 @@ -556,6 +556,7 @@ F test/fts4aa.test 0c3152322c7f0b548cc942ad763eaba0da87ccca F test/fts4check.test 66fa274cab2b615f2fb338b257713aba8fad88a8 F test/fts4content.test 2e7252557d6d24afa101d9ba1de710d6140e6d06 F test/fts4docid.test e33c383cfbdff0284685604d256f347a18fdbf01 +F test/fts4incr.test 79093b825148178a4eeba2bd1219a19b5d2d248a F test/fts4langid.test 24a6e41063b416bbdf371ff6b4476fa41c194aa7 F test/fts4merge.test c424309743fdd203f8e56a1f1cd7872cd66cc0ee F test/fts4merge2.test 5faa558d1b672f82b847d2a337465fa745e46891 @@ -1119,7 +1120,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P ea543f081d93ed1bf66c21ce2108ec94e349f4c5 e0db7b38e1bc0edb1c3995cb23c46488aa6a0909 -R d2f3c7ddacead75bcfbaa37694b1ef7b +P 65d9c6fafbc19d3582e07c31fd915a70e7fcfa8e +R c082139794006b287921621a475577ab U dan -Z 780ab77ea4503f5f6e1ddf0b75c99905 +Z 7170aa47c893316c61ddefdaf461c4d6 diff --git a/manifest.uuid b/manifest.uuid index 2edf5be192..100e788565 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -65d9c6fafbc19d3582e07c31fd915a70e7fcfa8e \ No newline at end of file +bc3a2ed5fb2402805928b0002457eebf06f87c47 \ No newline at end of file diff --git a/test/fts4incr.test b/test/fts4incr.test new file mode 100644 index 0000000000..31d4937c10 --- /dev/null +++ b/test/fts4incr.test @@ -0,0 +1,53 @@ +# 2012 March 26 +# +# 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. +# +#************************************************************************* +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +source $testdir/fts3_common.tcl +set ::testprefix fts4docid + +# If SQLITE_ENABLE_FTS3 is defined, omit this file. +ifcapable !fts3 { + finish_test + return +} + +# Create the fts_kjv_genesis procedure which fills and FTS3/4 table +# with the complete text of the Book of Genesis. +# +source $testdir/genesis.tcl + +do_test 1.0 { + execsql { CREATE VIRTUAL TABLE t1 USING fts3(words) } + fts_kjv_genesis +} {} + +do_execsql_test 1.1 { + SELECT min(docid), max(docid) FROM t1; +} {1001001 1050026} + +foreach {tn q res} { + 1 { SELECT count(*) FROM t1 WHERE t1 MATCH 'and' AND docid < 1010000} 224 + 2 { SELECT count(*) FROM t1 WHERE t1 MATCH '"in the"' AND docid < 1010000} 47 + 3 { SELECT count(*) FROM t1 WHERE t1 MATCH '"And God"' AND docid < 1010000} 33 + 4 { SELECT count(*) FROM t1 WHERE t1 + MATCH '"land of canaan"' AND docid < 1030000 } 7 +} { + foreach s {0 1} { + execsql "INSERT INTO t1(t1) VALUES('test-no-incr-doclist=$s')" + do_execsql_test 2.$tn.$s $q $res + set t($s) [lindex [time [list execsql $q] 100] 0] + } + puts "with optimization: $t(0) without: $t(1)" +} + +finish_test