CatapultServer  v0.5.0.1 (Elephant)
PatriciaTreeRdbDataSource.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "PatriciaTreeContainer.h"
23 #include "catapult/types.h"
24 
25 namespace catapult { namespace cache {
26 
29  public:
32  {}
33 
34  public:
36  size_t size() {
37  return m_container.size();
38  }
39 
41  std::unique_ptr<const tree::TreeNode> get(const Hash256& hash) const {
42  auto iter = m_container.find(hash);
43  if (m_container.cend() == iter)
44  return nullptr;
45 
46  const auto& pair = *iter;
47  return std::make_unique<const tree::TreeNode>(pair.second.copy());
48  }
49 
50  public:
52  void set(const tree::LeafTreeNode& node) {
53  set(tree::TreeNode(node));
54  }
55 
57  void set(const tree::BranchTreeNode& node) {
58  set(tree::TreeNode(node));
59  }
60 
61  private:
62  void set(const tree::TreeNode& node) {
63  m_container.insert(std::make_pair(node.hash(), node.copy()));
64  }
65 
66  private:
68  };
69 }}
catapult::tree::TreeNode::copy
TreeNode copy() const
Creates a copy of this node.
Definition: TreeNode.cpp:234
catapult::cache::PatriciaTreeRdbDataSource::set
void set(const tree::TreeNode &node)
Definition: PatriciaTreeRdbDataSource.h:62
catapult::cache::PatriciaTreeRdbDataSource::size
size_t size()
Gets the number of saved nodes.
Definition: PatriciaTreeRdbDataSource.h:36
catapult::cache::PatriciaTreeRdbDataSource
Patricia tree rocksdb-based data source.
Definition: PatriciaTreeRdbDataSource.h:28
catapult::cache::RdbTypedColumnContainer::cend
const_iterator cend() const
Returns iterator that represents non-existing element.
Definition: RdbTypedColumnContainer.h:140
catapult::cache::PatriciaTreeRdbDataSource::set
void set(const tree::BranchTreeNode &node)
Saves a branch tree node.
Definition: PatriciaTreeRdbDataSource.h:57
catapult::tree::TreeNode::hash
const Hash256 & hash() const
Gets the hash representation of this node.
Definition: TreeNode.cpp:202
catapult::cache::RdbTypedColumnContainer::find
const_iterator find(const KeyType &key) const
Finds element with key. Returns cend() if key has not been found.
Definition: RdbTypedColumnContainer.h:123
catapult::cache::RdbColumnContainer::size
size_t size() const
Returns size of the column.
Definition: RdbColumnContainer.cpp:64
catapult::cache::RdbTypedColumnContainer::insert
void insert(const StorageType &element)
Inserts element into container.
Definition: RdbTypedColumnContainer.h:112
catapult::cache::PatriciaTreeRdbDataSource::set
void set(const tree::LeafTreeNode &node)
Saves a leaf tree node.
Definition: PatriciaTreeRdbDataSource.h:52
catapult::tree::LeafTreeNode
Represents a leaf tree node.
Definition: TreeNode.h:34
catapult::cache::PatriciaTreeRdbDataSource::m_container
PatriciaTreeContainer & m_container
Definition: PatriciaTreeRdbDataSource.h:67
PatriciaTreeContainer.h
types.h
catapult::cache::PatriciaTreeRdbDataSource::PatriciaTreeRdbDataSource
PatriciaTreeRdbDataSource(PatriciaTreeContainer &container)
Creates data source around container.
Definition: PatriciaTreeRdbDataSource.h:31
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::tree::TreeNode
Represents a tree node.
Definition: TreeNode.h:124
catapult::utils::ByteArray< Hash256_Size, Hash256_tag >
catapult::cache::PatriciaTreeRdbDataSource::get
std::unique_ptr< const tree::TreeNode > get(const Hash256 &hash) const
Gets the tree node associated with hash.
Definition: PatriciaTreeRdbDataSource.h:41
catapult::cache::RdbTypedColumnContainer< PatriciaTreeColumnDescriptor >
catapult::tree::BranchTreeNode
Represents a branch tree node.
Definition: TreeNode.h:60