21 std::string containerID = (this->
id()).
str();
22 MaxHistorySize::setMaxHistorySize(maxSize, containerID);
29 UpdateResult result = EntityBase::update(
update);
30 result.removedSnapshots = this->
truncate();
34 std::vector<EntitySnapshot>
37 std::vector<EntitySnapshot> removedElements;
44 : std::numeric_limits<size_t>::max();
49 removedElements.push_back(std::move(this->
_container.begin()->second));
59 <<
"Entity '" << this->
id().
str() <<
"' has "
61 <<
" snapshots with unlimited history (maxHistorySize=-1). "
62 <<
"Consider setting a limit to prevent memory exhaustion.";
64 return removedElements;
68 std::vector<Memory::Base::UpdateResult>
72 std::map<std::string, std::vector<const EntityUpdate*>> updatesPerCoreSegment;
75 updatesPerCoreSegment[
update.entityID.coreSegmentName].push_back(&
update);
78 std::vector<Memory::Base::UpdateResult> result;
80 std::vector<std::string> missingCoreSegmentNames;
81 for (
const auto& [coreSegmentName, updates] : updatesPerCoreSegment)
83 auto it = this->
_container.find(coreSegmentName);
90 [&result, &coreSegment, updates = &updates]()
95 Base::UpdateResult ret{r};
97 result.push_back(ret);
104 missingCoreSegmentNames.push_back(coreSegmentName);
108 if (not missingCoreSegmentNames.empty())
118 Memory::Base::UpdateResult
124 Base::UpdateResult result;
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
UpdateResult update(const EntityUpdate &update)
Updates an entity's history.
std::vector< UpdateResult > update(const Commit &commit, const bool addMissingCoreSegmentDuringUpdate=false, const bool checkMemoryName=true)
CoreSegmentT & getCoreSegment(const std::string &name)
void _checkContainerName(const std::string &gottenName, const std::string &actualName, bool emptyOk=true) const
static MissingEntry create(const std::string &missingKey, const ContainerT &container)
auto doLockedExclusive(FunctionT &&function)
Execute function under exclusive (write) lock.
void setMaxHistorySize(long maxSize)
Sets the maximum history size.
std::vector< EntitySnapshotT > truncate()
If maximum size is set, ensure history's is not higher.
UpdateResult update(const EntityUpdate &update)
std::vector< Base::UpdateResult > updateLocking(const Commit &commit)
Perform the commit, locking the core segments.
long _maxHistorySize
Maximum size of entity histories.
size_t _truncateMaxBatchSize
Maximum number of snapshots to remove per truncate() call.
size_t _unlimitedHistoryWarningThreshold
Threshold for warning about unlimited history growth.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
A bundle of updates to be sent to the memory.
std::vector< EntityUpdate > updates
The entity updates.
An update of an entity for a specific point in time.
MemoryID entityID
The entity's ID.