/ Check-in [cccee7b5]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix some compiler warnings caused by signed/unsigned pointer conversions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fts5
Files: files | file ages | folders
SHA1:cccee7b5b1e84523f1c549d3052fd170e32bde80
User & Date: dan 2015-03-07 15:46:41
Context
2015-03-10
19:24
Avoid redundant string comparisons while merging fts5 segment b-trees. check-in: 5c46820d user: dan tags: fts5
2015-03-07
15:46
Fix some compiler warnings caused by signed/unsigned pointer conversions. check-in: cccee7b5 user: dan tags: fts5
11:50
Fix the bm25() function so that it multiplies scores by -1 before returning them. This means better matches have a lower numerical score, so "ORDER BY rank" (not "ORDER BY rank DESC") does what you want. check-in: 3ee7b5a9 user: dan tags: fts5
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts5/fts5Int.h.

   392    392     int (*xEntry)(void*, i64, const u8*, int),
   393    393     int (*xTermDone)(void*)
   394    394   );
   395    395   
   396    396   int sqlite3Fts5HashQuery(
   397    397     Fts5Hash*,                      /* Hash table to query */
   398    398     const char *pTerm, int nTerm,   /* Query term */
   399         -  const char **ppDoclist,         /* OUT: Pointer to doclist for pTerm */
          399  +  const u8 **ppDoclist,           /* OUT: Pointer to doclist for pTerm */
   400    400     int *pnDoclist                  /* OUT: Size of doclist in bytes */
   401    401   );
   402    402   
   403    403   int sqlite3Fts5HashScanInit(
   404    404     Fts5Hash*,                      /* Hash table to query */
   405    405     const char *pTerm, int nTerm    /* Query prefix */
   406    406   );
   407    407   void sqlite3Fts5HashScanNext(Fts5Hash*);
   408    408   int sqlite3Fts5HashScanEof(Fts5Hash*);
   409    409   void sqlite3Fts5HashScanEntry(Fts5Hash *,
   410    410     const char **pzTerm,            /* OUT: term (nul-terminated) */
   411         -  const char **ppDoclist,         /* OUT: pointer to doclist */
          411  +  const u8 **ppDoclist,           /* OUT: pointer to doclist */
   412    412     int *pnDoclist                  /* OUT: size of doclist in bytes */
   413    413   );
   414    414   
   415    415   
   416    416   /*
   417    417   ** End of interface to code in fts5_hash.c.
   418    418   **************************************************************************/

Changes to ext/fts5/fts5_hash.c.

   376    376   
   377    377   /*
   378    378   ** Query the hash table for a doclist associated with term pTerm/nTerm.
   379    379   */
   380    380   int sqlite3Fts5HashQuery(
   381    381     Fts5Hash *pHash,                /* Hash table to query */
   382    382     const char *pTerm, int nTerm,   /* Query term */
   383         -  const char **ppDoclist,         /* OUT: Pointer to doclist for pTerm */
          383  +  const u8 **ppDoclist,           /* OUT: Pointer to doclist for pTerm */
   384    384     int *pnDoclist                  /* OUT: Size of doclist in bytes */
   385    385   ){
   386    386     unsigned int iHash = fts5HashKey(pHash->nSlot, pTerm, nTerm);
   387    387     Fts5HashEntry *p;
   388    388   
   389    389     for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
   390    390       if( memcmp(p->zKey, pTerm, nTerm)==0 && p->zKey[nTerm]==0 ) break;
   391    391     }
   392    392   
   393    393     if( p ){
   394    394       fts5HashAddPoslistSize(p);
   395         -    *ppDoclist = &p->zKey[nTerm+1];
          395  +    *ppDoclist = (const u8*)&p->zKey[nTerm+1];
   396    396       *pnDoclist = p->nData - (sizeof(*p) + nTerm + 1);
   397    397     }else{
   398    398       *ppDoclist = 0;
   399    399       *pnDoclist = 0;
   400    400     }
   401    401   
   402    402     return SQLITE_OK;
