fts2.c File Reference

Go to the source code of this file.

Classes

struct  DataBuffer
struct  StringBuffer
struct  DLReader
struct  DLWriter
struct  PLReader
struct  PLWriter
struct  DLCollector
struct  OrderedDLReader
struct  QueryTerm
struct  Query
struct  Snippet
struct  Snippet::snippetMatch
struct  fulltext_vtab
struct  fulltext_cursor
struct  Token
struct  TableSpec
struct  InteriorBlock
struct  InteriorWriter
struct  InteriorReader
struct  LeafWriter
struct  LeafReader
struct  LeavesReader
struct  TermData
struct  OptLeavesReader

Defines

#define TRACE(A)
#define MERGE_COUNT   16
#define CLEAR(b)   memset(b, '\0', sizeof(*(b)))
#define SCRAMBLE(b)
#define VARINT_MAX   10
#define ASSERT_VALID_DOCLIST(i, p, n, o)   assert( 1 )
#define LEAF_SELECT   "select block from %_segments where rowid between ? and ? order by rowid"
#define kPendingThreshold   (1*1024*1024)
#define TOKEN_EOF   0
#define TOKEN_SPACE   1
#define TOKEN_ID   2
#define TOKEN_STRING   3
#define TOKEN_PUNCT   4
#define IdChar(C)   (((c=C)&0x80)!=0 || (c>0x1f && isIdChar[c-0x20]))
#define FTS2_ROTOR_SZ   (32)
#define FTS2_ROTOR_MASK   (FTS2_ROTOR_SZ-1)
#define SNIPPET_IGNORE   0
#define SNIPPET_DESIRED   1
#define INTERIOR_MAX   2048
#define INTERIOR_MIN_TERMS   7
#define ROOT_MAX   1024
#define ASSERT_VALID_INTERIOR_BLOCK(x)   assert( 1 )
#define STANDALONE_MIN   1024
#define LEAF_MAX   2048
#define ASSERT_VALID_LEAF_NODE(p, n)   assert( 1 )

Typedefs

typedef struct fulltext_vtab fulltext_vtab

Enumerations

enum  DocListType {
  DL_DOCIDS, DL_POSITIONS, DL_POSITIONS_OFFSETS, DL_DOCIDS,
  DL_POSITIONS, DL_POSITIONS_OFFSETS, DL_DOCIDS, DL_POSITIONS,
  DL_POSITIONS_OFFSETS
}
enum  { POS_END = 0, POS_COLUMN, POS_BASE }
enum  QueryType {
  QUERY_GENERIC, QUERY_ROWID, QUERY_FULLTEXT, QUERY_GENERIC,
  QUERY_ROWID, QUERY_FULLTEXT, QUERY_GENERIC, QUERY_DOCID,
  QUERY_FULLTEXT
}
enum  fulltext_statement {
  CONTENT_INSERT_STMT, CONTENT_SELECT_STMT, CONTENT_UPDATE_STMT, CONTENT_DELETE_STMT,
  TERM_SELECT_STMT, TERM_SELECT_ALL_STMT, TERM_INSERT_STMT, TERM_UPDATE_STMT,
  TERM_DELETE_STMT, MAX_STMT, CONTENT_INSERT_STMT, CONTENT_SELECT_STMT,
  CONTENT_UPDATE_STMT, CONTENT_DELETE_STMT, CONTENT_EXISTS_STMT, BLOCK_INSERT_STMT,
  BLOCK_SELECT_STMT, BLOCK_DELETE_STMT, BLOCK_DELETE_ALL_STMT, SEGDIR_MAX_INDEX_STMT,
  SEGDIR_SET_STMT, SEGDIR_SELECT_LEVEL_STMT, SEGDIR_SPAN_STMT, SEGDIR_DELETE_STMT,
  SEGDIR_SELECT_SEGMENT_STMT, SEGDIR_SELECT_ALL_STMT, SEGDIR_DELETE_ALL_STMT, SEGDIR_COUNT_STMT,
  MAX_STMT, CONTENT_INSERT_STMT, CONTENT_SELECT_STMT, CONTENT_UPDATE_STMT,
  CONTENT_DELETE_STMT, CONTENT_EXISTS_STMT, BLOCK_INSERT_STMT, BLOCK_SELECT_STMT,
  BLOCK_DELETE_STMT, BLOCK_DELETE_ALL_STMT, SEGDIR_MAX_INDEX_STMT, SEGDIR_SET_STMT,
  SEGDIR_SELECT_LEVEL_STMT, SEGDIR_SPAN_STMT, SEGDIR_DELETE_STMT, SEGDIR_SELECT_SEGMENT_STMT,
  SEGDIR_SELECT_ALL_STMT, SEGDIR_DELETE_ALL_STMT, SEGDIR_COUNT_STMT, MAX_STMT
}

Functions

