]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add an interface to better test incremental loading of doclists by FTS4. Also some...
authordan <dan@noemail.net>
Wed, 15 Jun 2011 08:30:29 +0000 (08:30 +0000)
committerdan <dan@noemail.net>
Wed, 15 Jun 2011 08:30:29 +0000 (08:30 +0000)
FossilOrigin-Name: 7a3813138d1a5c5d99f4756c79998831d779774f

ext/fts3/fts3_test.c
ext/fts3/fts3_write.c
manifest
manifest.uuid
test/fts3auto.test

index e82fca608ad18859ff596e62134923c9f880fa0c..de20e06cce11697ebe1cbefc44f324b464eb1623 100644 (file)
@@ -242,8 +242,78 @@ static int fts3_near_match_cmd(
   return rc;
 }
 
+/*
+**   Tclcmd: fts3_configure_incr_load ?CHUNKSIZE THRESHOLD?
+**
+** Normally, FTS uses hard-coded values to determine the minimum doclist
+** size eligible for incremental loading, and the size of the chunks loaded
+** when a doclist is incrementally loaded. This command allows the built-in
+** values to be overridden for testing purposes.
+**
+** If present, the first argument is the chunksize in bytes to load doclists
+** in. The second argument is the minimum doclist size in bytes to use
+** incremental loading with.
+**
+** Whether or not the arguments are present, this command returns a list of
+** two integers - the initial chunksize and threshold when the command is
+** invoked. This can be used to restore the default behaviour after running
+** tests. For example:
+**
+**    # Override incr-load settings for testing:
+**    set cfg [fts3_configure_incr_load $new_chunksize $new_threshold]
+**
+**    .... run tests ....
+**
+**    # Restore initial incr-load settings:
+**    eval fts3_configure_incr_load $cfg
+*/
+static int fts3_configure_incr_load_cmd(
+  ClientData clientData,
+  Tcl_Interp *interp,
+  int objc,
+  Tcl_Obj *CONST objv[]
+){
+  extern int test_fts3_node_chunksize;
+  extern int test_fts3_node_chunk_threshold;
+  int iArg1;
+  int iArg2;
+  Tcl_Obj *pRet;
+
+  if( objc!=1 && objc!=3 ){
+    Tcl_WrongNumArgs(interp, 1, objv, "?CHUNKSIZE THRESHOLD?");
+    return TCL_ERROR;
+  }
+
+  pRet = Tcl_NewObj();
+  Tcl_IncrRefCount(pRet);
+  Tcl_ListObjAppendElement(
+      interp, pRet, Tcl_NewIntObj(test_fts3_node_chunksize));
+  Tcl_ListObjAppendElement(
+      interp, pRet, Tcl_NewIntObj(test_fts3_node_chunk_threshold));
+
+  if( objc==3 ){
+    int iArg1;
+    int iArg2;
+    if( Tcl_GetIntFromObj(interp, objv[1], &iArg1)
+     || Tcl_GetIntFromObj(interp, objv[2], &iArg2)
+    ){
+      Tcl_DecrRefCount(pRet);
+      return TCL_ERROR;
+    }
+    test_fts3_node_chunksize = iArg1;
+    test_fts3_node_chunk_threshold = iArg2;
+  }
+
+  Tcl_SetObjResult(interp, pRet);
+  Tcl_DecrRefCount(pRet);
+  return TCL_OK;
+}
+
 int Sqlitetestfts3_Init(Tcl_Interp *interp){
   Tcl_CreateObjCommand(interp, "fts3_near_match", fts3_near_match_cmd, 0, 0);
+  Tcl_CreateObjCommand(interp, 
+      "fts3_configure_incr_load", fts3_configure_incr_load_cmd, 0, 0
+  );
   return TCL_OK;
 }
 
index 30c0a1a15bd27a540ec4812f1704a950f3602815..0d1e6ba21da6e9c01edd3cd655d5d61e784b7b54 100644 (file)
 ** is 1. Clearly such small values would be inefficient, but can be useful 
 ** for testing purposes.
 **
-** TODO: Add a test interface to modify these "constants" from a script for
-** this purpose.
+** If this module is built with SQLITE_TEST defined, these constants may
+** be overridden at runtime for testing purposes. File fts3_test.c contains
+** a Tcl interface to read and write the values.
 */
