Go to the documentation of this file.
31 workingMemory(workingMemory), longtermMemory(longtermMemory)
42 data::AddSegmentResult
48 ARMARX_DEBUG <<
"Adding segment using MemoryToIceAdapter";
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";
288 catch (
const error::ArMemError& e)
293 catch (
const aron::error::AronException& e)
298 catch (
const Ice::Exception& e)
318 armem::query::data::Result
330 armem::query::data::Result result;
333 result.memory = armarx::toIce<data::MemoryPtr>(wmResult);
335 result.success =
true;
336 if (result.memory->coreSegments.size() == 0)
344 armem::query::data::Result
367 armem::query::data::Result result;
369 result.memory = armarx::toIce<data::MemoryPtr>(ltmResult);
371 result.success =
true;
372 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);
424 ARMARX_INFO <<
"Reloading of all core segments from LTM into WM triggered";
433 auto res = this->
commit(com);
444 ARMARX_INFO <<
"Reloading of specific core segments from LTM into WM triggered";
446 std::ostringstream namesStr;
447 for (
auto it = coreSegmentNames.begin(); it != coreSegmentNames.end(); ++it)
449 if (it != coreSegmentNames.begin())
454 ARMARX_INFO <<
"Loading core segments=" << namesStr.str();
464 auto res = this->
commit(com);
473 ARMARX_INFO <<
"Reloading of coresegment defined in 'loadedCoreSegments' from LTM into WM "
474 "on startup triggered";
478 ARMARX_INFO <<
"Loading core segments=" << coreNames
479 <<
" defined in property 'loadedCoreSegments'";
482 std::list<std::string>
names;
483 std::stringstream ss(coreNames);
486 while (std::getline(ss, item,
','))
488 names.push_back(item);
500 ARMARX_INFO <<
"Reloading of data from LTM into WM on startup triggered";
508 ARMARX_INFO <<
"Not loading initial data from LTM due to importOnStartup being "
516 dto::DirectlyStoreResult
522 dto::DirectlyStoreResult output;
523 output.success =
true;
525 armem::wm::Memory m = armarx::fromIce<armem::wm::Memory>(directlStoreInput.memory);
531 dto::StartRecordResult
539 dto::StartRecordResult
ret;
545 dto::StopRecordResult
555 ARMARX_INFO <<
"Starting to save left-over WM data into LTM";
561 ARMARX_INFO <<
"Not storing WM data into LTM on stop, because storeOnStop is "
568 std::thread stopRecordingThread(
571 ltm->stopRecording();
572 ltm->bufferFinished();
575 stopRecordingThread.detach();
578 <<
"Stopped all LTM recordings, please wait with stopping the component until "
579 "all files are written";
581 dto::StopRecordResult
ret;
587 dto::RecordStatusResult
590 dto::RecordStatusResult
ret;
599 [&savedSnapshots, &totalSnapshots](
const auto&
c)
601 c.forEachProviderSegment(
602 [&savedSnapshots, &totalSnapshots](
const auto& p)
605 [&savedSnapshots, &totalSnapshots](
const auto& e)
607 savedSnapshots += e.getStatistics().recordedSnapshots;
609 e.forEachSnapshot([&totalSnapshots](
const auto&)
610 { totalSnapshots++; });
615 ret.status.savedSnapshots = savedSnapshots;
616 ret.status.totalSnapshots = totalSnapshots;
622 prediction::data::PredictionResultSeq
627 return armarx::toIce<prediction::data::PredictionResultSeq>(res);
630 prediction::data::EngineSupportMap
633 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.
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.
CoreSegment & addCoreSegment(const std::string &name, Args... args)
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