[Groonga-commit] groonga/groonga [master] added last_tf

Back to archive index

null+****@clear***** null+****@clear*****
2012年 2月 9日 (木) 06:36:31 JST


Daijiro MORI	2012-02-09 06:36:31 +0900 (Thu, 09 Feb 2012)

  New Revision: 9a30869fc80684f2409e9095b85dc90e31a55b47

  Log:
    added last_tf

  Modified files:
    lib/ii.c

  Modified: lib/ii.c (+17 -12)
===================================================================
--- lib/ii.c    2012-02-08 23:15:08 +0900 (cd998ff)
+++ lib/ii.c    2012-02-09 06:36:31 +0900 (346e2d8)
@@ -6360,6 +6360,7 @@ typedef struct {
   uint32_t npostings;
   grn_id last_rid;
   uint32_t last_sid;
+  uint32_t last_tf;
   uint32_t last_pos;
   uint32_t offset_rid;
   uint32_t offset_sid;
@@ -6469,14 +6470,17 @@ grn_ii_builder_flush(grn_ctx *ctx, grn_ii_builder *builder)
       } else {
         builder_counter *counter = &builder->counters[id - 1];
         if (counter->last_rid == rid) {
-          outbuf[counter->offset + counter->nrecs]++;
+          counter->last_tf++;
         } else {
-          if (counter->last_rid) { counter->offset++; }
-          counter->last_sid = 0;
-          counter->last_pos = 0;
+          if (counter->last_rid) {
+            outbuf[counter->offset + counter->nrecs] = counter->last_tf;
+            counter->offset++;
+          }
           outbuf[counter->offset] = rid - counter->last_rid;
           counter->last_rid = rid;
-          outbuf[counter->offset + counter->nrecs] = 1;
+          counter->last_sid = 0;
+          counter->last_tf = 1;
+          counter->last_pos = 0;
         }
         outbuf[counter->nposts++] = pos - counter->last_pos;
         counter->last_pos = pos;
@@ -6485,16 +6489,10 @@ grn_ii_builder_flush(grn_ctx *ctx, grn_ii_builder *builder)
     }
   }
   {
-    ssize_t r = write(builder->tmpfd, outbuf, pos * sizeof(uint32_t));
-    if (r > 0) { builder->filepos += r; }
-    block->tail = builder->filepos;
-  }
-  builder->nblocks++;
-  GRN_FREE(outbuf);
-  {
     builder_counter *counter;
     grn_id tid, tid_max = grn_table_size(ctx, builder->tmp_lexicon);
     for (counter = builder->counters, tid = 1; tid <= tid_max; counter++, tid++) {
+      outbuf[counter->offset + counter->nrecs] = counter->last_tf;
       counter->nrecs = 0;
       counter->nposts = 0;
       counter->lastrec = 0;
@@ -6503,6 +6501,13 @@ grn_ii_builder_flush(grn_ctx *ctx, grn_ii_builder *builder)
       counter->last_rid = 0; /* FIXME */
     }
   }
+  {
+    ssize_t r = write(builder->tmpfd, outbuf, pos * sizeof(uint32_t));
+    if (r > 0) { builder->filepos += r; }
+    block->tail = builder->filepos;
+  }
+  builder->nblocks++;
+  GRN_FREE(outbuf);
   builder->blockpos = 0;
   grn_obj_close(ctx, builder->tmp_lexicon);
   builder->tmp_lexicon = NULL;




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