-#define FTS3_NODE_CHUNKSIZE (4*1024) 
-#define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)
-/* #define FTS3_NODE_CHUNKSIZE 1 */
-/* #define FTS3_NODE_CHUNK_THRESHOLD 1 */
+#ifdef SQLITE_TEST
+int test_fts3_node_chunksize = (4*1024);
+int test_fts3_node_chunk_threshold = (4*1024)*4;
+# define FTS3_NODE_CHUNKSIZE       test_fts3_node_chunksize
+# define FTS3_NODE_CHUNK_THRESHOLD test_fts3_node_chunk_threshold
+#else
+# define FTS3_NODE_CHUNKSIZE (4*1024) 
+# define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)
+#endif
 
 typedef struct PendingList PendingList;
 typedef struct SegmentNode SegmentNode;
index 54f991e43258fbb7d1dcd63026e274b87bab7cb9..5c19d15b5f430ee2de91dba4d66c1efa816a2f36 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\smemory\sleak\sthat\scan\sfollow\san\sOOM\serror\sin\sa\suser-function\sthat\suses\ssqlite3_set_auxdata().
-D 2011-06-14T14:18:45.331
+C Add\san\sinterface\sto\sbetter\stest\sincremental\sloading\sof\sdoclists\sby\sFTS4.\sAlso\ssome\stests\sfor\sthis\sand\sterm\sprefix\squeries.
+D 2011-06-15T08:30:29.176
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -72,11 +72,11 @@ F ext/fts3/fts3_icu.c ac494aed69835008185299315403044664bda295
 F ext/fts3/fts3_porter.c d61cfd81fb0fd8fbcb25adcaee0ba671aefaa5c2
 F ext/fts3/fts3_snippet.c 82e2c1e420c871c02f6e85ea438570118d7105c8
 F ext/fts3/fts3_term.c 6c7f33ab732a2a0f281898685650e3a492e1e2f1
-F ext/fts3/fts3_test.c 9376cc865447e63c671f0f9ffd1a2c9a29678230
+F ext/fts3/fts3_test.c 4c90a63c117c989ea899d59e2195622dcf61dbc0
 F ext/fts3/fts3_tokenizer.c 055f3dc7369585350b28db1ee0f3b214dca6724d
 F ext/fts3/fts3_tokenizer.h 13ffd9fcb397fec32a05ef5cd9e0fa659bf3dbd3
 F ext/fts3/fts3_tokenizer1.c 6e5cbaa588924ac578263a598e4fb9f5c9bb179d
-F ext/fts3/fts3_write.c bc24cec303d86aeb4b40fcbdf9f252f93ef78fc7
+F ext/fts3/fts3_write.c 4c008450666d6a1f45ba404cf654ebdb3d4da4cd
 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9
 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100
 F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9
@@ -455,7 +455,7 @@ F test/fts3am.test 218aa6ba0dfc50c7c16b2022aac5c6be593d08d8
 F test/fts3an.test a49ccadc07a2f7d646ec1b81bc09da2d85a85b18
 F test/fts3ao.test b83f99f70e9eec85f27d75801a974b3f820e01f9
 F test/fts3atoken.test 402ef2f7c2fb4b3d4fa0587df6441c1447e799b3
-F test/fts3auto.test 2f86f2a0e8ffa26d81d570897e6cc1c2262256d5
+F test/fts3auto.test a98cc895bd92df14ce4a6e94f5c68d33edcc1372
 F test/fts3aux1.test 0b02743955d56fc0d4d66236a26177bd1b726de0
 F test/fts3b.test e93bbb653e52afde110ad53bbd793f14fe7a8984
 F test/fts3c.test fc723a9cf10b397fdfc2b32e73c53c8b1ec02958
@@ -945,7 +945,7 @@ F tool/split-sqlite3c.tcl d9be87f1c340285a3e081eb19b4a247981ed290c
 F tool/symbols.sh bc2a3709940d47c8ac8e0a1fdf17ec801f015a00
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings.sh 347d974d143cf132f953b565fbc03026f19fcb4d
-P b1f9c1e0ac51cedfb05ac073a603343f6df865b5
-R 915dabb427b7d44a9631a4d5ac3ba884
+P 0185c4b689d18d66e6aa39b4a7bddc279e3c9d17
+R 1c51f9714aac7706b1e74e389e8d32c5
 U dan
