null+****@clear*****
null+****@clear*****
2011年 7月 1日 (金) 12:02:30 JST
Kouhei Sutou 2011-07-01 03:02:30 +0000 (Fri, 01 Jul 2011)
New Revision: 55bea4d8bd9425b20b6d2239f801a697a1b6f15a
Log:
check command supports hash.
Modified files:
lib/hash.c
lib/hash.h
lib/proc.c
Modified: lib/hash.c (+37 -0)
===================================================================
--- lib/hash.c 2011-07-01 02:17:22 +0000 (6fd1c3a)
+++ lib/hash.c 2011-07-01 03:02:30 +0000 (627ef86)
@@ -16,6 +16,7 @@
*/
#include "hash.h"
#include "pat.h"
+#include "output.h"
#include <string.h>
#include <limits.h>
@@ -2132,6 +2133,42 @@ grn_hash_sort(grn_ctx *ctx, grn_hash *hash,
}
}
+void
+grn_hash_check(grn_ctx *ctx, grn_hash *hash)
+{
+ char buf[8];
+ struct grn_hash_header *h = hash->header;
+ GRN_OUTPUT_ARRAY_OPEN("RESULT", 1);
+ GRN_OUTPUT_MAP_OPEN("SUMMARY", 12);
+ GRN_OUTPUT_CSTR("flags");
+ grn_itoh(h->flags, buf, 8);
+ GRN_OUTPUT_STR(buf, 8);
+ GRN_OUTPUT_CSTR("key_size");
+ GRN_OUTPUT_INT64(hash->key_size);
+ GRN_OUTPUT_CSTR("value_size");
+ GRN_OUTPUT_INT64(hash->value_size);
+ GRN_OUTPUT_CSTR("tokenizer");
+ GRN_OUTPUT_INT64(h->tokenizer);
+ GRN_OUTPUT_CSTR("curr_rec");
+ GRN_OUTPUT_INT64(h->curr_rec);
+ GRN_OUTPUT_CSTR("curr_key");
+ GRN_OUTPUT_INT64(h->curr_key);
+ GRN_OUTPUT_CSTR("idx_offset");
+ GRN_OUTPUT_INT64(h->idx_offset);
+ GRN_OUTPUT_CSTR("entry_size");
+ GRN_OUTPUT_INT64(hash->entry_size);
+ GRN_OUTPUT_CSTR("max_offset");
+ GRN_OUTPUT_INT64(*hash->max_offset);
+ GRN_OUTPUT_CSTR("n_entries");
+ GRN_OUTPUT_INT64(*hash->n_entries);
+ GRN_OUTPUT_CSTR("n_garbages");
+ GRN_OUTPUT_INT64(*hash->n_garbages);
+ GRN_OUTPUT_CSTR("lock");
+ GRN_OUTPUT_INT64(h->lock);
+ GRN_OUTPUT_MAP_CLOSE();
+ GRN_OUTPUT_ARRAY_CLOSE();
+}
+
/* todo : not completed yet
grn_rc
grn_hash_group(grn_ctx *ctx, grn_hash *hash,
Modified: lib/hash.h (+2 -0)
===================================================================
--- lib/hash.h 2011-07-01 02:17:22 +0000 (96054e4)
+++ lib/hash.h 2011-07-01 03:02:30 +0000 (fab0e89)
@@ -311,6 +311,8 @@ grn_rc grn_array_remove(grn_ctx *ctx, const char *path);
grn_id grn_hash_at(grn_ctx *ctx, grn_hash *hash, grn_id id);
grn_id grn_array_at(grn_ctx *ctx, grn_array *array, grn_id id);
+void grn_hash_check(grn_ctx *ctx, grn_hash *hash);
+
#ifdef __cplusplus
}
#endif
Modified: lib/proc.c (+3 -1)
===================================================================
--- lib/proc.c 2011-07-01 02:17:22 +0000 (fb7d14e)
+++ lib/proc.c 2011-07-01 03:02:30 +0000 (df4bb3c)
@@ -2063,8 +2063,10 @@ proc_check(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
case GRN_TABLE_PAT_KEY :
grn_pat_check(ctx, (grn_pat *)obj);
break;
- case GRN_TABLE_DAT_KEY :
case GRN_TABLE_HASH_KEY :
+ grn_hash_check(ctx, (grn_hash *)obj);
+ break;
+ case GRN_TABLE_DAT_KEY :
case GRN_TABLE_NO_KEY :
case GRN_COLUMN_FIX_SIZE :
GRN_OUTPUT_BOOL(!ctx->rc);