1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Remove some unused code from fts3. Add tests to fts3matchinfo.test.

FossilOrigin-Name: ae40b34cf7c24c9601bdfb5cbe5b20f05a376ea8
This commit is contained in:
dan
2010-11-24 11:51:56 +00:00
parent 1e66e40eb9
commit ad3acbbfb3
7 changed files with 168 additions and 96 deletions

View File

@ -2255,8 +2255,8 @@ static int fts3PhraseSelect(
for(ii=0; ii<pPhrase->nToken; ii++){
Fts3PhraseToken *pTok; /* Token to find doclist for */
int iTok; /* The token being queried this iteration */
char *pList; /* Pointer to token doclist */
int nList; /* Size of buffer at pList */
char *pList = 0; /* Pointer to token doclist */
int nList = 0; /* Size of buffer at pList */
/* Select a token to process. If this is an xFilter() call, then tokens
** are processed in order from least to most costly. Otherwise, tokens
@ -3275,7 +3275,10 @@ static void fts3MatchinfoFunc(
Fts3Cursor *pCsr; /* Cursor handle passed through apVal[0] */
assert( nVal==1 || nVal==2 );
if( SQLITE_OK==fts3FunctionArg(pContext, "matchinfo", apVal[0], &pCsr) ){
const char *zArg = (nVal>1 ? sqlite3_value_text(apVal[1]) : 0);
const char *zArg = 0;
if( nVal>1 ){
zArg = (const char *)sqlite3_value_text(apVal[1]);
}
sqlite3Fts3Matchinfo(pContext, pCsr, zArg);
}
}

View File

@ -291,8 +291,6 @@ int sqlite3Fts3SegReaderIterate(
);
int sqlite3Fts3SegReaderCost(Fts3Cursor *, Fts3SegReader *, int *);
int sqlite3Fts3AllSegdirs(Fts3Table*, sqlite3_stmt **);
int sqlite3Fts3MatchinfoDocsizeLocal(Fts3Cursor*, u32*);
int sqlite3Fts3MatchinfoDocsizeGlobal(Fts3Cursor*, u32*);
int sqlite3Fts3ReadLock(Fts3Table *);
int sqlite3Fts3ReadBlock(Fts3Table*, sqlite3_int64, char **, int*);

View File

@ -819,6 +819,12 @@ static void fts3LoadColumnlistCounts(char **pp, u32 *aOut, int isGlobal){
** where X is the number of matches for phrase iPhrase is column iCol of all
** rows of the table. Y is the number of rows for which column iCol contains
** at least one instance of phrase iPhrase.
**
** If the phrase pExpr consists entirely of deferred tokens, then all X and
** Y values are set to nDoc, where nDoc is the number of documents in the
** file system. This is done because the full-text index doclist is required
** to calculate these values properly, and the full-text index doclist is
** not available for deferred tokens.
*/
static int fts3ExprGlobalHitsCb(
Fts3Expr *pExpr, /* Phrase expression node */
@ -903,13 +909,13 @@ static int fts3MatchinfoCheck(
char cArg,
char **pzErr
){
if( cArg==FTS3_MATCHINFO_NPHRASE
|| cArg==FTS3_MATCHINFO_NCOL
|| cArg==FTS3_MATCHINFO_NDOC && pTab->bHasStat
|| cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bHasStat
|| cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize
|| cArg==FTS3_MATCHINFO_LCS
|| cArg==FTS3_MATCHINFO_HITS
if( (cArg==FTS3_MATCHINFO_NPHRASE)
|| (cArg==FTS3_MATCHINFO_NCOL)
|| (cArg==FTS3_MATCHINFO_NDOC && pTab->bHasStat)
|| (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bHasStat)
|| (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)
|| (cArg==FTS3_MATCHINFO_LCS)
|| (cArg==FTS3_MATCHINFO_HITS)
){
return SQLITE_OK;
}
@ -1182,7 +1188,7 @@ void sqlite3Fts3Snippet(
** columns of the FTS3 table. Otherwise, only column iCol is considered.
*/
for(iRead=0; iRead<pTab->nColumn; iRead++){
SnippetFragment sF;
SnippetFragment sF = {0, 0, 0, 0};
int iS;
if( iCol>=0 && iRead!=iCol ) continue;

View File

@ -2488,75 +2488,6 @@ static void fts3DecodeIntArray(
}
}
/*
** Fill in the document size auxiliary information for the matchinfo
** structure. The auxiliary information is:
**
** N Total number of documents in the full-text index
** a0 Average length of column 0 over the whole index
** n0 Length of column 0 on the matching row
** ...
** aM Average length of column M over the whole index
** nM Length of column M on the matching row
**
** The fts3MatchinfoDocsizeLocal() routine fills in the nX values.
** The fts3MatchinfoDocsizeGlobal() routine fills in N and the aX values.
*/
int sqlite3Fts3MatchinfoDocsizeLocal(Fts3Cursor *pCur, u32 *a){
const char *pBlob; /* The BLOB holding %_docsize info */
int nBlob; /* Size of the BLOB */
sqlite3_stmt *pStmt; /* Statement for reading and writing */
int i, j; /* Loop counters */
sqlite3_int64 x; /* Varint value */
int rc; /* Result code from subfunctions */
Fts3Table *p; /* The FTS table */
p = (Fts3Table*)pCur->base.pVtab;
rc = fts3SqlStmt(p, SQL_SELECT_DOCSIZE, &pStmt, 0);
if( rc ){
return rc;
}
sqlite3_bind_int64(pStmt, 1, pCur->iPrevId);
if( sqlite3_step(pStmt)==SQLITE_ROW ){
nBlob = sqlite3_column_bytes(pStmt, 0);
pBlob = (const char*)sqlite3_column_blob(pStmt, 0);
for(i=j=0; i<p->nColumn && j<nBlob; i++){
j = sqlite3Fts3GetVarint(&pBlob[j], &x);
a[2+i*2] = (u32)(x & 0xffffffff);
}
}
sqlite3_reset(pStmt);
return SQLITE_OK;
}
int sqlite3Fts3MatchinfoDocsizeGlobal(Fts3Cursor *pCur, u32 *a){
const char *pBlob; /* The BLOB holding %_stat info */
int nBlob; /* Size of the BLOB */
sqlite3_stmt *pStmt; /* Statement for reading and writing */
int i, j; /* Loop counters */
sqlite3_int64 x; /* Varint value */
int nDoc; /* Number of documents */
int rc; /* Result code from subfunctions */
Fts3Table *p; /* The FTS table */
p = (Fts3Table*)pCur->base.pVtab;
rc = fts3SqlStmt(p, SQL_SELECT_DOCTOTAL, &pStmt, 0);
if( rc ){
return rc;
}
if( sqlite3_step(pStmt)==SQLITE_ROW ){
nBlob = sqlite3_column_bytes(pStmt, 0);
pBlob = (const char*)sqlite3_column_blob(pStmt, 0);
j = sqlite3Fts3GetVarint(pBlob, &x);
a[0] = nDoc = (u32)(x & 0xffffffff);
for(i=0; i<p->nColumn && j<nBlob; i++){
j = sqlite3Fts3GetVarint(&pBlob[j], &x);
a[1+i*2] = ((u32)(x & 0xffffffff) + nDoc/2)/nDoc;
}
}
sqlite3_reset(pStmt);
return SQLITE_OK;
}
/*
** Insert the sizes (in tokens) for each column of the document
** with docid equal to p->iPrevDocid. The sizes are encoded as