-Z 905532115e84db070a1615e7e8131374
+Z 77f3043182a3d5e0d927f56eefb2694c
index 3952312e3e7a3957eec1c1527949a25b20aad93c..34ba6c729783efa3718a08aacb01c8e7b3977de3 100644 (file)
@@ -1 +1 @@
-0185c4b689d18d66e6aa39b4a7bddc279e3c9d17
\ No newline at end of file
+7a3813138d1a5c5d99f4756c79998831d779774f
\ No newline at end of file
index 5c9b85128ba73cbdf458ec087fe0ceb24ab8edfe..1fd02c537ff4fa45bf18d70383e714f264a6edb2 100644 (file)
@@ -530,6 +530,53 @@ foreach {tn create} {
   do_fts3query_test 4.$tn.4.5 -deferred fi* t1 {on* NEAR/3 fi*}
 }
 
+#--------------------------------------------------------------------------
+# The following test cases - fts3auto-5.* - focus on using prefix indexes.
+#
+set chunkconfig [fts3_configure_incr_load 1 1]
+foreach {tn create} {
+  1    "fts4(a, b)"
+  2    "fts4(a, b, order=DESC, prefix=1)"
+  3    "fts4(a, b, order=ASC,  prefix=1,3)"
+  4    "fts4(a, b, order=DESC, prefix=2,4)"
+} {
+
+  execsql [subst {
+    DROP TABLE t1;
+    CREATE VIRTUAL TABLE t1 USING $create;
+  }]
+
+  foreach {a b} {
+    "the song of songs which is solomons"
+    "let him kiss me with the kisses of his mouth for thy love is better than wine"
+    "because of the savour of thy good ointments thy name is as ointment poured forth therefore do the virgins love thee"
+    "draw me we will run after thee the king hath brought me into his chambers we will be glad and rejoice in thee we will remember thy love more than wine the upright love thee"
+    "i am black but comely o ye daughters of jerusalem as the tents of kedar as the curtains of solomon"
+    "look not upon me because i am black because the sun hath looked upon me my mothers children were angry with me they made me the keeper of the vineyards but mine own vineyard have i not kept"
+    "tell me o thou whom my soul loveth where thou feedest where thou makest thy flock to rest at noon for why should i be as one that turneth aside by the flocks of thy companions?"
+    "if thou know not o thou fairest among women go thy way forth by the footsteps of the flock and feed thy kids beside the shepherds tents"
+    "i have compared thee o my love to a company of horses in pharaohs chariots"
+    "thy cheeks are comely with rows of jewels thy neck with chains of gold"
+    "we will make thee borders of gold with studs of silver"
+    "while the king sitteth at his table my spikenard sendeth forth the smell thereof"
+    "a bundle of myrrh is my wellbeloved unto me he shall lie all night betwixt my breasts"
+    "my beloved is unto me as a cluster of camphire in the vineyards of en gedi"
+    "behold thou art fair my love behold thou art fair thou hast doves eyes"
+    "behold thou art fair my beloved yea pleasant also our bed is green"
+    "the beams of our house are cedar and our rafters of fir"
+  } {
+    execsql {INSERT INTO t1(a, b) VALUES($a, $b)}
+  }
+
+  do_fts3query_test 5.$tn.1.1 t1 {s*}
+  do_fts3query_test 5.$tn.1.2 t1 {so*}
+  do_fts3query_test 5.$tn.1.3 t1 {"s* o*"}
+  do_fts3query_test 5.$tn.1.4 t1 {b* NEAR/3 a*}
+  do_fts3query_test 5.$tn.1.5 t1 {th* NEAR/5 a* NEAR/5 w*}
+  do_fts3query_test 5.$tn.1.6 t1 {"b* th* art* fair*"}
+}
+eval fts3_configure_incr_load $chunkconfig
+
 set sqlite_fts3_enable_parentheses $sfep
 finish_test