null+****@clear*****
null+****@clear*****
2010年 7月 26日 (月) 16:56:25 JST
Daijiro MORI 2010-07-26 07:56:25 +0000 (Mon, 26 Jul 2010)
New Revision: 1a983c2db54532a4f94614f82e66f6a1122f8eb4
Log:
Fixed a fatal bug in grn_ja_defrag_seg().
Modified files:
lib/pat.c
lib/proc.c
lib/store.c
lib/store.h
Modified: lib/pat.c (+1 -0)
===================================================================
--- lib/pat.c 2010-07-26 02:26:03 +0000 (b20ff10)
+++ lib/pat.c 2010-07-26 07:56:25 +0000 (75fee65)
@@ -2215,6 +2215,7 @@ grn_pat_check(grn_ctx *ctx, grn_pat *pat)
GRN_OUTPUT_INT64(h->curr_del3);
GRN_OUTPUT_CSTR("n_garbages");
GRN_OUTPUT_INT64(h->n_garbages);
+ GRN_OUTPUT_MAP_CLOSE();
GRN_OUTPUT_ARRAY_CLOSE();
}
Modified: lib/proc.c (+3 -1)
===================================================================
--- lib/proc.c 2010-07-26 02:26:03 +0000 (979ac79)
+++ lib/proc.c 2010-07-26 07:56:25 +0000 (8f1fe40)
@@ -1937,10 +1937,12 @@ proc_check(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
break;
case GRN_TABLE_HASH_KEY :
case GRN_TABLE_NO_KEY :
- case GRN_COLUMN_VAR_SIZE :
case GRN_COLUMN_FIX_SIZE :
GRN_OUTPUT_BOOL(!ctx->rc);
break;
+ case GRN_COLUMN_VAR_SIZE :
+ grn_ja_check(ctx, (grn_ja *)obj);
+ break;
case GRN_COLUMN_INDEX :
{
grn_ii *ii = (grn_ii *)obj;
Modified: lib/store.c (+39 -2)
===================================================================
--- lib/store.c 2010-07-26 02:26:03 +0000 (296dd5d)
+++ lib/store.c 2010-07-26 07:56:25 +0000 (e61f5bc)
@@ -18,6 +18,7 @@
#include "str.h"
#include "store.h"
#include "ql.h"
+#include "output.h"
#include <string.h>
/* rectangular arrays */
@@ -1031,8 +1032,8 @@ grn_ja_defrag_seg(grn_ctx *ctx, grn_ja *ja, uint32_t seg)
if (id & DELETED) {
element_size = (id & ~DELETED);
} else {
- element_size = grn_ja_size(ctx, ja, id) + sizeof(uint32_t);
- if (grn_ja_put(ctx, ja, id, v + sizeof(uint32_t), element_size, 0)) {
+ element_size = grn_ja_size(ctx, ja, id);
+ if (grn_ja_put(ctx, ja, id, v + sizeof(uint32_t), element_size, GRN_OBJ_SET)) {
return ctx->rc;
}
element_size = (element_size + sizeof(grn_id) - 1) & ~(sizeof(grn_id) - 1);
@@ -1063,6 +1064,42 @@ grn_ja_defrag(grn_ctx *ctx, grn_ja *ja, int threshold)
return nsegs;
}
+void
+grn_ja_check(grn_ctx *ctx, grn_ja *ja)
+{
+ char buf[8];
+ uint32_t seg;
+ struct grn_ja_header *h = ja->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("curr seg");
+ GRN_OUTPUT_INT64(h->curr_seg);
+ GRN_OUTPUT_CSTR("curr pos");
+ GRN_OUTPUT_INT64(h->curr_pos);
+ GRN_OUTPUT_CSTR("max_element_size");
+ GRN_OUTPUT_INT64(h->max_element_size);
+ GRN_OUTPUT_MAP_CLOSE();
+ GRN_OUTPUT_ARRAY_OPEN("DETAIL", 8);
+ for (seg = 0; seg < JA_N_DSEGMENTS; seg++) {
+ int dseg = SEGMENTS_AT(ja, seg);
+ if (dseg) {
+ GRN_OUTPUT_MAP_OPEN("SEG", -1);
+ GRN_OUTPUT_CSTR("seg id");
+ GRN_OUTPUT_INT64(seg);
+ GRN_OUTPUT_CSTR("seg type");
+ GRN_OUTPUT_INT64((dseg & SEG_MASK)>>28);
+ GRN_OUTPUT_CSTR("seg value");
+ GRN_OUTPUT_INT64(dseg & ~SEG_MASK);
+ GRN_OUTPUT_MAP_CLOSE();
+ }
+ }
+ GRN_OUTPUT_ARRAY_CLOSE();
+ GRN_OUTPUT_ARRAY_CLOSE();
+}
+
/**** vgram ****/
/*
Modified: lib/store.h (+2 -0)
===================================================================
--- lib/store.h 2010-07-26 02:26:03 +0000 (1608f10)
+++ lib/store.h 2010-07-26 07:56:25 +0000 (947e78e)
@@ -104,6 +104,8 @@ int grn_ja_defrag(grn_ctx *ctx, grn_ja *ja, int threshold);
grn_rc grn_ja_putv(grn_ctx *ctx, grn_ja *ja, grn_id id, grn_obj *vector, int flags);
+void grn_ja_check(grn_ctx *ctx, grn_ja *ja);
+
/*
typedef struct _grn_vgram_vnode