| souffle
    2.0.2-371-g6315b36
    | 
 
 
 
#include <Generator.h>
|  | 
|  | LINK (AbstractConditional, NestedOperation) | 
|  | 
|  | LINK (AbstractExistenceCheck, Condition) | 
|  | 
|  | LINK (AbstractOperator, Expression) | 
|  | 
|  | LINK (Aggregate, RelationOperation) | 
|  | 
|  | LINK (AutoIncrement, Expression) | 
|  | 
|  | LINK (BinRelationStatement, Statement) | 
|  | 
|  | LINK (Break, AbstractConditional) | 
|  | 
|  | LINK (Call, Statement) | 
|  | 
|  | LINK (Choice, RelationOperation) | 
|  | 
|  | LINK (Clear, RelationStatement) | 
|  | 
|  | LINK (Condition, Node) | 
|  | 
|  | LINK (Conjunction, Condition) | 
|  | 
|  | LINK (Constant, Expression) | 
|  | 
|  | LINK (Constraint, Condition) | 
|  | 
|  | LINK (DebugInfo, Statement) | 
|  | 
|  | LINK (EmptinessCheck, Condition) | 
|  | 
|  | LINK (ExistenceCheck, AbstractExistenceCheck) | 
|  | 
|  | LINK (Exit, Statement) | 
|  | 
|  | LINK (Expression, Node) | 
|  | 
|  | LINK (Extend, BinRelationStatement) | 
|  | 
|  | LINK (False, Condition) | 
|  | 
|  | LINK (Filter, AbstractConditional) | 
|  | 
|  | LINK (FloatConstant, Constant) | 
|  | 
|  | LINK (IndexAggregate, IndexOperation) | 
|  | 
|  | LINK (IndexChoice, IndexOperation) | 
|  | 
|  | LINK (IndexOperation, RelationOperation) | 
|  | 
|  | LINK (IndexScan, IndexOperation) | 
|  | 
|  | LINK (IntrinsicOperator, AbstractOperator) | 
|  | 
|  | LINK (IO, RelationStatement) | 
|  | 
|  | LINK (ListStatement, Statement) | 
|  | 
|  | LINK (LogRelationTimer, Statement) | 
|  | 
|  | LINK (LogSize, RelationStatement) | 
|  | 
|  | LINK (LogTimer, Statement) | 
|  | 
|  | LINK (Loop, Statement) | 
|  | 
|  | LINK (Negation, Condition) | 
|  | 
|  | LINK (NestedOperation, Operation) | 
|  | 
|  | LINK (Operation, Node) | 
|  | 
|  | LINK (PackRecord, Expression) | 
|  | 
|  | LINK (Parallel, ListStatement) | 
|  | 
|  | LINK (ParallelAggregate, Aggregate) | 
|  | 
|  | LINK (ParallelChoice, Choice) | 
|  | 
|  | LINK (ParallelIndexAggregate, IndexAggregate) | 
|  | 
|  | LINK (ParallelIndexChoice, IndexChoice) | 
|  | 
|  | LINK (ParallelIndexScan, IndexScan) | 
|  | 
|  | LINK (ParallelScan, Scan) | 
|  | 
|  | LINK (Program, Node) | 
|  | 
|  | LINK (Project, Operation) | 
|  | 
|  | LINK (ProvenanceExistenceCheck, AbstractExistenceCheck) | 
|  | 
|  | LINK (Query, Statement) | 
|  | 
|  | LINK (Relation, Node) | 
|  | 
|  | LINK (RelationOperation, TupleOperation) | 
|  | 
|  | LINK (RelationSize, Expression) | 
|  | 
|  | LINK (RelationStatement, Statement) | 
|  | 
|  | LINK (Scan, RelationOperation) | 
|  | 
|  | LINK (Sequence, ListStatement) | 
|  | 
|  | LINK (SignedConstant, Constant) | 
|  | 
|  | LINK (Statement, Node) | 
|  | 
|  | LINK (SubroutineArgument, Expression) | 
|  | 
|  | LINK (SubroutineReturn, Operation) | 
|  | 
|  | LINK (Swap, BinRelationStatement) | 
|  | 
|  | LINK (True, Condition) | 
|  | 
|  | LINK (TupleElement, Expression) | 
|  | 
|  | LINK (TupleOperation, NestedOperation) | 
|  | 
|  | LINK (UndefValue, Expression) | 
|  | 
|  | LINK (UnpackRecord, TupleOperation) | 
|  | 
|  | LINK (UnsignedConstant, Constant) | 
|  | 
|  | LINK (UserDefinedOperator, AbstractOperator) | 
|  | 
| virtual Own< Node > | visitNode (const Node &, Params...) | 
|  | The base case for all visitors – if no more specific overload was defined.  More... 
 | 
