[Groonga-commit] groonga/grnxx at 4a7dc80 [master] Voidify the return value of Storage::unlink_node() and *::unlink().

Back to archive index

susumu.yata null+****@clear*****
Thu Jul 11 12:58:47 JST 2013


susumu.yata	2013-07-11 12:58:47 +0900 (Thu, 11 Jul 2013)

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

  Message:
    Voidify the return value of Storage::unlink_node() and *::unlink().

  Modified files:
    lib/grnxx/array.hpp
    lib/grnxx/array2.hpp
    lib/grnxx/array2_impl.cpp
    lib/grnxx/array2_impl.hpp
    lib/grnxx/array_impl.cpp
    lib/grnxx/array_impl.hpp
    lib/grnxx/map.cpp
    lib/grnxx/map.hpp
    lib/grnxx/map/bytes_array.cpp
    lib/grnxx/map/bytes_array.hpp
    lib/grnxx/map/bytes_store.cpp
    lib/grnxx/map/bytes_store.hpp
    lib/grnxx/map/hash_table.cpp
    lib/grnxx/map/hash_table/key_id_array.hpp
    lib/grnxx/storage.hpp
    lib/grnxx/storage/storage_impl.cpp
    lib/grnxx/storage/storage_impl.hpp
    test/test_map.cpp
    test/test_storage.cpp

  Modified: lib/grnxx/array.hpp (+4 -4)
===================================================================
--- lib/grnxx/array.hpp    2013-07-10 19:20:01 +0900 (45168d5)
+++ lib/grnxx/array.hpp    2013-07-11 12:58:47 +0900 (d92f31d)
@@ -82,8 +82,8 @@ class Array {
   }
 
   // Unlink an array.