static int safe_isspace (char c)
static int safe_tolower (char c)
static int safe_isalnum (char c)
static int putVarint (char *p, sqlite_int64 v)
static int getVarint (const char *p, sqlite_int64 *v)
static int getVarint32 (const char *p, int *pi)
static void dataBufferInit (DataBuffer *pBuffer, int nCapacity)
static void dataBufferReset (DataBuffer *pBuffer)
static void dataBufferDestroy (DataBuffer *pBuffer)
static void dataBufferSwap (DataBuffer *pBuffer1, DataBuffer *pBuffer2)
static void dataBufferExpand (DataBuffer *pBuffer, int nAddCapacity)
static void dataBufferAppend (DataBuffer *pBuffer, const char *pSource, int nSource)
static void dataBufferAppend2 (DataBuffer *pBuffer, const char *pSource1, int nSource1, const char *pSource2, int nSource2)
static void dataBufferReplace (DataBuffer *pBuffer, const char *pSource, int nSource)
static void initStringBuffer (StringBuffer *sb)
static int stringBufferLength (StringBuffer *sb)
static char * stringBufferData (StringBuffer *sb)
static void stringBufferDestroy (StringBuffer *sb)
static void nappend (StringBuffer *sb, const char *zFrom, int nFrom)
static void append (StringBuffer *sb, const char *zFrom)
static void appendList (StringBuffer *sb, int nString, char **azString)
static int endsInWhiteSpace (StringBuffer *p)
static void appendWhiteSpace (StringBuffer *p)
static void trimWhiteSpace (StringBuffer *p)
static int dlrAtEnd (DLReader *pReader)
static sqlite_int64 dlrDocid (DLReader *pReader)
static const char * dlrDocData (DLReader *pReader)
static int dlrDocDataBytes (DLReader *pReader)
static int dlrAllDataBytes (DLReader *pReader)
static const char * dlrPosData (DLReader *pReader)
static int dlrPosDataLen (DLReader *pReader)
static void dlrStep (DLReader *pReader)
static void dlrInit (DLReader *pReader, DocListType iType, const char *pData, int nData)
static void dlrDestroy (DLReader *pReader)
static void dlwInit (DLWriter *pWriter, DocListType iType, DataBuffer *b)
static void dlwDestroy (DLWriter *pWriter)
static void dlwAppend (DLWriter *pWriter, const char *pData, int nData, sqlite_int64 iFirstDocid, sqlite_int64 iLastDocid)
static void dlwCopy (DLWriter *pWriter, DLReader *pReader)
static void dlwAdd (DLWriter *pWriter, sqlite_int64 iDocid)
static int plrAtEnd (PLReader *pReader)
static int plrColumn (PLReader *pReader)
static int plrPosition (PLReader *pReader)
static int plrStartOffset (PLReader *pReader)
static int plrEndOffset (PLReader *pReader)
static void plrStep (PLReader *pReader)
static void plrInit (PLReader *pReader, DLReader *pDLReader)
static void plrDestroy (PLReader *pReader)
static void plwAdd (PLWriter *pWriter, int iColumn, int iPos, int iStartOffset, int iEndOffset)
static void plwCopy (PLWriter *pWriter, PLReader *pReader)
static void plwInit (PLWriter *pWriter, DLWriter *dlw, sqlite_int64 iDocid)
static void plwTerminate (PLWriter *pWriter)
static void plwDestroy (PLWriter *pWriter)
static void dlcAddDoclist (DLCollector *pCollector, DataBuffer *b)
static void dlcNext (DLCollector *pCollector, sqlite_int64 iDocid)
static void dlcAddPos (DLCollector *pCollector, int iColumn, int iPos, int iStartOffset, int iEndOffset)
static DLCollectordlcNew (sqlite_int64 iDocid, DocListType iType)
static void dlcDelete (DLCollector *pCollector)
static void docListTrim (DocListType iType, const char *pData, int nData, int iColumn, DocListType iOutType, DataBuffer *out)
static int orderedDLReaderCmp (OrderedDLReader *r1, OrderedDLReader *r2)
static void orderedDLReaderReorder (OrderedDLReader *p, int n)
static void docListMerge (DataBuffer *out, DLReader *pReaders, int nReaders)
static int posListCmp (PLReader *pLeft, PLReader *pRight)
static void posListUnion (DLReader *pLeft, DLReader *pRight, DLWriter *pOut)
static void docListUnion (const char *pLeft, int nLeft, const char *pRight, int nRight, DataBuffer *pOut)
static void posListPhraseMerge (DLReader *pLeft, DLReader *pRight, DLWriter *pOut)
static void docListPhraseMerge (const char *pLeft, int nLeft, const char *pRight, int nRight, DocListType iType, DataBuffer *pOut)
static void docListAndMerge (const char *pLeft, int nLeft, const char *pRight, int nRight, DataBuffer *pOut)
static void docListOrMerge (const char *pLeft, int nLeft, const char *pRight, int nRight, DataBuffer *pOut)
static void docListExceptMerge (const char *pLeft, int nLeft, const char *pRight, int nRight, DataBuffer *pOut)
static char * string_dup_n (const char *s, int n)
static char * string_dup (const char *s)
static char * string_format (const char *zFormat, const char *zDb, const char *zName)
static int sql_exec (sqlite3 *db, const char *zDb, const char *zName, const char *zFormat)
static int sql_prepare (sqlite3 *db, const char *zDb, const char *zName, sqlite3_stmt **ppStmt, const char *zFormat)
static struct fulltext_vtabcursor_vtab (fulltext_cursor *c)
static const char * contentInsertStatement (fulltext_vtab *v)
static const char * contentUpdateStatement (fulltext_vtab *v)
static int sql_get_statement (fulltext_vtab *v, fulltext_statement iStmt, sqlite3_stmt **ppStmt)
static int sql_single_step (sqlite3_stmt *s)
static int sql_get_leaf_statement (fulltext_vtab *v, int idx, sqlite3_stmt **ppStmt)
static int content_insert (fulltext_vtab *v, sqlite3_value *rowid, sqlite3_value **pValues)
static int content_update (fulltext_vtab *v, sqlite3_value **pValues, sqlite_int64 iRowid)
static void freeStringArray (int nString, const char **pString)
static int content_select (fulltext_vtab *v, sqlite_int64 iRow, const char ***pValues)
static int content_delete (fulltext_vtab *v, sqlite_int64 iRow)
static int content_exists (fulltext_vtab *v)
static int block_insert (fulltext_vtab *v, const char *pData, int nData, sqlite_int64 *piBlockid)
static int block_delete (fulltext_vtab *v, sqlite_int64 iStartBlockid, sqlite_int64 iEndBlockid)
static int segdir_max_index (fulltext_vtab *v, int iLevel, int *pidx)
static int segdir_set (fulltext_vtab *v, int iLevel, int idx, sqlite_int64 iStartBlockid, sqlite_int64 iLeavesEndBlockid, sqlite_int64 iEndBlockid, const char *pRootData, int nRootData)
static int segdir_span (fulltext_vtab *v, int iLevel, sqlite_int64 *piStartBlockid, sqlite_int64 *piEndBlockid)
static int segdir_delete (fulltext_vtab *v, int iLevel)
static int segdir_delete_all (fulltext_vtab *v)
static int segdir_count (fulltext_vtab *v, int *pnSegments, int *piMaxLevel)
static int clearPendingTerms (fulltext_vtab *v)
static void fulltext_vtab_destroy (fulltext_vtab *v)
static int getToken (const char *z, int *tokenType)
static char ** tokenizeString (const char *z, int *pnToken)
static void dequoteString (char *z)
static void tokenListToIdList (char **azIn)
static char * firstToken (char *zIn, char **pzTail)
static int startsWith (const char *s, const char *t)
static void clearTableSpec (TableSpec *p)
static int parseSpec (TableSpec *pSpec, int argc, const char *const *argv, char **pzErr)
static char * fulltextSchema (int nColumn, const char *const *azColumn, const char *zTableName)
static int constructVtab (sqlite3 *db, fts2Hash *pHash, TableSpec *spec, sqlite3_vtab **ppVTab, char **pzErr)
static int fulltextConnect (sqlite3 *db, void *pAux, int argc, const char *const *argv, sqlite3_vtab **ppVTab, char **pzErr)
static int fulltextCreate (sqlite3 *db, void *pAux, int argc, const char *const *argv, sqlite3_vtab **ppVTab, char **pzErr)
static int fulltextBestIndex (sqlite3_vtab *pVTab, sqlite3_index_info *pInfo)
static int fulltextDisconnect (sqlite3_vtab *pVTab)
static int fulltextDestroy (sqlite3_vtab *pVTab)
static int fulltextOpen (sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor)
static void queryClear (Query *q)
static void snippetClear (Snippet *p)
static void snippetAppendMatch (Snippet *p, int iCol, int iTerm, int iStart, int nByte)
static void snippetOffsetsOfColumn (Query *pQuery, Snippet *pSnippet, int iColumn, const char *zDoc, int nDoc)
static void snippetAllOffsets (fulltext_cursor *p)
static void snippetOffsetText (Snippet *p)
static int wordBoundary (int iBreak, const char *zDoc, int nDoc, struct snippetMatch *aMatch, int nMatch, int iCol)
static void snippetText (fulltext_cursor *pCursor, const char *zStartMark, const char *zEndMark, const char *zEllipsis)
static int fulltextClose (sqlite3_vtab_cursor *pCursor)
static int fulltextNext (sqlite3_vtab_cursor *pCursor)
static int termSelect (fulltext_vtab *v, int iColumn, const char *pTerm, int nTerm, int isPrefix, DocListType iType, DataBuffer *out)
static int docListOfTerm (fulltext_vtab *v, int iColumn, QueryTerm *pQTerm, DataBuffer *pResult)
static void queryAdd (Query *q, const char *pTerm, int nTerm)
static int checkColumnSpecifier (fulltext_vtab *pVtab, const char *zToken, int nToken)
static int tokenizeSegment (sqlite3_tokenizer *pTokenizer, const char *pSegment, int nSegment, int inPhrase, Query *pQuery)
static int parseQuery (fulltext_vtab *v, const char *zInput, int nInput, int dfltColumn, Query *pQuery)
static int flushPendingTerms (fulltext_vtab *v)
static int fulltextQuery (fulltext_vtab *v, int iColumn, const char *zInput, int nInput, DataBuffer *pResult, Query *pQuery)
static int fulltextFilter (sqlite3_vtab_cursor *pCursor, int idxNum, const char *idxStr, int argc, sqlite3_value **argv)
static int fulltextEof (sqlite3_vtab_cursor *pCursor)
static int fulltextColumn (sqlite3_vtab_cursor *pCursor, sqlite3_context *pContext, int idxCol)
static int fulltextRowid (sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid)
static int buildTerms (fulltext_vtab *v, sqlite_int64 iDocid, const char *zText, int iColumn)
static int insertTerms (fulltext_vtab *v, sqlite_int64 iRowid, sqlite3_value **pValues)
static int deleteTerms (fulltext_vtab *v, sqlite_int64 iRowid)
static int initPendingTerms (fulltext_vtab *v, sqlite_int64 iDocid)
static int index_insert (fulltext_vtab *v, sqlite3_value *pRequestRowid, sqlite3_value **pValues, sqlite_int64 *piRowid)
static int index_delete (fulltext_vtab *v, sqlite_int64 iRow)
static int index_update (fulltext_vtab *v, sqlite_int64 iRow, sqlite3_value **pValues)
static InteriorBlockinteriorBlockNew (int iHeight, sqlite_int64 iChildBlock, const char *pTerm, int nTerm)
static void interiorWriterInit (int iHeight, const char *pTerm, int nTerm, sqlite_int64 iChildBlock, InteriorWriter *pWriter)
static void interiorWriterAppend (InteriorWriter *pWriter, const char *pTerm, int nTerm, sqlite_int64 iChildBlock)
static int interiorWriterDestroy (InteriorWriter *pWriter)
static int interiorWriterRootInfo (fulltext_vtab *v, InteriorWriter *pWriter, char **ppRootInfo, int *pnRootInfo, sqlite_int64 *piEndBlockid)
static void interiorReaderDestroy (InteriorReader *pReader)
static void interiorReaderInit (const char *pData, int nData, InteriorReader *pReader)
static int interiorReaderAtEnd (InteriorReader *pReader)
static sqlite_int64 interiorReaderCurrentBlockid (InteriorReader *pReader)
static int interiorReaderTermBytes (InteriorReader *pReader)
static const char * interiorReaderTerm (InteriorReader *pReader)
static void interiorReaderStep (InteriorReader *pReader)
static int interiorReaderTermCmp (InteriorReader *pReader, const char *pTerm, int nTerm, int isPrefix)
static void leafWriterInit (int iLevel, int idx, LeafWriter *pWriter)
static int leafWriterInternalFlush (fulltext_vtab *v, LeafWriter *pWriter, int iData, int nData)
static int leafWriterFlush (fulltext_vtab *v, LeafWriter *pWriter)
static int leafWriterRootInfo (fulltext_vtab *v, LeafWriter *pWriter, char **ppRootInfo, int *pnRootInfo, sqlite_int64 *piEndBlockid)
static int leafWriterFinalize (fulltext_vtab *v, LeafWriter *pWriter)
static void leafWriterDestroy (LeafWriter *pWriter)
static int leafWriterEncodeTerm (LeafWriter *pWriter, const char *pTerm, int nTerm)
static int leafWriterInlineFlush (fulltext_vtab *v, LeafWriter *pWriter, const char *pTerm, int nTerm, int iDoclistData)
static int leafWriterStepMerge (fulltext_vtab *v, LeafWriter *pWriter, const char *pTerm, int nTerm, DLReader *pReaders, int nReaders)
static int leafWriterStep (fulltext_vtab *v, LeafWriter *pWriter, const char *pTerm, int nTerm, const char *pData, int nData)
static void leafReaderDestroy (LeafReader *pReader)
static int leafReaderAtEnd (LeafReader *pReader)
static int leafReaderTermBytes (LeafReader *pReader)
static const char * leafReaderTerm (LeafReader *pReader)
static int leafReaderDataBytes (LeafReader *pReader)
static const char * leafReaderData (LeafReader *pReader)
static void leafReaderInit (const char *pData, int nData, LeafReader *pReader)
static void leafReaderStep (LeafReader *pReader)
static int leafReaderTermCmp (LeafReader *pReader, const char *pTerm, int nTerm, int isPrefix)
static int leavesReaderTermBytes (LeavesReader *pReader)
static const char * leavesReaderTerm (LeavesReader *pReader)
static int leavesReaderDataBytes (LeavesReader *pReader)
static const char * leavesReaderData (LeavesReader *pReader)
static int leavesReaderAtEnd (LeavesReader *pReader)
static int leavesReaderReset (LeavesReader *pReader)
static void leavesReaderDestroy (LeavesReader *pReader)
static int leavesReaderInit (fulltext_vtab *v, int idx, sqlite_int64 iStartBlockid, sqlite_int64 iEndBlockid, const char *pRootData, int nRootData, LeavesReader *pReader)
static int leavesReaderStep (fulltext_vtab *v, LeavesReader *pReader)
static int leavesReaderTermCmp (LeavesReader *lr1, LeavesReader *lr2)
static int leavesReaderCmp (LeavesReader *lr1, LeavesReader *lr2)
static void leavesReaderReorder (LeavesReader *pLr, int nLr)
static int leavesReadersInit (fulltext_vtab *v, int iLevel, LeavesReader *pReaders, int *piReaders)
static int leavesReadersMerge (fulltext_vtab *v, LeavesReader *pReaders, int nReaders, LeafWriter *pWriter)
static int segmentMerge (fulltext_vtab *v, int iLevel)
static int segdirNextIndex (fulltext_vtab *v, int iLevel, int *pidx)
static void docListAccumulateUnion (DataBuffer *acc, const char *pData, int nData)
static int loadSegmentLeavesInt (fulltext_vtab *v, LeavesReader *pReader, const char *pTerm, int nTerm, int isPrefix, DataBuffer *out)
static int loadSegmentLeaf (fulltext_vtab *v, const char *pData, int nData, const char *pTerm, int nTerm, int isPrefix, DataBuffer *out)
static int loadSegmentLeaves (fulltext_vtab *v, sqlite_int64 iStartLeaf, sqlite_int64 iEndLeaf, const char *pTerm, int nTerm, int isPrefix, DataBuffer *out)
static void getChildrenContaining (const char *pData, int nData, const char *pTerm, int nTerm, int isPrefix, sqlite_int64 *piStartChild, sqlite_int64 *piEndChild)
static int loadAndGetChildrenContaining (fulltext_vtab *v, sqlite_int64 iBlockid, const char *pTerm, int nTerm, int isPrefix, sqlite_int64 *piStartChild, sqlite_int64 *piEndChild)
static int loadSegmentInt (fulltext_vtab *v, const char *pData, int nData, sqlite_int64 iLeavesEnd, const char *pTerm, int nTerm, int isPrefix, DataBuffer *out)
static int loadSegment (fulltext_vtab *v, const char *pData, int nData, sqlite_int64 iLeavesEnd, const char *pTerm, int nTerm, int isPrefix, DataBuffer *out)
static int termDataCmp (const void *av, const void *bv)
static int writeZeroSegment (fulltext_vtab *v, fts2Hash *pTerms)
static int fulltextUpdate (sqlite3_vtab *pVtab, int nArg, sqlite3_value **ppArg, sqlite_int64 *pRowid)
static int fulltextSync (sqlite3_vtab *pVtab)
static int fulltextBegin (sqlite3_vtab *pVtab)
static int fulltextCommit (sqlite3_vtab *pVtab)
static int fulltextRollback (sqlite3_vtab *pVtab)
static void snippetFunc (sqlite3_context *pContext, int argc, sqlite3_value **argv)
static void snippetOffsetsFunc (sqlite3_context *pContext, int argc, sqlite3_value **argv)
static int optLeavesReaderAtEnd (OptLeavesReader *pReader)
static int optLeavesReaderTermBytes (OptLeavesReader *pReader)
static const char * optLeavesReaderData (OptLeavesReader *pReader)
static int optLeavesReaderDataBytes (OptLeavesReader *pReader)
static const char * optLeavesReaderTerm (OptLeavesReader *pReader)
static int optLeavesReaderStep (fulltext_vtab *v, OptLeavesReader *pReader)
static int optLeavesReaderTermCmp (OptLeavesReader *lr1, OptLeavesReader *lr2)
static int optLeavesReaderCmp (OptLeavesReader *lr1, OptLeavesReader *lr2)
static void optLeavesReaderReorder (OptLeavesReader *pLr, int nLr)
static int optimizeInternal (fulltext_vtab *v, OptLeavesReader *readers, int nReaders, LeafWriter *pWriter)
static void optimizeFunc (sqlite3_context *pContext, int argc, sqlite3_value **argv)
static int fulltextFindFunction (sqlite3_vtab *pVtab, int nArg, const char *zName, void(**pxFunc)(sqlite3_context *, int, sqlite3_value **), void **ppArg)
static int fulltextRename (sqlite3_vtab *pVtab, const char *zName)
static void hashDestroy (void *p)
void sqlite3Fts2SimpleTokenizerModule (sqlite3_tokenizer_module const **ppModule)
void sqlite3Fts2PorterTokenizerModule (sqlite3_tokenizer_module const **ppModule)
void sqlite3Fts2IcuTokenizerModule (sqlite3_tokenizer_module const **ppModule)
int sqlite3Fts2InitHashTable (sqlite3 *, fts2Hash *, const char *)
int sqlite3Fts2Init (sqlite3 *db)
int sqlite3_extension_init (sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi)

