Skip to content
Snippets Groups Projects
Commit f3a2d97d authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Move code, fix style (don't start using another code style in an existing environment, dammit)

parent f23d6473
No related branches found
No related tags found
No related merge requests found
...@@ -144,7 +144,7 @@ namespace armarx::armem::server ...@@ -144,7 +144,7 @@ namespace armarx::armem::server
MemoryToIceAdapter::commit(const armem::Commit& commit) MemoryToIceAdapter::commit(const armem::Commit& commit)
{ {
std::vector<data::MemoryID> updatedIDs; std::vector<data::MemoryID> updatedIDs;
const bool publishUpdates = memoryListenerTopic; const bool publishUpdates = bool(memoryListenerTopic);
CommitResult commitResult; CommitResult commitResult;
for (const EntityUpdate& update : commit.updates) for (const EntityUpdate& update : commit.updates)
...@@ -152,6 +152,7 @@ namespace armarx::armem::server ...@@ -152,6 +152,7 @@ namespace armarx::armem::server
EntityUpdateResult& result = commitResult.results.emplace_back(); EntityUpdateResult& result = commitResult.results.emplace_back();
try try
{ {
// update() will lock core segment mutexes
auto updateResult = workingMemory->update(update); auto updateResult = workingMemory->update(update);
result.success = true; result.success = true;
...@@ -202,29 +203,27 @@ namespace armarx::armem::server ...@@ -202,29 +203,27 @@ namespace armarx::armem::server
{ {
ARMARX_CHECK_NOT_NULL(workingMemory); ARMARX_CHECK_NOT_NULL(workingMemory);
armem::wm::query_proc::MemoryQueryProcessor wm_processor( // Core segment processors will aquire the core segment locks.
input.withData ? armem::DataMode::WithData armem::wm::query_proc::MemoryQueryProcessor wmProcessor(
: armem::DataMode::NoData); input.withData ? armem::DataMode::WithData : armem::DataMode::NoData);
wm::Memory wmResult = wmProcessor.process(input, *workingMemory, /* execute if: */ { query::data::QueryTarget::WM });
armem::query::data::Result result;
wm::Memory wm_result = wm_processor.process(input, *workingMemory, /* execute if: */ { query::data::QueryTarget::WM });
armem::ltm::query_proc::MemoryQueryProcessor ltm_processor;
ltm::Memory ltm_result = ltm_processor.process(input, *longtermMemory, /* execute if: */ { query::data::QueryTarget::LTM });
armem::ltm::query_proc::MemoryQueryProcessor ltmProcessor;
ltm::Memory ltmResult = ltmProcessor.process(input, *longtermMemory, /* execute if: */ { query::data::QueryTarget::LTM });
if (ltm_result.hasData()) armem::query::data::Result result;
if (ltmResult.hasData())
{ {
// ATTENTION: This code block moves data from LTM back into WM. // ATTENTION: This code block moves data from LTM back into WM.
// However, since some segments are constrained, the WM might send data back to LTM. // However, since some segments are constrained, the WM might send data back to LTM.
// This may also affect the data returned by the current query. // This may also affect the data returned by the current query.
// However, this is expected behavior, since we copy the data in the processor (copyEmpty) we can safely return the copy and // However, this is expected behavior, since we copy the data in the processor (copyEmpty) we can safely return the copy and
// remove the original memory reference from WM here. // remove the original memory reference from WM here.
wm::Memory ltm_converted = ltm_result.convert(); wm::Memory ltmConverted = ltmResult.convert();
wm_result.append(ltm_converted); wmResult.append(ltmConverted);
// query again to limit output size (TODO: Skip if querytype is all) // query again to limit output size (TODO: Skip if querytype is all)
wm::Memory merged_result = wm_processor.process(input, wm_result); wm::Memory merged_result = wmProcessor.process(input, wmResult);
result.memory = toIce<data::MemoryPtr>(merged_result); result.memory = toIce<data::MemoryPtr>(merged_result);
// also move results of ltm to wm // also move results of ltm to wm
...@@ -235,7 +234,7 @@ namespace armarx::armem::server ...@@ -235,7 +234,7 @@ namespace armarx::armem::server
} }
else else
{ {
result.memory = toIce<data::MemoryPtr>(wm_result); result.memory = toIce<data::MemoryPtr>(wmResult);
} }
result.success = true; result.success = true;
...@@ -247,6 +246,13 @@ namespace armarx::armem::server ...@@ -247,6 +246,13 @@ namespace armarx::armem::server
return result; return result;
} }
client::QueryResult MemoryToIceAdapter::query(const client::QueryInput& input)
{
return client::QueryResult::fromIce(query(input.toIce()));
}
// LTM LOADING FROM LTM // LTM LOADING FROM LTM
query::data::Result MemoryToIceAdapter::load(const armem::query::data::Input& query) query::data::Result MemoryToIceAdapter::load(const armem::query::data::Input& query)
{ {
...@@ -257,6 +263,7 @@ namespace armarx::armem::server ...@@ -257,6 +263,7 @@ namespace armarx::armem::server
return output; return output;
} }
// LTM STORING // LTM STORING
data::StoreResult MemoryToIceAdapter::store(const armem::data::StoreInput& input) data::StoreResult MemoryToIceAdapter::store(const armem::data::StoreInput& input)
{ {
...@@ -284,9 +291,6 @@ namespace armarx::armem::server ...@@ -284,9 +291,6 @@ namespace armarx::armem::server
return output; return output;
} }
client::QueryResult MemoryToIceAdapter::query(const client::QueryInput& input)
{
return client::QueryResult::fromIce(query(input.toIce()));
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment