[Groonga-mysql-commit] mroonga/mroonga [master] add some wrapper methods

Zurück zum Archiv-Index

null+****@clear***** null+****@clear*****
2011年 6月 10日 (金) 09:22:40 JST


Kentoku	2011-06-10 00:22:40 +0000 (Fri, 10 Jun 2011)

  New Revision: 712c5b3be124239ba2f419c47c14e8111740ebae

  Log:
    add some wrapper methods

  Modified files:
    ha_mroonga.cc
    ha_mroonga.h

  Modified: ha_mroonga.cc (+121 -3)
===================================================================
--- ha_mroonga.cc    2011-06-09 15:02:01 +0000 (bc706be)
+++ ha_mroonga.cc    2011-06-10 00:22:40 +0000 (57713dd)
@@ -880,6 +880,7 @@ ha_mroonga::ha_mroonga(handlerton *hton, TABLE_SHARE *share)
   res = NULL;
   res0 = NULL;
   sort_keys = NULL;
+  share = NULL;
   DBUG_VOID_RETURN;
 }
 
@@ -1698,6 +1699,32 @@ int ha_mroonga::info(uint flag)
   DBUG_RETURN(0);
 }
 
+uint ha_mroonga::wrapper_lock_count()
+{
+  uint lock_count;
+  MRN_DBUG_ENTER_METHOD();
+  MRN_SET_WRAP_SHARE_KEY(share, table->s);
+  MRN_SET_WRAP_TABLE_KEY(this, table);
+  lock_count = wrap_handler->lock_count();
+  MRN_SET_BASE_SHARE_KEY(share, table->s);
+  MRN_SET_BASE_TABLE_KEY(this, table);
+  DBUG_RETURN(lock_count + 1);
+}
+
+uint ha_mroonga::default_lock_count()
+{
+  MRN_DBUG_ENTER_METHOD();
+  DBUG_RETURN(1);
+}
+
+uint ha_mroonga::lock_count()
+{
+  MRN_DBUG_ENTER_METHOD();
+  if (share->wrapper_mode)
+    DBUG_RETURN(wrapper_lock_count());
+  DBUG_RETURN(default_lock_count());
+}
+
 THR_LOCK_DATA **ha_mroonga::store_lock(THD *thd, THR_LOCK_DATA **to,
                                        enum thr_lock_type lock_type)
 {
@@ -1772,7 +1799,7 @@ void ha_mroonga::position(const uchar *record)
   DBUG_VOID_RETURN;
 }
 
