The datalog_source module¶
Generic interface for datasources used by theory
-
class
octant.datalog_source.Datasource(types)¶ Represents the source of facts used by the Datalog interpreter
Parameters: types – Basic types used by the source. -
get_table_types(table, fields)¶ Return the types of the fields for a given table
Parameters: - table – the table name
- fields – a list of field names
Returns: a list of the type names of the fiels
-
is_extensible(atom)¶ Check if the atom uses a table registered in the datasource
Parameters: atom – the atom Returns: a boolean
-
register(session, accessors)¶ Registers a new source.
A source is described by a way to create a sessions and accessors to populate each table. The complete type using Haskell-like existential type (generics with limited scope) would be:
(session: Callable[[], S], accessor: Dict[ str, Forall[R, Tuple[ Callable[[S], R], Dict[str, Tuple[str, Callable[[R], int | str]]]]]] ) -> None
Parameters: - session – a callback
() -> SwhereSis the type of a session. - accessors – a map where keys are table (predicate)
names and values are pairs of a row accessor of type
(S) -> RwhereRis the type of the internal datasource row representation and a map that associates to each field name of the row a pair of the name of an octant typetand a field accessor of type(R) -> TwhereTis the source representation oft.
- session – a callback
-
retrieve_table(table_name, fields, mk_relation, extract=None)¶ Get the facts on the cloud or in the csv cache.
Parameters: - table_name – the name of the table to retrieve
- fields – the list of field names of the table used
- mk_relation – a callback called on each row an taking a row value as a list of Z3 objects associated to each field and creating a fact in the Z3 context for the row.
- extract – an optional list of integer indexes defining the args to give back as a result (used by unfolding)
Returns: None or a list of tuples for the columns requested in extract.
-
use_cache()¶ check if it uses the cache
-