souffle
2.0.2-371-g6315b36
|
Go to the documentation of this file.
101 #include <unordered_map>
112 class NodeGenerator :
public ram::Visitor<Own<Node>> {
250 template <
class RamNode>
258 template <
class RamNode>
262 size_t mapOrder(
size_t tupleId,
size_t elementId)
const;
281 template <
class RamNode>
291 size_t getArity(
const std::string& relName);
329 std::unordered_map<const ram::Node*, size_t>
indexTable;
339 std::unordered_map<const ram::Node*, size_t>
viewTable;
341 std::unordered_map<std::string, size_t>
relTable;
343 std::unordered_map<std::string, const ram::Relation*>
relationMap;
Breaks out of the loop if a condition holds.
NodePtr visitLogRelationTimer(const ram::LogRelationTimer &timer) override
size_t mapOrder(size_t tupleId, size_t elementId) const
Map the decoded order of elementId based on current context.
NodePtr visitConstraint(const ram::Constraint &relOp) override
constexpr auto size(const C &c) -> decltype(c.size())
NodePtr visitParallelIndexAggregate(const ram::ParallelIndexAggregate &piAggregate) override
NodePtr visitExtend(const ram::Extend &extend) override
Increment a counter and return its value.
NodePtr visitIndexScan(const ram::IndexScan &iScan) override
size_t relId
Next available location to encode a relation.
Operator that represents an extrinsic (user-defined) functor.
void newQueryBlock()
Reset view allocation system, since view's life time is within each query.
RelationHandle * getRelationHandle(const size_t idx)
Search for tuples of a relation matching a criteria.
std::unordered_map< std::string, const ram::Relation * > relationMap
name / relation mapping
NodePtr visitParallelIndexChoice(const ram::ParallelIndexChoice &piChoice) override
size_t getArity(const std::string &relName)
get arity of relation
Swap operation with respect to two relations.
NodePtr visitScan(const ram::Scan &scan) override
A relational algebra query.
Own< RelationWrapper > RelationHandle
NodePtr visitSubroutineReturn(const ram::SubroutineReturn &ret) override
Packs a record's arguments into a reference.
NodePtr visitQuery(const ram::Query &query) override
NodePtr visitParallelAggregate(const ram::ParallelAggregate &pAggregate) override
NodePtr visitParallelIndexScan(const ram::ParallelIndexScan &piscan) override
NodePtr visitSequence(const ram::Sequence &seq) override
NodePtr visitAggregate(const ram::Aggregate &aggregate) override
NodePtr visitTupleOperation(const ram::TupleOperation &search) override
NodePtr visitProject(const ram::Project &project) override
Execute statement until statement terminates loop via an exit statement.
void addNewTuple(size_t tupleId, size_t arity)
Bind tuple with a natural full order.
NodePtr visitSwap(const ram::Swap &swap) override
Exit statement for a loop.
NodePtr visitBreak(const ram::Break &breakOp) override
std::unordered_map< std::string, size_t > relTable
Environment encoding, store a mapping from ram::Relation to its id.
Use an index to find a tuple in a relation such that a given condition holds in parallel.
Parallel block of statements.
Extend equivalence relation.
NodePtr visitTrue(const ram::True <rue) override
std::unordered_map< const ram::Node *, size_t > viewTable
Environment encoding, store a mapping from ram::Node to its View id.
NodePtr visitFalse(const ram::False &lfalse) override
std::unordered_map< const ram::Node *, size_t > indexTable
Environment encoding, store a mapping from ram::Node to its operation index id.
NodePtr visitExit(const ram::Exit &exit) override
NodePtr visitIndexAggregate(const ram::IndexAggregate &iAggregate) override
Execution time logger for a statement.
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.
Existence check for a tuple(-pattern) in a relation.
Access element from the current tuple in a tuple environment.
NodePtr visitTupleElement(const ram::TupleElement &access) override
An order to be enforced for storing tuples within indexes.
std::vector< Order > tupleOrders
std::shared_ptr< ViewContext > parentQueryViewContext
Points to the current viewContext during the generation.
Checks whether a given condition holds.
A conjunction of conditions.
Provenance Existence check for a relation.
NodePtr visitConstant(const ram::Constant &num) override
NodeGenerator & generator
NodePtr visitExistenceCheck(const ram::ExistenceCheck &exists) override
Node is a superclass for all RAM IR classes.
size_t getNewRelId()
Get a valid relation id for encoding.
NodePtr visitSubroutineArgument(const ram::SubroutineArgument &arg) override
SuperInstruction getExistenceSuperInstInfo(const ram::AbstractExistenceCheck &abstractExist)
Encode and return the super-instruction information about an existence check operation.
Project a result into the target relation.
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.
NodePtr visitIndexChoice(const ram::IndexChoice &iChoice) override
NodePtr visitPackRecord(const ram::PackRecord &pr) override
bool requireView(const ram::Node *node)
Return true if the given operation requires a view.
Delete tuples of a relation.
Aggregate over values of a relation using an index in parallel.
An abstract class for performing indexed operations.
NodePtr visitIntrinsicOperator(const ram::IntrinsicOperator &op) override
Abstract existence check for a tuple in a relation.
Abstract class for a nesting operations in a loop-nest.
NodeGenerator(Engine &engine)
NodePtr visitCall(const ram::Call &call) override
NodePtr visitConjunction(const ram::Conjunction &conj) override
Aggregation function applied on some relation.
This class translate the RAM Program into executable format and interpreter it.
Parallel Aggregation function applied on some relation.
NodePtr visitIO(const ram::IO &io) override
Use an index to find a tuple in a relation such that a given condition holds.
Indexed aggregation on a relation. The index allows us to iterate over a restricted range.
NodePtr visitNestedOperation(const ram::NestedOperation &nested) override
NodePtr visitParallel(const ram::Parallel ¶llel) override
Iterate all tuples of a relation in parallel.
Represents a Ram Constant.
Emptiness check for a relation.
I/O statement for a relation.
NodePtr visitUndefValue(const ram::UndefValue &) override
NodePtr visitNode(const ram::Node &node) override
size_t encodeView(const ram::Node *node)
Encode and return the View id of an operation.
NodePtr visitUserDefinedOperator(const ram::UserDefinedOperator &op) override
NodePtr visitLoop(const ram::Loop &loop) override
size_t getNextViewId()
Get a valid view id for encoding.
NodePtr visitNegation(const ram::Negation &neg) override
Abstract class for relation searches and lookups.
std::vector< NodePtr > NodePtrVec
This class help generator reordering tuple access based on the index oder.
Find a tuple in a relation such that a given condition holds.
Iterate all tuples of a relation.
Search for tuples of a relation matching a criteria.
Operator that represents an intrinsic (built-in) functor.
void insertOrder(size_t tupleId, const Order &order)
NodePtr visitParallelChoice(const ram::ParallelChoice &pChoice) override
NodePtr visitAutoIncrement(const ram::AutoIncrement &inc) override
This class encodes information for a super-instruction, which is used to eliminate Number and TupleEl...
Evaluates a binary constraint with respect to two Expressions.
Negates a given condition.
NodePtr generateTree(const ram::Node &root)
Generate the tree based on given entry.
OrderingContext(NodeGenerator &generator)
NodePtr visitDebugInfo(const ram::DebugInfo &dbg) override
NodePtr visitUnpackRecord(const ram::UnpackRecord &unpack) override
NodePtr visitNestedIntrinsicOperator(const ram::NestedIntrinsicOperator &op) override
NodePtr visitProvenanceExistenceCheck(const ram::ProvenanceExistenceCheck &provExists) override
NodePtr visitClear(const ram::Clear &clear) override
size_t encodeRelation(const std::string &relName)
Encode and create the relation, return the relation id.
NodePtr visitParallelScan(const ram::ParallelScan &pScan) override
NodePtr visitLogSize(const ram::LogSize &size) override
Effectively identical to IntrinsicOperator, except it can produce multiple results.
NodePtr visitLogTimer(const ram::LogTimer &timer) override
Engine & engine
Reference to the engine instance.
Access argument of a subroutine.
NodePtr visitRelationSize(const ram::RelationSize &size) override
A statement for returning from a ram subroutine.
Returns the numbers of tuples in a relation.
Log relation size and a logging message.
const std::string & getViewRelation(const ram::Node *node)
Return the associated relation of a operation which requires a view.
size_t viewId
Next available location to encode View.
Sequence of RAM statements.
NodePtr visitChoice(const ram::Choice &choice) override
OrderingContext orderingContext
ordering context
NodePtr visitFilter(const ram::Filter &filter) override
Execution time logger for a statement.
Find a tuple in a relation such that a given condition holds in parallel.
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.
NodePtr visitEmptinessCheck(const ram::EmptinessCheck &emptiness) override