|  | 
Definition at line 119 of file Generator.h.
 
◆ NodePtr
◆ NodePtrVec
◆ RelationHandle
◆ NodeGenerator()
      
        
          | souffle::interpreter::NodeGenerator::NodeGenerator | ( | Engine & | engine | ) |  | 
      
 
Definition at line 30 of file Generator.cpp.
   35         if (isA<ram::Query>(&node)) {
 
 
 
 
◆ encodeIndexPos()
template<class RamNode > 
  
  | 
        
          | size_t souffle::interpreter::NodeGenerator::encodeIndexPos | ( | RamNode & | node | ) |  |  | private | 
 
 
◆ encodeRelation()
  
  | 
        
          | size_t souffle::interpreter::NodeGenerator::encodeRelation | ( | const std::string & | relName | ) |  |  | private | 
 
Encode and create the relation, return the relation id. 
Definition at line 531 of file Generator.cpp.
 
 
◆ encodeView()
  
  | 
        
          | size_t souffle::interpreter::NodeGenerator::encodeView | ( | const ram::Node * | node | ) |  |  | private | 
 
Encode and return the View id of an operation. 
Definition at line 510 of file Generator.cpp.
  517     assert(it != 
relationMap.end() && 
"relation not found");
 
 
 
 
◆ generateTree()
      
        
          | NodePtr souffle::interpreter::NodeGenerator::generateTree | ( | const ram::Node & | root | ) |  | 
      
 
Generate the tree based on given entry. 
Return a NodePtr to the root. 
Definition at line 37 of file Generator.cpp.
   41         } 
else if (
const auto* exists = 
dynamic_cast<const ram::ExistenceCheck*
>(&node)) {
 
   44         } 
