Skip to content

Commit

Permalink
[search] Treat nrel_key_sc_element as binary relation
Browse files Browse the repository at this point in the history
  • Loading branch information
kilativ-dotcom committed Oct 17, 2024
1 parent 8a04e35 commit 6e045e2
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ScAddrUnorderedSet ScComponentManagerCommandSearch::Execute(ScAgentContext * con
{
if (commandParameters.find(std::get<0>(searchByRelation[sequenceNumber])) != commandParameters.cend())
{
SearchComponentsByRelationSet(
SearchComponentsByRelation(
context,
std::get<1>(searchByRelation[sequenceNumber]),
std::get<2>(searchByRelation[sequenceNumber]),
Expand All @@ -55,6 +55,19 @@ ScAddrUnorderedSet ScComponentManagerCommandSearch::Execute(ScAgentContext * con
}
}

for (size_t sequenceNumber = 0; sequenceNumber < searchByRelationSet.size(); sequenceNumber++)
{
if (commandParameters.find(std::get<0>(searchByRelationSet[sequenceNumber])) != commandParameters.cend())
{
SearchComponentsByRelationSet(
context,
std::get<1>(searchByRelationSet[sequenceNumber]),
std::get<2>(searchByRelationSet[sequenceNumber]),
searchComponentTemplate,
commandParameters.at(std::get<0>(searchByRelationSet[sequenceNumber])));
}
}

std::map<std::string, ScAddrUnorderedSet> linksValues;
for (size_t sequenceNumber = 0; sequenceNumber < searchByLine.size(); sequenceNumber++)
{
Expand All @@ -77,6 +90,29 @@ ScAddrUnorderedSet ScComponentManagerCommandSearch::Execute(ScAgentContext * con
return componentsSpecifications;
}

void ScComponentManagerCommandSearch::SearchComponentsByRelation(
ScMemoryContext * context,
ScAddr const & relationAddr,
std::string const & nodeAlias,
ScTemplate & searchComponentTemplate,
std::vector<std::string> const & parameters)
{
if (parameters.empty())
searchComponentTemplate.Quintuple(
COMPONENT_ALIAS, ScType::VarCommonArc, ScType::VarNode >> nodeAlias, ScType::VarPermPosArc, relationAddr);
for (std::string const & parameterIdentifier : parameters)
{
ScAddr parameterAddr = context->SearchElementBySystemIdentifier(parameterIdentifier);
if (!parameterAddr.IsValid())
{
searchComponentTemplate.Clear();
break;
}
searchComponentTemplate.Quintuple(
COMPONENT_ALIAS, ScType::VarCommonArc, parameterAddr, ScType::VarPermPosArc, relationAddr);
}
}

void ScComponentManagerCommandSearch::SearchComponentsByRelationSet(
ScMemoryContext * context,
ScAddr const & relationAddr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ class ScComponentManagerCommandSearch : public ScComponentManagerCommand
{MAIN_ID, ScKeynodes::nrel_main_idtf, MAIN_ID_LINK_ALIAS}};

std::vector<std::tuple<std::string, ScAddr, std::string>> searchByRelation = {
{AUTHOR, keynodes::ScComponentManagerKeynodes::nrel_authors, AUTHORS_SET_ALIAS},
{KEY, keynodes::ScComponentManagerKeynodes::nrel_key_sc_element, KEY_SET_ALIAS}};

std::vector<std::tuple<std::string, ScAddr, std::string>> searchByRelationSet = {
{AUTHOR, keynodes::ScComponentManagerKeynodes::nrel_authors, AUTHORS_SET_ALIAS}};

void SearchComponentsByClass(
ScMemoryContext * context,
ScTemplate & searchComponentTemplate,
Expand All @@ -59,6 +61,13 @@ class ScComponentManagerCommandSearch : public ScComponentManagerCommand
ScTemplate & searchComponentTemplate,
std::vector<std::string> const & parameters);

void SearchComponentsByRelation(
ScMemoryContext * context,
ScAddr const & relationAddr,
std::string const & setAlias,
ScTemplate & searchComponentTemplate,
std::vector<std::string> const & parameters);

ScAddrUnorderedSet SearchComponentsByRelationLink(
ScMemoryContext * context,
ScAddr const & relationAddr,
Expand Down

0 comments on commit 6e045e2

Please sign in to comment.