[Groonga-commit] groonga/groonga at c4c68c1 [master] grn_ts: add grn_ts_table_get_key2()

Back to archive index

susumu.yata null+****@clear*****
Thu Sep 3 19:18:38 JST 2015


susumu.yata	2015-09-03 19:18:38 +0900 (Thu, 03 Sep 2015)

  New Revision: c4c68c1798ea74d7934963c77e5c5a0e355f1c23
  https://github.com/groonga/groonga/commit/c4c68c1798ea74d7934963c77e5c5a0e355f1c23

  Message:
    grn_ts: add grn_ts_table_get_key2()

  Modified files:
    lib/ts.c

  Modified: lib/ts.c (+25 -0)
===================================================================
--- lib/ts.c    2015-09-03 11:00:17 +0900 (321d06c)
+++ lib/ts.c    2015-09-03 19:18:38 +0900 (9b4ebac)
@@ -418,6 +418,31 @@ grn_ts_table_get_value(grn_ctx *ctx, grn_obj *table, grn_id id, void *buf) {
   }
 }
 
+#define GRN_TS_TABLE_GET_KEY2_CASE_BLOCK(TYPE, type)\
+  case GRN_TABLE_ ## TYPE ## _KEY: {\
+    uint32_t key_size;\
+    grn_ ## type *type = (grn_ ## type *)table;\
+    const void *key = _grn_ ## type ## _key(ctx, type, id, &key_size);\
+    if (size) {\
+      *size = key_size;\
+    }\
+    return key;\
+  }
+/* grn_ts_table_get_key2() gets a reference to a key (_key). */
+static const void *
+grn_ts_table_get_key2(grn_ctx *ctx, grn_obj *table, grn_id id, size_t *size) {
+  switch (table->header.type) {
+    GRN_TS_TABLE_GET_KEY2_CASE_BLOCK(HASH, hash)
+    GRN_TS_TABLE_GET_KEY2_CASE_BLOCK(PAT, pat)
+    GRN_TS_TABLE_GET_KEY2_CASE_BLOCK(DAT, dat)
+    /* GRN_TABLE_NO_KEY does not support _key. */
+    default: {
+      return NULL;
+    }
+  }
+}
+#undef GRN_TS_TABLE_GET_KEY2_CASE_BLOCK
+
 /*-------------------------------------------------------------
  * grn_ts_expr_node.
  */
-------------- next part --------------
HTML����������������������������...
Descargar 



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