From 1a669f84a12a576f3055277f43b6a6ea3e76da33 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 11 Aug 2014 20:26:34 +0000 Subject: [PATCH] Simplify the way position lists are copied when merging data. FossilOrigin-Name: 9f8d678a0ea75e169daf8b3f00bd05f52a050ea6 --- ext/fts5/fts5_index.c | 46 ++++++++++++++++++++++++++++++------------- manifest | 12 +++++------ manifest.uuid | 2 +- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index e1f6c70f60..a21f881e61 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -2813,6 +2813,34 @@ static void fts5WriteAppendPoslistInt( } } +static void fts5WriteAppendPoslistData( + Fts5Index *p, + Fts5SegWriter *pWriter, + const u8 *aData, + int nData +){ + Fts5PageWriter *pPage = &pWriter->aWriter[0]; + const u8 *a = aData; + int n = nData; + + while( p->rc==SQLITE_OK && (pPage->buf.n + n)>=p->pgsz ){ + int nReq = p->pgsz - pPage->buf.n; + int nCopy = 0; + while( nCopyrc, &pPage->buf, nCopy, a); + a += nCopy; + n -= nCopy; + fts5WriteFlushLeaf(p, pWriter); + pWriter->bFirstRowidInPage = 1; + } + if( n>0 ){ + fts5BufferAppendBlob(&p->rc, &pPage->buf, n, a); + } +} + static void fts5WriteAppendZerobyte(Fts5Index *p, Fts5SegWriter *pWriter){ fts5BufferAppendVarint(&p->rc, &pWriter->aWriter[0].buf, 0); } @@ -3041,12 +3069,7 @@ fflush(stdout); /* Copy the position list from input to output */ fts5WriteAppendPoslistInt(p, &writer, sPos.nRem); for(/* noop */; !fts5ChunkIterEof(p, &sPos); fts5ChunkIterNext(p, &sPos)){ - int iOff = 0; - while( iOffpIdx, &p->writer, iRowid); @@ -3190,13 +3213,8 @@ static int fts5FlushNewEntry( /* Append the size of the position list in bytes */ fts5WriteAppendPoslistInt(p->pIdx, &p->writer, nPoslist); - /* Copy the position list to the output segment */ - while( ipIdx, &p->writer, iVal); - } - + /* And the poslist data */ + fts5WriteAppendPoslistData(p->pIdx, &p->writer, aPoslist, nPoslist); return rc; } diff --git a/manifest b/manifest index c888cfba5a..fab8b27016 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Replace\sthe\shash\stable\sborrowed\sfrom\sfts3. -D 2014-08-11T19:44:52.686 +C Simplify\sthe\sway\sposition\slists\sare\scopied\swhen\smerging\sdata. +D 2014-08-11T20:26:34.077 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in b03432313a3aad96c706f8164fb9f5307eaf19f5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -111,7 +111,7 @@ F ext/fts5/fts5_buffer.c 248c61ac9fec001602efc72a45704f3b8d367c00 F ext/fts5/fts5_config.c f4ebf143e141b8c77355e3b15aba81b7be51d710 F ext/fts5/fts5_expr.c 7b8e380233176053841904a86006696ee8f6cd24 F ext/fts5/fts5_hash.c 2af412d00f65ad427f18acbe421c113413cdef06 -F ext/fts5/fts5_index.c ccef8703b6228a39090b0a03b83f163e69627ff2 +F ext/fts5/fts5_index.c 687736cba90a735ecd3cf9bf0e4174e7e5cc3f60 F ext/fts5/fts5_storage.c fa3c8fc4766d850a4977bf1d4b71c37e7b07ab8b F ext/fts5/fts5parse.y 777da8e5819f75c217982c79c29d014c293acac9 F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43 @@ -1202,7 +1202,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 a14fa876f0eb66028e302b908967cc4a05ede9fc -R b81a5fabd4e838059b5d12635ffcd939 +P 617e2fac1c128212254f71b1a8fddaf0d1d90262 +R b29d729688c110acdf84d0128dad3fdf U dan -Z 39c621bf94a400035f58731d1ee0f6cd +Z 772c48dd1029e003fed3d46062572012 diff --git a/manifest.uuid b/manifest.uuid index 602ab0978e..7afe20b569 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -617e2fac1c128212254f71b1a8fddaf0d1d90262 \ No newline at end of file +9f8d678a0ea75e169daf8b3f00bd05f52a050ea6 \ No newline at end of file