SQLamarr
The stand-alone ultra-fast simulation option for the LHCb experiment
SQLamarr::BasePlugin Class Referenceabstract

Interface to dynamically linked parametrizations. More...

#include <BasePlugin.h>

Inheritance diagram for SQLamarr::BasePlugin:

Public Member Functions

 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 ()
 

Protected Member Functions

virtual void eval_parametrization (float *output, const float *input)=0
 Evaluate the external parametrization. More...
 
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...
 

Additional Inherited Members

- Protected Attributes inherited from SQLamarr::BaseSqlInterface
SQLite3DBm_database
 Reference to the SQLite database (not owned). More...
 

Detailed Description

Interface to dynamically linked parametrizations.

A SQLamarr BasePlugin is a parametrization defined in a shared object dynamically linked at run time. For an example to generate such parametrizations, please refer to the scikinC project.

The BasePlugin class is an abstract class defining a generic interface. Client applications are expected to use specialized plugins, obtained by defining the function signature and its call.

In particular, the function eval_parametrization is a pure virtual function that must be overridden with the logic to call the dynamically loaded function with the appropriate signature.

The BasePlugin class implements selecting the input columns from the database, links the external library 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.

See also
SQLamarr::Plugin implementing the function signature float* (float*, const float*)
SQLamarr::GenerativePlugin implementing the function signature float* (float*, const float*)

Definition at line 59 of file BasePlugin.h.

Constructor & Destructor Documentation

◆ BasePlugin() [1/2]

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.

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 29 of file BasePlugin.cpp.

◆ BasePlugin() [2/2]

SQLamarr::BasePlugin::BasePlugin ( BasePlugin )
delete

◆ ~BasePlugin()

virtual SQLamarr::BasePlugin::~BasePlugin ( )
inlinevirtual

Definition at line 86 of file BasePlugin.h.

Member Function Documentation

◆ eval_parametrization()

virtual void SQLamarr::BasePlugin::eval_parametrization ( float *  output,
const float *  input 
)
protectedpure virtual

Evaluate the external parametrization.

This function can be overridden to provide custom preprocessing and postprocessing steps, or to link to functions with custom signature.

◆ execute()

void SQLamarr::BasePlugin::execute ( void  )
overridevirtual

Execute the external function and copies the output in a new table.

Implements SQLamarr::Transformer.

Definition at line 124 of file BasePlugin.cpp.

◆ load_func()

template<typename Func_t >
Func_t SQLamarr::BasePlugin::load_func ( const std::string &  fname)
protected

Load a generic-typed function from an external library.

Definition at line 122 of file BasePlugin.h.


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