/ Check-in [dffd358f]
Login

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

Overview
Comment:Remove all references to "docid" within fts5 source code and comments. Replace with "rowid".
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: dffd358f6cbf575d3b1045b1ce53429d15bade2a
User & Date: dan 2015-08-05 07:43:46
Context
2015-08-05
08:01
Fix some problems in test code detected by cppcheck. check-in: c9ff4ca4 user: dan tags: trunk
07:43
Remove all references to "docid" within fts5 source code and comments. Replace with "rowid". check-in: dffd358f user: dan tags: trunk
2015-08-04
20:29
Add new test file fts5_test_mi.c, containing an implementation of a function similar to FTS4 matchinfo() for FTS5. check-in: 4f9520a9 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts5/fts5Int.h.

   297    297   **   sqlite3Fts5IterNext(pIter)
   298    298   ** ){
   299    299   **   i64 iRowid = sqlite3Fts5IterRowid(pIter);
   300    300   ** }
   301    301   */
   302    302   
   303    303   /*
   304         -** Open a new iterator to iterate though all docids that match the 
          304  +** Open a new iterator to iterate though all rowids that match the 
   305    305   ** specified token or token prefix.
   306    306   */
   307    307   int sqlite3Fts5IndexQuery(
   308    308     Fts5Index *p,                   /* FTS index to query */
   309    309     const char *pToken, int nToken, /* Token (or prefix) to query for */
   310    310     int flags,                      /* Mask of FTS5INDEX_QUERY_X flags */
   311    311     Fts5IndexIter **ppIter

Changes to ext/fts5/fts5_expr.c.

    30     30   void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(u64));
    31     31   void sqlite3Fts5ParserFree(void*, void (*freeProc)(void*));
    32     32   void sqlite3Fts5Parser(void*, int, Fts5Token, Fts5Parse*);
    33     33   
    34     34   struct Fts5Expr {
    35     35     Fts5Index *pIndex;
    36     36     Fts5ExprNode *pRoot;
    37         -  int bDesc;                      /* Iterate in descending docid order */
           37  +  int bDesc;                      /* Iterate in descending rowid order */
    38     38     int nPhrase;                    /* Number of phrases in expression */
    39     39     Fts5ExprPhrase **apExprPhrase;  /* Pointers to phrase objects */
    40     40   };
    41     41   
    42     42   /*
    43     43   ** eType:
    44     44   **   Expression node type. Always one of:

Changes to ext/fts5/fts5_index.c.

    29     29   **   * all segment b-tree leaf data is stored in fixed size page records 
    30     30   **     (e.g. 1000 bytes). A single doclist may span multiple pages. Care is 
    31     31   **     taken to ensure it is possible to iterate in either direction through 
    32     32   **     the entries in a doclist, or to seek to a specific entry within a 
    33     33   **     doclist, without loading it into memory.
    34     34   **
    35     35   **   * large doclists that span many pages have associated "doclist index"
    36         -**     records that contain a copy of the first docid on each page spanned by
           36  +**     records that contain a copy of the first rowid on each page spanned by
    37     37   **     the doclist. This is used to speed up seek operations, and merges of
    38     38   **     large doclists with very small doclists.
    39     39   **
    40     40   **   * extra fields in the "structure record" record the state of ongoing
    41     41   **     incremental merge operations.
    42     42   **
    43     43   */
................................................................................
   206    206   **   is:
   207    207   **
   208    208   **     * Flags byte. Bits are:
   209    209   **         0x01: Clear if leaf is also the root page, otherwise set.
   210    210   **
   211    211   **     * Page number of fts index leaf page. As a varint.
   212    212   **
   213         -**     * First docid on page indicated by previous field. As a varint.
          213  +**     * First rowid on page indicated by previous field. As a varint.
   214    214   **
   215    215   **     * A list of varints, one for each subsequent termless page. A 
   216         -**       positive delta if the termless page contains at least one docid, 
          216  +**       positive delta if the termless page contains at least one rowid, 
   217    217   **       or an 0x00 byte otherwise.
   218    218   **
   219    219   **   Internal doclist index nodes are:
   220    220   **
   221    221   **     * Flags byte. Bits are:
   222    222   **         0x01: Clear for root page, otherwise set.
   223    223   **
   224    224   **     * Page number of first child page. As a varint.
   225    225   **
   226         -**     * Copy of first docid on page indicated by previous field. As a varint.
          226  +**     * Copy of first rowid on page indicated by previous field. As a varint.
   227    227   **
   228         -**     * A list of delta-encoded varints - the first docid on each subsequent
          228  +**     * A list of delta-encoded varints - the first rowid on each subsequent
   229    229   **       child page. 
   230    230   **
   231    231   */
   232    232   
   233    233   /*
   234    234   ** Rowids for the averages and structure records in the %_data table.
   235    235   */