Variables

static const char *const fulltext_zStatement [MAX_STMT]
static const sqlite3_module fts2Module
static const char isIdChar []

Define Documentation

#define ASSERT_VALID_DOCLIST ( i,
p,
n,
 )     assert( 1 )

Definition at line 738 of file fts2.c.

Referenced by dlwAppend(), and leafWriterStepMerge().

#define ASSERT_VALID_INTERIOR_BLOCK (  )     assert( 1 )

Definition at line 4159 of file fts2.c.

Referenced by interiorWriterAppend(), interiorWriterInit(), and interiorWriterRootInfo().

#define ASSERT_VALID_LEAF_NODE ( p,
 )     assert( 1 )

Definition at line 4562 of file fts2.c.

Referenced by leafWriterInternalFlush(), and leafWriterStepMerge().

#define CLEAR (  )     memset(b, '\0', sizeof(*(b)))
#define FTS2_ROTOR_MASK   (FTS2_ROTOR_SZ-1)

Definition at line 3073 of file fts2.c.

Referenced by snippetOffsetsOfColumn().

#define FTS2_ROTOR_SZ   (32)

Definition at line 3072 of file fts2.c.

Referenced by snippetOffsetsOfColumn().

#define IdChar (  )     (((c=C)&0x80)!=0 || (c>0x1f && isIdChar[c-0x20]))

Definition at line 2429 of file fts2.c.

#define INTERIOR_MAX   2048

Definition at line 4045 of file fts2.c.

Referenced by interiorBlockNew(), and interiorWriterAppend().