................................................................................
   417    417   int sqlite3Fts5HashScanEof(Fts5Hash *p){
   418    418     return (p->pScan==0);
   419    419   }
   420    420   
   421    421   void sqlite3Fts5HashScanEntry(
   422    422     Fts5Hash *pHash,
   423    423     const char **pzTerm,            /* OUT: term (nul-terminated) */
   424         -  const char **ppDoclist,         /* OUT: pointer to doclist */
          424  +  const u8 **ppDoclist,           /* OUT: pointer to doclist */
   425    425     int *pnDoclist                  /* OUT: size of doclist in bytes */
   426    426   ){
   427    427     Fts5HashEntry *p;
   428    428     if( (p = pHash->pScan) ){
   429    429       int nTerm = strlen(p->zKey);
   430    430       fts5HashAddPoslistSize(p);
   431    431       *pzTerm = p->zKey;
   432         -    *ppDoclist = &p->zKey[nTerm+1];
          432  +    *ppDoclist = (const u8*)&p->zKey[nTerm+1];
   433    433       *pnDoclist = p->nData - (sizeof(*p) + nTerm + 1);
   434    434     }else{
   435    435       *pzTerm = 0;
   436    436       *ppDoclist = 0;
   437    437       *pnDoclist = 0;
   438    438     }
   439    439   }
   440    440   
   441    441   #endif /* SQLITE_ENABLE_FTS5 */

