MySQL 8.0.40
Source Code Documentation
plugin_ngram.cc File Reference
#include <assert.h>
#include <stddef.h>
#include "my_inttypes.h"
#include "mysql/plugin.h"
#include "storage/innobase/include/fts0tokenize.h"

Macros

#define RETURN_IF_ERROR(ret)    if (ret != 0) return ret;
 

Functions

static int ngram_parse (MYSQL_FTPARSER_PARAM *param, const char *doc, int len, MYSQL_FTPARSER_BOOLEAN_INFO *bool_info)
 Parse a document into ngram. More...
 
static int ngram_get_token_size (const CHARSET_INFO *cs, const char *token, int len)
 Get token char size by charset. More...
 
static int ngram_term_convert (MYSQL_FTPARSER_PARAM *param, const char *token, int len, MYSQL_FTPARSER_BOOLEAN_INFO *bool_info)
 Convert term into phrase and handle wildcard. More...
 
static int ngram_parser_parse (MYSQL_FTPARSER_PARAM *param)
 Ngram parser parse document. More...
 
static MYSQL_SYSVAR_INT (token_size, ngram_token_size, PLUGIN_VAR_READONLY, "InnoDB ngram full text plugin parser token size in characters", nullptr, nullptr, 2, 1, 10, 0)
 
 mysql_declare_plugin (ngram_parser)
 Ngram plugin descriptor. More...
 

Variables

static int ngram_token_size
 Ngram token size, by default bigram. More...
 
static struct st_mysql_ftparser ngram_parser_descriptor
 Fulltext ngram parser. More...
 
static SYS_VARngram_system_variables [] = {MYSQL_SYSVAR(token_size), nullptr}
 Ngram plugin system variables. More...
 
 mysql_declare_plugin_end
 

Macro Definition Documentation

◆ RETURN_IF_ERROR

#define RETURN_IF_ERROR (   ret)     if (ret != 0) return ret;

Function Documentation

◆ mysql_declare_plugin()

mysql_declare_plugin ( ngram_parser  )

Ngram plugin descriptor.

< type

< descriptor

< name

< author

< description

< init function (when loaded)

< check uninstall function

< deinit function (when unloaded)

< version

< status variables

< system variables

◆ MYSQL_SYSVAR_INT()

static MYSQL_SYSVAR_INT ( token_size  ,
ngram_token_size  ,
PLUGIN_VAR_READONLY  ,
"InnoDB ngram full text plugin parser token size in characters"  ,
nullptr  ,
nullptr  ,
,
,
10  ,
 
)
static

◆ ngram_get_token_size()

static int ngram_get_token_size ( const CHARSET_INFO cs,
const char *  token,
int  len 
)
static

Get token char size by charset.

Parameters
[in]cscharset
[in]tokentoken
[in]lentoken length in bytes
Return values
sizein number of chars

◆ ngram_parse()

static int ngram_parse ( MYSQL_FTPARSER_PARAM param,
const char *  doc,
int  len,
MYSQL_FTPARSER_BOOLEAN_INFO bool_info 
)
static

Parse a document into ngram.

Parameters
[in]paramplugin parser param
[in]docdocument to parse
[in]lendocument length in bytes
[in,out]bool_infoboolean info
Return values
0on success
1on failure.

◆ ngram_parser_parse()

static int ngram_parser_parse ( MYSQL_FTPARSER_PARAM param)
static

Ngram parser parse document.

Parameters
[in]paramplugin parser param
Return values
0on success
1on failure.

◆ ngram_term_convert()

static int ngram_term_convert ( MYSQL_FTPARSER_PARAM param,
const char *  token,
int  len,
MYSQL_FTPARSER_BOOLEAN_INFO bool_info 
)
static

Convert term into phrase and handle wildcard.

Parameters
[in]paramplugin parser param
[in]tokentoken to parse
[in]lentoken length in bytes
[in,out]bool_infoboolean info
Return values
0on success
1on failure.

Variable Documentation

◆ mysql_declare_plugin_end

mysql_declare_plugin_end

◆ ngram_parser_descriptor

struct st_mysql_ftparser ngram_parser_descriptor
static
Initial value:
= {
#define MYSQL_FTPARSER_INTERFACE_VERSION
Definition: plugin.h:655
static int ngram_parser_parse(MYSQL_FTPARSER_PARAM *param)
Ngram parser parse document.
Definition: plugin_ngram.cc:199

Fulltext ngram parser.

◆ ngram_system_variables

SYS_VAR* ngram_system_variables[] = {MYSQL_SYSVAR(token_size), nullptr}
static

Ngram plugin system variables.

◆ ngram_token_size

int ngram_token_size
static

Ngram token size, by default bigram.