| 260 | } |
| 261 | |
| 262 | uint32_t BTreeDatabase::leafBlockCount() { |
| 263 | WriteLocker writeLocker(m_lock); |
| 264 | checkIfOpen("leafBlockCount", true); |
| 265 | |
| 266 | struct LeafBlocksVisitor { |
| 267 | bool operator()(shared_ptr<IndexNode> const&) { |
| 268 | return true; |
| 269 | } |
| 270 | |
| 271 | bool operator()(shared_ptr<LeafNode> const& leaf) { |
| 272 | leafBlockCount += 1 + parent->leafTailBlocks(leaf->self).size(); |
| 273 | return true; |
| 274 | } |
| 275 | |
| 276 | BTreeDatabase* parent = nullptr; |
| 277 | BlockIndex leafBlockCount = 0; |
| 278 | }; |
| 279 | |
| 280 | LeafBlocksVisitor visitor; |
| 281 | visitor.parent = this; |
| 282 | m_impl.forAllNodes(visitor); |
| 283 | |
| 284 | return visitor.leafBlockCount; |
| 285 | } |
| 286 | |
| 287 | void BTreeDatabase::commit() { |
| 288 | WriteLocker writeLocker(m_lock); |