souffle
2.0.2-371-g6315b36
|
Go to the documentation of this file.
27 #include <initializer_list>
74 virtual uint32_t
getId()
const {
158 std::unique_ptr<iterator_base>
iter =
nullptr;
208 iter.reset(
o.iter->clone());
266 return (
iter ==
o.iter) || (*
iter == *
o.iter);
278 return !(*
this ==
o);
319 virtual std::size_t
size()
const = 0;
326 virtual std::string
getName()
const = 0;
407 std::string signature =
"<" + std::string(
getAttrType(0));
422 virtual void purge() = 0;
446 std::vector<RamDomain>
array;
509 assert(
array.size() <= std::numeric_limits<Relation::arity_type>::max());
560 assert(
pos <
size() &&
"exceeded tuple's size");
574 assert(
pos <
size() &&
"exceeded tuple's size");
576 "wrong element type");
589 assert(
pos <
size() &&
"exceeded tuple's size");
603 assert(
pos <
size() &&
"exceeded tuple's size");
617 assert(
pos <
size() &&
"exceeded tuple's size");
631 assert(
pos <
size() &&
"exceeded tuple's size");
633 "wrong element type");
634 integer = ramBitCast<RamSigned>(
array[
pos++]);
646 assert(
pos <
size() &&
"exceeded tuple's size");
648 uint = ramBitCast<RamUnsigned>(
array[
pos++]);
660 assert(
pos <
size() &&
"exceeded tuple's size");
662 ramFloat = ramBitCast<RamFloat>(
array[
pos++]);
672 return array.begin();
680 assert(tupleList.size() ==
relation->
getArity() &&
"tuple arity does not match relation arity");
742 if (!isInput && !isOutput) {
747 [[deprecated(
"pass `rel` by reference; `rel` may not be null"), maybe_unused]]
void addRelation(
748 const std::string& name, Relation*
rel,
bool isInput,
bool isOutput) {
749 assert(
rel &&
"`rel` may not be null");
764 virtual void run() {}
773 virtual void runAll(std::string inputDirectory =
"", std::string outputDirectory =
"") = 0;
781 virtual void loadAll(std::string inputDirectory =
"") = 0;
789 virtual void printAll(std::string outputDirectory =
"") = 0;
805 this->numThreads = numThreadsValue;
898 std::vector<RamDomain>& ) {
899 fatal(
"unknown subroutine");
948 template <
typename Tuple,
size_t N>
960 template <
typename Tuple>
963 t1 << std::get<0>(t);
974 template <
typename... Args>
989 template <
typename... Args>
1041 static std::map<std::string, ProgramFactory*> factoryReg;
1053 assert(!entry &&
"double-linked/defined souffle analyis");
1067 auto pos = reg.find(factoryName);
1068 return (pos == reg.end()) ? nullptr : pos->second;
1093 if (factory !=
nullptr) {
ProgramFactory * link
Singly linked-list to store all program factories Note that STL data-structures are not possible due ...
bool contains(const std::tuple< Args... > &t, Relation *relation)
Contains function with std::tuple as input (wrapper)
virtual ~SouffleProgram()=default
Destructor.
Wrapper class for abstract iterator.
void purgeOutputRelations()
Remove all the tuples from the outputRelations, calling the purge method of each.
virtual ~iterator_base()=default
Destructor.
virtual iterator_base * clone() const =0
Clone the iterator_base.
std::vector< Relation * > getInternalRelations() const
Getter of internalRelations, which this vector structure contains all relations that are neither an i...
virtual SouffleProgram * newInstance()=0
Create new instance (abstract).
virtual const char * getAttrType(size_t) const =0
Get the attribute type of a relation at the column specified by the parameter.
tuple(const Relation *r)
Constructor.
virtual void runAll(std::string inputDirectory="", std::string outputDirectory="")=0
Execute program, loading inputs and storing outputs as required.
const std::string & resolve(const RamDomain index) const
Find a symbol in the table by its index, note that this gives an error if the index is out of bounds.
std::string name
The name of factory.
iterator & operator++()
Overload the "++" operator.
static ProgramFactory * find(const std::string &factoryName)
Find a factory by its name, return the fatory if found, return nullptr if the factory not found.
tuple & operator<<(const std::string &str)
Set the "current element" of the tuple to the given string, then increment the index giving the curre...
A functor representing the identity function for a generic type T.
static void registerFactory(ProgramFactory *factory)
Create and insert a factory into the factoryReg map.
const Relation & relation
The relation to which the tuple belongs.
bool operator!=(const iterator &o) const
Overload the "!=" operator.
iterator()=default
Constructor.
void setNumThreads(std::size_t numThreadsValue)
Set the number of threads to be used.
std::vector< Relation * > outputRelations
outputRelations stores all the output relation in a vector.
virtual void insert(const tuple &t)=0
Insert a new tuple into the relation.
virtual bool equal(const iterator_base &o) const =0
Check if the passed-in object of o is the the same as the current iterator_base.
std::size_t getRelationSize(const std::string &name) const
Return the size of the target relation from relationMap.
size_t pos
pos shows what the current position of a tuple is.
virtual bool contains(const tuple &t) const =0
Check whether a tuple exists in a relation.
virtual ~ProgramFactory()=default
Destructor.
tuple & operator*() const
Overload the "*" operator.
RamDomain lookup(const std::string &symbol)
Find the index of a symbol in the table, inserting a new symbol if it does not exist there already.
Object-oriented wrapper class for Souffle's templatized relations.
virtual void printAll(std::string outputDirectory="")=0
Store all output relations.
auto clone(const std::vector< A * > &xs)
Abstract base class for generated Datalog programs.
const Relation & getRelation() const
Get the reference to the relation to which the tuple belongs.
virtual void run()
Execute the souffle program, without any loads or stores.
std::vector< Relation * > allRelations
allRelations store all the relation in a vector.
virtual RecordTable & getRecordTable()=0
Get the record table of the program.
static std::map< std::string, ProgramFactory * > & getFactoryRegistry()
Helper method for creating a factory map, which map key is the name of the program factory,...
const RamDomain * data
Allows printing using WriteStream.
virtual tuple & operator*()=0
Overload the "*" operator.
arity_type getPrimaryArity() const
Return the number of non-auxiliary attributes.
std::vector< Relation * > internalRelations
internalRelation stores all the relation in a vector that are neither an input or an output.
std::vector< Relation * > getOutputRelations() const
Getter of outputRelations, which this vector structure contains all output relations.
virtual void dumpOutputs()=0
Output all the output relations in stdout, without generating any files.
std::string getRelationName(const std::string &name) const
Return the name of the target relation from relationMap.
std::size_t numThreads
The number of threads used by OpenMP.
constexpr auto get(span< E, S > s) -> decltype(s[N])
std::vector< Relation * > getInputRelations() const
Getter of inputRelations, which this vector structure contains all input relations.
bool operator==(const iterator_base &o) const
Overload the "==" operator.
~iterator()=default
Destructor.
static void add(const Tuple &t, souffle::tuple &t1)
void addRelation(const std::string &name, Relation &rel, bool isInput, bool isOutput)
Add the relation to relationMap (with its name) and allRelations, depends on the properties of the re...
virtual void operator++()=0
Overload the "++" operator.
std::vector< Relation * > getAllRelations() const
Getter of allRelations, which this vector structure contains all relations.
iterator & operator=(const iterator &o)
Overload the "=" operator.
virtual iterator end() const =0
Return an iterator pointing to next to the last tuple of the relation.
virtual ~Relation()=default
Destructor.
void insert(const std::tuple< Args... > &t, Relation *relation)
Insert function with std::tuple as input (wrapper)
std::string getSignature()
Get the signature of a relation.
virtual void dumpInputs()=0
Output all the input relations in stdout, without generating any files.
virtual std::string getName() const =0
Get the name of a relation.
virtual iterator begin() const =0
Return an iterator pointing to the first tuple of the relation.
std::map< std::string, Relation * > relationMap
Define a relation map for external access, when getRelation(name) is called, the relation with the gi...
Relation::arity_type size() const
Return the number of elements in the tuple.
virtual arity_type getAuxiliaryArity() const =0
Return the number of auxiliary attributes.
virtual std::size_t size() const =0
Get the number of tuples in a relation.
virtual void purge()=0
Delete all the tuples in relation.
virtual void executeSubroutine(std::string, const std::vector< RamDomain > &, std::vector< RamDomain > &)
Execute a subroutine.
iterator_base(uint32_t arg_id)
Constructor.
RamDomain & operator[](size_t idx)
Overload the operator [].
Relation * getRelation(const std::string &name) const
Get Relation by its name from relationMap, if relation not found, return a nullptr.
Abstract program factory class.
std::vector< Relation * > inputRelations
inputRelations stores all the input relation in a vector.
std::unique_ptr< iterator_base > iter
virtual arity_type getArity() const =0
Return the arity of a relation.
tuple & operator>>(std::string &str)
Get the "current element" of the tuple as a string, then increment the index giving the current eleme...
void fatal(const char *format, const Args &... args)
virtual void loadAll(std::string inputDirectory="")=0
Read all input relations.
To ramBitCast(From source)
In C++20 there will be a new way to cast between types by reinterpreting bits (std::bit_cast),...
void rewind()
Reset the index giving the "current element" of the tuple to zero.
void purgeInputRelations()
Remove all the tuples from the inputRelations, calling the purge method of each.
std::vector< RamDomain > array
Dynamic array used to store the elements in a tuple.
bool operator==(const iterator &o) const
Overload the "==" operator.
uint32_t id
Required for identifying type of iterator (NB: LLVM has no typeinfo).
void rel(size_t limit, bool showLimit=true)
virtual const char * getAttrName(size_t) const =0
Get the attribute name of a relation at the column specified by the parameter.
Defines a tuple for the OO interface such that relations with varying columns can be accessed.
Helper function for the wrapper function Relation::insert() and Relation::contains().
decltype(array) ::iterator begin()
Iterator for direct access to tuple's data.
virtual uint32_t getId() const
Get the ID of the iterator_base object.
virtual SymbolTable & getSymbolTable() const =0
Get the symbol table of a relation.
void purgeInternalRelations()
Remove all the tuples from the internalRelations, calling the purge method of each.
std::size_t getNumThreads()
Get the number of threads to be used.
virtual SymbolTable & getSymbolTable()=0
Get the symbol table of the program.
ProgramFactory(std::string name)
Constructor.