SQLite

Check-in [46b2d3cef5]
Login

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

Overview
Comment:Remove some dead code from fts3_snippet.c.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | fts3-matchinfo-y
Files: files | file ages | folders
SHA1: 46b2d3cef5c22a9e6bd0a4f8411f17b7ec72bd18
User & Date: dan 2015-05-06 17:51:59.283
Context
2015-05-06
18:15
Merge latest trunk changes with this branch. (check-in: 8a13e1fdbe user: dan tags: fts3-matchinfo-y)
17:51
Remove some dead code from fts3_snippet.c. (check-in: 46b2d3cef5 user: dan tags: fts3-matchinfo-y)
17:41
More optimization for the 'y' and 'b' matchinfo directives. (check-in: 8c5b9fedfc user: dan tags: fts3-matchinfo-y)
Changes
Side-by-Side Diff Show Whitespace Changes Patch
Changes to ext/fts3/fts3_snippet.c.
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257

258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
234
235
236
237
238
239
240


241
242
243
244
245
246
247
248
249
250




251
252
253
254
255
256
257
258
259
260
261
262

263
264
265
266
267
268
269







-
-










-
-
-
-

+










-







*/
static void fts3GetDeltaPosition(char **pp, int *piPos){
  int iVal;
  *pp += fts3GetVarint32(*pp, &iVal);
  *piPos += (iVal-2);
}

static int fts3ExprLHitsCb(Fts3Expr*, int, void*);

/*
** Helper function for fts3ExprIterate() (see below).
*/
static int fts3ExprIterate2(
  Fts3Expr *pExpr,                /* Expression to iterate phrases of */
  int *piPhrase,                  /* Pointer to phrase counter */
  int (*x)(Fts3Expr*,int,void*),  /* Callback function to invoke for phrases */
  void *pCtx                      /* Second argument to pass to callback */
){
  int rc;                         /* Return code */

  if( x==fts3ExprLHitsCb && pExpr->bEof ){
    rc = SQLITE_OK;
  }else{
    int eType = pExpr->eType;     /* Type of expression node pExpr */

    if( eType!=FTSQUERY_PHRASE ){
      assert( pExpr->pLeft && pExpr->pRight );
      rc = fts3ExprIterate2(pExpr->pLeft, piPhrase, x, pCtx);
      if( rc==SQLITE_OK && eType!=FTSQUERY_NOT ){
        rc = fts3ExprIterate2(pExpr->pRight, piPhrase, x, pCtx);
      }
    }else{
      rc = x(pExpr, *piPhrase, pCtx);
      (*piPhrase)++;
    }
  }
  return rc;
}

/*
** Iterate through all phrase nodes in an FTS3 query, except those that
** are part of a sub-tree that is the right-hand-side of a NOT operator.
** For each phrase node found, the supplied callback function is invoked.
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
962
963
964
965
966
967
968
















































969
970
971
972
973
974
975







-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-







    if( pCsr ){
      p->aMatchinfo[iStart+i*3] = fts3ColumnlistCount(&pCsr);
    }else{
      p->aMatchinfo[iStart+i*3] = 0;
    }
  }

  return rc;
}

/*
** fts3ExprIterate() callback used to gather information for the matchinfo
** directives 'y' and 'b'.
*/
static int fts3ExprLHitsCb(
  Fts3Expr *pExpr,                /* Phrase expression node */
  int iPhrase,                    /* Phrase number */
  void *pCtx                      /* Pointer to MatchInfo structure */
){
  int rc = SQLITE_OK;
  MatchInfo *p = (MatchInfo *)pCtx;
  
  /* This must be a phrase */
  assert( pExpr->pPhrase );

  if( pExpr->iDocid==p->pCursor->iPrevId ){
    Fts3Table *pTab = (Fts3Table *)p->pCursor->base.pVtab;
    int iStart;
    Fts3Phrase *pPhrase = pExpr->pPhrase;
    char *pIter = pPhrase->doclist.pList;
    int iCol = 0;

    assert( p->flag==FTS3_MATCHINFO_LHITS_BM || p->flag==FTS3_MATCHINFO_LHITS );
    if( p->flag==FTS3_MATCHINFO_LHITS ){
      iStart = iPhrase * p->nCol;
    }else{
      iStart = iPhrase * ((p->nCol + 31) / 32);
    }

    while( 1 ){
      int nHit = fts3ColumnlistCount(&pIter);
      if( (pPhrase->iColumn>=pTab->nColumn || pPhrase->iColumn==iCol) ){
        if( p->flag==FTS3_MATCHINFO_LHITS ){
          p->aMatchinfo[iStart + iCol] = (u32)nHit;
        }else if( nHit ){
          p->aMatchinfo[iStart + (iCol+1)/32] |= (1 << (iCol&0x1F));
        }
      }
      assert( *pIter==0x00 || *pIter==0x01 );
      if( *pIter!=0x01 ) break;
      pIter++;
      pIter += fts3GetVarint32(pIter, &iCol);
    }
  }

  return rc;
}

static int fts3MatchinfoCheck(
  Fts3Table *pTab, 
  char cArg,
  char **pzErr