CatapultServer  v0.5.0.1 (Elephant)
UpdateSet.h
Go to the documentation of this file.
1 
21 #pragma once
24 
25 namespace catapult { namespace cache {
26 
28  template<typename TKeyTraits, typename TDescriptor, typename TContainer, typename TMemorySet>
30  auto size = elements.size();
31  if (!deltas.HasChanges())
32  return;
33 
34  for (const auto& added : deltas.Added)
35  elements.insert(added);
36 
37  for (const auto& element : deltas.Copied)
38  elements.insert(element);
39 
40  for (const auto& element : deltas.Removed)
41  elements.remove(TKeyTraits::ToKey(element));
42 
43  size += deltas.Added.size();
44  size -= deltas.Removed.size();
45  elements.setSize(size);
46  }
47 
49  template<typename TDescriptor, typename TContainer, typename TPruningBoundary>
50  void PruneBaseSet(RdbTypedColumnContainer<TDescriptor, TContainer>& elements, const TPruningBoundary& pruningBoundary) {
51  auto size = elements.size();
52  size -= elements.prune(pruningBoundary.value());
53  elements.setSize(size);
54  }
55 }}
catapult::deltaset::DeltaElements::Removed
const TSet & Removed
Removed elements.
Definition: DeltaElements.h:47
catapult::deltaset::DeltaElements::Added
const TSet & Added
Added elements.
Definition: DeltaElements.h:44
RdbTypedColumnContainer.h
catapult::deltaset::DeltaElements::HasChanges
bool HasChanges() const
Returns true if there are any pending changes.
Definition: DeltaElements.h:38
catapult::deltaset::DeltaElements
Slim wrapper around changed elements.
Definition: DeltaElements.h:27
catapult::cache::RdbTypedColumnContainer::prune
size_t prune(const KeyType &key)
Prunes elements with keys smaller than key. Returns number of pruned elements.
Definition: RdbTypedColumnContainer.h:130
catapult::cache::PruneBaseSet
void PruneBaseSet(RdbTypedColumnContainer< TDescriptor, TContainer > &elements, const TPruningBoundary &pruningBoundary)
Optionally prunes elements using pruningBoundary, which indicates the upper bound of elements to remo...
Definition: UpdateSet.h:50
catapult::cache::RdbTypedColumnContainer::remove
void remove(const KeyType &key)
Removes element with key.
Definition: RdbTypedColumnContainer.h:135
size
uint64_t size
Definition: MemoryCounters.cpp:65
catapult::cache::RdbTypedColumnContainer::insert
void insert(const StorageType &element)
Inserts element into container.
Definition: RdbTypedColumnContainer.h:112
catapult::deltaset::DeltaElements::Copied
const TSet & Copied
Copied elements.
Definition: DeltaElements.h:50
DeltaElements.h
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::cache::UpdateSet
void UpdateSet(RdbTypedColumnContainer< TDescriptor, TContainer > &elements, const deltaset::DeltaElements< TMemorySet > &deltas)
Applies all changes in deltas to elements.
Definition: UpdateSet.h:29
catapult::cache::RdbTypedColumnContainer
Typed container adapter that wraps column.
Definition: RdbTypedColumnContainer.h:32