/ Check-in [7e0f861b]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Add a comment to the FTS getAbsoluteLevel() function. No actual code changes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fts4-incr-merge
Files: files | file ages | folders
SHA1: 7e0f861beda4d74d0c3c9fb4abb3ddb5fee346bd
User & Date: dan 2012-03-16 14:54:07
Context
2012-03-16
15:54
Fix some integer overflow problems that can occur when using large langauge id values. check-in: 3475092c user: dan tags: fts4-incr-merge
14:54
Add a comment to the FTS getAbsoluteLevel() function. No actual code changes. check-in: 7e0f861b user: dan tags: fts4-incr-merge
2012-03-15
17:45
Modify incremental merge code to merge nMin segments at a time. check-in: cd34bc1a user: dan tags: fts4-incr-merge
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3_write.c.

   477    477     }else{
   478    478       rc = SQLITE_OK;
   479    479     }
   480    480   
   481    481     return rc;
   482    482   }
   483    483   
          484  +/*
          485  +** FTS maintains a separate indexes for each language-id (a 32-bit integer).
          486  +** Within each language id, a separate index is maintained to store the
          487  +** document terms, and each configured prefix size (configured the FTS 
          488  +** "prefix=" option). And each index consists of multiple levels ("relative
          489  +** levels").
          490  +**
          491  +** All three of these values (the language id, the specific index and the
          492  +** level within the index) are encoded in 64-bit integer values stored
          493  +** in the %_segdir table on disk. This function is used to convert three
          494  +** separate component values into the single 64-bit integer value that
          495  +** can be used to query the %_segdir table.
          496  +**
          497  +** Specifically, each language-id/index combination is allocated 1024 
          498  +** 64-bit integer level values ("absolute levels"). The main terms index
          499  +** for language-id 0 is allocate values 0-1023. The first prefix index
          500  +** (if any) for language-id 0 is allocated values 1024-2047. And so on.
          501  +** Language 1 indexes are allocated immediately following language 0.
          502  +**
          503  +** So, for a system with nPrefix prefix indexes configured, the block of
          504  +** absolute levels that corresponds to language-id iLangid and index 
          505  +** iIndex starts at absolute level ((iLangid * (nPrefix+1) + iIndex) * 1024).
          506  +*/
   484    507   static sqlite3_int64 getAbsoluteLevel(
   485         -  Fts3Table *p, 
   486         -  int iLangid, 
   487         -  int iIndex, 
   488         -  int iLevel
          508  +  Fts3Table *p,                   /* FTS3 table handle */
          509  +  int iLangid,                    /* Language id */
          510  +  int iIndex,                     /* Index in p->aIndex[] */
          511  +  int iLevel                      /* Level of segments */
   489    512   ){
   490    513     assert( iLangid>=0 );
   491    514     assert( p->nIndex>0 );
   492    515     assert( iIndex>=0 && iIndex<p->nIndex );
   493    516     return (iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL + iLevel;
   494    517   }
   495    518