[groonga-dev,00012] grn_table_columns()を公開してほしい

Back to archive index

Kouhei Sutou kou****@clear*****
2009年 4月 8日 (水) 09:03:31 JST


須藤です。

QL-APIではカラム名一覧を取得するAPIがありますが、現在公開され
ているDB-APIではその機能を実現することができません。この機能
を実現するためにgrn_table_columns()を公開してもらえないでしょ
うか?

カラム名一覧を取得する機能があると、テーブルの内容をダンプし
たり、メタプログラミングのようなことができるようになり、
groongaを利用してより有用なプログラムを書けるようになります。

diff --git a/groonga.h b/groonga.h
index b4a08ea..f839503 100644
--- a/groonga.h
+++ b/groonga.h
@@ -767,6 +767,21 @@ GRN_API grn_rc grn_table_difference(grn_ctx *ctx, grn_obj *table1, grn_obj *tabl
                                     grn_obj *res1, grn_obj *res2);
 
 /**
+ * grn_table_columns:
+ * @table: 対象table
+ * @name: 取得したいカラム名のprefix
+ * @name_size: @nameの長さ
+ * @res: 結果を格納するGRN_TABLE_HASH_KEYのtable
+ *
+ * @nameから始まるtableのカラムIDを@resに格納する。
+ * @name_sizeが0の場合はすべてのカラムIDを格納する。格納した
+ * カラムIDの数を返す。
+ **/
+GRN_API int grn_table_columns(grn_ctx *ctx, grn_obj *table,
+                              const char *name, unsigned name_size,
+                              grn_obj *res);
+
+/**
  * grn_table_column:
  * @table: 対象table
  * @name: カラム名
diff --git a/lib/db.h b/lib/db.h
index b578358..8a1db4d 100644
--- a/lib/db.h
+++ b/lib/db.h
@@ -71,9 +71,6 @@ grn_rc grn_table_search(grn_ctx *ctx, grn_obj *table,
                         const void *key, uint32_t key_size,
                         grn_search_flags flags, grn_obj *res, grn_sel_operator op);
 
-int grn_table_columns(grn_ctx *ctx, grn_obj *table, const char *name, unsigned name_size,
-                      grn_obj *res);
-
 grn_id grn_table_next(grn_ctx *ctx, grn_obj *table, grn_id id);
 
 int grn_table_get_key2(grn_ctx *ctx, grn_obj *table, grn_id id, grn_obj *bulk);

--
須藤 功平 <kou****@clear*****>

株式会社クリアコード (http://www.clear-code.com/)




groonga-dev メーリングリストの案内
Back to archive index