@@ -61,6 +61,7 @@ void fill_vector_with_case(std::vector<T>& to_fill, const abstract_value& opts)
6161#include < easylogging++.h>
6262
6363
64+
6465/* *
6566 * This class is referred to Closure as it wraps around both the loaded data and the intermediate values generating
6667 * the resulting graph as per matching.
@@ -825,9 +826,9 @@ struct closure {
825826 NestedResultTable interpret_closure_evaluate (rewrite_expr* ptr, bool force, bool node_or_edge_otherwise) /* const*/ ;
826827// std::vector<size_t> interpret_closure_evaluate2(rewrite_expr* ptr) /*const*/;
827828
828- std::pair<roaring::Roaring64Map, size_t > interpret (test_pred& ptr, size_t maxN) /* const*/ ;
829+ OrderedSet interpret (test_pred& ptr, size_t maxN) /* const*/ ;
829830
830- NestedResultTable resolve (const NestedResultTable& x,
831+ NestedResultTable resolve (const NestedResultTable& x, OrderedSet& containment,
831832 NestedResultTable::variant_type_cpp script_cast = NestedResultTable::RT_NONE) const ;
832833
833834 };
@@ -1238,7 +1239,7 @@ struct closure {
12381239 Interpret I (graph_id, pattern_id, pattern_result.first , it->second , table_offset, *this , pr.morphisms , forloading);
12391240 if (pattern.has_where ) {
12401241 auto result = I.interpret (pattern.where , 1 );
1241- if ((result.first . cardinality ()== 0 )) {
1242+ if ((result.empty () )) {
12421243 table_offset++;
12431244 continue ; // next entry
12441245 }
@@ -1373,16 +1374,21 @@ std::string getOstringstream(
13731374 return imploded.str ();
13741375 }
13751376
1376- case NestedResultTable::RT_SIZET:
1377- return std::get<std::string>(I.resolve (containingStrings, NestedResultTable::RT_STRING).content );
1377+ case NestedResultTable::RT_SIZET: {
1378+ OrderedSet toIgnore{0 };
1379+ return std::get<std::string>(I.resolve (containingStrings, toIgnore, NestedResultTable::RT_STRING).content );
1380+ }
13781381
13791382 case NestedResultTable::RT_VSIZET: {
13801383 const auto & V = std::get<std::vector<size_t >>(containingStrings.content );
13811384 size_t index = 0 ;
13821385 std::map<size_t , std::unordered_set<std::string>> M;
1383- auto tmp = I.resolve (containingStrings, NestedResultTable::RT_VSTRING );
1386+
1387+ OrderedSet toIgnore{(size_t )0 };
1388+ auto tmp = I.resolve (containingStrings,toIgnore, NestedResultTable::RT_VSTRING );
13841389 for (size_t i = 0 , N = tmp.size (); i<N; i++) {
1385- M[V.at (index)].insert (tmp.getString (i));
1390+ if (toIgnore.contains (i))
1391+ M[V.at (index)].insert (tmp.getString (i));
13861392 index++;
13871393 }
13881394 for (auto it = M.begin (), en = M.end (); it != en; ) {
@@ -1425,14 +1431,18 @@ std::vector<gsm_object_xi_content> getFlattenedContent(
14251431 }
14261432
14271433 case NestedResultTable::RT_SIZET: {
1428- return I.resolve (containingStrings, NestedResultTable::RT_CONTENT).getContent (0 );
1434+ OrderedSet toIgnore{0 };
1435+ return I.resolve (containingStrings, toIgnore, NestedResultTable::RT_CONTENT).getContent (0 );
14291436 }
14301437
14311438 case NestedResultTable::RT_VSIZET: {
1432- const auto W = I.resolve (containingStrings, NestedResultTable::RT_VCONTENT );
1439+ OrderedSet toIgnore{(size_t )0 };
1440+ const auto W = I.resolve (containingStrings, toIgnore, NestedResultTable::RT_VCONTENT );
14331441 for (size_t i = 0 , N = W.size (); i<N; i++) {
1434- auto x = W.getContent (i);
1435- imploded.insert (imploded.end (), x.begin (), x.end ());
1442+ if (toIgnore.contains (i)) {
1443+ auto x = W.getContent (i);
1444+ imploded.insert (imploded.end (), x.begin (), x.end ());
1445+ }
14361446 }
14371447 remove_duplicates (imploded);
14381448 return imploded;
@@ -1446,8 +1456,9 @@ std::vector<gsm_object_xi_content> getFlattenedContent(
14461456 }
14471457}
14481458
1449- template <typename T>
14501459
1460+ template <typename T>
1461+ static inline
14511462 void complexInstantiate (size_t graph_id,
14521463 closure& self,
14531464 const closure::Interpret &I,
@@ -1463,68 +1474,96 @@ template <typename T>
14631474 NestedResultTable &NAME) {
14641475 auto nameType = (NAME.size ()) > 1 ? NestedResultTable::RT_VSTRING : NestedResultTable::RT_STRING;
14651476 auto valType = (VAL.size ()) > 1 ? vectorType : simpleType;
1477+ if (VAR.containsInt (30 ))
1478+ std::cerr << " DEBUG" << std::endl;
14661479 if ((VAR.cell_nested_morphism == VAL.cell_nested_morphism ) &&
14671480 (VAL.cell_nested_morphism == NAME.cell_nested_morphism )) {
1468- VAL = I.resolve (VAL, valType);
1469- NAME = I.resolve (NAME, nameType);
1481+ OrderedSet rLS{(size_t )0 }, rNS{(size_t )0 };
1482+ VAL = I.resolve (VAL, rLS, valType);
1483+ NAME = I.resolve (NAME,rNS, nameType);
1484+ rLS &= rNS;
14701485 for (size_t i = 0 , N = std::min ({VAR.size (), VAL.size (), NAME.size ()}); i < N; i++) {
1486+ if (rLS.contains (i))
14711487 resolve (graph_id, VAR.getInt (i), NAME.getString (i), projector (VAL,i));
1472- // delta_updates_per_graph[graph_id].delta_plus_db.generateId(VAR.getInt(i)).content[NAME.getString(i)] = VAL.getT<std::string>(i);
1488+ // else
1489+ // DEBUG_ASSERT((NAME.getInt(i) != (size_t)-1)||(VAL.getInt(i) != (size_t)-1));
14731490 }
14741491 } else if (VAR.cell_nested_morphism == VAL.cell_nested_morphism ) {
1475- VAL = I.resolve (VAL, valType);
1476- NAME = I.resolve (NAME, nameType);
1492+ OrderedSet rLS{(size_t )0 }, rNS{(size_t )0 };
1493+ VAL = I.resolve (VAL, rLS, valType);
1494+ NAME = I.resolve (NAME, rNS, nameType);
14771495 for (size_t i = 0 , N = NAME.size (); i<N; i++) {
1478- for (size_t i = 0 , N = VAR.size (); i < N; i++) {
1479- resolve (graph_id, VAR.getInt (i), NAME.getString (i), projector (VAL,i));
1480- // delta_updates_per_graph[graph_id].delta_plus_db.generateId(VAR.getInt(i)).content[x] = VAL.getT<std::string>(i);
1481- }
1496+ if (rNS.contains (i)) {
1497+ for (size_t j = 0 , M = VAR.size (); j < M; j++) {
1498+ if (rLS.contains (j))
1499+ resolve (graph_id, VAR.getInt (j), NAME.getString (i), projector (VAL,j));
1500+ // else
1501+ // DEBUG_ASSERT(VAL.getInt(i) == (size_t)-1);
1502+ }
1503+ } // else
1504+ // DEBUG_ASSERT(NAME.getInt(i) == (size_t)-1);
14821505 }
14831506 } else if ((NAME.cell_nested_morphism == VAR.cell_nested_morphism ) && (NAME.cell_nested_morphism == -1 )) {
1484- NAME = I. resolve (NAME, nameType) ;
1485-
1507+ OrderedSet rLS{( size_t ) 0 } ;
1508+ NAME = I. resolve (NAME, rLS, nameType);
14861509 auto result = flattenT (I, delim, VAL);
14871510 for (size_t i = 0 , N = std::min ({VAR.size (), NAME.size ()}); i < N; i++) {
1511+ if (rLS.contains (i))
14881512 resolve (graph_id, VAR.getInt (i), NAME.getString (i), result);
1489- // delta_updates_per_graph[graph_id].delta_plus_db.generateId(VAR.getInt(i)).content[NAME.getString(i)] = result;
1513+ // else
1514+ // DEBUG_ASSERT(NAME.getInt(i) == (size_t)-1);
14901515 }
14911516 } else if ((NAME.cell_nested_morphism == VAR.cell_nested_morphism ) && (VAL.cell_nested_morphism == -1 )) {
1492- NAME = I.resolve (NAME, nameType);
1517+ OrderedSet rLS{(size_t )0 };
1518+ NAME = I.resolve (NAME, rLS, nameType);
14931519 auto val = flattenT (I, delim, VAL);
14941520 for (size_t i = 0 , N = std::min ({VAR.size (), NAME.size ()}); i < N; i++) {
1521+ if (rLS.contains (i))
14951522 resolve (graph_id, VAR.getInt (i), NAME.getString (i), val);
1496- // delta_updates_per_graph[graph_id].delta_plus_db.generateId(VAR.getInt(i)).content[NAME.getString(i)] = val;
1523+ // else
1524+ // DEBUG_ASSERT(NAME.getInt(i) == (size_t)-1);
14971525 }
14981526 } else if ((NAME.cell_nested_morphism == VAL.cell_nested_morphism ) && (VAR.cell_nested_morphism == -1 )) {
1499- VAL = I.resolve (VAL, valType);
1500- NAME = I.resolve (NAME, nameType);
1527+ OrderedSet rLS{(size_t )0 }, rNS{(size_t )0 };
1528+ VAL = I.resolve (VAL,rLS, valType);
1529+ NAME = I.resolve (NAME,rNS, nameType);
15011530 DEBUG_ASSERT (VAR.size () == 1 );
15021531 std::unordered_map<std::string, std::set<T>> vals;
1503- for (size_t i = 0 , N = std::min ({NAME.size (), VAL.size ()}); i < N; i++) {
1532+ rLS &= rNS;
1533+ for (size_t i = 0 , N = rLS.cardinality (); i < N; i++) {
1534+ if (rLS.contains (i))
15041535 vals[NAME.getString (i)].insert (projector (VAL,i));
1536+ // else
1537+ // DEBUG_ASSERT((NAME.getInt(i) == (size_t)-1)||(VAL.getInt(i) == (size_t)-1));
15051538 }
15061539 for (const auto &[k, v]: vals) {
15071540 resolve (graph_id, VAR.getInt (0 ), k, flatten2 (v));
1508- // delta_updates_per_graph[graph_id].delta_plus_db.generateId(VAR.getInt(0)).content[k] = imploded.str();
15091541 }
15101542 } else if ((NAME.cell_nested_morphism == VAL.cell_nested_morphism ) && (VAL.cell_nested_morphism == -1 )) {
15111543 DEBUG_ASSERT ((VAL.size () == 1 ) && (NAME.size () == 1 ));
15121544 auto val = flattenT (I, delim, VAL);
15131545 auto name = getOstringstream (I, delim, NAME);
15141546 for (size_t idx = 0 , N = VAR.size (); idx < N; idx++) {
15151547 resolve (graph_id, VAR.getInt (0 ), name, val);
1516- // delta_updates_per_graph[graph_id].delta_plus_db.generateId(VAR.getInt(idx)).content[name] = val;
15171548 }
15181549 } else {
1519- NAME = I.resolve (NAME, nameType);
1550+ OrderedSet rLS{(size_t )0 };
1551+ NAME = I.resolve (NAME, rLS, nameType);
15201552 DEBUG_ASSERT ((NAME.cell_nested_morphism != VAL.cell_nested_morphism ) &&
15211553 (VAR.cell_nested_morphism != VAL.cell_nested_morphism ) &&
15221554 (NAME.cell_nested_morphism != VAR.cell_nested_morphism ));
15231555 if (VAR.cell_nested_morphism == -1 ) {
15241556 DEBUG_ASSERT (VAR.size () == 1 );
15251557 size_t id = VAR.getInt (0 );
15261558 const auto &namesV = std::get<std::vector<std::string>>(NAME.content );
1527- std::unordered_set<std::string> names (namesV.begin (), namesV.end ());
1559+ std::unordered_set<std::string> names;
1560+ for (size_t idx = 0 , N = rLS.cardinality (); idx<N; idx++) {
1561+ if (rLS.contains (idx))
1562+ names.insert (namesV.at (idx));
1563+ // else
1564+ // DEBUG_ASSERT((NAME.getInt(idx) == (size_t)-1));
1565+ }
1566+ // std::unordered_set<std::string> names(namesV.begin(), namesV.end());
15281567 auto str = flattenT (I, delim, VAL);
15291568 for (const auto &name: names) {
15301569 resolve (graph_id, VAR.getInt (0 ), name, str);
@@ -1533,7 +1572,13 @@ template <typename T>
15331572 } else if (VAL.cell_nested_morphism == -1 ) {
15341573 DEBUG_ASSERT (VAL.size () == 1 );
15351574 const auto &namesV = std::get<std::vector<std::string>>(NAME.content );
1536- std::unordered_set<std::string> names (namesV.begin (), namesV.end ());
1575+ std::unordered_set<std::string> names;
1576+ for (size_t idx = 0 , N = rLS.cardinality (); idx<N; idx++) {
1577+ if (rLS.contains (idx))
1578+ names.insert (namesV.at (idx));
1579+ // else
1580+ // DEBUG_ASSERT((NAME.getInt(idx) == (size_t)-1));
1581+ }
15371582 const auto val = flattenT (I, delim, VAL);
15381583 for (size_t i = 0 , N = VAR.size (); i < N; i++) {
15391584 auto id = VAR.getInt (i);
@@ -1547,10 +1592,14 @@ template <typename T>
15471592 DEBUG_ASSERT (NAME.size () == 1 );
15481593 const auto &name = NAME.getString (0 );
15491594 const auto val = flattenT (I, delim, VAL);
1595+ // std::cout << rLS << std::endl;
1596+ if (rLS.contains (0 ))
15501597 for (size_t i = 0 , N = VAR.size (); i < N; i++) {
15511598 resolve (graph_id, VAR.getInt (i), name, val);
15521599// delta_updates_per_graph[graph_id].delta_plus_db.generateId(VAR.getInt(i)).content[name] = val;
15531600 }
1601+ // else
1602+ // DEBUG_ASSERT(NAME.getInt(0) == (size_t)-1);
15541603 }
15551604 }
15561605 }
0 commit comments