Kouhei Sutou
null+****@clear*****
Thu Mar 24 16:21:39 JST 2016
Kouhei Sutou 2016-03-24 16:21:39 +0900 (Thu, 24 Mar 2016) New Revision: 00e64f6ef63146204a7b8eb9f19ce7cbcff3173b https://github.com/groonga/groonga/commit/00e64f6ef63146204a7b8eb9f19ce7cbcff3173b Message: Fix a bug that offline index construction against WITH_POSITION + VECTOR If we use offline index construction against WITH_POSITION index for non-text vector column, the index ignores position. TODO: We fix this bug by disabling offline index construction for now. But we should support offline index construction for the case. Added files: test/command/suite/load/index/offline/vector_int32_position.expected test/command/suite/load/index/offline/vector_int32_position.test Modified files: include/groonga/type.h lib/index_column.c Modified: include/groonga/type.h (+3 -0) =================================================================== --- include/groonga/type.h 2016-03-24 19:17:26 +0900 (bbbd97d) +++ include/groonga/type.h 2016-03-24 16:21:39 +0900 (9262f20) @@ -22,6 +22,9 @@ extern "C" { #endif +#define GRN_TYPE_IS_TEXT_FAMILY(type) \ + (GRN_DB_SHORT_TEXT <= (type) && (type) <= GRN_DB_LONG_TEXT) + GRN_API grn_obj *grn_type_create(grn_ctx *ctx, const char *name, unsigned int name_size, grn_obj_flags flags, unsigned int size); GRN_API uint32_t grn_type_size(grn_ctx *ctx, grn_obj *type); Modified: lib/index_column.c (+9 -1) =================================================================== --- lib/index_column.c 2016-03-24 19:17:26 +0900 (958e000) +++ lib/index_column.c 2016-03-24 16:21:39 +0900 (1cb7cd5) @@ -108,7 +108,8 @@ grn_index_column_build(grn_ctx *ctx, grn_obj *index_column) grn_obj_flags flags; grn_ii *ii = (grn_ii *)index_column; grn_bool use_grn_ii_build; - grn_table_get_info(ctx, ii->lexicon, &flags, NULL, NULL, NULL, NULL); + grn_obj *tokenizer = NULL; + grn_table_get_info(ctx, ii->lexicon, &flags, NULL, &tokenizer, NULL, NULL); switch (flags & GRN_OBJ_TABLE_TYPE_MASK) { case GRN_OBJ_TABLE_PAT_KEY : case GRN_OBJ_TABLE_DAT_KEY : @@ -121,6 +122,13 @@ grn_index_column_build(grn_ctx *ctx, grn_obj *index_column) if ((ii->header->flags & GRN_OBJ_WITH_WEIGHT)) { use_grn_ii_build = GRN_FALSE; } + if ((ii->header->flags & GRN_OBJ_WITH_POSITION) && + (!tokenizer && + !GRN_TYPE_IS_TEXT_FAMILY(ii->lexicon->header.domain))) { + /* TODO: Support offline index construction for WITH_POSITION + * index against UInt32 vector column. */ + use_grn_ii_build = GRN_FALSE; + } if ((col = GRN_MALLOC(ncol * sizeof(grn_obj *)))) { for (cp = col, i = ncol; i; s++, cp++, i--) { if (!(*cp = grn_ctx_at(ctx, *s))) { Added: test/command/suite/load/index/offline/vector_int32_position.expected (+17 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/load/index/offline/vector_int32_position.expected 2016-03-24 16:21:39 +0900 (95b27a3) @@ -0,0 +1,17 @@ +table_create Entries TABLE_NO_KEY +[[0,0.0,0.0],true] +column_create Entries numbers COLUMN_VECTOR Int32 +[[0,0.0,0.0],true] +load --table Entries +[ +["numbers"], +[[18, 19, 20]], +[[100, 200]] +] +[[0,0.0,0.0],2] +table_create Numbers TABLE_PAT_KEY Int32 +[[0,0.0,0.0],true] +column_create Numbers entries_numbers COLUMN_INDEX|WITH_POSITION Entries numbers +[[0,0.0,0.0],true] +select Entries --filter 'numbers[1] > 19' +[[0,0.0,0.0],[[[1],[["_id","UInt32"],["numbers","Int32"]],[2,[100,200]]]]] Added: test/command/suite/load/index/offline/vector_int32_position.test (+14 -0) 100644 =================================================================== --- /dev/null +++ test/command/suite/load/index/offline/vector_int32_position.test 2016-03-24 16:21:39 +0900 (904e263) @@ -0,0 +1,14 @@ +table_create Entries TABLE_NO_KEY +column_create Entries numbers COLUMN_VECTOR Int32 + +load --table Entries +[ +["numbers"], +[[18, 19, 20]], +[[100, 200]] +] + +table_create Numbers TABLE_PAT_KEY Int32 +column_create Numbers entries_numbers COLUMN_INDEX|WITH_POSITION Entries numbers + +select Entries --filter 'numbers[1] > 19' -------------- next part -------------- HTML����������������������������...Download