[Groonga-commit] groonga/groonga [master] Support GRN_OBJ_WITH_POSITION in grn_index_cursor_next()

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Dec 4 19:22:08 JST 2012


Kouhei Sutou	2012-12-04 19:22:08 +0900 (Tue, 04 Dec 2012)

  New Revision: 4b28dab747d07883a4411719a7415885065ed340
  https://github.com/groonga/groonga/commit/4b28dab747d07883a4411719a7415885065ed340

  Merged 5aebe87: Merge pull request #42 from groonga/support-position-in-index-cursor-next

  Log:
    Support GRN_OBJ_WITH_POSITION in grn_index_cursor_next()
    
    We cannot get position inforamtion by grn_index_cursor_* API. It will
    be used by rroonga.

  Modified files:
    lib/db.c

  Modified: lib/db.c (+14 -1)
===================================================================
--- lib/db.c    2012-12-04 00:14:50 +0900 (cab6c84)
+++ lib/db.c    2012-12-04 19:22:08 +0900 (2352954)
@@ -2667,7 +2667,17 @@ grn_index_cursor_next(grn_ctx *ctx, grn_obj *c, grn_id *tid)
   grn_ii_posting *ip = NULL;
   grn_index_cursor *ic = (grn_index_cursor *)c;
   GRN_API_ENTER;
-  if (ic->iic) { ip = grn_ii_cursor_next(ctx, ic->iic); }
+  if (ic->iic) {
+    if (ic->flags & GRN_OBJ_WITH_POSITION) {
+      ip = grn_ii_cursor_next_pos(ctx, ic->iic);
+      while (!ip && grn_ii_cursor_next(ctx, ic->iic)) {
+        ip = grn_ii_cursor_next_pos(ctx, ic->iic);
+        break;
+      }
+    } else {
+      ip = grn_ii_cursor_next(ctx, ic->iic);
+    }
+  }
   if (!ip) {
     while ((ic->tid = grn_table_cursor_next_inline(ctx, ic->tc))) {
       grn_ii *ii = (grn_ii *)ic->index;
@@ -2676,6 +2686,9 @@ grn_index_cursor_next(grn_ctx *ctx, grn_obj *c, grn_id *tid)
                                         ic->rid_min, ic->rid_max,
                                         ii->n_elements, ic->flags))) {
         ip = grn_ii_cursor_next(ctx, ic->iic);
+        if (ip && ic->flags & GRN_OBJ_WITH_POSITION) {
+          ip = grn_ii_cursor_next_pos(ctx, ic->iic);
+        }
         break;
       }
     }
-------------- next part --------------
HTML����������������������������...
Télécharger 



More information about the Groonga-commit mailing list
Back to archive index