[Groonga-commit] groonga/groonga [master] [geo] support limit.

Back to archive index

null+****@clear***** null+****@clear*****
2011年 10月 19日 (水) 23:05:28 JST


Kouhei Sutou	2011-10-19 14:05:28 +0000 (Wed, 19 Oct 2011)

  New Revision: d275f25e8a3bab7c021ae6ba9bfd2b523d543139

  Log:
    [geo] support limit.

  Modified files:
    lib/geo.c
    test/unit/core/test-geo-in-rectangle.c

  Modified: lib/geo.c (+6 -4)
===================================================================
--- lib/geo.c    2011-10-19 13:59:36 +0000 (59a5166)
+++ lib/geo.c    2011-10-19 14:05:28 +0000 (3545dd9)
@@ -1050,14 +1050,16 @@ grn_geo_cursor_each(grn_ctx *ctx, grn_obj *geo_cursor,
 
       while ((posting = grn_ii_cursor_next(ctx, ii_cursor))) {
         if (cursor->offset == 0) {
-          if (!callback(ctx, posting, user_data)) {
-            return;
-          }
+          grn_bool keep_each;
+          keep_each = callback(ctx, posting, user_data);
           if (cursor->rest > 0) {
             if (--(cursor->rest) == 0) {
-              return;
+              keep_each = GRN_FALSE;
             }
           }
+          if (!keep_each) {
+            return;
+          }
         } else {
           cursor->offset--;
         }

  Modified: test/unit/core/test-geo-in-rectangle.c (+19 -0)
===================================================================
--- test/unit/core/test-geo-in-rectangle.c    2011-10-19 13:59:36 +0000 (642d9f3)
+++ test/unit/core/test-geo-in-rectangle.c    2011-10-19 14:05:28 +0000 (336673b)
@@ -270,6 +270,25 @@ data_cursor(void)
                                 "nezu-no-taiyaki",
                                 NULL),
            0, -1);
+  ADD_DATA("offset",
+           gcut_list_string_new("hirose-ya",
+                                "taiyaki-kataoka",
+                                "kuruma",
+                                "nezu-no-taiyaki",
+                                NULL),
+           2, -1);
+  ADD_DATA("limit",
+           gcut_list_string_new("soba-taiyaki-ku",
+                                "sazare",
+                                "hirose-ya",
+                                NULL),
+           0, 3);
+  ADD_DATA("offset - limit",
+           gcut_list_string_new("hirose-ya",
+                                "taiyaki-kataoka",
+                                "kuruma",
+                                NULL),
+           2, 3);
 
 #undef ADD_DATA
 }




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