#define INTERIOR_MIN_TERMS   7

Definition at line 4052 of file fts2.c.

Referenced by interiorWriterAppend().

#define kPendingThreshold   (1*1024*1024)

Definition at line 1878 of file fts2.c.

Referenced by initPendingTerms().

#define LEAF_MAX   2048

Definition at line 4466 of file fts2.c.

Referenced by leafWriterInit(), leafWriterStepMerge(), and optimizeInternal().

#define LEAF_SELECT   "select block from %_segments where rowid between ? and ? order by rowid"

Definition at line 1864 of file fts2.c.

Referenced by sql_get_leaf_statement().

#define MERGE_COUNT   16
#define ROOT_MAX   1024

Definition at line 4065 of file fts2.c.

Referenced by interiorWriterRootInfo(), and leafWriterRootInfo().

#define SCRAMBLE (  ) 
#define SNIPPET_DESIRED   1

Definition at line 3255 of file fts2.c.

#define SNIPPET_IGNORE   0

Definition at line 3254 of file fts2.c.

#define STANDALONE_MIN   1024

Definition at line 4463 of file fts2.c.

Referenced by leafWriterStepMerge().

#define TOKEN_EOF   0

Definition at line 2401 of file fts2.c.

#define TOKEN_ID   2

Definition at line 2403 of file fts2.c.

#define TOKEN_PUNCT   4

Definition at line 2405 of file fts2.c.

#define TOKEN_SPACE   1

Definition at line 2402 of file fts2.c.

#define TOKEN_STRING   3

Definition at line 2404 of file fts2.c.

#define TRACE (  ) 

Definition at line 335 of file fts2.c.

#define VARINT_MAX   10

Definition at line 406 of file fts2.c.


Typedef Documentation

typedef struct fulltext_vtab fulltext_vtab

Definition at line 1690 of file fts2.c.


Enumeration Type Documentation

anonymous enum
Enumerator:
POS_END 
POS_COLUMN 
POS_BASE 

Definition at line 376 of file fts2.c.

Enumerator:
DL_DOCIDS 
DL_POSITIONS 
DL_POSITIONS_OFFSETS 
DL_DOCIDS 
DL_POSITIONS 
DL_POSITIONS_OFFSETS 
DL_DOCIDS 
DL_POSITIONS 
DL_POSITIONS_OFFSETS 

Definition at line 357 of file fts2.c.

Enumerator:
CONTENT_INSERT_STMT 
CONTENT_SELECT_STMT 
CONTENT_UPDATE_STMT 
CONTENT_DELETE_STMT 
TERM_SELECT_STMT 
TERM_SELECT_ALL_STMT 
TERM_INSERT_STMT 
TERM_UPDATE_STMT 
TERM_DELETE_STMT 
MAX_STMT 
CONTENT_INSERT_STMT 
CONTENT_SELECT_STMT 
CONTENT_UPDATE_STMT 
CONTENT_DELETE_STMT 
CONTENT_EXISTS_STMT 
BLOCK_INSERT_STMT 
BLOCK_SELECT_STMT 
BLOCK_DELETE_STMT 
BLOCK_DELETE_ALL_STMT 
SEGDIR_MAX_INDEX_STMT 
SEGDIR_SET_STMT 
SEGDIR_SELECT_LEVEL_STMT 
SEGDIR_SPAN_STMT 
SEGDIR_DELETE_STMT 
SEGDIR_SELECT_SEGMENT_STMT 
SEGDIR_SELECT_ALL_STMT 
SEGDIR_DELETE_ALL_STMT 
SEGDIR_COUNT_STMT 
MAX_STMT 
CONTENT_INSERT_STMT 
CONTENT_SELECT_STMT 
CONTENT_UPDATE_STMT 
CONTENT_DELETE_STMT 
CONTENT_EXISTS_STMT 
BLOCK_INSERT_STMT 
BLOCK_SELECT_STMT 
BLOCK_DELETE_STMT 
BLOCK_DELETE_ALL_STMT 
SEGDIR_MAX_INDEX_STMT 
SEGDIR_SET_STMT 
SEGDIR_SELECT_LEVEL_STMT 
SEGDIR_SPAN_STMT 
SEGDIR_DELETE_STMT 
SEGDIR_SELECT_SEGMENT_STMT 
SEGDIR_SELECT_ALL_STMT 
SEGDIR_DELETE_ALL_STMT 
SEGDIR_COUNT_STMT 
MAX_STMT 

Definition at line 1772 of file fts2.c.

enum QueryType
Enumerator:
QUERY_GENERIC 
QUERY_ROWID 
QUERY_FULLTEXT 
QUERY_GENERIC 
QUERY_ROWID 
QUERY_FULLTEXT 
QUERY_GENERIC 
QUERY_DOCID 
QUERY_FULLTEXT 

Definition at line 1766 of file fts2.c.


Function Documentation

static void append ( StringBuffer sb,
const char *  zFrom 
) [static]
static void appendList ( StringBuffer sb,
int  nString,
char **  azString 
) [static]

Definition at line 553 of file fts2.c.

References append().

Referenced by contentInsertStatement(), and fulltextCreate().

static void appendWhiteSpace ( StringBuffer p  )  [static]

Definition at line 569 of file fts2.c.

References append(), endsInWhiteSpace(), and stringBufferLength().

Referenced by snippetText().

static int block_delete ( fulltext_vtab v,
sqlite_int64  iStartBlockid,
sqlite_int64  iEndBlockid 
) [static]

Definition at line 2159 of file fts2.c.

References BLOCK_DELETE_STMT, sql_get_statement(), sql_single_step(), sqlite3_bind_int64(), and SQLITE_OK.

Referenced by segdir_delete().

static int block_insert ( fulltext_vtab v,
const char *  pData,
int  nData,
sqlite_int64 piBlockid 
) [static]
static int buildTerms ( fulltext_vtab v,
sqlite_int64  iDocid,
const char *  zText,
int  iColumn 
) [static]
static int checkColumnSpecifier ( fulltext_vtab pVtab,
const char *  zToken,
int  nToken 
) [static]

Definition at line 3511 of file fts2.c.

References fulltext_vtab::azColumn, and fulltext_vtab::nColumn.

Referenced by tokenizeSegment().

static int clearPendingTerms ( fulltext_vtab v  )  [static]
static void clearTableSpec ( TableSpec p  )  [static]
static int constructVtab ( sqlite3 db,
fts2Hash pHash,
TableSpec spec,
sqlite3_vtab **  ppVTab,
char **  pzErr 
) [static]
static int content_delete ( fulltext_vtab v,
sqlite_int64  iRow 
) [static]

Definition at line 2103 of file fts2.c.

References CONTENT_DELETE_STMT, sql_get_statement(), sql_single_step(), sqlite3_bind_int64(), and SQLITE_OK.

Referenced by index_delete().

static int content_exists ( fulltext_vtab v  )  [static]
static int content_insert ( fulltext_vtab v,
sqlite3_value rowid,
sqlite3_value **  pValues 
) [static]
static int content_select ( fulltext_vtab v,
sqlite_int64  iRow,
const char ***  pValues 
) [static]
static int content_update ( fulltext_vtab v,
sqlite3_value **  pValues,
sqlite_int64  iRowid 
) [static]
static const char* contentInsertStatement ( fulltext_vtab v  )  [static]
static const char* contentUpdateStatement ( fulltext_vtab v  )  [static]
static struct fulltext_vtab* cursor_vtab ( fulltext_cursor c  )  [static, read]

Definition at line 1900 of file fts2.c.

References fulltext_cursor::base, and sqlite3_vtab_cursor::pVtab.

Referenced by fulltextColumn(), fulltextFilter(), and optimizeFunc().

static void dataBufferAppend ( DataBuffer pBuffer,
const char *  pSource,
int  nSource 
) [static]
static void dataBufferAppend2 ( DataBuffer pBuffer,
const char *  pSource1,
int  nSource1,
const char *  pSource2,
int  nSource2 
) [static]
static void dataBufferDestroy ( DataBuffer pBuffer  )  [static]
static void dataBufferExpand ( DataBuffer pBuffer,
int  nAddCapacity 
) [static]
static void dataBufferInit ( DataBuffer pBuffer,
int  nCapacity 
) [static]
static void dataBufferReplace ( DataBuffer pBuffer,
const char *  pSource,
int  nSource 
) [static]
static void dataBufferReset ( DataBuffer pBuffer  )  [static]
static void dataBufferSwap ( DataBuffer pBuffer1,
DataBuffer pBuffer2 
) [static]

Definition at line 483 of file fts2.c.

Referenced by loadSegmentLeavesInt().

static int deleteTerms ( fulltext_vtab v,
sqlite_int64  iRowid 
) [static]
static void dequoteString ( char *  z  )  [static]