................................................................................
   380    380     int pgno;                       /* Page number for this page */
   381    381     Fts5Buffer buf;                 /* Buffer containing page data */
   382    382     Fts5Buffer term;                /* Buffer containing previous term on page */
   383    383   };
   384    384   struct Fts5DlidxWriter {
   385    385     int pgno;                       /* Page number for this page */
   386    386     int bPrevValid;                 /* True if iPrev is valid */
   387         -  i64 iPrev;                      /* Previous docid value written to page */
          387  +  i64 iPrev;                      /* Previous rowid value written to page */
   388    388     Fts5Buffer buf;                 /* Buffer containing page data */
   389    389   };
   390    390   struct Fts5SegWriter {
   391    391     int iSegid;                     /* Segid to write to */
   392    392     Fts5PageWriter writer;          /* PageWriter object */
   393         -  i64 iPrevRowid;                 /* Previous docid written to current leaf */
          393  +  i64 iPrevRowid;                 /* Previous rowid written to current leaf */
   394    394     u8 bFirstRowidInDoclist;        /* True if next rowid is first in doclist */
   395    395     u8 bFirstRowidInPage;           /* True if next rowid is first in page */
   396    396     u8 bFirstTermInPage;            /* True if next term will be first in leaf */
   397    397     int nLeafWritten;               /* Number of leaf pages written */
   398    398     int nEmpty;                     /* Number of contiguous term-less nodes */
   399    399   
   400    400     int nDlidx;                     /* Allocated size of aDlidx[] array */
................................................................................
   403    403     /* Values to insert into the %_idx table */
   404    404     Fts5Buffer btterm;              /* Next term to insert into %_idx table */
   405    405     int iBtPage;                    /* Page number corresponding to btterm */
   406    406   };
   407    407   
   408    408   /*
   409    409   ** Object for iterating through the merged results of one or more segments,
   410         -** visiting each term/docid pair in the merged data.
          410  +** visiting each term/rowid pair in the merged data.
   411    411   **
   412    412   ** nSeg is always a power of two greater than or equal to the number of
   413    413   ** segments that this object is merging data from. Both the aSeg[] and
   414    414   ** aFirst[] arrays are sized at nSeg entries. The aSeg[] array is padded
   415    415   ** with zeroed objects - these are handled as if they were iterators opened
   416    416   ** on empty segments.
   417    417   **
................................................................................
   428    428   typedef struct Fts5CResult Fts5CResult;
   429    429   struct Fts5CResult {
   430    430     u16 iFirst;                     /* aSeg[] index of firstest iterator */
   431    431     u8 bTermEq;                     /* True if the terms are equal */
   432    432   };
   433    433   
   434    434   /*
   435         -** Object for iterating through a single segment, visiting each term/docid
          435  +** Object for iterating through a single segment, visiting each term/rowid
   436    436   ** pair in the segment.
   437    437   **
   438    438   ** pSeg:
   439    439   **   The segment to iterate through.
   440    440   **
   441    441   ** iLeafPgno:
   442    442   **   Current leaf page number within segment.
................................................................................
   460    460   **
   461    461   **   FTS5_SEGITER_ONETERM:
   462    462   **     If set, set the iterator to point to EOF after the current doclist 
   463    463   **     has been exhausted. Do not proceed to the next term in the segment.
   464    464   **
   465    465   **   FTS5_SEGITER_REVERSE:
   466    466   **     This flag is only ever set if FTS5_SEGITER_ONETERM is also set. If
   467         -**     it is set, iterate through docids in descending order instead of the
          467  +**     it is set, iterate through rowid in descending order instead of the
   468    468   **     default ascending order.
   469    469   **
   470    470   ** iRowidOffset/nRowidOffset/aRowidOffset:
   471    471   **     These are used if the FTS5_SEGITER_REVERSE flag is set.
   472    472   **
   473    473   **     For each rowid on the page corresponding to the current term, the
   474    474   **     corresponding aRowidOffset[] entry is set to the byte offset of the
................................................................................
  2235   2235       }
  2236   2236       iOff += nNew;
  2237   2237   
  2238   2238       /* Skip past the doclist. If the end of the page is reached, bail out. */
  2239   2239       while( 1 ){
  2240   2240         int nPos;
  2241   2241   
  2242         -      /* Skip past docid delta */
         2242  +      /* Skip past rowid delta */
  2243   2243         fts5IndexSkipVarint(a, iOff);
  2244   2244   
  2245   2245         /* Skip past position list */
  2246   2246         fts5IndexGetVarint32(a, iOff, nPos);
  2247   2247         iOff += (nPos >> 1);
  2248   2248         if( iOff>=(n-1) ){
  2249   2249           iOff = n;
................................................................................
  3373   3373     int nTerm, const u8 *pTerm 
  3374   3374   ){
  3375   3375     int nPrefix;                    /* Bytes of prefix compression for term */
  3376   3376     Fts5PageWriter *pPage = &pWriter->writer;
  3377   3377   
  3378   3378     assert( pPage->buf.n==0 || pPage->buf.n>4 );
  3379   3379     if( pPage->buf.n==0 ){
  3380         -    /* Zero the first term and first docid fields */
         3380  +    /* Zero the first term and first rowid fields */
  3381   3381       static const u8 zero[] = { 0x00, 0x00, 0x00, 0x00 };
  3382   3382       fts5BufferAppendBlob(&p->rc, &pPage->buf, 4, zero);
  3383   3383       assert( pWriter->bFirstTermInPage );
  3384   3384     }
  3385   3385     if( p->rc ) return;
  3386   3386     
  3387   3387     if( pWriter->bFirstTermInPage ){
................................................................................
  3433   3433     /* If the current leaf page is full, flush it to disk. */
  3434   3434     if( pPage->buf.n>=p->pConfig->pgsz ){
  3435   3435       fts5WriteFlushLeaf(p, pWriter);
  3436   3436     }
  3437   3437   }
  3438   3438   
  3439   3439   /*
  3440         -** Append a docid and position-list size field to the writers output. 
         3440  +** Append a rowid and position-list size field to the writers output. 
  3441   3441   */
  3442   3442   static void fts5WriteAppendRowid(
  3443   3443     Fts5Index *p, 
  3444   3444     Fts5SegWriter *pWriter,
  3445   3445     i64 iRowid,
  3446   3446     int nPos
  3447   3447   ){
  3448   3448     if( p->rc==SQLITE_OK ){
  3449   3449       Fts5PageWriter *pPage = &pWriter->writer;
  3450   3450   
  3451         -    /* If this is to be the first docid written to the page, set the 
  3452         -    ** docid-pointer in the page-header. Also append a value to the dlidx
         3451  +    /* If this is to be the first rowid written to the page, set the 
         3452  +    ** rowid-pointer in the page-header. Also append a value to the dlidx
  3453   3453       ** buffer, in case a doclist-index is required.  */
  3454   3454       if( pWriter->bFirstRowidInPage ){
  3455   3455         fts5PutU16(pPage->buf.p, pPage->buf.n);
  3456   3456         fts5WriteDlidxAppend(p, pWriter, iRowid);
  3457   3457       }
  3458   3458   
  3459         -    /* Write the docid. */
         3459  +    /* Write the rowid. */
  3460   3460       if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){
  3461   3461         fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid);
  3462   3462       }else{
  3463   3463         assert( p->rc || iRowid>pWriter->iPrevRowid );
  3464   3464         fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid - pWriter->iPrevRowid);
  3465   3465       }
  3466   3466       pWriter->iPrevRowid = iRowid;
................................................................................
  3999   3999             int bDummy;
  4000   4000             iOff += fts5GetVarint(&pDoclist[iOff], (u64*)&iDelta);
  4001   4001             nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy);
  4002   4002             nCopy += nPos;
  4003   4003             iRowid += iDelta;
  4004   4004             
  4005   4005             if( writer.bFirstRowidInPage ){
  4006         -            fts5PutU16(&pBuf->p[0], pBuf->n);   /* first docid on page */
         4006  +            fts5PutU16(&pBuf->p[0], pBuf->n);   /* first rowid on page */
  4007   4007               pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);
  4008   4008               writer.bFirstRowidInPage = 0;
  4009   4009               fts5WriteDlidxAppend(p, &writer, iRowid);
  4010   4010             }else{
  4011   4011               pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta);
  4012   4012             }
  4013   4013             assert( pBuf->n<=pBuf->nSpace );
