[Groonga-commit] groonga/grnxx at 59d03b8 [master] Update Index::find() to return an empty cursor if N/A is given.

Back to archive index

susumu.yata null+****@clear*****
Tue Dec 2 18:11:15 JST 2014


susumu.yata	2014-12-02 18:11:15 +0900 (Tue, 02 Dec 2014)

  New Revision: 59d03b8f976737b3644f1892885efe3a5d9a2e5a
  https://github.com/groonga/grnxx/commit/59d03b8f976737b3644f1892885efe3a5d9a2e5a

  Message:
    Update Index::find() to return an empty cursor if N/A is given.

  Modified files:
    lib/grnxx/impl/index.cpp

  Modified: lib/grnxx/impl/index.cpp (+9 -3)
===================================================================
--- lib/grnxx/impl/index.cpp    2014-12-02 18:06:24 +0900 (8488382)
+++ lib/grnxx/impl/index.cpp    2014-12-02 18:11:15 +0900 (6c93579)
@@ -376,7 +376,9 @@ void TreeIndex<Int>::remove(Int row_id, const Datum &value) {
 std::unique_ptr<Cursor> TreeIndex<Int>::find(
     const Datum &value,
     const CursorOptions &options) const {
-  if (value.type() != INT_DATA) {
+  if (value.type() == NA_DATA) {
+    return create_empty_cursor();
+  } else if (value.type() != INT_DATA) {
     throw "Data type conflict";  // TODO
   }
   auto map_it = map_.find(value.as_int());
@@ -534,7 +536,9 @@ void TreeIndex<Float>::remove(Int row_id, const Datum &value) {
 std::unique_ptr<Cursor> TreeIndex<Float>::find(
     const Datum &value,
     const CursorOptions &options) const {
-  if (value.type() != FLOAT_DATA) {
+  if (value.type() == NA_DATA) {
+    return create_empty_cursor();
+  } else if (value.type() != FLOAT_DATA) {
     throw "Data type conflict";  // TODO
   }
   auto map_it = map_.find(value.as_float());
@@ -702,7 +706,9 @@ void TreeIndex<Text>::remove(Int row_id, const Datum &value) {
 std::unique_ptr<Cursor> TreeIndex<Text>::find(
     const Datum &value,
     const CursorOptions &options) const {
-  if (value.type() != TEXT_DATA) {
+  if (value.type() == NA_DATA) {
+    return create_empty_cursor();
+  } else if (value.type() != TEXT_DATA) {
     throw "Data type conflict";  // TODO
   }
   Text text = value.as_text();
-------------- next part --------------
HTML����������������������������...
Télécharger 



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