-int ha_mroonga::extra(enum ha_extra_function operation)
+int ha_mroonga::mrn_extra(enum ha_extra_function operation)
 {
   MRN_DBUG_ENTER_METHOD();
   switch (operation) {
@@ -1788,6 +1815,74 @@ int ha_mroonga::extra(enum ha_extra_function operation)
   DBUG_RETURN(0);
 }
 
+int ha_mroonga::wrapper_extra(enum ha_extra_function operation)
+{
+  int error;
+  MRN_DBUG_ENTER_METHOD();
+  MRN_SET_WRAP_SHARE_KEY(share, table->s);
+  MRN_SET_WRAP_TABLE_KEY(this, table);
+  error = wrap_handler->extra(operation);
+  MRN_SET_BASE_SHARE_KEY(share, table->s);
+  MRN_SET_BASE_TABLE_KEY(this, table);
+  DBUG_RETURN(error);
+}
+
+int ha_mroonga::default_extra(enum ha_extra_function operation)
+{
+  MRN_DBUG_ENTER_METHOD();
+  DBUG_RETURN(0);
+}
+
+int ha_mroonga::extra(enum ha_extra_function operation)
+{
+  int error;
+  MRN_DBUG_ENTER_METHOD();
+  if (share->wrapper_mode)
+  {
+    if ((error = wrapper_extra(operation)))
+      DBUG_RETURN(error);
+  } else {
+    if ((error = default_extra(operation)))
+      DBUG_RETURN(error);
+  }
+  DBUG_RETURN(mrn_extra(operation));
+}
+
+int ha_mroonga::wrapper_extra_opt(enum ha_extra_function operation,
+                                  ulong cache_size)
+{
+  int error;
+  MRN_DBUG_ENTER_METHOD();
+  MRN_SET_WRAP_SHARE_KEY(share, table->s);
+  MRN_SET_WRAP_TABLE_KEY(this, table);
+  error = wrap_handler->extra_opt(operation, cache_size);
+  MRN_SET_BASE_SHARE_KEY(share, table->s);
+  MRN_SET_BASE_TABLE_KEY(this, table);
+  DBUG_RETURN(error);
+}
+
+int ha_mroonga::default_extra_opt(enum ha_extra_function operation,
+                                  ulong cache_size)
+{
+  MRN_DBUG_ENTER_METHOD();
+  DBUG_RETURN(0);
+}
+
+int ha_mroonga::extra_opt(enum ha_extra_function operation, ulong cache_size)
+{
+  int error;
+  MRN_DBUG_ENTER_METHOD();
+  if (share->wrapper_mode)
+  {
+    if ((error = wrapper_extra_opt(operation, cache_size)))
+      DBUG_RETURN(error);
+  } else {
+    if ((error = default_extra_opt(operation, cache_size)))
+      DBUG_RETURN(error);
+  }
+  DBUG_RETURN(mrn_extra(operation));
+}
+
 int ha_mroonga::write_row(uchar *buf)
 {
   MRN_DBUG_ENTER_METHOD();
@@ -2924,7 +3019,19 @@ void ha_mroonga::store_fields_from_primary_table(uchar *buf, grn_id rid)
   DBUG_VOID_RETURN;
 }
 
-int ha_mroonga::reset()
+int ha_mroonga::wrapper_reset()
+{
+  int error;
+  MRN_DBUG_ENTER_METHOD();
+  MRN_SET_WRAP_SHARE_KEY(share, table->s);
+  MRN_SET_WRAP_TABLE_KEY(this, table);
+  error = wrap_handler->ha_reset();
+  MRN_SET_BASE_SHARE_KEY(share, table->s);
+  MRN_SET_BASE_TABLE_KEY(this, table);
+  DBUG_RETURN(error);
+}
+
+int ha_mroonga::default_reset()
 {
   MRN_DBUG_ENTER_METHOD();
   if (sort_keys != NULL) {
@@ -2940,10 +3047,21 @@ int ha_mroonga::reset()
     _score = NULL;
     res = NULL;
   }
-  ignoring_duplicated_key = false;
   DBUG_RETURN(0);
 }
 
+int ha_mroonga::reset()
+{
+  int error;
+  MRN_DBUG_ENTER_METHOD();
+  if (share->wrapper_mode)
+    error = wrapper_reset();
+  else
+    error = default_reset();
+  ignoring_duplicated_key = false;
+  DBUG_RETURN(error);
+}
+
 #if MYSQL_VERSION_ID >= 50513
 handler *ha_mroonga::clone(const char *name, MEM_ROOT *mem_root)
 {

  Modified: ha_mroonga.h (+11 -0)
===================================================================
--- ha_mroonga.h    2011-06-09 15:02:01 +0000 (0e23694)
+++ ha_mroonga.h    2011-06-10 00:22:40 +0000 (40d2844)
@@ -112,6 +112,7 @@ public:
   int close();                                                     // required
   int info(uint flag);                                             // required
 
+  uint lock_count();
   THR_LOCK_DATA **store_lock(THD *thd,                             // required
 			     THR_LOCK_DATA **to,
 			     enum thr_lock_type lock_type);
@@ -122,6 +123,7 @@ public:
   int rnd_pos(uchar *buf, uchar *pos);                             // required
   void position(const uchar *record);                              // required
   int extra(enum ha_extra_function operation);
+  int extra_opt(enum ha_extra_function operation, ulong cache_size);
 
   int delete_table(const char *name);
   int write_row(uchar *buf);
@@ -215,6 +217,15 @@ private:
   int default_open(const char *name, int mode, uint test_if_locked);
   int wrapper_close();
   int default_close();
+  int mrn_extra(enum ha_extra_function operation);
+  int wrapper_extra(enum ha_extra_function operation);
+  int default_extra(enum ha_extra_function operation);
+  int wrapper_extra_opt(enum ha_extra_function operation, ulong cache_size);
+  int default_extra_opt(enum ha_extra_function operation, ulong cache_size);
+  int wrapper_reset();
+  int default_reset();
+  uint wrapper_lock_count();
+  uint default_lock_count();
 };
 
 #ifdef __cplusplus




Groonga-mysql-commit メーリングリストの案内
Zurück zum Archiv-Index