souffle  2.0.2-371-g6315b36
Namespaces | Data Structures | Typedefs | Enumerations | Functions | Variables
souffle Namespace Reference

Namespaces

 ast
 
 ast2ram
 
 detail
 
 evaluator
 
 gzfstream
 
 interpreter
 
 profile
 
 ram
 
 stream_write_qualified_char_as_number
 
 synthesiser
 Souffle - A Datalog Compiler Copyright (c) 2013, 2015, Oracle and/or its affiliates.
 
 test
 

Data Structures

class  BaseTable
 
class  btree_multiset
 A b-tree based multi-set implementation. More...
 
class  btree_set
 A b-tree based set implementation. More...
 
class  CacheAccessCounter
 cache hits/misses. More...
 
class  CmdOptions
 A utility class for parsing command line arguments within generated query programs. More...
 
struct  comp_deref
 A functor class supporting the values pointers are pointing to. More...
 
class  ConstConstraint
 Constant constraints for values in query command. More...
 
class  DebugReport
 Class representing a HTML report, consisting of a list of sections. More...
 
class  DebugReportSection
 Class representing a section of a HTML report. More...
 
struct  deref
 A functor dereferencing a given type. More...
 
struct  deref_less
 A functor comparing the dereferenced value of a pointer type utilizing a given comparator. More...
 
class  Diagnostic
 
class  DiagnosticMessage
 
class  DisjointSet
 Structure that emulates a Disjoint Set, i.e. More...
 
struct  EqrelMapComparator
 
class  Equivalence
 Equivalence class for variables in query command. More...
 
class  EquivalenceRelation
 
class  ErrorReport
 
class  Explain
 
class  ExplainConfig
 
class  ExplainProvenance
 
class  ExplainProvenanceImpl
 
class  Global
 
class  Graph
 A simple graph structure for graph-based operations. More...
 
struct  id
 A functor representing the identity function for a generic type T. More...
 
class  InnerNode
 
struct  IntrinsicFunctorInfo
 
class  IOSystem
 
struct  IsPtrLike
 
struct  IsPtrLike< Own< A > >
 
struct  IsPtrLike< std::shared_ptr< A > >
 
struct  IsPtrLike< std::weak_ptr< A > >
 
struct  IterDerefWrapper
 A wrapper for an iterator obtaining pointers of a certain type, dereferencing values before forwarding them to the consumer. More...
 
struct  lambda_traits
 A type trait enabling the deduction of type properties of lambdas. More...
 
class  LambdaBTreeSet
 A b-tree based set implementation. More...
 
class  LeafNode
 
struct  Lock
 A small utility class for implementing simple locks. More...
 
class  Logger
 The class utilized to times for the souffle profiling tool. More...
 
class  LogStatement
 
class  LRUCache
 An Least-Recently-Used cache for arbitrary element types. More...
 
class  LRUCache< T, 0 >
 
class  LRUCache< T, 1 >
 
class  MainConfig
 
struct  MainOption
 
class  OptimisticReadWriteLock
 A 'sequential' non-locking implementation for an optimistic r/w lock. More...
 
class  ParserDriver
 
class  PiggyList
 
struct  print_deref
 A functor printing elements after dereferencing it. More...
 
class  ProfileEventSingleton
 Profile Event Singleton. More...
 
class  ProgramFactory
 Abstract program factory class. More...
 
class  RandomInsertPiggyList
 A PiggyList that allows insertAt functionality. More...
 
struct  range
 A utility class enabling representation of ranges by pairing two iterator instances marking lower and upper boundaries. More...
 
class  ReadCinCSVFactory
 
class  ReadCinJSONFactory
 
class  ReadFileCSV
 
class  ReadFileCSVFactory
 
class  ReadFileJSON
 
class  ReadFileJSONFactory
 
class  ReadSQLiteFactory
 
class  ReadStream
 
class  ReadStreamCSV
 
class  ReadStreamFactory
 
class  ReadStreamJSON
 
class  ReadStreamSQLite
 
class  ReadWriteLock
 
class  RecordMap
 Bidirectional mappping between records and record references. More...
 
class  RecordTable
 
class  Relation
 Object-oriented wrapper class for Souffle's templatized relations. More...
 
class  RelationWrapper
 Relation wrapper used internally in the generated Datalog program. More...
 
struct  reverse
 Use to range-for iterate in reverse. More...
 
class  RuleBody
 
struct  scanner_data
 
class  ScreenBuffer
 
class  SerialisationStream
 
class  SignalHandler
 Class SignalHandler captures signals and reports the context where the signal occurs. More...
 
class  SingleValueIterator
 An iterator to be utilized if there is only a single element to iterate over. More...
 
class  SouffleProgram
 Abstract base class for generated Datalog programs. More...
 
class  SparseArray
 A sparse array simulates an array associating to every element of uint32_t an element of a generic type T. More...
 
class  SparseBitMap
 A sparse bit-map is a bit map virtually assigning a bit value to every value if the uint32_t domain. More...
 
class  SparseDisjointSet
 
class  SpinLock
 A 'sequential' non-locking implementation for a spin lock. More...
 
class  SrcLocation
 A class describing a range in an input file. More...
 
class  SymbolTable
 
class  t_info
 info relations More...
 
class  t_nullaries
 Nullary relations. More...
 
class  Table
 
class  TempFileStream
 
class  TreeNode
 
class  Trie
 
class  Trie< 1u >
 A template specialization for tries representing a set. More...
 
class  tuple
 Defines a tuple for the OO interface such that relations with varying columns can be accessed. More...
 
class  WriteCoutCSV
 
class  WriteCoutCSVFactory
 
class  WriteCoutJSON
 
class  WriteCoutJSONFactory
 
class  WriteCoutPrintSize
 
class  WriteCoutPrintSizeFactory
 
class  WriteFileCSV
 
class  WriteFileCSVFactory
 
class  WriteFileJSON
 
class  WriteFileJSONFactory
 
class  WriteSQLiteFactory
 
class  WriteStream
 
class  WriteStreamCSV
 
class  WriteStreamFactory
 
class  WriteStreamJSON
 
class  WriteStreamSQLite
 

Typedefs

using block_t = uint64_t
 
template<typename A , typename B >
using copy_const_t = std::conditional_t< std::is_const_v< A >, const B, B >
 
using IntrinsicFunctors = std::vector< std::reference_wrapper< const IntrinsicFunctorInfo > >
 
template<typename A >
using Own = std::unique_ptr< A >
 
using parent_t = uint64_t
 
using RamDomain = int32_t
 
using RamFloat = float
 
using RamSigned = RamDomain
 
using RamUnsigned = uint32_t
 
using rank_t = uint8_t
 
template<typename A , size_t E = tcb::dynamic_extent>
using span = tcb::span< A, E >
 
using time_point = std::chrono::high_resolution_clock::time_point
 
template<typename A , size_t N>
using Tuple = std::array< A, N >
 
template<typename A >
using VecOwn = std::vector< Own< A > >
 
using yyscan_t = void *
 

Enumerations

enum  AggregateOp {
  AggregateOp::MAX, AggregateOp::MIN, AggregateOp::SUM, AggregateOp::FMAX,
  AggregateOp::FMIN, AggregateOp::FSUM, AggregateOp::MEAN, AggregateOp::UMAX,
  AggregateOp::UMIN, AggregateOp::USUM, AggregateOp::COUNT
}
 Types of aggregation functions. More...
 
enum  BinaryConstraintOp {
  BinaryConstraintOp::EQ, BinaryConstraintOp::FEQ, BinaryConstraintOp::NE, BinaryConstraintOp::FNE,
  BinaryConstraintOp::LT, BinaryConstraintOp::ULT, BinaryConstraintOp::FLT, BinaryConstraintOp::SLT,
  BinaryConstraintOp::LE, BinaryConstraintOp::ULE, BinaryConstraintOp::FLE, BinaryConstraintOp::SLE,
  BinaryConstraintOp::GT, BinaryConstraintOp::UGT, BinaryConstraintOp::FGT, BinaryConstraintOp::SGT,
  BinaryConstraintOp::GE, BinaryConstraintOp::UGE, BinaryConstraintOp::FGE, BinaryConstraintOp::SGE,
  BinaryConstraintOp::MATCH, BinaryConstraintOp::CONTAINS, BinaryConstraintOp::NOT_MATCH, BinaryConstraintOp::NOT_CONTAINS
}
 Binary Constraint Operators. More...
 
enum  FunctorOp {
  FunctorOp::ORD, FunctorOp::STRLEN, FunctorOp::NEG, FunctorOp::FNEG,
  FunctorOp::BNOT, FunctorOp::UBNOT, FunctorOp::LNOT, FunctorOp::ULNOT,
  FunctorOp::F2I, FunctorOp::F2S, FunctorOp::F2U, FunctorOp::I2F,
  FunctorOp::I2S, FunctorOp::I2U, FunctorOp::S2F, FunctorOp::S2I,
  FunctorOp::S2U, FunctorOp::U2F, FunctorOp::U2I, FunctorOp::U2S,
  FunctorOp::ADD, FunctorOp::SUB, FunctorOp::MUL, FunctorOp::DIV,
  FunctorOp::EXP, FunctorOp::MAX, FunctorOp::MIN, FunctorOp::MOD,
  FunctorOp::BAND, FunctorOp::BOR, FunctorOp::BXOR, FunctorOp::BSHIFT_L,
  FunctorOp::BSHIFT_R, FunctorOp::BSHIFT_R_UNSIGNED, FunctorOp::LAND, FunctorOp::LOR,
  FunctorOp::LXOR, FunctorOp::UADD, FunctorOp::USUB, FunctorOp::UMUL,
  FunctorOp::UDIV, FunctorOp::UEXP, FunctorOp::UMAX, FunctorOp::UMIN,
  FunctorOp::UMOD, FunctorOp::UBAND, FunctorOp::UBOR, FunctorOp::UBXOR,
  FunctorOp::UBSHIFT_L, FunctorOp::UBSHIFT_R, FunctorOp::UBSHIFT_R_UNSIGNED, FunctorOp::ULAND,
  FunctorOp::ULOR, FunctorOp::ULXOR, FunctorOp::FADD, FunctorOp::FSUB,
  FunctorOp::FMUL, FunctorOp::FDIV, FunctorOp::FEXP, FunctorOp::FMAX,
  FunctorOp::FMIN, FunctorOp::SMAX, FunctorOp::SMIN, FunctorOp::RANGE,
  FunctorOp::URANGE, FunctorOp::FRANGE, FunctorOp::CAT, FunctorOp::SUBSTR
}
 
enum  RelationQualifier {
  RelationQualifier::INPUT, RelationQualifier::OUTPUT, RelationQualifier::PRINTSIZE, RelationQualifier::OVERRIDABLE,
  RelationQualifier::INLINE, RelationQualifier::MAGIC, RelationQualifier::SUPPRESSED
}
 Space of qualifiers that a relation can have. More...
 
enum  RelationRepresentation {
  RelationRepresentation::DEFAULT, RelationRepresentation::BRIE, RelationRepresentation::BTREE, RelationRepresentation::EQREL,
  RelationRepresentation::INFO
}
 Space of internal representations that a relation can have. More...
 
enum  RelationTag {
  RelationTag::INPUT, RelationTag::OUTPUT, RelationTag::PRINTSIZE, RelationTag::OVERRIDABLE,
  RelationTag::INLINE, RelationTag::MAGIC, RelationTag::SUPPRESSED, RelationTag::BRIE,
  RelationTag::BTREE, RelationTag::EQREL
}
 Space of user-chosen tags that a relation can have. More...
 
enum  TypeAttribute {
  TypeAttribute::Symbol, TypeAttribute::Signed, TypeAttribute::Unsigned, TypeAttribute::Float,
  TypeAttribute::Record, TypeAttribute::ADT
}
 

Functions

std::string absPath (const std::string &path)
 C++-style realpath. More...
 
std::pair< uint8_t, uint8_t > aggregateArity (AggregateOp op)
 
template<typename Container , typename UnaryPredicate >
bool all_of (const Container &c, UnaryPredicate p)
 A generic test checking whether all elements within a container satisfy a certain predicate. More...
 
template<typename Container , typename UnaryPredicate >
bool any_of (const Container &c, UnaryPredicate p)
 A generic test checking whether any elements within a container satisfy a certain predicate. More...
 
template<typename B , typename A >
std::enable_if_t< std::is_base_of_v< A, B >, copy_const_t< A, B > * > as (A &x)
 
template<typename B , typename A >
auto as (A *x)
 Helpers for dynamic_casting without having to specify redundant type qualifiers. More...
 
template<typename B , typename A >
B * as (const std::unique_ptr< A > &x)
 
std::string baseName (const std::string &filename)
 
bool canBeParsedAsRamFloat (const std::string &string)
 Can a string be parsed as RamFloat. More...
 
bool canBeParsedAsRamSigned (const std::string &string)
 Can a string be parsed as RamSigned. More...
 
bool canBeParsedAsRamUnsigned (const std::string &string)
 Can a string be parsed as RamUnsigned. More...
 
template<typename toType , typename baseType >
bool castEq (const baseType *left, const baseType *right)
 Cast the values, from baseType to toType and compare using ==. More...
 
template<typename A >
std::unique_ptr< A > clone (const A *node)
 
template<typename A , typename B >
auto clone (const std::pair< A, B > &p)
 
template<typename A >
std::unique_ptr< A > clone (const std::unique_ptr< A > &node)
 
template<typename A >
auto clone (const std::vector< A * > &xs)
 
template<typename A >
auto clone (const std::vector< std::unique_ptr< A >> &xs)
 
void compileToBinary (std::string compileCmd, const std::string &sourceFilename)
 Compiles the given source file to a binary file. More...
 
template<typename C >
bool contains (const C &container, const typename C::value_type &element)
 A utility to check generically whether a given element is contained in a given container. More...
 
template<typename C >
bool contains (const C &container, const typename C::value_type::first_type &element)
 Version of contains specialised for maps. More...
 
template<typename A >
bool contains (const std::set< A > &container, const A &element)
 
std::string convertDotToSVG (const std::string &dotSpec)
 
AggregateOp convertOverloadedAggregator (const AggregateOp op, const TypeAttribute type)
 Convert aggregator to a give type. More...
 
BinaryConstraintOp convertOverloadedConstraint (const BinaryConstraintOp constraintOp, const TypeAttribute toType)
 Convert Constraint to work with requested type. More...
 
BinaryConstraintOp convertStrictToNotEqualConstraint (const BinaryConstraintOp constraintOp)
 
BinaryConstraintOp convertStrictToWeakIneqConstraint (const BinaryConstraintOp constraintOp)
 
template<typename Iter >
IterDerefWrapper< Iter > derefIter (const Iter &iter)
 A factory function enabling the construction of a dereferencing iterator utilizing the automated deduction of template parameters. More...
 
std::string dirName (const std::string &name)
 C++-style dirname. More...
 
long duration_in_ns (const time_point &start, const time_point &end)
 
long duration_in_us (const time_point &start, const time_point &end)
 
bool endsWith (const std::string &value, const std::string &ending)
 Determines whether the given value string ends with the given end string. More...
 
template<typename T >
bool equal_ptr (const std::unique_ptr< T > &a, const std::unique_ptr< T > &b)
 Compares two values referenced by a pointer where the case where both pointers are null is also considered equivalent. More...
 
template<typename T >
bool equal_ptr (const T *a, const T *b)
 Compares two values referenced by a pointer where the case where both pointers are null is also considered equivalent. More...
 
template<typename Container , typename Comparator >
bool equal_targets (const Container &a, const Container &b, const Comparator &comp)
 A function testing whether two containers are equal with the given Comparator. More...
 
template<typename T , template< typename... > class Container>
bool equal_targets (const Container< std::unique_ptr< T >> &a, const Container< std::unique_ptr< T >> &b)
 A function testing whether two containers of unique pointers are referencing equivalent targets. More...
 
template<typename T , template< typename... > class Container>
bool equal_targets (const Container< T * > &a, const Container< T * > &b)
 A function testing whether two containers of pointers are referencing equivalent targets. More...
 
template<typename Key , typename Value >
bool equal_targets (const std::map< Key, std::unique_ptr< Value >> &a, const std::map< Key, std::unique_ptr< Value >> &b)
 A function testing whether two maps of unique pointers are referencing to equivalent targets. More...
 
std::string escape (const std::string &inputString)
 
std::string escape (const std::string &inputString, const std::string &needle, const std::string &replacement)
 
std::string escapeJSONstring (const std::string &JSONstr)
 Escape JSON string. More...
 
std::stringstream execStdOut (char const *cmd)
 
std::stringstream execStdOut (std::string const &cmd)
 
void executeBinary (const std::string &binaryFilename)
 Executes a binary file. More...
 
bool existDir (const std::string &name)
 Check whether a directory exists in the file system. More...
 
bool existFile (const std::string &name)
 Check whether a file exists in the file system. More...
 
void explain (SouffleProgram &prog, bool ncurses)
 
template<typename... Args>
void fatal (const char *format, const Args &... args)
 
std::string fileExtension (const std::string &path)
 File extension, with all else removed. More...
 
template<typename A , typename F >
std::vector< A > filter (std::vector< A > xs, F &&f)
 Filter a vector to include certain elements. More...
 
template<typename A , typename F >
std::vector< A > filterNot (std::vector< A > xs, F &&f)
 Filter a vector to exclude certain elements. More...
 
std::string findTool (const std::string &tool, const std::string &base, const std::string &path)
 
IntrinsicFunctors functorBuiltIn (FunctorOp op)
 
IntrinsicFunctors functorBuiltIn (std::string_view symbol)
 
IntrinsicFunctors functorBuiltIn (std::string_view symbol, const std::vector< TypeAttribute > &params)
 
std::stringstream & genJsonRules (std::stringstream &ss, const std::string &name, size_t maxRows)
 
std::stringstream & genJsonUsage (std::stringstream &ss)
 
std::vector< TypeAttributegetBinaryConstraintTypes (const BinaryConstraintOp op)
 Get type binary constraint operates on. More...
 
std::string getCurrentFilename (const std::vector< std::string > &filenames)
 
BinaryConstraintOp getEqConstraint (const std::string &type)
 
BinaryConstraintOp getGreaterEqualConstraint (const std::string &type)
 
BinaryConstraintOp getGreaterThanConstraint (const std::string &type)
 
template<typename C >
C::value_type getIf (const C &container, std::function< bool(const typename C::value_type)> pred)
 Returns the first element in a container that satisfies a given predicate, nullptr otherwise. More...
 
souffle::SouffleProgramgetInstance (const char *p)
 
BinaryConstraintOp getLessEqualConstraint (const std::string &type)
 
BinaryConstraintOp getLessThanConstraint (const std::string &type)
 
FunctorOp getMaxOp (const std::string &type)
 
FunctorOp getMinOp (const std::string &type)
 Given a type of an an attribute it returns the appropriate min/max functor operation. More...
 
template<typename C >
C::mapped_type const & getOr (const C &container, typename C::key_type key, const typename C::mapped_type &defaultValue)
 Get value for a given key; if not found, return default value. More...
 
LockgetOutputLock ()
 Obtains a reference to the lock synchronizing output operations. More...
 
RelationQualifier getRelationQualifierFromTag (const RelationTag &tag)
 Get the corresponding RelationQualifier for a valid RelationTag. More...
 
RelationRepresentation getRelationRepresentationFromTag (const RelationTag &tag)
 Get the corresponding RelationRepresentation for a valid RelationTag. More...
 
TypeAttribute getTypeAttributeAggregate (const AggregateOp op)
 Get return type of the aggregate. More...
 
std::string identifier (std::string id)
 Valid C++ identifier, note that this does not ensure the uniqueness of identifiers returned. More...
 
template<typename B , typename A >
std::enable_if_t< std::is_base_of_v< A, B >, bool > isA (A &x)
 
template<typename B , typename A >
bool isA (A *x)
 Checks if the object of type Source can be casted to type Destination. More...
 
template<typename B , typename A >
bool isA (const std::unique_ptr< A > &x)
 
bool isEqConstraint (const BinaryConstraintOp constraintOp)
 
bool isExecutable (const std::string &name)
 Check whether a given file exists and it is an executable. More...
 
bool isFunctorMultiResult (FunctorOp op)
 
bool isGreaterEqual (const BinaryConstraintOp constraintOp)
 
bool isGreaterThan (const BinaryConstraintOp constraintOp)
 