Definition at line 2551 of file fts2.c.

Referenced by firstToken(), and tokenListToIdList().

static void dlcAddDoclist ( DLCollector pCollector,
DataBuffer b 
) [static]
static void dlcAddPos ( DLCollector pCollector,
int  iColumn,
int  iPos,
int  iStartOffset,
int  iEndOffset 
) [static]

Definition at line 1085 of file fts2.c.

References DLCollector::plw, and plwAdd().

Referenced by buildTerms().

static void dlcDelete ( DLCollector pCollector  )  [static]
static DLCollector* dlcNew ( sqlite_int64  iDocid,
DocListType  iType 
) [static]
static void dlcNext ( DLCollector pCollector,
sqlite_int64  iDocid 
) [static]

Definition at line 1080 of file fts2.c.

References DLCollector::dlw, DLCollector::plw, plwDestroy(), plwInit(), and plwTerminate().

Referenced by buildTerms().

static int dlrAllDataBytes ( DLReader pReader  )  [static]

Definition at line 632 of file fts2.c.

References dlrAtEnd(), and DLReader::nData.

Referenced by docListMerge(), and leafWriterStepMerge().

static int dlrAtEnd ( DLReader pReader  )  [static]
static void dlrDestroy ( DLReader pReader  )  [static]
static const char* dlrDocData ( DLReader pReader  )  [static]

Definition at line 624 of file fts2.c.

References dlrAtEnd(), and DLReader::pData.

Referenced by dlwCopy(), and docListMerge().

static int dlrDocDataBytes ( DLReader pReader  )  [static]

Definition at line 628 of file fts2.c.

References dlrAtEnd(), and DLReader::nElement.

Referenced by dlwCopy(), and docListMerge().

static sqlite_int64 dlrDocid ( DLReader pReader  )  [static]
static void dlrInit ( DLReader pReader,
DocListType  iType,
const char *  pData,
int  nData 
) [static]
static const char* dlrPosData ( DLReader pReader  )  [static]

Definition at line 640 of file fts2.c.

References dlrAtEnd(), getVarint, and DLReader::pData.

Referenced by plrInit().

static int dlrPosDataLen ( DLReader pReader  )  [static]

Definition at line 646 of file fts2.c.

References dlrAtEnd(), getVarint, DLReader::nElement, and DLReader::pData.

Referenced by plrInit().

static void dlrStep ( DLReader pReader  )  [static]
static void dlwAdd ( DLWriter pWriter,
sqlite_int64  iDocid 
) [static]
static void dlwAppend ( DLWriter pWriter,
const char *  pData,
int  nData,
sqlite_int64  iFirstDocid,
sqlite_int64  iLastDocid 
) [static]
static void dlwCopy ( DLWriter pWriter,
DLReader pReader 
) [static]

Definition at line 818 of file fts2.c.

References dlrDocData(), dlrDocDataBytes(), dlrDocid(), and dlwAppend().

Referenced by docListUnion().

static void dlwDestroy ( DLWriter pWriter  )  [static]
static void dlwInit ( DLWriter pWriter,
DocListType  iType,
DataBuffer b 
) [static]
static void docListAccumulateUnion ( DataBuffer acc,
const char *  pData,
int  nData 
) [static]
static void docListAndMerge ( const char *  pLeft,
int  nLeft,
const char *  pRight,
int  nRight,
DataBuffer pOut 
) [static]
static void docListExceptMerge ( const char *  pLeft,
int  nLeft,
const char *  pRight,
int  nRight,
DataBuffer pOut 
) [static]
static void docListMerge ( DataBuffer out,
DLReader pReaders,
int  nReaders 
) [static]
static int docListOfTerm ( fulltext_vtab v,
int  iColumn,
QueryTerm pQTerm,
DataBuffer pResult 
) [static]
static void docListOrMerge ( const char *  pLeft,
int  nLeft,
const char *  pRight,
int  nRight,
DataBuffer pOut 
) [static]
static void docListPhraseMerge ( const char *  pLeft,
int  nLeft,
const char *  pRight,
int  nRight,
DocListType  iType,
DataBuffer pOut 
) [static]
static void docListTrim ( DocListType  iType,
const char *  pData,
int  nData,
int  iColumn,
DocListType  iOutType,
DataBuffer out 
) [static]
static void docListUnion ( const char *  pLeft,
int  nLeft,
const char *  pRight,
int  nRight,
DataBuffer pOut 
) [static]
static int endsInWhiteSpace ( StringBuffer p  )  [static]

Definition at line 561 of file fts2.c.

References safe_isspace(), stringBufferData(), and stringBufferLength().

Referenced by appendWhiteSpace(), and trimWhiteSpace().

static char* firstToken ( char *  zIn,
char **  pzTail 
) [static]

Definition at line 2615 of file fts2.c.

References dequoteString(), getToken(), TOKEN_EOF, TOKEN_SPACE, and ttype.

Referenced by parseSpec().

static int flushPendingTerms ( fulltext_vtab v  )  [static]
static void freeStringArray ( int  nString,
const char **  pString 
) [static]

Definition at line 2048 of file fts2.c.

References sqlite3_free().

Referenced by content_select(), and deleteTerms().

static void fulltext_vtab_destroy ( fulltext_vtab v  )  [static]
static int fulltextBegin ( sqlite3_vtab pVtab  )  [static]

Definition at line 5934 of file fts2.c.

References clearPendingTerms(), fulltext_vtab::nPendingData, and TRACE.

static int fulltextBestIndex ( sqlite3_vtab pVTab,
sqlite3_index_info pInfo 
) [static]
static int fulltextClose ( sqlite3_vtab_cursor pCursor  )  [static]
static int fulltextColumn ( sqlite3_vtab_cursor pCursor,
sqlite3_context pContext,
int  idxCol 
) [static]
static int fulltextCommit ( sqlite3_vtab pVtab  )  [static]

Definition at line 5945 of file fts2.c.

References clearPendingTerms(), fulltext_vtab::nPendingData, and TRACE.

static int fulltextConnect ( sqlite3 db,
void *  pAux,
int  argc,
const char *const *  argv,
sqlite3_vtab **  ppVTab,
char **  pzErr 
) [static]

Definition at line 2885 of file fts2.c.

References clearTableSpec(), constructVtab(), parseSpec(), and SQLITE_OK.

static int fulltextCreate ( sqlite3 db,
void *  pAux,
int  argc,
const char *const *  argv,
sqlite3_vtab **  ppVTab,
char **  pzErr 
) [static]
static int fulltextDestroy ( sqlite3_vtab pVTab  )  [static]
static int fulltextDisconnect ( sqlite3_vtab pVTab  )  [static]

Definition at line 2984 of file fts2.c.

References fulltext_vtab_destroy(), SQLITE_OK, and TRACE.

static int fulltextEof ( sqlite3_vtab_cursor pCursor  )  [static]

Definition at line 3850 of file fts2.c.

References fulltext_cursor::eof.

static int fulltextFilter ( sqlite3_vtab_cursor pCursor,
int  idxNum,
const char *  idxStr,
int  argc,
sqlite3_value **  argv 
) [static]
static int fulltextFindFunction ( sqlite3_vtab pVtab,
int  nArg,
const char *  zName,
void(**)(sqlite3_context *, int, sqlite3_value **)  pxFunc,
void **  ppArg 
) [static]

Definition at line 6679 of file fts2.c.

References optimizeFunc(), snippetFunc(), and snippetOffsetsFunc().

static int fulltextNext ( sqlite3_vtab_cursor pCursor  )  [static]
static int fulltextOpen ( sqlite3_vtab pVTab,
sqlite3_vtab_cursor **  ppCursor 
) [static]

Definition at line 3006 of file fts2.c.

References fulltext_cursor::base, sqlite3_malloc(), SQLITE_NOMEM, SQLITE_OK, and TRACE.

static int fulltextQuery ( fulltext_vtab v,
int  iColumn,
const char *  zInput,
int  nInput,
DataBuffer pResult,
Query pQuery 
) [static]
static int fulltextRename ( sqlite3_vtab pVtab,
const char *  zName 
) [static]
static int fulltextRollback ( sqlite3_vtab pVtab  )  [static]

Definition at line 5954 of file fts2.c.

References clearPendingTerms(), and TRACE.

static int fulltextRowid ( sqlite3_vtab_cursor pCursor,
sqlite_int64 pRowid 
) [static]

Definition at line 3882 of file fts2.c.

References fulltext_cursor::pStmt, sqlite3_column_int64(), and SQLITE_OK.

static char* fulltextSchema ( int  nColumn,
const char *const *  azColumn,
const char *  zTableName 
) [static]

Definition at line 2782 of file fts2.c.

