null+****@clear*****
null+****@clear*****
2011年 6月 29日 (水) 19:35:29 JST
mooz 2011-06-29 10:35:29 +0000 (Wed, 29 Jun 2011)
New Revision: 093d70f8b7100e9aac592be2db79c9a77060e75d
Log:
Keep full text result in handler. refs #1027
Modified files:
ha_mroonga.cc
ha_mroonga.h
Modified: ha_mroonga.cc (+31 -0)
===================================================================
--- ha_mroonga.cc 2011-06-29 08:18:17 +0000 (ba202d6)
+++ ha_mroonga.cc 2011-06-29 10:35:29 +0000 (fd52737)
@@ -955,6 +955,7 @@ ha_mroonga::ha_mroonga(handlerton *hton, TABLE_SHARE *share)
share = NULL;
is_clone = FALSE;
wrap_handler = NULL;
+ matched_record_keys = NULL;
fulltext_searching = FALSE;
DBUG_VOID_RETURN;
}
@@ -4049,9 +4050,33 @@ FT_INFO *ha_mroonga::wrapper_ft_init_ext(uint flags, uint key_nr, String *key)
grn_obj_unlink(info->ctx, expression);
grn_obj_unlink(info->ctx, match_columns);
+ merge_matched_record_keys(info->result);
+
DBUG_RETURN((FT_INFO *)info);
}
+void ha_mroonga::merge_matched_record_keys(grn_obj *matched_result)
+{
+ MRN_DBUG_ENTER_METHOD();
+
+ grn_operator operation = GRN_OP_AND;
+
+ if (!matched_record_keys) {
+ matched_record_keys = grn_table_create(ctx, NULL, 0, NULL,
+ GRN_TABLE_HASH_KEY | GRN_OBJ_WITH_SUBREC,
+ grn_table, 0);
+ // OR for empty table
+ operation = GRN_OP_OR;
+ }
+
+ grn_rc rc;
+ rc = grn_table_setoperation(ctx, matched_record_keys, matched_result,
+ matched_record_keys, operation);
+
+
+ DBUG_VOID_RETURN;
+}
+
FT_INFO *ha_mroonga::default_ft_init_ext(uint flags, uint key_nr, String *key)
{
MRN_DBUG_ENTER_METHOD();
@@ -4518,6 +4543,12 @@ int ha_mroonga::wrapper_reset()
error = wrap_handler->ha_reset();
MRN_SET_BASE_SHARE_KEY(share, table->s);
MRN_SET_BASE_TABLE_KEY(this, table);
+ grn_obj_unlink(ctx, matched_record_keys);
+ matched_record_keys = NULL;
+ if (matched_record_keys) {
+ grn_obj_unlink(ctx, matched_record_keys);
+ matched_record_keys = NULL;
+ }
DBUG_RETURN(error);
}
Modified: ha_mroonga.h (+2 -0)
===================================================================
--- ha_mroonga.h 2011-06-29 08:18:17 +0000 (fef1459)
+++ ha_mroonga.h 2011-06-29 10:35:29 +0000 (db5ac95)
@@ -92,6 +92,7 @@ private:
grn_obj *_score;
st_mrn_ft_info mrn_ft_info;
+ grn_obj *matched_record_keys;
char **key_min;
char **key_max;
@@ -329,6 +330,7 @@ private:
int default_read_range_next();
int wrapper_ft_init();
int default_ft_init();
+ void merge_matched_record_keys(grn_obj *matched_result);
void wrapper_ft_end();
void default_ft_end();
FT_INFO *wrapper_ft_init_ext(uint flags, uint key_nr, String *key);