mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Further optimizations for the 'y' and 'b' matchinfo operators.
FossilOrigin-Name: fbd038bb57322e1ed2e1ee52f3d134594b6bfcc0
This commit is contained in:
@@ -238,27 +238,28 @@ static void fts3GetDeltaPosition(char **pp, int *piPos){
|
|||||||
*piPos += (iVal-2);
|
*piPos += (iVal-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int fts3ExprLHitsCb(Fts3Expr*, int, void*);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Helper function for fts3ExprIterate() (see below).
|
** Helper function for fts3ExprIterate() (see below).
|
||||||
*/
|
*/
|
||||||
static int fts3ExprIterate2(
|
static int fts3ExprIterate2(
|
||||||
Fts3Expr *pExpr, /* Expression to iterate phrases of */
|
Fts3Expr *pExpr, /* Expression to iterate phrases of */
|
||||||
int bExcludeEof,
|
|
||||||
int *piPhrase, /* Pointer to phrase counter */
|
int *piPhrase, /* Pointer to phrase counter */
|
||||||
int (*x)(Fts3Expr*,int,void*), /* Callback function to invoke for phrases */
|
int (*x)(Fts3Expr*,int,void*), /* Callback function to invoke for phrases */
|
||||||
void *pCtx /* Second argument to pass to callback */
|
void *pCtx /* Second argument to pass to callback */
|
||||||
){
|
){
|
||||||
int rc; /* Return code */
|
int rc; /* Return code */
|
||||||
|
|
||||||
if( bExcludeEof && pExpr->bEof ){
|
if( x==fts3ExprLHitsCb && pExpr->bEof ){
|
||||||
rc = SQLITE_OK;
|
rc = SQLITE_OK;
|
||||||
}else{
|
}else{
|
||||||
int eType = pExpr->eType; /* Type of expression node pExpr */
|
int eType = pExpr->eType; /* Type of expression node pExpr */
|
||||||
if( eType!=FTSQUERY_PHRASE ){
|
if( eType!=FTSQUERY_PHRASE ){
|
||||||
assert( pExpr->pLeft && pExpr->pRight );
|
assert( pExpr->pLeft && pExpr->pRight );
|
||||||
rc = fts3ExprIterate2(pExpr->pLeft, bExcludeEof, piPhrase, x, pCtx);
|
rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx);
|
||||||
if( rc==SQLITE_OK && eType!=FTSQUERY_NOT ){
|
if( rc==SQLITE_OK && eType!=FTSQUERY_NOT ){
|
||||||
rc = fts3ExprIterate2(pExpr->pRight, bExcludeEof, piPhrase, x, pCtx);
|
rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
rc = x(pExpr, *piPhrase, pCtx);
|
rc = x(pExpr, *piPhrase, pCtx);
|
||||||
@@ -280,12 +281,11 @@ static int fts3ExprIterate2(
|
|||||||
*/
|
*/
|
||||||
static int fts3ExprIterate(
|
static int fts3ExprIterate(
|
||||||
Fts3Expr *pExpr, /* Expression to iterate phrases of */
|
Fts3Expr *pExpr, /* Expression to iterate phrases of */
|
||||||
int bExcludeEof, /* Include nodes already at EOF */
|
|
||||||
int (*x)(Fts3Expr*,int,void*), /* Callback function to invoke for phrases */
|
int (*x)(Fts3Expr*,int,void*), /* Callback function to invoke for phrases */
|
||||||
void *pCtx /* Second argument to pass to callback */
|
void *pCtx /* Second argument to pass to callback */
|
||||||
){
|
){
|
||||||
int iPhrase = 0; /* Variable used as the phrase counter */
|
int iPhrase = 0; /* Variable used as the phrase counter */
|
||||||
return fts3ExprIterate2(pExpr, bExcludeEof, &iPhrase, x, pCtx);
|
return fts3ExprIterate2(pExpr, &iPhrase, x, pCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -324,7 +324,7 @@ static int fts3ExprLoadDoclists(
|
|||||||
int rc; /* Return Code */
|
int rc; /* Return Code */
|
||||||
LoadDoclistCtx sCtx = {0,0,0}; /* Context for fts3ExprIterate() */
|
LoadDoclistCtx sCtx = {0,0,0}; /* Context for fts3ExprIterate() */
|
||||||
sCtx.pCsr = pCsr;
|
sCtx.pCsr = pCsr;
|
||||||
rc = fts3ExprIterate(pCsr->pExpr, 0, fts3ExprLoadDoclistsCb, (void *)&sCtx);
|
rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx);
|
||||||
if( pnPhrase ) *pnPhrase = sCtx.nPhrase;
|
if( pnPhrase ) *pnPhrase = sCtx.nPhrase;
|
||||||
if( pnToken ) *pnToken = sCtx.nToken;
|
if( pnToken ) *pnToken = sCtx.nToken;
|
||||||
return rc;
|
return rc;
|
||||||
@@ -338,7 +338,7 @@ static int fts3ExprPhraseCountCb(Fts3Expr *pExpr, int iPhrase, void *ctx){
|
|||||||
}
|
}
|
||||||
static int fts3ExprPhraseCount(Fts3Expr *pExpr){
|
static int fts3ExprPhraseCount(Fts3Expr *pExpr){
|
||||||
int nPhrase = 0;
|
int nPhrase = 0;
|
||||||
(void)fts3ExprIterate(pExpr, 0, fts3ExprPhraseCountCb, (void *)&nPhrase);
|
(void)fts3ExprIterate(pExpr, fts3ExprPhraseCountCb, (void *)&nPhrase);
|
||||||
return nPhrase;
|
return nPhrase;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -554,7 +554,7 @@ static int fts3BestSnippet(
|
|||||||
sIter.nSnippet = nSnippet;
|
sIter.nSnippet = nSnippet;
|
||||||
sIter.nPhrase = nList;
|
sIter.nPhrase = nList;
|
||||||
sIter.iCurrent = -1;
|
sIter.iCurrent = -1;
|
||||||
rc = fts3ExprIterate(pCsr->pExpr, 0, fts3SnippetFindPositions, (void*)&sIter);
|
rc = fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void*)&sIter);
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
|
|
||||||
/* Set the *pmSeen output variable. */
|
/* Set the *pmSeen output variable. */
|
||||||
@@ -923,7 +923,7 @@ static int fts3ExprLocalHitsCb(
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
** fts3ExprIterate() callback used to gather information for the matchinfo
|
** fts3ExprIterate() callback used to gather information for the matchinfo
|
||||||
** directive 'y'.
|
** directives 'y' and 'b'.
|
||||||
*/
|
*/
|
||||||
static int fts3ExprLHitsCb(
|
static int fts3ExprLHitsCb(
|
||||||
Fts3Expr *pExpr, /* Phrase expression node */
|
Fts3Expr *pExpr, /* Phrase expression node */
|
||||||
@@ -1124,7 +1124,7 @@ static int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){
|
|||||||
aIter = sqlite3_malloc(sizeof(LcsIterator) * pCsr->nPhrase);
|
aIter = sqlite3_malloc(sizeof(LcsIterator) * pCsr->nPhrase);
|
||||||
if( !aIter ) return SQLITE_NOMEM;
|
if( !aIter ) return SQLITE_NOMEM;
|
||||||
memset(aIter, 0, sizeof(LcsIterator) * pCsr->nPhrase);
|
memset(aIter, 0, sizeof(LcsIterator) * pCsr->nPhrase);
|
||||||
(void)fts3ExprIterate(pCsr->pExpr, 0, fts3MatchinfoLcsCb, (void*)aIter);
|
(void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);
|
||||||
|
|
||||||
for(i=0; i<pInfo->nPhrase; i++){
|
for(i=0; i<pInfo->nPhrase; i++){
|
||||||
LcsIterator *pIter = &aIter[i];
|
LcsIterator *pIter = &aIter[i];
|
||||||
@@ -1272,7 +1272,7 @@ static int fts3MatchinfoValues(
|
|||||||
case FTS3_MATCHINFO_LHITS: {
|
case FTS3_MATCHINFO_LHITS: {
|
||||||
int nZero = fts3MatchinfoSize(pInfo, zArg[i]) * sizeof(u32);
|
int nZero = fts3MatchinfoSize(pInfo, zArg[i]) * sizeof(u32);
|
||||||
memset(pInfo->aMatchinfo, 0, nZero);
|
memset(pInfo->aMatchinfo, 0, nZero);
|
||||||
(void)fts3ExprIterate(pCsr->pExpr, 1, fts3ExprLHitsCb, (void*)pInfo);
|
(void)fts3ExprIterate(pCsr->pExpr, fts3ExprLHitsCb, (void*)pInfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1287,10 +1287,10 @@ static int fts3MatchinfoValues(
|
|||||||
rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc, 0);
|
rc = fts3MatchinfoSelectDoctotal(pTab, &pSelect, &pInfo->nDoc, 0);
|
||||||
if( rc!=SQLITE_OK ) break;
|
if( rc!=SQLITE_OK ) break;
|
||||||
}
|
}
|
||||||
rc = fts3ExprIterate(pExpr, 0, fts3ExprGlobalHitsCb,(void*)pInfo);
|
rc = fts3ExprIterate(pExpr, fts3ExprGlobalHitsCb,(void*)pInfo);
|
||||||
if( rc!=SQLITE_OK ) break;
|
if( rc!=SQLITE_OK ) break;
|
||||||
}
|
}
|
||||||
(void)fts3ExprIterate(pExpr, 0, fts3ExprLocalHitsCb,(void*)pInfo);
|
(void)fts3ExprIterate(pExpr, fts3ExprLocalHitsCb,(void*)pInfo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1348,6 +1348,12 @@ static int fts3GetMatchinfo(
|
|||||||
|
|
||||||
/* Determine the number of integers in the buffer returned by this call. */
|
/* Determine the number of integers in the buffer returned by this call. */
|
||||||
for(i=0; zArg[i]; i++){
|
for(i=0; zArg[i]; i++){
|
||||||
|
char *zErr = 0;
|
||||||
|
if( fts3MatchinfoCheck(pTab, zArg[i], &zErr) ){
|
||||||
|
sqlite3_result_error(pCtx, zErr, -1);
|
||||||
|
sqlite3_free(zErr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
nMatchinfo += fts3MatchinfoSize(&sInfo, zArg[i]);
|
nMatchinfo += fts3MatchinfoSize(&sInfo, zArg[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1589,7 +1595,7 @@ void sqlite3Fts3Offsets(
|
|||||||
*/
|
*/
|
||||||
sCtx.iCol = iCol;
|
sCtx.iCol = iCol;
|
||||||
sCtx.iTerm = 0;
|
sCtx.iTerm = 0;
|
||||||
(void)fts3ExprIterate(pCsr->pExpr, 0, fts3ExprTermOffsetInit, (void*)&sCtx);
|
(void)fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx);
|
||||||
|
|
||||||
/* Retreive the text stored in column iCol. If an SQL NULL is stored
|
/* Retreive the text stored in column iCol. If an SQL NULL is stored
|
||||||
** in column iCol, jump immediately to the next iteration of the loop.
|
** in column iCol, jump immediately to the next iteration of the loop.
|
||||||
@@ -1681,19 +1687,10 @@ void sqlite3Fts3Matchinfo(
|
|||||||
const char *zArg /* Second arg to matchinfo() function */
|
const char *zArg /* Second arg to matchinfo() function */
|
||||||
){
|
){
|
||||||
Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
|
Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
|
||||||
int rc;
|
|
||||||
int i;
|
|
||||||
const char *zFormat;
|
const char *zFormat;
|
||||||
|
int rc;
|
||||||
|
|
||||||
if( zArg ){
|
if( zArg ){
|
||||||
for(i=0; zArg[i]; i++){
|
|
||||||
char *zErr = 0;
|
|
||||||
if( fts3MatchinfoCheck(pTab, zArg[i], &zErr) ){
|
|
||||||
sqlite3_result_error(pContext, zErr, -1);
|
|
||||||
sqlite3_free(zErr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
zFormat = zArg;
|
zFormat = zArg;
|
||||||
}else{
|
}else{
|
||||||
zFormat = FTS3_MATCHINFO_DEFAULT;
|
zFormat = FTS3_MATCHINFO_DEFAULT;
|
||||||
@@ -1702,11 +1699,11 @@ void sqlite3Fts3Matchinfo(
|
|||||||
if( !pCsr->pExpr ){
|
if( !pCsr->pExpr ){
|
||||||
sqlite3_result_blob(pContext, "", 0, SQLITE_STATIC);
|
sqlite3_result_blob(pContext, "", 0, SQLITE_STATIC);
|
||||||
return;
|
return;
|
||||||
|
}else{
|
||||||
|
/* Retrieve matchinfo() data. */
|
||||||
|
rc = fts3GetMatchinfo(pContext, pCsr, zFormat);
|
||||||
|
sqlite3Fts3SegmentsClose(pTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Retrieve matchinfo() data. */
|
|
||||||
rc = fts3GetMatchinfo(pContext, pCsr, zFormat);
|
|
||||||
sqlite3Fts3SegmentsClose(pTab);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Add\sthe\sfts3\smatchinfo\s'b'\sflag.
|
C Further\soptimizations\sfor\sthe\s'y'\sand\s'b'\smatchinfo\soperators.
|
||||||
D 2015-05-05T20:39:53.730
|
D 2015-05-06T08:43:26.741
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1
|
F Makefile.in 08728ecbeddca339c77bfd564d3484b523dffdb1
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -87,7 +87,7 @@ F ext/fts3/fts3_hash.c 29b986e43f4e9dd40110eafa377dc0d63c422c60
|
|||||||
F ext/fts3/fts3_hash.h 39cf6874dc239d6b4e30479b1975fe5b22a3caaf
|
F ext/fts3/fts3_hash.h 39cf6874dc239d6b4e30479b1975fe5b22a3caaf
|
||||||
F ext/fts3/fts3_icu.c e319e108661147bcca8dd511cd562f33a1ba81b5
|
F ext/fts3/fts3_icu.c e319e108661147bcca8dd511cd562f33a1ba81b5
|
||||||
F ext/fts3/fts3_porter.c 3565faf04b626cddf85f03825e86056a4562c009
|
F ext/fts3/fts3_porter.c 3565faf04b626cddf85f03825e86056a4562c009
|
||||||
F ext/fts3/fts3_snippet.c 2224cdfddd4825c449bab0420549b76963f5e444
|
F ext/fts3/fts3_snippet.c e03db2f3eb878849aa95e9638873d057be9aad39
|
||||||
F ext/fts3/fts3_term.c 88c55a6fa1a51ab494e33dced0401a6c28791fd7
|
F ext/fts3/fts3_term.c 88c55a6fa1a51ab494e33dced0401a6c28791fd7
|
||||||
F ext/fts3/fts3_test.c 8a3a78c4458b2d7c631fcf4b152a5cd656fa7038
|
F ext/fts3/fts3_test.c 8a3a78c4458b2d7c631fcf4b152a5cd656fa7038
|
||||||
F ext/fts3/fts3_tokenize_vtab.c a27593ab19657166f6fa5ec073b678cc29a75860
|
F ext/fts3/fts3_tokenize_vtab.c a27593ab19657166f6fa5ec073b678cc29a75860
|
||||||
@@ -1256,7 +1256,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P dddd7e182943a1d3a9d32830e819a63f1a228d6d
|
P b9b77972d88171e4239b8194f308eb5d60b5d172
|
||||||
R 163d76f4b269e89cdb470ec09f3dac69
|
R 34e6b7f6ad3a1ef38f2174c145dcb2ec
|
||||||
U dan
|
U dan
|
||||||
Z 5b29ad8a6cfef6f4d3b7a8b71870984c
|
Z b623aae8ea84248dd7625f093d4e05ab
|
||||||
|
@@ -1 +1 @@
|
|||||||
b9b77972d88171e4239b8194f308eb5d60b5d172
|
fbd038bb57322e1ed2e1ee52f3d134594b6bfcc0
|
Reference in New Issue
Block a user