References sqlite3_free(), and sqlite3_mprintf().

Referenced by constructVtab().

static int fulltextSync ( sqlite3_vtab pVtab  )  [static]

Definition at line 5929 of file fts2.c.

References flushPendingTerms(), and TRACE.

static int fulltextUpdate ( sqlite3_vtab pVtab,
int  nArg,
sqlite3_value **  ppArg,
sqlite_int64 pRowid 
) [static]
static void getChildrenContaining ( const char *  pData,
int  nData,
const char *  pTerm,
int  nTerm,
int  isPrefix,
sqlite_int64 piStartChild,
sqlite_int64 piEndChild 
) [static]
static int getToken ( const char *  z,
int *  tokenType 
) [static]

Definition at line 2436 of file fts2.c.

References IdChar, safe_isspace(), TOKEN_EOF, TOKEN_ID, TOKEN_PUNCT, TOKEN_SPACE, and TOKEN_STRING.

Referenced by firstToken(), and tokenizeString().

static int getVarint ( const char *  p,
sqlite_int64 v 
) [static]

Definition at line 426 of file fts2.c.

References VARINT_MAX.

static int getVarint32 ( const char *  p,
int *  pi 
) [static]

Definition at line 442 of file fts2.c.

References getVarint.

static void hashDestroy ( void *  p  )  [static]

Definition at line 6760 of file fts2.c.

References sqlite3_free(), and sqlite3Fts2HashClear().

Referenced by sqlite3Fts2Init().

static int index_delete ( fulltext_vtab v,
sqlite_int64  iRow 
) [static]

Definition at line 4007 of file fts2.c.

References content_delete(), deleteTerms(), initPendingTerms(), and SQLITE_OK.

Referenced by fulltextUpdate().

static int index_insert ( fulltext_vtab v,
sqlite3_value pRequestRowid,
sqlite3_value **  pValues,
sqlite_int64 piRowid 
) [static]
static int index_update ( fulltext_vtab v,
sqlite_int64  iRow,
sqlite3_value **  pValues 
) [static]

Definition at line 4021 of file fts2.c.

References content_update(), deleteTerms(), initPendingTerms(), insertTerms(), and SQLITE_OK.

Referenced by fulltextUpdate().

static int initPendingTerms ( fulltext_vtab v,
sqlite_int64  iDocid 
) [static]
static void initStringBuffer ( StringBuffer sb  )  [static]
static int insertTerms ( fulltext_vtab v,
sqlite_int64  iRowid,
sqlite3_value **  pValues 
) [static]

Definition at line 3951 of file fts2.c.

References buildTerms(), fulltext_vtab::nColumn, sqlite3_value_text(), and SQLITE_OK.

Referenced by index_insert(), and index_update().

static InteriorBlock* interiorBlockNew ( int  iHeight,
sqlite_int64  iChildBlock,
const char *  pTerm,
int  nTerm 
) [static]
static int interiorReaderAtEnd ( InteriorReader pReader  )  [static]
static sqlite_int64 interiorReaderCurrentBlockid ( InteriorReader pReader  )  [static]

Definition at line 4377 of file fts2.c.

References InteriorReader::iBlockid.

Referenced by getChildrenContaining().

static void interiorReaderDestroy ( InteriorReader pReader  )  [static]

Definition at line 4333 of file fts2.c.

References dataBufferDestroy(), SCRAMBLE, and InteriorReader::term.

Referenced by getChildrenContaining().

static void interiorReaderInit ( const char *  pData,
int  nData,
InteriorReader pReader 
) [static]
static void interiorReaderStep ( InteriorReader pReader  )  [static]
static const char* interiorReaderTerm ( InteriorReader pReader  )  [static]

Definition at line 4385 of file fts2.c.

References interiorReaderAtEnd(), DataBuffer::pData, and InteriorReader::term.

Referenced by interiorReaderTermCmp().

static int interiorReaderTermBytes ( InteriorReader pReader  )  [static]

Definition at line 4381 of file fts2.c.

References interiorReaderAtEnd(), DataBuffer::nData, and InteriorReader::term.

Referenced by interiorReaderTermCmp().

static int interiorReaderTermCmp ( InteriorReader pReader,
const char *  pTerm,
int  nTerm,
int  isPrefix 
) [static]

Definition at line 4419 of file fts2.c.

References interiorReaderTerm(), and interiorReaderTermBytes().

Referenced by getChildrenContaining().

static void interiorWriterAppend ( InteriorWriter pWriter,
const char *  pTerm,
int  nTerm,
sqlite_int64  iChildBlock 
) [static]
static int interiorWriterDestroy ( InteriorWriter pWriter  )  [static]
static void interiorWriterInit ( int  iHeight,
const char *  pTerm,
int  nTerm,
sqlite_int64  iChildBlock,
InteriorWriter pWriter 
) [static]
static int interiorWriterRootInfo ( fulltext_vtab v,
InteriorWriter pWriter,
char **  ppRootInfo,
int *  pnRootInfo,
sqlite_int64 piEndBlockid 
) [static]
static int leafReaderAtEnd ( LeafReader pReader  )  [static]

Definition at line 4917 of file fts2.c.

References LeafReader::nData.

Referenced by leafReaderStep(), and leavesReaderStep().

static const char* leafReaderData ( LeafReader pReader  )  [static]

Definition at line 4937 of file fts2.c.

References getVarint32, DataBuffer::nData, LeafReader::pData, and LeafReader::term.

Referenced by leavesReaderData().

static int leafReaderDataBytes ( LeafReader pReader  )  [static]

Definition at line 4931 of file fts2.c.

References getVarint32, DataBuffer::nData, LeafReader::pData, and LeafReader::term.

Referenced by leavesReaderDataBytes().

static void leafReaderDestroy ( LeafReader pReader  )  [static]

Definition at line 4912 of file fts2.c.

References dataBufferDestroy(), SCRAMBLE, and LeafReader::term.

Referenced by leavesReaderDestroy(), and leavesReaderStep().

static void leafReaderInit ( const char *  pData,
int  nData,
LeafReader pReader 
) [static]
static void leafReaderStep ( LeafReader pReader  )  [static]
static const char* leafReaderTerm ( LeafReader pReader  )  [static]

Definition at line 4925 of file fts2.c.

References DataBuffer::nData, DataBuffer::pData, and LeafReader::term.

Referenced by leavesReaderTerm().

static int leafReaderTermBytes ( LeafReader pReader  )  [static]

Definition at line 4922 of file fts2.c.

References DataBuffer::nData, and LeafReader::term.

Referenced by leavesReaderTermBytes().

static int leafReaderTermCmp ( LeafReader pReader,
const char *  pTerm,
int  nTerm,
int  isPrefix 
) [static]

Definition at line 4993 of file fts2.c.

References DataBuffer::nData, DataBuffer::pData, and LeafReader::term.

Referenced by leavesReaderTermCmp(), and loadSegmentLeavesInt().

static void leafWriterDestroy ( LeafWriter pWriter  )  [static]
static int leafWriterEncodeTerm ( LeafWriter pWriter,
const char *  pTerm,
int  nTerm 
) [static]
static int leafWriterFinalize ( fulltext_vtab v,
LeafWriter pWriter 
) [static]
static int leafWriterFlush ( fulltext_vtab v,
LeafWriter pWriter 
) [static]
static void leafWriterInit ( int  iLevel,
int  idx,
LeafWriter pWriter 
) [static]
static int leafWriterInlineFlush ( fulltext_vtab v,
LeafWriter pWriter,
const char *  pTerm,
int  nTerm,
int  iDoclistData 
) [static]
static int leafWriterInternalFlush ( fulltext_vtab v,
LeafWriter pWriter,
int  iData,
int  nData 
) [static]
static int leafWriterRootInfo ( fulltext_vtab v,
LeafWriter pWriter,
char **  ppRootInfo,
int *  pnRootInfo,
sqlite_int64 piEndBlockid 
) [static]
static int leafWriterStep ( fulltext_vtab v,
LeafWriter pWriter,
const char *  pTerm,
int  nTerm,
const char *  pData,
int  nData 
) [static]

Definition at line 4889 of file fts2.c.

References DL_DEFAULT, dlrDestroy(), dlrInit(), and leafWriterStepMerge().

Referenced by optimizeInternal(), and writeZeroSegment().

static int leafWriterStepMerge ( fulltext_vtab v,
LeafWriter pWriter,
const char *  pTerm,
int  nTerm,
DLReader pReaders,
int  nReaders 
) [static]
static int leavesReaderAtEnd ( LeavesReader pReader  )  [static]
static int leavesReaderCmp ( LeavesReader lr1,
LeavesReader lr2 
) [static]

Definition at line 5165 of file fts2.c.

References LeavesReader::idx, and leavesReaderTermCmp().

