SQLamarr
The stand-alone ultra-fast simulation option for the LHCb experiment
SQLamarr::Plugin Class Reference

Interface to dynamically linked generative parametrizations. More...

#include <Plugin.h>

Inheritance diagram for SQLamarr::Plugin:

Classes

class  Plugin
 Wrap an external function as defined in a compiled shared library. More...
 

Public Member Functions

 Plugin (SQLite3DB &db, const std::string &library, const std::string &function_name, const std::string &select_query, const std::string &output_table, const std::vector< std::string > outputs, const std::vector< std::string > reference_keys={"ref_id"})
 Constructor. More...
 
- Public Member Functions inherited from SQLamarr::BasePlugin
 BasePlugin (SQLite3DB &db, const std::string &library, const std::string &function_name, const std::string &select_query, const std::string &output_table, const std::vector< std::string > outputs, const std::vector< std::string > reference_keys={"ref_id"})
 Constructor. More...
 
 BasePlugin (BasePlugin &)=delete
 
virtual ~BasePlugin ()
 
void execute () override
 Execute the external function and copies the output in a new table. More...
 
- Public Member Functions inherited from SQLamarr::BaseSqlInterface
 BaseSqlInterface (SQLite3DB &db)
 Constructor, acquiring the database without ownership. More...
 
virtual ~BaseSqlInterface ()
 
void sync_database (const std::string &db_uri)
 
void invalidate_cache (void)
 Invalidate the cache of the queries. More...
 

Public Attributes

 argtypes
 
 restype
 

Additional Inherited Members

- Protected Member Functions inherited from SQLamarr::BasePlugin
template<typename Func_t >
Func_t load_func (const std::string &fname)
 Load a generic-typed function from an external library. More...
 
- Protected Member Functions inherited from SQLamarr::BaseSqlInterface
sqlite3_stmt * get_statement (const std::string &name, const std::string &query)
 Creates or retrieve from cache a statement. More...
 
void begin_transaction ()
 Begin an SQL transaction stopping update to disk util end_transaction() is issued
More...
 
void end_transaction ()
 End an SQL transaction re-enabling disk updates. More...
 
int last_insert_row ()
 Return the index of the last rows inserted in any table. More...
 
void using_sql_function (const std::string &name, int argc, void(*xFunc)(sqlite3_context *, int, sqlite3_value **))
 Register a static function in DB, enabling usage from SQL. More...
 
bool exec_stmt (sqlite3_stmt *)
 Execute a statement, possibly throwing an exception on failure. More...
 
- Protected Attributes inherited from SQLamarr::BaseSqlInterface
SQLite3DBm_database
 Reference to the SQLite database (not owned). More...
 

Detailed Description

Interface to dynamically linked generative parametrizations.

A SQLamarr::Plugin is a parametrization defined in a shared object dynamically linked at run time.

Plugin specialize the BasePlugin class to parametrizations taking as an input one or more normally distributed random features. These additional random features are usually injected at some point of the pipeline generating random features according to a pdf conditioned by the features.

As for the all classes inheriting from BasePlugin class, Plugin takes care of selecting the input columns from the database, links the external ibrary based on its path and the name of the function and finally creates a table with the output.

If a table with the same name as the output table exists in the database, it is overwritten without warning.

In order to match the output table to the input, one or more integer variables can be defined as reference keys which are not used as inputs for the parametrization, but transparently copied to the output table.

Definition at line 45 of file Plugin.h.

Constructor & Destructor Documentation

◆ Plugin()

SQLamarr::Plugin::Plugin ( SQLite3DB db,
const std::string &  library,
const std::string &  function_name,
const std::string &  select_query,
const std::string &  output_table,
const std::vector< std::string >  outputs,
const std::vector< std::string >  reference_keys = {"ref_id"} 
)
inline

Constructor.

Parameters
dbReference to the database, passed without ownership
libraryPath to the shared object (library). If in CWD, prepend "./".
function_nameLinking symbol of the target function as set at compile-time
select_querySQL Query selecting the inputs. Number and order of the parameters columns are relevant. Names not listed in `reference_keys` are ignored.
output_tableSQL name of the output table. Must be alphanumeric.
outputsVector of column names for the output table. The order must match the output produced by the compiled parametrization.
reference_keysList of column names ignored.

Definition at line 49 of file Plugin.h.

Member Data Documentation

◆ argtypes

SQLamarr.Plugin.argtypes

Definition at line 17 of file Plugin.py.

◆ restype

SQLamarr.Plugin.restype

Definition at line 27 of file Plugin.py.


The documentation for this class was generated from the following files: