From: dan Date: Fri, 27 Feb 2015 09:41:10 +0000 (+0000) Subject: Further minor optimizations to flushing fts5 data to disk. X-Git-Tag: version-3.8.11~114^2~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f400282bdf8e184b89437f6ae8d4c5e9297a81ab;p=thirdparty%2Fsqlite.git Further minor optimizations to flushing fts5 data to disk. FossilOrigin-Name: a07dcca9ef3821a6719ef9dbbc8ed861fa005035 --- diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 79c6d007de..3fe408a86e 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -3401,6 +3401,12 @@ static int fts5PoslistPrefix(const u8 *aBuf, int nMax){ return ret; } +#define fts5BufferSafeAppendBlob(pBuf, pBlob, nBlob) { \ + assert( pBuf->nSpace>=(pBuf->n+nBlob) ); \ + memcpy(&pBuf->p[pBuf->n], pBlob, nBlob); \ + pBuf->n += nBlob; \ +} + /* ** Flush the contents of in-memory hash table iHash to a new level-0 ** segment on disk. Also update the corresponding structure record. @@ -3460,6 +3466,7 @@ static void fts5FlushOneHash(Fts5Index *p, int iHash, int *pnLeaf){ pBuf = &writer.aWriter[0].buf; if( (nTerm + 32) > pBuf->nSpace ){ fts5BufferGrow(&p->rc, pBuf, nTerm + 32 - pBuf->n); + if( p->rc ) break; } } @@ -3480,13 +3487,11 @@ static void fts5FlushOneHash(Fts5Index *p, int iHash, int *pnLeaf){ nSuffix = nTerm; } pBuf->n += sqlite3PutVarint(&pBuf->p[pBuf->n], nSuffix); - fts5BufferAppendBlob(&p->rc, pBuf, - nSuffix, (const u8*)&zTerm[nTerm-nSuffix] - ); + fts5BufferSafeAppendBlob(pBuf, (const u8*)&zTerm[nTerm-nSuffix], nSuffix); if( pgsz>=(pBuf->n + nDoclist + 1) ){ /* The entire doclist will fit on the current leaf. */ - fts5BufferAppendBlob(&p->rc, pBuf, nDoclist, pDoclist); + fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist); }else{ i64 iRowid = 0; i64 iDelta = 0; @@ -3516,7 +3521,7 @@ static void fts5FlushOneHash(Fts5Index *p, int iHash, int *pnLeaf){ if( (pBuf->n + nCopy) <= pgsz ){ /* The entire poslist will fit on the current leaf. So copy ** it in one go. */ - fts5BufferAppendBlob(&p->rc, pBuf, nCopy, &pDoclist[iOff]); + fts5BufferSafeAppendBlob(pBuf, &pDoclist[iOff], nCopy); }else{ /* The entire poslist will not fit on this leaf. So it needs ** to be broken into sections. The only qualification being @@ -3531,7 +3536,7 @@ static void fts5FlushOneHash(Fts5Index *p, int iHash, int *pnLeaf){ }else{ n = fts5PoslistPrefix(&pPoslist[iPos], nSpace); } - fts5BufferAppendBlob(&p->rc, pBuf, n, &pPoslist[iPos]); + fts5BufferSafeAppendBlob(pBuf, &pPoslist[iPos], n); iPos += n; if( iPos>=nCopy ) break; fts5WriteFlushLeaf(p, &writer); diff --git a/manifest b/manifest index 9484610f04..5e4cb7afe0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssuffix\sand\sprefix\scompression\sof\sterms\sin\stop-level\sfts5\ssegments.\sAnd\sa\scrash\sthat\scould\sfollow\san\sOOM\scondition. -D 2015-02-27T07:23:26.074 +C Further\sminor\soptimizations\sto\sflushing\sfts5\sdata\sto\sdisk. +D 2015-02-27T09:41:10.812 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5407a688f4d77a05c18a8142be8ae5a2829dd610 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -112,7 +112,7 @@ F ext/fts5/fts5_buffer.c b92ba0eb67532d174934087f93716caf9a2168c7 F ext/fts5/fts5_config.c e3421a76c2abd33a05ac09df0c97c64952d1e700 F ext/fts5/fts5_expr.c eee52c9df84eade48eaa3f50c8876f44b552ff9b F ext/fts5/fts5_hash.c 63ad0066ec83525f0dad5b416d9db6e06f7d39ac -F ext/fts5/fts5_index.c 14549572551b60d99413f9bd2043ed2be004a328 +F ext/fts5/fts5_index.c deb7a5b73ca79b297cb32ce604015d13ad4a129e F ext/fts5/fts5_storage.c f7c12c9f454b2a525827b3d85fd222789236f548 F ext/fts5/fts5_tcl.c 1293fac2bb26903fd3d5cdee59c5885ba7e620d5 F ext/fts5/fts5_tokenize.c 0d108148c26132448487926fe683425002aee369 @@ -1284,7 +1284,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 8e3ca6323a2beab5f04250e24ae15b159d2aa0ac -R f04df10b48e4ca5c813b34f1122b4215 +P bb104b3646c6f07ed002be7360b08433ee7980d4 +R 7d2aff01dcb4baccf8d2147c84edd80c U dan -Z 4695fccf9ba60f7f53ddc85dbb7a72b7 +Z 8659a7b4b1b02ada86d180379ab48889 diff --git a/manifest.uuid b/manifest.uuid index b080cab9ec..6faea6421b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bb104b3646c6f07ed002be7360b08433ee7980d4 \ No newline at end of file +a07dcca9ef3821a6719ef9dbbc8ed861fa005035 \ No newline at end of file