Referenced by leavesReaderReorder().

static const char* leavesReaderData ( LeavesReader pReader  )  [static]
static int leavesReaderDataBytes ( LeavesReader pReader  )  [static]
static void leavesReaderDestroy ( LeavesReader pReader  )  [static]
static int leavesReaderInit ( fulltext_vtab v,
int  idx,
sqlite_int64  iStartBlockid,
sqlite_int64  iEndBlockid,
const char *  pRootData,
int  nRootData,
LeavesReader pReader 
) [static]
static void leavesReaderReorder ( LeavesReader pLr,
int  nLr 
) [static]

Definition at line 5174 of file fts2.c.

References leavesReaderCmp().

Referenced by leavesReadersInit(), and segmentMerge().

static int leavesReaderReset ( LeavesReader pReader  )  [static]

Definition at line 5060 of file fts2.c.

References LeavesReader::pStmt, and sqlite3_reset().

Referenced by loadSegmentLeaf(), and loadSegmentLeaves().

static int leavesReadersInit ( fulltext_vtab v,
int  iLevel,
LeavesReader pReaders,
int *  piReaders 
) [static]
static int leavesReadersMerge ( fulltext_vtab v,
LeavesReader pReaders,
int  nReaders,
LeafWriter pWriter 
) [static]
static int leavesReaderStep ( fulltext_vtab v,
LeavesReader pReader 
) [static]
static const char* leavesReaderTerm ( LeavesReader pReader  )  [static]
static int leavesReaderTermBytes ( LeavesReader pReader  )  [static]
static int leavesReaderTermCmp ( LeavesReader lr1,
LeavesReader lr2 
) [static]
static int loadAndGetChildrenContaining ( fulltext_vtab v,
sqlite_int64  iBlockid,
const char *  pTerm,
int  nTerm,
int  isPrefix,
sqlite_int64 piStartChild,
sqlite_int64 piEndChild 
) [static]
static int loadSegment ( fulltext_vtab v,
const char *  pData,
int  nData,
sqlite_int64  iLeavesEnd,
const char *  pTerm,
int  nTerm,
int  isPrefix,
DataBuffer out 
) [static]
static int loadSegmentInt ( fulltext_vtab v,
const char *  pData,
int  nData,
sqlite_int64  iLeavesEnd,
const char *  pTerm,
int  nTerm,
int  isPrefix,
DataBuffer out 
) [static]
static int loadSegmentLeaf ( fulltext_vtab v,
const char *  pData,
int  nData,
const char *  pTerm,
int  nTerm,
int  isPrefix,
DataBuffer out 
) [static]
static int loadSegmentLeaves ( fulltext_vtab v,
sqlite_int64  iStartLeaf,
sqlite_int64  iEndLeaf,
const char *  pTerm,
int  nTerm,
int  isPrefix,
DataBuffer out 
) [static]
static int loadSegmentLeavesInt ( fulltext_vtab v,
LeavesReader pReader,
const char *  pTerm,
int  nTerm,
int  isPrefix,
DataBuffer out 
) [static]
static void nappend ( StringBuffer sb,
const char *  zFrom,
int  nFrom 
) [static]

Definition at line 541 of file fts2.c.

References StringBuffer::b, dataBufferAppend2(), and DataBuffer::nData.

Referenced by append(), and snippetText().

static void optimizeFunc ( sqlite3_context pContext,
int  argc,
sqlite3_value **  argv 
) [static]
static int optimizeInternal ( fulltext_vtab v,
OptLeavesReader readers,
int  nReaders,
LeafWriter pWriter 
) [static]
static int optLeavesReaderAtEnd ( OptLeavesReader pReader  )  [static]

Definition at line 6040 of file fts2.c.

References leavesReaderAtEnd(), and OptLeavesReader::reader.

Referenced by optimizeInternal().

static int optLeavesReaderCmp ( OptLeavesReader lr1,
OptLeavesReader lr2 
) [static]

Definition at line 6064 of file fts2.c.

References optLeavesReaderTermCmp(), and OptLeavesReader::segment.

Referenced by optLeavesReaderReorder().

static const char* optLeavesReaderData ( OptLeavesReader pReader  )  [static]

Definition at line 6046 of file fts2.c.

References leavesReaderData(), and OptLeavesReader::reader.

Referenced by optimizeInternal().

static int optLeavesReaderDataBytes ( OptLeavesReader pReader  )  [static]

Definition at line 6049 of file fts2.c.

References leavesReaderDataBytes(), and OptLeavesReader::reader.

Referenced by optimizeInternal().

static void optLeavesReaderReorder ( OptLeavesReader pLr,
int  nLr 
) [static]

Definition at line 6072 of file fts2.c.

References optLeavesReaderCmp().

Referenced by optimizeInternal().

static int optLeavesReaderStep ( fulltext_vtab v,
OptLeavesReader pReader 
) [static]

Definition at line 6055 of file fts2.c.

References leavesReaderStep(), and OptLeavesReader::reader.

Referenced by optimizeInternal().

static const char* optLeavesReaderTerm ( OptLeavesReader pReader  )  [static]

Definition at line 6052 of file fts2.c.

References leavesReaderTerm(), and OptLeavesReader::reader.

Referenced by optimizeInternal().

static int optLeavesReaderTermBytes ( OptLeavesReader pReader  )  [static]

Definition at line 6043 of file fts2.c.

References leavesReaderTermBytes(), and OptLeavesReader::reader.

Referenced by optimizeInternal().

static int optLeavesReaderTermCmp ( OptLeavesReader lr1,
OptLeavesReader lr2 
) [static]

Definition at line 6058 of file fts2.c.

References leavesReaderTermCmp(), and OptLeavesReader::reader.

Referenced by optimizeInternal(), and optLeavesReaderCmp().

static int orderedDLReaderCmp ( OrderedDLReader r1,
OrderedDLReader r2 
) [static]

Definition at line 1170 of file fts2.c.

References dlrAtEnd(), dlrDocid(), OrderedDLReader::idx, and OrderedDLReader::pReader.

Referenced by orderedDLReaderReorder().

static void orderedDLReaderReorder ( OrderedDLReader p,
int  n 
) [static]

Definition at line 1192 of file fts2.c.

References orderedDLReaderCmp().

Referenced by docListMerge().

static int parseQuery ( fulltext_vtab v,
const char *  zInput,
int  nInput,
int  dfltColumn,
Query pQuery 
) [static]
static int parseSpec ( TableSpec pSpec,
int  argc,
const char *const *  argv,
char **  pzErr 
) [static]
static int plrAtEnd ( PLReader pReader  )  [static]
static int plrColumn ( PLReader pReader  )  [static]

Definition at line 865 of file fts2.c.

References PLReader::iColumn, and plrAtEnd().

Referenced by docListTrim(), plwCopy(), posListCmp(), and posListPhraseMerge().

static void plrDestroy ( PLReader pReader  )  [static]

Definition at line 929 of file fts2.c.

References SCRAMBLE.

Referenced by docListTrim(), posListPhraseMerge(), and posListUnion().

static int plrEndOffset ( PLReader pReader  )  [static]

Definition at line 877 of file fts2.c.

References PLReader::iEndOffset, and plrAtEnd().

Referenced by docListTrim(), plwCopy(), and posListCmp().

static void plrInit ( PLReader pReader,
DLReader pDLReader 
) [static]
static int plrPosition ( PLReader pReader  )  [static]

Definition at line 869 of file fts2.c.

References PLReader::iPosition, and plrAtEnd().

Referenced by docListTrim(), plwCopy(), posListCmp(), and posListPhraseMerge().

static int plrStartOffset ( PLReader pReader  )  [static]

Definition at line 873 of file fts2.c.

References PLReader::iStartOffset, and plrAtEnd().

Referenced by docListTrim(), plwCopy(), and posListCmp().

static void plrStep ( PLReader pReader  )  [static]
static void plwAdd ( PLWriter pWriter,
int  iColumn,
int  iPos,
int  iStartOffset,
int  iEndOffset 
) [static]
static void plwCopy ( PLWriter pWriter,
PLReader pReader 
) [static]

Definition at line 1001 of file fts2.c.

References plrColumn(), plrEndOffset(), plrPosition(), plrStartOffset(), and plwAdd().

Referenced by posListUnion().

static void plwDestroy ( PLWriter pWriter  )  [static]

Definition at line 1043 of file fts2.c.

References SCRAMBLE.

Referenced by dlcDelete(), dlcNext(), docListTrim(), posListPhraseMerge(), and posListUnion().

