Modify the way the number of leaves written and the maximum relative level are calculated in the auto-incr-merge code.
FossilOrigin-Name: 0d841c957c6ec4afecb49504177c6279e09d7012
This commit is contained in:
+11
-4
@@ -3103,12 +3103,19 @@ static int fts3UpdateMethod(
|
||||
** hash-table to the database.
|
||||
*/
|
||||
static int fts3SyncMethod(sqlite3_vtab *pVtab){
|
||||
const int nMinMerge = 64; /* Minimum amount of incr-merge work to do */
|
||||
Fts3Table *p = (Fts3Table*)pVtab;
|
||||
int rc = sqlite3Fts3PendingTermsFlush(p);
|
||||
if( rc==SQLITE_OK && p->bAutoincrmerge==1 && p->nLeafAdd>0 ){
|
||||
int A = p->nLeafAdd * p->mxLevel;
|
||||
A += A/2;
|
||||
rc = sqlite3Fts3Incrmerge(p, A, 8);
|
||||
|
||||
if( rc==SQLITE_OK && p->bAutoincrmerge==1 && p->nLeafAdd>(nMinMerge/16) ){
|
||||
int mxLevel = 0; /* Maximum relative level value in db */
|
||||
int A; /* Incr-merge parameter A */
|
||||
|
||||
rc = sqlite3Fts3MaxLevel(p, &mxLevel);
|
||||
assert( rc==SQLITE_OK || mxLevel==0 );
|
||||
A = p->nLeafAdd * p->mxLevel;
|
||||
A += (A/2);
|
||||
if( A>nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, 8);
|
||||
}
|
||||
sqlite3Fts3SegmentsClose(p);
|
||||
return rc;
|
||||
|
||||
+2
-1
@@ -203,7 +203,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[36];
|
||||
sqlite3_stmt *aStmt[37];
|
||||
|
||||
char *zReadExprlist;
|
||||
char *zWriteExprlist;
|
||||
@@ -431,6 +431,7 @@ int sqlite3Fts3DeferToken(Fts3Cursor *, Fts3PhraseToken *, int);
|
||||
int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *);
|
||||
void sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *);
|
||||
void sqlite3Fts3SegmentsClose(Fts3Table *);
|
||||
int sqlite3Fts3MaxLevel(Fts3Table *, int *);
|
||||
|
||||
/* Special values interpreted by sqlite3SegReaderCursor() */
|
||||
#define FTS3_SEGCURSOR_PENDING -1
|
||||
|
||||
+29
-2
@@ -265,6 +265,7 @@ struct SegmentNode {
|
||||
#define SQL_CHOMP_SEGDIR 33
|
||||
#define SQL_SEGMENT_IS_APPENDABLE 34
|
||||
#define SQL_SELECT_INDEXES 35
|
||||
#define SQL_SELECT_MXLEVEL 36
|
||||
|
||||
/*
|
||||
** This function is used to obtain an SQLite prepared statement handle
|
||||
@@ -363,7 +364,11 @@ static int fts3SqlStmt(
|
||||
|
||||
/* SQL_SELECT_INDEXES
|
||||
** Return the list of valid segment indexes for absolute level ? */
|
||||
/* 35 */ "SELECT idx FROM %Q.'%q_segdir' WHERE level=? ORDER BY 1 ASC"
|
||||
/* 35 */ "SELECT idx FROM %Q.'%q_segdir' WHERE level=? ORDER BY 1 ASC",
|
||||
|
||||
/* SQL_SELECT_MXLEVEL
|
||||
** Return the largest relative level in the FTS index or indexes. */
|
||||
/* 36 */ "SELECT max( level %% 1024 ) FROM %Q.'%q_segdir'"
|
||||
};
|
||||
int rc = SQLITE_OK;
|
||||
sqlite3_stmt *pStmt;
|
||||
@@ -1877,6 +1882,27 @@ static void fts3UpdateMaxLevel(Fts3Table *p, sqlite3_int64 iLevel){
|
||||
if( iLevel>p->mxLevel ) p->mxLevel = iLevel;
|
||||
}
|
||||
|
||||
/*
|
||||
** Find the largest relative level number in the table. If successful, set
|
||||
** *pnMax to this value and return SQLITE_OK. Otherwise, if an error occurs,
|
||||
** set *pnMax to zero and return an SQLite error code.
|
||||
*/
|
||||
int sqlite3Fts3MaxLevel(Fts3Table *p, int *pnMax){
|
||||
int rc;
|
||||
int mxLevel = 0;
|
||||
sqlite3_stmt *pStmt = 0;
|
||||
|
||||
rc = fts3SqlStmt(p, SQL_SELECT_MXLEVEL, &pStmt, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
if( SQLITE_ROW==sqlite3_step(pStmt) ){
|
||||
mxLevel = sqlite3_column_int(pStmt, 0);
|
||||
}
|
||||
rc = sqlite3_reset(pStmt);
|
||||
}
|
||||
*pnMax = mxLevel;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Insert a record into the %_segdir table.
|
||||
*/
|
||||
@@ -2194,6 +2220,7 @@ static int fts3SegWriterAdd(
|
||||
/* The current leaf node is full. Write it out to the database. */
|
||||
rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);
|
||||
if( rc!=SQLITE_OK ) return rc;
|
||||
p->nLeafAdd++;
|
||||
|
||||
/* Add the current term to the interior node tree. The term added to
|
||||
** the interior tree must:
|
||||
@@ -2302,6 +2329,7 @@ static int fts3SegWriterFlush(
|
||||
rc = fts3WriteSegdir(
|
||||
p, iLevel, iIdx, 0, 0, 0, pWriter->aData, pWriter->nData);
|
||||
}
|
||||
p->nLeafAdd++;
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -3011,7 +3039,6 @@ int sqlite3Fts3PendingTermsFlush(Fts3Table *p){
|
||||
int rc = SQLITE_OK;
|
||||
int i;
|
||||
|
||||
p->nLeafAdd += (p->nPendingData + p->nNodeSize - 1)/p->nNodeSize;
|
||||
for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){
|
||||
rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING);
|
||||
if( rc==SQLITE_DONE ) rc = SQLITE_OK;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
C An\sattempt\sat\sautomatic\sincremental\smerging\sfor\sFTS4.
|
||||
D 2012-03-24T02:20:43.242
|
||||
C Modify\sthe\sway\sthe\snumber\sof\sleaves\swritten\sand\sthe\smaximum\srelative\slevel\sare\scalculated\sin\sthe\sauto-incr-merge\scode.
|
||||
D 2012-03-24T14:45:19.279
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@@ -63,9 +63,9 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51
|
||||
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
|
||||
F ext/fts3/README.tokenizers 998756696647400de63d5ba60e9655036cb966e9
|
||||
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
|
||||
F ext/fts3/fts3.c ef3d7af4a635beacf5546ea6c8c03329e263fd30
|
||||
F ext/fts3/fts3.c 442f0ccf5c1a6a63844b9712b6f66bf8adb603b6
|
||||
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
|
||||
F ext/fts3/fts3Int.h 1e635c9ba3a384496a4524f7b94d7d0525930552
|
||||
F ext/fts3/fts3Int.h f65df0fd76617cd43cb9795e5eec27e90ee4cbab
|
||||
F ext/fts3/fts3_aux.c 5205182bd8f372782597888156404766edf5781e
|
||||
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 5c98225a53705e5ee34824087478cf477bdb7004
|
||||
F ext/fts3/fts3_write.c 663f2fa51e7096d8f496f94db5f215c6d8d22820
|
||||
F ext/fts3/fts3_write.c c71f84711f189bc18a82560949ac1656318fd2c5
|
||||
F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9
|
||||
F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100
|
||||
F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9
|
||||
@@ -997,10 +997,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
|
||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||
P ed7c17ea165f6348506bd23ebc58c427bb65d697
|
||||
R c65796e564760bf2b3e7eed574e1eb1f
|
||||
T *branch * fts4-auto-incr-merge
|
||||
T *sym-fts4-auto-incr-merge *
|
||||
T -sym-fts4-incr-merge *
|
||||
U drh
|
||||
Z 9b979efabd6b6c201cc4798b465233ce
|
||||
P ed69434cd89084f4b57bd2cc4f5cc558904af565
|
||||
R bf494068b52a47b15eebd4119e5e6c0c
|
||||
U dan
|
||||
Z 7eb3af40022cc7568ef4099b19e62140
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
ed69434cd89084f4b57bd2cc4f5cc558904af565
|
||||
0d841c957c6ec4afecb49504177c6279e09d7012
|
||||
Reference in New Issue
Block a user