[Groonga-commit] groonga/groonga at 5566afb [master] mrb: add Groonga::DoubleArrayTrie

Back to archive index

Kouhei Sutou null+****@clear*****
Sun Dec 28 23:44:46 JST 2014


Kouhei Sutou	2014-12-28 23:44:46 +0900 (Sun, 28 Dec 2014)

  New Revision: 5566afb8e34c7c401b6730b268657b299f9ac9c3
  https://github.com/groonga/groonga/commit/5566afb8e34c7c401b6730b268657b299f9ac9c3

  Message:
    mrb: add Groonga::DoubleArrayTrie

  Added files:
    lib/mrb/mrb_double_array_trie.c
    lib/mrb/mrb_double_array_trie.h
  Modified files:
    lib/ctx_impl_mrb.c
    lib/mrb/mrb_converter.c
    lib/mrb/sources.am

  Modified: lib/ctx_impl_mrb.c (+2 -0)
===================================================================
--- lib/ctx_impl_mrb.c    2014-12-28 23:41:08 +0900 (1f6b60e)
+++ lib/ctx_impl_mrb.c    2014-12-28 23:44:46 +0900 (85e164a)
@@ -35,6 +35,7 @@
 #include "mrb/mrb_array.h"
 #include "mrb/mrb_hash_table.h"
 #include "mrb/mrb_patricia_trie.h"
+#include "mrb/mrb_double_array_trie.h"
 #include "mrb/mrb_column.h"
 #include "mrb/mrb_fixed_size_column.h"
 #include "mrb/mrb_variable_size_column.h"
@@ -109,6 +110,7 @@ grn_ctx_impl_mrb_init_bindings(grn_ctx *ctx)
   grn_mrb_array_init(ctx);
   grn_mrb_hash_table_init(ctx);
   grn_mrb_patricia_trie_init(ctx);
+  grn_mrb_double_array_trie_init(ctx);
   grn_mrb_column_init(ctx);
   grn_mrb_fixed_size_column_init(ctx);
   grn_mrb_variable_size_column_init(ctx);

  Modified: lib/mrb/mrb_converter.c (+3 -0)
===================================================================
--- lib/mrb/mrb_converter.c    2014-12-28 23:41:08 +0900 (6612ea2)
+++ lib/mrb/mrb_converter.c    2014-12-28 23:44:46 +0900 (3188e47)
@@ -67,6 +67,9 @@ grn_mrb_class_from_grn_obj(mrb_state *mrb, grn_obj *object)
   case GRN_TABLE_PAT_KEY :
     klass = mrb_class_get_under(mrb, data->module, "PatriciaTrie");
     break;
+  case GRN_TABLE_DAT_KEY :
+    klass = mrb_class_get_under(mrb, data->module, "DoubleArrayTrie");
+    break;
   case GRN_VOID :
     klass = mrb_class_get_under(mrb, data->module, "Void");
     break;

  Added: lib/mrb/mrb_double_array_trie.c (+60 -0) 100644
===================================================================
--- /dev/null
+++ lib/mrb/mrb_double_array_trie.c    2014-12-28 23:44:46 +0900 (5c03409)
@@ -0,0 +1,60 @@
+/* -*- c-basic-offset: 2 -*- */
+/*
+  Copyright(C) 2014 Brazil
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License version 2.1 as published by the Free Software Foundation.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#include "../grn_ctx_impl.h"
+
+#ifdef GRN_WITH_MRUBY
+#include <mruby.h>
+#include <mruby/class.h>
+#include <mruby/data.h>
+
+#include "mrb_double_array_trie.h"
+
+static struct mrb_data_type mrb_grn_double_array_trie_type = {
+  "Groonga::DoubleArrayTrie",
+  NULL
+};
+
+static mrb_value
+mrb_grn_double_array_trie_initialize(mrb_state *mrb, mrb_value self)
+{
+  mrb_value mrb_double_array_trie_ptr;
+
+  mrb_get_args(mrb, "o", &mrb_double_array_trie_ptr);
+  DATA_TYPE(self) = &mrb_grn_double_array_trie_type;
+  DATA_PTR(self) = mrb_cptr(mrb_double_array_trie_ptr);
+  return self;
+}
+
+void
+grn_mrb_double_array_trie_init(grn_ctx *ctx)
+{
+  grn_mrb_data *data = &(ctx->impl->mrb);
+  mrb_state *mrb = data->state;
+  struct RClass *module = data->module;
+  struct RClass *table_class;
+  struct RClass *klass;
+
+  table_class = mrb_class_get_under(mrb, module, "Table");
+  klass = mrb_define_class_under(mrb, module, "DoubleArrayTrie", table_class);
+  MRB_SET_INSTANCE_TT(klass, MRB_TT_DATA);
+
+  mrb_define_method(mrb, klass, "initialize",
+                    mrb_grn_double_array_trie_initialize, MRB_ARGS_REQ(1));
+}
+#endif

  Added: lib/mrb/mrb_double_array_trie.h (+34 -0) 100644
===================================================================
--- /dev/null
+++ lib/mrb/mrb_double_array_trie.h    2014-12-28 23:44:46 +0900 (a69a94e)
@@ -0,0 +1,34 @@
+/* -*- c-basic-offset: 2 -*- */
+/*
+  Copyright(C) 2014 Brazil
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License version 2.1 as published by the Free Software Foundation.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+
+#ifndef GRN_MRB_DOUBLE_ARRAY_TRIE_H
+#define GRN_MRB_DOUBLE_ARRAY_TRIE_H
+
+#include "../grn_ctx.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void grn_mrb_double_array_trie_init(grn_ctx *ctx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GRN_MRB_DOUBLE_ARRAY_TRIE_H */

  Modified: lib/mrb/sources.am (+2 -0)
===================================================================
--- lib/mrb/sources.am    2014-12-28 23:41:08 +0900 (5e8384a)
+++ lib/mrb/sources.am    2014-12-28 23:44:46 +0900 (c19d2ff)
@@ -13,6 +13,8 @@ libgrnmrb_la_SOURCES =				\
 	mrb_ctx.h				\
 	mrb_database.c				\
 	mrb_database.h				\
+	mrb_double_array_trie.c			\
+	mrb_double_array_trie.h			\
 	mrb_error.c				\
 	mrb_error.h				\
 	mrb_expr.c				\
-------------- next part --------------
HTML����������������������������...
Télécharger 



More information about the Groonga-commit mailing list
Back to archive index