Kouhei Sutou
null+****@clear*****
Mon Nov 17 22:56:02 JST 2014
Kouhei Sutou 2014-11-17 22:56:02 +0900 (Mon, 17 Nov 2014) New Revision: adb675f11108c741ef311229bb3e8c6b34e95645 https://github.com/groonga/groonga/commit/adb675f11108c741ef311229bb3e8c6b34e95645 Message: Rename grn_token_mode to grn_tokenize_mode Because it's not mode for grn_token. It's mode for grn_token_cursor. grn_token_cursor uses it for specifying how to tokenize. Modified files: include/groonga/token.h include/groonga/token_filter.h include/groonga/tokenizer.h lib/db.c lib/grn_token_cursor.h lib/ii.c lib/proc.c lib/token_cursor.c lib/tokenizer.c Modified: include/groonga/token.h (+23 -5) =================================================================== --- include/groonga/token.h 2014-11-17 22:42:12 +0900 (fa24756) +++ include/groonga/token.h 2014-11-17 22:56:02 +0900 (5aeaf0b) @@ -23,6 +23,23 @@ extern "C" { #endif /* __cplusplus */ /* + * grn_tokenize_mode describes propose for tokenization. + * + * `GRN_TOKENIZE_GET`: Tokenize for search. + * + * `GRN_TOKENIZE_ADD`: Tokenize for adding token to index. + * + * `GRN_TOKENIZE_DELETE`: Tokenize for deleting token from index. + * + * @since 4.0.8 + */ +typedef enum { + GRN_TOKENIZE_GET = 0, + GRN_TOKENIZE_ADD, + GRN_TOKENIZE_DELETE +} grn_tokenize_mode; + +/* grn_token_mode describes propose for tokenization. `GRN_TOKEN_GET`: Tokenization for search. @@ -32,12 +49,13 @@ extern "C" { `GRN_TOKEN_DEL`: Tokenization for deleting token from index. @since 4.0.7 + @deprecated since 4.0.8. Use grn_tokenize_mode instead. */ -typedef enum { - GRN_TOKEN_GET = 0, - GRN_TOKEN_ADD, - GRN_TOKEN_DEL -} grn_token_mode; +typedef grn_tokenize_mode grn_token_mode; + +#define GRN_TOKEN_GET GRN_TOKENIZE_GET +#define GRN_TOKEN_ADD GRN_TOKENIZE_ADD +#define GRN_TOKEN_DEL GRN_TOKENIZE_DELETE /* * grn_token_status is a flag set for tokenizer status codes. Modified: include/groonga/token_filter.h (+1 -1) =================================================================== --- include/groonga/token_filter.h 2014-11-17 22:42:12 +0900 (9376ce2) +++ include/groonga/token_filter.h 2014-11-17 22:56:02 +0900 (9c5a356) @@ -26,7 +26,7 @@ extern "C" { typedef void *grn_token_filter_init_func(grn_ctx *ctx, grn_obj *table, - grn_token_mode mode); + grn_tokenize_mode mode); typedef void grn_token_filter_filter_func(grn_ctx *ctx, grn_token *current_token, Modified: include/groonga/tokenizer.h (+2 -0) =================================================================== --- include/groonga/tokenizer.h 2014-11-17 22:42:12 +0900 (6659308) +++ include/groonga/tokenizer.h 2014-11-17 22:56:02 +0900 (8ad7f67) @@ -83,7 +83,9 @@ struct _grn_tokenizer_query { grn_encoding encoding; unsigned int flags; grn_bool have_tokenized_delimiter; + /* Deprecated since 4.0.8. Use tokenize_mode instead. */ grn_token_mode token_mode; + grn_tokenize_mode tokenize_mode; }; /* Modified: lib/db.c (+1 -1) =================================================================== --- lib/db.c 2014-11-17 22:42:12 +0900 (df63f55) +++ lib/db.c 2014-11-17 22:56:02 +0900 (5b09679) @@ -10238,7 +10238,7 @@ grn_table_tokenize(grn_ctx *ctx, grn_obj *table, grn_obj *buf, grn_bool addp) { grn_token_cursor *token_cursor = NULL; - grn_token_mode mode = addp ? GRN_TOKEN_ADD : GRN_TOKEN_GET; + grn_tokenize_mode mode = addp ? GRN_TOKENIZE_ADD : GRN_TOKENIZE_GET; GRN_API_ENTER; if (!(token_cursor = grn_token_cursor_open(ctx, table, str, str_len, mode, 0))) { goto exit; Modified: lib/grn_token_cursor.h (+2 -2) =================================================================== --- lib/grn_token_cursor.h 2014-11-17 22:42:12 +0900 (2b6682d) +++ lib/grn_token_cursor.h 2014-11-17 22:56:02 +0900 (81175bc) @@ -45,7 +45,7 @@ typedef struct { uint32_t orig_blen; uint32_t curr_size; int32_t pos; - grn_token_mode mode; + grn_tokenize_mode mode; grn_token_cursor_status status; grn_bool force_prefix; grn_obj_flags table_flags; @@ -61,7 +61,7 @@ typedef struct { GRN_API grn_token_cursor *grn_token_cursor_open(grn_ctx *ctx, grn_obj *table, const char *str, size_t str_len, - grn_token_mode mode, + grn_tokenize_mode mode, unsigned int flags); GRN_API grn_id grn_token_cursor_next(grn_ctx *ctx, grn_token_cursor *token_cursor); Modified: lib/ii.c (+2 -1) =================================================================== --- lib/ii.c 2014-11-17 22:42:12 +0900 (52b18f7) +++ lib/ii.c 2014-11-17 22:56:02 +0900 (8f9f9a8) @@ -4876,7 +4876,8 @@ exit : static grn_rc grn_vector2updspecs(grn_ctx *ctx, grn_ii *ii, grn_id rid, unsigned int section, - grn_obj *in, grn_obj *out, grn_token_mode mode, grn_obj *posting) + grn_obj *in, grn_obj *out, grn_tokenize_mode mode, + grn_obj *posting) { int j; grn_id tid; Modified: lib/proc.c (+1 -1) =================================================================== --- lib/proc.c 2014-11-17 22:42:12 +0900 (1c89071) +++ lib/proc.c 2014-11-17 22:56:02 +0900 (caa3088) @@ -3809,7 +3809,7 @@ create_lexicon_for_tokenize(grn_ctx *ctx, } static void -tokenize(grn_ctx *ctx, grn_obj *lexicon, grn_obj *string, grn_token_mode mode, +tokenize(grn_ctx *ctx, grn_obj *lexicon, grn_obj *string, grn_tokenize_mode mode, unsigned int flags, grn_obj *tokens) { grn_token_cursor *token_cursor; Modified: lib/token_cursor.c (+4 -4) =================================================================== --- lib/token_cursor.c 2014-11-17 22:42:12 +0900 (41e5e95) +++ lib/token_cursor.c 2014-11-17 22:56:02 +0900 (d3e2e2d) @@ -47,7 +47,7 @@ grn_token_cursor_open_initialize_token_filters(grn_ctx *ctx, grn_token_cursor * grn_token_cursor_open(grn_ctx *ctx, grn_obj *table, const char *str, size_t str_len, - grn_token_mode mode, unsigned int flags) + grn_tokenize_mode mode, unsigned int flags) { grn_token_cursor *token_cursor; grn_encoding encoding; @@ -194,7 +194,7 @@ grn_token_cursor_next(grn_ctx *ctx, grn_token_cursor *token_cursor) curr_, stat_); token_cursor->status = ((status & GRN_TOKEN_LAST) || - (token_cursor->mode == GRN_TOKEN_GET && + (token_cursor->mode == GRN_TOKENIZE_GET && (status & GRN_TOKEN_REACH_END))) ? GRN_TOKEN_CURSOR_DONE : GRN_TOKEN_CURSOR_DOING; token_cursor->force_prefix = GRN_FALSE; @@ -238,7 +238,7 @@ grn_token_cursor_next(grn_ctx *ctx, grn_token_cursor *token_cursor) } if (status & GRN_TOKEN_UNMATURED) { if (status & GRN_TOKEN_OVERLAP) { - if (token_cursor->mode == GRN_TOKEN_GET) { + if (token_cursor->mode == GRN_TOKENIZE_GET) { token_cursor->pos++; continue; } @@ -251,7 +251,7 @@ grn_token_cursor_next(grn_ctx *ctx, grn_token_cursor *token_cursor) } else { token_cursor->status = GRN_TOKEN_CURSOR_DONE; } - if (token_cursor->mode == GRN_TOKEN_ADD) { + if (token_cursor->mode == GRN_TOKENIZE_ADD) { switch (table->header.type) { case GRN_TABLE_PAT_KEY : if (grn_io_lock(ctx, ((grn_pat *)table)->io, grn_lock_timeout)) { Modified: lib/tokenizer.c (+5 -4) =================================================================== --- lib/tokenizer.c 2014-11-17 22:42:12 +0900 (d1921fd) +++ lib/tokenizer.c 2014-11-17 22:56:02 +0900 (aba5c28) @@ -102,7 +102,7 @@ grn_tokenizer_query_open(grn_ctx *ctx, int num_args, grn_obj **args, { grn_obj *flags = grn_ctx_pop(ctx); grn_obj *query_str = grn_ctx_pop(ctx); - grn_obj *token_mode = grn_ctx_pop(ctx); + grn_obj *tokenize_mode = grn_ctx_pop(ctx); if (query_str == NULL) { GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT, "missing argument"); @@ -127,11 +127,12 @@ grn_tokenizer_query_open(grn_ctx *ctx, int num_args, grn_obj **args, } else { query->flags = 0; } - if (token_mode) { - query->token_mode = GRN_UINT32_VALUE(token_mode); + if (tokenize_mode) { + query->tokenize_mode = GRN_UINT32_VALUE(tokenize_mode); } else { - query->token_mode = GRN_TOKEN_ADD; + query->tokenize_mode = GRN_TOKENIZE_ADD; } + query->token_mode = query->tokenize_mode; { grn_obj * const table = args[0]; -------------- next part -------------- HTML����������������������������...Download