[Groonga-commit] groonga/groonga [master] Added cut off logic to grn_geo_search().

Back to archive index

null+****@clear***** null+****@clear*****
2010年 7月 2日 (金) 17:58:20 JST


Daijiro MORI	2010-07-02 08:58:20 +0000 (Fri, 02 Jul 2010)

  New Revision: e0478a9de630096d64b77207109fa69ba97afb64

  Log:
    Added cut off logic to grn_geo_search().

  Modified files:
    lib/proc.c

  Modified: lib/proc.c (+3 -1)
===================================================================
--- lib/proc.c    2010-07-02 08:38:23 +0000 (4a1141c)
+++ lib/proc.c    2010-07-02 08:58:20 +0000 (493f212)
@@ -2017,13 +2017,14 @@ grn_geo_search(grn_ctx *ctx, grn_obj *obj, grn_obj **args, int nargs,
     goto exit;
   }
   {
+    uint32_t s, h;
     grn_id tid;
     grn_geo_point pos;
     grn_table_cursor *tc = grn_table_cursor_open(ctx, pat, NULL, 0,
                                                  GRN_BULK_HEAD(pos1),
                                                  sizeof(grn_geo_point),
                                                  0, -1, GRN_CURSOR_PREFIX);
-    while ((tid = grn_table_cursor_next(ctx, tc))) {
+    for (s = 0, h = 256; s <= h * 16 && (tid = grn_table_cursor_next(ctx, tc)); s++) {
       grn_table_get_key(ctx, pat, tid, &pos, sizeof(grn_geo_point));
       lng0 = GEO_INT2RAD(pos.longitude);
       lat0 = GEO_INT2RAD(pos.latitude);
@@ -2031,6 +2032,7 @@ grn_geo_search(grn_ctx *ctx, grn_obj *obj, grn_obj **args, int nargs,
       y = (lat1 - lat0);
       if (((x * x) + (y * y)) <= d) {
         grn_ii_at(ctx, (grn_ii *)obj, tid, (grn_hash *)res, op);
+        h++;
       }
     }
     grn_table_cursor_close(ctx, tc);




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