#include <Relation.h>
Definition at line 144 of file Relation.h.
 
◆ BrieRelation()
◆ computeIndices()
  
  | 
        
          | void souffle::synthesiser::BrieRelation::computeIndices | ( |  | ) |  |  | override | 
 
Generate index set for a brie relation. 
Definition at line 849 of file Relation.cpp.
  850     assert(!isProvenance && 
"bries cannot be used with provenance");
 
  856     assert(!inds.empty() && 
"No full index in relation");
 
  859     for (
auto& ind : inds) {
 
  862             std::set<int> curIndexElems(ind.begin(), ind.end());
 
  866                 if (curIndexElems.find(
i) == curIndexElems.end()) {
 
  872         assert(ind.size() == 
getArity() && 
"index is not a full");
 
  876     computedIndices = inds;
 
 
References i.
 
 
◆ generateTypeStruct()
  
  | 
        
          | void souffle::synthesiser::BrieRelation::generateTypeStruct | ( | std::ostream & | out | ) |  |  | override | 
 
Generate type struct of a brie relation. 
Definition at line 904 of file Relation.cpp.
  906     const auto& inds = getIndices();
 
  907     size_t numIndexes = inds.size();
 
  908     std::map<MinIndexSelection::LexOrder, int> indexToNumMap;
 
  912     out << 
"static constexpr Relation::arity_type Arity = " << 
arity << 
";\n";
 
  915     for (
size_t i = 0; 
i < inds.size(); 
i++) {
 
  916         if (
i < getMinIndexSelection().getAllOrders().
size()) {
 
  917             indexToNumMap[getMinIndexSelection().getAllOrders()[
i]] = 
i;
 
  919         out << 
"using t_ind_" << 
i << 
" = Trie<" << inds[
i].size() << 
">;\n";
 
  920         out << 
"t_ind_" << 
i << 
" ind_" << 
i << 
";\n";
 
  922     out << 
"using t_tuple = t_ind_" << masterIndex << 
"::entry_type;\n";
 
  925     for (
size_t i = 0; 
i < numIndexes; 
i++) {
 
  927         out << 
"class iterator_" << 
i << 
" : public std::iterator<std::forward_iterator_tag, t_tuple> {\n";
 
  928         out << 
"    using nested_iterator = typename t_ind_" << 
i << 
"::iterator;\n";
 
  929         out << 
"    nested_iterator nested;\n";
 
  930         out << 
"    t_tuple value;\n";
 
  933         out << 
"    iterator_" << 
i << 
"() = default;\n";
 
  934         out << 
"    iterator_" << 
i << 
"(const nested_iterator& iter) : nested(iter), value(orderOut_" << 
i 
  936         out << 
"    iterator_" << 
i << 
"(const iterator_" << 
i << 
"& other) = default;\n";
 
  937         out << 
"    iterator_" << 
i << 
"& operator=(const iterator_" << 
i << 
"& other) = default;\n";
 
  939         out << 
"    bool operator==(const iterator_" << 
i << 
"& other) const {\n";
 
  940         out << 
"        return nested == other.nested;\n";
 
  943         out << 
"    bool operator!=(const iterator_" << 
i << 
"& other) const {\n";
 
  944         out << 
"        return !(*this == other);\n";
 
  947         out << 
"    const t_tuple& operator*() const {\n";
 
  948         out << 
"        return value;\n";
 
  951         out << 
"    const t_tuple* operator->() const {\n";
 
  952         out << 
"        return &value;\n";
 
  955         out << 
"    iterator_" << 
i << 
"& operator++() {\n";
 
  956         out << 
"        ++nested;\n";
 
  957         out << 
"        value = orderOut_" << 
i << 
"(*nested);\n";
 
  958         out << 
"        return *this;\n";
 
  962     out << 
"using iterator = iterator_" << masterIndex << 
";\n";
 
  965     out << 
"struct context {\n";
 
  966     for (
size_t i = 0; 
i < numIndexes; 
i++) {
 
  967         out << 
"t_ind_" << 
i << 
"::op_context hints_" << 
i << 
";\n";
 
  970     out << 
"context createContext() { return context(); }\n";
 
  973     out << 
"bool insert(const t_tuple& t) {\n";
 
  974     out << 
"context h;\n";
 
  975     out << 
"return insert(t, h);\n";
 
  978     out << 
"bool insert(const t_tuple& t, context& h) {\n";
 
  979     out << 
"if (ind_" << masterIndex << 
".insert(orderIn_" << masterIndex << 
"(t), h.hints_" << masterIndex
 
  981     for (
size_t i = 0; 
i < numIndexes; 
i++) {
 
  982         if (
i != masterIndex) {
 
  983             out << 
"ind_" << 
i << 
".insert(orderIn_" << 
i << 
"(t), h.hints_" << 
i << 
");\n";
 
  986     out << 
"return true;\n";
 
  987     out << 
"} else return false;\n";
 
  990     out << 
"bool insert(const RamDomain* ramDomain) {\n";
 
  991     out << 
"RamDomain data[" << 
arity << 
"];\n";
 
  992     out << 
"std::copy(ramDomain, ramDomain + " << 
arity << 
", data);\n";
 
  993     out << 
"const t_tuple& tuple = reinterpret_cast<const t_tuple&>(data);\n";
 
  994     out << 
"context h;\n";
 
  995     out << 
"return insert(tuple, h);\n";
 
  999     std::vector<std::string> decls;
 
 1000     std::vector<std::string> params;
 
 1001     for (
size_t i = 0; 
i < 
arity; 
i++) {
 
 1002         decls.push_back(
"RamDomain a" + std::to_string(
i));
 
 1003         params.push_back(
"a" + std::to_string(
i));
 
 1005     out << 
"bool insert(" << 
join(decls, 
",") << 
") {\nRamDomain data[";
 
 1006     out << 
arity << 
"] = {" << 
join(params, 
",") << 
"};\n";
 
 1007     out << 
"return insert(data);\n";
 
 1011     out << 
"bool contains(const t_tuple& t, context& h) const {\n";
 
 1012     out << 
"return ind_" << masterIndex << 
".contains(orderIn_" << masterIndex << 
"(t), h.hints_" 
 1013         << masterIndex << 
");\n";
 
 1016     out << 
"bool contains(const t_tuple& t) const {\n";
 
 1017     out << 
"context h;\n";
 
 1018     out << 
"return contains(t, h);\n";
 
 1022     out << 
"std::size_t size() const {\n";
 
 1023     out << 
"return ind_" << masterIndex << 
".size();\n";
 
 1028         out << 
"iterator find(const t_tuple& t, context& h) const {\n";
 
 1029         out << 
"return ind_" << masterIndex << 
".find(orderIn_" << masterIndex << 
"(t), h.hints_" 
 1030             << masterIndex << 
");\n";
 
 1033         out << 
"iterator find(const t_tuple& t) const {\n";
 
 1034         out << 
"context h;\n";
 
 1035         out << 
"return find(t, h);\n";
 
 1040     out << 
"range<iterator> lowerUpperRange_0(const t_tuple& lower, const t_tuple& upper, context& h) const " 
 1042     out << 
"return range<iterator>(ind_" << masterIndex << 
".begin(),ind_" << masterIndex << 
".end());\n";
 
 1045     out << 
"range<iterator> lowerUpperRange_0(const t_tuple& lower, const t_tuple& upper) const {\n";
 
 1046     out << 
"return range<iterator>(ind_" << masterIndex << 
".begin(),ind_" << masterIndex << 
".end());\n";
 
 1050     for (
auto search : getMinIndexSelection().getSearches()) {
 
 1051         auto& lexOrder = getMinIndexSelection().getLexOrder(search);
 
 1052         size_t indNum = indexToNumMap[lexOrder];
 
 1054         out << 
"range<iterator_" << indNum << 
"> lowerUpperRange_" << search;
 
 1055         out << 
"(const t_tuple& lower, const t_tuple& upper, context& h) const {\n";
 
 1059         for (
size_t i = 0; 
i < 
arity; 
i++) {
 
 1060             if (search[
i] != analysis::AttributeConstraint::None) {
 
 1065         out << 
"auto r = ind_" << indNum << 
".template getBoundaries<" << indSize << 
">(orderIn_" << indNum
 
 1066             << 
"(lower), h.hints_" << indNum << 
");\n";
 
 1067         out << 
"return make_range(iterator_" << indNum << 
"(r.begin()), iterator_" << indNum
 
 1071         out << 
"range<iterator_" << indNum << 
"> lowerUpperRange_" << search;
 
 1072         out << 
"(const t_tuple& lower, const t_tuple& upper) const {\n";
 
 1073         out << 
"context h; return lowerUpperRange_" << search << 
"(lower,upper, h);\n";
 
 1078     out << 
"bool empty() const {\n";
 
 1079     out << 
"return ind_" << masterIndex << 
".empty();\n";
 
 1083     out << 
"std::vector<range<iterator>> partition() const {\n";
 
 1084     out << 
"std::vector<range<iterator>> res;\n";
 
 1085     out << 
"for (const auto& cur : ind_" << masterIndex << 
".partition(10000)) {\n";
 
 1086     out << 
"    res.push_back(make_range(iterator(cur.begin()), iterator(cur.end())));\n";
 
 1088     out << 
"return res;\n";
 
 1092     out << 
"void purge() {\n";
 
 1093     for (
size_t i = 0; 
i < numIndexes; 
i++) {
 
 1094         out << 
"ind_" << 
i << 
".clear();\n";
 
 1099     out << 
"iterator begin() const {\n";
 
 1100     out << 
"return iterator_" << masterIndex << 
"(ind_" << masterIndex << 
".begin());\n";
 
 1103     out << 
"iterator end() const {\n";
 
 1104     out << 
"return iterator_" << masterIndex << 
"(ind_" << masterIndex << 
".end());\n";
 
 1108     out << 
"void printStatistics(std::ostream& o) const {\n";
 
 1109     for (
size_t i = 0; 
i < numIndexes; 
i++) {
 
 1110         out << 
"o << \" arity " << 
arity << 
" brie index " << 
i << 
" lex-order " << inds[
i] << 
"\\n\";\n";
 
 1112         out << 
"ind_" << 
i << 
".printStats(o);\n";
 
 1117     for (
size_t i = 0; 
i < numIndexes; 
i++) {
 
 1119         out << 
"static t_tuple orderIn_" << 
i << 
"(const t_tuple& t) {\n";
 
 1120         out << 
"t_tuple res;\n";
 
 1121         for (
size_t j = 0; 
j < ind.size(); 
j++) {
 
 1122             out << 
"res[" << 
j << 
"] = t[" << ind[
j] << 
"];\n";
 
 1124         out << 
"return res;\n";
 
 1127         out << 
"static t_tuple orderOut_" << 
i << 
"(const t_tuple& t) {\n";
 
 1128         out << 
"t_tuple res;\n";
 
 1129         for (
size_t j = 0; 
j < ind.size(); 
j++) {
 
 1130             out << 
"res[" << ind[
j] << 
"] = t[" << 
j << 
"];\n";
 
 1132         out << 
"return res;\n";
 
 
References i, j, souffle::join(), and TCB_SPAN_NAMESPACE_NAME::detail::size().
 
 
◆ getTypeName()
  
  | 
        
          | std::string souffle::synthesiser::BrieRelation::getTypeName | ( |  | ) |  |  | override | 
 
Generate type name of a brie relation. 
Definition at line 880 of file Relation.cpp.
  882     std::unordered_set<uint32_t> attributesUsed;
 
  883     for (
auto& ind : getIndices()) {
 
  884         for (
auto& attr : ind) {
 
  885             attributesUsed.insert(attr);
 
  889     std::stringstream res;
 
  890     res << 
"t_brie_" << getTypeAttributeString(
relation.getAttributeTypes(), attributesUsed);
 
  892     for (
auto& ind : getIndices()) {
 
  893         res << 
"__" << 
join(ind, 
"_");
 
  896     for (
auto& search : getMinIndexSelection().getSearches()) {
 
  897         res << 
"__" << search;
 
 
References souffle::join(), and relation.
 
 
The documentation for this class was generated from the following files:
 
Relation(std::string name, size_t arity, size_t auxiliaryArity, std::vector< std::string > attributeNames, std::vector< std::string > attributeTypes, RelationRepresentation representation)
detail::joined_sequence< Iter, Printer > join(const Iter &a, const Iter &b, const std::string &sep, const Printer &p)
Creates an object to be forwarded to some output stream for printing sequences of elements interspers...