static void plwInit ( PLWriter pWriter,
DLWriter dlw,
sqlite_int64  iDocid 
) [static]
static void plwTerminate ( PLWriter pWriter  )  [static]
static int posListCmp ( PLReader pLeft,
PLReader pRight 
) [static]
static void posListPhraseMerge ( DLReader pLeft,
DLReader pRight,
DLWriter pOut 
) [static]
static void posListUnion ( DLReader pLeft,
DLReader pRight,
DLWriter pOut 
) [static]
static int putVarint ( char *  p,
sqlite_int64  v 
) [static]

Definition at line 411 of file fts2.c.

References VARINT_MAX.

static void queryAdd ( Query q,
const char *  pTerm,
int  nTerm 
) [static]
static void queryClear ( Query q  )  [static]
static int safe_isalnum ( char  c  )  [static]

Definition at line 353 of file fts2.c.

Referenced by parseSpec(), startsWith(), and tokenListToIdList().

static int safe_isspace ( char  c  )  [static]

Definition at line 347 of file fts2.c.

Referenced by endsInWhiteSpace(), getToken(), startsWith(), and wordBoundary().

static int safe_tolower ( char  c  )  [static]

Definition at line 350 of file fts2.c.

Referenced by startsWith().

static int segdir_count ( fulltext_vtab v,
int *  pnSegments,
int *  piMaxLevel 
) [static]
static int segdir_delete ( fulltext_vtab v,
int  iLevel 
) [static]
static int segdir_delete_all ( fulltext_vtab v  )  [static]
static int segdir_max_index ( fulltext_vtab v,
int  iLevel,
int *  pidx 
) [static]
static int segdir_set ( fulltext_vtab v,
int  iLevel,
int  idx,
sqlite_int64  iStartBlockid,
sqlite_int64  iLeavesEndBlockid,
sqlite_int64  iEndBlockid,
const char *  pRootData,
int  nRootData 
) [static]
static int segdir_span ( fulltext_vtab v,
int  iLevel,
sqlite_int64 piStartBlockid,
sqlite_int64 piEndBlockid 
) [static]
static int segdirNextIndex ( fulltext_vtab v,
int  iLevel,
int *  pidx 
) [static]

Definition at line 5257 of file fts2.c.

References MERGE_COUNT, segdir_max_index(), segmentMerge(), SQLITE_DONE, SQLITE_OK, and SQLITE_ROW.

Referenced by segmentMerge(), and writeZeroSegment().

static int segmentMerge ( fulltext_vtab v,
int  iLevel 
) [static]
static void snippetAllOffsets ( fulltext_cursor p  )  [static]
static void snippetAppendMatch ( Snippet p,
int  iCol,
int  iTerm,
int  iStart,
int  nByte 
) [static]

Definition at line 3045 of file fts2.c.

References Snippet::aMatch, Snippet::nAlloc, Snippet::nMatch, and sqlite3_realloc().

Referenced by snippetOffsetsOfColumn().

static void snippetClear ( Snippet p  )  [static]

Definition at line 3036 of file fts2.c.

References Snippet::aMatch, CLEAR, sqlite3_free(), Snippet::zOffset, and Snippet::zSnippet.

Referenced by fulltextClose(), and fulltextNext().

static void snippetFunc ( sqlite3_context pContext,
int  argc,
sqlite3_value **  argv 
) [static]
static void snippetOffsetsFunc ( sqlite3_context pContext,
int  argc,
sqlite3_value **  argv 
) [static]
static void snippetOffsetsOfColumn ( Query pQuery,
Snippet pSnippet,
int  iColumn,
const char *  zDoc,
int  nDoc 
) [static]
static void snippetOffsetText ( Snippet p  )  [static]
static void snippetText ( fulltext_cursor pCursor,
const char *  zStartMark,
const char *  zEndMark,
const char *  zEllipsis 
) [static]
static int sql_exec ( sqlite3 db,
const char *  zDb,
const char *  zName,
const char *  zFormat 
) [static]

Definition at line 1667 of file fts2.c.

References sqlite3_exec(), sqlite3_free(), string_format(), and TRACE.

Referenced by fulltextCreate(), and fulltextDestroy().

static int sql_get_leaf_statement ( fulltext_vtab v,
int  idx,
sqlite3_stmt **  ppStmt 
) [static]
static int sql_get_statement ( fulltext_vtab v,
fulltext_statement  iStmt,
sqlite3_stmt **  ppStmt 
) [static]
static int sql_prepare ( sqlite3 db,
const char *  zDb,
const char *  zName,
sqlite3_stmt **  ppStmt,
const char *  zFormat 
) [static]
static int sql_single_step ( sqlite3_stmt s  )  [static]
int sqlite3_extension_init ( sqlite3 db,
char **  pzErrMsg,
const sqlite3_api_routines pApi 
)

Definition at line 6849 of file fts2.c.

References sqlite3Fts2Init(), and SQLITE_EXTENSION_INIT2.

void sqlite3Fts2IcuTokenizerModule ( sqlite3_tokenizer_module const **  ppModule  ) 

Referenced by sqlite3Fts2Init().

int sqlite3Fts2Init ( sqlite3 db  ) 
int sqlite3Fts2InitHashTable ( sqlite3 ,
fts2Hash ,
const char *   
)
void sqlite3Fts2PorterTokenizerModule ( sqlite3_tokenizer_module const **  ppModule  ) 

Definition at line 636 of file fts2_porter.c.

Referenced by sqlite3Fts2Init().

void sqlite3Fts2SimpleTokenizerModule ( sqlite3_tokenizer_module const **  ppModule  ) 

Definition at line 224 of file fts2_tokenizer1.c.

Referenced by sqlite3Fts2Init().

static int startsWith ( const char *  s,
const char *  t 
) [static]

Definition at line 2645 of file fts2.c.

References safe_isalnum(), safe_isspace(), and safe_tolower().

Referenced by parseSpec().

static char* string_dup ( const char *  s  )  [static]

Definition at line 1626 of file fts2.c.

References string_dup_n().

Referenced by content_select().

static char* string_dup_n ( const char *  s,
int  n 
) [static]

Definition at line 1616 of file fts2.c.

References sqlite3_malloc().

Referenced by string_dup().

static char* string_format ( const char *  zFormat,
const char *  zDb,
const char *  zName 
) [static]

Definition at line 1634 of file fts2.c.

References sqlite3_malloc().

Referenced by sql_exec(), and sql_prepare().

static char* stringBufferData ( StringBuffer sb  )  [static]
static void stringBufferDestroy ( StringBuffer sb  )  [static]

Definition at line 537 of file fts2.c.

References StringBuffer::b, and dataBufferDestroy().

Referenced by fulltextCreate().

static int stringBufferLength ( StringBuffer sb  )  [static]

Definition at line 531 of file fts2.c.

References StringBuffer::b, and DataBuffer::nData.

Referenced by appendWhiteSpace(), endsInWhiteSpace(), snippetOffsetText(), and snippetText().

static int termDataCmp ( const void *  av,
const void *  bv 
) [static]

Definition at line 5766 of file fts2.c.

References TermData::nTerm, and TermData::pTerm.

Referenced by writeZeroSegment().

static int termSelect ( fulltext_vtab v,
int  iColumn,
const char *  pTerm,
int  nTerm,
int  isPrefix,
DocListType  iType,
DataBuffer out 
) [static]
static int tokenizeSegment ( sqlite3_tokenizer pTokenizer,
const char *  pSegment,
int  nSegment,
int  inPhrase,
Query pQuery 
) [static]
static char** tokenizeString ( const char *  z,
int *  pnToken 
) [static]

Definition at line 2504 of file fts2.c.

References getToken(), Token::n, sqlite3_free(), sqlite3_malloc(), TOKEN_SPACE, and Token::z.

Referenced by parseSpec().

static void tokenListToIdList ( char **  azIn  )  [static]

Definition at line 2593 of file fts2.c.

References dequoteString(), and safe_isalnum().

Referenced by parseSpec().

static void trimWhiteSpace ( StringBuffer p  )  [static]

Definition at line 575 of file fts2.c.

References StringBuffer::b, endsInWhiteSpace(), DataBuffer::nData, and DataBuffer::pData.

Referenced by snippetText().

static int wordBoundary ( int  iBreak,
const char *  zDoc,
int  nDoc,
struct snippetMatch *  aMatch,
int  nMatch,
int  iCol 
) [static]

Definition at line 3213 of file fts2.c.

References safe_isspace().

Referenced by snippetText().

static int writeZeroSegment ( fulltext_vtab v,
fts2Hash pTerms 
) [static]

Variable Documentation

static const sqlite3_module fts2Module [static]
const char* const fulltext_zStatement[MAX_STMT] [static]

Definition at line 1802 of file fts2.c.

const char isIdChar[] [static]
Initial value:
 {

    0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,  
    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,  
    0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,  
}

Definition at line 2420 of file fts2.c.


ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:58 2011 by Doxygen 1.6.1