-  static bool unlink(Storage *storage, uint32_t storage_node_id) {
-    return Impl::unlink(storage, storage_node_id);
+  static void unlink(Storage *storage, uint32_t storage_node_id) {
+    Impl::unlink(storage, storage_node_id);
   }
 
   // Return the number of values in each page.
@@ -188,8 +188,8 @@ class Array<bool, PAGE_SIZE_IN_BITS, TABLE_SIZE, SECONDARY_TABLE_SIZE> {
   }
 
   // Unlink an array.
-  static bool unlink(Storage *storage, uint32_t storage_node_id) {
-    return UnitArray::unlink(storage, storage_node_id);
+  static void unlink(Storage *storage, uint32_t storage_node_id) {
+    UnitArray::unlink(storage, storage_node_id);
   }
 
   // Return the number of values in each unit.

  Modified: lib/grnxx/array2.hpp (+2 -2)
===================================================================
--- lib/grnxx/array2.hpp    2013-07-10 19:20:01 +0900 (02bf59c)
+++ lib/grnxx/array2.hpp    2013-07-11 12:58:47 +0900 (b939a2b)
@@ -77,8 +77,8 @@ class Array {
   }
 
   // Unlink an array.
-  static bool unlink(Storage *storage, uint32_t storage_node_id) {
-    return Impl::unlink(storage, storage_node_id);
+  static void unlink(Storage *storage, uint32_t storage_node_id) {
+    Impl::unlink(storage, storage_node_id);
   }
 
   // Return the storage node ID.

  Modified: lib/grnxx/array2_impl.cpp (+6 -6)
===================================================================
--- lib/grnxx/array2_impl.cpp    2013-07-10 19:20:01 +0900 (60d5536)
+++ lib/grnxx/array2_impl.cpp    2013-07-11 12:58:47 +0900 (5d04d86)
@@ -219,13 +219,13 @@ void Array1D::open(Storage *storage, uint32_t storage_node_id,
   size_ = header->size;
 }
 
-bool Array1D::unlink(Storage *storage, uint32_t storage_node_id,
+void Array1D::unlink(Storage *storage, uint32_t storage_node_id,
                      uint64_t value_size, uint64_t page_size,
                      uint64_t table_size) {
   Array1D array;
   array.open(storage, storage_node_id,
              value_size, page_size, table_size, nullptr);
-  return storage->unlink_node(storage_node_id);
+  storage->unlink_node(storage_node_id);
 }
 
 Array2D::Array2D()
@@ -330,13 +330,13 @@ void Array2D::open(Storage *storage, uint32_t storage_node_id,
   size_ = header_->size;
 }
 
-bool Array2D::unlink(Storage *storage, uint32_t storage_node_id,
+void Array2D::unlink(Storage *storage, uint32_t storage_node_id,
                      uint64_t value_size, uint64_t page_size,
                      uint64_t table_size) {
   Array2D array;
   array.open(storage, storage_node_id,
              value_size, page_size, table_size, nullptr);
-  return storage->unlink_node(storage_node_id);
+  storage->unlink_node(storage_node_id);
 }
 
 void Array2D::reserve_pages() {
@@ -502,13 +502,13 @@ void Array3D::open(Storage *storage, uint32_t storage_node_id,
   size_ = header_->size;
 }
 
-bool Array3D::unlink(Storage *storage, uint32_t storage_node_id,
+void Array3D::unlink(Storage *storage, uint32_t storage_node_id,
                      uint64_t value_size, uint64_t page_size,
                      uint64_t table_size) {
   Array3D array;
   array.open(storage, storage_node_id,
              value_size, page_size, table_size, nullptr);
-  return storage->unlink_node(storage_node_id);
+  storage->unlink_node(storage_node_id);
 }
 
 void Array3D::reserve_tables() {

  Modified: lib/grnxx/array2_impl.hpp (+6 -6)
===================================================================
--- lib/grnxx/array2_impl.hpp    2013-07-10 19:20:01 +0900 (285e561)
+++ lib/grnxx/array2_impl.hpp    2013-07-11 12:58:47 +0900 (0850ef1)
@@ -54,7 +54,7 @@ class Array1D {
             uint64_t table_size, ArrayFillPage fill_page);
 
   // Unlink an array.
-  static bool unlink(Storage *storage, uint32_t storage_node_id,
+  static void unlink(Storage *storage, uint32_t storage_node_id,
                      uint64_t value_size, uint64_t page_size,
                      uint64_t table_size);
 
@@ -95,7 +95,7 @@ class Array2D {
             uint64_t table_size, ArrayFillPage fill_page);
 
   // Unlink an array.
-  static bool unlink(Storage *storage, uint32_t storage_node_id,
+  static void unlink(Storage *storage, uint32_t storage_node_id,
                      uint64_t value_size, uint64_t page_size,
                      uint64_t table_size);
 
@@ -157,7 +157,7 @@ class Array3D {
             uint64_t table_size, ArrayFillPage fill_page);
 
   // Unlink an array.
-  static bool unlink(Storage *storage, uint32_t storage_node_id,
+  static void unlink(Storage *storage, uint32_t storage_node_id,
                      uint64_t value_size, uint64_t page_size,
                      uint64_t table_size);
 
@@ -270,9 +270,9 @@ class ArrayImpl {
   }
 
   // Unlink an array.
-  static bool unlink(Storage *storage, uint32_t storage_node_id) {
-    return Impl::unlink(storage, storage_node_id,
-                        sizeof(Value), PAGE_SIZE, TABLE_SIZE);
+  static void unlink(Storage *storage, uint32_t storage_node_id) {
+    Impl::unlink(storage, storage_node_id,
+                 sizeof(Value), PAGE_SIZE, TABLE_SIZE);
   }
 
   // Return the storage node ID.

  Modified: lib/grnxx/array_impl.cpp (+6 -6)
===================================================================
--- lib/grnxx/array_impl.cpp    2013-07-10 19:20:01 +0900 (862a119)
+++ lib/grnxx/array_impl.cpp    2013-07-11 12:58:47 +0900 (f2775a4)
@@ -121,11 +121,11 @@ void Array1D::open(Storage *storage, uint32_t storage_node_id,
   page_ = page_node.body();
 }
 
-bool Array1D::unlink(Storage *storage, uint32_t storage_node_id,
+void Array1D::unlink(Storage *storage, uint32_t storage_node_id,
                      uint64_t value_size, uint64_t page_size) {
   Array1D array;
   array.open(storage, storage_node_id, value_size, page_size);
-  return storage->unlink_node(storage_node_id);
+  storage->unlink_node(storage_node_id);
 }
 
 Array2D::Array2D()
@@ -234,13 +234,13 @@ void Array2D::open(Storage *storage, uint32_t storage_node_id,
   }
 }
 
-bool Array2D::unlink(Storage *storage, uint32_t storage_node_id,
+void Array2D::unlink(Storage *storage, uint32_t storage_node_id,
                      uint64_t value_size, uint64_t page_size,
                      uint64_t table_size) {
   Array2D array;
   array.open(storage, storage_node_id,
              value_size, page_size, table_size, nullptr);
-  return storage->unlink_node(storage_node_id);
+  storage->unlink_node(storage_node_id);
 }
 
 void Array2D::initialize_page(uint64_t page_id) {
@@ -372,13 +372,13 @@ void Array3D::open(Storage *storage, uint32_t storage_node_id,
   }
 }
 
-bool Array3D::unlink(Storage *storage, uint32_t storage_node_id,
+void Array3D::unlink(Storage *storage, uint32_t storage_node_id,
                      uint64_t value_size, uint64_t page_size,
                      uint64_t table_size, uint64_t secondary_table_size) {
   Array3D array;
   array.open(storage, storage_node_id, value_size, page_size,
              table_size, secondary_table_size, nullptr);
-  return storage->unlink_node(storage_node_id);
+  storage->unlink_node(storage_node_id);
 }
 
 void Array3D::initialize_page(uint64_t table_id, uint64_t page_id) {

  Modified: lib/grnxx/array_impl.hpp (+11 -11)
===================================================================
--- lib/grnxx/array_impl.hpp    2013-07-10 19:20:01 +0900 (dbaf6ec)
+++ lib/grnxx/array_impl.hpp    2013-07-11 12:58:47 +0900 (7929e6c)
@@ -47,7 +47,7 @@ class Array1D {
   void open(Storage *storage, uint32_t storage_node_id,
             uint64_t value_size, uint64_t page_size);
 
-  static bool unlink(Storage *storage, uint32_t storage_node_id,
+  static void unlink(Storage *storage, uint32_t storage_node_id,
                      uint64_t value_size, uint64_t page_size);
 
   uint32_t storage_node_id() const {
@@ -81,7 +81,7 @@ class Array2D {
             uint64_t value_size, uint64_t page_size,
             uint64_t table_size, FillPage fill_page);
 
-  static bool unlink(Storage *storage, uint32_t storage_node_id,
+  static void unlink(Storage *storage, uint32_t storage_node_id,
                      uint64_t value_size, uint64_t page_size,
                      uint64_t table_size);
 
@@ -128,7 +128,7 @@ class Array3D {
             uint64_t table_size, uint64_t secondary_table_size,
             FillPage fill_page);
 
-  static bool unlink(Storage *storage, uint32_t storage_node_id,
+  static void unlink(Storage *storage, uint32_t storage_node_id,
                      uint64_t value_size, uint64_t page_size,
                      uint64_t table_size, uint64_t secondary_table_size);
 
@@ -202,8 +202,8 @@ class ArrayImpl<T, PAGE_SIZE, 1, 1> {
   }
 
   // Unlink an array.
-  static bool unlink(Storage *storage, uint32_t storage_node_id) {
-    return Array1D::unlink(storage, storage_node_id, sizeof(Value), PAGE_SIZE);
+  static void unlink(Storage *storage, uint32_t storage_node_id) {
+    Array1D::unlink(storage, storage_node_id, sizeof(Value), PAGE_SIZE);
   }
 
   // Return the number of values in each page.
@@ -308,9 +308,9 @@ class ArrayImpl<T, PAGE_SIZE, TABLE_SIZE, 1> {
   }
 
   // Unlink an array.
-  static bool unlink(Storage *storage, uint32_t storage_node_id) {
-    return Array2D::unlink(storage, storage_node_id, sizeof(Value),
-                           PAGE_SIZE, TABLE_SIZE);
+  static void unlink(Storage *storage, uint32_t storage_node_id) {
+    Array2D::unlink(storage, storage_node_id, sizeof(Value),
+                    PAGE_SIZE, TABLE_SIZE);
   }
 
   // Return the number of values in each page.
@@ -417,9 +417,9 @@ class ArrayImpl {
   }
 
   // Unlink an array.
-  static bool unlink(Storage *storage, uint32_t storage_node_id) {
-    return Array3D::unlink(storage, storage_node_id, sizeof(Value),
-                           PAGE_SIZE, TABLE_SIZE, SECONDARY_TABLE_SIZE);
+  static void unlink(Storage *storage, uint32_t storage_node_id) {
+    Array3D::unlink(storage, storage_node_id, sizeof(Value),
+                    PAGE_SIZE, TABLE_SIZE, SECONDARY_TABLE_SIZE);
   }
 
   // Return the number of values in each page.

  Modified: lib/grnxx/map.cpp (+2 -2)
===================================================================
--- lib/grnxx/map.cpp    2013-07-10 19:20:01 +0900 (f51f407)
+++ lib/grnxx/map.cpp    2013-07-11 12:58:47 +0900 (3667632)
@@ -121,9 +121,9 @@ Map<T> *Map<T>::open(Storage *storage, uint32_t storage_node_id) {
 }
 
 template <typename T>
-bool Map<T>::unlink(Storage *storage, uint32_t storage_node_id) {
+void Map<T>::unlink(Storage *storage, uint32_t storage_node_id) {
   std::unique_ptr<Map<T>> map(open(storage, storage_node_id));
-  return storage->unlink_node(storage_node_id);
+  storage->unlink_node(storage_node_id);
 }
 
 template <typename T>

  Modified: lib/grnxx/map.hpp (+1 -1)
===================================================================
--- lib/grnxx/map.hpp    2013-07-10 19:20:01 +0900 (ec97f4e)
+++ lib/grnxx/map.hpp    2013-07-11 12:58:47 +0900 (12d8d72)
@@ -68,7 +68,7 @@ class Map {
   static Map *open(Storage *storage, uint32_t storage_node_id);
 
   // Unlink a map.
-  static bool unlink(Storage *storage, uint32_t storage_node_id);
+  static void unlink(Storage *storage, uint32_t storage_node_id);
 
   // Return the storage node ID.
   virtual uint32_t storage_node_id() const = 0;

  Modified: lib/grnxx/map/bytes_array.cpp (+2 -2)
===================================================================
--- lib/grnxx/map/bytes_array.cpp    2013-07-10 19:20:01 +0900 (1a812bd)
+++ lib/grnxx/map/bytes_array.cpp    2013-07-11 12:58:47 +0900 (ce80438)
@@ -76,9 +76,9 @@ BytesArray *BytesArray::open(Storage *storage, uint32_t storage_node_id) {
   return array.release();
 }
 
-bool BytesArray::unlink(Storage *storage, uint32_t storage_node_id) {
+void BytesArray::unlink(Storage *storage, uint32_t storage_node_id) {
   std::unique_ptr<BytesArray> array(open(storage, storage_node_id));
-  return storage->unlink_node(storage_node_id);
+  storage->unlink_node(storage_node_id);
 }
 
 bool BytesArray::get(uint64_t value_id, Value *value) {

  Modified: lib/grnxx/map/bytes_array.hpp (+1 -1)
===================================================================
--- lib/grnxx/map/bytes_array.hpp    2013-07-10 19:20:01 +0900 (571f808)
+++ lib/grnxx/map/bytes_array.hpp    2013-07-11 12:58:47 +0900 (2e19f0c)
@@ -56,7 +56,7 @@ class BytesArray {
   static BytesArray *open(Storage *storage, uint32_t storage_node_id);
 
   // Unlink an array.
-  static bool unlink(Storage *storage, uint32_t storage_node_id);
+  static void unlink(Storage *storage, uint32_t storage_node_id);
 
   // Return the number of values in each page.
   static constexpr uint64_t page_size() {

  Modified: lib/grnxx/map/bytes_store.cpp (+2 -2)
===================================================================
--- lib/grnxx/map/bytes_store.cpp    2013-07-10 19:20:01 +0900 (22c5462)
+++ lib/grnxx/map/bytes_store.cpp    2013-07-11 12:58:47 +0900 (398c747)
@@ -476,14 +476,14 @@ BytesStore *BytesStore::open(Storage *storage, uint32_t storage_node_id) {
   return BytesStoreImpl::open(storage, storage_node_id);
 }
 
-bool BytesStore::unlink(Storage *storage, uint32_t storage_node_id) {
+void BytesStore::unlink(Storage *storage, uint32_t storage_node_id) {
   if (!storage) {
     GRNXX_ERROR() << "invalid argument: storage == nullptr";
     throw LogicError();
   }
   std::unique_ptr<BytesStore> store(
       BytesStore::open(storage, storage_node_id));
-  return storage->unlink_node(storage_node_id);
+  storage->unlink_node(storage_node_id);
 }
 
 }  // namespace map

  Modified: lib/grnxx/map/bytes_store.hpp (+1 -1)
===================================================================
--- lib/grnxx/map/bytes_store.hpp    2013-07-10 19:20:01 +0900 (5ef0d79)
+++ lib/grnxx/map/bytes_store.hpp    2013-07-11 12:58:47 +0900 (4e5e67a)
@@ -48,7 +48,7 @@ class BytesStore {
   static BytesStore *open(Storage *storage, uint32_t storage_node_id);
 
   // Unlink a store.
-  static bool unlink(Storage *storage, uint32_t storage_node_id);
+  static void unlink(Storage *storage, uint32_t storage_node_id);
 
   // Return the storage node ID.
   virtual uint32_t storage_node_id() const = 0;

  Modified: lib/grnxx/map/hash_table.cpp (+1 -3)
===================================================================
--- lib/grnxx/map/hash_table.cpp    2013-07-10 19:20:01 +0900 (14dcd63)
+++ lib/grnxx/map/hash_table.cpp    2013-07-11 12:58:47 +0900 (6b00e96)
@@ -258,9 +258,7 @@ bool HashTable<T>::truncate() {
       KeyIDArray::create(storage_, storage_node_id_,
                          KeyIDArray::page_size() - 1));
   if (header_->old_key_ids_storage_node_id != STORAGE_INVALID_NODE_ID) try {
-    if (!KeyIDArray::unlink(storage_, header_->old_key_ids_storage_node_id)) {
-      throw LogicError();
-    }
+    KeyIDArray::unlink(storage_, header_->old_key_ids_storage_node_id);
   } catch (...) {
     KeyIDArray::unlink(storage_, new_key_ids->storage_node_id());
     throw;

  Modified: lib/grnxx/map/hash_table/key_id_array.hpp (+2 -2)
===================================================================
--- lib/grnxx/map/hash_table/key_id_array.hpp    2013-07-10 19:20:01 +0900 (228aad0)
+++ lib/grnxx/map/hash_table/key_id_array.hpp    2013-07-11 12:58:47 +0900 (4323dfc)
@@ -103,9 +103,9 @@ class KeyIDArray {
   }
 
   // Unlink an array.
-  static bool unlink(Storage *storage, uint32_t storage_node_id) {
+  static void unlink(Storage *storage, uint32_t storage_node_id) {
     std::unique_ptr<KeyIDArray> array(open(storage, storage_node_id));
-    return storage->unlink_node(storage_node_id);
+    storage->unlink_node(storage_node_id);
   }
 
   // Return the number of values in each page.

  Modified: lib/grnxx/storage.hpp (+1 -1)
===================================================================
--- lib/grnxx/storage.hpp    2013-07-10 19:20:01 +0900 (49003e7)
+++ lib/grnxx/storage.hpp    2013-07-11 12:58:47 +0900 (03e0499)
@@ -158,7 +158,7 @@ class Storage {
 
   // Unlink a node and return true on success.
   // The unlinked node and its descendants will be removed by sweep().
-  virtual bool unlink_node(uint32_t node_id) = 0;
+  virtual void unlink_node(uint32_t node_id) = 0;
 
   // Sweep unlinked nodes whose modified time < (now - lifetime).
   virtual void sweep(Duration lifetime) = 0;

  Modified: lib/grnxx/storage/storage_impl.cpp (+5 -17)
===================================================================
--- lib/grnxx/storage/storage_impl.cpp    2013-07-10 19:20:01 +0900 (99846dd)
+++ lib/grnxx/storage/storage_impl.cpp    2013-07-11 12:58:47 +0900 (a1ac2f9)
@@ -213,7 +213,7 @@ StorageNode StorageImpl::open_node(uint32_t node_id) {
   return StorageNode(node_header, body);
 }
 
-bool StorageImpl::unlink_node(uint32_t node_id) {
+void StorageImpl::unlink_node(uint32_t node_id) {
   if (flags_ & STORAGE_READ_ONLY) {
     GRNXX_ERROR() << "invalid operation: flags = " << flags_;
     throw LogicError();
@@ -225,12 +225,9 @@ bool StorageImpl::unlink_node(uint32_t node_id) {
     throw LogicError();
   }
   NodeHeader * const node_header = get_node_header(node_id);
-  if (node_header->status == STORAGE_NODE_UNLINKED) {
-    // Already unlinked
-    return false;
-  }
   if (node_header->status != STORAGE_NODE_ACTIVE) {
-    GRNXX_ERROR() << "invalid argument: status = " << node_header->status;
+    GRNXX_ERROR() << "invalid status: expected = " << STORAGE_NODE_ACTIVE
+                  << ", actual = " << node_header->status;
     throw LogicError();
   }
   NodeHeader * const from_node_header =
@@ -267,7 +264,6 @@ bool StorageImpl::unlink_node(uint32_t node_id) {
   }
   header_->latest_unlinked_node_id = node_id;
   node_header->modified_time = clock_.now();
-  return true;
 }
 
 void StorageImpl::sweep(Duration lifetime) {
@@ -375,11 +371,7 @@ void StorageImpl::create_file_backed_storage(const char *path,
     create_active_node(options.root_size);
     header_->validate();
   } catch (...) {
-    try {
-      unlink_storage();
-    } catch (...) {
-      // Ignore an exception.
-    }
+    unlink_storage();
     throw;
   }
 }
@@ -469,11 +461,7 @@ void StorageImpl::open_or_create_storage(const char *path, StorageFlags flags,
       create_active_node(options.root_size);
       header_->validate();
     } catch (...) {
-      try {
-        unlink_storage();
-      } catch (...) {
-        // Ignore an exception.
-      }
+      unlink_storage();
       throw;
     }
   }

  Modified: lib/grnxx/storage/storage_impl.hpp (+1 -1)
===================================================================
--- lib/grnxx/storage/storage_impl.hpp    2013-07-10 19:20:01 +0900 (9987e97)
+++ lib/grnxx/storage/storage_impl.hpp    2013-07-11 12:58:47 +0900 (e8fee14)
@@ -57,7 +57,7 @@ class StorageImpl : public Storage {
   StorageNode create_node(uint32_t parent_node_id, uint64_t size);
   StorageNode open_node(uint32_t node_id);
 
-  bool unlink_node(uint32_t node_id);
+  void unlink_node(uint32_t node_id);
 
   void sweep(Duration lifetime);
 

  Modified: test/test_map.cpp (+3 -3)
===================================================================
--- test/test_map.cpp    2013-07-10 19:20:01 +0900 (9d2b602)
+++ test/test_map.cpp    2013-07-11 12:58:47 +0900 (e54e48e)
@@ -164,7 +164,7 @@ void test_bytes_store_unlink() {
                                      grnxx::STORAGE_ROOT_NODE_ID));
   grnxx::StorageNode storage_node =
       storage->open_node(store->storage_node_id());
-  assert(grnxx::map::BytesStore::unlink(storage.get(), storage_node.id()));
+  grnxx::map::BytesStore::unlink(storage.get(), storage_node.id());
   assert(storage_node.status() == grnxx::STORAGE_NODE_UNLINKED);
 }
 
@@ -297,7 +297,7 @@ void test_bytes_array_unlink() {
                                      grnxx::STORAGE_ROOT_NODE_ID));
   grnxx::StorageNode storage_node =
       storage->open_node(array->storage_node_id());
-  assert(grnxx::map::BytesArray::unlink(storage.get(), storage_node.id()));
+  grnxx::map::BytesArray::unlink(storage.get(), storage_node.id());
   assert(storage_node.status() == grnxx::STORAGE_NODE_UNLINKED);
 }
 
@@ -365,7 +365,7 @@ void test_map_unlink(grnxx::MapType map_type) {
       grnxx::Map<T>::create(storage.get(), grnxx::STORAGE_ROOT_NODE_ID,
                             map_type));
   grnxx::StorageNode storage_node = storage->open_node(map->storage_node_id());
-  assert(grnxx::Map<T>::unlink(storage.get(), storage_node.id()));
+  grnxx::Map<T>::unlink(storage.get(), storage_node.id());
   assert(storage_node.status() == grnxx::STORAGE_NODE_UNLINKED);
 }
 

  Modified: test/test_storage.cpp (+9 -10)
===================================================================
--- test/test_storage.cpp    2013-07-10 19:20:01 +0900 (a521233)
+++ test/test_storage.cpp    2013-07-11 12:58:47 +0900 (c1fc661)
@@ -458,11 +458,10 @@ void test_storage_unlink_node() {
   node_1 = storage->create_node(grnxx::STORAGE_ROOT_NODE_ID, 1 << 20);
   node_2 = storage->create_node(grnxx::STORAGE_ROOT_NODE_ID, 1 << 24);
 
-  assert(storage->unlink_node(node_1.id()));
+  storage->unlink_node(node_1.id());
   assert(node_1.status() == grnxx::STORAGE_NODE_UNLINKED);
-  assert(storage->unlink_node(node_2.id()));
+  storage->unlink_node(node_2.id());
   assert(node_2.status() == grnxx::STORAGE_NODE_UNLINKED);
-//  assert(!storage->unlink_node(grnxx::STORAGE_ROOT_NODE_ID));
 }
 
 void test_storage_sweep() {
@@ -475,7 +474,7 @@ void test_storage_sweep() {
   assert(storage->create_node(node.id(), 1 << 18));
   uint64_t total_size = storage->total_size();
   for (int i = 0; i < 100; ++i) {
-    assert(storage->unlink_node(node.id()));
+    storage->unlink_node(node.id());
     storage->sweep(grnxx::Duration(0));
     node = storage->create_node(grnxx::STORAGE_ROOT_NODE_ID, 1 << 18);
     assert(storage->create_node(node.id(), 1 << 18));
@@ -488,7 +487,7 @@ void test_storage_sweep() {
   assert(storage->create_node(node.id(), 0));
   total_size = storage->total_size();
   for (int i = 0; i < 100; ++i) {
-    assert(storage->unlink_node(node.id()));
+    storage->unlink_node(node.id());
     storage->sweep(grnxx::Duration(0));
     node = storage->create_node(grnxx::STORAGE_ROOT_NODE_ID, 0);
     assert(storage->create_node(node.id(), 0));
@@ -551,7 +550,7 @@ void test_storage_num_nodes() {
 
   node = storage->create_node(grnxx::STORAGE_ROOT_NODE_ID, 1 << 24);
   assert(storage->num_nodes() == 2);
-  assert(storage->unlink_node(node.id()));
+  storage->unlink_node(node.id());
   assert(storage->num_nodes() == 2);
   storage->sweep(grnxx::Duration(0));
   assert(storage->num_nodes() == 1);
@@ -580,7 +579,7 @@ void test_storage_body_usage() {
   prev_body_usage = storage->body_usage();
   node = storage->create_node(grnxx::STORAGE_ROOT_NODE_ID, 1 << 24);
   assert(storage->body_usage() == (prev_body_usage + node.size()));
-  assert(storage->unlink_node(node.id()));
+  storage->unlink_node(node.id());
   storage->sweep(grnxx::Duration(0));
   assert(storage->body_usage() == prev_body_usage);
   for (int i = 0; i < 16; ++i) {
@@ -600,7 +599,7 @@ void test_storage_body_size() {
   node = storage->create_node(grnxx::STORAGE_ROOT_NODE_ID, 1 << 23);
   assert(storage->body_size() > prev_body_size);
   prev_body_size = storage->body_size();
-  assert(storage->unlink_node(node.id()));
+  storage->unlink_node(node.id());
   storage->sweep(grnxx::Duration(0));
   assert(storage->body_size() == prev_body_size);
   for (int i = 0; i < 16; ++i) {
@@ -638,7 +637,7 @@ void test_storage_random_queries() {
     } else if (value < 64) {
       if (!id_set.empty()) {
         // Unlink a node.
-        assert(storage->unlink_node(*id_set.begin()));
+        storage->unlink_node(*id_set.begin());
         id_set.erase(id_set.begin());
       }
     } else {
@@ -718,7 +717,7 @@ void test_storage_random_queries2() {
 
     // Unlink children of the root node.
     for (std::uint32_t root_child_id : root_child_id_vector) {
-      assert(storage->unlink_node(root_child_id));
+      storage->unlink_node(root_child_id);
     }
     storage->sweep(grnxx::Duration(0));
   }
-------------- next part --------------
HTML����������������������������...
Download 



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