else if (
const auto* provExists = 
dynamic_cast<const ram::ProvenanceExistenceCheck*
>(&node)) {
 
   54     return mk<Constant>(I_Constant, &num);
 
 
 
 
◆ getArity()
  
  | 
        
          | size_t souffle::interpreter::NodeGenerator::getArity | ( | const std::string & | relName | ) |  |  | private | 
 
 
◆ getExistenceSuperInstInfo()
Encode and return the super-instruction information about an existence check operation. 
Definition at line 634 of file Generator.cpp.
  635         indexId = 
encodeIndexPos(*
dynamic_cast<const ram::ProvenanceExistenceCheck*
>(&abstractExist));
 
  637         fatal(
"Unrecognized ram::AbstractExistenceCheck.");
 
  640     size_t arity = 
getArity(abstractExist.getRelation());
 
  641     SuperInstruction superOp(arity);
 
  642     const auto& children = abstractExist.getValues();
 
  643     for (
size_t i = 0; 
i < arity; ++
i) {
 
  644         auto& child = children[order[
i]];
 
  654         if (isA<ram::Constant>(child)) {
 
  655             superOp.first[
i] = 
dynamic_cast<ram::Constant*
>(child)->getConstant();
 
  656             superOp.second[
i] = superOp.first[
i];
 
  661         if (isA<ram::TupleElement>(child)) {
 
  662             auto tuple = 
dynamic_cast<ram::TupleElement*
>(child);
 
  663             size_t tupleId = tuple->getTupleId();
 
  664             size_t elementId = tuple->getElement();
 
  666             superOp.tupleFirst.push_back({
i, tupleId, newElementId});
 
  671         superOp.exprFirst.push_back(std::pair<
size_t, Own<Node>>(
i, 
visit(child)));
 
  677     size_t arity = 
getArity(exist.getRelation());
 
  678     SuperInstruction superOp(arity);
 
  679     const auto& children = exist.getValues();
 
 
 
 
◆ getIndexSuperInstInfo()
Encode and return the super-instruction information about a index operation. 
Definition at line 565 of file Generator.cpp.
  570         auto& 
low = first[order[
i]];
 
  579         if (isA<ram::Constant>(
low)) {
 
  580             indexOperation.first[
i] = 
dynamic_cast<ram::Constant*
>(
low)->getConstant();
 
  585         if (isA<ram::TupleElement>(
low)) {
 
  586             auto lowTuple = 
dynamic_cast<ram::TupleElement*
>(
low);
 
  587             size_t tupleId = lowTuple->getTupleId();
 
  588             size_t elementId = lowTuple->getElement();
 
  590             indexOperation.tupleFirst.push_back({
i, tupleId, newElementId});
 
  595         indexOperation.exprFirst.push_back(std::pair<
size_t, Own<Node>>(
i, 
visit(
low)));
 
  597     const auto& second = ramIndex.getRangePattern().second;
 
  598     for (
size_t i = 0; 
i < arity; ++
i) {
 
  599         auto& hig = second[order[
i]];
 
  608         if (isA<ram::Constant>(hig)) {
 
  609             indexOperation.second[
i] = 
dynamic_cast<ram::Constant*
>(hig)->getConstant();
 
  614         if (isA<ram::TupleElement>(hig)) {
 
  615             auto highTuple = 
dynamic_cast<ram::TupleElement*
>(hig);
 
  616             size_t tupleId = highTuple->getTupleId();
 
  617             size_t elementId = highTuple->getElement();
 
  619             indexOperation.tupleSecond.push_back({
i, tupleId, newElementId});
 
  624         indexOperation.exprSecond.push_back(std::pair<
size_t, Own<Node>>(
i, 
visit(hig)));
 
  626     return indexOperation;
 
  630     auto interpreterRel = 
encodeRelation(abstractExist.getRelation());
 
  632     if (isA<ram::ExistenceCheck>(&abstractExist)) {
 
 
 
 
◆ getNewRelId()
  
  | 
        
          | size_t souffle::interpreter::NodeGenerator::getNewRelId | ( |  | ) |  |  | private | 
 
Get a valid relation id for encoding. 
Definition at line 488 of file Generator.cpp.
 
 
◆ getNextViewId()
  
  | 
        
          | size_t souffle::interpreter::NodeGenerator::getNextViewId | ( |  | ) |  |  | private | 
 
Get a valid view id for encoding. 
Definition at line 492 of file Generator.cpp.
  493     const std::string& name = node.getRelation();
 
 
 
 
◆ getProjectSuperInstInfo()
Encode and return the super-instruction information about a project operation. 
No reordering needed for projection as project can have more then one target indexes and reordering can only be done during runtime. 
Definition at line 681 of file Generator.cpp.
  684             superOp.first[
i] = 
dynamic_cast<ram::Constant*
>(child)->getConstant();
 
  689         if (isA<ram::TupleElement>(child)) {
 
  690             auto tuple = 
dynamic_cast<ram::TupleElement*
>(child);
 
  691             size_t tupleId = tuple->getTupleId();
 
  692             size_t elementId = tuple->getElement();
 
  694             superOp.tupleFirst.push_back({
i, tupleId, newElementId});
 
  699         superOp.exprFirst.push_back(std::pair<
size_t, Own<Node>>(
i, 
visit(child)));
 
 
References souffle::interpreter::SuperInstruction::first, and i.
 
 
◆ getRelationHandle()
  
  | 
        
          | RelationHandle * souffle::interpreter::NodeGenerator::getRelationHandle | ( | const size_t | idx | ) |  |  | private | 
 
Definition at line 542 of file Generator.cpp.
  544     } 
else if (isA<ram::IndexOperation>(node)) {
 
 
 
 
◆ getViewRelation()
  
  | 
        
          | const std::string & souffle::interpreter::NodeGenerator::getViewRelation | ( | const ram::Node * | node | ) |  |  | private | 
 
Return the associated relation of a operation which requires a view. 
This function assume the operation does requires a view. 
Definition at line 555 of file Generator.cpp.
  561     size_t arity = 
getArity(ramIndex.getRelation());
 
 
 
 
◆ lookup()
  
  | 
        
          | const ram::Relation & souffle::interpreter::NodeGenerator::lookup | ( | const std::string & | relName | ) |  |  | private | 
 
 
◆ newQueryBlock()
  
  | 
        
          | void souffle::interpreter::NodeGenerator::newQueryBlock | ( |  | ) |  |  | private | 
 
Reset view allocation system, since view's life time is within each query. 
Definition at line 483 of file Generator.cpp.
 
 
◆ requireView()
  
  | 
        
          | bool souffle::interpreter::NodeGenerator::requireView | ( | const ram::Node * | node | ) |  |  | private | 
 
Return true if the given operation requires a view. 
Definition at line 546 of file Generator.cpp.
  551     if (
const auto* exist = 
dynamic_cast<const ram::AbstractExistenceCheck*
>(node)) {
 
  552         return exist->getRelation();
 
  553     } 
else if (
const auto* index = 
dynamic_cast<const ram::IndexOperation*
>(node)) {
 
 
 
 
◆ visitAggregate()
◆ visitAutoIncrement()
Definition at line 69 of file Generator.cpp.
   70                          : op.getArguments()) {
 
   71         children.push_back(
visit(arg));
 
 
 
◆ visitBreak()
  
  | 
        
          | NodePtr souffle::interpreter::NodeGenerator::visitBreak | ( | const ram::Break & | breakOp | ) |  |  | override | 
 
 
◆ visitCall()
  
  | 
        
          | NodePtr souffle::interpreter::NodeGenerator::visitCall | ( | const ram::Call & | call | ) |  |  | override | 
 
Definition at line 373 of file Generator.cpp.
  382     return mk<LogRelationTimer>(I_LogRelationTimer, &timer, 
visit(timer.getStatement()), 
rel);
 
 
 
 
◆ visitChoice()
◆ visitClear()
◆ visitConjunction()
◆ visitConstant()
◆ visitConstraint()
◆ visitDebugInfo()
◆ visitEmptinessCheck()
◆ visitExistenceCheck()
Definition at line 143 of file Generator.cpp.
  147     auto ramRelation = 
lookup(exists.getRelation());
 
  149     return mk<ExistenceCheck>(
type, &exists, isTotal, 
encodeView(&exists), std::move(superOp),
 
  150             ramRelation.isTemp(), ramRelation.getName());
 
  156     return mk<ProvenanceExistenceCheck>(
type, &provExists, 
visit(provExists.getChildNodes().back()),
 
 
 
 
◆ visitExit()
  
  | 
        
          | NodePtr souffle::interpreter::NodeGenerator::visitExit | ( | const ram::Exit & | exit | ) |  |  | override | 
 
 
◆ visitExtend()
◆ visitFalse()
◆ visitFilter()
◆ visitIndexAggregate()
◆ visitIndexChoice()
◆ visitIndexScan()
◆ visitIntrinsicOperator()
Definition at line 73 of file Generator.cpp.
   78     for (
const auto& arg : op.getArguments()) {
 
   79         children.push_back(
visit(arg));
 
 
 
 
◆ visitIO()
  
  | 
        
          | NodePtr souffle::interpreter::NodeGenerator::visitIO | ( | const ram::IO & | io | ) |  |  | override | 
 
Definition at line 411 of file Generator.cpp.
  413     std::shared_ptr<ViewContext> viewContext = std::make_shared<ViewContext>();
 
 
 
 
◆ visitLogRelationTimer()
◆ visitLogSize()
◆ visitLogTimer()
◆ visitLoop()
  
  | 
        
          | NodePtr souffle::interpreter::NodeGenerator::visitLoop | ( | const ram::Loop & | loop | ) |  |  | override | 
 
 
◆ visitNegation()
◆ visitNestedIntrinsicOperator()
Definition at line 89 of file Generator.cpp.
   97     for (
const auto& arg : pr.getArguments()) {
 
   98         children.push_back(
visit(arg));
 
 
 
 
◆ visitNestedOperation()
◆ visitNode()
  
  | 
        
          | NodePtr souffle::interpreter::NodeGenerator::visitNode | ( | const ram::Node & | node | ) |  |  | override | 
 
 
◆ visitPackRecord()
Definition at line 100 of file Generator.cpp.
  104     return mk<SubroutineArgument>(I_SubroutineArgument, &arg);
 
 
 
 
◆ visitParallel()
◆ visitParallelAggregate()
◆ visitParallelChoice()
◆ visitParallelIndexAggregate()
Definition at line 308 of file Generator.cpp.
  320     return mk<Break>(I_Break, &breakOp, 
visit(breakOp.getCondition()), 
visit(breakOp.getOperation()));
 
 
 
 
◆ visitParallelIndexChoice()
◆ visitParallelIndexScan()
◆ visitParallelScan()
◆ visitProject()
Definition at line 332 of file Generator.cpp.
  337     for (
const auto& value : ret.getValues()) {
 
  338         children.push_back(
visit(value));
 
 
 
 
◆ visitProvenanceExistenceCheck()
Definition at line 158 of file Generator.cpp.
  161     return mk<Constraint>(I_Constraint, &relOp, 
visit(relOp.getLHS()), 
visit(relOp.getRHS()));
 
 
 
 
◆ visitQuery()
◆ visitRelationSize()
◆ visitScan()
  
  | 
        
          | NodePtr souffle::interpreter::NodeGenerator::visitScan | ( | const ram::Scan & | scan | ) |  |  | override | 
 
 
◆ visitSequence()
Definition at line 348 of file Generator.cpp.
  354     for (
const auto& value : parallel.getStatements()) {
 
 
 
 
◆ visitSubroutineArgument()
Definition at line 108 of file Generator.cpp.
  109     return mk<True>(I_True, <rue);
 
 
 
 
◆ visitSubroutineReturn()
Definition at line 340 of file Generator.cpp.
  345     for (
const auto& value : seq.getStatements()) {
 
  346         children.push_back(
visit(value));
 
 
 
 
◆ visitSwap()
  
  | 
        
          | NodePtr souffle::interpreter::NodeGenerator::visitSwap | ( | const ram::Swap & | swap | ) |  |  | override | 
 
 
◆ visitTrue()
  
  | 
        
          | NodePtr souffle::interpreter::NodeGenerator::visitTrue | ( | const ram::True & | ltrue | ) |  |  | override | 
 
 
◆ visitTupleElement()
Definition at line 62 of file Generator.cpp.
   65     return mk<AutoIncrement>(I_AutoIncrement, &inc);
 
 
 
 
◆ visitTupleOperation()
◆ visitUndefValue()
◆ visitUnpackRecord()
◆ visitUserDefinedOperator()
Definition at line 81 of file Generator.cpp.
   85     auto arity = op.getArguments().size();
 
 
 
 
◆ engine
  
  | 
        
          | Engine& souffle::interpreter::NodeGenerator::engine |  | private | 
 
Reference to the engine instance. 
Definition at line 354 of file Generator.h.
 
 
◆ indexTable
  
  | 
        
          | std::unordered_map<const ram::Node*, size_t> souffle::interpreter::NodeGenerator::indexTable |  | private | 
 
Environment encoding, store a mapping from ram::Node to its operation index id. 
Definition at line 336 of file Generator.h.
 
 
◆ orderingContext
◆ parentQueryViewContext
  
  | 
        
          | std::shared_ptr<ViewContext> souffle::interpreter::NodeGenerator::parentQueryViewContext = nullptr |  | private | 
 
Points to the current viewContext during the generation. 
It is used to passing viewContext between parent query and its nested parallel operation. As parallel operation requires its own view information. 
Definition at line 340 of file Generator.h.
 
 
◆ relationMap
  
  | 
        
          | std::unordered_map<std::string, const ram::Relation*> souffle::interpreter::NodeGenerator::relationMap |  | private | 
 
 
◆ relId
  
  | 
        
          | size_t souffle::interpreter::NodeGenerator::relId = 0 |  | private | 
 
Next available location to encode a relation. 
Definition at line 344 of file Generator.h.
 
 
◆ relTable
  
  | 
        
          | std::unordered_map<std::string, size_t> souffle::interpreter::NodeGenerator::relTable |  | private | 
 
 
◆ viewId
  
  | 
        
          | size_t souffle::interpreter::NodeGenerator::viewId = 0 |  | private | 
 
Next available location to encode View. 
Definition at line 342 of file Generator.h.
 
 
◆ viewTable
  
  | 
        
          | std::unordered_map<const ram::Node*, size_t> souffle::interpreter::NodeGenerator::viewTable |  | private | 
 
 
The documentation for this class was generated from the following files:
 
size_t mapOrder(size_t tupleId, size_t elementId) const
Map the decoded order of elementId based on current context.
VecOwn< RelationHandle > relations
Symbol table for relations.
constexpr auto size(const C &c) -> decltype(c.size())
NodePtr visitExtend(const ram::Extend &extend) override
virtual Own< Node > visit(const Node &node, Params... args)
The main entry for a visit process conducting the dispatching of a visit to the various sub-types of ...
size_t relId
Next available location to encode a relation.
RelationHandle * getRelationHandle(const size_t idx)
std::unordered_map< std::string, const ram::Relation * > relationMap
name / relation mapping
size_t getArity(const std::string &relName)
get arity of relation
constexpr RamSigned MAX_RAM_SIGNED
bool isUndefValue(const Expression *expr)
Determines if an expression represents an undefined value.
NodePtr visitTupleOperation(const ram::TupleOperation &search) override
void addNewTuple(size_t tupleId, size_t arity)
Bind tuple with a natural full order.
std::unordered_map< std::string, size_t > relTable
Environment encoding, store a mapping from ram::Relation to its id.
std::unordered_map< const ram::Node *, size_t > viewTable
Environment encoding, store a mapping from ram::Node to its View id.
ram::analysis::IndexAnalysis * isa
IndexAnalysis.
std::unordered_map< const ram::Node *, size_t > indexTable
Environment encoding, store a mapping from ram::Node to its operation index id.
void addTupleWithDefaultOrder(size_t tupleId, const RamNode &node)
Bind tuple with the default order.
SuperInstruction getIndexSuperInstInfo(const ram::IndexOperation &ramIndex)
Encode and return the super-instruction information about a index operation.
std::vector< const ram::Condition * > findConjunctiveTerms(const ram::Condition *condition)
store terms of a conjunction in an array of pointers without cloning
std::shared_ptr< ViewContext > parentQueryViewContext
Points to the current viewContext during the generation.
NodePtr visitConstant(const ram::Constant &num) override
SuperInstruction getExistenceSuperInstInfo(const ram::AbstractExistenceCheck &abstractExist)
Encode and return the super-instruction information about an existence check operation.
std::vector< A > filter(std::vector< A > xs, F &&f)
Filter a vector to include certain elements.
const ram::Relation & lookup(const std::string &relName)
get arity of relation
void addTupleWithIndexOrder(size_t tupleId, const RamNode &node)
Bind tuple with the corresponding index order.
bool requireView(const ram::Node *node)
Return true if the given operation requires a view.
NodeGenerator(Engine &engine)
constexpr RamSigned MIN_RAM_SIGNED
lower and upper boundaries for the ram types
size_t encodeView(const ram::Node *node)
Encode and return the View id of an operation.
std::vector< NodePtr > NodePtrVec
NodeType constructNodeType(std::string tokBase, const ram::Relation &rel)
Construct interpreterNodeType by looking at the representation and the arity of the given rel.
static SearchSignature getFullSearchSignature(size_t arity)
OrderingContext(NodeGenerator &generator)
NodePtr visitProvenanceExistenceCheck(const ram::ProvenanceExistenceCheck &provExists) override
void fatal(const char *format, const Args &... args)
size_t encodeRelation(const std::string &relName)
Encode and create the relation, return the relation id.
void visitDepthFirst(const Node &root, Visitor< R, Ps... > &visitor, Args &... args)
A utility function visiting all nodes within the ast rooted by the given node recursively in a depth-...
Engine & engine
Reference to the engine instance.
MinIndexSelection & getIndexes(const std::string &relName)
@Brief get the minimal index cover for a relation
const std::string & getViewRelation(const ram::Node *node)
Return the associated relation of a operation which requires a view.
void rel(size_t limit, bool showLimit=true)
OrderingContext orderingContext
ordering context
SuperInstruction getProjectSuperInstInfo(const ram::Project &exist)
Encode and return the super-instruction information about a project operation.
size_t encodeIndexPos(RamNode &node)
Return operation index id from the result of indexAnalysis.