Go to the documentation of this file.
33 workingMemory(workingMemory), longtermMemory(longtermMemory)
44 data::AddSegmentResult
50 data::AddSegmentResult output;
65 output.success =
false;
66 output.errorMessage = e.what();
72 if (
input.providerSegmentName.size() > 0)
75 [&coreSegment, &
input]()
84 if (
input.clearWhenExists)
86 server::wm::ProviderSegment& provider =
87 coreSegment->getProviderSegment(input.providerSegmentName);
99 output.success =
true;
100 output.segmentID = segmentID.
str();
104 data::AddSegmentsResult
110 data::AddSegmentsResult output;
111 for (
const auto& i :
input)
113 output.push_back(
addSegment(i, addCoreSegments));
123 auto handleException = [](
const std::string& what)
125 data::CommitResult result;
126 data::EntityUpdateResult& r = result.results.emplace_back();
128 r.errorMessage = what;
140 return handleException(e.what());
142 catch (
const Ice::Exception& e)
145 return handleException(e.what());
149 data::CommitResult resultIce;
150 toIce(resultIce, result);
166 return this->_commit(
commit,
false);
174 auto handleException = [](
const std::string& what)
176 data::CommitResult result;
177 data::EntityUpdateResult& r = result.results.emplace_back();
179 r.errorMessage = what;
191 return handleException(e.what());
193 catch (
const Ice::Exception& e)
196 return handleException(e.what());
200 data::CommitResult resultIce;
201 toIce(resultIce, result);
217 return this->_commit(
commit,
true);
221 MemoryToIceAdapter::_commit(
const armem::Commit& commit,
bool locking)
224 std::vector<data::MemoryID> updatedIDs;
240 for (
const auto& snapshot : updateResult.removedSnapshots)
242 ARMARX_DEBUG <<
"The id " << snapshot.id() <<
" was removed from wm";
252 m.update(
update,
true,
false);
287 catch (
const error::ArMemError& e)
292 catch (
const aron::error::AronException& e)
297 catch (
const Ice::Exception& e)
317 armem::query::data::Result
329 armem::query::data::Result result;
332 result.memory = armarx::toIce<data::MemoryPtr>(wmResult);
334 result.success =
true;
335 if (result.memory->coreSegments.size() == 0)
343 armem::query::data::Result
366 armem::query::data::Result result;
368 result.memory = armarx::toIce<data::MemoryPtr>(ltmResult);
370 result.success =
true;
371 if (result.memory->coreSegments.size() == 0)
388 armem::structure::data::GetServerStructureResult
395 armem::structure::data::GetServerStructureResult
ret;
406 if (query_result.success)
408 structure.
append(query_result.memory);
414 ret.serverStructure = armarx::toIce<data::MemoryPtr>(structure);
423 ARMARX_INFO <<
"Reloading of all core segments from LTM into WM triggered";
432 auto res = this->
commit(com);
442 ARMARX_INFO <<
"Reloading of specific core segments from LTM into WM triggered";
444 std::ostringstream namesStr;
445 for (
auto it = coreSegmentNames.begin(); it != coreSegmentNames.end(); ++it) {
446 if (it != coreSegmentNames.begin()) namesStr <<
", ";
450 ARMARX_INFO <<
"Loading core segments=" << namesStr.str();
460 auto res = this->
commit(com);
469 ARMARX_INFO <<
"Reloading of coresegment defined in 'loadedCoreSegments' from LTM into WM on startup triggered";
473 ARMARX_INFO <<
"Loading core segments=" << coreNames <<
" defined in property 'loadedCoreSegments'";
476 std::list<std::string>
names;
477 std::stringstream ss(coreNames);
480 while (std::getline(ss, item,
','))
482 names.push_back(item);
494 ARMARX_INFO <<
"Reloading of data from LTM into WM on startup triggered";
502 ARMARX_INFO <<
"Not loading initial data from LTM due to importOnStartup being "
510 dto::DirectlyStoreResult
516 dto::DirectlyStoreResult output;
517 output.success =
true;
519 armem::wm::Memory m = armarx::fromIce<armem::wm::Memory>(directlStoreInput.memory);
525 dto::StartRecordResult
533 dto::StartRecordResult
ret;
539 dto::StopRecordResult
549 ARMARX_INFO <<
"Starting to save left-over WM data into LTM";
555 ARMARX_INFO <<
"Not storing WM data into LTM on stop, because storeOnStop is "
562 std::thread stopRecordingThread(
565 ltm->stopRecording();
566 ltm->bufferFinished();
569 stopRecordingThread.detach();
572 <<
"Stopped all LTM recordings, please wait with stopping the component until "
573 "all files are written";
575 dto::StopRecordResult
ret;
581 dto::RecordStatusResult
584 dto::RecordStatusResult
ret;
593 [&savedSnapshots, &totalSnapshots](
const auto&
c)
595 c.forEachProviderSegment(
596 [&savedSnapshots, &totalSnapshots](
const auto& p)
599 [&savedSnapshots, &totalSnapshots](
const auto& e)
601 savedSnapshots += e.getStatistics().recordedSnapshots;
603 e.forEachSnapshot([&totalSnapshots](
const auto&)
604 { totalSnapshots++; });
609 ret.status.savedSnapshots = savedSnapshots;
610 ret.status.totalSnapshots = totalSnapshots;
616 prediction::data::PredictionResultSeq
621 return armarx::toIce<prediction::data::PredictionResultSeq>(res);
624 prediction::data::EngineSupportMap
627 prediction::data::EngineSupportMap result;
server::wm::Memory * workingMemory
ReaderT::InputType T & ret
std::string providerSegmentName
A bundle of updates to be sent to the memory.
QueryInput buildQueryInput() const
RecordingMode getRecordingMode() const
Result of an EntityUpdate.
std::string coreSegmentsToLoad
server::ltm::Memory * longtermMemory
CoreSegmentT & getCoreSegment(const std::string &name)
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
dto::StartRecordResult startRecord(const dto::StartRecordInput &startRecordInput)
client::MemoryListenerInterfacePrx memoryListenerTopic
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
void toMemory(Memory &m, const std::vector< CoreSegment > &e)
void toIce(data::MemoryID &ice, const MemoryID &id)
DataMode boolToDataMode(bool withData)
struct armarx::armem::server::ltm::detail::MemoryBase::Properties p
std::string coreSegmentName
prediction::data::PredictionResultSeq predict(prediction::data::PredictionRequestSeq requests)
armem::structure::data::GetServerStructureResult getServerStructure()
A memory storing data on the hard drive and in mongodb (needs 'armarx memory start' to start the mong...
void toIce(std::map< IceKeyT, IceValueT > &iceMap, const boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
armem::CommitResult reloadFromLTMOnStartup()
Triggers a reload (.
void setMemoryListener(client::MemoryListenerInterfacePrx memoryListenerTopic)
void resolve(armem::wm::Memory &memory)
convert the references of the input into a wm::Memory
ResultMemoryT process(const armem::query::data::Input &input, const MemoryT &memory) const
armem::CommitResult reloadPropertyDefinedCoreSegmentsFromLTM()
std::map< MemoryID, std::vector< PredictionEngine > > getAllPredictionEngines() const
void fromIce(Eigen::Vector2f &e, const Ice::FloatSeq &ice)
armem::wm::Memory loadLatestNReferences(int n)
ReaderT::InputType & input
Client-side working memory.
int maxAmountOfSnapshotsLoaded
The AronNotValidException class.
An update of an entity for a specific point in time.
CoreSegmentT & addCoreSegment(const std::string &name, aron::type::ObjectPtr coreSegmentType=nullptr, const std::vector< PredictionEngine > &predictionEngines={})
Add an empty core segment with the given name, type and prediction engines.
bool forEachCoreSegment(std::function< void(CoreSegment &)> func) const final
iterate over all core segments of this ltm
dto::RecordStatusResult getRecordStatus()
void directlyStore(const armem::wm::Memory &memory, bool simulatedVersion=false)
auto doLocked(FunctionT &&function) const
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
void startRecording()
enable/disable
prediction::data::EngineSupportMap getAvailableEngines()
dto::StopRecordResult stopRecord()
void fromIce(const std::map< IceKeyT, IceValueT > &iceMap, boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
dto::DirectlyStoreResult directlyStore(const dto::DirectlyStoreInput &directlStoreInput)
Represents a point in time.
data::AddSegmentResult addSegment(const data::AddSegmentInput &input, bool addCoreSegments=false)
const simox::meta::IntEnumNames names
armem::wm::Memory loadAllReferences()
return the full ltm as a wm::Memory with only references the ltm may be huge, use with caution
std::vector< EntityUpdateResult > results
data::AddSegmentsResult addSegments(const data::AddSegmentsInput &input, bool addCoreSegments=false)
MemoryToIceAdapter(server::wm::Memory *workingMemory=nullptr, server::ltm::Memory *longtermMemory=nullptr)
Construct an MemoryToIceAdapter from an existing Memory.
armem::CommitResult reloadCoreSegmentsFromLTM(std::list< std::string > &coreSegmentname)
Only load specific core segments and their data from the LTM.
@ NoData
Just get the structure, but no ARON data.
void append(const OtherDerivedT &other)
Merge another memory into this one.
The query::Builder class provides a fluent-style specification of hierarchical queries.
std::vector< PredictionResult > dispatchPredictions(const std::vector< PredictionRequest > &requests)
std::vector< UpdateResult > update(const Commit &commit, const bool addMissingCoreSegmentDuringUpdate=false, const bool checkMemoryName=true)
Store all updates in commit.
Indicates that a name in a given ID does not match a container's own name.
void all()
Get all snapshots from all entities in all segments.
armem::CommitResult reloadAllFromLTM()
Loads all core segments and their data from the LTM.
ProviderSegment & addProviderSegment(const std::string &name, Args... args)
std::vector< Base::UpdateResult > updateLocking(const Commit &commit)
Perform the commit, locking the core segments.
static QueryResult fromIce(const armem::query::data::Result &ice)
query::data::Result queryLTM(const armem::query::data::Input &input, bool storeIntoWM)
Query the LTMs of the memory server.
Commit toCommit(const ContainerT &container)
data::CommitResult commitLocking(const data::Commit &commitIce, Time timeArrived)
data::CommitResult commit(const data::Commit &commitIce, Time timeArrived)
Indicates that a container did not have an entry under a given name.
query::data::Result query(const armem::query::data::Input &input)
void store(const armem::wm::Memory &memory)
append a wm::Memory instance to the ltm
const armem::MemoryID MemoryID