souffle
2.0.2-371-g6315b36
|
Go to the documentation of this file.
61 void push_back(std::pair<size_t, size_t> idx) {
66 bool verify(
const std::vector<tuple>& product)
const {
77 const std::pair<size_t, size_t>&
getFirstIdx()
const {
82 const std::vector<std::pair<size_t, size_t>>&
getIndices()
const {
102 std::vector<std::pair<size_t, size_t>>
indices;
120 bool verify(
const std::vector<tuple>& product)
const {
122 return product[constr.first.first][constr.first.second] == constr.second;
140 inline std::vector<std::string>
split(
const std::string& s,
char delim,
int times = -1) {
141 std::vector<std::string> v;
142 std::stringstream
ss(s);
145 while ((
times > 0 ||
times <= -1) && std::getline(
ss, item, delim)) {
150 if (
ss.peek() != EOF) {
151 std::string remainder;
152 std::getline(
ss, remainder);
153 v.push_back(remainder);
159 class ExplainProvenance {
164 virtual void setup() = 0;
171 std::string relName, std::vector<std::string> args,
size_t ruleNum) = 0;
174 const std::vector<std::string>&
tuple, std::map<std::string, std::string>& bodyVariables) = 0;
176 virtual std::string
getRule(std::string relName,
size_t ruleNum) = 0;
178 virtual std::vector<std::string>
getRules(
const std::string& relName) = 0;
188 virtual void queryProcess(
const std::vector<std::pair<std::string, std::vector<std::string>>>& rels) = 0;
195 const std::string& relName,
const std::vector<std::string>& args)
const {
196 std::vector<RamDomain> nums;
199 if (
rel ==
nullptr) {
203 for (
size_t i = 0;
i < args.size();
i++) {
214 const std::string& relName,
const std::vector<RamDomain>& nums)
const {
215 std::vector<std::string> args;
218 if (
rel ==
nullptr) {
222 for (
size_t i = 0;
i < nums.size();
i++) {
231 case 'i':
return tfm::format(
"%d", ramBitCast<RamSigned>(value));
232 case 'u':
return tfm::format(
"%d", ramBitCast<RamUnsigned>(value));
233 case 'f':
return tfm::format(
"%f", ramBitCast<RamFloat>(value));
236 default:
fatal(
"unhandled type attr code");
246 assert(2 <= value.size() && value[0] ==
'"' && value.back() ==
'"');
248 case 'r':
fatal(
"not implemented");
249 default:
fatal(
"unhandled type attr code");
virtual Own< TreeNode > explainNegation(std::string relName, size_t ruleNum, const std::vector< std::string > &tuple, std::map< std::string, std::string > &bodyVariables)=0
RamSigned RamSignedFromString(const std::string &str, std::size_t *position=nullptr, const int base=10)
Converts a string to a RamSigned.
virtual std::string measureRelation(std::string relName)=0
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.
bool verify(const std::vector< tuple > &product) const
Verify if the query product satisfies constant constraint.
const std::pair< size_t, size_t > & getFirstIdx() const
Extract index of the first occurrence of the varible.
const std::string & getSymbol() const
Get the symbol of variable.
ConstConstraint()=default
Constructor.
Constant constraints for values in query command.
virtual Own< TreeNode > explainSubproof(std::string relName, RamDomain label, size_t depthLimit)=0
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.
Equivalence & operator=(const Equivalence &o)=default
Copy assignment operator.
Abstract base class for generated Datalog programs.
const std::vector< std::pair< size_t, size_t > > & getIndices() const
Get indices of equivalent variables.
detail::multiplying_printer< T > times(const T &value, unsigned num)
A utility printing a given value multiple times.
std::string valueShow(const char type, const RamDomain value) const
Equivalence(char t, std::string s, std::pair< size_t, size_t > idx)
Constructor for Equvialence class.
virtual void queryProcess(const std::vector< std::pair< std::string, std::vector< std::string >>> &rels)=0
Process query with given arguments.
virtual ~ExplainProvenance()=default
RamDomain valueRead(const char type, const std::string &value) const
std::vector< RamDomain > argsToNums(const std::string &relName, const std::vector< std::string > &args) const
std::vector< std::pair< std::pair< size_t, size_t >, RamDomain > > & getConstraints()
Get the constant constraint vector.
std::vector< std::string > split(const std::string &s, char delim, int times=-1)
utility function to split a string
virtual std::string getRule(std::string relName, size_t ruleNum)=0
Equivalence class for variables in query command.
~ConstConstraint()=default
Destructor.
void push_back(std::pair< size_t, size_t > idx)
Add index at the end of indices vector.
std::vector< std::string > decodeArguments(const std::string &relName, const std::vector< RamDomain > &nums) const
Decode arguments from their ram representation and return as strings.
virtual void printRulesJSON(std::ostream &os)=0
virtual Own< TreeNode > explain(std::string relName, std::vector< std::string > tuple, size_t depthLimit)=0
bool all_of(const Container &c, UnaryPredicate p)
A generic test checking whether all elements within a container satisfy a certain predicate.
Relation * getRelation(const std::string &name) const
Get Relation by its name from relationMap, if relation not found, return a nullptr.
ExplainProvenance(SouffleProgram &prog)
void push_back(std::pair< std::pair< size_t, size_t >, RamDomain > constr)
Add constant constraint at the end of constConstrs vector.
virtual std::vector< std::string > getRules(const std::string &relName)=0
bool verify(const std::vector< tuple > &product) const
Verify if elements at the indices are equivalent in the given product.
virtual std::vector< std::string > explainNegationGetVariables(std::string relName, std::vector< std::string > args, size_t ruleNum)=0
void fatal(const char *format, const Args &... args)
std::vector< std::pair< std::pair< size_t, size_t >, RamDomain > > constConstrs
RamUnsigned RamUnsignedFromString(const std::string &str, std::size_t *position=nullptr, const int base=10)
Converts a string to a RamUnsigned.
To ramBitCast(From source)
In C++20 there will be a new way to cast between types by reinterpreting bits (std::bit_cast),...
char getType() const
Get type of the variable of the equivalence class, 'i' for RamSigned, 's' for symbol 'u' for RamUnsig...
std::vector< std::pair< size_t, size_t > > indices
RamFloat RamFloatFromString(const std::string &str, std::size_t *position=nullptr)
Converts a string to a RamFloat.
~Equivalence()=default
Destructor.
void rel(size_t limit, bool showLimit=true)
Defines a tuple for the OO interface such that relations with varying columns can be accessed.
class souffle::profile::Tui ss