CatapultServer  v0.5.0.1 (Elephant)
CacheDescriptorAdapters.h
Go to the documentation of this file.
1 
21 #pragma once
22 #include "CacheConfiguration.h"
28 #include <unordered_map>
29 
30 namespace catapult { namespace cache {
31 
32  namespace detail {
34  template<typename TElementTraits, typename TDescriptor, typename TValueHasher>
36  private:
38  public:
39  using KeyType = typename TDescriptor::KeyType;
40  using ValueType = typename TDescriptor::ValueType;
41  using StorageType = std::pair<const KeyType, ValueType>;
42  using Serializer = typename TDescriptor::Serializer;
43 
44  static constexpr auto GetKeyFromValue = TDescriptor::GetKeyFromValue;
45 
46  static constexpr auto& ToKey(const StorageType& element) {
47  return element.first;
48  }
49 
50  static constexpr auto& ToValue(const StorageType& element) {
51  return element.second;
52  }
53 
54  static auto ToStorage(const ValueType& value) {
55  return StorageType(TDescriptor::GetKeyFromValue(value), value);
56  }
57  };
58 
60  using MemoryMapType = std::unordered_map<typename TDescriptor::KeyType, typename TDescriptor::ValueType, TValueHasher>;
61 
62  struct Converter {
63  static constexpr auto ToKey = TDescriptor::GetKeyFromValue;
64  };
65 
66  // workaround for VS truncation
72  >,
73  Converter,
75  >;
76 
77  struct StorageTraits : public MapStorageTraits {};
78 
79  public:
82 
85 
87  using BaseSetDeltaPointerType = std::shared_ptr<BaseSetDeltaType>;
88  };
89  }
90 
92  template<typename TDescriptor, typename TValueHasher = std::hash<typename TDescriptor::KeyType>>
95  TDescriptor,
96  TValueHasher>;
97 
99  template<typename TDescriptor, typename TValueHasher = std::hash<typename TDescriptor::KeyType>>
102  TDescriptor,
103  TValueHasher>;
104 
105  namespace detail {
107  template<typename TElementTraits>
109  private:
110  using ElementType = std::remove_const_t<typename TElementTraits::ElementType>;
111 
112  class StorageSetType : public deltaset::detail::OrderedSetType<TElementTraits> {
113  public:
115  {}
116  };
117 
118  using MemorySetType = std::set<ElementType>;
119 
120  // workaround for VS truncation
126  >,
128  >;
129 
130  struct StorageTraits : public SetStorageTraits {};
131 
132  public:
135 
138 
140  using BaseSetDeltaPointerType = std::shared_ptr<BaseSetDeltaType>;
141  };
142  }
143 
145  template<typename TDescriptor>
148 
150  template<typename TDescriptor>
153 
154  namespace detail {
156  template<typename TElementTraits, typename TDescriptor>
158  private:
160  public:
161  using KeyType = typename TDescriptor::KeyType;
162  using ValueType = typename TDescriptor::ValueType;
163  using StorageType = typename TDescriptor::KeyType;
164  using Serializer = typename TDescriptor::Serializer;
165 
166  static constexpr auto GetKeyFromValue = TDescriptor::GetKeyFromValue;
167 
168  static constexpr auto& ToKey(const StorageType& element) {
169  return element;
170  }
171 
172  static constexpr auto& ToValue(const StorageType& element) {
173  return element;
174  }
175 
176  static constexpr auto& ToStorage(const ValueType& value) {
177  return value;
178  }
179  };
180 
181  using ElementType = std::remove_const_t<typename TElementTraits::ElementType>;
183  using MemorySetType = std::set<ElementType>;
184 
185  // workaround for VS truncation
191  >,
193  >;
194 
195  struct StorageTraits : public SetStorageTraits {};
196 
197  public:
200 
203 
205  using BaseSetDeltaPointerType = std::shared_ptr<BaseSetDeltaType>;
206  };
207  }
208 
210  template<typename TDescriptor>
213  TDescriptor>;
214 
216  template<typename TDescriptor>
219  TDescriptor>;
220 }}
ConditionalContainer.h
catapult::cache::detail::OrderedSetAdapter::DescriptorAdapter::ToValue
static constexpr auto & ToValue(const StorageType &element)
Definition: CacheDescriptorAdapters.h:172
catapult::cache::detail::OrderedMemorySetAdapter
Defines cache types for an ordered, memory backed set based cache.
Definition: CacheDescriptorAdapters.h:108
catapult::deltaset::SetStorageTraits
Base set compatible traits for stl set types.
Definition: BaseSetDefaultTraits.h:60
catapult::cache::detail::OrderedMemorySetAdapter::BaseSetDeltaType
typename BaseSetType::DeltaType BaseSetDeltaType
Base set delta type.
Definition: CacheDescriptorAdapters.h:137
UpdateSet.h
catapult::cache::detail::UnorderedMapAdapter::Converter::ToKey
static constexpr auto ToKey
Definition: CacheDescriptorAdapters.h:63
catapult::cache::detail::OrderedSetAdapter::StorageSetType
CacheContainerView< DescriptorAdapter > StorageSetType
Definition: CacheDescriptorAdapters.h:182
catapult::cache::detail::UnorderedMapAdapter::Converter
Definition: CacheDescriptorAdapters.h:62
catapult::cache::detail::OrderedSetAdapter::ElementType
std::remove_const_t< typename TElementTraits::ElementType > ElementType
Definition: CacheDescriptorAdapters.h:181
catapult::deltaset::ImmutableTypeTraits
Traits used for describing an immutable type.
Definition: BaseSetDefaultTraits.h:166
catapult::cache::detail::UnorderedMapAdapter::BaseSetDeltaType
typename BaseSetType::DeltaType BaseSetDeltaType
Base set delta type.
Definition: CacheDescriptorAdapters.h:84
catapult::deltaset::BaseSet::DeltaType
BaseSetDelta< TElementTraits, TSetTraits > DeltaType
Definition: BaseSet.h:58
catapult::cache::detail::OrderedSetAdapter
Defines cache types for an ordered set based cache.
Definition: CacheDescriptorAdapters.h:157
OrderedSet.h
catapult::cache::detail::OrderedSetAdapter::DescriptorAdapter::Serializer
typename TDescriptor::Serializer Serializer
Definition: CacheDescriptorAdapters.h:164
catapult::deltaset::OrderedSet
A base set with ordered keys.
Definition: OrderedSet.h:59
catapult::cache::detail::UnorderedMapAdapter::DescriptorAdapter::ToValue
static constexpr auto & ToValue(const StorageType &element)
Definition: CacheDescriptorAdapters.h:50
catapult::deltaset::MutableTypeTraits
Traits used for describing a mutable type.
Definition: BaseSetDefaultTraits.h:152
catapult::deltaset::MapStorageTraits
Base set compatible traits for stl map types.
Definition: BaseSetDefaultTraits.h:96
BaseSet.h
catapult::cache::detail::UnorderedMapAdapter::MemoryMapType
std::unordered_map< typename TDescriptor::KeyType, typename TDescriptor::ValueType, TValueHasher > MemoryMapType
Definition: CacheDescriptorAdapters.h:60
catapult::cache::detail::UnorderedMapAdapter::StorageMapType
CacheContainerView< DescriptorAdapter > StorageMapType
Definition: CacheDescriptorAdapters.h:59
catapult::cache::detail::UnorderedMapAdapter::DescriptorAdapter::Serializer
typename TDescriptor::Serializer Serializer
Definition: CacheDescriptorAdapters.h:42
catapult::cache::detail::OrderedSetAdapter::DescriptorAdapter::KeyType
typename TDescriptor::KeyType KeyType
Definition: CacheDescriptorAdapters.h:161
CacheDatabase.h
catapult::cache::detail::OrderedMemorySetAdapter::ElementType
std::remove_const_t< typename TElementTraits::ElementType > ElementType
Definition: CacheDescriptorAdapters.h:110
catapult::cache::detail::UnorderedMapAdapter::DescriptorAdapter
Definition: CacheDescriptorAdapters.h:37
catapult::cache::detail::UnorderedMapAdapter::DescriptorAdapter::StorageType
std::pair< const KeyType, ValueType > StorageType
Definition: CacheDescriptorAdapters.h:41
catapult::cache::detail::OrderedSetAdapter::MemorySetType
std::set< ElementType > MemorySetType
Definition: CacheDescriptorAdapters.h:183
catapult::deltaset::detail::OrderedSetType
std::set< std::remove_const_t< typename T::ElementType >, std::less< typename T::ElementType > > OrderedSetType
Definition: OrderedSet.h:39
catapult::cache::detail::OrderedSetAdapter::BaseSetDeltaPointerType
std::shared_ptr< BaseSetDeltaType > BaseSetDeltaPointerType
Base set delta pointer type.
Definition: CacheDescriptorAdapters.h:205
catapult::cache::detail::OrderedMemorySetAdapter::BaseSetDeltaPointerType
std::shared_ptr< BaseSetDeltaType > BaseSetDeltaPointerType
Base set delta pointer type.
Definition: CacheDescriptorAdapters.h:140
catapult::cache::detail::OrderedMemorySetAdapter::StorageSetType
Definition: CacheDescriptorAdapters.h:112
catapult::cache::RocksDatabase
RocksDb-backed database.
Definition: RocksDatabase.h:116
catapult::cache::detail::OrderedSetAdapter::DescriptorAdapter::ToStorage
static constexpr auto & ToStorage(const ValueType &value)
Definition: CacheDescriptorAdapters.h:176
catapult::cache::detail::OrderedSetAdapter::DescriptorAdapter::GetKeyFromValue
static constexpr auto GetKeyFromValue
Definition: CacheDescriptorAdapters.h:166
catapult::cache::detail::OrderedSetAdapter::StorageTraits
Definition: CacheDescriptorAdapters.h:195
catapult::deltaset::BaseSet
Definition: BaseSet.h:52
catapult::deltaset::SetKeyTraits
Key-related traits for stl set types.
Definition: BaseSetDefaultTraits.h:34
catapult::cache::detail::UnorderedMapAdapter::DescriptorAdapter::ToStorage
static auto ToStorage(const ValueType &value)
Definition: CacheDescriptorAdapters.h:54
catapult::cache::detail::UnorderedMapAdapter::DescriptorAdapter::ToKey
static constexpr auto & ToKey(const StorageType &element)
Definition: CacheDescriptorAdapters.h:46
catapult::cache::detail::OrderedMemorySetAdapter::MemorySetType
std::set< ElementType > MemorySetType
Definition: CacheDescriptorAdapters.h:118
catapult::cache::detail::OrderedSetAdapter::BaseSetDeltaType
typename BaseSetType::DeltaType BaseSetDeltaType
Base set delta type.
Definition: CacheDescriptorAdapters.h:202
catapult::cache::detail::UnorderedMapAdapter::BaseSetDeltaPointerType
std::shared_ptr< BaseSetDeltaType > BaseSetDeltaPointerType
Base set delta pointer type.
Definition: CacheDescriptorAdapters.h:87
catapult::cache::detail::OrderedSetAdapter::DescriptorAdapter::ValueType
typename TDescriptor::ValueType ValueType
Definition: CacheDescriptorAdapters.h:162
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::cache::detail::UnorderedMapAdapter::DescriptorAdapter::ValueType
typename TDescriptor::ValueType ValueType
Definition: CacheDescriptorAdapters.h:40
catapult::deltaset::MapKeyTraits
Key-related traits for stl map types.
Definition: BaseSetDefaultTraits.h:47
catapult::deltaset::ConditionalContainer
A conditional container that delegates to either a storage or a memory backed container.
Definition: ConditionalContainer.h:53
catapult::cache::detail::OrderedSetAdapter::DescriptorAdapter::ToKey
static constexpr auto & ToKey(const StorageType &element)
Definition: CacheDescriptorAdapters.h:168
catapult::cache::detail::UnorderedMapAdapter::StorageTraits
Definition: CacheDescriptorAdapters.h:77
catapult::cache::detail::OrderedMemorySetAdapter::StorageTraits
Definition: CacheDescriptorAdapters.h:130
catapult::cache::detail::OrderedMemorySetAdapter::StorageSetType::StorageSetType
StorageSetType(CacheDatabase &, size_t)
Definition: CacheDescriptorAdapters.h:114
catapult::cache::detail::OrderedSetAdapter::DescriptorAdapter::StorageType
typename TDescriptor::KeyType StorageType
Definition: CacheDescriptorAdapters.h:163
catapult::cache::RdbTypedColumnContainer
Typed container adapter that wraps column.
Definition: RdbTypedColumnContainer.h:32
catapult::cache::detail::OrderedSetAdapter::DescriptorAdapter
Definition: CacheDescriptorAdapters.h:159
CacheConfiguration.h
catapult::cache::detail::UnorderedMapAdapter::DescriptorAdapter::GetKeyFromValue
static constexpr auto GetKeyFromValue
Definition: CacheDescriptorAdapters.h:44
catapult::cache::detail::UnorderedMapAdapter::DescriptorAdapter::KeyType
typename TDescriptor::KeyType KeyType
Definition: CacheDescriptorAdapters.h:39
catapult::cache::detail::UnorderedMapAdapter
Defines cache types for an unordered map based cache.
Definition: CacheDescriptorAdapters.h:35