|
LSSTApplications
10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
|
Class for database storage. More...
#include <DbStorage.h>
Public Types | |
| typedef boost::shared_ptr < DbStorage > | Ptr |
Public Types inherited from lsst::daf::persistence::Storage | |
| typedef boost::shared_ptr < Storage > | Ptr |
| typedef std::vector< Ptr > | List |
Public Types inherited from lsst::daf::base::Citizen | |
| enum | { magicSentinel = 0xdeadbeef } |
| typedef unsigned long | memId |
| Type of the block's ID. More... | |
| typedef memId(* | memNewCallback )(const memId cid) |
| A function used to register a callback. More... | |
| typedef memId(* | memCallback )(const Citizen *ptr) |
Public Member Functions | |
| DbStorage (void) | |
| ~DbStorage (void) | |
| virtual void | setPolicy (lsst::pex::policy::Policy::Ptr policy) |
| virtual void | setPersistLocation (LogicalLocation const &location) |
| virtual void | setRetrieveLocation (LogicalLocation const &location) |
| virtual void | startTransaction (void) |
| virtual void | endTransaction (void) |
| virtual void | createTableFromTemplate (std::string const &tableName, std::string const &templateName, bool mayAlreadyExist=false) |
| virtual void | dropTable (std::string const &tableName) |
| virtual void | truncateTable (std::string const &tableName) |
| virtual void | executeSql (std::string const &sqlStatement) |
| virtual void | setTableForInsert (std::string const &tableName) |
| template<typename T > | |
| void | setColumn (std::string const &columnName, T const &value) |
| virtual void | setColumnToNull (std::string const &columnName) |
| virtual void | insertRow (void) |
| virtual void | setTableForQuery (std::string const &tableName, bool isExpr=false) |
| virtual void | setTableListForQuery (std::vector< std::string > const &tableNameList) |
| virtual void | outColumn (std::string const &columnName, bool isExpr=false) |
| template<typename T > | |
| void | outParam (std::string const &columnName, T *location, bool isExpr=false) |
| template<typename T > | |
| void | condParam (std::string const ¶mName, T const &value) |
| virtual void | orderBy (std::string const &expression) |
| virtual void | groupBy (std::string const &expression) |
| virtual void | setQueryWhere (std::string const &whereClause) |
| virtual void | query (void) |
| virtual bool | next (void) |
| template<typename T > | |
| T const & | getColumnByPos (int pos) |
| bool | columnIsNull (int pos) |
| virtual void | finishQuery (void) |
Public Member Functions inherited from lsst::daf::persistence::Storage | |
| virtual | ~Storage (void) |
Public Member Functions inherited from lsst::daf::base::Citizen | |
| Citizen (const std::type_info &) | |
| Citizen (Citizen const &) | |
| ~Citizen () | |
| Citizen & | operator= (Citizen const &) |
| std::string | repr () const |
| Return a string representation of a Citizen. More... | |
| void | markPersistent (void) |
| Mark a Citizen as persistent and not destroyed until process end. More... | |
| memId | getId () const |
| Return the Citizen's ID. More... | |
Protected Member Functions | |
| DbStorage (std::type_info const &type) | |
Protected Member Functions inherited from lsst::daf::persistence::Storage | |
| Storage (std::type_info const &type) | |
| void | verifyPathName (std::string const &pathName) |
Private Attributes | |
| boost::scoped_ptr< DbStorageImpl > | _impl |
| Implementation class for isolation. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from lsst::daf::persistence::Storage | |
| static Ptr | createInstance (std::string const &name, LogicalLocation const &location, bool persist, lsst::pex::policy::Policy::Ptr policy) |
Static Public Member Functions inherited from lsst::daf::base::Citizen | |
| static bool | hasBeenCorrupted () |
| Check all allocated blocks for corruption. More... | |
| static memId | getNextMemId () |
| Return the memId of the next object to be allocated. More... | |
| static int | init () |
| Called once when the memory system is being initialised. More... | |
| static int | census (int, memId startingMemId=0) |
| How many active Citizens are there? More... | |
| static void | census (std::ostream &stream, memId startingMemId=0) |
| Print a list of all active Citizens to stream, sorted by ID. More... | |
| static const std::vector < const Citizen * > * | census () |
| Return a (newly allocated) std::vector of active Citizens sorted by ID. More... | |
| static memId | setNewCallbackId (memId id) |
| Call the NewCallback when block is allocated. More... | |
| static memId | setDeleteCallbackId (memId id) |
| Call the current DeleteCallback when block is deleted. More... | |
| static memNewCallback | setNewCallback (memNewCallback func) |
| Set the NewCallback function. More... | |
| static memCallback | setDeleteCallback (memCallback func) |
| Set the DeleteCallback function. More... | |
| static memCallback | setCorruptionCallback (memCallback func) |
| Set the CorruptionCallback function. More... | |
Class for database storage.
Persists data to a database. Provides methods for writing rows to a table and retrieving rows from a query.
Definition at line 63 of file DbStorage.h.
| typedef boost::shared_ptr<DbStorage> lsst::daf::persistence::DbStorage::Ptr |
Definition at line 65 of file DbStorage.h.
| lsst::daf::persistence::DbStorage::DbStorage | ( | void | ) |
Constructor.
Definition at line 57 of file DbStorage.cc.
| lsst::daf::persistence::DbStorage::~DbStorage | ( | void | ) |
|
explicitprotected |
Constructor with subclass type.
| [in] | type | typeid() of subclass |
Definition at line 63 of file DbStorage.cc.
| bool lsst::daf::persistence::DbStorage::columnIsNull | ( | int | pos | ) |
Determine if the value of a column is NULL.
| [in] | pos | Position of the column (starts at 0) |
Definition at line 270 of file DbStorage.cc.
| void lsst::daf::persistence::DbStorage::condParam | ( | std::string const & | paramName, |
| T const & | value | ||
| ) |
Bind a value to a WHERE condition parameter.
| [in] | paramName | Name of the parameter (prefixed by ":" in the WHERE clause) |
| [in] | value | Value to be bound to the parameter. |
Definition at line 218 of file DbStorage.cc.
|
virtual |
Create a new table from an existing template table.
| [in] | tableName | Name of the new table |
| [in] | templateName | Name of the existing template table |
| [in] | mayAlreadyExist | False (default) if the table must not be present |
Note: currently works with MySQL only.
Reimplemented in lsst::daf::persistence::DbTsvStorage.
Definition at line 112 of file DbStorage.cc.
|
virtual |
Drop a table.
| [in] | tableName | Name of the table to drop |
Reimplemented in lsst::daf::persistence::DbTsvStorage.
Definition at line 121 of file DbStorage.cc.
|
virtual |
End a transaction.
Implements lsst::daf::persistence::Storage.
Reimplemented in lsst::daf::persistence::DbTsvStorage.
Definition at line 101 of file DbStorage.cc.
|
virtual |
Execute an arbitrary SQL statement. Use primarily to perform server-side computations or complex DDL.
| [in] | sqlStatement | SQL statement to be executed. Must not end in ";". |
Definition at line 136 of file DbStorage.cc.
|
virtual |
Indicate that query processing is finished. Must be called after next() returns false; no getColumnByPos() or columnIsNull() calls may be made after this method is called.
Definition at line 278 of file DbStorage.cc.
| T const & lsst::daf::persistence::DbStorage::getColumnByPos | ( | int | pos | ) |
Get the value of a column of the query result row by position.
| [in] | pos | Position of the column (starts at 0) |
Definition at line 263 of file DbStorage.cc.
|
virtual |
Request that the query output be grouped by an expression.
| [in] | expression | Text of the SQL expression |
Definition at line 233 of file DbStorage.cc.
|
virtual |
Insert the row. Row values must have been set with setColumn() calls.
Reimplemented in lsst::daf::persistence::DbTsvStorage.
Definition at line 166 of file DbStorage.cc.
|
virtual |
Move to the next (first) row of the query result.
Definition at line 255 of file DbStorage.cc.
|
virtual |
Request that the query output be sorted by an expression. Multiple expressions may be specified, in order.
| [in] | expression | Text of the SQL expression |
Definition at line 226 of file DbStorage.cc.
|
virtual |
Request a column in the query output.
| [in] | columnName | Name of the column |
| [in] | isExpr | True if the name is actually an expression |
The order of outColumn() calls is the order of appearance in the output row. Use either outColumn() or outParam() but not both.
Definition at line 194 of file DbStorage.cc.
| void lsst::daf::persistence::DbStorage::outParam | ( | std::string const & | columnName, |
| T * | location, | ||
| bool | isExpr = false |
||
| ) |
Request a column in the query output and bind a destination location.
| [in] | columnName | Name of the column |
| [in] | location | Pointer to the destination |
| [in] | isExpr | True if the name is actually an expression |
The order of outParam() calls is the order of appearance in the output row. Use either outColumn() or outParam() but not both.
Definition at line 207 of file DbStorage.cc.
|
virtual |
Execute the query.
Definition at line 248 of file DbStorage.cc.
| void lsst::daf::persistence::DbStorage::setColumn | ( | std::string const & | columnName, |
| T const & | value | ||
| ) |
Set the value to insert in a given column.
| [in] | columnName | Name of the column |
| [in] | value | Value to set in the column |
Definition at line 152 of file DbStorage.cc.
|
virtual |
Set a given column to NULL.
| [in] | columnName | Name of the column |
Reimplemented in lsst::daf::persistence::DbTsvStorage.
Definition at line 159 of file DbStorage.cc.
|
virtual |
Set the database location to persist to.
| [in] | location | Database connection string to insert to. |
Implements lsst::daf::persistence::Storage.
Reimplemented in lsst::daf::persistence::DbTsvStorage.
Definition at line 82 of file DbStorage.cc.
|
virtual |
Allow a policy to be used to configure the DbStorage.
| [in] | policy |
Implements lsst::daf::persistence::Storage.
Reimplemented in lsst::daf::persistence::DbTsvStorage.
Definition at line 75 of file DbStorage.cc.
|
virtual |
Set the condition for the WHERE clause of the query.
| [in] | whereClause | SQL text of the WHERE clause |
May include join conditions.
Definition at line 242 of file DbStorage.cc.
|
virtual |
Set the database location to retrieve from.
| [in] | location | Database connection string to query. |
Implements lsst::daf::persistence::Storage.
Reimplemented in lsst::daf::persistence::DbTsvStorage.
Definition at line 89 of file DbStorage.cc.
|
virtual |
Set the table to insert rows into.
| [in] | tableName | Name of the table |
Reimplemented in lsst::daf::persistence::DbTsvStorage.
Definition at line 143 of file DbStorage.cc.
|
virtual |
Set the table to query (single-table queries only).
| [in] | tableName | Name of the table |
| [in] | isExpr | True if the name is actually a table expression |
Definition at line 175 of file DbStorage.cc.
|
virtual |
Set a list of tables to query (multiple-table queries).
| [in] | tableNameList | Vector of names of tables |
Definition at line 182 of file DbStorage.cc.
|
virtual |
Start a transaction.
Implements lsst::daf::persistence::Storage.
Reimplemented in lsst::daf::persistence::DbTsvStorage.
Definition at line 95 of file DbStorage.cc.
|
virtual |
Truncate a table.
| [in] | tableName | Name of the table to truncate |
Reimplemented in lsst::daf::persistence::DbTsvStorage.
Definition at line 128 of file DbStorage.cc.
|
private |
Implementation class for isolation.
Definition at line 113 of file DbStorage.h.
1.8.5