[Groonga-commit] groonga/grnxx [master] Update the interface of MapCursor.

Back to archive index

susumu.yata null+****@clear*****
Fri Mar 15 15:34:06 JST 2013


susumu.yata	2013-03-15 15:34:06 +0900 (Fri, 15 Mar 2013)

  New Revision: 4e44bab64ff693f3581c360e1be5f38ee0ae1898
  https://github.com/groonga/grnxx/commit/4e44bab64ff693f3581c360e1be5f38ee0ae1898

  Message:
    Update the interface of MapCursor.

  Modified files:
    lib/map.hpp
    lib/map/da/basic/trie.cpp
    lib/map/da/basic/trie.hpp
    lib/map/da/large/trie.cpp
    lib/map/da/large/trie.hpp
    lib/map/da/trie.hpp
    lib/map/double_array.cpp
    lib/map/double_array.hpp
    test/test_map_da_basic_trie.cpp

  Modified: lib/map.hpp (+1 -1)
===================================================================
--- lib/map.hpp    2013-03-15 15:04:55 +0900 (d648211)
+++ lib/map.hpp    2013-03-15 15:34:06 +0900 (9c3de3e)
@@ -272,7 +272,7 @@ class Map {
   // Find keys in prefixes of "query". "flags" accepts MAP_CURSOR_ASCENDING,
   // MAP_CURSOR_DESCENDING, and MAP_CURSOR_EXCEPT_MAX.
   virtual MapCursor *open_prefix_cursor(MapCursorFlags flags,
-                                        const Slice &max,
+                                        size_t min, const Slice &max,
                                         int64_t offset, int64_t limit) = 0;
   // Find keys starting with "query". "flags" accepts MAP_CURSOR_ASCENDING,
   // MAP_CURSOR_DESCENDING, and MAP_CURSOR_EXCEPT_MIN.

  Modified: lib/map/da/basic/trie.cpp (+2 -3)
===================================================================
--- lib/map/da/basic/trie.cpp    2013-03-15 15:04:55 +0900 (d123c6b)
+++ lib/map/da/basic/trie.cpp    2013-03-15 15:34:06 +0900 (521cf5c)
@@ -341,8 +341,7 @@ bool Trie::update(const Slice &src_key, const Slice &dest_key,
 MapCursor *Trie::open_id_cursor(MapCursorFlags flags,
                                 int64_t min, int64_t max,
                                 int64_t offset, int64_t limit) {
-  // TODO
-  return nullptr;
+  return IDCursor::open(this, flags, min, max, offset, limit);
 }
 
 MapCursor *Trie::open_key_cursor(MapCursorFlags flags,
@@ -353,7 +352,7 @@ MapCursor *Trie::open_key_cursor(MapCursorFlags flags,
 }
 
 MapCursor *Trie::open_prefix_cursor(MapCursorFlags flags,
-                                    const Slice &max,
+                                    size_t min, const Slice &max,
                                     int64_t offset, int64_t limit) {
   // TODO
   return nullptr;

  Modified: lib/map/da/basic/trie.hpp (+2 -1)
===================================================================
--- lib/map/da/basic/trie.hpp    2013-03-15 15:04:55 +0900 (f6a2a8c)
+++ lib/map/da/basic/trie.hpp    2013-03-15 15:34:06 +0900 (7acbc93)
@@ -454,7 +454,8 @@ class Trie : public da::Trie {
   MapCursor *open_key_cursor(MapCursorFlags flags,
                              const Slice &min, const Slice &max,
                              int64_t offset, int64_t limit);
-  MapCursor *open_prefix_cursor(MapCursorFlags flags, const Slice &max,
+  MapCursor *open_prefix_cursor(MapCursorFlags flags,
+                                size_t min, const Slice &max,
                                 int64_t offset, int64_t limit);
   MapCursor *open_predictive_cursor(MapCursorFlags flags, const Slice &min,
                                     int64_t offset, int64_t limit);

  Modified: lib/map/da/large/trie.cpp (+1 -1)
===================================================================
--- lib/map/da/large/trie.cpp    2013-03-15 15:04:55 +0900 (f062efe)
+++ lib/map/da/large/trie.cpp    2013-03-15 15:34:06 +0900 (c5d4ab1)
@@ -364,7 +364,7 @@ MapCursor *Trie::open_key_cursor(MapCursorFlags flags,
 }
 
 MapCursor *Trie::open_prefix_cursor(MapCursorFlags flags,
-                                    const Slice &max,
+                                    size_t min, const Slice &max,
                                     int64_t offset, int64_t limit) {
   // TODO
   return nullptr;

  Modified: lib/map/da/large/trie.hpp (+2 -1)
===================================================================
--- lib/map/da/large/trie.hpp    2013-03-15 15:04:55 +0900 (06dc45d)
+++ lib/map/da/large/trie.hpp    2013-03-15 15:34:06 +0900 (896c1a8)
@@ -446,7 +446,8 @@ class Trie : public da::Trie {
   MapCursor *open_key_cursor(MapCursorFlags flags,
                              const Slice &min, const Slice &max,
                              int64_t offset, int64_t limit);
-  MapCursor *open_prefix_cursor(MapCursorFlags flags, const Slice &max,
+  MapCursor *open_prefix_cursor(MapCursorFlags flags,
+                                size_t min, const Slice &max,
                                 int64_t offset, int64_t limit);
   MapCursor *open_predictive_cursor(MapCursorFlags flags, const Slice &min,
                                     int64_t offset, int64_t limit);

  Modified: lib/map/da/trie.hpp (+1 -1)
===================================================================
--- lib/map/da/trie.hpp    2013-03-15 15:04:55 +0900 (22ffc22)
+++ lib/map/da/trie.hpp    2013-03-15 15:34:06 +0900 (ac4b6ed)
@@ -90,7 +90,7 @@ class Trie {
                                      const Slice &min, const Slice &max,
                                      int64_t offset, int64_t limit) = 0;
   virtual MapCursor *open_prefix_cursor(MapCursorFlags flags,
-                                        const Slice &max,
+                                        size_t min, const Slice &max,
                                         int64_t offset, int64_t limit) = 0;
   virtual MapCursor *open_predictive_cursor(MapCursorFlags flags,
                                             const Slice &min,

  Modified: lib/map/double_array.cpp (+2 -2)
===================================================================
--- lib/map/double_array.cpp    2013-03-15 15:04:55 +0900 (ace2213)
+++ lib/map/double_array.cpp    2013-03-15 15:34:06 +0900 (5ed2f92)
@@ -177,14 +177,14 @@ MapCursor *DoubleArray::open_key_cursor(MapCursorFlags flags,
 }
 
 MapCursor *DoubleArray::open_prefix_cursor(MapCursorFlags flags,
-                                           const Slice &max,
+                                           size_t min, const Slice &max,
                                            int64_t offset, int64_t limit) {
   open_trie_if_needed();
   if (!front_) {
     // TODO
     return nullptr;
   }
-  return front_->open_prefix_cursor(flags, max, offset, limit);
+  return front_->open_prefix_cursor(flags, min, max, offset, limit);
 }
 
 MapCursor *DoubleArray::open_predictive_cursor(MapCursorFlags flags,

  Modified: lib/map/double_array.hpp (+2 -1)
===================================================================
--- lib/map/double_array.hpp    2013-03-15 15:04:55 +0900 (e5e281f)
+++ lib/map/double_array.hpp    2013-03-15 15:34:06 +0900 (e384ca3)
@@ -63,7 +63,8 @@ class DoubleArray : public Map {
   MapCursor *open_key_cursor(MapCursorFlags flags,
                              const Slice &min, const Slice &max,
                              int64_t offset, int64_t limit);
-  MapCursor *open_prefix_cursor(MapCursorFlags flags, const Slice &max,
+  MapCursor *open_prefix_cursor(MapCursorFlags flags,
+                                size_t min, const Slice &max,
                                 int64_t offset, int64_t limit);
   MapCursor *open_predictive_cursor(MapCursorFlags flags, const Slice &min,
                                     int64_t offset, int64_t limit);

  Modified: test/test_map_da_basic_trie.cpp (+11 -12)
===================================================================
--- test/test_map_da_basic_trie.cpp    2013-03-15 15:04:55 +0900 (9c357e1)
+++ test/test_map_da_basic_trie.cpp    2013-03-15 15:34:06 +0900 (104623d)
@@ -376,8 +376,7 @@ void test_id_cursor() {
   }
 
   std::unique_ptr<grnxx::MapCursor> cursor(
-      grnxx::map::da::basic::IDCursor::open(
-          trie.get(), grnxx::MapCursorFlags(), 0, -1, 0, -1));
+      trie->open_id_cursor(grnxx::MapCursorFlags(), 0, -1, 0, -1));
   for (std::size_t i = 0; i < NUM_KEYS; ++i) {
     assert(cursor->next());
     assert(cursor->key_id() == static_cast<std::int64_t>(i));
@@ -385,8 +384,8 @@ void test_id_cursor() {
   }
   assert(!cursor->next());
 
-  cursor.reset(grnxx::map::da::basic::IDCursor::open(
-      trie.get(), grnxx::MapCursorFlags(), 0, -1, NUM_KEYS / 2, -1));
+  cursor.reset(trie->open_id_cursor(
+      grnxx::MapCursorFlags(), 0, -1, NUM_KEYS / 2, -1));
   for (std::size_t i = NUM_KEYS / 2; i < NUM_KEYS; ++i) {
     assert(cursor->next());
     assert(cursor->key_id() == static_cast<std::int64_t>(i));
@@ -394,8 +393,8 @@ void test_id_cursor() {
   }
   assert(!cursor->next());
 
-  cursor.reset(grnxx::map::da::basic::IDCursor::open(
-      trie.get(), grnxx::MapCursorFlags(), 0, -1, 0, NUM_KEYS / 2));
+  cursor.reset(trie->open_id_cursor(
+      grnxx::MapCursorFlags(), 0, -1, 0, NUM_KEYS / 2));
   for (std::size_t i = 0; i < NUM_KEYS / 2; ++i) {
     assert(cursor->next());
     assert(cursor->key_id() == static_cast<std::int64_t>(i));
@@ -403,8 +402,8 @@ void test_id_cursor() {
   }
   assert(!cursor->next());
 
-  cursor.reset(grnxx::map::da::basic::IDCursor::open(
-      trie.get(), grnxx::MAP_CURSOR_DESCENDING, 0, -1, 0, -1));
+  cursor.reset(trie->open_id_cursor(
+      grnxx::MAP_CURSOR_DESCENDING, 0, -1, 0, -1));
   for (std::size_t i = 0; i < NUM_KEYS; ++i) {
     assert(cursor->next());
     assert(cursor->key_id() == static_cast<std::int64_t>(NUM_KEYS - i - 1));
@@ -412,14 +411,14 @@ void test_id_cursor() {
   }
   assert(!cursor->next());
 
-  cursor.reset(grnxx::map::da::basic::IDCursor::open(
-      trie.get(), grnxx::MAP_CURSOR_EXCEPT_MIN, 0, 1, 0, -1));
+  cursor.reset(trie->open_id_cursor(
+      grnxx::MAP_CURSOR_EXCEPT_MIN, 0, 1, 0, -1));
   assert(cursor->next());
   assert(cursor->key_id() == 1);
   assert(!cursor->next());
 
-  cursor.reset(grnxx::map::da::basic::IDCursor::open(
-      trie.get(), grnxx::MAP_CURSOR_EXCEPT_MAX, 2, 3, 0, -1));
+  cursor.reset(trie->open_id_cursor(
+      grnxx::MAP_CURSOR_EXCEPT_MAX, 2, 3, 0, -1));
   assert(cursor->next());
   assert(cursor->key_id() == 2);
   assert(!cursor->next());
-------------- next part --------------
HTML����������������������������...
下载 



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