@@ -267,16 +267,6 @@ struct fts_word_freq_t {
267267 double idf; /* !< Inverse document frequency */
268268};
269269
270- /* *******************************************************************
271- Callback function to fetch the rows in an FTS INDEX record.
272- @return always TRUE */
273- static
274- ibool
275- fts_query_index_fetch_nodes (
276- /* ========================*/
277- void * row, /* !< in: sel_node_t* */
278- void * user_arg); /* !< in: pointer to ib_vector_t */
279-
280270/* *******************************************************************
281271Read and filter nodes.
282272@return fts_node_t instance */
@@ -318,14 +308,11 @@ static bool node_query_processor(
318308 const rec_offs* offsets, void * user_arg)
319309{
320310 fts_query_t * query= static_cast <fts_query_t *>(user_arg);
321- fts_string_t key;
322311 ulint word_len;
323312 const byte* word_data = rec_get_nth_field (rec, offsets, 0 , &word_len);
324313 if (!word_data || word_len == UNIV_SQL_NULL ||
325314 word_len > FTS_MAX_WORD_LEN)
326315 return true ;
327- key.f_str = const_cast <byte*>(word_data);
328- key.f_len = word_len;
329316 ut_a (query->cur_node ->type == FTS_AST_TERM
330317 || query->cur_node ->type == FTS_AST_TEXT
331318 || query->cur_node ->type == FTS_AST_PARSER_PHRASE_LIST);
@@ -2517,7 +2504,6 @@ fts_query_phrase_search(
25172504 /* Ignore empty strings. */
25182505 if (num_token > 0 ) {
25192506 fts_string_t * token = NULL ;
2520- fts_fetch_t fetch;
25212507 trx_t * trx = query->trx ;
25222508 fts_ast_oper_t oper = query->oper ;
25232509 ulint i;
@@ -2554,11 +2540,6 @@ fts_query_phrase_search(
25542540 }
25552541 }
25562542
2557- /* Setup the callback args for filtering and consolidating
2558- the ilist. */
2559- fetch.read_arg = query;
2560- fetch.read_record = fts_query_index_fetch_nodes;
2561-
25622543 for (i = 0 ; i < num_token; i++) {
25632544 /* Search for the first word from the phrase. */
25642545 token = static_cast <fts_string_t *>(
@@ -3030,156 +3011,6 @@ fts_query_filter_doc_ids(
30303011 }
30313012}
30323013
3033- /* ****************************************************************/ /* *
3034- Read the FTS INDEX row.
3035- @return DB_SUCCESS if all go well. */
3036- static
3037- dberr_t
3038- fts_query_read_node (
3039- /* ================*/
3040- fts_query_t * query, /* !< in: query instance */
3041- const fts_string_t * word, /* !< in: current word */
3042- que_node_t * exp) /* !< in: query graph node */
3043- {
3044- int i;
3045- int ret;
3046- fts_node_t node;
3047- ib_rbt_bound_t parent;
3048- fts_word_freq_t * word_freq;
3049- ibool skip = FALSE ;
3050- fts_string_t term;
3051- byte buf[FTS_MAX_WORD_LEN + 1 ];
3052- dberr_t error = DB_SUCCESS;
3053-
3054- ut_a (query->cur_node ->type == FTS_AST_TERM
3055- || query->cur_node ->type == FTS_AST_TEXT
3056- || query->cur_node ->type == FTS_AST_PARSER_PHRASE_LIST);
3057-
3058- memset (&node, 0 , sizeof (node));
3059- term.f_str = buf;
3060-
3061- /* Need to consider the wildcard search case, the word frequency
3062- is created on the search string not the actual word. So we need
3063- to assign the frequency on search string behalf. */
3064- if (query->cur_node ->type == FTS_AST_TERM
3065- && query->cur_node ->term .wildcard ) {
3066-
3067- term.f_len = query->cur_node ->term .ptr ->len ;
3068- ut_ad (FTS_MAX_WORD_LEN >= term.f_len );
3069- memcpy (term.f_str , query->cur_node ->term .ptr ->str , term.f_len );
3070- } else {
3071- term.f_len = word->f_len ;
3072- ut_ad (FTS_MAX_WORD_LEN >= word->f_len );
3073- memcpy (term.f_str , word->f_str , word->f_len );
3074- }
3075-
3076- /* Lookup the word in our rb tree, it must exist. */
3077- ret = rbt_search (query->word_freqs , &parent, &term);
3078-
3079- ut_a (ret == 0 );
3080-
3081- word_freq = rbt_value (fts_word_freq_t , parent.last );
3082-
3083- /* Start from 1 since the first column has been read by the caller.
3084- Also, we rely on the order of the columns projected, to filter
3085- out ilists that are out of range and we always want to read
3086- the doc_count irrespective of the suitability of the row. */
3087-
3088- for (i = 1 ; exp && !skip; exp = que_node_get_next (exp), ++i) {
3089-
3090- dfield_t * dfield = que_node_get_val (exp);
3091- byte* data = static_cast <byte*>(
3092- dfield_get_data (dfield));
3093- ulint len = dfield_get_len (dfield);
3094-
3095- ut_a (len != UNIV_SQL_NULL);
3096-
3097- /* Note: The column numbers below must match the SELECT. */
3098-
3099- switch (i) {
3100- case 1 : /* DOC_COUNT */
3101- word_freq->doc_count += mach_read_from_4 (data);
3102- break ;
3103-
3104- case 2 : /* FIRST_DOC_ID */
3105- node.first_doc_id = fts_read_doc_id (data);
3106-
3107- /* Skip nodes whose doc ids are out range. */
3108- if (query->oper == FTS_EXIST
3109- && query->upper_doc_id > 0
3110- && node.first_doc_id > query->upper_doc_id ) {
3111- skip = TRUE ;
3112- }
3113- break ;
3114-
3115- case 3 : /* LAST_DOC_ID */
3116- node.last_doc_id = fts_read_doc_id (data);
3117-
3118- /* Skip nodes whose doc ids are out range. */
3119- if (query->oper == FTS_EXIST
3120- && query->lower_doc_id > 0
3121- && node.last_doc_id < query->lower_doc_id ) {
3122- skip = TRUE ;
3123- }
3124- break ;
3125-
3126- case 4 : /* ILIST */
3127-
3128- error = fts_query_filter_doc_ids (
3129- query, &word_freq->word , word_freq,
3130- &node, data, len, FALSE );
3131-
3132- break ;
3133-
3134- default :
3135- ut_error;
3136- }
3137- }
3138-
3139- if (!skip) {
3140- /* Make sure all columns were read. */
3141-
3142- ut_a (i == 5 );
3143- }
3144-
3145- return error;
3146- }
3147-
3148- /* ****************************************************************/ /* *
3149- Callback function to fetch the rows in an FTS INDEX record.
3150- @return always returns TRUE */
3151- static
3152- ibool
3153- fts_query_index_fetch_nodes (
3154- /* ========================*/
3155- void * row, /* !< in: sel_node_t* */
3156- void * user_arg) /* !< in: pointer to fts_fetch_t */
3157- {
3158- fts_string_t key;
3159- sel_node_t * sel_node = static_cast <sel_node_t *>(row);
3160- fts_fetch_t * fetch = static_cast <fts_fetch_t *>(user_arg);
3161- fts_query_t * query = static_cast <fts_query_t *>(fetch->read_arg );
3162- que_node_t * exp = sel_node->select_list ;
3163- dfield_t * dfield = que_node_get_val (exp);
3164- void * data = dfield_get_data (dfield);
3165- ulint dfield_len = dfield_get_len (dfield);
3166-
3167- key.f_str = static_cast <byte*>(data);
3168- key.f_len = dfield_len;
3169-
3170- ut_a (dfield_len <= FTS_MAX_WORD_LEN);
3171-
3172- /* Note: we pass error out by 'query->error' */
3173- query->error = fts_query_read_node (query, &key, que_node_get_next (exp));
3174-
3175- if (query->error != DB_SUCCESS) {
3176- ut_ad (query->error == DB_FTS_EXCEED_RESULT_CACHE_LIMIT);
3177- return (FALSE );
3178- } else {
3179- return (TRUE );
3180- }
3181- }
3182-
31833014/* ****************************************************************/ /* *
31843015Calculate the inverse document frequency (IDF) for all the terms. */
31853016static
0 commit comments