[Groonga-commit] groonga/grnxx at c5710b6 [master] Update find_starts_with/prefixes() to return an empty cursor if N/A is given.

Back to archive index

susumu.yata null+****@clear*****
Tue Dec 2 18:13:05 JST 2014


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

  New Revision: c5710b671b1e05ae2bbcdd9c68ffa144030b0255
  https://github.com/groonga/grnxx/commit/c5710b671b1e05ae2bbcdd9c68ffa144030b0255

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

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

  Modified: lib/grnxx/impl/index.cpp (+8 -4)
===================================================================
--- lib/grnxx/impl/index.cpp    2014-12-02 18:11:15 +0900 (6c93579)
+++ lib/grnxx/impl/index.cpp    2014-12-02 18:13:05 +0900 (144d0d3)
@@ -786,12 +786,14 @@ std::unique_ptr<Cursor> TreeIndex<Text>::find_starts_with(
     const EndPoint &prefix,
     const CursorOptions &options) const {
   // TODO: Typecast will be supported in future?
-  if (prefix.value.type() != TEXT_DATA) {
+  if (prefix.value.type() == NA_DATA) {
+    return create_empty_cursor();
+  } else if (prefix.value.type() != TEXT_DATA) {
     throw "Data type conflict";  // TODO
   }
   Text text = prefix.value.as_text();
   if (text.is_na()) {
-    throw "No prefix";  // TODO
+    return create_empty_cursor();
   }
   String lower_bound_value(text.raw_data(), text.raw_size());
 
@@ -824,12 +826,14 @@ std::unique_ptr<Cursor> TreeIndex<Text>::find_prefixes(
     const Datum &value,
     const CursorOptions &options) const {
   // TODO: Typecast will be supported in future?
-  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();
   if (text.is_na()) {
-    throw "No value";  // TODO
+    return create_empty_cursor();
   }
   String string(text.raw_data(), text.raw_size());
   Array<Map::iterator> array;
-------------- next part --------------
HTML����������������������������...
Download 



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