[Groonga-commit] groonga/groonga [master] only active records are moved in grn_ja_defrag_seg().

Back to archive index

null+****@clear***** null+****@clear*****
2010年 7月 27日 (火) 22:13:08 JST


Daijiro MORI	2010-07-27 13:13:08 +0000 (Tue, 27 Jul 2010)

  New Revision: 8c19f2619a53f0afd776d143523e182d92301ce5

  Log:
    only active records are moved in grn_ja_defrag_seg().

  Modified files:
    lib/store.c

  Modified: lib/store.c (+5 -6)
===================================================================
--- lib/store.c    2010-07-27 06:47:14 +0000 (f5b6946)
+++ lib/store.c    2010-07-27 13:13:08 +0000 (aaee261)
@@ -1014,11 +1014,11 @@ static grn_rc
 grn_ja_defrag_seg(grn_ctx *ctx, grn_ja *ja, uint32_t seg)
 {
   byte *v = NULL, *ve;
-  uint32_t element_size, *segusage = &SEGMENTS_AT(ja,seg);
+  uint32_t element_size, cum = 0, sum = (SEGMENTS_AT(ja,seg) & ~SEG_MASK);
   GRN_IO_SEG_REF(ja->io, seg, v);
   if (!v) { return GRN_NO_MEMORY_AVAILABLE; }
   ve = v + JA_SEGMENT_SIZE;
-  while (v < ve && (*segusage != SEG_SEQ)) {
+  while (v < ve && cum < sum) {
     grn_id id = *((grn_id *)v);
     if (id & DELETED) {
       element_size = (id & ~DELETED);
@@ -1028,13 +1028,12 @@ grn_ja_defrag_seg(grn_ctx *ctx, grn_ja *ja, uint32_t seg)
         return ctx->rc;
       }
       element_size = (element_size + sizeof(grn_id) - 1) & ~(sizeof(grn_id) - 1);
+      cum += sizeof(uint32_t) + element_size;
     }
     v += sizeof(uint32_t) + element_size;
   }
-  if (*segusage != SEG_SEQ) {
-    GRN_LOG(ctx, GRN_LOG_ERROR, "dseges[%d] = %d after defrag", seg, *segusage);
-  }
-  // *segusage = 0;
+  GRN_LOG(ctx, GRN_LOG_NOTICE, "dseges[%d] = %d after defrag",
+          seg, (SEGMENTS_AT(ja,seg) & ~SEG_MASK));
   GRN_IO_SEG_UNREF(ja->io, seg);
   return GRN_SUCCESS;
 }




Groonga-commit メーリングリストの案内
Back to archive index