................................................................................
  4605   4605       }
  4606   4606     }
  4607   4607   
  4608   4608     return rc;
  4609   4609   }
  4610   4610   
  4611   4611   /*
  4612         -** Open a new iterator to iterate though all docids that match the 
         4612  +** Open a new iterator to iterate though all rowid that match the 
  4613   4613   ** specified token or token prefix.
  4614   4614   */
  4615   4615   int sqlite3Fts5IndexQuery(
  4616   4616     Fts5Index *p,                   /* FTS index to query */
  4617   4617     const char *pToken, int nToken, /* Token (or prefix) to query for */
  4618   4618     int flags,                      /* Mask of FTS5INDEX_QUERY_X flags */
  4619   4619     Fts5IndexIter **ppIter          /* OUT: New iterator object */

Changes to ext/fts5/fts5_main.c.

  1169   1169       return sqlite3Fts5ExprRowid(pCsr->pExpr);
  1170   1170     }
  1171   1171   }
  1172   1172   
  1173   1173   /* 
  1174   1174   ** This is the xRowid method. The SQLite core calls this routine to
  1175   1175   ** retrieve the rowid for the current row of the result set. fts5
  1176         -** exposes %_content.docid as the rowid for the virtual table. The
         1176  +** exposes %_content.rowid as the rowid for the virtual table. The
  1177   1177   ** rowid should be written to *pRowid.
  1178   1178   */
  1179   1179   static int fts5RowidMethod(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){
  1180   1180     Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;
  1181   1181     int ePlan = pCsr->ePlan;
  1182   1182     
  1183   1183     assert( CsrFlagTest(pCsr, FTS5CSR_EOF)==0 );

Changes to ext/fts5/fts5_vocab.c.

   438    438         break;
   439    439     }
   440    440     return SQLITE_OK;
   441    441   }
   442    442   
   443    443   /* 
   444    444   ** This is the xRowid method. The SQLite core calls this routine to
   445         -** retrieve the rowid for the current row of the result set. fts5
   446         -** exposes %_content.docid as the rowid for the virtual table. The
          445  +** retrieve the rowid for the current row of the result set. The
   447    446   ** rowid should be written to *pRowid.
   448    447   */
   449    448   static int fts5VocabRowidMethod(
   450    449     sqlite3_vtab_cursor *pCursor, 
   451    450     sqlite_int64 *pRowid
   452    451   ){
   453    452     Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;