]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Simplify the way position lists are copied when merging data.
authordan <dan@noemail.net>
Mon, 11 Aug 2014 20:26:34 +0000 (20:26 +0000)
committerdan <dan@noemail.net>
Mon, 11 Aug 2014 20:26:34 +0000 (20:26 +0000)
FossilOrigin-Name: 9f8d678a0ea75e169daf8b3f00bd05f52a050ea6

ext/fts5/fts5_index.c
manifest
manifest.uuid

index e1f6c70f60479905e64bd0558f9ff009c0b36a4e..a21f881e61c056cdd1a281c7870878925226567a 100644 (file)
@@ -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( nCopy<nReq ){
+      i64 dummy;
+      nCopy += getVarint(&a[nCopy], (u64*)&dummy);
+    }
+    fts5BufferAppendBlob(&p->rc, &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( iOff<sPos.n ){
-          int iVal;
-          iOff += getVarint32(&sPos.p[iOff], iVal);
-          fts5WriteAppendPoslistInt(p, &writer, iVal);
-        }
+        fts5WriteAppendPoslistData(p, &writer, sPos.p, sPos.n);
       }
     }
 
@@ -3180,9 +3203,9 @@ static int fts5FlushNewEntry(
   const u8 *aPoslist, 
   int nPoslist
 ){
+  Fts5Buffer *pBuf;
   Fts5FlushCtx *p = (Fts5FlushCtx*)pCtx;
   int rc = SQLITE_OK;
-  int i = 0;
 
   /* Append the rowid itself */
   fts5WriteAppendRowid(p->pIdx, &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( i<nPoslist ){
-    int iVal;
-    i += getVarint32(&aPoslist[i], iVal);
-    fts5WriteAppendPoslistInt(p->pIdx, &p->writer, iVal);
-  }
-
+  /* And the poslist data */
+  fts5WriteAppendPoslistData(p->pIdx, &p->writer, aPoslist, nPoslist);
   return rc;
 }
 
index c888cfba5a8437b895eb500406cc5236dcb4c22d..fab8b2701624461948896853a8c00fa54271e0bc 100644 (file)
--- 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
index 602ab0978e3fa5457a6d2d5f139db3159a902d8b..7afe20b5698a5f4582f9e479f36fbe56e142a04f 100644 (file)
@@ -1 +1 @@
-617e2fac1c128212254f71b1a8fddaf0d1d90262
\ No newline at end of file
+9f8d678a0ea75e169daf8b3f00bd05f52a050ea6
\ No newline at end of file