Changes to ext/fts5/fts5_index.c.

  1793   1793             }else if( iOff!=fts5GetU16(&a[2]) ){
  1794   1794               pIter->iLeafOffset += fts5GetVarint32(&a[iOff], nKeep);
  1795   1795             }
  1796   1796           }else{
  1797   1797             pIter->iRowid += iDelta;
  1798   1798           }
  1799   1799         }else if( pIter->pSeg==0 ){
  1800         -        const char *pList = 0;
         1800  +        const u8 *pList = 0;
  1801   1801           const char *zTerm;
  1802   1802           int nList;
  1803   1803           if( 0==(pIter->flags & FTS5_SEGITER_ONETERM) ){
  1804   1804             sqlite3Fts5HashScanNext(p->apHash[0]);
  1805   1805             sqlite3Fts5HashScanEntry(p->apHash[0], &zTerm, &pList, &nList);
  1806   1806           }
  1807   1807           if( pList==0 ){
  1808   1808             fts5DataRelease(pIter->pLeaf);
  1809   1809             pIter->pLeaf = 0;
  1810   1810           }else{
  1811   1811             pIter->pLeaf->p = (u8*)pList;
  1812   1812             pIter->pLeaf->n = nList;
  1813   1813             sqlite3Fts5BufferSet(&p->rc, &pIter->term, strlen(zTerm), (u8*)zTerm);
  1814         -          pIter->iLeafOffset = getVarint((u8*)pList, (u64*)&pIter->iRowid);
         1814  +          pIter->iLeafOffset = getVarint(pList, (u64*)&pIter->iRowid);
  1815   1815             if( pIter->flags & FTS5_SEGITER_REVERSE ){
  1816   1816               fts5SegIterReverseInitPage(p, pIter);
  1817   1817             }
  1818   1818           }
  1819   1819         }else{
  1820   1820           iOff = 0;
  1821   1821           /* Next entry is not on the current page */
................................................................................
  2071   2071     Fts5Index *p,                   /* FTS5 backend */
  2072   2072     int iIdx,                       /* Config.aHash[] index of FTS index */
  2073   2073     const u8 *pTerm, int nTerm,     /* Term to seek to */
  2074   2074     int flags,                      /* Mask of FTS5INDEX_XXX flags */
  2075   2075     Fts5SegIter *pIter              /* Object to populate */
  2076   2076   ){
  2077   2077     Fts5Hash *pHash = p->apHash[iIdx];
  2078         -  const char *pList = 0;
         2078  +  const u8 *pList = 0;
  2079   2079     int nList = 0;
  2080   2080     const u8 *z = 0;
  2081   2081     int n = 0;
  2082   2082   
  2083   2083     assert( pHash );
  2084   2084     assert( p->rc==SQLITE_OK );
  2085   2085   
................................................................................
  3429   3429   
  3430   3430     if( iSegid ){
  3431   3431       const int pgsz = p->pConfig->pgsz;
  3432   3432   
  3433   3433       Fts5StructureSegment *pSeg;   /* New segment within pStruct */
  3434   3434       int nHeight;                  /* Height of new segment b-tree */
  3435   3435       Fts5Buffer *pBuf;             /* Buffer in which to assemble leaf page */
  3436         -    const char *zPrev = 0;
         3436  +    const u8 *zPrev = 0;
  3437   3437   
  3438   3438       Fts5SegWriter writer;
  3439   3439       fts5WriteInit(p, &writer, iHash, iSegid);
  3440   3440   
  3441   3441       /* Pre-allocate the buffer used to assemble leaf pages to the target
  3442   3442       ** page size.  */
  3443   3443       assert( pgsz>0 );
................................................................................
  3454   3454       while( p->rc==SQLITE_OK && 0==sqlite3Fts5HashScanEof(pHash) ){
  3455   3455         const char *zTerm;
  3456   3456         int nTerm;
  3457   3457         const u8 *pDoclist;
  3458   3458         int nDoclist;
  3459   3459         int nSuffix;                /* Size of term suffix */
  3460   3460   
  3461         -      sqlite3Fts5HashScanEntry(pHash, &zTerm,(const char**)&pDoclist,&nDoclist);
         3461  +      sqlite3Fts5HashScanEntry(pHash, &zTerm, &pDoclist, &nDoclist);
  3462   3462         nTerm = strlen(zTerm);
  3463   3463   
  3464   3464         /* Decide if the term fits on the current leaf. If not, flush it
  3465   3465         ** to disk.  */
  3466   3466         if( (pBuf->n + nTerm + 2) > pgsz ){
  3467   3467           fts5WriteFlushLeaf(p, &writer);
  3468   3468           pBuf = &writer.aWriter[0].buf;
................................................................................
  3470   3470             fts5BufferGrow(&p->rc, pBuf, nTerm + 32 - pBuf->n);
  3471   3471             if( p->rc ) break;
  3472   3472           }
  3473   3473         }
  3474   3474   
  3475   3475         /* Write the term to the leaf. And push it up into the b-tree hierarchy */
  3476   3476         if( writer.bFirstTermInPage==0 ){
  3477         -        int nPre = fts5PrefixCompress(nTerm, zPrev, nTerm, zTerm);
         3477  +        int nPre = fts5PrefixCompress(nTerm, zPrev, nTerm, (const u8*)zTerm);
  3478   3478           pBuf->n += sqlite3PutVarint(&pBuf->p[pBuf->n], nPre);
  3479   3479           nSuffix = nTerm - nPre;
  3480   3480         }else{
  3481   3481           fts5PutU16(&pBuf->p[2], pBuf->n);
  3482   3482           writer.bFirstTermInPage = 0;
  3483   3483           if( writer.aWriter[0].pgno!=1 ){
  3484         -          int nPre = fts5PrefixCompress(nTerm, zPrev, nTerm, zTerm);
         3484  +          int nPre = fts5PrefixCompress(nTerm, zPrev, nTerm, (const u8*)zTerm);
  3485   3485             fts5WriteBtreeTerm(p, &writer, nPre+1, (const u8*)zTerm);
  3486   3486             pBuf = &writer.aWriter[0].buf;
  3487   3487             assert( nPre<nTerm );
  3488   3488           }
  3489   3489           nSuffix = nTerm;
  3490   3490         }
  3491   3491         pBuf->n += sqlite3PutVarint(&pBuf->p[pBuf->n], nSuffix);
................................................................................
  3549   3549             assert( pBuf->n<=pgsz );
  3550   3550             iOff += nCopy;
  3551   3551           }
  3552   3552         }
  3553   3553   
  3554   3554         pBuf->p[pBuf->n++] = '\0';
  3555   3555         assert( pBuf->n<=pBuf->nSpace );
  3556         -      zPrev = zTerm;
         3556  +      zPrev = (const u8*)zTerm;
  3557   3557         sqlite3Fts5HashScanNext(pHash);
  3558   3558       }
  3559   3559       sqlite3Fts5HashClear(pHash);
  3560   3560       fts5WriteFinish(p, &writer, &nHeight, &pgnoLast);
  3561   3561   
  3562   3562       /* Update the Fts5Structure. It is written back to the database by the
  3563   3563       ** fts5StructureRelease() call below.  */