[Groonga-commit] groonga/grnxx [master] Rename search*() to find*().

Back to archive index

susumu.yata null+****@clear*****
Mon Apr 15 11:18:20 JST 2013


susumu.yata	2013-04-15 11:18:20 +0900 (Mon, 15 Apr 2013)

  New Revision: 110d8c449ec82b3f86b5f2f3bc76605355b89dce
  https://github.com/groonga/grnxx/commit/110d8c449ec82b3f86b5f2f3bc76605355b89dce

  Message:
    Rename search*() to find*().

  Modified files:
    lib/grnxx/alpha/map.cpp
    lib/grnxx/alpha/map.hpp
    lib/grnxx/alpha/map/array.cpp
    lib/grnxx/alpha/map/array.hpp
    lib/grnxx/alpha/map/double_array.cpp
    lib/grnxx/alpha/map/double_array.hpp
    test/test_alpha_map.cpp

  Modified: lib/grnxx/alpha/map.cpp (+1 -1)
===================================================================
--- lib/grnxx/alpha/map.cpp    2013-04-15 10:42:58 +0900 (a96e003)
+++ lib/grnxx/alpha/map.cpp    2013-04-15 11:18:20 +0900 (ffc1cfb)
@@ -179,7 +179,7 @@ bool Map<T>::reset(int64_t, T) {
 }
 
 template <typename T>
