Kouhei Sutou
null+****@clear*****
Thu Jan 17 16:18:04 JST 2013
Kouhei Sutou 2013-01-17 16:18:04 +0900 (Thu, 17 Jan 2013) New Revision: 688de23a834c3e10a17929d1d35c4a9a5e3c6c02 https://github.com/groonga/groonga/commit/688de23a834c3e10a17929d1d35c4a9a5e3c6c02 Log: Extract grn_column_index() for column + range operations Modified files: lib/db.c Modified: lib/db.c (+31 -18) =================================================================== --- lib/db.c 2013-01-17 16:16:12 +0900 (d61b23a) +++ lib/db.c 2013-01-17 16:18:04 +0900 (dcb03dc) @@ -7826,6 +7826,35 @@ grn_column_index_column_match(grn_ctx *ctx, grn_obj *obj, grn_operator op, return n; } +static inline int +grn_column_index_column_range(grn_ctx *ctx, grn_obj *obj, grn_operator op, + grn_obj **indexbuf, int buf_size, int *section) +{ + int n = 0; + grn_obj **ip = indexbuf; + grn_hook *hooks; + + for (hooks = DB_OBJ(obj)->hooks[GRN_HOOK_SET]; hooks; hooks = hooks->next) { + default_set_value_hook_data *data = (void *)NEXT_ADDR(hooks); + grn_obj *target = grn_ctx_at(ctx, data->target); + if (target->header.type != GRN_COLUMN_INDEX) { continue; } + if (section) { *section = (MULTI_COLUMN_INDEXP(target)) ? data->section : 0; } + { + grn_obj *tokenizer, *lexicon = grn_ctx_at(ctx, target->header.domain); + if (!lexicon) { continue; } + if (lexicon->header.type != GRN_TABLE_PAT_KEY) { continue; } + /* FIXME: GRN_TABLE_DAT_KEY should be supported */ + grn_table_get_info(ctx, lexicon, NULL, NULL, &tokenizer, NULL); + if (tokenizer) { continue; } + } + if (n < buf_size) { + *ip++ = target; + } + n++; + } + + return n; +} static inline int grn_column_index_accessor_match(grn_ctx *ctx, grn_obj *obj, grn_operator op, @@ -7904,24 +7933,8 @@ grn_column_index(grn_ctx *ctx, grn_obj *obj, grn_operator op, case GRN_OP_LESS_EQUAL : case GRN_OP_GREATER_EQUAL : case GRN_OP_CALL : - for (hooks = DB_OBJ(obj)->hooks[GRN_HOOK_SET]; hooks; hooks = hooks->next) { - default_set_value_hook_data *data = (void *)NEXT_ADDR(hooks); - grn_obj *target = grn_ctx_at(ctx, data->target); - if (target->header.type != GRN_COLUMN_INDEX) { continue; } - if (section) { *section = (MULTI_COLUMN_INDEXP(target)) ? data->section : 0; } - { - grn_obj *tokenizer, *lexicon = grn_ctx_at(ctx, target->header.domain); - if (!lexicon) { continue; } - if (lexicon->header.type != GRN_TABLE_PAT_KEY) { continue; } - /* FIXME: GRN_TABLE_DAT_KEY should be supported */ - grn_table_get_info(ctx, lexicon, NULL, NULL, &tokenizer, NULL); - if (tokenizer) { continue; } - } - if (n < buf_size) { - *ip++ = target; - } - n++; - } + n = grn_column_index_column_range(ctx, obj, op, + indexbuf, buf_size, section); break; default : break; -------------- next part -------------- HTML����������������������������... 下载