souffle
2.0.2-371-g6315b36
|
#include <Index.h>
@Brief computes the minimal index cover for a relation in a RAM Program.
If the indexes of a relation can cover several searches, the minimal set of indexes is computed by Dilworth's problem. See
"Automatic Index Selection for Large-Scale Datalog Computation" http://www.vldb.org/pvldb/vol12/p141-subotic.pdf
Definition at line 208 of file Index.h.
◆ AttributeIndex
◆ AttributeSet
◆ Chain
◆ ChainOrderMap
◆ DischargeMap
◆ IndexSignatureMap
◆ LexOrder
◆ OrderCollection
◆ SearchSet
◆ SignatureIndexMap
◆ SignatureMap
◆ MinIndexSelection()
souffle::ram::analysis::MinIndexSelection::MinIndexSelection |
( |
| ) |
|
|
default |
◆ ~MinIndexSelection()
souffle::ram::analysis::MinIndexSelection::~MinIndexSelection |
( |
| ) |
|
|
default |
◆ addSearch()
void souffle::ram::analysis::MinIndexSelection::addSearch |
( |
SearchSignature |
cols | ) |
|
|
inline |
◆ card()
static size_t souffle::ram::analysis::MinIndexSelection::card |
( |
SearchSignature |
cols | ) |
|
|
inlinestaticprotected |
◆ getAllChains()
const ChainOrderMap souffle::ram::analysis::MinIndexSelection::getAllChains |
( |
| ) |
const |
|
inline |
◆ getAllOrders()
const OrderCollection souffle::ram::analysis::MinIndexSelection::getAllOrders |
( |
| ) |
const |
|
inline |
◆ getAttributesToDischarge()
Return the attribute position for each indexed operation that should be discharged.
Definition at line 443 of file Index.cpp.
450 return allInequalities;
455 return allInequalities;
461 for (
size_t i = 0;
i < s.arity(); ++
i) {
463 interpreterAttributesToDischarge.insert(
i);
468 return interpreterAttributesToDischarge;
475 relAnalysis = translationUnit.getAnalysis<RelationAnalysis>();
◆ getChain()
@Brief get a chain from a matching
- Parameters
-
Starting | node of a chain |
Matching | |
- Returns
- A minimal chain given an unmapped node from set A we follow it from set B until it cannot be matched from B if not matched from B then umn is a chain.
Definition at line 348 of file Index.cpp.
354 if (std::find(chain.begin(), chain.end(), start) == chain.end()) {
355 chain.push_back(start);
358 if (mit == match.end()) {
359 std::reverse(chain.begin(), chain.end());
364 if (std::find(chain.begin(), chain.end(), a) == chain.end()) {
373 assert(!nodes.empty());
References indexToSignature, and signatureToIndexB.
◆ getChainsFromMatching()
@Brief get all chains from the matching
Definition at line 377 of file Index.cpp.
379 for (
auto node : nodes) {
387 assert(!umKeys.empty());
393 for (
auto umKey : umKeys) {
405 for (
size_t i = 0;
i < delta.arity(); ++
i) {
References chainToOrder.
◆ getLexOrder()
◆ getLexOrderNum()
int souffle::ram::analysis::MinIndexSelection::getLexOrderNum |
( |
SearchSignature |
cols | ) |
const |
|
inline |
@Brief Get index for a search
Definition at line 258 of file Index.h.
References map().
◆ getSearches()
const SearchSet& souffle::ram::analysis::MinIndexSelection::getSearches |
( |
| ) |
const |
|
inline |
◆ getUnmatchedKeys()
@Brief get all nodes which are unmatched from A-> B
Definition at line 396 of file Index.h.
400 for (
auto node : nodes) {
402 unmatched.insert(node);
References signatureToIndexA.
◆ insertDefaultTotalIndex()
void souffle::ram::analysis::MinIndexSelection::insertDefaultTotalIndex |
( |
size_t |
arity | ) |
|
|
inline |
◆ insertIndex()
◆ isSubset()
bool souffle::ram::analysis::MinIndexSelection::isSubset |
( |
SearchSignature |
cols | ) |
const |
|
inline |
Check whether number of constraints in k is not equal to number of columns in lexicographical order.
Definition at line 276 of file Index.h.
References card(), map(), and orders.
◆ map()
int souffle::ram::analysis::MinIndexSelection::map |
( |
SearchSignature |
cols | ) |
const |
|
inlineprotected |
◆ print()
void souffle::ram::analysis::MinIndexSelection::print |
( |
std::ostream & |
os | ) |
|
|
inline |
◆ removeExtraInequalities()
void souffle::ram::analysis::MinIndexSelection::removeExtraInequalities |
( |
| ) |
|
|
protected |
@Brief remove arbitrary extra inequalities
Definition at line 426 of file Index.cpp.
429 seenInequality =
true;
438 const SearchSignature& s,
const Relation&
rel) {
441 for (
size_t i = 0;
i < s.arity(); ++
i) {
References i, and souffle::ram::analysis::None.
◆ solve()
void souffle::ram::analysis::MinIndexSelection::solve |
( |
| ) |
|
@Brief map the keys in the key set to lexicographical order
Definition at line 263 of file Index.cpp.
303 assert(!chains.empty());
304 for (
const auto& chain : chains) {
305 std::vector<uint32_t> ids;
307 SearchSignature initDelta = *(chain.begin());
311 for (
auto iit = chain.begin(); next(iit) != chain.end(); ++iit) {
316 assert(!ids.empty());
321 for (
auto chain : chains) {
322 for (
auto search : chain) {
323 int idx =
map(search);
324 size_t l =
card(search);
326 SearchSignature
k(search.arity());
327 for (
size_t i = 0;
i <
l;
i++) {
330 for (
size_t i = 0;
i < search.arity(); ++
i) {
332 assert(
"incorrect lexicographical order");
335 assert(
"incorrect lexicographical order");
344 SearchSignature start = umn;
◆ updateSearch()
- Parameters
-
OldSearch | to be updated |
NewSearch | to replace the OldSearch |
Definition at line 409 of file Index.cpp.
412 for (
auto& search : chain) {
413 if (search == oldSearch) {
422 auto newSearch = oldSearch;
423 bool seenInequality =
false;
424 for (
size_t i = 0;
i < oldSearch.arity(); ++
i) {
◆ chainToOrder
ChainOrderMap souffle::ram::analysis::MinIndexSelection::chainToOrder |
|
protected |
◆ dischargedMap
DischargeMap souffle::ram::analysis::MinIndexSelection::dischargedMap |
|
protected |
◆ indexToSignature
◆ matching
MaxMatching souffle::ram::analysis::MinIndexSelection::matching |
|
protected |
◆ orders
◆ searches
SearchSet souffle::ram::analysis::MinIndexSelection::searches |
|
protected |
◆ signatureToIndexA
◆ signatureToIndexB
The documentation for this class was generated from the following files:
const Matchings & solve()
@Brief solve the maximum matching problem
std::vector< SearchSignature > Chain
void insertIndex(LexOrder &ids, SearchSignature delta)
@Brief insert an index based on the delta
void updateSearch(SearchSignature oldSearch, SearchSignature newSearch)
int map(SearchSignature cols) const
@Brief maps search columns to an lexicographical order (labeled by a number)
std::set< SearchSignature, SearchComparator > SearchSet
std::unordered_map< Node, Node > Matchings
Matching represent a solution of the matching, i.e., which node in the bi-partite graph maps to anoth...
std::unordered_set< AttributeIndex > AttributeSet
std::vector< AttributeIndex > LexOrder
void run(const TranslationUnit &translationUnit) override
Run analysis for a RAM translation unit.
void removeExtraInequalities()
@Brief remove arbitrary extra inequalities
std::list< Chain > ChainOrderMap
const ChainOrderMap getAllChains() const
@Brief Get all chains
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...
const ChainOrderMap getChainsFromMatching(const MaxMatching::Matchings &match, const SearchSet &nodes)
@Brief get all chains from the matching
IndexSignatureMap indexToSignature
static size_t card(SearchSignature cols)
@Brief count the number of constraints in key
DischargeMap dischargedMap
ChainOrderMap chainToOrder
SignatureIndexMap signatureToIndexB
SignatureIndexMap signatureToIndexA
static SearchSignature getFullSearchSignature(size_t arity)
static MainConfig & config()
AttributeSet getAttributesToDischarge(const SearchSignature &s, const Relation &rel)
Return the attribute position for each indexed operation that should be discharged.
static SearchSignature getDelta(const SearchSignature &lhs, const SearchSignature &rhs)
void fatal(const char *format, const Args &... args)
const OrderCollection getAllOrders() const
@Brief Get all indexes
void addEdge(Node u, Node v)
@Brief add an edge to the bi-partite graph
const SearchSet & getSearches() const
@Brief Get searches
Chain getChain(const SearchSignature umn, const MaxMatching::Matchings &match)
@Brief get a chain from a matching
void rel(size_t limit, bool showLimit=true)