CatapultServer  v0.5.0.1 (Elephant)
LockInfoBaseSets.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "LockInfoCacheTypes.h"
26 
27 namespace catapult { namespace cache {
28 
29  template<typename TDescriptor>
30  using LockInfoPatriciaTree = tree::BasePatriciaTree<
31  SerializerHashedKeyEncoder<typename TDescriptor::Serializer>,
32  PatriciaTreeRdbDataSource,
34 
35  template<typename TCacheTypes, typename TDescriptor>
37  typename TCacheTypes::PrimaryTypes::BaseSetDeltaPointerType pPrimary;
38  typename TCacheTypes::HeightGroupingTypes::BaseSetDeltaPointerType pHeightGrouping;
39  std::shared_ptr<typename TDescriptor::PatriciaTree::DeltaType> pPatriciaTree;
40  };
41 
42  template<typename TCacheTypes, typename TDescriptor, typename TBaseSetDeltaPointers>
44  public:
46  using IsOrderedSet = std::false_type;
47 
48  public:
49  explicit LockInfoBaseSets(const CacheConfiguration& config)
50  : CacheDatabaseMixin(config, { "default", "height_grouping" })
51  , Primary(GetContainerMode(config), database(), 0)
54  {}
55 
56  public:
57  typename TCacheTypes::PrimaryTypes::BaseSetType Primary;
58  typename TCacheTypes::HeightGroupingTypes::BaseSetType HeightGrouping;
60 
61  public:
62  TBaseSetDeltaPointers rebase() {
63  TBaseSetDeltaPointers deltaPointers;
64  deltaPointers.pPrimary = Primary.rebase();
65  deltaPointers.pHeightGrouping = HeightGrouping.rebase();
66  deltaPointers.pPatriciaTree = PatriciaTree.rebase();
67  return deltaPointers;
68  }
69 
70  TBaseSetDeltaPointers rebaseDetached() const {
71  TBaseSetDeltaPointers deltaPointers;
72  deltaPointers.pPrimary = Primary.rebaseDetached();
73  deltaPointers.pHeightGrouping = HeightGrouping.rebaseDetached();
74  deltaPointers.pPatriciaTree = PatriciaTree.rebaseDetached();
75  return deltaPointers;
76  }
77 
78  void commit() {
79  Primary.commit();
80  HeightGrouping.commit();
82  flush();
83  }
84  };
85 }}
catapult::cache::LockInfoBaseSets::HeightGrouping
TCacheTypes::HeightGroupingTypes::BaseSetType HeightGrouping
Definition: LockInfoBaseSets.h:58
CachePatriciaTree.h
catapult::cache::CacheDatabaseMixin::hasPatriciaTreeSupport
bool hasPatriciaTreeSupport() const
Returns true if patricia tree support is enabled.
Definition: CacheDatabaseMixin.h:50
catapult::cache::LockInfoBaseSetDeltaPointers::pHeightGrouping
TCacheTypes::HeightGroupingTypes::BaseSetDeltaPointerType pHeightGrouping
Definition: LockInfoBaseSets.h:38
catapult::cache::LockInfoBaseSets
Definition: LockInfoBaseSets.h:43
catapult::cache::LockInfoBaseSetDeltaPointers
Definition: LockInfoBaseSets.h:36
catapult::cache::LockInfoBaseSets::Primary
TCacheTypes::PrimaryTypes::BaseSetType Primary
Definition: LockInfoBaseSets.h:57
catapult::cache::CacheDatabaseMixin::GetContainerMode
static deltaset::ConditionalContainerMode GetContainerMode(const CacheConfiguration &config)
Gets the container mode specified by config.
Definition: CacheDatabaseMixin.h:61
catapult::cache::LockInfoBaseSetDeltaPointers::pPrimary
TCacheTypes::PrimaryTypes::BaseSetDeltaPointerType pPrimary
Definition: LockInfoBaseSets.h:37
catapult::cache::LockInfoBaseSets::commit
void commit()
Definition: LockInfoBaseSets.h:78
catapult::cache::LockInfoBaseSets::PatriciaTree
CachePatriciaTree< typename TDescriptor::PatriciaTree > PatriciaTree
Definition: LockInfoBaseSets.h:59
catapult::cache::CacheDatabaseMixin
Mixin that owns a cache database.
Definition: CacheDatabaseMixin.h:30
catapult::cache::LockInfoBaseSets< HashLockInfoCacheTypes, HashLockInfoCacheDescriptor, HashLockInfoBaseSetDeltaPointers >::IsOrderedSet
std::false_type IsOrderedSet
Indicates the set is not ordered.
Definition: LockInfoBaseSets.h:46
LockInfoCacheTypes.h
catapult::cache::LockInfoBaseSetDeltaPointers::pPatriciaTree
std::shared_ptr< typename TDescriptor::PatriciaTree::DeltaType > pPatriciaTree
Definition: LockInfoBaseSets.h:39
BasePatriciaTree.h
catapult::cache::CachePatriciaTree::commit
void commit()
Commits all changes in the rebased tree.
Definition: CachePatriciaTree.h:56
catapult::cache::CachePatriciaTree::rebaseDetached
auto rebaseDetached() const
Definition: CachePatriciaTree.h:51
catapult::cache::LockInfoBaseSets::LockInfoBaseSets
LockInfoBaseSets(const CacheConfiguration &config)
Definition: LockInfoBaseSets.h:49
catapult::cache::LockInfoBaseSets::rebase
TBaseSetDeltaPointers rebase()
Definition: LockInfoBaseSets.h:62
catapult::cache::CachePatriciaTree::rebase
auto rebase()
Returns a delta based on the same data source as this tree.
Definition: CachePatriciaTree.h:45
catapult::cache::CacheDatabaseMixin::database
CacheDatabase & database()
Gets the database.
Definition: CacheDatabaseMixin.h:55
catapult::cache::CacheConfiguration
Cache configuration.
Definition: CacheConfiguration.h:37
catapult::cache::LockInfoPatriciaTree
tree::BasePatriciaTree< SerializerHashedKeyEncoder< typename TDescriptor::Serializer >, PatriciaTreeRdbDataSource, utils::ArrayHasher< typename TDescriptor::KeyType > > LockInfoPatriciaTree
Definition: LockInfoBaseSets.h:33
PatriciaTreeEncoderAdapters.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::cache::LockInfoBaseSets::rebaseDetached
TBaseSetDeltaPointers rebaseDetached() const
Definition: LockInfoBaseSets.h:70
catapult::cache::CacheDatabaseMixin::flush
void flush()
Flushes the database.
Definition: CacheDatabaseMixin.h:68
catapult::cache::CachePatriciaTree< typename TDescriptor::PatriciaTree >
catapult::utils::ArrayHasher
Definition: Hashers.h:32