-bool Map<T>::search(T, int64_t *) {
+bool Map<T>::find(T, int64_t *) {
   // Not supported.
   return false;
 }

  Modified: lib/grnxx/alpha/map.hpp (+2 -2)
===================================================================
--- lib/grnxx/alpha/map.hpp    2013-04-15 10:42:58 +0900 (ff21f62)
+++ lib/grnxx/alpha/map.hpp    2013-04-15 11:18:20 +0900 (cb16e93)
@@ -132,9 +132,9 @@ class Map {
   // on success.
   virtual bool reset(int64_t key_id, T dest_key);
 
-  // Search "key" and return true on success.
+  // Find "key" and return true on success.
   // Assign the ID to "*key_id" iff "key_id" != nullptr.
-  virtual bool search(T key, int64_t *key_id = nullptr);
+  virtual bool find(T key, int64_t *key_id = nullptr);
   // Insert "key" and return true on success.
   // Assign the ID to "*key_id" iff "key_id" != nullptr.
   virtual bool insert(T key, int64_t *key_id = nullptr);

  Modified: lib/grnxx/alpha/map/array.cpp (+10 -10)
===================================================================
--- lib/grnxx/alpha/map/array.cpp    2013-04-15 10:42:58 +0900 (645d4b3)
+++ lib/grnxx/alpha/map/array.cpp    2013-04-15 11:18:20 +0900 (15966ac)
@@ -154,7 +154,7 @@ bool Array<T>::reset(int64_t key_id, T dest_key) {
   if (!get_bit(key_id)) {
     return false;
   }
-  if (search(dest_key)) {
+  if (find(dest_key)) {
     return false;
   }
   keys_[key_id] = Helper<T>::normalize(dest_key);
@@ -162,7 +162,7 @@ bool Array<T>::reset(int64_t key_id, T dest_key) {
 }
 
 template <typename T>
-bool Array<T>::search(T key, int64_t *key_id) {
+bool Array<T>::find(T key, int64_t *key_id) {
   for (int64_t i = 0; i <= header_->max_key_id; ++i) {
     if (get_bit(i)) {
       if (Helper<T>::equal_to(key, keys_[i])) {
@@ -206,7 +206,7 @@ bool Array<T>::insert(T key, int64_t *key_id) {
 template <typename T>
 bool Array<T>::remove(T key) {
   int64_t key_id;
-  if (!search(key, &key_id)) {
+  if (!find(key, &key_id)) {
     return false;
   }
   set_bit(key_id, false);
@@ -216,10 +216,10 @@ bool Array<T>::remove(T key) {
 template <typename T>
 bool Array<T>::update(T src_key, T dest_key, int64_t *key_id) {
   int64_t src_key_id;
-  if (!search(src_key, &src_key_id)) {
+  if (!find(src_key, &src_key_id)) {
     return false;
   }
-  if (search(dest_key)) {
+  if (find(dest_key)) {
     return false;
   }
   keys_[src_key_id] = Helper<T>::normalize(dest_key);
@@ -333,7 +333,7 @@ bool Array<Slice>::reset(int64_t key_id, Slice dest_key) {
   if (!blob) {
     return false;
   }
-  if (!dest_key || search(dest_key)) {
+  if (!dest_key || find(dest_key)) {
     return false;
   }
   std::string buf;
@@ -341,7 +341,7 @@ bool Array<Slice>::reset(int64_t key_id, Slice dest_key) {
   return true;
 }
 
-bool Array<Slice>::search(Slice key, int64_t *key_id) {
+bool Array<Slice>::find(Slice key, int64_t *key_id) {
   for (int64_t i = 0; i <= header_->max_key_id; ++i) {
     db::Blob blob = keys_[i].get();
     if (key == blob_to_slice(blob)) {
@@ -384,7 +384,7 @@ bool Array<Slice>::insert(Slice key, int64_t *key_id) {
 
 bool Array<Slice>::remove(Slice key) {
   int64_t key_id;
-  if (!search(key, &key_id)) {
+  if (!find(key, &key_id)) {
     return false;
   }
   keys_[key_id] = nullptr;
@@ -393,10 +393,10 @@ bool Array<Slice>::remove(Slice key) {
 
 bool Array<Slice>::update(Slice src_key, Slice dest_key, int64_t *key_id) {
   int64_t src_key_id;
-  if (!search(src_key, &src_key_id)) {
+  if (!find(src_key, &src_key_id)) {
     return false;
   }
-  if (!dest_key || search(dest_key)) {
+  if (!dest_key || find(dest_key)) {
     return false;
   }
   std::string buf;

  Modified: lib/grnxx/alpha/map/array.hpp (+2 -2)
===================================================================
--- lib/grnxx/alpha/map/array.hpp    2013-04-15 10:42:58 +0900 (e3def13)
+++ lib/grnxx/alpha/map/array.hpp    2013-04-15 11:18:20 +0900 (58d9f45)
@@ -55,7 +55,7 @@ class Array : public grnxx::alpha::Map<T> {
   bool unset(int64_t key_id);
   bool reset(int64_t key_id, T dest_key);
 
-  bool search(T key, int64_t *key_id = nullptr);
+  bool find(T key, int64_t *key_id = nullptr);
   bool insert(T key, int64_t *key_id = nullptr);
   bool remove(T key);
   bool update(T src_key, T dest_key, int64_t *key_id = nullptr);
@@ -103,7 +103,7 @@ class Array<Slice> : public grnxx::alpha::Map<Slice> {
   bool unset(int64_t key_id);
   bool reset(int64_t key_id, Slice dest_key);
 
-  bool search(Slice key, int64_t *key_id = nullptr);
+  bool find(Slice key, int64_t *key_id = nullptr);
   bool insert(Slice key, int64_t *key_id = nullptr);
   bool remove(Slice key);
   bool update(Slice src_key, Slice dest_key, int64_t *key_id = nullptr);

  Modified: lib/grnxx/alpha/map/double_array.cpp (+9 -9)
===================================================================
--- lib/grnxx/alpha/map/double_array.cpp    2013-04-15 10:42:58 +0900 (75d38eb)
+++ lib/grnxx/alpha/map/double_array.cpp    2013-04-15 11:18:20 +0900 (edc4457)
@@ -567,14 +567,14 @@ bool DoubleArray<T>::reset(int64_t key_id, T dest_key) {
 }
 
 template <typename T>
-bool DoubleArray<T>::search(T key, int64_t *key_id) {
+bool DoubleArray<T>::find(T key, int64_t *key_id) {
   if ((key.size() < MIN_KEY_SIZE) || (key.size() > MAX_KEY_SIZE)) {
     return false;
   }
 
   uint32_t node_id = ROOT_NODE_ID;
   size_t query_pos = 0;
-  if (!search_leaf(key, node_id, query_pos)) {
+  if (!find_leaf(key, node_id, query_pos)) {
     return false;
   }
 
@@ -609,7 +609,7 @@ bool DoubleArray<T>::insert(T key, int64_t *key_id) {
   uint32_t node_id = ROOT_NODE_ID;
   size_t query_pos = 0;
 
-  search_leaf(key, node_id, query_pos);
+  find_leaf(key, node_id, query_pos);
   if (!insert_leaf(key, node_id, query_pos)) {
     if (key_id) {
       *key_id = get_key(nodes_[node_id].key_pos()).id();
@@ -667,7 +667,7 @@ bool DoubleArray<T>::update(T src_key, T dest_key, int64_t *key_id) {
   Lock lock(&header_->inter_process_mutex);
 
   int64_t src_key_id;
-  if (!search(src_key, &src_key_id)) {
+  if (!find(src_key, &src_key_id)) {
     return false;
   }
   if (update_key(static_cast<int32_t>(src_key_id), src_key, dest_key)) {
@@ -782,7 +782,7 @@ template <typename T>
 bool DoubleArray<T>::remove_key(const Slice &key) {
   uint32_t node_id = ROOT_NODE_ID;
   size_t query_pos = 0;
-  if (!search_leaf(key, node_id, query_pos)) {
+  if (!find_leaf(key, node_id, query_pos)) {
     return false;
   }
 
@@ -808,7 +808,7 @@ bool DoubleArray<T>::update_key(int32_t key_id, const Slice &src_key,
   uint32_t node_id = ROOT_NODE_ID;
   size_t query_pos = 0;
 
-  search_leaf(dest_key, node_id, query_pos);
+  find_leaf(dest_key, node_id, query_pos);
   if (!insert_leaf(dest_key, node_id, query_pos)) {
     return false;
   }
@@ -821,7 +821,7 @@ bool DoubleArray<T>::update_key(int32_t key_id, const Slice &src_key,
 
   node_id = ROOT_NODE_ID;
   query_pos = 0;
-  if (!search_leaf(src_key, node_id, query_pos)) {
+  if (!find_leaf(src_key, node_id, query_pos)) {
     GRNXX_ERROR() << "key not found (unexpected)";
     GRNXX_THROW();
   }
@@ -830,8 +830,8 @@ bool DoubleArray<T>::update_key(int32_t key_id, const Slice &src_key,
 }
 
 template <typename T>
-bool DoubleArray<T>::search_leaf(const Slice &key, uint32_t &node_id,
-                                 size_t &query_pos) {
+bool DoubleArray<T>::find_leaf(const Slice &key, uint32_t &node_id,
+                               size_t &query_pos) {
   for ( ; query_pos < key.size(); ++query_pos) {
     const DoubleArrayNode node = nodes_[node_id];
     if (node.is_leaf()) {

  Modified: lib/grnxx/alpha/map/double_array.hpp (+2 -2)
===================================================================
--- lib/grnxx/alpha/map/double_array.hpp    2013-04-15 10:42:58 +0900 (171023e)
+++ lib/grnxx/alpha/map/double_array.hpp    2013-04-15 11:18:20 +0900 (3b6407e)
@@ -50,7 +50,7 @@ class DoubleArray : public Map<T> {
   bool unset(int64_t key_id);
   bool reset(int64_t key_id, T dest_key);
 
-  bool search(T key, int64_t *key_id = nullptr);
+  bool find(T key, int64_t *key_id = nullptr);
   bool insert(T key, int64_t *key_id = nullptr);
   bool remove(T key);
   bool update(T src_key, T dest_key, int64_t *key_id = nullptr);
@@ -86,7 +86,7 @@ class DoubleArray : public Map<T> {
   bool update_key(int32_t key_id, const Slice &src_key,
                   const Slice &dest_key);
 
-  bool search_leaf(const Slice &key, uint32_t &node_id, size_t &query_pos);
+  bool find_leaf(const Slice &key, uint32_t &node_id, size_t &query_pos);
   bool insert_leaf(const Slice &key, uint32_t &node_id, size_t query_pos);
 
   uint32_t insert_node(uint32_t node_id, uint16_t label);

  Modified: test/test_alpha_map.cpp (+8 -8)
===================================================================
--- test/test_alpha_map.cpp    2013-04-15 10:42:58 +0900 (525f852)
+++ test/test_alpha_map.cpp    2013-04-15 11:18:20 +0900 (8606623)
@@ -114,7 +114,7 @@ void compare_maps(const std::unique_ptr<Map<T>> &map,
     assert(stored_key == key);
 
     std::int64_t stored_key_id;
-    assert(map->search(key, &stored_key_id));
+    assert(map->find(key, &stored_key_id));
     assert(stored_key_id == key_id);
   }
 }
@@ -323,7 +323,7 @@ void test_map_array() {
     assert(map->get(key_id, &stored_key));
     assert(stored_key == key);
 
-    assert(map->search(key, &stored_key_id));
+    assert(map->find(key, &stored_key_id));
     assert(stored_key_id == key_id);
   }
 
@@ -374,7 +374,7 @@ void test_map_array() {
     assert(map->get(old_it->second, &key));
     assert(key == new_it->first);
     std::int64_t key_id;
-    assert(map->search(key, &key_id));
+    assert(map->find(key, &key_id));
     assert(key_id == old_it->second);
   }
 
@@ -392,7 +392,7 @@ void test_map_array() {
     assert(map->get(old_it->second, &key));
     assert(key == new_it->first);
     std::int64_t key_id;
-    assert(map->search(key, &key_id));
+    assert(map->find(key, &key_id));
     assert(key_id == old_it->second);
   }
 }
@@ -414,7 +414,7 @@ void test_nan() {
   double key;
   assert(map->get(key_id, &key));
   assert(std::isnan(key));
-  assert(map->search(nan, &key_id));
+  assert(map->find(nan, &key_id));
   assert(key_id == 0);
 
   assert(map->unset(key_id));
@@ -464,7 +464,7 @@ void test_map_double_array() {
     assert(map->get(key_id, &stored_key));
     assert(stored_key == key);
 
-    assert(map->search(key, &stored_key_id));
+    assert(map->find(key, &stored_key_id));
     assert(stored_key_id == key_id);
   }
 
@@ -518,7 +518,7 @@ void test_map_double_array() {
     assert(map->get(old_it->second, &key));
     assert(key == new_it->first);
     std::int64_t key_id;
-    assert(map->search(key, &key_id));
+    assert(map->find(key, &key_id));
     assert(key_id == old_it->second);
   }
 
@@ -537,7 +537,7 @@ void test_map_double_array() {
     assert(map->get(old_it->second, &key));
     assert(key == new_it->first);
     std::int64_t key_id;
-    assert(map->search(key, &key_id));
+    assert(map->find(key, &key_id));
     assert(key_id == old_it->second);
   }
 }
-------------- next part --------------
HTML����������������������������...
Download 



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