[Groonga-commit] groonga/groonga at f27fa66 [master] Export grn_geo_table_sort()

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Oct 6 17:10:45 JST 2015


Kouhei Sutou	2015-10-06 17:10:45 +0900 (Tue, 06 Oct 2015)

  New Revision: f27fa66b80baa14b3c8968773cd1dcae5499e04a
  https://github.com/groonga/groonga/commit/f27fa66b80baa14b3c8968773cd1dcae5499e04a

  Message:
    Export grn_geo_table_sort()
    
    It's for Rroonga.

  Copied files:
    include/groonga/geo.h
      (from include/groonga.h)
  Modified files:
    include/groonga.h
    lib/db.c
    lib/geo.c
    lib/grn_geo.h

  Modified: include/groonga.h (+1 -0)
===================================================================
--- include/groonga.h    2015-10-06 16:32:47 +0900 (f2250c8)
+++ include/groonga.h    2015-10-06 17:10:45 +0900 (8f68051)
@@ -22,6 +22,7 @@
 #include "groonga/groonga.h"
 #include "groonga/obj.h"
 #include "groonga/ii.h"
+#include "groonga/geo.h"
 #include "groonga/expr.h"
 #include "groonga/output.h"
 #include "groonga/util.h"

  Copied: include/groonga/geo.h (+23 -16) 58%
===================================================================
--- include/groonga.h    2015-10-06 16:32:47 +0900 (f2250c8)
+++ include/groonga/geo.h    2015-10-06 17:10:45 +0900 (b7a954b)
@@ -1,5 +1,6 @@
+/* -*- c-basic-offset: 2 -*- */
 /*
-  Copyright(C) 2014-2015 Brazil
+  Copyright(C) 2015 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -15,18 +16,24 @@
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
-#ifndef GROONGA_H
-#define GROONGA_H
-
-#include "groonga/portability.h"
-#include "groonga/groonga.h"
-#include "groonga/obj.h"
-#include "groonga/ii.h"
-#include "groonga/expr.h"
-#include "groonga/output.h"
-#include "groonga/util.h"
-#include "groonga/request_canceler.h"
-#include "groonga/thread.h"
-#include "groonga/windows_event_logger.h"
-
-#endif /* GROONGA_H */
+
+#ifndef GROONGA_GEO_H
+#define GROONGA_GEO_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+GRN_API int grn_geo_table_sort(grn_ctx *ctx,
+                               grn_obj *table,
+                               int offset,
+                               int limit,
+                               grn_obj *result,
+                               grn_obj *column,
+                               grn_obj *geo_point);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GROONGA_GEO_H */

  Modified: lib/db.c (+6 -1)
===================================================================
--- lib/db.c    2015-10-06 16:32:47 +0900 (2332ad5)
+++ lib/db.c    2015-10-06 17:10:45 +0900 (0370de2)
@@ -11008,7 +11008,12 @@ grn_table_sort(grn_ctx *ctx, grn_obj *table, int offset, int limit,
     e = offset + limit;
   }
   if (keys->flags & GRN_TABLE_SORT_GEO) {
-    i = grn_geo_table_sort(ctx, table, offset, limit, result, keys, n_keys);
+    if (n_keys == 2) {
+      i = grn_geo_table_sort(ctx, table, offset, limit, result,
+                             keys[0].key, keys[1].key);
+    } else {
+      i = 0;
+    }
     goto exit;
   }
   if (n_keys == 1 && !GRN_ACCESSORP(keys->key) &&

  Modified: lib/geo.c (+6 -6)
===================================================================
--- lib/geo.c    2015-10-06 16:32:47 +0900 (d94419d)
+++ lib/geo.c    2015-10-06 17:10:45 +0900 (c12c817)
@@ -686,18 +686,18 @@ grn_geo_table_sort_by_distance(grn_ctx *ctx,
 
 int
 grn_geo_table_sort(grn_ctx *ctx, grn_obj *table, int offset, int limit,
-                   grn_obj *result, grn_table_sort_key *keys, int n_keys)
+                   grn_obj *result, grn_obj *column, grn_obj *geo_point)
 {
   grn_obj *index;
   int i = 0, e = offset + limit;
-  grn_bool accessorp = GRN_ACCESSORP(keys->key);
-  if (n_keys == 2 && (index = find_geo_sort_index(ctx, keys->key))) {
+  grn_bool accessorp = GRN_ACCESSORP(column);
+  if ((index = find_geo_sort_index(ctx, column))) {
     grn_id tid;
-    grn_obj *arg = keys[1].key;
     grn_pat *pat = (grn_pat *)grn_ctx_at(ctx, index->header.domain);
     grn_id domain = pat->obj.header.domain;
     grn_pat_cursor *pc = grn_pat_cursor_open(ctx, pat, NULL, 0,
-                                             GRN_BULK_HEAD(arg), GRN_BULK_VSIZE(arg),
+                                             GRN_BULK_HEAD(geo_point),
+                                             GRN_BULK_VSIZE(geo_point),
                                              0, -1, GRN_CURSOR_PREFIX);
     if (pc) {
       if (domain != GRN_DB_TOKYO_GEO_POINT && domain != GRN_DB_WGS84_GEO_POINT) {
@@ -717,7 +717,7 @@ grn_geo_table_sort(grn_ctx *ctx, grn_obj *table, int offset, int limit,
           }
         }
       } else {
-        grn_geo_point *base_point = (grn_geo_point *)GRN_BULK_HEAD(arg);
+        grn_geo_point *base_point = (grn_geo_point *)GRN_BULK_HEAD(geo_point);
         i = grn_geo_table_sort_by_distance(ctx, table, index, pat,
                                            pc, accessorp, base_point,
                                            offset, limit, result);

  Modified: lib/grn_geo.h (+0 -3)
===================================================================
--- lib/grn_geo.h    2015-10-06 16:32:47 +0900 (5becbe4)
+++ lib/grn_geo.h    2015-10-06 17:10:45 +0900 (14e8d81)
@@ -125,9 +125,6 @@ typedef struct {
 grn_rc grn_geo_cursor_close(grn_ctx *ctx, grn_obj *geo_cursor);
 
 
-int grn_geo_table_sort(grn_ctx *ctx, grn_obj *table, int offset, int limit,
-                       grn_obj *result, grn_table_sort_key *keys, int n_keys);
-
 grn_rc grn_geo_resolve_approximate_type(grn_ctx *ctx, grn_obj *type_name,
                                         grn_geo_approximate_type *type);
 
-------------- next part --------------
HTML����������������������������...
Download 



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