null+****@clear*****
null+****@clear*****
2010年 7月 16日 (金) 20:39:06 JST
Daijiro MORI 2010-07-16 11:39:06 +0000 (Fri, 16 Jul 2010)
New Revision: c79efbc6c73ad270c02f704feb82a5cad9b71fc5
Log:
Added grn_pat_check().
Modified files:
lib/ii.c
lib/output.h
lib/pat.c
lib/pat.h
lib/proc.c
Modified: lib/ii.c (+6 -5)
===================================================================
--- lib/ii.c 2010-07-15 05:04:54 +0000 (6647902)
+++ lib/ii.c 2010-07-16 11:39:06 +0000 (a2ae87f)
@@ -2980,7 +2980,7 @@ grn_ii_buffer_check(grn_ctx *ctx, grn_ii *ii, uint32_t seg)
GRN_OUTPUT_ARRAY_OPEN("TERMS", sb->header.nterms);
for (bt = sb->terms, n = sb->header.nterms; n; n--, bt++) {
- grn_id tid;
+ grn_id tid, tid_;
char key[GRN_TABLE_MAX_KEY_SIZE];
int key_size;
uint16_t nextb;
@@ -2995,14 +2995,15 @@ grn_ii_buffer_check(grn_ctx *ctx, grn_ii *ii, uint32_t seg)
continue;
}
GRN_OUTPUT_ARRAY_OPEN("TERM", -1);
- key_size = grn_table_get_key(ctx, ii->lexicon, bt->tid, key, GRN_TABLE_MAX_KEY_SIZE);
- tid = grn_table_get(ctx, ii->lexicon, key, key_size);
+ tid = (bt->tid & GRN_ID_MAX);
+ key_size = grn_table_get_key(ctx, ii->lexicon, tid, key, GRN_TABLE_MAX_KEY_SIZE);
+ tid_ = grn_table_get(ctx, ii->lexicon, key, key_size);
GRN_OUTPUT_STR(key, key_size);
GRN_OUTPUT_INT64(bt->tid);
- GRN_OUTPUT_INT64(tid);
+ GRN_OUTPUT_INT64(tid_);
nextb = bt->pos_in_buffer;
size_in_buffer += bt->size_in_buffer;
- if (tid != bt->tid && (bt->size_in_buffer || bt->size_in_chunk)) {
+ if (tid != tid_ && (bt->size_in_buffer || bt->size_in_chunk)) {
ndeleted_terms_with_value++;
}
GETNEXTB();
Modified: lib/output.h (+4 -0)
===================================================================
--- lib/output.h 2010-07-15 05:04:54 +0000 (d1d7f0a)
+++ lib/output.h 2010-07-16 11:39:06 +0000 (082a51c)
@@ -29,6 +29,10 @@
#include "store.h"
#endif /* GRN_STORE_H */
+#ifndef GRN_QL_H
+#include "ql.h"
+#endif /* GRN_QL_H */
+
#ifdef __cplusplus
extern "C" {
#endif
Modified: lib/pat.c (+34 -0)
===================================================================
--- lib/pat.c 2010-07-15 05:04:54 +0000 (ac8e233)
+++ lib/pat.c 2010-07-16 11:39:06 +0000 (86c10fd)
@@ -18,6 +18,7 @@
#include <string.h>
#include <limits.h>
#include "pat.h"
+#include "output.h"
#define GRN_PAT_DELETED (GRN_ID_MAX + 1)
@@ -2152,3 +2153,36 @@ grn_pat_cursor_delete(grn_ctx *ctx, grn_pat_cursor *c,
{
return grn_pat_delete_by_id(ctx, c->pat, c->curr_rec, optarg);
}
+
+void
+grn_pat_check(grn_ctx *ctx, grn_pat *pat)
+{
+ char buf[8];
+ struct grn_pat_header *h = pat->header;
+ GRN_OUTPUT_ARRAY_OPEN("RESULT", 8);
+ GRN_OUTPUT_MAP_OPEN("SUMMARY", 8);
+ GRN_OUTPUT_CSTR("flags");
+ grn_itoh(h->flags, buf, 8);
+ GRN_OUTPUT_STR(buf, 8);
+ GRN_OUTPUT_CSTR("key size");
+ GRN_OUTPUT_INT64(h->key_size);
+ GRN_OUTPUT_CSTR("value_size");
+ GRN_OUTPUT_INT64(h->value_size);
+ GRN_OUTPUT_CSTR("tokenizer");
+ GRN_OUTPUT_INT64(h->tokenizer);
+ GRN_OUTPUT_CSTR("n_entries");
+ GRN_OUTPUT_INT64(h->n_entries);
+ 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("curr_del");
+ GRN_OUTPUT_INT64(h->curr_del);
+ GRN_OUTPUT_CSTR("curr_del2");
+ GRN_OUTPUT_INT64(h->curr_del2);
+ GRN_OUTPUT_CSTR("curr_del3");
+ GRN_OUTPUT_INT64(h->curr_del3);
+ GRN_OUTPUT_CSTR("n_garbages");
+ GRN_OUTPUT_INT64(h->n_garbages);
+ GRN_OUTPUT_ARRAY_CLOSE();
+}
Modified: lib/pat.h (+1 -0)
===================================================================
--- lib/pat.h 2010-07-15 05:04:54 +0000 (4fefe38)
+++ lib/pat.h 2010-07-16 11:39:06 +0000 (3390755)
@@ -95,6 +95,7 @@ const char *_grn_pat_key(grn_ctx *ctx, grn_pat *pat, grn_id id, uint32_t *key_si
grn_id grn_pat_next(grn_ctx *ctx, grn_pat *pat, grn_id id);
const char *grn_pat_get_value_(grn_ctx *ctx, grn_pat *pat, grn_id id, uint32_t *size);
grn_id grn_pat_at(grn_ctx *ctx, grn_pat *pat, grn_id id);
+void grn_pat_check(grn_ctx *ctx, grn_pat *pat);
#ifdef __cplusplus
}
Modified: lib/proc.c (+4 -0)
===================================================================
--- lib/proc.c 2010-07-15 05:04:54 +0000 (096b0bc)
+++ lib/proc.c 2010-07-16 11:39:06 +0000 (4a29976)
@@ -1866,7 +1866,11 @@ proc_check(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
} else {
switch (obj->header.type) {
case GRN_DB :
+ GRN_OUTPUT_BOOL(!ctx->rc);
+ break;
case GRN_TABLE_PAT_KEY :
+ grn_pat_check(ctx, (grn_pat *)obj);
+ break;
case GRN_TABLE_HASH_KEY :
case GRN_TABLE_NO_KEY :
case GRN_COLUMN_VAR_SIZE :