[Groonga-commit] groonga/grnxx at 58ea20c [master] Update Sorter to support GeoPoint.

Back to archive index

susumu.yata null+****@clear*****
Wed Jul 30 18:04:05 JST 2014


susumu.yata	2014-07-30 18:04:05 +0900 (Wed, 30 Jul 2014)

  New Revision: 58ea20c0045a726a187b2e85ed65c9016ad3ab01
  https://github.com/groonga/grnxx/commit/58ea20c0045a726a187b2e85ed65c9016ad3ab01

  Message:
    Update Sorter to support GeoPoint.

  Modified files:
    lib/grnxx/sorter.cpp

  Modified: lib/grnxx/sorter.cpp (+21 -0)
===================================================================
--- lib/grnxx/sorter.cpp    2014-07-30 18:01:59 +0900 (2acc42a)
+++ lib/grnxx/sorter.cpp    2014-07-30 18:04:05 +0900 (1325994)
@@ -48,6 +48,17 @@ struct RegularComparer {
   }
 };
 
+template <>
+struct RegularComparer<GeoPoint> {
+  using Value = GeoPoint;
+  bool operator()(Value lhs, Value rhs) const {
+    if (lhs.latitude() != rhs.latitude()) {
+      return lhs.latitude() < rhs.latitude();
+    }
+    return lhs.longitude() < rhs.longitude();
+  }
+};
+
 template <typename T>
 struct ReverseComparer {
   using Value = T;
@@ -346,6 +357,16 @@ unique_ptr<SorterNode> SorterNode::create(Error *error, Order &&order) {
       }
       break;
     }
+    case GEO_POINT_DATA: {
+      if (order.type == REGULAR_ORDER) {
+        node.reset(new (nothrow) Node<RegularComparer<GeoPoint>>(
+            std::move(order)));
+      } else {
+        node.reset(new (nothrow) Node<ReverseComparer<GeoPoint>>(
+            std::move(order)));
+      }
+      break;
+    }
     case TEXT_DATA: {
       if (order.type == REGULAR_ORDER) {
         node.reset(new (nothrow) Node<RegularComparer<Text>>(
-------------- next part --------------
HTML����������������������������...
下載 



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