bool isInfixFunctorOp (const BinaryConstraintOp op)
 Determines whether a functor should be written using infix notation (e.g. More...
 
bool isInfixFunctorOp (const FunctorOp op)
 
bool isInfixFunctorOp (std::string_view symbol)
 Determines whether a functor should be written using infix notation (e.g. More...
 
bool isLessEqual (const BinaryConstraintOp constraintOp)
 
bool isLessThan (const BinaryConstraintOp constraintOp)
 
bool isNumber (const char *str)
 Check whether a string is a sequence of digits. More...
 
bool isOrderedBinaryConstraintOp (const BinaryConstraintOp op)
 Determines whether arguments of constraint are orderable. More...
 
bool isOverloaded (const BinaryConstraintOp constraintOp)
 Utility function, informing whether constraint is overloaded. More...
 
bool isOverloadedAggregator (const AggregateOp op)
 
bool isOverloadedFunctor (std::string_view symbol)
 Indicate whether a functor is overloaded. More...
 
bool isPrefix (const std::string &prefix, const std::string &element)
 Determine if one string is a prefix of another. More...
 
bool isRelationQualifierTag (const RelationTag &tag)
 Check if a given relation tag is a relation qualifier. More...
 
bool isRelationRepresentationTag (const RelationTag &tag)
 Check if a given relation tag sets a relation representation. More...
 
bool isStrictIneqConstraint (const BinaryConstraintOp constraintOp)
 
bool isValidFunctorOpArity (std::string_view symbol, size_t arity)
 
bool isWeakIneqConstraint (const BinaryConstraintOp constraintOp)
 
template<typename Container , typename Printer , typename Iter = typename Container::const_iterator>
detail::joined_sequence< Iter, Printer > join (const Container &c, const std::string &sep, const Printer &p)
 Creates an object to be forwarded to some output stream for printing the content of containers interspersed by a given separator. More...
 
template<typename Container , typename Iter = typename Container::const_iterator, typename T = typename std::iterator_traits<Iter>::value_type>
std::enable_if_t<!JoinShouldDeref< T >, detail::joined_sequence< Iter, detail::print< id< T > > > > join (const Container &c, const std::string &sep=",")
 Creates an object to be forwarded to some output stream for printing the content of containers interspersed by a given separator. More...
 
template<typename Container , typename Iter = typename Container::const_iterator, typename T = typename std::iterator_traits<Iter>::value_type>
std::enable_if_t< JoinShouldDeref< T >, detail::joined_sequence< Iter, detail::print< deref< T > > > > join (const Container &c, const std::string &sep=",")
 
template<typename Iter , typename Printer >
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 interspersed by a given separator. More...
 
template<typename Iter , typename T = typename Iter::value_type>
detail::joined_sequence< Iter, detail::print< id< T > > > join (const Iter &a, const Iter &b, const std::string &sep=",")
 Creates an object to be forwarded to some output stream for printing sequences of elements interspersed by a given separator. More...
 
int main (int argc, char **argv)
 
template<typename Iter >
range< Iter > make_range (const Iter &a, const Iter &b)
 A utility function enabling the construction of ranges without explicitly specifying the iterator type. More...
 
template<typename A , typename F >
auto map (const std::vector< A > &xs, F &&f)
 Applies a function to each element of a vector and returns the results. More...
 
template<typename A , typename B = A, typename... Args>
Own< A > mk (Args &&... xs)
 
BinaryConstraintOp negatedConstraintOp (const BinaryConstraintOp op)
 Negated Constraint Operator Each operator requires a negated operator which is necessary for the expansion of complex rule bodies with disjunction and negation. More...
 
template<typename Container , typename UnaryPredicate >
bool none_of (const Container &c, UnaryPredicate p)
 A generic test checking whether all elements within a container satisfy a certain predicate. More...
 
time_point now ()
 
std::ostream & operator<< (std::ostream &os, AggregateOp op)
 
std::ostream & operator<< (std::ostream &os, BinaryConstraintOp x)
 
std::ostream & operator<< (std::ostream &os, FunctorOp op)
 
std::ostream & operator<< (std::ostream &os, RelationQualifier qualifier)
 
std::ostream & operator<< (std::ostream &os, RelationRepresentation representation)
 
std::ostream & operator<< (std::ostream &os, RelationTag qualifier)
 
std::ostream & operator<< (std::ostream &os, TypeAttribute T)
 
template<typename T , unsigned size>
std::ostream & operator<< (std::ostream &out, const LRUCache< T, size > &cache)
 
std::ostream & operator<< (std::ostream &out, const RuleBody &body)
 
template<std::size_t Arity>
RamDomain pack (RecordTable &recordTab, span< const RamDomain, Arity > tuple)
 helper to convert tuple to record reference for the synthesiser More...
 
template<std::size_t Arity>
RamDomain pack (RecordTable &recordTab, Tuple< RamDomain, Arity > const &tuple)
 helper to convert tuple to record reference for the synthesiser More...
 
std::string pathJoin (const std::string &first, const std::string &second)
 Join two paths together; note that this does not resolve overlaps or relative paths. More...
 
void printHTMLGraph (std::ostream &out, const std::string &dotSpec, const std::string &id)
 
template<typename To = RamDomain, typename From >
To ramBitCast (From source)
 In C++20 there will be a new way to cast between types by reinterpreting bits (std::bit_cast), but as of January 2020 it is not yet supported. More...
 
RamFloat RamFloatFromString (const std::string &str, std::size_t *position=nullptr)
 Converts a string to a RamFloat. More...
 
RamSigned RamSignedFromString (const std::string &str, std::size_t *position=nullptr, const int base=10)
 Converts a string to a RamSigned. More...
 
RamUnsigned RamUnsignedFromString (const std::string &str, std::size_t *position=nullptr, const int base=10)
 Converts a string to a RamUnsigned. More...
 
std::string simpleName (const std::string &path)
 File name, with extension removed. More...
 
std::vector< std::string > split (const std::string &s, char delim, int times=-1)
 utility function to split a string More...
 
std::vector< std::string > splitString (const std::string &str, char delimiter)
 Splits a string given a delimiter. More...
 
std::string stringify (const std::string &input)
 Stringify a string using escapes for escape, newline, tab, double-quotes and semicolons. More...
 
std::string tempFile ()
 Generate temporary file. More...
 
 TEST (SparseArray, Basic)
 
 TEST (SparseArray, Copy)
 
 TEST (SparseArray, Find)
 
 TEST (SparseArray, Find2)
 
 TEST (SparseArray, Iterator)
 
 TEST (SparseArray, IteratorStress)
 
 TEST (SparseArray, IteratorStress2)
 
 TEST (SparseArray, Limits)
 
 TEST (SparseArray, LowerBound)
 
 TEST (SparseArray, LowerBound2)
 
 TEST (SparseArray, MemoryUsage)
 
 TEST (SparseArray, Merge)
 
 TEST (SparseArray, UpperBound)
 
 TEST (SparseArray, UpperBound2)
 
 TEST (SparseBitMap, Basic)
 
 TEST (SparseBitMap, CopyAndMerge)
 
 TEST (SparseBitMap, Find)
 
 TEST (SparseBitMap, Iterator)
 
 TEST (SparseBitMap, IteratorStress2)
 
 TEST (SparseBitMap, Size)
 
 TEST (SparseBitMap, Stress)
 
 TEST (Trie, Basic)
 
 TEST (Trie, BoundaryTest_1D)
 
 TEST (Trie, BoundaryTest_1D_2)
 
 TEST (Trie, BoundaryTest_1D_Stress)
 
 TEST (Trie, BoundaryTest_1D_Stress_Dense)
 
 TEST (Trie, BoundaryTest_2D)
 
 TEST (Trie, BoundaryTest_2D_2)
 
 TEST (Trie, BoundaryTest_2D_Stress)
 
 TEST (Trie, BoundaryTest_2D_Stress_Dense)
 
 TEST (Trie, BoundaryTest_3D)
 
 TEST (Trie, BoundaryTest_3D_2)
 
 TEST (Trie, BoundaryTest_3D_Stress)
 
 TEST (Trie, Iterator)
 
 TEST (Trie, IteratorStress_1D)
 
 TEST (Trie, IteratorStress_2D)
 
 TEST (Trie, IteratorStress_3D)
 
 TEST (Trie, IteratorStress_4D)
 
 TEST (Trie, Limits)
 
 TEST (Trie, Merge_1D)
 
 TEST (Trie, Merge_2D)
 
 TEST (Trie, Merge_3D)
 
 TEST (Trie, Merge_Bug)
 
 TEST (Trie, Merge_Stress)
 
 TEST (Trie, Parallel)
 
 TEST (Trie, RangeQuery)
 
 TEST (Trie, RangeQuery_1D)
 
 TEST (Trie, RangeQuery_2D)
 
 TEST (Trie, RangeQuery_3D)
 
 TEST (Trie, RangeQueryStress)
 
 TEST (Trie, Size)
 
template<typename T >
detail::multiplying_printer< T > times (const T &value, unsigned num)
 A utility printing a given value multiple times. More...
 
std::string toBase64 (const std::string &data)
 
BinaryConstraintOp toBinaryConstraintOp (const std::string &symbol)
 Converts symbolic representation of an operator to the operator. More...
 
char const * toBinaryConstraintSymbol (const BinaryConstraintOp op)
 Converts operator to its symbolic representation. More...
 
template<typename T >
std::vector< T * > toPtrVector (const std::vector< std::unique_ptr< T >> &v)
 A utility function enabling the creation of a vector of pointers. More...
 
const std::string & toString (const std::string &str)
 A generic function converting strings into strings (trivial case). More...
 
template<typename T >
std::enable_if<!detail::is_printable< T >::value, std::string >::type toString (const T &)
 A fallback for the to-string function in case an unprintable object is supposed to be printed. More...
 
template<typename T >
std::enable_if< detail::is_printable< T >::value, std::string >::type toString (const T &value)
 A generic function converting arbitrary objects to strings by utilizing their print capability. More...
 
template<typename T >
std::vector< T > toVector ()
 A utility function enabling the creation of a vector with a fixed set of elements within a single expression. More...
 
template<typename T , typename... R>
std::vector< T > toVector (const T &first, const R &... rest)
 A utility function enabling the creation of a vector with a fixed set of elements within a single expression. More...
 
std::string unescape (const std::string &inputString)
 
std::string unescape (const std::string &inputString, const std::string &needle, const std::string &replacement)
 
std::string which (const std::string &name)
 Simple implementation of a which tool. More...
 

Variables

constexpr auto dynamic_extent = tcb::dynamic_extent
 
constexpr char FUNCTOR_INTRINSIC_PREFIX_NEGATE_NAME [] = "negate"
 
template<typename T >
constexpr bool isRamType
 
template<typename A >
constexpr bool JoinShouldDeref = IsPtrLike<A>::value && !std::is_same_v<A, char const*>
 
constexpr RamFloat MAX_RAM_FLOAT = std::numeric_limits<RamFloat>::max()
 
constexpr RamSigned MAX_RAM_SIGNED = std::numeric_limits<RamSigned>::max()
 
constexpr RamUnsigned MAX_RAM_UNSIGNED = std::numeric_limits<RamUnsigned>::max()
 
constexpr RamFloat MIN_RAM_FLOAT = std::numeric_limits<RamFloat>::lowest()
 
constexpr RamSigned MIN_RAM_SIGNED = std::numeric_limits<RamSigned>::min()
 lower and upper boundaries for the ram types More...
 
constexpr RamUnsigned MIN_RAM_UNSIGNED = std::numeric_limits<RamUnsigned>::min()
 
constexpr block_t rank_mask = (1ul << split_size) - 1
 
constexpr uint8_t split_size = 8u
 

Typedef Documentation

◆ block_t

using souffle::block_t = typedef uint64_t

Definition at line 47 of file UnionFind.h.

◆ copy_const_t

template<typename A , typename B >
using souffle::copy_const_t = typedef std::conditional_t<std::is_const_v<A>, const B, B>

Definition at line 150 of file MiscUtil.h.

◆ IntrinsicFunctors

using souffle::IntrinsicFunctors = typedef std::vector<std::reference_wrapper<const IntrinsicFunctorInfo> >

Definition at line 129 of file FunctorOps.h.

◆ Own

template<typename A >
using souffle::Own = typedef std::unique_ptr<A>

Definition at line 42 of file ContainerUtil.h.

◆ parent_t

using souffle::parent_t = typedef uint64_t

Definition at line 41 of file UnionFind.h.

◆ RamDomain

using souffle::RamDomain = typedef int32_t

Definition at line 56 of file RamTypes.h.

◆ RamFloat

using souffle::RamFloat = typedef float

Definition at line 60 of file RamTypes.h.

◆ RamSigned

using souffle::RamSigned = typedef RamDomain

Definition at line 57 of file RamTypes.h.

◆ RamUnsigned

using souffle::RamUnsigned = typedef uint32_t

Definition at line 58 of file RamTypes.h.

◆ rank_t

using souffle::rank_t = typedef uint8_t

Definition at line 39 of file UnionFind.h.

◆ span

template<typename A , size_t E = tcb::dynamic_extent>
using souffle::span = typedef tcb::span<A, E>

Definition at line 659 of file span.h.

◆ time_point

using souffle::time_point = typedef std::chrono::high_resolution_clock::time_point

Definition at line 85 of file MiscUtil.h.

◆ Tuple

template<typename A , size_t N>
using souffle::Tuple = typedef std::array<A, N>

Definition at line 36 of file RamTypes.h.

◆ VecOwn

template<typename A >
using souffle::VecOwn = typedef std::vector<Own<A> >

Definition at line 45 of file ContainerUtil.h.

◆ yyscan_t

using souffle::yyscan_t = typedef void*

Definition at line 48 of file ParserDriver.h.

Enumeration Type Documentation

◆ AggregateOp

enum souffle::AggregateOp
strong

Types of aggregation functions.

Enumerator
MAX 
MIN 
SUM 
FMAX 
FMIN 
FSUM 
MEAN 
UMAX 
UMIN 
USUM 
COUNT 

Definition at line 34 of file AggregateOp.h.

45  {
46  switch (op) {
47  case AggregateOp::COUNT: return os << "count";
48 
49  case AggregateOp::MEAN: return os << "mean";

◆ BinaryConstraintOp

Binary Constraint Operators.

Enumerator
EQ 
FEQ 
NE 
FNE 
LT 
ULT 
FLT 
SLT 
LE 
ULE 
FLE 
SLE 
GT 
UGT 
FGT 
SGT 
GE 
UGE 
FGE 
SGE 
MATCH 
CONTAINS 
NOT_MATCH 
NOT_CONTAINS 

Definition at line 41 of file BinaryConstraintOps.h.

64  {
65  return os << toBinaryConstraintSymbol(x);
66 }

◆ FunctorOp

enum souffle::FunctorOp
strong
Enumerator
ORD 

Unary Functor Operators.

STRLEN 
NEG 
FNEG 
BNOT 
UBNOT 
LNOT 
ULNOT 
F2I 
F2S 
F2U 
I2F 
I2S 
I2U 
S2F 
S2I 
S2U 
U2F 
U2I 
U2S 
ADD 

Binary Functor Operators.

SUB 
MUL 
DIV 
EXP 
MAX 
MIN 
MOD 
BAND 
BOR 
BXOR 
BSHIFT_L 
BSHIFT_R 
BSHIFT_R_UNSIGNED 
LAND 
LOR 
LXOR 
UADD 
USUB 
UMUL 
UDIV 
UEXP 
UMAX 
UMIN 
UMOD 
UBAND 
UBOR 
UBXOR 
UBSHIFT_L 
UBSHIFT_R 
UBSHIFT_R_UNSIGNED 
ULAND 
ULOR 
ULXOR 
FADD 
FSUB 
FMUL 
FDIV 
FEXP 
FMAX 
FMIN 
SMAX 
SMIN 
RANGE 
URANGE 
FRANGE 
CAT 
SUBSTR 

Ternary Functor Operators.

Definition at line 35 of file FunctorOps.h.

114  {
115  std::string symbol;
116  std::vector<TypeAttribute> params;

◆ RelationQualifier

Space of qualifiers that a relation can have.

Enumerator
INPUT 
OUTPUT 
PRINTSIZE 
OVERRIDABLE 
INLINE 
MAGIC 
SUPPRESSED 

Definition at line 45 of file RelationTag.h.

50  {
51  DEFAULT, // use default data-structure
52  BRIE, // use brie data-structure
53  BTREE, // use btree data-structure

◆ RelationRepresentation

Space of internal representations that a relation can have.

Enumerator
DEFAULT 
BRIE 
BTREE 
EQREL 
INFO 

Definition at line 56 of file RelationTag.h.

61  {
62  switch (tag) {

◆ RelationTag

enum souffle::RelationTag
strong

Space of user-chosen tags that a relation can have.

Enumerator
INPUT 
OUTPUT 
PRINTSIZE 
OVERRIDABLE 
INLINE 
MAGIC 
SUPPRESSED 
BRIE 
BTREE 
EQREL 

Definition at line 31 of file RelationTag.h.

39  {
40  INPUT, // relation read from csv
41  OUTPUT, // relation written to csv
42  PRINTSIZE, // number of tuples written to stdout

◆ TypeAttribute

Enumerator
Symbol 
Signed 
Unsigned 
Float 
Record 
ADT 

Definition at line 34 of file TypeAttribute.h.

38  {
39  switch (T) {
40  case TypeAttribute::Symbol: return os << "TypeAttribute::Symbol";
41  case TypeAttribute::Signed: return os << "TypeAttribute::Signed";

Function Documentation

◆ absPath()

std::string souffle::absPath ( const std::string &  path)
inline

C++-style realpath.

Definition at line 156 of file FileUtil.h.

159  {
160  unsigned firstPos = static_cast<unsigned>(first.size()) - 1;

Referenced by findTool().

◆ aggregateArity()

std::pair<uint8_t, uint8_t> souffle::aggregateArity ( AggregateOp  op)
inline

Definition at line 74 of file AggregateOp.h.

74  :
75  case AggregateOp::MAX:
76  case AggregateOp::MEAN:
77  case AggregateOp::MIN:
78  case AggregateOp::SUM:
79  case AggregateOp::UMAX:
80  case AggregateOp::UMIN:
81  case AggregateOp::USUM: return {1, 1};
82  }
83 
85 }
86 
87 /**
88  * Get return type of the aggregate.
89  */
91  switch (op) {

◆ all_of()

template<typename Container , typename UnaryPredicate >
bool souffle::all_of ( const Container &  c,
UnaryPredicate  p 
)

A generic test checking whether all elements within a container satisfy a certain predicate.

Parameters
cthe container
pthe predicate
Returns
true if for all elements x in c the predicate p(x) is true, false otherwise; for empty containers the result is always true

Definition at line 110 of file FunctionalUtil.h.

118  {

References any_of(), and p.

Referenced by souffle::ast::analysis::TypeSet::end(), and functorBuiltIn().

Here is the call graph for this function:

◆ any_of()

template<typename Container , typename UnaryPredicate >
bool souffle::any_of ( const Container &  c,
UnaryPredicate  p 
)

A generic test checking whether any elements within a container satisfy a certain predicate.

Parameters
cthe container
pthe predicate
Returns
true if there is an element x in c such that predicate p(x) is true, false otherwise; for empty containers the result is always false

Definition at line 124 of file FunctionalUtil.h.

132  {

References none_of(), and p.

Referenced by souffle::ParserDriver::addTag(), all_of(), isValidFunctorOpArity(), and souffle::ast::transform::ResolveAliasesTransformer::removeComplexTermsInAtoms().

Here is the call graph for this function:

◆ as() [1/3]

template<typename B , typename A >
std::enable_if_t<std::is_base_of_v<A, B>, copy_const_t<A, B>*> souffle::as ( A &  x)

Definition at line 166 of file MiscUtil.h.

173  {

◆ as() [2/3]

template<typename B , typename A >
auto souffle::as ( A *  x)

Helpers for dynamic_casting without having to specify redundant type qualifiers.

e.g. as<AstLiteral>(p) instead of dynamic_cast<const AstLiteral*>(p.get()).

Definition at line 157 of file MiscUtil.h.

160  {
161  return as<B>(&x);
162 }
163 

◆ as() [3/3]

template<typename B , typename A >
B* souffle::as ( const std::unique_ptr< A > &  x)

Definition at line 171 of file MiscUtil.h.

173  {

◆ baseName()

std::string souffle::baseName ( const std::string &  filename)
inline

Definition at line 199 of file FileUtil.h.

199  {
200  return "/";
201  }
202 
203  size_t lastSlashBeforeBasename = filename.find_last_of('/', lastNotSlash - 1);
204  if (lastSlashBeforeBasename == std::string::npos) {
205  lastSlashBeforeBasename = static_cast<size_t>(-1);
206  }
207  return filename.substr(lastSlashBeforeBasename + 1, lastNotSlash - lastSlashBeforeBasename);
208 }
209 
210 /**
211  * File name, with extension removed.
212  */
213 inline std::string simpleName(const std::string& path) {
214  std::string name = baseName(path);

◆ canBeParsedAsRamFloat()

bool souffle::canBeParsedAsRamFloat ( const std::string &  string)
inline

Can a string be parsed as RamFloat.

Definition at line 192 of file StringUtil.h.

197  {
198  return static_cast<RamDomain>(std::stoull(str, pos, base));
199 }
200 #elif RAM_DOMAIN_SIZE == 32

Referenced by souffle::ExplainProvenanceImpl::queryProcess(), and souffle::ast::analysis::TypeConstraintsAnalysis::visitNumericConstant().

◆ canBeParsedAsRamSigned()

bool souffle::canBeParsedAsRamSigned ( const std::string &  string)
inline

Can a string be parsed as RamSigned.

Souffle (parser, not fact file readers) accepts: hex, binary and base 10. Integer can be negative, in all 3 formats this means that it starts with minus (c++ default semantics).

Definition at line 162 of file StringUtil.h.

Referenced by souffle::ExplainProvenanceImpl::queryProcess(), and souffle::ast::analysis::TypeConstraintsAnalysis::visitNumericConstant().

◆ canBeParsedAsRamUnsigned()

bool souffle::canBeParsedAsRamUnsigned ( const std::string &  string)
inline

Can a string be parsed as RamUnsigned.

Souffle accepts: hex, binary and base 10.

Definition at line 179 of file StringUtil.h.

186  {
187  size_t charactersRead = 0;

Referenced by souffle::ExplainProvenanceImpl::queryProcess(), and souffle::ast::analysis::TypeConstraintsAnalysis::visitNumericConstant().

◆ castEq()

template<typename toType , typename baseType >
bool souffle::castEq ( const baseType *  left,
const baseType *  right 
)

Cast the values, from baseType to toType and compare using ==.

(if casting fails -> return false.)

Template Parameters
baseType,initialType of values
toType,typewhere equality comparison takes place.

Definition at line 404 of file ContainerUtil.h.

411  {

◆ clone() [1/5]

template<typename A >
std::unique_ptr<A> souffle::clone ( const A *  node)

Definition at line 108 of file MiscUtil.h.

108  : nullptr;
109 }
110 

◆ clone() [2/5]

template<typename A , typename B >
auto souffle::clone ( const std::pair< A, B > &  p)

Definition at line 118 of file MiscUtil.h.

124  {

References b.

◆ clone() [3/5]

template<typename A >
std::unique_ptr<A> souffle::clone ( const std::unique_ptr< A > &  node)

Definition at line 113 of file MiscUtil.h.

124  {

◆ clone() [4/5]

template<typename A >
auto souffle::clone ( const std::vector< A * > &  xs)

Definition at line 172 of file ContainerUtil.h.

176  {
177  std::vector<std::unique_ptr<A>> ys;
178  ys.reserve(xs.size());
179  for (auto&& x : xs) {

Referenced by souffle::ast::BranchInit::BranchInit(), souffle::ast::transform::SemanticCheckerImpl::checkAggregator(), souffle::ram::Program::clone(), souffle::ast::Program::clone(), souffle::ram::transform::CollapseFiltersTransformer::collapseFilters(), souffle::ast::transform::MagicSetTransformer::MagicSetCoreTransformer::createMagicClause(), souffle::ast::transform::DebugReporter::disableTransformers(), souffle::ast::transform::FixpointTransformer::disableTransformers(), souffle::ast::transform::ConditionalTransformer::disableTransformers(), souffle::ram::transform::EliminateDuplicatesTransformer::eliminateDuplicates(), souffle::ram::transform::ExpandFilterTransformer::expandFilters(), souffle::ram::DebugInfo::getChildNodes(), souffle::ram::Exit::getChildNodes(), souffle::ram::LogTimer::getChildNodes(), souffle::ram::Loop::getChildNodes(), souffle::ram::Query::getChildNodes(), souffle::ast::TypeCast::getChildNodes(), souffle::ram::transform::MakeIndexTransformer::getExpressionPair(), souffle::ast::transform::getInlinedArgument(), souffle::ast::transform::getInlinedAtom(), souffle::ram::Negation::getOperand(), souffle::ram::Constraint::getOperator(), souffle::ram::Conjunction::getRHS(), souffle::ast::transform::MaterializeAggregationQueriesTransformer::groundInjectedParameters(), souffle::ram::transform::HoistAggregateTransformer::hoistAggregate(), souffle::ast2ram::AstToRamTranslator::makeSubproofSubroutine(), souffle::RuleBody::negated(), souffle::ast::Negation::Negation(), souffle::ram::ParallelAggregate::ParallelAggregate(), souffle::ram::ParallelChoice::ParallelChoice(), souffle::ram::transform::ParallelTransformer::parallelizeOperations(), souffle::ast::renameAtoms(), souffle::ram::transform::ReorderConditionsTransformer::reorderConditions(), souffle::ram::transform::ReorderFilterBreak::reorderFilterBreak(), souffle::RuleBody::toClauseBodies(), souffle::ast::transform::SimplifyAggregateTargetExpressionTransformer::transform(), souffle::ast::transform::RemoveRedundantSumsTransformer::transform(), souffle::ast::transform::PartitionBodyLiteralsTransformer::transform(), souffle::ast::transform::MagicSetTransformer::MagicSetCoreTransformer::transform(), and souffle::ast::transform::FoldAnonymousRecords::transformClause().

◆ clone() [5/5]

template<typename A >
auto souffle::clone ( const std::vector< std::unique_ptr< A >> &  xs)

Definition at line 182 of file ContainerUtil.h.

◆ compileToBinary()

void souffle::compileToBinary ( std::string  compileCmd,
const std::string &  sourceFilename 
)

Compiles the given source file to a binary file.

Definition at line 165 of file main.cpp.

169  : splitString(Global::config().get("libraries"), ' ')) {
170  // The first entry may be blank
171  if (library.empty()) {
172  continue;
173  }
174  compileCmd += "-l" + library + ' ';
175  }
176 
177  compileCmd += sourceFilename;
178 
179  // run executable
180  if (system(compileCmd.c_str()) != 0) {
181  throw std::invalid_argument("failed to compile C++ source <" + sourceFilename + ">");
182  }
183 }
184 
185 int main(int argc, char** argv) {
186  /* Time taking for overall runtime */
187  auto souffle_start = std::chrono::high_resolution_clock::now();
188 
189  /* have all to do with command line arguments in its own scope, as these are accessible through the global

◆ contains() [1/3]

template<typename C >
bool souffle::contains ( const C &  container,
const typename C::value_type &  element 
)

A utility to check generically whether a given element is contained in a given container.

Definition at line 75 of file ContainerUtil.h.

75  {
76  return container.find(element) != container.end();
77 }

Referenced by souffle::ast::transform::MagicSetTransformer::MagicSetCoreTransformer::addRelevantVariables(), souffle::ParserDriver::addTag(), souffle::ast::transform::MagicSetTransformer::AdornDatabaseTransformer::queueAdornment(), souffle::ast::renameAtoms(), and TEST().

◆ contains() [2/3]

template<typename C >
bool souffle::contains ( const C &  container,
const typename C::value_type::first_type &  element 
)

Version of contains specialised for maps.

This workaround is needed because of set container, for which value_type == key_type, which is ambiguous in this context.

Definition at line 92 of file ContainerUtil.h.

◆ contains() [3/3]

template<typename A >
bool souffle::contains ( const std::set< A > &  container,
const A &  element 
)

Definition at line 81 of file ContainerUtil.h.

◆ convertDotToSVG()

std::string souffle::convertDotToSVG ( const std::string &  dotSpec)
inline

Definition at line 213 of file GraphUtils.h.

220  {
221  std::string data = convertDotToSVG(dotSpec);
222 
223  if (data.find("<svg") != std::string::npos) {
224  out << "<img alt='graph image' src='data:image/svg+xml;base64," << toBase64(data) << "'><br/>\n";

◆ convertOverloadedAggregator()

AggregateOp souffle::convertOverloadedAggregator ( const AggregateOp  op,
const TypeAttribute  type 
)
inline

Convert aggregator to a give type.

Eg. sum, float → fsum.

Definition at line 133 of file AggregateOp.h.

135  {
136  default:
137  fatal("agg op is not overloadable");
138 
139  // clang-format off
140  CASE_NUMERIC(MAX)
141  CASE_NUMERIC(MIN)
142  CASE_NUMERIC(SUM)
143  // clang-format on
144  }
145 
146 #undef CASE_NUMERIC
147 }
148 
149 } // namespace souffle

References CASE_NUMERIC, fatal(), MAX, MIN, and SUM.

Here is the call graph for this function:

◆ convertOverloadedConstraint()

BinaryConstraintOp souffle::convertOverloadedConstraint ( const BinaryConstraintOp  constraintOp,
const TypeAttribute  toType 
)
inline

Convert Constraint to work with requested type.

Example: constraintOp = LT, toType = Float -> FLT (less-than working on floats).

Definition at line 248 of file BinaryConstraintOps.h.

250  : \
251  switch (toType) { \
252  default : return BinaryConstraintOp:: op; \
253  case TypeAttribute::Float : return BinaryConstraintOp::F##op; \
254  }
255 #define COMPARE_CONSTRAINT(op) \
256  case BinaryConstraintOp::op: \
257  switch (toType) { \
258  case TypeAttribute::Signed : return BinaryConstraintOp:: op; \
259  case TypeAttribute::Unsigned: return BinaryConstraintOp::U##op; \
260  case TypeAttribute::Float : return BinaryConstraintOp::F##op; \
261  case TypeAttribute::Symbol : return BinaryConstraintOp::S##op; \
262  case TypeAttribute::ADT : \
263  case TypeAttribute::Record : return FAIL(); \
264  } \
265  break; /* HACK: GCC-9 is incorrectly reporting a case fallthru */
266  // clang-format on
267 
268  switch (constraintOp) {
271 
276 
277  default: fatal("invalid constraint conversion: constraint = %s", constraintOp);
278  }
279 
281 
282 #undef COMPARE_CONSTRAINT_FLOAT_OR_RAW
283 #undef COMPARE_CONSTRAINT
284 }
285 
286 /**
287  * Negated Constraint Operator
288  * Each operator requires a negated operator which is
289  * necessary for the expansion of complex rule bodies with disjunction and negation.
290  */

References COMPARE_CONSTRAINT, COMPARE_CONSTRAINT_FLOAT_OR_RAW, EQ, fatal(), GE, GT, LE, LT, and NE.

Here is the call graph for this function:

◆ convertStrictToNotEqualConstraint()

BinaryConstraintOp souffle::convertStrictToNotEqualConstraint ( const BinaryConstraintOp  constraintOp)
inline

Definition at line 173 of file BinaryConstraintOps.h.

173  : return BinaryConstraintOp::NE;
174  case BinaryConstraintOp::FLT: return BinaryConstraintOp::FNE;
175  case BinaryConstraintOp::FGT: return BinaryConstraintOp::FNE;
176  default: break;
177  }
178  return constraintOp;
179 }
180 
181 inline bool isLessThan(const BinaryConstraintOp constraintOp) {
182  switch (constraintOp) {
183  case BinaryConstraintOp::LT:
184  case BinaryConstraintOp::ULT:
185  case BinaryConstraintOp::FLT: return true;

◆ convertStrictToWeakIneqConstraint()

BinaryConstraintOp souffle::convertStrictToWeakIneqConstraint ( const BinaryConstraintOp  constraintOp)
inline

Definition at line 159 of file BinaryConstraintOps.h.

159  : return BinaryConstraintOp::UGE;
160  case BinaryConstraintOp::FLT: return BinaryConstraintOp::FLE;
161  case BinaryConstraintOp::FGT: return BinaryConstraintOp::FGE;
162  default: break;
163  }
164  return constraintOp;
165 }
166 
168  assert(isStrictIneqConstraint(constraintOp));
169  switch (constraintOp) {
170  case BinaryConstraintOp::LT: return BinaryConstraintOp::NE;
171  case BinaryConstraintOp::GT: return BinaryConstraintOp::NE;

◆ derefIter()

template<typename Iter >
IterDerefWrapper<Iter> souffle::derefIter ( const Iter &  iter)

A factory function enabling the construction of a dereferencing iterator utilizing the automated deduction of template parameters.

Definition at line 252 of file ContainerUtil.h.

254  : public std::iterator<std::forward_iterator_tag, T> {

References souffle::SingleValueIterator< T >::end, and souffle::SingleValueIterator< T >::value.

Referenced by souffle::ast::analysis::TypeSet::begin().

◆ dirName()

std::string souffle::dirName ( const std::string &  name)
inline

C++-style dirname.

Definition at line 132 of file FileUtil.h.

132  {
133  return "/";
134  }
135  size_t leadingSlash = name.find_last_of('/', lastNotSlash);
136  // No '/'
137  if (leadingSlash == std::string::npos) {
138  return ".";
139  }
140  // dirname is '/'
141  if (leadingSlash == 0) {
142  return "/";
143  }
144  return name.substr(0, leadingSlash);
145 }
146 
147 /**
148  * C++-style realpath
149  */
150 inline std::string absPath(const std::string& path) {
151  char buf[PATH_MAX];

Referenced by getCurrentFilename().

◆ duration_in_ns()

long souffle::duration_in_ns ( const time_point start,
const time_point end 
)
inline

Definition at line 99 of file MiscUtil.h.

◆ duration_in_us()

long souffle::duration_in_us ( const time_point start,
const time_point end 
)
inline

Definition at line 94 of file MiscUtil.h.

◆ endsWith()

bool souffle::endsWith ( const std::string &  value,
const std::string &  ending 
)
inline

Determines whether the given value string ends with the given end string.

Definition at line 311 of file StringUtil.h.

315  {
316  std::vector<std::string> parts;

◆ equal_ptr() [1/2]

template<typename T >
bool souffle::equal_ptr ( const std::unique_ptr< T > &  a,
const std::unique_ptr< T > &  b 
)

Compares two values referenced by a pointer where the case where both pointers are null is also considered equivalent.

Definition at line 145 of file MiscUtil.h.

151  {

◆ equal_ptr() [2/2]

template<typename T >
bool souffle::equal_ptr ( const T *  a,
const T *  b 
)

Compares two values referenced by a pointer where the case where both pointers are null is also considered equivalent.

Definition at line 130 of file MiscUtil.h.

Referenced by souffle::ram::AbstractLog::apply(), souffle::ram::AbstractConditional::apply(), souffle::ram::AbstractChoice::getChildNodes(), souffle::ram::Exit::print(), souffle::ram::Query::print(), and souffle::ram::NestedOperation::print().

◆ equal_targets() [1/4]

template<typename Container , typename Comparator >
bool souffle::equal_targets ( const Container &  a,
const Container &  b,
const Comparator comp 
)

A function testing whether two containers are equal with the given Comparator.

Definition at line 433 of file ContainerUtil.h.

434  {
435  return false;
436  }
437 
438  // check content
439  return std::equal(a.begin(), a.end(), b.begin(), comp);
440 }
441 
442 /**
443  * A function testing whether two containers of pointers are referencing equivalent
444  * targets.
445  */
446 template <typename T, template <typename...> class Container>

Referenced by souffle::ram::AbstractOperator::apply(), souffle::ast::Term::apply(), souffle::ast::Program::equal(), equal_targets(), and souffle::ast::transform::RemoveRelationCopiesTransformer::removeRelationCopies().

◆ equal_targets() [2/4]

template<typename T , template< typename... > class Container>
bool souffle::equal_targets ( const Container< std::unique_ptr< T >> &  a,
const Container< std::unique_ptr< T >> &  b 
)

A function testing whether two containers of unique pointers are referencing equivalent targets.

Definition at line 462 of file ContainerUtil.h.

References b, and equal_targets().

Here is the call graph for this function:

◆ equal_targets() [3/4]

template<typename T , template< typename... > class Container>
bool souffle::equal_targets ( const Container< T * > &  a,
const Container< T * > &  b 
)

A function testing whether two containers of pointers are referencing equivalent targets.

Definition at line 453 of file ContainerUtil.h.

References b, and equal_targets().

Here is the call graph for this function:

◆ equal_targets() [4/4]

template<typename Key , typename Value >
bool souffle::equal_targets ( const std::map< Key, std::unique_ptr< Value >> &  a,
const std::map< Key, std::unique_ptr< Value >> &  b 
)

A function testing whether two maps of unique pointers are referencing to equivalent targets.

Definition at line 471 of file ContainerUtil.h.

◆ escape() [1/2]

std::string souffle::escape ( const std::string &  inputString)
inline

Definition at line 428 of file StringUtil.h.

◆ escape() [2/2]

std::string souffle::escape ( const std::string &  inputString,
const std::string &  needle,
const std::string &  replacement 
)
inline

Definition at line 417 of file StringUtil.h.

422  {
423  std::string escaped = escape(inputString, "\"", "\\\"");
424  escaped = escape(escaped, "\t", "\\t");
425  escaped = escape(escaped, "\r", "\\r");
426  escaped = escape(escaped, "\n", "\\n");

◆ escapeJSONstring()

std::string souffle::escapeJSONstring ( const std::string &  JSONstr)
inline

Escape JSON string.

Definition at line 373 of file StringUtil.h.

381  {
382  for (size_t i = 0; i < id.length(); i++) {
383  if (((isalpha(id[i]) == 0) && i == 0) || ((isalnum(id[i]) == 0) && id[i] != '_')) {
384  id[i] = '_';

◆ execStdOut() [1/2]

std::stringstream souffle::execStdOut ( char const *  cmd)
inline

Definition at line 274 of file FileUtil.h.

282  {
283  return execStdOut(cmd.c_str());
284 }
285 
286 class TempFileStream : public std::fstream {

◆ execStdOut() [2/2]

std::stringstream souffle::execStdOut ( std::string const &  cmd)
inline

Definition at line 288 of file FileUtil.h.

289  :
290  TempFileStream(std::string fileName = tempFile())

◆ executeBinary()

void souffle::executeBinary ( const std::string &  binaryFilename)

Executes a binary file.

Definition at line 124 of file main.cpp.

128  {
129  for (const std::string& library : splitString(Global::config().get("library-dir"), ' ')) {
130  ldPath += library + ':';
131  }
132  ldPath.pop_back();
133  setenv("LD_LIBRARY_PATH", ldPath.c_str(), 1);
134  }
135 
136  std::string exePath;
137 #ifdef __APPLE__
138  // OSX does not pass on the environment from setenv so add it to the command line
139  exePath = "DYLD_LIBRARY_PATH=\"" + ldPath + "\" ";
140 #endif
141  exePath += binaryFilename;
142 
143  int exitCode = system(exePath.c_str());
144 
145  if (Global::config().get("dl-program").empty()) {
146  remove(binaryFilename.c_str());
147  remove((binaryFilename + ".cpp").c_str());
148  }
149 
150  // exit with same code as executable
151  if (exitCode != EXIT_SUCCESS) {
152  exit(exitCode);
153  }
154 }
155 
156 /**
157  * Compiles the given source file to a binary file.
158  */
159 void compileToBinary(std::string compileCmd, const std::string& sourceFilename) {
160  // add source code

◆ existDir()

bool souffle::existDir ( const std::string &  name)
inline

Check whether a directory exists in the file system.

Definition at line 84 of file FileUtil.h.

91  {
92  return existFile(name) && (access(name.c_str(), X_OK) == 0);

Referenced by main().

◆ existFile()

bool souffle::existFile ( const std::string &  name)
inline

Check whether a file exists in the file system.

Definition at line 71 of file FileUtil.h.

78  {
79  struct stat buffer = {};

Referenced by getCurrentFilename(), and main().

◆ explain()

void souffle::explain ( SouffleProgram prog,
bool  ncurses 
)
inline

Definition at line 627 of file Explain.h.

627  {
628  ExplainProvenanceImpl prov(prog);
629 
630  if (ncurses) {
631 #ifdef USE_NCURSES
632  ExplainNcurses exp(prov);
633  exp.explain();
634 #else
635  std::cout << "The ncurses-based interface is not enabled\n";
636 #endif
637  } else {
638  ExplainConsole exp(prov);
639  exp.explain();
640  }
641 }

◆ fatal()

template<typename... Args>
void souffle::fatal ( const char *  format,
const Args &...  args 
)

◆ fileExtension()

std::string souffle::fileExtension ( const std::string &  path)
inline

File extension, with all else removed.

Definition at line 238 of file FileUtil.h.

241  {
242  return std::string();
243  }
244  // last dot after last slash, or no slash
245  return name.substr(lastDot + 1);
246 }
247 
248 /**
249  * Generate temporary file.
250  */
251 inline std::string tempFile() {
252 #ifdef _WIN32

◆ filter()

template<typename A , typename F >
std::vector<A> souffle::filter ( std::vector< A >  xs,
F &&  f 
)

◆ filterNot()

template<typename A , typename F >
std::vector<A> souffle::filterNot ( std::vector< A >  xs,
F &&  f 
)

Filter a vector to exclude certain elements.

Definition at line 146 of file FunctionalUtil.h.

149  {

◆ findTool()

std::string souffle::findTool ( const std::string &  tool,
const std::string &  base,
const std::string &  path 
)
inline

Definition at line 182 of file FileUtil.h.

183  {
184  return absPath(subpath);
185  }
186  }
187  return "";
188 }
189 
190 /*
191  * Get the basename of a fully qualified filename
192  */
193 inline std::string baseName(const std::string& filename) {
194  if (filename.empty()) {

References absPath().

Here is the call graph for this function:

◆ functorBuiltIn() [1/3]

IntrinsicFunctors souffle::functorBuiltIn ( FunctorOp  op)

Definition at line 224 of file FunctorOps.cpp.

224  {
225  return pickFunctors([&](auto&& x) { return x.op == op; });
226 }

Referenced by isFunctorMultiResult(), isInfixFunctorOp(), and souffle::ast::analysis::TypeConstraintsAnalysis::visitFunctor().

◆ functorBuiltIn() [2/3]

IntrinsicFunctors souffle::functorBuiltIn ( std::string_view  symbol)

Definition at line 228 of file FunctorOps.cpp.

228  {
229  return pickFunctors([&](auto&& x) { return x.symbol == symbol; });
230 }

◆ functorBuiltIn() [3/3]

IntrinsicFunctors souffle::functorBuiltIn ( std::string_view  symbol,
const std::vector< TypeAttribute > &  params 
)

Definition at line 232 of file FunctorOps.cpp.

232  {
233  return pickFunctors([&](auto&& x) {
234  auto paramsOk =
235  x.variadic ? all_of(params, [&](auto t) { return t == x.params[0]; }) : x.params == params;
236  return x.symbol == symbol && paramsOk;
237  });
238 }

References all_of().

Here is the call graph for this function:

◆ genJsonRules()

std::stringstream& souffle::genJsonRules ( std::stringstream &  ss,
const std::string &  name,
size_t  maxRows 
)

Definition at line 339 of file Tui.h.

339  {
340  const std::shared_ptr<ProgramRun>& run = out.getProgramRun();
341 
342  auto comma = [&ss](bool& first, const std::string& delimiter = ", ") {
343  if (!first) {
344  ss << delimiter;
345  } else {
346  first = false;
347  }
348  };
349 
350  ss << '"' << name << R"_(":{)_";
351 
352  bool firstRow = true;
353  auto rows = ruleTable.getRows();
354  std::stable_sort(rows.begin(), rows.end(), [](std::shared_ptr<Row> left, std::shared_ptr<Row> right) {
355  return (*left)[0]->getDoubleVal() > (*right)[0]->getDoubleVal();
356  });
357  maxRows = std::min(rows.size(), maxRows);
358 
359  for (size_t i = 0; i < maxRows; ++i) {
360  Row& row = *rows[i];
361 
362  std::vector<std::string> part = Tools::split(row[6]->toString(0), ".");
363  std::string strRel = "R" + part[0].substr(1);
364  Table versionTable = out.getVersions(strRel, row[6]->toString(0));
365 
366  std::string src;
367  if (versionTable.rows.size() > 0) {
368  if (versionTable.rows[0]->cells[9] != nullptr) {
369  src = (*versionTable.rows[0])[9]->toString(0);
370  } else {
371  src = "-";
372  }
373  } else {
374  src = row[10]->toString(-1);
375  }
376  comma(firstRow);
377  ss << "\n ";
378 
379  ss << '"' << row[6]->toString(0) << R"_(": [)_";
380  ss << '"' << Tools::cleanJsonOut(row[5]->toString(0)) << R"_(", )_";
381  ss << '"' << Tools::cleanJsonOut(row[6]->toString(0)) << R"_(", )_";
382  ss << row[0]->getDoubleVal() << ", ";
383  ss << row[1]->getDoubleVal() << ", ";
384  ss << row[2]->getDoubleVal() << ", ";
385  ss << row[4]->getLongVal() << ", ";
386 
387  ss << '"' << src << R"_(", )_";
388  ss << "[";
389 
390  bool has_ver = false;
391  bool firstCol = true;
392  for (auto& _ver_row : versionTable.getRows()) {
393  comma(firstCol);
394  has_ver = true;
395  Row ver_row = *_ver_row;
396  ss << '[';
397  ss << '"' << Tools::cleanJsonOut(ver_row[5]->toString(0)) << R"_(", )_";
398  ss << '"' << Tools::cleanJsonOut(ver_row[6]->toString(0)) << R"_(", )_";
399  ss << ver_row[0]->getDoubleVal() << ", ";
400  ss << ver_row[1]->getDoubleVal() << ", ";
401  ss << ver_row[2]->getDoubleVal() << ", ";
402  ss << ver_row[4]->getLongVal() << ", ";
403  ss << '"' << src << R"_(", )_";
404  ss << ver_row[8]->getLongVal();
405  ss << ']';
406  }
407 
408  ss << "], ";
409 
410  if (row[6]->toString(0).at(0) != 'C') {
411  ss << "{}, {}]";
412  } else {
413  ss << R"_({"tot_t": [)_";
414 
415  std::vector<uint64_t> iteration_tuples;
416  bool firstCol = true;
417  for (auto& i : run->getRelation(row[7]->toString(0))->getIterations()) {
418  bool add = false;
419  std::chrono::microseconds totalTime{};
420  uint64_t totalSize = 0L;
421  for (auto& rul : i->getRules()) {
422  if (rul.second->getId() == row[6]->toString(0)) {
423  totalTime += rul.second->getRuntime();
424 
425  totalSize += rul.second->size();
426  add = true;
427  }
428  }
429  if (add) {
430  comma(firstCol);
431  ss << totalTime.count();
432  iteration_tuples.push_back(totalSize);
433  }
434  }
435  ss << R"_(], "tuples": [)_";
436  firstCol = true;
437  for (auto& i : iteration_tuples) {
438  comma(firstCol);
439  ss << i;
440  }
441 
442  ss << "]}, {";
443 
444  if (has_ver) {
445  ss << R"_("tot_t": [)_";
446 
447  firstCol = true;
448  for (auto& row : versionTable.rows) {
449  comma(firstCol);
450  ss << (*row)[0]->getDoubleVal();
451  }
452  ss << R"_(], "tuples": [)_";
453 
454  firstCol = true;
455  for (auto& row : versionTable.rows) {
456  comma(firstCol);
457  ss << (*row)[4]->getLongVal();
458  }
459  ss << ']';
460  }
461  ss << "}]";
462  }
463  }
464  ss << "\n}";
465  return ss;
466  }

References souffle::profile::Tools::cleanJsonOut(), souffle::profile::OutputProcessor::getProgramRun(), souffle::profile::Table::getRows(), souffle::profile::OutputProcessor::getVersions(), i, souffle::profile::Tui::out, rul(), souffle::profile::Tui::ruleTable, souffle::Table< T, blockSize >::size(), souffle::profile::Tools::split(), souffle::profile::ss, and toString().

Referenced by genJson().

Here is the call graph for this function:

◆ genJsonUsage()

std::stringstream& souffle::genJsonUsage ( std::stringstream &  ss)

◆ getBinaryConstraintTypes()

std::vector<TypeAttribute> souffle::getBinaryConstraintTypes ( const BinaryConstraintOp  op)
inline

Get type binary constraint operates on.

Definition at line 439 of file BinaryConstraintOps.h.

441  : return { TypeAttribute::Signed }; \
442  case BinaryConstraintOp::U##op: return { TypeAttribute::Unsigned }; \
443  case BinaryConstraintOp::F##op: return { TypeAttribute::Float }; \
444  case BinaryConstraintOp::S##op: return { TypeAttribute::Symbol };
445  // clang-format on
446 
447  switch (op) {
448  COMPARE_EQUALS(EQ)
449  COMPARE_EQUALS(NE)
450  COMPARE_OP(LT)
451  COMPARE_OP(LE)
452  COMPARE_OP(GT)
453  COMPARE_OP(GE)
454 
455  case BinaryConstraintOp::MATCH:
456  case BinaryConstraintOp::NOT_MATCH:
457  case BinaryConstraintOp::CONTAINS:
458  case BinaryConstraintOp::NOT_CONTAINS: return {TypeAttribute::Symbol};
459  }
460 
462 
463 #undef COMPARE_EQUALS
464 #undef COMPARE_OP
465 }
466 
467 } // end of namespace souffle

References COMPARE_EQUALS, COMPARE_OP, CONTAINS, EQ, GE, GT, LE, LT, MATCH, NE, NOT_CONTAINS, NOT_MATCH, and Symbol.

◆ getCurrentFilename()

std::string souffle::getCurrentFilename ( const std::vector< std::string > &  filenames)

Definition at line 33 of file SrcLocation.cpp.

33  : filenames) {
34  if (!filename.empty() && filename[0] == '/') {
35  path = dirName(filename);
36  } else if (existFile(path + "/" + filename)) {
37  path = dirName(path + "/" + filename);
38  } else if (existFile(filename)) {
39  path = dirName(filename);
40  } else {
41  path = ".";
42  }
43  }
44 
45  return path + "/" + baseName(filenames.back());
46 }
47 
48 bool SrcLocation::operator<(const SrcLocation& other) const {
49  // Translate filename stack into current files
50  std::string filename = getCurrentFilename(filenames);
51  std::string otherFilename = getCurrentFilename(other.filenames);
52 

References dirName(), and existFile().

Here is the call graph for this function:

◆ getEqConstraint()

BinaryConstraintOp souffle::getEqConstraint ( const std::string &  type)
inline

Definition at line 74 of file BinaryConstraintOps.h.

74  : return BinaryConstraintOp::EQ;
75  }
76 }
77 
78 inline BinaryConstraintOp getLessEqualConstraint(const std::string& type) {
79  switch (type[0]) {
80  case 'f': return BinaryConstraintOp::FLE;
81  case 'u': return BinaryConstraintOp::ULE;
82  case 'i': return BinaryConstraintOp::LE;

◆ getGreaterEqualConstraint()

BinaryConstraintOp souffle::getGreaterEqualConstraint ( const std::string &  type)
inline

Definition at line 94 of file BinaryConstraintOps.h.

94  : return BinaryConstraintOp::GE;
95  }
96 }
97 
98 inline BinaryConstraintOp getLessThanConstraint(const std::string& type) {
99  switch (type[0]) {
100  case 'f': return BinaryConstraintOp::FLT;
101  case 'u': return BinaryConstraintOp::ULT;
102  case 'i': return BinaryConstraintOp::LT;

◆ getGreaterThanConstraint()

BinaryConstraintOp souffle::getGreaterThanConstraint ( const std::string &  type)
inline

Definition at line 114 of file BinaryConstraintOps.h.

114  : return BinaryConstraintOp::GT;
115  }
116 }
117 
118 inline bool isEqConstraint(const BinaryConstraintOp constraintOp) {
119  switch (constraintOp) {
120  case BinaryConstraintOp::EQ:
121  case BinaryConstraintOp::FEQ: return true;
122  default: break;

◆ getIf()

template<typename C >
C::value_type souffle::getIf ( const C &  container,
std::function< bool(const typename C::value_type)>  pred 
)

Returns the first element in a container that satisfies a given predicate, nullptr otherwise.

Definition at line 101 of file ContainerUtil.h.

Referenced by souffle::ParserDriver::addFunctorDeclaration(), and souffle::ParserDriver::addType().

◆ getInstance()

souffle::SouffleProgram* souffle::getInstance ( const char *  p)
inline

◆ getLessEqualConstraint()

BinaryConstraintOp souffle::getLessEqualConstraint ( const std::string &  type)
inline

Definition at line 84 of file BinaryConstraintOps.h.

84  : return BinaryConstraintOp::LE;
85  }
86 }
87 
88 inline BinaryConstraintOp getGreaterEqualConstraint(const std::string& type) {
89  switch (type[0]) {
90  case 'f': return BinaryConstraintOp::FGE;
91  case 'u': return BinaryConstraintOp::UGE;
92  case 'i': return BinaryConstraintOp::GE;

◆ getLessThanConstraint()

BinaryConstraintOp souffle::getLessThanConstraint ( const std::string &  type)
inline

Definition at line 104 of file BinaryConstraintOps.h.

104  : return BinaryConstraintOp::LT;
105  }
106 }
107 
108 inline BinaryConstraintOp getGreaterThanConstraint(const std::string& type) {
109  switch (type[0]) {
110  case 'f': return BinaryConstraintOp::FGT;
111  case 'u': return BinaryConstraintOp::UGT;
112  case 'i': return BinaryConstraintOp::GT;

◆ getMaxOp()

FunctorOp souffle::getMaxOp ( const std::string &  type)

Definition at line 276 of file FunctorOps.cpp.

276  {
277  switch (type[0]) {
278  case 'f': return FunctorOp::FMAX;
279  case 'u': return FunctorOp::UMAX;
280  case 'i': return FunctorOp::MAX;
281  default: return FunctorOp::MAX;
282  }
283 }

References FMAX, MAX, and UMAX.

◆ getMinOp()

FunctorOp souffle::getMinOp ( const std::string &  type)

Given a type of an an attribute it returns the appropriate min/max functor operation.

Definition at line 267 of file FunctorOps.cpp.

267  {
268  switch (type[0]) {
269  case 'f': return FunctorOp::FMIN;
270  case 'u': return FunctorOp::UMIN;
271  case 'i': return FunctorOp::MIN;
272  default: return FunctorOp::MIN;
273  }
274 }

References FMIN, MIN, and UMIN.

◆ getOr()

template<typename C >
C::mapped_type const& souffle::getOr ( const C &  container,
typename C::key_type  key,
const typename C::mapped_type &  defaultValue 
)

Get value for a given key; if not found, return default value.

Definition at line 111 of file ContainerUtil.h.

111  {
112  return defaultValue;
113  }
114 }
115 
116 /**
117  * A utility function enabling the creation of a vector with a fixed set of
118  * elements within a single expression. This is the base case covering empty
119  * vectors.
120  */

Referenced by souffle::ReadFileCSV::ReadFileCSV(), and souffle::WriteFileCSV::writeNextTuple().

◆ getOutputLock()

Lock& souffle::getOutputLock ( )
inline

Obtains a reference to the lock synchronizing output operations.

Definition at line 568 of file ParallelUtil.h.

568  {
569  static Lock outputLock;
570  return outputLock;
571 }

Referenced by souffle::WriteCoutCSV::writeNextTuple().

◆ getRelationQualifierFromTag()

RelationQualifier souffle::getRelationQualifierFromTag ( const RelationTag tag)
inline

Get the corresponding RelationQualifier for a valid RelationTag.

Definition at line 95 of file RelationTag.h.

95  : return RelationQualifier::INLINE;
96  case RelationTag::MAGIC: return RelationQualifier::MAGIC;
97  case RelationTag::SUPPRESSED: return RelationQualifier::SUPPRESSED;
98  default: fatal("invalid relation tag");
99  }
100 }
101 
102 /**
103  * Get the corresponding RelationRepresentation for a valid RelationTag.
104  */
106  switch (tag) {

◆ getRelationRepresentationFromTag()

RelationRepresentation souffle::getRelationRepresentationFromTag ( const RelationTag tag)
inline

Get the corresponding RelationRepresentation for a valid RelationTag.

Definition at line 111 of file RelationTag.h.

116  {
117  switch (qualifier) {
118  case RelationTag::INPUT: return os << "input";
119  case RelationTag::OUTPUT: return os << "output";
120  case RelationTag::PRINTSIZE: return os << "printsize";

◆ getTypeAttributeAggregate()

TypeAttribute souffle::getTypeAttributeAggregate ( const AggregateOp  op)
inline

Get return type of the aggregate.

Definition at line 96 of file AggregateOp.h.

97  :
98  case AggregateOp::FMAX:
99  case AggregateOp::FMIN:
100  case AggregateOp::FSUM: return TypeAttribute::Float;
101 
102  case AggregateOp::UMAX:
103  case AggregateOp::UMIN:
104  case AggregateOp::USUM: return TypeAttribute::Unsigned;
105  }
106 
108 }
109 
110 inline bool isOverloadedAggregator(const AggregateOp op) {
111  switch (op) {
112  case AggregateOp::MAX:
113  case AggregateOp::MIN:
114  case AggregateOp::SUM: return true;

◆ identifier()

std::string souffle::identifier ( std::string  id)
inline

Valid C++ identifier, note that this does not ensure the uniqueness of identifiers returned.

Definition at line 387 of file StringUtil.h.

393  {
394  std::string result = inputString;

Referenced by souffle::ram::transform::MakeIndexTransformer::getExpressionPair().

◆ isA() [1/3]

template<typename B , typename A >
std::enable_if_t<std::is_base_of_v<A, B>, bool> souffle::isA ( A &  x)

Definition at line 184 of file MiscUtil.h.

192  {

◆ isA() [2/3]

template<typename B , typename A >
bool souffle::isA ( A *  x)

Checks if the object of type Source can be casted to type Destination.

Definition at line 179 of file MiscUtil.h.

◆ isA() [3/3]

template<typename B , typename A >
bool souffle::isA ( const std::unique_ptr< A > &  x)

Definition at line 189 of file MiscUtil.h.

192  {

References tinyformat::format().

Here is the call graph for this function:

◆ isEqConstraint()

bool souffle::isEqConstraint ( const BinaryConstraintOp  constraintOp)
inline

Definition at line 124 of file BinaryConstraintOps.h.

127  {
128  switch (constraintOp) {
129  case BinaryConstraintOp::LT:
130  case BinaryConstraintOp::GT:
131  case BinaryConstraintOp::ULT:

Referenced by souffle::ast::BindingStore::BindingStore(), souffle::ast::transform::ResolveAnonymousRecordAliasesTransformer::replaceUnnamedVariable(), and souffle::ast::transform::FoldAnonymousRecords::transformClause().

◆ isExecutable()

bool souffle::isExecutable ( const std::string &  name)
inline

Check whether a given file exists and it is an executable.

Definition at line 97 of file FileUtil.h.

98  {
99  // Check if name has path components in it and if so return it immediately

◆ isFunctorMultiResult()

bool souffle::isFunctorMultiResult ( FunctorOp  op)

Definition at line 247 of file FunctorOps.cpp.

247  {
248  auto&& xs = functorBuiltIn(op);
249  return xs.front().get().multipleResults;
250 }

References functorBuiltIn().

Here is the call graph for this function:

◆ isGreaterEqual()

bool souffle::isGreaterEqual ( const BinaryConstraintOp  constraintOp)
inline

Definition at line 217 of file BinaryConstraintOps.h.

225  {

◆ isGreaterThan()

bool souffle::isGreaterThan ( const BinaryConstraintOp  constraintOp)
inline

Definition at line 197 of file BinaryConstraintOps.h.

201  {
202  switch (constraintOp) {
203  case BinaryConstraintOp::LE:
204  case BinaryConstraintOp::ULE:
205  case BinaryConstraintOp::FLE: return true;

◆ isInfixFunctorOp() [1/3]

bool souffle::isInfixFunctorOp ( const BinaryConstraintOp  op)
inline

Determines whether a functor should be written using infix notation (e.g.

a + b + c) or prefix notation (e.g. +(a,b,c))

Definition at line 425 of file BinaryConstraintOps.h.

426  : return true;
427  }
428 }
429 
430 /**
431  * Get type binary constraint operates on.
432  **/
433 inline std::vector<TypeAttribute> getBinaryConstraintTypes(const BinaryConstraintOp op) {
434  // clang-format off

◆ isInfixFunctorOp() [2/3]

bool souffle::isInfixFunctorOp ( const FunctorOp  op)

Definition at line 262 of file FunctorOps.cpp.

262  {
263  auto&& xs = functorBuiltIn(op);
264  return isInfixFunctorOp(xs.front().get().symbol);
265 }

References functorBuiltIn(), and isInfixFunctorOp().

Here is the call graph for this function:

◆ isInfixFunctorOp() [3/3]

bool souffle::isInfixFunctorOp ( std::string_view  symbol)

Determines whether a functor should be written using infix notation (e.g.

a + b + c) or prefix notation (e.g. +(a,b,c))

Generally follow Haskell convention: functions w/ symbolic names are infix, otherwise prefix. NOTE: The surface syntax occasionally uses alpha infix operators For backwards compatibility we translate these into symbolic ops.

Definition at line 252 of file FunctorOps.cpp.

252  {
253  assert(!symbol.empty() && "no functors have an empty name");
254  // arithmetic/bitwise/logical negation are prefix ops
255  if (symbol == FUNCTOR_INTRINSIC_PREFIX_NEGATE_NAME) return false;
256  if (symbol == "!") return false;
257  if (symbol == "~") return false;
258  auto alphaUnderscore = symbol == "_" || isalpha(symbol.at(0));
259  return !alphaUnderscore;
260 }

References FUNCTOR_INTRINSIC_PREFIX_NEGATE_NAME.

Referenced by isInfixFunctorOp(), and souffle::ast::analysis::TypeConstraintsAnalysis::visitFunctor().

◆ isLessEqual()

bool souffle::isLessEqual ( const BinaryConstraintOp  constraintOp)
inline

Definition at line 207 of file BinaryConstraintOps.h.

211  {
212  switch (constraintOp) {
213  case BinaryConstraintOp::GE:
214  case BinaryConstraintOp::UGE:
215  case BinaryConstraintOp::FGE: return true;

◆ isLessThan()

bool souffle::isLessThan ( const BinaryConstraintOp  constraintOp)
inline

Definition at line 187 of file BinaryConstraintOps.h.

191  {
192  switch (constraintOp) {
193  case BinaryConstraintOp::GT:
194  case BinaryConstraintOp::UGT:
195  case BinaryConstraintOp::FGT: return true;

◆ isNumber()

bool souffle::isNumber ( const char *  str)
inline

Check whether a string is a sequence of digits.

Definition at line 217 of file StringUtil.h.

217  {
218  return false;
219  }
220  str++;
221  }
222  return true;
223 }
224 
225 /**
226  * A generic function converting strings into strings (trivial case).
227  */
228 inline const std::string& toString(const std::string& str) {
229  return str;

Referenced by main().

◆ isOrderedBinaryConstraintOp()

bool souffle::isOrderedBinaryConstraintOp ( const BinaryConstraintOp  op)
inline

Determines whether arguments of constraint are orderable.

Definition at line 389 of file BinaryConstraintOps.h.

389  :
390  case BinaryConstraintOp::ULT:
391  case BinaryConstraintOp::FLT:
392  case BinaryConstraintOp::LE:
393  case BinaryConstraintOp::ULE:
394  case BinaryConstraintOp::FLE:
395  case BinaryConstraintOp::GE:
396  case BinaryConstraintOp::UGE:
397  case BinaryConstraintOp::FGE:
398  case BinaryConstraintOp::GT:
399  case BinaryConstraintOp::UGT:
400  case BinaryConstraintOp::FGT:
401  case BinaryConstraintOp::SLT:
402  case BinaryConstraintOp::SLE:
403  case BinaryConstraintOp::SGE:
404  case BinaryConstraintOp::SGT: return true;
405 
406  case BinaryConstraintOp::MATCH:
407  case BinaryConstraintOp::NOT_MATCH:
408  case BinaryConstraintOp::CONTAINS:
409  case BinaryConstraintOp::NOT_CONTAINS: return false;
410  }
411 
413 }
414 
415 /**
416  * Determines whether a functor should be written using infix notation (e.g. `a + b + c`)
417  * or prefix notation (e.g. `+(a,b,c)`)
418  */
419 inline bool isInfixFunctorOp(const BinaryConstraintOp op) {

◆ isOverloaded()

bool souffle::isOverloaded ( const BinaryConstraintOp  constraintOp)
inline

Utility function, informing whether constraint is overloaded.

Only the signed version's are treated as overloaded (as they are returned by the parser).

Definition at line 231 of file BinaryConstraintOps.h.

231  :
232  case BinaryConstraintOp::GE: return true;
233  default: break;
234  }
235  return false;
236 }
237 
238 /**
239  * Convert Constraint to work with requested type.
240  * Example: constraintOp = LT, toType = Float -> FLT (less-than working on floats).
241  */

◆ isOverloadedAggregator()

bool souffle::isOverloadedAggregator ( const AggregateOp  op)
inline

Definition at line 116 of file AggregateOp.h.

116  :
117  case AggregateOp::COUNT: return false;
118 
119  default: return false;
120  }
121 }
122 
123 /**
124  * Convert aggregator to a give type.
125  * Eg. sum, float → fsum.
126  **/

◆ isOverloadedFunctor()

bool souffle::isOverloadedFunctor ( std::string_view  symbol)

Indicate whether a functor is overloaded.

At the moment, the signed versions are treated as representatives (because parser always returns a signed version).

◆ isPrefix()

bool souffle::isPrefix ( const std::string &  prefix,
const std::string &  element 
)
inline

Determine if one string is a prefix of another.

Definition at line 292 of file StringUtil.h.

305  {

Referenced by RamUnsignedFromString().

◆ isRelationQualifierTag()

bool souffle::isRelationQualifierTag ( const RelationTag tag)
inline

Check if a given relation tag is a relation qualifier.

Definition at line 79 of file RelationTag.h.

79  :
80  case RelationTag::MAGIC:
81  case RelationTag::SUPPRESSED: return true;
82  default: return false;
83  }
84 }
85 
86 /**
87  * Get the corresponding RelationQualifier for a valid RelationTag.
88  */
90  switch (tag) {

◆ isRelationRepresentationTag()

bool souffle::isRelationRepresentationTag ( const RelationTag tag)
inline

Check if a given relation tag sets a relation representation.

Definition at line 67 of file RelationTag.h.

73  {
74  switch (tag) {

◆ isStrictIneqConstraint()

bool souffle::isStrictIneqConstraint ( const BinaryConstraintOp  constraintOp)
inline

Definition at line 133 of file BinaryConstraintOps.h.

133  :
134  case BinaryConstraintOp::FGT: return true;
135  default: break;
136  }
137  return false;
138 }
139 
140 inline bool isWeakIneqConstraint(const BinaryConstraintOp constraintOp) {
141  switch (constraintOp) {
142  case BinaryConstraintOp::LE:
143  case BinaryConstraintOp::GE:
144  case BinaryConstraintOp::ULE:

◆ isValidFunctorOpArity()

bool souffle::isValidFunctorOpArity ( std::string_view  symbol,
size_t  arity 
)

Definition at line 240 of file FunctorOps.cpp.

240  {
241  return any_of(FUNCTOR_INTRINSICS, [&](auto&& x) {
242  auto arityOk = x.params.size() == arity || x.variadic;
243  return x.symbol == symbol && arityOk;
244  });
245 }

References any_of().

Here is the call graph for this function:

◆ isWeakIneqConstraint()

bool souffle::isWeakIneqConstraint ( const BinaryConstraintOp  constraintOp)
inline

Definition at line 146 of file BinaryConstraintOps.h.

146  :
147  case BinaryConstraintOp::FGE: return true;
148  default: break;
149  }
150  return false;
151 }
152 
154  assert(isStrictIneqConstraint(constraintOp));
155  switch (constraintOp) {
156  case BinaryConstraintOp::LT: return BinaryConstraintOp::LE;
157  case BinaryConstraintOp::GT: return BinaryConstraintOp::GE;

◆ join() [1/5]

template<typename Container , typename Printer , typename Iter = typename Container::const_iterator>
detail::joined_sequence<Iter, Printer> souffle::join ( const Container &  c,
const std::string &  sep,
const Printer &  p 
)

Creates an object to be forwarded to some output stream for printing the content of containers interspersed by a given separator.

For use cases see the test case {util_test.cpp}.

Definition at line 199 of file StreamUtil.h.

◆ join() [2/5]

template<typename Container , typename Iter = typename Container::const_iterator, typename T = typename std::iterator_traits<Iter>::value_type>
std::enable_if_t<!JoinShouldDeref<T>, detail::joined_sequence<Iter, detail::print<id<T> > > > souffle::join ( const Container &  c,
const std::string &  sep = "," 
)

Creates an object to be forwarded to some output stream for printing the content of containers interspersed by a given separator.

For use cases see the test case {util_test.cpp}.

Definition at line 216 of file StreamUtil.h.

218  {
219  return join(c.begin(), c.end(), sep, detail::print<deref<T>>());

References join().

Here is the call graph for this function:

◆ join() [3/5]

template<typename Container , typename Iter = typename Container::const_iterator, typename T = typename std::iterator_traits<Iter>::value_type>
std::enable_if_t<JoinShouldDeref<T>, detail::joined_sequence<Iter, detail::print<deref<T> > > > souffle::join ( const Container &  c,
const std::string &  sep = "," 
)

Definition at line 223 of file StreamUtil.h.

226  {

◆ join() [4/5]

template<typename Iter , typename Printer >
detail::joined_sequence<Iter, Printer> souffle::join ( const Iter &  a,
const Iter &  b,
const std::string &  sep,
const Printer &  p 
)

◆ join() [5/5]

template<typename Iter , typename T = typename Iter::value_type>
detail::joined_sequence<Iter, detail::print<id<T> > > souffle::join ( const Iter &  a,
const Iter &  b,
const std::string &  sep = "," 
)

Creates an object to be forwarded to some output stream for printing sequences of elements interspersed by a given separator.

For use cases see the test case {util_test.cpp}.

Definition at line 187 of file StreamUtil.h.

190  {util_test.cpp}.

References join(), and p.

Here is the call graph for this function:

◆ main()

int souffle::main ( int  argc,
char **  argv 
)

Ensure that code generation is enabled if using SWIG interface option.

Definition at line 191 of file main.cpp.

191  {
192  std::stringstream header;
193  header << "============================================================================" << std::endl;
194  header << "souffle -- A datalog engine." << std::endl;
195  header << "Usage: souffle [OPTION] FILE." << std::endl;
196  header << "----------------------------------------------------------------------------" << std::endl;
197  header << "Options:" << std::endl;
198 
199  std::stringstream footer;
200  footer << "----------------------------------------------------------------------------" << std::endl;
201  footer << "Version: " << PACKAGE_VERSION << "" << std::endl;
202  footer << "----------------------------------------------------------------------------" << std::endl;
203  footer << "Copyright (c) 2016-20 The Souffle Developers." << std::endl;
204  footer << "Copyright (c) 2013-16 Oracle and/or its affiliates." << std::endl;
205  footer << "All rights reserved." << std::endl;
206  footer << "============================================================================" << std::endl;
207 
208  // command line options, the environment will be filled with the arguments passed to them, or
209  // the empty string if they take none
210  // main option, the datalog program itself, has an empty key
211  std::vector<MainOption> options{{"", 0, "", "", false, ""},
212  {"fact-dir", 'F', "DIR", ".", false, "Specify directory for fact files."},
213  {"include-dir", 'I', "DIR", ".", true, "Specify directory for include files."},
214  {"output-dir", 'D', "DIR", ".", false,
215  "Specify directory for output files. If <DIR> is `-` then stdout is used."},
216  {"jobs", 'j', "N", "1", false,
217  "Run interpreter/compiler in parallel using N threads, N=auto for system "
218  "default."},
219  {"compile", 'c', "", "", false,
220  "Generate C++ source code, compile to a binary executable, then run this "
221  "executable."},
222  {"generate", 'g', "FILE", "", false,
223  "Generate C++ source code for the given Datalog program and write it to "
224  "<FILE>. If <FILE> is `-` then stdout is used."},
225  {"swig", 's', "LANG", "", false,
226  "Generate SWIG interface for given language. The values <LANG> accepts is java and "
227  "python. "},
228  {"library-dir", 'L', "DIR", "", false, "Specify directory for library files."},
229  {"libraries", 'l', "FILE", "", false, "Specify libraries."},
230  {"no-warn", 'w', "", "", false, "Disable warnings."},
231  {"magic-transform", 'm', "RELATIONS", "", false,
232  "Enable magic set transformation changes on the given relations, use '*' "
233  "for all."},
234  {"macro", 'M', "MACROS", "", false, "Set macro definitions for the pre-processor"},
235  {"disable-transformers", 'z', "TRANSFORMERS", "", false,
236  "Disable the given AST transformers."},
237  {"dl-program", 'o', "FILE", "", false,
238  "Generate C++ source code, written to <FILE>, and compile this to a "
239  "binary executable (without executing it)."},
240  {"live-profile", '\2', "", "", false, "Enable live profiling."},
241  {"profile", 'p', "FILE", "", false, "Enable profiling, and write profile data to <FILE>."},
242  {"profile-use", 'u', "FILE", "", false,
243  "Use profile log-file <FILE> for profile-guided optimization."},
244  {"debug-report", 'r', "FILE", "", false, "Write HTML debug report to <FILE>."},
245  {"pragma", 'P', "OPTIONS", "", false, "Set pragma options."},
246  {"provenance", 't', "[ none | explain | explore ]", "", false,
247  "Enable provenance instrumentation and interaction."},
248  {"verbose", 'v', "", "", false, "Verbose output."},
249  {"version", '\3', "", "", false, "Version."},
250  {"show", '\4',
251  "[ parse-errors | precedence-graph | scc-graph | transformed-datalog | "
252  "transformed-ram | type-analysis ]",
253  "", false, "Print selected program information."},
254  {"parse-errors", '\5', "", "", false, "Show parsing errors, if any, then exit."},
255  {"help", 'h', "", "", false, "Display this help message."},
256  {"legacy", '\6', "", "", false, "Enable legacy support."}};
257  Global::config().processArgs(argc, argv, header.str(), footer.str(), options);
258 
259  // ------ command line arguments -------------
260 
261  // Take in pragma options from the command line
262  if (Global::config().has("pragma")) {
263  std::vector<std::string> configOptions = splitString(Global::config().get("pragma"), ';');
264  for (const std::string& option : configOptions) {
265  size_t splitPoint = option.find(':');
266 
267  std::string optionName = option.substr(0, splitPoint);
268  std::string optionValue = (splitPoint == std::string::npos)
269  ? ""
270  : option.substr(splitPoint + 1, option.length());
271 
272  if (!Global::config().has(optionName)) {
273  Global::config().set(optionName, optionValue);
274  }
275  }
276  }
277 
278  /* for the version option, if given print the version text then exit */
279  if (Global::config().has("version")) {
280  std::cout << "Souffle: " << PACKAGE_VERSION;
281  std::cout << "(" << RAM_DOMAIN_SIZE << "bit Domains)";
282  std::cout << std::endl;
283  std::cout << "Copyright (c) 2016-19 The Souffle Developers." << std::endl;
284  std::cout << "Copyright (c) 2013-16 Oracle and/or its affiliates." << std::endl;
285  return 0;
286  }
287  Global::config().set("version", PACKAGE_VERSION);
288 
289  /* for the help option, if given simply print the help text then exit */
290  if (!Global::config().has("") || Global::config().has("help")) {
291  std::cout << Global::config().help();
292  return 0;
293  }
294 
295  /* check that datalog program exists */
296  if (!existFile(Global::config().get(""))) {
297  throw std::runtime_error("cannot open file " + std::string(Global::config().get("")));
298  }
299 
300  /* for the jobs option, to determine the number of threads used */
301 #ifdef _OPENMP
302  if (isNumber(Global::config().get("jobs").c_str())) {
303  if (std::stoi(Global::config().get("jobs")) < 1) {
304  throw std::runtime_error("-j/--jobs may only be set to 'auto' or an integer greater than 0.");
305  }
306  } else {
307  if (!Global::config().has("jobs", "auto")) {
308  throw std::runtime_error("-j/--jobs may only be set to 'auto' or an integer greater than 0.");
309  }
310  Global::config().set("jobs", "0");
311  }
312 #else
313  // Check that -j option has not been changed from the default
314  if (Global::config().get("jobs") != "1" && !Global::config().has("no-warn")) {
315  std::cerr << "\nThis installation of Souffle does not support concurrent jobs.\n";
316  }
317 #endif
318 
319  /* if an output directory is given, check it exists */
320  if (Global::config().has("output-dir") && !Global::config().has("output-dir", "-") &&
321  !existDir(Global::config().get("output-dir")) &&
322  !(Global::config().has("generate") ||
323  (Global::config().has("dl-program") && !Global::config().has("compile")))) {
324  throw std::runtime_error(
325  "output directory " + Global::config().get("output-dir") + " does not exists");
326  }
327 
328  /* collect all input directories for the c pre-processor */
329  if (Global::config().has("include-dir")) {
330  std::string currentInclude = "";
331  std::string allIncludes = "";
332  for (const char& ch : Global::config().get("include-dir")) {
333  if (ch == ' ') {
334  if (!existDir(currentInclude)) {
335  throw std::runtime_error("include directory " + currentInclude + " does not exists");
336  } else {
337  allIncludes += " -I";
338  allIncludes += currentInclude;
339  currentInclude = "";
340  }
341  } else {
342  currentInclude += ch;
343  }
344  }
345  allIncludes += " -I" + currentInclude;
346  Global::config().set("include-dir", allIncludes);
347  }
348 
349  /* collect all macro definitions for the pre-processor */
350  if (Global::config().has("macro")) {
351  std::string currentMacro = "";
352  std::string allMacros = "";
353  for (const char& ch : Global::config().get("macro")) {
354  if (ch == ' ') {
355  allMacros += " -D";
356  allMacros += currentMacro;
357  currentMacro = "";
358  } else {
359  currentMacro += ch;
360  }
361  }
362  allMacros += " -D" + currentMacro;
363  Global::config().set("macro", allMacros);
364  }
365 
366  /* turn on compilation of executables */
367  if (Global::config().has("dl-program")) {
368  Global::config().set("compile");
369  }
370 
371  if (Global::config().has("live-profile") && !Global::config().has("profile")) {
372  Global::config().set("profile");
373  }
374  } catch (std::exception& e) {
375  std::cerr << e.what() << std::endl;
376  exit(EXIT_FAILURE);
377  }
378 
379  /**
380  * Ensure that code generation is enabled if using SWIG interface option.
381  */
382  if (Global::config().has("swig") && !Global::config().has("generate")) {
383  Global::config().set("generate", simpleName(Global::config().get("")));
384  }
385 
386  // ------ start souffle -------------
387 
388  std::string souffleExecutable = which(argv[0]);
389 
390  if (souffleExecutable.empty()) {
391  throw std::runtime_error("failed to determine souffle executable path");
392  }
393 
394  /* Create the pipe to establish a communication between cpp and souffle */
395  std::string cmd = ::which("mcpp");
396 
397  if (!isExecutable(cmd)) {
398  throw std::runtime_error("failed to locate mcpp pre-processor");
399  }
400 
401  cmd += " -e utf8 -W0 " + Global::config().get("include-dir");
402  if (Global::config().has("macro")) {
403  cmd += " " + Global::config().get("macro");
404  }
405  // Add RamDomain size as a macro
406  cmd += " -DRAM_DOMAIN_SIZE=" + std::to_string(RAM_DOMAIN_SIZE);
407  cmd += " " + Global::config().get("");
408  FILE* in = popen(cmd.c_str(), "r");
409 
410  /* Time taking for parsing */
411  auto parser_start = std::chrono::high_resolution_clock::now();
412 
413  // ------- parse program -------------
414 
415  // parse file
416  ErrorReport errReport(Global::config().has("no-warn"));
417  DebugReport debugReport;
418  Own<ast::TranslationUnit> astTranslationUnit =
419  ParserDriver::parseTranslationUnit("<stdin>", in, errReport, debugReport);
420 
421  // close input pipe
422  int preprocessor_status = pclose(in);
423  if (preprocessor_status == -1) {
424  perror(nullptr);
425  throw std::runtime_error("failed to close pre-processor pipe");
426  }
427 
428  /* Report run-time of the parser if verbose flag is set */
429  if (Global::config().has("verbose")) {
430  auto parser_end = std::chrono::high_resolution_clock::now();
431  std::cout << "Parse Time: " << std::chrono::duration<double>(parser_end - parser_start).count()
432  << "sec\n";
433  }
434 
435  if (Global::config().get("show") == "parse-errors") {
436  std::cout << astTranslationUnit->getErrorReport();
437  return astTranslationUnit->getErrorReport().getNumErrors();
438  }
439 
440  // ------- check for parse errors -------------
441  astTranslationUnit->getErrorReport().exitIfErrors();
442 
443  // ------- rewriting / optimizations -------------
444 
445  /* set up additional global options based on pragma declaratives */
446  (mk<ast::transform::PragmaChecker>())->apply(*astTranslationUnit);
447 
448  /* construct the transformation pipeline */
449 
450  // Equivalence pipeline
451  auto equivalencePipeline =
452  mk<ast::transform::PipelineTransformer>(mk<ast::transform::NameUnnamedVariablesTransformer>(),
453  mk<ast::transform::FixpointTransformer>(mk<ast::transform::MinimiseProgramTransformer>()),
454  mk<ast::transform::ReplaceSingletonVariablesTransformer>(),
455  mk<ast::transform::RemoveRelationCopiesTransformer>(),
456  mk<ast::transform::RemoveEmptyRelationsTransformer>(),
457  mk<ast::transform::RemoveRedundantRelationsTransformer>());
458 
459  // Magic-Set pipeline
460  auto magicPipeline = mk<ast::transform::PipelineTransformer>(mk<ast::transform::MagicSetTransformer>(),
461  mk<ast::transform::ResolveAliasesTransformer>(),
462  mk<ast::transform::RemoveRelationCopiesTransformer>(),
463  mk<ast::transform::RemoveEmptyRelationsTransformer>(),
464  mk<ast::transform::RemoveRedundantRelationsTransformer>(), souffle::clone(equivalencePipeline));
465 
466  // Partitioning pipeline
467  auto partitionPipeline =
468  mk<ast::transform::PipelineTransformer>(mk<ast::transform::NameUnnamedVariablesTransformer>(),
469  mk<ast::transform::PartitionBodyLiteralsTransformer>(),
470  mk<ast::transform::ReplaceSingletonVariablesTransformer>());
471 
472  // Provenance pipeline
473  auto provenancePipeline = mk<ast::transform::ConditionalTransformer>(
474  Global::config().has("provenance"), mk<ast::transform::ProvenanceTransformer>());
475 
476  // Main pipeline
477  auto pipeline = mk<ast::transform::PipelineTransformer>(mk<ast::transform::ComponentChecker>(),
478  mk<ast::transform::ComponentInstantiationTransformer>(),
479  mk<ast::transform::IODefaultsTransformer>(),
480  mk<ast::transform::SimplifyAggregateTargetExpressionTransformer>(),
481  mk<ast::transform::UniqueAggregationVariablesTransformer>(),
482  mk<ast::transform::FixpointTransformer>(mk<ast::transform::PipelineTransformer>(
483  mk<ast::transform::ResolveAnonymousRecordAliasesTransformer>(),
484  mk<ast::transform::FoldAnonymousRecords>())),
485  mk<ast::transform::SemanticChecker>(), mk<ast::transform::GroundWitnessesTransformer>(),
486  mk<ast::transform::UniqueAggregationVariablesTransformer>(),
487  mk<ast::transform::NormaliseMultiResultFunctorsTransformer>(),
488  mk<ast::transform::MaterializeSingletonAggregationTransformer>(),
489  mk<ast::transform::FixpointTransformer>(
490  mk<ast::transform::MaterializeAggregationQueriesTransformer>()),
491  mk<ast::transform::ResolveAliasesTransformer>(),
492  mk<ast::transform::RemoveBooleanConstraintsTransformer>(),
493  mk<ast::transform::ResolveAliasesTransformer>(), mk<ast::transform::MinimiseProgramTransformer>(),
494  mk<ast::transform::InlineRelationsTransformer>(), mk<ast::transform::GroundedTermsChecker>(),
495  mk<ast::transform::ResolveAliasesTransformer>(),
496  mk<ast::transform::RemoveRedundantRelationsTransformer>(),
497  mk<ast::transform::RemoveRelationCopiesTransformer>(),
498  mk<ast::transform::RemoveEmptyRelationsTransformer>(),
499  mk<ast::transform::ReplaceSingletonVariablesTransformer>(),
500  mk<ast::transform::FixpointTransformer>(mk<ast::transform::PipelineTransformer>(
501  mk<ast::transform::ReduceExistentialsTransformer>(),
502  mk<ast::transform::RemoveRedundantRelationsTransformer>())),
503  mk<ast::transform::RemoveRelationCopiesTransformer>(), std::move(partitionPipeline),
504  std::move(equivalencePipeline), mk<ast::transform::RemoveRelationCopiesTransformer>(),
505  std::move(magicPipeline), mk<ast::transform::ReorderLiteralsTransformer>(),
506  mk<ast::transform::RemoveRedundantSumsTransformer>(),
507  mk<ast::transform::RemoveEmptyRelationsTransformer>(),
508  mk<ast::transform::AddNullariesToAtomlessAggregatesTransformer>(),
509  mk<ast::transform::ReorderLiteralsTransformer>(), mk<ast::transform::ExecutionPlanChecker>(),
510  std::move(provenancePipeline), mk<ast::transform::IOAttributesTransformer>());
511 
512  // Disable unwanted transformations
513  if (Global::config().has("disable-transformers")) {
514  std::vector<std::string> givenTransformers =
515  splitString(Global::config().get("disable-transformers"), ',');
516  pipeline->disableTransformers(
517  std::set<std::string>(givenTransformers.begin(), givenTransformers.end()));
518  }
519 
520  // Set up the debug report if necessary
521  if (Global::config().has("debug-report")) {
522  auto parser_end = std::chrono::high_resolution_clock::now();
523  std::stringstream ss;
524 
525  // Add current time
526  std::time_t time = std::time(nullptr);
527  ss << "Executed at ";
528  ss << std::put_time(std::localtime(&time), "%F %T") << "\n";
529 
530  // Add config
531  ss << "(\n";
532  ss << join(Global::config().data(), ",\n", [](std::ostream& out, const auto& arg) {
533  out << " \"" << arg.first << "\" -> \"" << arg.second << '"';
534  });
535  ss << "\n)";
536 
537  debugReport.addSection("Configuration", "Configuration", ss.str());
538 
539  // Add parsing runtime
540  std::string runtimeStr =
541  "(" + std::to_string(std::chrono::duration<double>(parser_end - parser_start).count()) + "s)";
542  debugReport.addSection("Parsing", "Parsing " + runtimeStr, "");
543 
544  pipeline->setDebugReport();
545  }
546 
547  // Toggle pipeline verbosity
548  pipeline->setVerbosity(Global::config().has("verbose"));
549 
550  // Apply all the transformations
551  pipeline->apply(*astTranslationUnit);
552 
553  if (Global::config().has("show")) {
554  // Output the transformed datalog and return
555  if (Global::config().get("show") == "transformed-datalog") {
556  std::cout << astTranslationUnit->getProgram() << std::endl;
557  return 0;
558  }
559 
560  // Output the precedence graph in graphviz dot format and return
561  if (Global::config().get("show") == "precedence-graph") {
562  astTranslationUnit->getAnalysis<ast::analysis::PrecedenceGraphAnalysis>()->print(std::cout);
563  std::cout << std::endl;
564  return 0;
565  }
566 
567  // Output the scc graph in graphviz dot format and return
568  if (Global::config().get("show") == "scc-graph") {
569  astTranslationUnit->getAnalysis<ast::analysis::SCCGraphAnalysis>()->print(std::cout);
570  std::cout << std::endl;
571  return 0;
572  }
573 
574  // Output the type analysis
575  if (Global::config().get("show") == "type-analysis") {
576  astTranslationUnit->getAnalysis<ast::analysis::TypeAnalysis>()->print(std::cout);
577  std::cout << std::endl;
578  return 0;
579  }
580  }
581 
582  // ------- execution -------------
583  /* translate AST to RAM */
584  debugReport.startSection();
585  auto ramTranslationUnit = ast2ram::AstToRamTranslator().translateUnit(*astTranslationUnit);
586  debugReport.endSection("ast-to-ram", "Translate AST to RAM");
587 
588  // Apply RAM transforms
589  {
590  using namespace ram::transform;
591  Own<Transformer> ramTransform = mk<TransformerSequence>(
592  mk<LoopTransformer>(mk<TransformerSequence>(mk<ExpandFilterTransformer>(),
593  mk<HoistConditionsTransformer>(), mk<MakeIndexTransformer>())),
594  mk<LoopTransformer>(mk<IndexedInequalityTransformer>()), mk<IfConversionTransformer>(),
595  mk<ChoiceConversionTransformer>(), mk<CollapseFiltersTransformer>(), mk<TupleIdTransformer>(),
596  mk<LoopTransformer>(
597  mk<TransformerSequence>(mk<HoistAggregateTransformer>(), mk<TupleIdTransformer>())),
598  mk<ExpandFilterTransformer>(), mk<HoistConditionsTransformer>(),
599  mk<CollapseFiltersTransformer>(), mk<EliminateDuplicatesTransformer>(),
600  mk<ReorderConditionsTransformer>(), mk<LoopTransformer>(mk<ReorderFilterBreak>()),
601  mk<ConditionalTransformer>(
602  // job count of 0 means all cores are used.
603  []() -> bool { return std::stoi(Global::config().get("jobs")) != 1; },
604  mk<ParallelTransformer>()),
605  mk<ReportIndexTransformer>());
606 
607  ramTransform->apply(*ramTranslationUnit);
608  }
609 
610  if (ramTranslationUnit->getErrorReport().getNumIssues() != 0) {
611  std::cerr << ramTranslationUnit->getErrorReport();
612  }
613 
614  // Output the transformed RAM program and return
615  if (Global::config().get("show") == "transformed-ram") {
616  std::cout << ramTranslationUnit->getProgram();
617  return 0;
618  }
619 
620  try {
621  if (!Global::config().has("compile") && !Global::config().has("dl-program") &&
622  !Global::config().has("generate") && !Global::config().has("swig")) {
623  // ------- interpreter -------------
624 
625  std::thread profiler;
626  // Start up profiler if needed
627  if (Global::config().has("live-profile") && !Global::config().has("compile")) {
628  profiler = std::thread([]() { profile::Tui().runProf(); });
629  }
630 
631  // configure and execute interpreter
632  Own<interpreter::Engine> interpreter(mk<interpreter::Engine>(*ramTranslationUnit));
633  interpreter->executeMain();
634  // If the profiler was started, join back here once it exits.
635  if (profiler.joinable()) {
636  profiler.join();
637  }
638  if (Global::config().has("provenance")) {
639  // only run explain interface if interpreted
640  interpreter::ProgInterface interface(*interpreter);
641  if (Global::config().get("provenance") == "explain") {
642  explain(interface, false);
643  } else if (Global::config().get("provenance") == "explore") {
644  explain(interface, true);
645  }
646  }
647  } else {
648  // ------- compiler -------------
649  auto synthesiser = mk<synthesiser::Synthesiser>(*ramTranslationUnit);
650 
651  // Find the base filename for code generation and execution
652  std::string baseFilename;
653  if (Global::config().has("dl-program")) {
654  baseFilename = Global::config().get("dl-program");
655  } else if (Global::config().has("generate")) {
656  baseFilename = Global::config().get("generate");
657 
658  // trim .cpp extension if it exists
659  if (baseFilename.size() >= 4 && baseFilename.substr(baseFilename.size() - 4) == ".cpp") {
660  baseFilename = baseFilename.substr(0, baseFilename.size() - 4);
661  }
662  } else {
663  baseFilename = tempFile();
664  }
665  if (baseName(baseFilename) == "/" || baseName(baseFilename) == ".") {
666  baseFilename = tempFile();
667  }
668 
669  std::string baseIdentifier = identifier(simpleName(baseFilename));
670  std::string sourceFilename = baseFilename + ".cpp";
671 
672  bool withSharedLibrary;
673  const bool emitToStdOut = Global::config().has("generate", "-");
674  if (emitToStdOut)
675  synthesiser->generateCode(std::cout, baseIdentifier, withSharedLibrary);
676  else {
677  std::ofstream os{sourceFilename};
678  synthesiser->generateCode(os, baseIdentifier, withSharedLibrary);
679  }
680 
681  if (withSharedLibrary) {
682  if (!Global::config().has("libraries")) {
683  Global::config().set("libraries", "functors");
684  }
685  if (!Global::config().has("library-dir")) {
686  Global::config().set("library-dir", ".");
687  }
688  }
689 
690  auto findCompileCmd = [&] {
691  auto cmd = ::findTool("souffle-compile", souffleExecutable, ".");
692  /* Fail if a souffle-compile executable is not found */
693  if (!isExecutable(cmd)) {
694  throw std::runtime_error("failed to locate souffle-compile");
695  }
696  return cmd;
697  };
698 
699  if (Global::config().has("swig")) {
700  auto compileCmd = findCompileCmd() + " -s " + Global::config().get("swig") + " ";
701  compileToBinary(compileCmd, sourceFilename);
702  } else if (Global::config().has("compile")) {
704  compileToBinary(findCompileCmd(), sourceFilename);
705  /* Report overall run-time in verbose mode */
706  if (Global::config().has("verbose")) {
708  std::cout << "Compilation Time: " << std::chrono::duration<double>(end - start).count()
709  << "sec\n";
710  }
711  // run compiled C++ program if requested.
712  if (!Global::config().has("dl-program") && !Global::config().has("swig")) {
713  executeBinary(baseFilename);
714  }
715  }
716  }
717  } catch (std::exception& e) {
718  std::cerr << e.what() << std::endl;
719  std::exit(EXIT_FAILURE);
720  }
721 
722  /* Report overall run-time in verbose mode */
723  if (Global::config().has("verbose")) {
724  auto souffle_end = std::chrono::high_resolution_clock::now();
725  std::cout << "Total Time: " << std::chrono::duration<double>(souffle_end - souffle_start).count()
726  << "sec\n";
727  }
728 
729  return 0;
730 }
731 
732 } // end of namespace souffle
733 
734 int main(int argc, char** argv) {
735  return souffle::main(argc, argv);
736 }

References souffle::Global::config(), existDir(), existFile(), TCB_SPAN_NAMESPACE_NAME::get(), souffle::MainConfig::help(), isNumber(), PACKAGE_VERSION, souffle::MainConfig::processArgs(), RAM_DOMAIN_SIZE, and splitString().

Referenced by main().

Here is the call graph for this function:

◆ make_range()

template<typename Iter >
range<Iter> souffle::make_range ( const Iter &  a,
const Iter &  b 
)

A utility function enabling the construction of ranges without explicitly specifying the iterator type.

Template Parameters
Iter.. the iterator type
Parameters
a.. the lower boundary
b.. the upper boundary

Definition at line 389 of file ContainerUtil.h.

398  {

Referenced by souffle::EquivalenceRelation< Arity >::closure(), souffle::EquivalenceRelation< Arity >::getBoundaries(), and souffle::EquivalenceRelation< Arity >::partition().

◆ map()

template<typename A , typename F >
auto souffle::map ( const std::vector< A > &  xs,
F &&  f 
)

◆ mk()

template<typename A , typename B = A, typename... Args>
Own<A> souffle::mk ( Args &&...  xs)

Definition at line 48 of file ContainerUtil.h.

51  {

References souffle::reverse< A >::begin(), souffle::reverse< A >::iterable, and souffle::reverse< A >::reverse().

Here is the call graph for this function:

◆ negatedConstraintOp()

BinaryConstraintOp souffle::negatedConstraintOp ( const BinaryConstraintOp  op)
inline

Negated Constraint Operator Each operator requires a negated operator which is necessary for the expansion of complex rule bodies with disjunction and negation.

Definition at line 297 of file BinaryConstraintOps.h.

298  : return BinaryConstraintOp::GE;
299  case BinaryConstraintOp::ULT: return BinaryConstraintOp::UGE;
300  case BinaryConstraintOp::FLT: return BinaryConstraintOp::FGE;
301  case BinaryConstraintOp::SLT: return BinaryConstraintOp::SGE;
302 
303  case BinaryConstraintOp::LE: return BinaryConstraintOp::GT;
304  case BinaryConstraintOp::ULE: return BinaryConstraintOp::UGT;
305  case BinaryConstraintOp::FLE: return BinaryConstraintOp::FGT;
306  case BinaryConstraintOp::SLE: return BinaryConstraintOp::SGT;
307 
308  case BinaryConstraintOp::GE: return BinaryConstraintOp::LT;
309  case BinaryConstraintOp::UGE: return BinaryConstraintOp::ULT;
310  case BinaryConstraintOp::FGE: return BinaryConstraintOp::FLT;
311  case BinaryConstraintOp::SGE: return BinaryConstraintOp::SLT;
312 
313  case BinaryConstraintOp::GT: return BinaryConstraintOp::LE;
314  case BinaryConstraintOp::UGT: return BinaryConstraintOp::ULE;
315  case BinaryConstraintOp::FGT: return BinaryConstraintOp::FLE;
316  case BinaryConstraintOp::SGT: return BinaryConstraintOp::SLE;
317 
318  case BinaryConstraintOp::MATCH: return BinaryConstraintOp::NOT_MATCH;
319  case BinaryConstraintOp::NOT_MATCH: return BinaryConstraintOp::MATCH;
320  case BinaryConstraintOp::CONTAINS: return BinaryConstraintOp::NOT_CONTAINS;
321  case BinaryConstraintOp::NOT_CONTAINS: return BinaryConstraintOp::CONTAINS;
322  }
323 
325 }
326 
327 /**
328  * Converts operator to its symbolic representation
329  */
330 inline char const* toBinaryConstraintSymbol(const BinaryConstraintOp op) {
331  switch (op) {

◆ none_of()

template<typename Container , typename UnaryPredicate >
bool souffle::none_of ( const Container &  c,
UnaryPredicate  p 
)

A generic test checking whether all elements within a container satisfy a certain predicate.

Parameters
cthe container
pthe predicate
Returns
true if for all elements x in c the predicate p(x) is true, false otherwise; for empty containers the result is always true

Definition at line 138 of file FunctionalUtil.h.

140  {

Referenced by any_of().

◆ now()

time_point souffle::now ( )
inline

◆ operator<<() [1/9]

std::ostream& souffle::operator<< ( std::ostream &  os,
AggregateOp  op 
)
inline

Definition at line 51 of file AggregateOp.h.

51  :
52  case AggregateOp::UMAX:
53  case AggregateOp::FMAX: return os << "max";
54 
55  case AggregateOp::MIN:
56  case AggregateOp::UMIN:
57  case AggregateOp::FMIN: return os << "min";
58 
59  case AggregateOp::SUM:
60  case AggregateOp::USUM:
61  case AggregateOp::FSUM: return os << "sum";
62  }
63 
65 }
66 
67 // `[min, max]` # of arguments for each function
68 inline std::pair<uint8_t, uint8_t> aggregateArity(AggregateOp op) {
69  switch (op) {
70  case AggregateOp::COUNT: return {0, 0};
71 

◆ operator<<() [2/9]

std::ostream& souffle::operator<< ( std::ostream &  os,
BinaryConstraintOp  x 
)
inline

Definition at line 70 of file BinaryConstraintOps.h.

70  : return BinaryConstraintOp::FEQ;
71  case 'u': return BinaryConstraintOp::EQ;
72  case 'i': return BinaryConstraintOp::EQ;

◆ operator<<() [3/9]

std::ostream & souffle::operator<< ( std::ostream &  os,
FunctorOp  op 
)

Definition at line 285 of file FunctorOps.cpp.

285  {
286  return os << functorOpNameLegacy(op);
287 }

◆ operator<<() [4/9]

std::ostream& souffle::operator<< ( std::ostream &  os,
RelationQualifier  qualifier 
)
inline

Definition at line 139 of file RelationTag.h.

139  : return os << "inline";
140  case RelationQualifier::MAGIC: return os << "magic";
141  case RelationQualifier::SUPPRESSED: return os << "suppressed";
142  }
143 
145 }
146 
147 inline std::ostream& operator<<(std::ostream& os, RelationRepresentation representation) {
148  switch (representation) {
149  case RelationRepresentation::BTREE: return os << "btree";
150  case RelationRepresentation::BRIE: return os << "brie";
151  case RelationRepresentation::EQREL: return os << "eqrel";

◆ operator<<() [5/9]

std::ostream& souffle::operator<< ( std::ostream &  os,
RelationRepresentation  representation 
)
inline

Definition at line 153 of file RelationTag.h.

153  : return os;
154  }
155 
157 }
158 
159 } // namespace souffle

◆ operator<<() [6/9]

std::ostream& souffle::operator<< ( std::ostream &  os,
RelationTag  qualifier 
)
inline

Definition at line 122 of file RelationTag.h.

122  : return os << "inline";
123  case RelationTag::MAGIC: return os << "magic";
124  case RelationTag::SUPPRESSED: return os << "suppressed";
125  case RelationTag::BRIE: return os << "brie";
126  case RelationTag::BTREE: return os << "btree";
127  case RelationTag::EQREL: return os << "eqrel";
128  }
129 
131 }
132 
133 inline std::ostream& operator<<(std::ostream& os, RelationQualifier qualifier) {
134  switch (qualifier) {
135  case RelationQualifier::INPUT: return os << "input";
136  case RelationQualifier::OUTPUT: return os << "output";
137  case RelationQualifier::PRINTSIZE: return os << "printsize";

◆ operator<<() [7/9]

std::ostream& souffle::operator<< ( std::ostream &  os,
TypeAttribute  T 
)
inline

Definition at line 44 of file TypeAttribute.h.

44  : return os << "TypeAttribute::Record";
45  case TypeAttribute::ADT: return os << "TypeAttribute::ADT";
46  }
47 
48  fatal("unhandled `TypeAttribute`");
49 }
50 
51 } // end of namespace souffle

◆ operator<<() [8/9]

template<typename T , unsigned size>
std::ostream& souffle::operator<< ( std::ostream &  out,
const LRUCache< T, size > &  cache 
)

Definition at line 142 of file CacheUtil.h.

151  {
152  // the single entry in this cache
153  T entry;

◆ operator<<() [9/9]

std::ostream& souffle::operator<< ( std::ostream &  out,
const RuleBody body 
)

Definition at line 153 of file ParserUtils.cpp.

158  {
159  return a.negated == b.negated && *a.atom == *b.atom;
160 }
161 
162 bool RuleBody::equal(const clause& a, const clause& b) {

◆ pack() [1/2]

template<std::size_t Arity>
RamDomain souffle::pack ( RecordTable recordTab,
span< const RamDomain, Arity >  tuple 
)

helper to convert tuple to record reference for the synthesiser

Definition at line 159 of file RecordTable.h.

◆ pack() [2/2]

template<std::size_t Arity>
RamDomain souffle::pack ( RecordTable recordTab,
Tuple< RamDomain, Arity > const &  tuple 
)

helper to convert tuple to record reference for the synthesiser

Definition at line 153 of file RecordTable.h.

◆ pathJoin()

std::string souffle::pathJoin ( const std::string &  first,
const std::string &  second 
)
inline

Join two paths together; note that this does not resolve overlaps or relative paths.

Definition at line 165 of file FileUtil.h.

165  {
166  secondPos++;
167  }
168  return first.substr(0, firstPos + 1) + '/' + second.substr(secondPos);
169 }
170 
171 /*
172  * Find out if an executable given by @p tool exists in the path given @p path
173  * relative to the directory given by @ base. A path here refers a
174  * colon-separated list of directories.
175  */

◆ printHTMLGraph()

void souffle::printHTMLGraph ( std::ostream &  out,
const std::string &  dotSpec,
const std::string &  id 
)
inline

Definition at line 226 of file GraphUtils.h.

◆ ramBitCast()

template<typename To = RamDomain, typename From >
To souffle::ramBitCast ( From  source)

In C++20 there will be a new way to cast between types by reinterpreting bits (std::bit_cast), but as of January 2020 it is not yet supported.

Cast a type by reinterpreting its bits. Domain is restricted to Ram Types only. Template takes two types (second type is never necessary because it can be deduced from the argument) The following always holds For type T and a : T ramBitCast<T>(ramBitCast<RamDomain>(a)) == a

Definition at line 87 of file RamTypes.h.

Referenced by souffle::interpreter::Engine::evalAggregate(), souffle::interpreter::Engine::execute(), souffle::ExplainProvenanceImpl::findTuple(), souffle::detail::brie::TrieBase< 1u, Trie< 1u > >::getBoundaries(), souffle::tuple::operator<<(), souffle::ExplainProvenanceImpl::queryProcess(), and souffle::interpreter::test::TEST().

◆ RamFloatFromString()

RamFloat souffle::RamFloatFromString ( const std::string &  str,
std::size_t *  position = nullptr 
)
inline

Converts a string to a RamFloat.

Definition at line 93 of file StringUtil.h.

Referenced by souffle::ExplainProvenanceImpl::queryProcess(), and souffle::evaluator::runRange().

◆ RamSignedFromString()

RamSigned souffle::RamSignedFromString ( const std::string &  str,
std::size_t *  position = nullptr,
const int  base = 10 
)
inline

Converts a string to a RamSigned.

This procedure has similar behaviour to std::stoi/stoll.

The procedure accepts prefixes 0b (if base = 2) and 0x (if base = 16) If base = 0, the procedure will try to infer the base from the prefix, if present.

Definition at line 51 of file StringUtil.h.

52  {
53  return RamSignedFromString(str, position, 16);
54  } else {
55  return RamSignedFromString(str, position);
56  }
57  }
58  std::string binaryNumber;
59  bool parsingBinary = base == 2;
60 
61  // stoi/stoll can't handle base 2 prefix by default.
62  if (parsingBinary) {
63  if (isPrefix("-0b", str)) {
64  binaryNumber = "-" + str.substr(3);
65  } else if (isPrefix("0b", str)) {
66  binaryNumber = str.substr(2);
67  }
68  }
69  const std::string& tmp = parsingBinary ? binaryNumber : str;
70 
71 #if RAM_DOMAIN_SIZE == 64
72  val = std::stoll(tmp, position, base);
73 #else
74  val = std::stoi(tmp, position, base);
75 #endif
76 
77  if (parsingBinary && position != nullptr) {
78  *position += 2;
79  }
80 
81  return val;
82 }
83 
84 /**
85  * Converts a string to a RamFloat
86  */
87 inline RamFloat RamFloatFromString(const std::string& str, std::size_t* position = nullptr) {
88  RamFloat val;

Referenced by souffle::ExplainProvenanceImpl::queryProcess(), and souffle::evaluator::runRange().

◆ RamUnsignedFromString()

RamUnsigned souffle::RamUnsignedFromString ( const std::string &  str,
std::size_t *  position = nullptr,
const int  base = 10 
)
inline

Converts a string to a RamUnsigned.

This procedure has similar behaviour to std::stoul/stoull.

The procedure accepts prefixes 0b (if base = 2) and 0x (if base = 16) If base = 0, the procedure will try to infer the base from the prefix, if present.

Definition at line 110 of file StringUtil.h.

111  {
112  if (isPrefix("0b", str)) {
113  return RamUnsignedFromString(str, position, 2);
114  } else if (isPrefix("0x", str)) {
115  return RamUnsignedFromString(str, position, 16);
116  } else {
117  return RamUnsignedFromString(str, position);
118  }
119  }
120 
121  // stoul/stoull can't handle binary prefix by default.
122  std::string binaryNumber;
123  bool parsingBinary = false;
124  if (base == 2 && isPrefix("0b", str)) {
125  binaryNumber = str.substr(2);
126  parsingBinary = true;
127  }
128  const std::string& tmp = parsingBinary ? binaryNumber : str;
129 
130  RamUnsigned val;
131 #if RAM_DOMAIN_SIZE == 64
132  val = std::stoull(tmp, position, base);
133 #else
134  val = std::stoul(tmp, position, base);
135 #endif
136 
137  if (parsingBinary && position != nullptr) {
138  *position += 2;
139  }
140 
141  // check if it's safe to cast (stoul returns unsigned long)
142  if (val > std::numeric_limits<RamUnsigned>::max()) {
143  throw std::invalid_argument("Unsigned number of of bounds");
144  }
145 
146  return static_cast<RamUnsigned>(val);
147 }
148 
149 /**
150  * Can a string be parsed as RamSigned.
151  *
152  * Souffle (parser, not fact file readers) accepts: hex, binary and base 10.
153  * Integer can be negative, in all 3 formats this means that it

References isPrefix(), and str.

Referenced by souffle::ExplainProvenanceImpl::queryProcess(), and souffle::ReadStreamCSV::readRamUnsigned().

Here is the call graph for this function:

◆ simpleName()

std::string souffle::simpleName ( const std::string &  path)
inline

File name, with extension removed.

Definition at line 219 of file FileUtil.h.

222  {
223  return name;
224  }
225  // last dot after last slash, or no slash
226  return name.substr(0, lastDot);
227 }
228 
229 /**
230  * File extension, with all else removed.
231  */
232 inline std::string fileExtension(const std::string& path) {
233  std::string name = path;

◆ split()

std::vector<std::string> souffle::split ( const std::string &  s,
char  delim,
int  times = -1 
)
inline

utility function to split a string

Definition at line 146 of file ExplainProvenance.h.

150  {
151  std::string remainder;
152  std::getline(ss, remainder);
153  v.push_back(remainder);
154  }
155 
156  return v;
157 }
158 
159 class ExplainProvenance {
160 public:
161  ExplainProvenance(SouffleProgram& prog) : prog(prog), symTable(prog.getSymbolTable()) {}
162  virtual ~ExplainProvenance() = default;
163 

Referenced by souffle::Explain::processCommand().

◆ splitString()

std::vector<std::string> souffle::splitString ( const std::string &  str,
char  delimiter 
)
inline

Splits a string given a delimiter.

Definition at line 321 of file StringUtil.h.

328  {
329  std::string str(input);

Referenced by main(), and souffle::ast::transform::SemanticChecker::transform().

◆ stringify()

std::string souffle::stringify ( const std::string &  input)
inline

Stringify a string using escapes for escape, newline, tab, double-quotes and semicolons.

Definition at line 334 of file StringUtil.h.

339  {
340  str.replace(start_pos, 1, "\\;");
341  start_pos += 2;
342  }
343  // replace double-quotes with escape sequence
344  start_pos = 0;
345  while ((start_pos = str.find('"', start_pos)) != std::string::npos) {
346  str.replace(start_pos, 1, "\\\"");
347  start_pos += 2;
348  }
349  // replace newline with escape sequence
350  start_pos = 0;
351  while ((start_pos = str.find('\n', start_pos)) != std::string::npos) {
352  str.replace(start_pos, 1, "\\n");
353  start_pos += 2;
354  }
355  // replace tab with escape sequence
356  start_pos = 0;
357  while ((start_pos = str.find('\t', start_pos)) != std::string::npos) {
358  str.replace(start_pos, 1, "\\t");
359  start_pos += 2;
360  }
361  return str;
362 }
363 
364 /**
365  * Escape JSON string.
366  */
367 inline std::string escapeJSONstring(const std::string& JSONstr) {
368  std::ostringstream destination;

Referenced by souffle::ram::DebugInfo::apply(), souffle::ram::LogTimer::apply(), souffle::ram::LogRelationTimer::apply(), souffle::ram::LogSize::clone(), and souffle::ast2ram::AstToRamTranslator::translateNonRecursiveRelation().

◆ tempFile()

std::string souffle::tempFile ( )
inline

Generate temporary file.

Definition at line 257 of file FileUtil.h.

268  {
269  FILE* in = popen(cmd, "r");
270  std::stringstream data;
271  while (in != nullptr) {
272  int c = fgetc(in);

◆ TEST() [1/51]

souffle::TEST ( SparseArray  ,
Basic   
)

Definition at line 45 of file brie_test.cpp.

74  {
75  SparseArray<int> map;
76 
77  map.update(std::numeric_limits<typename SparseArray<int>::index_type>::min(), 10);
78  map.update(std::numeric_limits<typename SparseArray<int>::index_type>::max(), 20);

◆ TEST() [2/51]

souffle::TEST ( SparseArray  ,
Copy   
)

Definition at line 246 of file brie_test.cpp.

268  {
269  // tests whether the first reference is properly updated while merging sets
270 
271  SparseArray<int> m1;
272  SparseArray<int> m2;

◆ TEST() [3/51]

souffle::TEST ( SparseArray  ,
Find   
)

Definition at line 196 of file brie_test.cpp.

220  {
221  SparseArray<int> a;
222 
223  EXPECT_EQ(a.end(), a.find(12));
224  EXPECT_EQ(a.end(), a.find(14));

◆ TEST() [4/51]

souffle::TEST ( SparseArray  ,
Find2   
)

Definition at line 226 of file brie_test.cpp.

240  {
241  SparseArray<int> m;
242 
243  m.update(12, 1);
244  m.update(14, 2);

◆ TEST() [5/51]

souffle::TEST ( SparseArray  ,
Iterator   
)

Definition at line 96 of file brie_test.cpp.

101  : should) {
102  map.update(cur.first, cur.second);
103  }
104 
105  std::set<std::pair<int, int>> is;
106  for (const auto& cur : map) {
107  is.insert(cur);
108  }
109 
110  EXPECT_EQ(should, is);
111 }
112 
113 TEST(SparseArray, IteratorStress) {
114  const static int N = 10000;
115 
116  SparseArray<int> map;
117 

References map().

Here is the call graph for this function:

◆ TEST() [6/51]

souffle::TEST ( SparseArray  ,
IteratorStress   
)

Definition at line 119 of file brie_test.cpp.

119  {
120  int n = random() % (N * 10);
121  if (!contains(pos, n)) {
122  pos.push_back(n);
123  }
124  }
125 
126  std::set<std::pair<int, int>> should;
127  for (int i = 0; i < N; i++) {
128  should.insert(std::make_pair(pos[i], i + 1));
129  }
130 
131  for (const auto& cur : should) {
132  map.update(cur.first, cur.second);
133  ASSERT_TRUE(map[cur.first] == cur.second);
134  }
135 
136  std::set<std::pair<int, int>> is;
137  for (const auto& cur : map) {
138  is.insert(cur);
139  }
140 
141  EXPECT_EQ(should, is);
142 }
143 
144 TEST(SparseArray, IteratorStress2) {
145  const static int N = 1000;
146 
147  bool log = false;
148 

References contains(), and n.

Here is the call graph for this function:

◆ TEST() [7/51]

souffle::TEST ( SparseArray  ,
IteratorStress2   
)

Definition at line 150 of file brie_test.cpp.

154  {
155  int n = random() % (N * 10);
156  if (!contains(pos, n)) {
157  pos.push_back(n);
158  }
159  }
160 
161  if (log) std::cout << "Creating input list ..\n";
162  std::set<std::pair<int, int>> should;
163  for (unsigned i = 0; i < j; i++) {
164  should.insert(std::make_pair(pos[i], i + 1));
165  }
166 
167  if (log) std::cout << "Filling in input list ..\n";
168  for (const auto& cur : should) {
169  map.update(cur.first, cur.second);
170  ASSERT_TRUE(map[cur.first] == cur.second);
171  }
172 
173  if (log) std::cout << "Sort should list ..\n";
174 
175  if (log) std::cout << "Collect is list ..\n";
176  std::set<std::pair<int, int>> is;
177  unsigned i = 0;
178  for (const auto& cur : map) {
179  is.insert(cur);
180  i++;
181  ASSERT_LE(i, j);
182  }
183 
184  if (log) std::cout << "Comparing lists ..\n";
185  EXPECT_EQ(should, is);
186  if (log) std::cout << "Done\n\n";
187  }
188 }
189 
190 TEST(SparseArray, Find) {
191  SparseArray<int> map;
192 
193  EXPECT_EQ(map.end(), map.find(1));
194  EXPECT_EQ(map.end(), map.find(12));

References contains(), and n.

Here is the call graph for this function:

◆ TEST() [8/51]

souffle::TEST ( SparseArray  ,
Limits   
)

Definition at line 80 of file brie_test.cpp.

83  : map) {
84  present.push_back(cur);
85  }
86 
87  EXPECT_EQ("[(0,10),(4294967295,20)]", toString(present));
88 }
89 
90 TEST(SparseArray, Iterator) {
91  SparseArray<int> map;
92 
93  std::set<std::pair<int, int>> should;
94  should.insert(std::make_pair(14, 4));

◆ TEST() [9/51]

souffle::TEST ( SparseArray  ,
LowerBound   
)

Definition at line 292 of file brie_test.cpp.

334  {
335  for (uint32_t m = 0; m < 256; ++m) {
336  SparseArray<uint32_t> a;
337  std::set<uint32_t> r;
338 

◆ TEST() [10/51]

souffle::TEST ( SparseArray  ,
LowerBound2   
)

Definition at line 340 of file brie_test.cpp.

340  {
341  continue;
342  }
343  a.update(i * 100, 10);
344  r.insert(i * 100);
345  }
346 
347  for (uint32_t i = 0; i < 10; i++) {
348  auto a_res = a.lowerBound(i * 100);
349  auto r_res = r.lower_bound(i * 100);
350 
351  EXPECT_EQ(a_res == a.end(), r_res == r.end()) << "\nm=" << std::bitset<8>(m) << "\ni=" << i;
352 
353  if (a_res == a.end()) {
354  continue;
355  }
356 
357  EXPECT_EQ(a_res->first, *r_res) << "\nm=" << std::bitset<8>(m) << "\ni=" << i;
358  }
359  }
360 }
361 
362 TEST(SparseArray, UpperBound) {
363  SparseArray<int> m;
364 
365  EXPECT_EQ(m.end(), m.upperBound(0));
366  EXPECT_EQ(m.end(), m.upperBound(10));

◆ TEST() [11/51]

souffle::TEST ( SparseArray  ,
MemoryUsage   
)

Definition at line 448 of file brie_test.cpp.

463  {
464  SparseArray<int> a;
465 
466  // an empty one should be small
467  EXPECT_TRUE(a.empty());
468  EXPECT_EQ(28, a.getMemoryUsage());
469 
470  // a single element should have the same size as an empty one
471  a.update(12, 15);
472  EXPECT_FALSE(a.empty());
473  EXPECT_EQ(288, a.getMemoryUsage());
474 
475  // more than one => there are nodes
476  a.update(14, 18);
477  EXPECT_FALSE(a.empty());
478  EXPECT_EQ(288, a.getMemoryUsage());
479  }
480 }
481 
482 TEST(SparseBitMap, Basic) {
483  SparseBitMap<> map;
484 
485  EXPECT_EQ(sizeof(std::bitset<sizeof(void*) * 8>), sizeof(void*));
486 

◆ TEST() [12/51]

souffle::TEST ( SparseArray  ,
Merge   
)

Definition at line 274 of file brie_test.cpp.

280  : m1) {
281  data.push_back(it);
282  }
283  EXPECT_EQ("[(100,1),(500,2)]", toString(data));
284 }
285 
286 TEST(SparseArray, LowerBound) {
287  SparseArray<int> m;
288 
289  EXPECT_EQ(m.end(), m.lowerBound(0));
290  EXPECT_EQ(m.end(), m.lowerBound(10));

References TCB_SPAN_NAMESPACE_NAME::detail::data().

Here is the call graph for this function:

◆ TEST() [13/51]

souffle::TEST ( SparseArray  ,
UpperBound   
)

Definition at line 368 of file brie_test.cpp.

414  {
415  for (uint32_t m = 0; m < 256; ++m) {
416  SparseArray<uint32_t> a;
417  std::set<uint32_t> r;
418 

◆ TEST() [14/51]

souffle::TEST ( SparseArray  ,
UpperBound2   
)

Definition at line 420 of file brie_test.cpp.

420  {
421  continue;
422  }
423  a.update(i * 100, 10);
424  r.insert(i * 100);
425  }
426 
427  for (uint32_t i = 0; i < 10; i++) {
428  auto a_res = a.upperBound(i * 100);
429  auto r_res = r.upper_bound(i * 100);
430 
431  EXPECT_EQ(a_res == a.end(), r_res == r.end()) << "\nm=" << std::bitset<8>(m) << "\ni=" << i;
432 
433  if (a_res == a.end()) {
434  continue;
435  }
436 
437  EXPECT_EQ(a_res->first, *r_res) << "\nm=" << std::bitset<8>(m) << "\ni=" << i;
438  }
439  }
440 }
441 
442 TEST(SparseArray, MemoryUsage) {
443  if (sizeof(void*) > 4) {
444  SparseArray<int> a;
445 
446  // an empty one should be small

◆ TEST() [15/51]

souffle::TEST ( SparseBitMap  ,
Basic   
)

Definition at line 488 of file brie_test.cpp.

510  {
511  const static int N = 10000;
512 
513  SparseBitMap<> map;
514 

◆ TEST() [16/51]

souffle::TEST ( SparseBitMap  ,
CopyAndMerge   
)

Definition at line 667 of file brie_test.cpp.

682  : m) {
683  EXPECT_TRUE(mapA.test(cur));
684  }
685 
686  m.addAll(mapA);
687  EXPECT_EQ(3, m.size());
688 
689  for (const auto& cur : m) {
690  EXPECT_TRUE(mapA.test(cur));
691  }
692 
693  m.addAll(mapB);
694  EXPECT_EQ(6, m.size());
695 
696  for (const auto& cur : m) {
697  EXPECT_TRUE(mapA.test(cur) || mapB.test(cur));
698  }
699 
700  m.addAll(mapC);
701  EXPECT_EQ(8, m.size());
702 
703  for (const auto& cur : m) {
704  EXPECT_TRUE(mapA.test(cur) || mapB.test(cur) || mapC.test(cur));
705  }
706 }
707 
708 TEST(Trie, Basic) {
709  Trie<1> set;
710 
711  EXPECT_TRUE(set.empty());
712  EXPECT_FALSE(set.contains({1}));

◆ TEST() [17/51]

souffle::TEST ( SparseBitMap  ,
Find   
)

Definition at line 624 of file brie_test.cpp.

648  {
649  SparseBitMap<> map;
650  EXPECT_EQ(0, map.size());
651  map.set(3);
652  EXPECT_EQ(1, map.size());

◆ TEST() [18/51]

souffle::TEST ( SparseBitMap  ,
Iterator   
)

Definition at line 540 of file brie_test.cpp.

542  {}", toString(vals));
543 
544  map.set(12);
545 
546  vals.clear();
547  for (const auto& cur : map) {
548  vals.insert(cur);
549  }
550 
551  EXPECT_EQ("{12}", toString(vals));
552 
553  map.set(12);
554  map.set(120);
555 
556  vals.clear();
557  for (const auto& cur : map) {
558  vals.insert(cur);
559  }
560 
561  EXPECT_EQ("{12,120}", toString(vals));
562 
563  map.set(1234);
564 
565  vals.clear();
566  for (const auto& cur : map) {
567  vals.insert(cur);
568  }
569 
570  EXPECT_EQ("{12,120,1234}", toString(vals));
571 }
572 
573 TEST(SparseBitMap, IteratorStress2) {
574  const static int N = 1000;
575 
576  bool log = false;
577 

◆ TEST() [19/51]

souffle::TEST ( SparseBitMap  ,
IteratorStress2   
)

Definition at line 579 of file brie_test.cpp.

583  {
584  int n = random() % (N * 10);
585  if (!contains(should, n)) {
586  should.insert(n);
587  }
588  }
589 
590  if (log) std::cout << "Filling in input list ..\n";
591  for (const auto& cur : should) {
592  map.set(cur);
593  ASSERT_TRUE(map[cur]);
594  }
595 
596  if (log) std::cout << "Collect is list ..\n";
597  std::set<int> is;
598  unsigned i = 0;
599  for (const auto& cur : map) {
600  is.insert(cur);
601  i++;
602 
603  if (i > j) {
604  map.dump();
605  std::cout << "Should: " << should << "\n";
606  std::cout << " Is: " << is << "\n";
607  }
608 
609  ASSERT_LE(i, j);
610  }
611 
612  if (log) std::cout << "Comparing lists ..\n";
613  EXPECT_EQ(should, is);
614  if (log) std::cout << "Done\n\n";
615  }
616 }
617 
618 TEST(SparseBitMap, Find) {
619  SparseBitMap<> map;
620 
621  EXPECT_EQ(map.end(), map.find(1));
622  EXPECT_EQ(map.end(), map.find(12));

References contains(), and n.

Here is the call graph for this function:

◆ TEST() [20/51]

souffle::TEST ( SparseBitMap  ,
Size   
)

Definition at line 654 of file brie_test.cpp.

661  {
662  SparseBitMap<> mapA;
663  SparseBitMap<> mapB;
664  SparseBitMap<> mapC;
665 

◆ TEST() [21/51]

souffle::TEST ( SparseBitMap  ,
Stress   
)

Definition at line 516 of file brie_test.cpp.

516  {
517  int n = random() % (N * 10);
518  if (!contains(should, n)) {
519  should.push_back(n);
520  }
521  }
522 
523  for (const auto& cur : should) {
524  map.set(cur);
525  ASSERT_TRUE(map[cur]);
526  }
527 
528  // check all the entries
529  for (int i = 0; i < N * 10; i++) {
530  EXPECT_EQ(map[i], contains(should, i));
531  }
532 }
533 
534 TEST(SparseBitMap, Iterator) {
535  SparseBitMap<> map;
536 
537  std::set<int> vals;
538  for (const auto& cur : map) {

References contains(), and n.

Here is the call graph for this function:

◆ TEST() [22/51]

souffle::TEST ( Trie  ,
Basic   
)

Definition at line 714 of file brie_test.cpp.

714  {3}));
715 
716  set.insert({1});
717 
718  EXPECT_TRUE(set.contains({1}));
719  EXPECT_FALSE(set.contains({2}));
720  EXPECT_FALSE(set.contains({3}));
721 
722  set.insert({2});
723 
724  EXPECT_TRUE(set.contains({1}));
725  EXPECT_TRUE(set.contains({2}));
726  EXPECT_FALSE(set.contains({3}));
727 }
728 
729 namespace {
730 
731 template <typename Iter>
732 int card(const range<Iter>& r) {
733  int res = 0;

◆ TEST() [23/51]

souffle::TEST ( Trie  ,
BoundaryTest_1D   
)

Definition at line 889 of file brie_test.cpp.

889  {i});
890  }
891 
892  auto a = t.lower_bound({5});
893  EXPECT_EQ(5, (*a)[0]);
894 
895  auto b = t.upper_bound({5});
896  EXPECT_EQ(6, (*b)[0]);
897 
898  // add duplicates
899 
900  t.insert({5});
901  t.insert({5});
902  t.insert({5});
903 
904  // test again ..
905  a = t.lower_bound({5});
906  EXPECT_EQ(5, (*a)[0]);
907 
908  b = t.upper_bound({5});
909  EXPECT_EQ(6, (*b)[0]);
910 
911  // check the distance
912  EXPECT_EQ(++a, b);
913 }
914 
915 TEST(Trie, BoundaryTest_1D_2) {
916  using test_set = Trie<1>;
917 
918  test_set t;
919 

References i.

◆ TEST() [24/51]

souffle::TEST ( Trie  ,
BoundaryTest_1D_2   
)

Definition at line 921 of file brie_test.cpp.

921  {i * 100});
922  }
923 
924  auto a = t.lower_bound({500});
925  EXPECT_EQ(500, (*a)[0]);
926 
927  auto b = t.upper_bound({500});
928  EXPECT_EQ(600, (*b)[0]);
929 
930  // add duplicates
931 
932  t.insert({500});
933  t.insert({500});
934  t.insert({500});
935 
936  // test again ..
937  a = t.lower_bound({500});
938  EXPECT_EQ(500, (*a)[0]);
939 
940  b = t.upper_bound({500});
941  EXPECT_EQ(600, (*b)[0]);
942 
943  // check the distance
944  EXPECT_EQ(++a, b);
945 }
946 
947 TEST(Trie, BoundaryTest_1D_Stress) {
948  using value_type = typename Trie<1>::element_type;
949  using test_set = Trie<1>;
950  using ref_set = std::set<value_type>;
951 

References i.

◆ TEST() [25/51]

souffle::TEST ( Trie  ,
BoundaryTest_1D_Stress   
)

Definition at line 953 of file brie_test.cpp.

955  {
956  t.insert({i * 100});
957  r.insert({i * 100});
958  }
959 
960  // Check various lookup points
961  for (int i = 0; i < 30; i++) {
962  value_type key{i * 50};
963 
964  auto t_lb = t.lower_bound(key);
965  auto r_lb = r.lower_bound(key);
966 
967  EXPECT_EQ(t_lb == t.end(), r_lb == r.end());
968  if (t_lb != t.end() && r_lb != r.end()) {
969  EXPECT_EQ(*t_lb, *r_lb);
970  }
971 
972  auto t_ub = t.upper_bound(key);
973  auto r_ub = r.upper_bound(key);
974 
975  EXPECT_EQ(t_ub == t.end(), r_ub == r.end());
976  if (t_ub != t.end() && r_ub != r.end()) {
977  EXPECT_EQ(*t_ub, *r_ub);
978  }
979  }
980 }
981 
982 TEST(Trie, BoundaryTest_1D_Stress_Dense) {
983  using value_type = typename Trie<1>::element_type;
984  using test_set = Trie<1>;
985  using ref_set = std::set<value_type>;
986 

References i.

◆ TEST() [26/51]

souffle::TEST ( Trie  ,
BoundaryTest_1D_Stress_Dense   
)

Definition at line 988 of file brie_test.cpp.

990  {
991  t.insert({i});
992  r.insert({i});
993  }
994 
995  // Check various lookup points
996  for (int i = 0; i < 2500; i++) {
997  value_type key{i};
998 
999  auto t_lb = t.lower_bound(key);
1000  auto r_lb = r.lower_bound(key);
1001 
1002  EXPECT_EQ(t_lb == t.end(), r_lb == r.end());
1003  if (t_lb != t.end() && r_lb != r.end()) {
1004  EXPECT_EQ(*t_lb, *r_lb);
1005  }
1006 
1007  auto t_ub = t.upper_bound(key);
1008  auto r_ub = r.upper_bound(key);
1009 
1010  EXPECT_EQ(t_ub == t.end(), r_ub == r.end());
1011  if (t_ub != t.end() && r_ub != r.end()) {
1012  EXPECT_EQ(*t_ub, *r_ub);
1013  }
1014  }
1015 }
1016 
1017 TEST(Trie, BoundaryTest_2D) {
1018  using test_set = Trie<2>;
1019 
1020  test_set t;
1021 

References i.

◆ TEST() [27/51]

souffle::TEST ( Trie  ,
BoundaryTest_2D   
)

Definition at line 1023 of file brie_test.cpp.

1023  {
1024  t.insert({i, j});
1025  }
1026  }
1027 
1028  auto a = t.lower_bound({5, 5});
1029  EXPECT_EQ(5, (*a)[0]);
1030  EXPECT_EQ(5, (*a)[1]);
1031 
1032  auto b = t.upper_bound({5, 5});
1033  EXPECT_EQ(5, (*b)[0]);
1034  EXPECT_EQ(6, (*b)[1]);
1035 
1036  // add duplicates
1037 
1038  t.insert({5, 5});
1039  t.insert({5, 5});
1040  t.insert({5, 5});
1041 
1042  // test again ..
1043  a = t.lower_bound({5, 5});
1044  EXPECT_EQ(5, (*a)[0]);
1045  EXPECT_EQ(5, (*a)[1]);
1046 
1047  b = t.upper_bound({5, 5});
1048  EXPECT_EQ(5, (*b)[0]);
1049  EXPECT_EQ(6, (*b)[1]);
1050 
1051  // check the distance
1052  EXPECT_EQ(++a, b);
1053 }
1054 
1055 TEST(Trie, BoundaryTest_2D_2) {
1056  using test_set = Trie<2>;
1057 
1058  test_set t;
1059 

References i, and j.

◆ TEST() [28/51]

souffle::TEST ( Trie  ,
BoundaryTest_2D_2   
)

Definition at line 1061 of file brie_test.cpp.

1061  {
1062  t.insert({i * 100, j * 100});
1063  }
1064  }
1065 
1066  auto a = t.lower_bound({500, 500});
1067  EXPECT_EQ(500, (*a)[0]);
1068  EXPECT_EQ(500, (*a)[1]);
1069 
1070  auto b = t.upper_bound({500, 500});
1071  EXPECT_EQ(500, (*b)[0]);
1072  EXPECT_EQ(600, (*b)[1]);
1073 
1074  // add duplicates
1075 
1076  t.insert({500, 500});
1077  t.insert({500, 500});
1078  t.insert({500, 500});
1079 
1080  // test again ..
1081  a = t.lower_bound({500, 500});
1082  EXPECT_EQ(500, (*a)[0]);
1083  EXPECT_EQ(500, (*a)[1]);
1084 
1085  b = t.upper_bound({500, 500});
1086  EXPECT_EQ(500, (*b)[0]);
1087  EXPECT_EQ(600, (*b)[1]);
1088 
1089  // check the distance
1090  EXPECT_EQ(++a, b);
1091 }
1092 
1093 TEST(Trie, BoundaryTest_2D_Stress) {
1094  using value_type = typename Trie<2>::element_type;
1095  using test_set = Trie<2>;
1096  using ref_set = std::set<value_type>;
1097 

References i, and j.

◆ TEST() [29/51]

souffle::TEST ( Trie  ,
BoundaryTest_2D_Stress   
)

Definition at line 1099 of file brie_test.cpp.

1101  {
1102  for (int j = 5; j < 10; j++) {
1103  t.insert({i * 100, j * 100});
1104  r.insert({i * 100, j * 100});
1105  }
1106  }
1107 
1108  // Check various lookup points
1109  for (int i = 0; i < 30; i++) {
1110  for (int j = 0; j < 30; j++) {
1111  value_type key{i * 50, j * 50};
1112 
1113  auto t_lb = t.lower_bound(key);
1114  auto r_lb = r.lower_bound(key);
1115 
1116  EXPECT_EQ(t_lb == t.end(), r_lb == r.end());
1117  if (t_lb != t.end() && r_lb != r.end()) {
1118  EXPECT_EQ(*t_lb, *r_lb);
1119  }
1120 
1121  auto t_ub = t.upper_bound(key);
1122  auto r_ub = r.upper_bound(key);
1123 
1124  EXPECT_EQ(t_ub == t.end(), r_ub == r.end());
1125  if (t_ub != t.end() && r_ub != r.end()) {
1126  EXPECT_EQ(*t_ub, *r_ub);
1127  }
1128  }
1129  }
1130 }
1131 
1132 TEST(Trie, BoundaryTest_2D_Stress_Dense) {
1133  using value_type = typename Trie<2>::element_type;
1134  using test_set = Trie<2>;
1135  using ref_set = std::set<value_type>;
1136 

References i, and j.

◆ TEST() [30/51]

souffle::TEST ( Trie  ,
BoundaryTest_2D_Stress_Dense   
)

Definition at line 1138 of file brie_test.cpp.

1140  {
1141  for (int j = 50; j < 250; j++) {
1142  t.insert({i, j});
1143  r.insert({i, j});
1144  }
1145  }
1146 
1147  // Check various lookup points
1148  for (int i = 0; i < 250; i++) {
1149  for (int j = 0; j < 300; j++) {
1150  value_type key{i, j};
1151 
1152  auto t_lb = t.lower_bound(key);
1153  auto r_lb = r.lower_bound(key);
1154 
1155  EXPECT_EQ(t_lb == t.end(), r_lb == r.end());
1156  if (t_lb != t.end() && r_lb != r.end()) {
1157  EXPECT_EQ(*t_lb, *r_lb);
1158  }
1159 
1160  auto t_ub = t.upper_bound(key);
1161  auto r_ub = r.upper_bound(key);
1162 
1163  EXPECT_EQ(t_ub == t.end(), r_ub == r.end());
1164  if (t_ub != t.end() && r_ub != r.end()) {
1165  EXPECT_EQ(*t_ub, *r_ub);
1166  }
1167  }
1168  }
1169 }
1170 
1171 TEST(Trie, BoundaryTest_3D) {
1172  using test_set = Trie<3>;
1173 
1174  test_set t;
1175 

References i, and j.

◆ TEST() [31/51]

souffle::TEST ( Trie  ,
BoundaryTest_3D   
)

Definition at line 1177 of file brie_test.cpp.

1177  {
1178  for (int k = 0; k < 10; k++) {
1179  t.insert({i, j, k});
1180  }
1181  }
1182  }
1183 
1184  auto a = t.lower_bound({5, 5, 5});
1185  EXPECT_EQ(5, (*a)[0]);
1186  EXPECT_EQ(5, (*a)[1]);
1187  EXPECT_EQ(5, (*a)[2]);
1188 
1189  auto b = t.upper_bound({5, 5, 5});
1190  EXPECT_EQ(5, (*b)[0]);
1191  EXPECT_EQ(5, (*b)[1]);
1192  EXPECT_EQ(6, (*b)[2]);
1193 
1194  // check the distance
1195  EXPECT_EQ(++a, b);
1196 }
1197 
1198 TEST(Trie, BoundaryTest_3D_2) {
1199  using test_set = Trie<3>;
1200 
1201  test_set t;
1202 

References i, j, and k.

◆ TEST() [32/51]

souffle::TEST ( Trie  ,
BoundaryTest_3D_2   
)

Definition at line 1204 of file brie_test.cpp.

1204  {
1205  for (int k = 0; k < 10; k++) {
1206  t.insert({i * 100, j * 100, k * 100});
1207  }
1208  }
1209  }
1210 
1211  auto a = t.lower_bound({500, 500, 500});
1212  EXPECT_EQ(500, (*a)[0]);
1213  EXPECT_EQ(500, (*a)[1]);
1214  EXPECT_EQ(500, (*a)[2]);
1215 
1216  auto b = t.upper_bound({500, 500, 500});
1217  EXPECT_EQ(500, (*b)[0]);
1218  EXPECT_EQ(500, (*b)[1]);
1219  EXPECT_EQ(600, (*b)[2]);
1220 
1221  // check the distance
1222  EXPECT_EQ(++a, b);
1223 }
1224 
1225 TEST(Trie, BoundaryTest_3D_Stress) {
1226  using value_type = typename Trie<3>::element_type;
1227  using test_set = Trie<3>;
1228  using ref_set = std::set<value_type>;
1229 

References i, j, and k.

◆ TEST() [33/51]

souffle::TEST ( Trie  ,
BoundaryTest_3D_Stress   
)

Definition at line 1231 of file brie_test.cpp.

1233  {
1234  for (int j = 5; j < 10; j++) {
1235  for (int k = 5; k < 10; k++) {
1236  t.insert({i * 100, j * 100, k * 100});
1237  r.insert({i * 100, j * 100, k * 100});
1238  }
1239  }
1240  }
1241 
1242  // Check various lookup points
1243  for (int i = 0; i < 30; i++) {
1244  for (int j = 0; j < 30; j++) {
1245  for (int k = 0; k < 30; k++) {
1246  value_type key{i * 50, j * 50, k * 50};
1247 
1248  auto t_lb = t.lower_bound(key);
1249  auto r_lb = r.lower_bound(key);
1250 
1251  EXPECT_EQ(t_lb == t.end(), r_lb == r.end());
1252  if (t_lb != t.end() && r_lb != r.end()) {
1253  EXPECT_EQ(*t_lb, *r_lb);
1254  }
1255 
1256  auto t_ub = t.upper_bound(key);
1257  auto r_ub = r.upper_bound(key);
1258 
1259  EXPECT_EQ(t_ub == t.end(), r_ub == r.end());
1260  if (t_ub != t.end() && r_ub != r.end()) {
1261  EXPECT_EQ(*t_ub, *r_ub);
1262  }
1263  }
1264  }
1265  }
1266 }
1267 
1268 TEST(Trie, RangeQuery) {
1269  Trie<3> set;
1270 
1271  for (int i = 0; i < 10; i++) {
1272  for (int j = 0; j < 10; j++) {

References i, j, and k.

◆ TEST() [34/51]

souffle::TEST ( Trie  ,
Iterator   
)

Definition at line 752 of file brie_test.cpp.

755  {4, 3});
756  set.insert({5, 2});
757 
758  EXPECT_NE(set.begin(), set.end());
759 
760  EXPECT_EQ(3, card(set));
761 }
762 
763 namespace {
764 
765 RamDomain rand(RamDomain max) {
766  return random() % max;
767 }

◆ TEST() [35/51]

souffle::TEST ( Trie  ,
IteratorStress_1D   
)

Definition at line 776 of file brie_test.cpp.

778  {
779  tuple cur{(RamDomain)(rand(N * 10))};
780  if (data.insert(cur).second) {
781  EXPECT_FALSE(set.contains(cur));
782  set.insert(cur);
783  EXPECT_TRUE(set.contains(cur));
784  }
785  }
786 
787  std::set<tuple> is;
788  for (const auto& cur : set) {
789  is.insert(cur);
790  }
791 
792  EXPECT_EQ(N, set.size());
793  EXPECT_EQ(data, is);
794 }
795 
796 TEST(Trie, IteratorStress_2D) {
797  using tuple = std::array<RamDomain, 2>;
798 
799  const int N = 10000;
800 

References TCB_SPAN_NAMESPACE_NAME::detail::data(), EXPECT_FALSE, and EXPECT_TRUE.

Here is the call graph for this function:

◆ TEST() [36/51]

souffle::TEST ( Trie  ,
IteratorStress_2D   
)

Definition at line 802 of file brie_test.cpp.

804  {
805  tuple cur;
806  cur[0] = (RamDomain)(rand(N * 10));
807  cur[1] = (RamDomain)(rand(N * 10));
808  if (data.insert(cur).second) {
809  EXPECT_FALSE(set.contains(cur));
810  set.insert(cur);
811  EXPECT_TRUE(set.contains(cur));
812  }
813  }
814 
815  std::set<tuple> is;
816  for (const auto& cur : set) {
817  is.insert(cur);
818  }
819 
820  EXPECT_EQ(N, set.size());
821  EXPECT_EQ(data, is);
822 }
823 
824 TEST(Trie, IteratorStress_3D) {
825  using tuple = std::array<RamDomain, 3>;
826 
827  const int N = 10000;
828 

References TCB_SPAN_NAMESPACE_NAME::detail::data(), EXPECT_FALSE, and EXPECT_TRUE.

Here is the call graph for this function:

◆ TEST() [37/51]

souffle::TEST ( Trie  ,
IteratorStress_3D   
)

Definition at line 830 of file brie_test.cpp.

832  {
833  tuple cur;
834  cur[0] = (RamDomain)(rand(N * 10));
835  cur[1] = (RamDomain)(rand(N * 10));
836  cur[2] = (RamDomain)(rand(N * 10));
837  if (data.insert(cur).second) {
838  EXPECT_FALSE(set.contains(cur));
839  set.insert(cur);
840  EXPECT_TRUE(set.contains(cur));
841  }
842  }
843 
844  std::set<tuple> is;
845  for (const auto& cur : set) {
846  is.insert(cur);
847  }
848 
849  EXPECT_EQ(N, set.size());
850  EXPECT_EQ(data, is);
851 }
852 
853 TEST(Trie, IteratorStress_4D) {
854  using tuple = std::array<RamDomain, 4>;
855 
856  const int N = 10000;
857 

References TCB_SPAN_NAMESPACE_NAME::detail::data(), EXPECT_FALSE, and EXPECT_TRUE.

Here is the call graph for this function:

◆ TEST() [38/51]

souffle::TEST ( Trie  ,
IteratorStress_4D   
)

Definition at line 859 of file brie_test.cpp.

861  {
862  tuple cur;
863  cur[0] = (RamDomain)(rand(N * 10));
864  cur[1] = (RamDomain)(rand(N * 10));
865  cur[2] = (RamDomain)(rand(N * 10));
866  cur[3] = (RamDomain)(rand(N * 10));
867  if (data.insert(cur).second) {
868  EXPECT_FALSE(set.contains(cur));
869  set.insert(cur);
870  EXPECT_TRUE(set.contains(cur));
871  }
872  }
873 
874  std::set<tuple> is;
875  for (const auto& cur : set) {
876  is.insert(cur);
877  }
878 
879  EXPECT_EQ(N, set.size());
880  EXPECT_EQ(data, is);
881 }
882 
883 TEST(Trie, BoundaryTest_1D) {
884  using test_set = Trie<1>;
885 
886  test_set t;
887 

References TCB_SPAN_NAMESPACE_NAME::detail::data(), EXPECT_FALSE, and EXPECT_TRUE.

Here is the call graph for this function:

◆ TEST() [39/51]

souffle::TEST ( Trie  ,
Limits   
)

Definition at line 1653 of file brie_test.cpp.

1654  {(1 << 31) + (1 << 30), 18});
1655  EXPECT_EQ(2, data.size());
1656 
1657  Trie<2> a;
1658  a.insert({140, 15});
1659 
1660  Trie<2> b;
1661  b.insert({25445, 18});
1662 
1663  b.insertAll(a);
1664 
1665  EXPECT_EQ(2, b.size());
1666 
1667  int counter = 0;
1668  for (auto it = b.begin(); it != b.end(); ++it) {
1669  counter++;
1670  }
1671  EXPECT_EQ(2, counter);
1672 }
1673 
1674 TEST(Trie, Parallel) {
1675  const int N = 10000;
1676 
1677  // get a unordered list of test data
1678  using entry_t = typename Trie<2>::entry_type;

◆ TEST() [40/51]

souffle::TEST ( Trie  ,
Merge_1D   
)

Definition at line 1425 of file brie_test.cpp.

1425  {i});
1426  b.insert({i + 5});
1427  }
1428 
1429  {
1430  Trie<1> c = e;
1431  c.insertAll(a);
1432  for (int i = 0; i < 10; i++) {
1433  EXPECT_EQ(a.contains({i}), c.contains({i}));
1434  }
1435  }
1436 
1437  {
1438  Trie<1> c = e;
1439  c.insertAll(b);
1440  for (int i = 0; i < 10; i++) {
1441  EXPECT_EQ(b.contains({i}), c.contains({i}));
1442  }
1443  }
1444 
1445  {
1446  Trie<1> c = e;
1447  c.insertAll(a);
1448  c.insertAll(b);
1449  for (int i = 0; i < 10; i++) {
1450  EXPECT_EQ(a.contains({i}) || b.contains({i}), c.contains({i}));
1451  }
1452  }
1453 }
1454 
1455 TEST(Trie, Merge_2D) {
1456  Trie<2> e;
1457  Trie<2> a;
1458  Trie<2> b;
1459 

References i.

◆ TEST() [41/51]

souffle::TEST ( Trie  ,
Merge_2D   
)

Definition at line 1461 of file brie_test.cpp.

1461  {
1462  a.insert({i, j});
1463  b.insert({i + 5, j + 5});
1464  }
1465  }
1466 
1467  {
1468  Trie<2> c = e;
1469  c.insertAll(a);
1470  for (int i = 0; i < 10; i++) {
1471  for (int j = 0; j < 10; j++) {
1472  EXPECT_EQ(a.contains({i, j}), c.contains({i, j}));
1473  }
1474  }
1475  }
1476 
1477  {
1478  Trie<2> c = e;
1479  c.insertAll(b);
1480  for (int i = 0; i < 10; i++) {
1481  for (int j = 0; j < 10; j++) {
1482  EXPECT_EQ(b.contains({i, j}), c.contains({i, j}));
1483  }
1484  }
1485  }
1486 
1487  {
1488  Trie<2> c = e;
1489  c.insertAll(a);
1490  c.insertAll(b);
1491  for (int i = 0; i < 10; i++) {
1492  for (int j = 0; j < 10; j++) {
1493  EXPECT_EQ(a.contains({i, j}) || b.contains({i, j}), c.contains({i, j}));
1494  }
1495  }
1496  }
1497 }
1498 
1499 TEST(Trie, Merge_3D) {
1500  Trie<3> e;
1501  Trie<3> a;
1502  Trie<3> b;
1503 

References b, i, and j.

◆ TEST() [42/51]

souffle::TEST ( Trie  ,
Merge_3D   
)

Definition at line 1505 of file brie_test.cpp.

1505  {
1506  for (int k = 0; k < 5; k++) {
1507  a.insert({i, j, k});
1508  b.insert({i + 5, j + 5, k + 5});
1509  }
1510  }
1511  }
1512 
1513  {
1514  Trie<3> c = e;
1515  c.insertAll(a);
1516  for (int i = 0; i < 10; i++) {
1517  for (int j = 0; j < 10; j++) {
1518  for (int k = 0; k < 5; k++) {
1519  EXPECT_EQ(a.contains({i, j, k}), c.contains({i, j, k}));
1520  }
1521  }
1522  }
1523  }
1524 
1525  {
1526  Trie<3> c = e;
1527  c.insertAll(b);
1528  for (int i = 0; i < 10; i++) {
1529  for (int j = 0; j < 10; j++) {
1530  for (int k = 0; k < 5; k++) {
1531  EXPECT_EQ(b.contains({i, j, k}), c.contains({i, j, k}));
1532  }
1533  }
1534  }
1535  }
1536 
1537  {
1538  Trie<3> c = e;
1539  c.insertAll(a);
1540  c.insertAll(b);
1541  for (int i = 0; i < 10; i++) {
1542  for (int j = 0; j < 10; j++) {
1543  for (int k = 0; k < 5; k++) {
1544  EXPECT_EQ(a.contains({i, j, k}) || b.contains({i, j, k}), c.contains({i, j, k}));
1545  }
1546  }
1547  }
1548  }
1549 }
1550 
1551 TEST(Trie, Merge_Stress) {
1552  using entry_t = typename Trie<2>::entry_type;
1553 
1554  const int N = 1000;
1555  const int M = 100;

References b, i, j, and k.

◆ TEST() [43/51]

souffle::TEST ( Trie  ,
Merge_Bug   
)

Definition at line 1585 of file brie_test.cpp.

1596  {133, 455});
1597  c.insert({10033, 455});
1598  a.insertAll(c);
1599 
1600  // a.getStore().dump();
1601 
1602  // ... caused the first element to be missing in the iterator
1603  int count = 0;
1604  for (auto it = a.begin(); it != a.end(); ++it) {
1605  count++;
1606  }
1607 
1608  // if there are 5 elements, everything is fine
1609  EXPECT_EQ(5, count);
1610 }
1611 
1612 TEST(Trie, Size) {
1613  Trie<2> t;
1614 
1615  EXPECT_TRUE(t.empty());
1616  EXPECT_EQ(0, t.size());

◆ TEST() [44/51]

souffle::TEST ( Trie  ,
Merge_Stress   
)

Definition at line 1557 of file brie_test.cpp.

1560  {
1561  Trie<2> b;
1562  for (int i = 0; i < N; i++) {
1563  RamDomain x = rand(N / 2);
1564  RamDomain y = rand(N / 2);
1565  if (!a.contains({x, y})) {
1566  b.insert({x, y});
1567  ref.insert(entry_t{x, y});
1568  }
1569  }
1570 
1571  a.insertAll(b);
1572 
1573  std::set<entry_t> is(a.begin(), a.end());
1574  std::set<entry_t> should(ref.begin(), ref.end());
1575  EXPECT_EQ(should, is);
1576  }
1577 }
1578 
1579 TEST(Trie, Merge_Bug) {
1580  // having this set ...
1581  Trie<2> a;
1582  a.insert({25129, 67714});
1583  a.insert({25132, 67714});

References b, souffle::Trie< Dim >::begin(), souffle::Trie< Dim >::contains(), souffle::Trie< Dim >::end(), EXPECT_EQ, and i.

Here is the call graph for this function:

◆ TEST() [45/51]

souffle::TEST ( Trie  ,
Parallel   
)

Definition at line 1680 of file brie_test.cpp.

1682  {
1683  entry_t entry{(RamDomain)(random() % N), (RamDomain)(random() % N)};
1684  if (filter.insert(entry)) {
1685  list.push_back(entry);
1686  }
1687  }
1688 
1689  // the number of times duplicates show up in the input set
1690  for (int dup = 1; dup < 4; dup++) {
1691  // now duplicate this list
1692  std::vector<entry_t> full;
1693  for (int i = 0; i < dup; i++) {
1694  for (const auto& cur : list) {
1695  full.push_back(cur);
1696  }
1697  }
1698 
1699  // shuffle data
1700  std::random_device rd;
1701  std::mt19937 generator(rd());
1702 
1703  std::shuffle(full.begin(), full.end(), generator);
1704 
1705  // now insert all those values into a new set - in parallel
1706  Trie<2> res;
1707 #pragma omp parallel for
1708  for (auto it = full.begin(); it < full.end(); ++it) {
1709  res.insert(*it);
1710  }
1711 
1712  // check resulting values
1713  EXPECT_EQ(N, res.size());
1714 
1715  std::set<entry_t> should(full.begin(), full.end());
1716  std::set<entry_t> is(res.begin(), res.end());
1717 
1718  for (const auto& cur : should) {
1719  EXPECT_TRUE(res.contains(cur)) << "Missing: " << cur << "\n";
1720  }
1721 
1722  for (const auto& cur : res) {
1723  EXPECT_TRUE(should.find(cur) != should.end()) << "Additional: " << cur << "\n"
1724  << "Contained: " << res.contains(cur) << "\n";
1725  }
1726 
1727  std::vector<entry_t> extra;
1728  for (const auto& cur : is) {
1729  if (should.find(cur) == should.end()) extra.push_back(cur);
1730  }
1731  EXPECT_TRUE(extra.empty()) << "Extra elments: " << extra << "\n";
1732 
1733  std::vector<entry_t> missing;
1734  for (const auto& cur : should) {
1735  if (is.find(cur) == is.end()) missing.push_back(cur);
1736  }
1737  EXPECT_TRUE(missing.empty()) << "Missing elments: " << missing << "\n"
1738  << "All Elements: " << should << "\n";
1739 
1740  EXPECT_EQ(N, should.size());
1741  EXPECT_EQ(N, is.size());
1742  EXPECT_EQ(should, is);
1743  }
1744 }
1745 
1746 } // namespace souffle

References filter().

Here is the call graph for this function:

◆ TEST() [46/51]

souffle::TEST ( Trie  ,
RangeQuery   
)

Definition at line 1274 of file brie_test.cpp.

1274  {i, j, k});
1275  }
1276  }
1277  }
1278 
1279  EXPECT_EQ(1000, set.size());
1280 
1281  // Range [*,*,*]
1282  EXPECT_EQ(1000, card(set.getBoundaries<0>({3, 4, 5})));
1283 
1284  // Range [3,*,*]
1285  EXPECT_EQ(100, card(set.getBoundaries<1>({3, 4, 5})));
1286 
1287  // Range [3,4,*]
1288  EXPECT_EQ(10, card(set.getBoundaries<2>({3, 4, 5})));
1289 
1290  // Range [3,4,5]
1291  EXPECT_EQ(1, card(set.getBoundaries<3>({3, 4, 5})));
1292 }
1293 
1294 TEST(Trie, RangeQuery_1D) {
1295  Trie<1> set;
1296 
1297  // empty set
1298  EXPECT_EQ(0, card(set.getBoundaries<0>({3})));

References i, j, and k.

◆ TEST() [47/51]

souffle::TEST ( Trie  ,
RangeQuery_1D   
)

Definition at line 1300 of file brie_test.cpp.

1302  {
1303  set.insert({i});
1304  }
1305 
1306  EXPECT_EQ(5, card(set.getBoundaries<0>({3})));
1307  EXPECT_EQ(5, card(set.getBoundaries<0>({7})));
1308 
1309  EXPECT_EQ(1, card(set.getBoundaries<1>({3})));
1310  EXPECT_EQ(0, card(set.getBoundaries<1>({7})));
1311 }
1312 
1313 TEST(Trie, RangeQuery_2D) {
1314  Trie<2> set;
1315 
1316  // empty set
1317  EXPECT_EQ(0, card(set.getBoundaries<0>({3, 4})));

References i.

◆ TEST() [48/51]

souffle::TEST ( Trie  ,
RangeQuery_2D   
)

Definition at line 1319 of file brie_test.cpp.

1319  {3, 4})));
1320 
1321  // add some elements
1322  for (int i = 0; i < 5; i++) {
1323  for (int j = 0; j < 5; j++) {
1324  set.insert({i, j});
1325  }
1326  }
1327 
1328  EXPECT_EQ(25, card(set.getBoundaries<0>({3, 4})));
1329  EXPECT_EQ(25, card(set.getBoundaries<0>({7, 4})));
1330  EXPECT_EQ(25, card(set.getBoundaries<0>({3, 7})));
1331 
1332  EXPECT_EQ(5, card(set.getBoundaries<1>({3, 4})));
1333  EXPECT_EQ(0, card(set.getBoundaries<1>({7, 4})));
1334  EXPECT_EQ(5, card(set.getBoundaries<1>({3, 7})));
1335 
1336  EXPECT_EQ(1, card(set.getBoundaries<2>({3, 4})));
1337  EXPECT_EQ(0, card(set.getBoundaries<2>({7, 4})));
1338  EXPECT_EQ(0, card(set.getBoundaries<2>({3, 7})));
1339 }
1340 
1341 TEST(Trie, RangeQuery_3D) {
1342  Trie<3> set;
1343 
1344  // empty set
1345  EXPECT_EQ(0, card(set.getBoundaries<0>({3, 4, 2})));

◆ TEST() [49/51]

souffle::TEST ( Trie  ,
RangeQuery_3D   
)

Definition at line 1347 of file brie_test.cpp.

1347  {3, 4, 2})));
1348  EXPECT_EQ(0, card(set.getBoundaries<3>({3, 4, 2})));
1349 
1350  // add some elements
1351  for (int i = 0; i < 5; i++) {
1352  for (int j = 0; j < 5; j++) {
1353  for (int k = 0; k < 5; k++) {
1354  set.insert({i, j, k});
1355  }
1356  }
1357  }
1358 
1359  EXPECT_EQ(125, card(set.getBoundaries<0>({3, 4, 2})));
1360  EXPECT_EQ(125, card(set.getBoundaries<0>({7, 4, 2})));
1361  EXPECT_EQ(125, card(set.getBoundaries<0>({3, 7, 2})));
1362  EXPECT_EQ(125, card(set.getBoundaries<0>({3, 7, 8})));
1363 
1364  EXPECT_EQ(25, card(set.getBoundaries<1>({3, 4, 2})));
1365  EXPECT_EQ(0, card(set.getBoundaries<1>({7, 4, 2})));
1366  EXPECT_EQ(25, card(set.getBoundaries<1>({3, 7, 2})));
1367  EXPECT_EQ(25, card(set.getBoundaries<1>({3, 7, 8})));
1368 
1369  EXPECT_EQ(5, card(set.getBoundaries<2>({3, 4, 2})));
1370  EXPECT_EQ(0, card(set.getBoundaries<2>({7, 4, 2})));
1371  EXPECT_EQ(0, card(set.getBoundaries<2>({3, 7, 2})));
1372  EXPECT_EQ(0, card(set.getBoundaries<2>({3, 7, 8})));
1373  EXPECT_EQ(5, card(set.getBoundaries<2>({3, 2, 8})));
1374 
1375  EXPECT_EQ(1, card(set.getBoundaries<3>({3, 4, 2})));
1376  EXPECT_EQ(0, card(set.getBoundaries<3>({7, 4, 2})));
1377  EXPECT_EQ(0, card(set.getBoundaries<3>({3, 7, 2})));
1378  EXPECT_EQ(0, card(set.getBoundaries<3>({3, 7, 8})));
1379 }
1380 
1381 TEST(Trie, RangeQueryStress) {
1382  Trie<3> set;
1383 
1384  for (int i = 0; i < 10; i++) {
1385  for (int j = 0; j < 10; j++) {

◆ TEST() [50/51]

souffle::TEST ( Trie  ,
RangeQueryStress   
)

Definition at line 1387 of file brie_test.cpp.

1387  {i, j, k});
1388  }
1389  }
1390  }
1391 
1392  EXPECT_EQ(1000, set.size());
1393 
1394  // Range [*,*,*]
1395  EXPECT_EQ(1000, card(set.getBoundaries<0>({3, 4, 5})));
1396 
1397  // Range [x,*,*]
1398  for (RamDomain x = 0; x < 10; x++) {
1399  EXPECT_EQ(100, card(set.getBoundaries<1>({x, 4, 5})));
1400  }
1401 
1402  // Range [x,y,*]
1403  for (RamDomain x = 0; x < 10; x++) {
1404  for (RamDomain y = 0; y < 10; y++) {
1405  EXPECT_EQ(10, card(set.getBoundaries<2>({x, y, 5})));
1406  }
1407  }
1408 
1409  // Range [x,y,*]
1410  for (RamDomain x = 0; x < 10; x++) {
1411  for (RamDomain y = 0; y < 10; y++) {
1412  for (RamDomain z = 0; z < 10; z++) {
1413  EXPECT_EQ(1, card(set.getBoundaries<3>({x, y, z})));
1414  }
1415  }
1416  }
1417 }
1418 
1419 TEST(Trie, Merge_1D) {
1420  Trie<1> e;
1421  Trie<1> a;
1422  Trie<1> b;
1423 

References i, j, and k.

◆ TEST() [51/51]

souffle::TEST ( Trie  ,
Size   
)

Definition at line 1618 of file brie_test.cpp.

1618  {1, 2});
1619 
1620  EXPECT_FALSE(t.empty());
1621  EXPECT_EQ(1, t.size());
1622 
1623  t.insert({1, 2});
1624 
1625  EXPECT_FALSE(t.empty());
1626  EXPECT_EQ(1, t.size());
1627 
1628  t.insert({2, 1});
1629 
1630  EXPECT_FALSE(t.empty());
1631  EXPECT_EQ(2, t.size());
1632 
1633  Trie<2> t2;
1634 
1635  t2.insert({1, 2});
1636  t2.insert({1, 3});
1637  t2.insert({1, 4});
1638  t2.insert({3, 2});
1639 
1640  EXPECT_EQ(4, t2.size());
1641 
1642  t.insertAll(t2);
1643  EXPECT_FALSE(t.empty());
1644  EXPECT_EQ(5, t.size());
1645 }
1646 
1647 TEST(Trie, Limits) {
1648  Trie<2> data;
1649 
1650  EXPECT_EQ(0, data.size());
1651  data.insert({10, 15});

◆ times()

template<typename T >
detail::multiplying_printer<T> souffle::times ( const T &  value,
unsigned  num 
)

◆ toBase64()

std::string souffle::toBase64 ( const std::string &  data)
inline

Definition at line 173 of file GraphUtils.h.

175  {
176  padding = 1;
177  } else if (data.size() % 3 == 1) {
178  padding = 2;
179  }
180 
181  for (unsigned int i = 0; i < padding; i++) {
182  tmp.push_back(0);
183  }
184  for (unsigned int i = 0; i < tmp.size(); i += 3) {
185  auto c1 = static_cast<unsigned char>(tmp[i]);
186  auto c2 = static_cast<unsigned char>(tmp[i + 1]);
187  auto c3 = static_cast<unsigned char>(tmp[i + 2]);
188  unsigned char index1 = c1 >> 2;
189  unsigned char index2 = ((c1 & 0x03) << 4) | (c2 >> 4);
190  unsigned char index3 = ((c2 & 0x0F) << 2) | (c3 >> 6);
191  unsigned char index4 = c3 & 0x3F;
192 
193  result.push_back(table[index1]);
194  result.push_back(table[index2]);
195  result.push_back(table[index3]);
196  result.push_back(table[index4]);
197  }
198  if (padding == 1) {
199  result[result.size() - 1] = '=';
200  } else if (padding == 2) {
201  result[result.size() - 1] = '=';
202  result[result.size() - 2] = '=';
203  }
204  return result;
205 }
206 
207 inline std::string convertDotToSVG(const std::string& dotSpec) {
208  // Check if dot is present
209  std::string cmd = which("dot");
210  if (!isExecutable(cmd)) {
211  return "";

◆ toBinaryConstraintOp()

BinaryConstraintOp souffle::toBinaryConstraintOp ( const std::string &  symbol)
inline

Converts symbolic representation of an operator to the operator.

Note that this won't tell you which polymorphic overload is actually used.

Definition at line 371 of file BinaryConstraintOps.h.

377  : symbol = `%s`", symbol);
378 }
379 
380 /**
381  * Determines whether arguments of constraint are orderable
382  */
383 inline bool isOrderedBinaryConstraintOp(const BinaryConstraintOp op) {
384  switch (op) {

◆ toBinaryConstraintSymbol()

char const * souffle::toBinaryConstraintSymbol ( const BinaryConstraintOp  op)
inline

Converts operator to its symbolic representation.

Definition at line 336 of file BinaryConstraintOps.h.

336  :
337  case BinaryConstraintOp::ULT:
338  case BinaryConstraintOp::FLT:
339  case BinaryConstraintOp::LT: return "<";
340  case BinaryConstraintOp::SLE:
341  case BinaryConstraintOp::ULE:
342  case BinaryConstraintOp::FLE:
343  case BinaryConstraintOp::LE: return "<=";
344  case BinaryConstraintOp::SGT:
345  case BinaryConstraintOp::UGT:
346  case BinaryConstraintOp::FGT:
347  case BinaryConstraintOp::GT: return ">";
348  case BinaryConstraintOp::SGE:
349  case BinaryConstraintOp::UGE:
350  case BinaryConstraintOp::FGE:
351  case BinaryConstraintOp::GE: return ">=";
352  case BinaryConstraintOp::MATCH: return "match";
353  case BinaryConstraintOp::CONTAINS: return "contains";
354  case BinaryConstraintOp::NOT_MATCH: return "not_match";
355  case BinaryConstraintOp::NOT_CONTAINS: return "not_contains";
356  }
357 
359 }
360 
361 /**
362  * Converts symbolic representation of an operator to the operator.
363  * Note that this won't tell you which polymorphic overload is actually used.
364  */
365 inline BinaryConstraintOp toBinaryConstraintOp(const std::string& symbol) {

◆ toPtrVector()

template<typename T >
std::vector<T*> souffle::toPtrVector ( const std::vector< std::unique_ptr< T >> &  v)

◆ toString() [1/3]

const std::string& souffle::toString ( const std::string &  str)
inline

◆ toString() [2/3]

template<typename T >
std::enable_if<!detail::is_printable<T>::value, std::string>::type souffle::toString ( const T &  )

A fallback for the to-string function in case an unprintable object is supposed to be printed.

Definition at line 277 of file StringUtil.h.

◆ toString() [3/3]

template<typename T >
std::enable_if<detail::is_printable<T>::value, std::string>::type souffle::toString ( const T &  value)

A generic function converting arbitrary objects to strings by utilizing their print capability.

This function is mainly intended for implementing test cases and debugging operations.

Definition at line 265 of file StringUtil.h.

◆ toVector() [1/2]

template<typename T >
std::vector<T> souffle::toVector ( )

A utility function enabling the creation of a vector with a fixed set of elements within a single expression.

This is the base case covering empty vectors.

Definition at line 128 of file ContainerUtil.h.

Referenced by TEST().

◆ toVector() [2/2]

template<typename T , typename... R>
std::vector<T> souffle::toVector ( const T &  first,
const R &...  rest 
)

A utility function enabling the creation of a vector with a fixed set of elements within a single expression.

This is the step case covering vectors of arbitrary length.

Definition at line 138 of file ContainerUtil.h.

140  {

References e.

◆ unescape() [1/2]

std::string souffle::unescape ( const std::string &  inputString)
inline

Definition at line 409 of file StringUtil.h.

412  {
413  std::string result = inputString;
414  size_t pos = 0;
415  while ((pos = result.find(needle, pos)) != std::string::npos) {

◆ unescape() [2/2]

std::string souffle::unescape ( const std::string &  inputString,
const std::string &  needle,
const std::string &  replacement 
)
inline

Definition at line 398 of file StringUtil.h.

403  {
404  std::string unescaped = unescape(inputString, "\\\"", "\"");
405  unescaped = unescape(unescaped, "\\t", "\t");
406  unescaped = unescape(unescaped, "\\r", "\r");
407  unescaped = unescape(unescaped, "\\n", "\n");

◆ which()

std::string souffle::which ( const std::string &  name)
inline

Simple implementation of a which tool.

Definition at line 104 of file FileUtil.h.

105  {
106  return "";
107  }
108  char buf[PATH_MAX];
109  std::stringstream sstr;
110  sstr << syspath;
111  std::string sub;
112 
113  // Check for existence of a binary called 'name' in PATH
114  while (std::getline(sstr, sub, ':')) {
115  std::string path = sub + "/" + name;
116  if ((::realpath(path.c_str(), buf) != nullptr) && isExecutable(path) && !existDir(path)) {
117  return buf;
118  }
119  }
120  return "";
121 }
122 
123 /**
124  * C++-style dirname
125  */
126 inline std::string dirName(const std::string& name) {
127  if (name.empty()) {

Variable Documentation

◆ dynamic_extent

constexpr auto souffle::dynamic_extent = tcb::dynamic_extent
constexpr

Definition at line 656 of file span.h.

◆ FUNCTOR_INTRINSIC_PREFIX_NEGATE_NAME

constexpr char souffle::FUNCTOR_INTRINSIC_PREFIX_NEGATE_NAME[] = "negate"
constexpr

Definition at line 147 of file FunctorOps.h.

Referenced by isInfixFunctorOp().

◆ isRamType

template<typename T >
constexpr bool souffle::isRamType
constexpr
Initial value:
= (std::is_same<T, RamDomain>::value || std::is_same<T, RamSigned>::value ||
std::is_same<T, RamUnsigned>::value || std::is_same<T, RamFloat>::value)

Definition at line 72 of file RamTypes.h.

◆ JoinShouldDeref

template<typename A >
constexpr bool souffle::JoinShouldDeref = IsPtrLike<A>::value && !std::is_same_v<A, char const*>
constexpr

Definition at line 206 of file StreamUtil.h.

◆ MAX_RAM_FLOAT

constexpr RamFloat souffle::MAX_RAM_FLOAT = std::numeric_limits<RamFloat>::max()
constexpr

Definition at line 103 of file RamTypes.h.

Referenced by souffle::interpreter::Engine::evalAggregate().

◆ MAX_RAM_SIGNED

constexpr RamSigned souffle::MAX_RAM_SIGNED = std::numeric_limits<RamSigned>::max()
constexpr

Definition at line 97 of file RamTypes.h.

Referenced by souffle::interpreter::Engine::evalAggregate().

◆ MAX_RAM_UNSIGNED

constexpr RamUnsigned souffle::MAX_RAM_UNSIGNED = std::numeric_limits<RamUnsigned>::max()
constexpr

Definition at line 100 of file RamTypes.h.

Referenced by souffle::interpreter::Engine::evalAggregate().

◆ MIN_RAM_FLOAT

constexpr RamFloat souffle::MIN_RAM_FLOAT = std::numeric_limits<RamFloat>::lowest()
constexpr

Definition at line 102 of file RamTypes.h.

Referenced by souffle::interpreter::Engine::evalAggregate().

◆ MIN_RAM_SIGNED

constexpr RamSigned souffle::MIN_RAM_SIGNED = std::numeric_limits<RamSigned>::min()
constexpr

lower and upper boundaries for the ram types

Definition at line 96 of file RamTypes.h.

Referenced by souffle::interpreter::Engine::evalAggregate().

◆ MIN_RAM_UNSIGNED

constexpr RamUnsigned souffle::MIN_RAM_UNSIGNED = std::numeric_limits<RamUnsigned>::min()
constexpr

Definition at line 99 of file RamTypes.h.

Referenced by souffle::interpreter::Engine::evalAggregate().

◆ rank_mask

constexpr block_t souffle::rank_mask = (1ul << split_size) - 1
constexpr

Definition at line 49 of file UnionFind.h.

Referenced by souffle::DisjointSet::b2p().

◆ split_size

constexpr uint8_t souffle::split_size = 8u
constexpr

Definition at line 44 of file UnionFind.h.

Referenced by souffle::DisjointSet::b2r().

souffle::baseName
std::string baseName(const std::string &filename)
Definition: FileUtil.h:199
souffle::tempFile
std::string tempFile()
Generate temporary file.
Definition: FileUtil.h:257
souffle::RamUnsigned
uint32_t RamUnsigned
Definition: RamTypes.h:58
souffle::RamSignedFromString
RamSigned RamSignedFromString(const std::string &str, std::size_t *position=nullptr, const int base=10)
Converts a string to a RamSigned.
Definition: StringUtil.h:51
souffle::simpleName
std::string simpleName(const std::string &path)
File name, with extension removed.
Definition: FileUtil.h:219
souffle::compileToBinary
void compileToBinary(std::string compileCmd, const std::string &sourceFilename)
Compiles the given source file to a binary file.
Definition: main.cpp:165
EXPECT_TRUE
#define EXPECT_TRUE(a)
Definition: test.h:189
souffle::existFile
bool existFile(const std::string &name)
Check whether a file exists in the file system.
Definition: FileUtil.h:71
souffle::explain
void explain(SouffleProgram &prog, bool ncurses)
Definition: Explain.h:627
UNREACHABLE_BAD_CASE_ANALYSIS
#define UNREACHABLE_BAD_CASE_ANALYSIS
Definition: MiscUtil.h:206
souffle::isPrefix
bool isPrefix(const std::string &prefix, const std::string &element)
Determine if one string is a prefix of another.
Definition: StringUtil.h:292
CASE_NUMERIC
#define CASE_NUMERIC(op)
souffle::toBase64
std::string toBase64(const std::string &data)
Definition: GraphUtils.h:173
TypeAttribute
Type attribute class.
m
var m
Definition: htmlJsChartistMin.h:15
souffle::RamDomain
int32_t RamDomain
Definition: RamTypes.h:56
souffle::isNumber
bool isNumber(const char *str)
Check whether a string is a sequence of digits.
Definition: StringUtil.h:217
souffle::getLessThanConstraint
BinaryConstraintOp getLessThanConstraint(const std::string &type)
Definition: BinaryConstraintOps.h:104
souffle::ast::analysis::sub
std::shared_ptr< Constraint< Var > > sub(const Var &a, const Var &b, const std::string &symbol="⊑")
A generic factory for constraints of the form.
Definition: ConstraintSystem.h:228
souffle::getGreaterEqualConstraint
BinaryConstraintOp getGreaterEqualConstraint(const std::string &type)
Definition: BinaryConstraintOps.h:94
souffle::escapeJSONstring
std::string escapeJSONstring(const std::string &JSONstr)
Escape JSON string.
Definition: StringUtil.h:373
ASSERT_LE
#define ASSERT_LE(a, b)
Definition: test.h:213
souffle::convertOverloadedAggregator
AggregateOp convertOverloadedAggregator(const AggregateOp op, const TypeAttribute type)
Convert aggregator to a give type.
Definition: AggregateOp.h:133
PACKAGE_VERSION
#define PACKAGE_VERSION
Definition: config.h:134
souffle::AggregateOp
AggregateOp
Types of aggregation functions.
Definition: AggregateOp.h:34
souffle::RelationTag::PRINTSIZE
@ PRINTSIZE
souffle::contains
bool contains(const C &container, const typename C::value_type &element)
A utility to check generically whether a given element is contained in a given container.
Definition: ContainerUtil.h:75
EXPECT_EQ
#define EXPECT_EQ(a, b)
Definition: test.h:191
souffle::dirName
std::string dirName(const std::string &name)
C++-style dirname.
Definition: FileUtil.h:132
S
#define S(x)
Definition: test.h:179
e
l j a showGridBackground &&c b raw series this eventEmitter e
Definition: htmlJsChartistMin.h:15
souffle::toString
std::enable_if<!detail::is_printable< T >::value, std::string >::type toString(const T &)
A fallback for the to-string function in case an unprintable object is supposed to be printed.
Definition: StringUtil.h:277
souffle::RamFloat
float RamFloat
Definition: RamTypes.h:60
main
int main(int argc, char **argv)
Definition: main.cpp:734
souffle::map
auto map(const std::vector< A > &xs, F &&f)
Applies a function to each element of a vector and returns the results.
Definition: ContainerUtil.h:158
souffle::toBinaryConstraintSymbol
char const * toBinaryConstraintSymbol(const BinaryConstraintOp op)
Converts operator to its symbolic representation.
Definition: BinaryConstraintOps.h:336
base
T & base
Definition: Reader.h:60
souffle::isWeakIneqConstraint
bool isWeakIneqConstraint(const BinaryConstraintOp constraintOp)
Definition: BinaryConstraintOps.h:146
souffle::getLessEqualConstraint
BinaryConstraintOp getLessEqualConstraint(const std::string &type)
Definition: BinaryConstraintOps.h:84
souffle::identifier
std::string identifier(std::string id)
Valid C++ identifier, note that this does not ensure the uniqueness of identifiers returned.
Definition: StringUtil.h:387
souffle::getRelationRepresentationFromTag
RelationRepresentation getRelationRepresentationFromTag(const RelationTag &tag)
Get the corresponding RelationRepresentation for a valid RelationTag.
Definition: RelationTag.h:111
souffle::escape
std::string escape(const std::string &inputString)
Definition: StringUtil.h:428
n
var n
Definition: htmlJsChartistMin.h:15
souffle::fileExtension
std::string fileExtension(const std::string &path)
File extension, with all else removed.
Definition: FileUtil.h:238
j
var j
Definition: htmlJsChartistMin.h:15
souffle::RelationTag::OUTPUT
@ OUTPUT
str
const std::string & str
Definition: json11.h:662
souffle::toString
const std::string & toString(const std::string &str)
A generic function converting strings into strings (trivial case).
Definition: StringUtil.h:234
souffle::Relation
Object-oriented wrapper class for Souffle's templatized relations.
Definition: SouffleInterface.h:49
souffle::now
time_point now()
Definition: MiscUtil.h:89
souffle::clone
auto clone(const std::vector< A * > &xs)
Definition: ContainerUtil.h:172
i
size_t i
Definition: json11.h:663
souffle::filter
std::vector< A > filter(std::vector< A > xs, F &&f)
Filter a vector to include certain elements.
Definition: FunctionalUtil.h:155
souffle::convertStrictToNotEqualConstraint
BinaryConstraintOp convertStrictToNotEqualConstraint(const BinaryConstraintOp constraintOp)
Definition: BinaryConstraintOps.h:173
souffle::getRelationQualifierFromTag
RelationQualifier getRelationQualifierFromTag(const RelationTag &tag)
Get the corresponding RelationQualifier for a valid RelationTag.
Definition: RelationTag.h:95
souffle::join
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...
Definition: StreamUtil.h:175
souffle::functorBuiltIn
IntrinsicFunctors functorBuiltIn(std::string_view symbol, const std::vector< TypeAttribute > &params)
Definition: FunctorOps.cpp:232
souffle::isInfixFunctorOp
bool isInfixFunctorOp(const FunctorOp op)
Definition: FunctorOps.cpp:262
souffle::any_of
bool any_of(const Container &c, UnaryPredicate p)
A generic test checking whether any elements within a container satisfy a certain predicate.
Definition: FunctionalUtil.h:124
souffle::main
int main(int argc, char **argv)
Definition: main.cpp:191
souffle::execStdOut
std::stringstream execStdOut(std::string const &cmd)
Definition: FileUtil.h:288
rul
void rul(size_t limit, bool showLimit=true)
Definition: Tui.h:1106
souffle::profile::Tools::cleanJsonOut
std::string cleanJsonOut(std::string value)
escape escapes and quotes, and remove surrounding quotes
Definition: StringUtils.h:232
souffle::RelationTag
RelationTag
Space of user-chosen tags that a relation can have.
Definition: RelationTag.h:31
souffle::convertOverloadedConstraint
BinaryConstraintOp convertOverloadedConstraint(const BinaryConstraintOp constraintOp, const TypeAttribute toType)
Convert Constraint to work with requested type.
Definition: BinaryConstraintOps.h:248
souffle::toBinaryConstraintOp
BinaryConstraintOp toBinaryConstraintOp(const std::string &symbol)
Converts symbolic representation of an operator to the operator.
Definition: BinaryConstraintOps.h:371
souffle::test::count
int count(const C &c)
Definition: table_test.cpp:40
TCB_SPAN_NAMESPACE_NAME::get
constexpr auto get(span< E, S > s) -> decltype(s[N])
Definition: span.h:599
souffle::isInfixFunctorOp
bool isInfixFunctorOp(const BinaryConstraintOp op)
Determines whether a functor should be written using infix notation (e.g.
Definition: BinaryConstraintOps.h:425
souffle::existDir
bool existDir(const std::string &name)
Check whether a directory exists in the file system.
Definition: FileUtil.h:84
souffle::isExecutable
bool isExecutable(const std::string &name)
Check whether a given file exists and it is an executable.
Definition: FileUtil.h:97
souffle::profile::Tools::split
std::vector< std::string > split(std::string toSplit, std::string delimiter)
split on the delimiter
Definition: StringUtils.h:162
souffle::aggregateArity
std::pair< uint8_t, uint8_t > aggregateArity(AggregateOp op)
Definition: AggregateOp.h:74
souffle::BinaryConstraintOp
BinaryConstraintOp
Binary Constraint Operators.
Definition: BinaryConstraintOps.h:41
ASSERT_TRUE
#define ASSERT_TRUE(a)
Definition: test.h:212
souffle::getBinaryConstraintTypes
std::vector< TypeAttribute > getBinaryConstraintTypes(const BinaryConstraintOp op)
Get type binary constraint operates on.
Definition: BinaryConstraintOps.h:439
souffle::unescape
std::string unescape(const std::string &inputString)
Definition: StringUtil.h:409
souffle::isEqConstraint
bool isEqConstraint(const BinaryConstraintOp constraintOp)
Definition: BinaryConstraintOps.h:124
k
var k
Definition: htmlJsChartistMin.h:15
souffle::findTool
std::string findTool(const std::string &tool, const std::string &base, const std::string &path)
Definition: FileUtil.h:182
EXPECT_NE
#define EXPECT_NE(a, b)
Definition: test.h:195
souffle::which
std::string which(const std::string &name)
Simple implementation of a which tool.
Definition: FileUtil.h:104
souffle::getTypeAttributeAggregate
TypeAttribute getTypeAttributeAggregate(const AggregateOp op)
Get return type of the aggregate.
Definition: AggregateOp.h:96
souffle::TEST
TEST(Trie, Parallel)
Definition: brie_test.cpp:1680
souffle::isStrictIneqConstraint
bool isStrictIneqConstraint(const BinaryConstraintOp constraintOp)
Definition: BinaryConstraintOps.h:133
souffle::all_of
bool all_of(const Container &c, UnaryPredicate p)
A generic test checking whether all elements within a container satisfy a certain predicate.
Definition: FunctionalUtil.h:110
souffle::absPath
std::string absPath(const std::string &path)
C++-style realpath.
Definition: FileUtil.h:156
souffle::test::time
long time(const std::string &name, const Op &operation)
Definition: btree_multiset_test.cpp:411
b
l j a showGridBackground &&c b raw series this eventEmitter b
Definition: htmlJsChartistMin.h:15
souffle::RelationRepresentation::DEFAULT
@ DEFAULT
souffle::getCurrentFilename
std::string getCurrentFilename(const std::vector< std::string > &filenames)
Definition: SrcLocation.cpp:33
souffle::convertDotToSVG
std::string convertDotToSVG(const std::string &dotSpec)
Definition: GraphUtils.h:213
souffle::splitString
std::vector< std::string > splitString(const std::string &str, char delimiter)
Splits a string given a delimiter.
Definition: StringUtil.h:321
souffle::executeBinary
void executeBinary(const std::string &binaryFilename)
Executes a binary file.
Definition: main.cpp:124
souffle::fatal
void fatal(const char *format, const Args &... args)
Definition: MiscUtil.h:198
COMPARE_OP
#define COMPARE_OP(op)
souffle::RamUnsignedFromString
RamUnsigned RamUnsignedFromString(const std::string &str, std::size_t *position=nullptr, const int base=10)
Converts a string to a RamUnsigned.
Definition: StringUtil.h:110
souffle::join
std::enable_if_t< JoinShouldDeref< T >, detail::joined_sequence< Iter, detail::print< deref< T > > > > join(const Container &c, const std::string &sep=",")
Definition: StreamUtil.h:223
souffle::RelationTag::INPUT
@ INPUT
TCB_SPAN_NAMESPACE_NAME::detail::data
constexpr auto data(C &c) -> decltype(c.data())
Definition: span.h:210
RAM_DOMAIN_SIZE
#define RAM_DOMAIN_SIZE
Types of elements in a tuple.
Definition: RamTypes.h:46
COMPARE_EQUALS
#define COMPARE_EQUALS(op)
souffle::operator<<
std::ostream & operator<<(std::ostream &os, RelationRepresentation representation)
Definition: RelationTag.h:153
souffle::RamFloatFromString
RamFloat RamFloatFromString(const std::string &str, std::size_t *position=nullptr)
Converts a string to a RamFloat.
Definition: StringUtil.h:93
COMPARE_CONSTRAINT_FLOAT_OR_RAW
#define COMPARE_CONSTRAINT_FLOAT_OR_RAW(op)
souffle::getGreaterThanConstraint
BinaryConstraintOp getGreaterThanConstraint(const std::string &type)
Definition: BinaryConstraintOps.h:114
souffle::RelationRepresentation
RelationRepresentation
Space of internal representations that a relation can have.
Definition: RelationTag.h:56
souffle::isLessThan
bool isLessThan(const BinaryConstraintOp constraintOp)
Definition: BinaryConstraintOps.h:187
souffle::RelationQualifier
RelationQualifier
Space of qualifiers that a relation can have.
Definition: RelationTag.h:45
COMPARE_CONSTRAINT
#define COMPARE_CONSTRAINT(op)
EXPECT_FALSE
#define EXPECT_FALSE(a)
Definition: test.h:190
std::type
ElementType type
Definition: span.h:640
souffle::convertStrictToWeakIneqConstraint
BinaryConstraintOp convertStrictToWeakIneqConstraint(const BinaryConstraintOp constraintOp)
Definition: BinaryConstraintOps.h:159
souffle::RelationTag::BRIE
@ BRIE
souffle::RelationTag::BTREE
@ BTREE
souffle::profile::ss
class souffle::profile::Tui ss
Definition: Tui.h:336
souffle::isOverloadedAggregator
bool isOverloadedAggregator(const AggregateOp op)
Definition: AggregateOp.h:116
souffle::FUNCTOR_INTRINSIC_PREFIX_NEGATE_NAME
constexpr char FUNCTOR_INTRINSIC_PREFIX_NEGATE_NAME[]
Definition: FunctorOps.h:147