null+****@clear*****
null+****@clear*****
2012年 2月 9日 (木) 13:48:45 JST
Daijiro MORI 2012-02-09 13:48:45 +0900 (Thu, 09 Feb 2012) New Revision: 1eda759bae00455a9c3ac7c6aa907fc34b4f3cb7 Log: added GRN_B_ENC_SIZE Modified files: lib/ii.c lib/io.h Modified: lib/ii.c (+12 -13) =================================================================== --- lib/ii.c 2012-02-09 13:46:55 +0900 (346e2d8) +++ lib/ii.c 2012-02-09 13:48:45 +0900 (0f786fc) @@ -6472,7 +6472,7 @@ grn_ii_builder_flush(grn_ctx *ctx, grn_ii_builder *builder) if (counter->last_rid == rid) { counter->last_tf++; } else { - if (counter->last_rid) { + if (counter->last_tf) { outbuf[counter->offset + counter->nrecs] = counter->last_tf; counter->offset++; } @@ -6497,8 +6497,8 @@ grn_ii_builder_flush(grn_ctx *ctx, grn_ii_builder *builder) counter->nposts = 0; counter->lastrec = 0; counter->offset = 0; - - counter->last_rid = 0; /* FIXME */ + counter->last_rid = 0; + counter->last_tf = 0; } } { @@ -6734,17 +6734,16 @@ grn_ii_builder_merge_one(grn_ctx *ctx, grn_ii_builder *builder, uint32_t *rp = block->recs; uint32_t *tp = block->tfs; uint32_t *pp = block->posts; - uint32_t n; - for (n = block->nrecs; n; n--) { - uint32_t np; - if (n == block->nrecs) { /* FIXME */ - *ridp = *rp++ - lr; lr += *ridp++; - } else { - *ridp = *rp++; lr += *ridp++; - } + uint32_t np, n = block->nrecs; + *ridp = *rp++ - lr; lr += *ridp++; + for (np = *tp; np; np--) { + *posp = *pp++; spos += *posp++; + } + *tfp++ = *tp++ - 1; + while (--n) { + *ridp = *rp++; lr += *ridp++; for (np = *tp; np; np--) { - *posp = *pp++; - spos += *posp++; + *posp = *pp++; spos += *posp++; } *tfp++ = *tp++ - 1; } Modified: lib/io.h (+3 -0) =================================================================== --- lib/io.h 2012-02-09 13:46:55 +0900 (d0e778c) +++ lib/io.h 2012-02-09 13:48:45 +0900 (b65173f) @@ -392,6 +392,9 @@ uint32_t grn_expire(grn_ctx *ctx, int count_thresh, uint32_t limit); p = _p; \ } +#define GRN_B_ENC_SIZE(v) \ + ((v) < 0x8f ? 1 : ((v) < 0x408f ? 2 : ((v) < 0x20408f ? 3 : ((v) < 0x1020408f ? 4 : 5)))) + #define GRN_B_DEC(v,p) \ { \ uint8_t *_p = (uint8_t *)p; \