LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
|
Class for database storage with data loading from TSV files. More...
#include <DbTsvStorage.h>
Public Types | |
typedef boost::shared_ptr < DbTsvStorage > | Ptr |
Public Types inherited from lsst::daf::persistence::DbStorage | |
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 | |
DbTsvStorage (void) | |
~DbTsvStorage (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 | 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) |
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) |
template<typename T > | |
T const & | getColumnByPos (int pos) |
template<> | |
void | setColumn (std::string const &columnName, char const &value) |
template<> | |
void | setColumn (std::string const &columnName, double const &value) |
template<> | |
void | setColumn (std::string const &columnName, float const &value) |
template<> | |
void | setColumn (std::string const &columnName, DateTime const &value) |
Public Member Functions inherited from lsst::daf::persistence::DbStorage | |
DbStorage (void) | |
~DbStorage (void) | |
virtual void | executeSql (std::string const &sqlStatement) |
template<typename T > | |
void | setColumn (std::string const &columnName, T const &value) |
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... | |
Private Member Functions | |
int | _getColumnIndex (std::string const &columnName) |
Private Attributes | |
bool | _persisting |
bool | _saveTemp |
Do not delete temporary TSV file if true. More... | |
std::string | _tempPath |
Directory pathname for temporary TSV file. More... | |
char * | _fileName |
Full pathname for temporary TSV file. More... | |
std::string | _location |
Database location URL. More... | |
std::string | _tableName |
std::map< std::string, int > | _colMap |
Map from column names to positions. More... | |
std::ostringstream | _convertStream |
Stream to convert to text. More... | |
std::vector< std::string > | _rowBuffer |
boost::scoped_ptr< std::ofstream > | _osp |
Output TSV stream. 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... | |
Protected Member Functions inherited from lsst::daf::persistence::DbStorage | |
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) |
Class for database storage with data loading from TSV files.
Subclass of DbStorage, overriding persistence methods.
Persists data to a database using TSV files as an intermediary for performance. Provides methods for writing rows to a table and retrieving rows from a query.
Definition at line 66 of file DbTsvStorage.h.
typedef boost::shared_ptr<DbTsvStorage> lsst::daf::persistence::DbTsvStorage::Ptr |
Definition at line 68 of file DbTsvStorage.h.
lsst::daf::persistence::DbTsvStorage::DbTsvStorage | ( | void | ) |
Constructor.
Definition at line 67 of file DbTsvStorage.cc.
lsst::daf::persistence::DbTsvStorage::~DbTsvStorage | ( | void | ) |
|
private |
Get the index of a given column. Create a new entry in the row buffer if the column hasn't already been seen. May modify the row buffer, so do not call this inside "_rowBuffer[]".
[in] | columnName | Name of the column |
Definition at line 252 of file DbTsvStorage.cc.
void lsst::daf::persistence::DbTsvStorage::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 368 of file DbTsvStorage.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 |
Reimplemented from lsst::daf::persistence::DbStorage.
Definition at line 183 of file DbTsvStorage.cc.
|
virtual |
Drop a table.
[in] | tableName | Name of the table to drop |
Reimplemented from lsst::daf::persistence::DbStorage.
Definition at line 202 of file DbTsvStorage.cc.
|
virtual |
End a transaction.
Reimplemented from lsst::daf::persistence::DbStorage.
Definition at line 114 of file DbTsvStorage.cc.
T const & lsst::daf::persistence::DbTsvStorage::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 376 of file DbTsvStorage.cc.
|
virtual |
Insert the row. Row values must have been set with setColumn() calls.
Reimplemented from lsst::daf::persistence::DbStorage.
Definition at line 334 of file DbTsvStorage.cc.
void lsst::daf::persistence::DbTsvStorage::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 357 of file DbTsvStorage.cc.
void lsst::daf::persistence::DbTsvStorage::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 270 of file DbTsvStorage.cc.
void lsst::daf::persistence::DbTsvStorage::setColumn | ( | std::string const & | columnName, |
char const & | value | ||
) |
Definition at line 284 of file DbTsvStorage.cc.
void lsst::daf::persistence::DbTsvStorage::setColumn | ( | std::string const & | columnName, |
double const & | value | ||
) |
Definition at line 294 of file DbTsvStorage.cc.
void lsst::daf::persistence::DbTsvStorage::setColumn | ( | std::string const & | columnName, |
float const & | value | ||
) |
Definition at line 303 of file DbTsvStorage.cc.
void lsst::daf::persistence::DbTsvStorage::setColumn | ( | std::string const & | columnName, |
DateTime const & | value | ||
) |
Definition at line 313 of file DbTsvStorage.cc.
|
virtual |
Set a given column to NULL.
[in] | columnName | Name of the column |
Reimplemented from lsst::daf::persistence::DbStorage.
Definition at line 326 of file DbTsvStorage.cc.
|
virtual |
Set the database location to persist to.
[in] | location | Database connection string to insert to. |
Reimplemented from lsst::daf::persistence::DbStorage.
Definition at line 91 of file DbTsvStorage.cc.
|
virtual |
Allow a policy to be used to configure the DbTsvStorage.
[in] | policy |
Reimplemented from lsst::daf::persistence::DbStorage.
Definition at line 78 of file DbTsvStorage.cc.
|
virtual |
Set the database location to retrieve from.
[in] | location | Database connection string to retrieve from. |
Reimplemented from lsst::daf::persistence::DbStorage.
Definition at line 101 of file DbTsvStorage.cc.
|
virtual |
Set the table to insert rows into.
[in] | tableName | Name of the table |
Reimplemented from lsst::daf::persistence::DbStorage.
Definition at line 234 of file DbTsvStorage.cc.
|
virtual |
Start a transaction.
Reimplemented from lsst::daf::persistence::DbStorage.
Definition at line 108 of file DbTsvStorage.cc.
|
virtual |
Truncate a table.
[in] | tableName | Name of the table to truncate |
Reimplemented from lsst::daf::persistence::DbStorage.
Definition at line 218 of file DbTsvStorage.cc.
|
private |
Map from column names to positions.
Definition at line 106 of file DbTsvStorage.h.
|
private |
Stream to convert to text.
Definition at line 107 of file DbTsvStorage.h.
|
private |
Full pathname for temporary TSV file.
Definition at line 103 of file DbTsvStorage.h.
|
private |
Database location URL.
Definition at line 104 of file DbTsvStorage.h.
|
private |
Output TSV stream.
Definition at line 109 of file DbTsvStorage.h.
|
private |
Definition at line 100 of file DbTsvStorage.h.
|
private |
Definition at line 108 of file DbTsvStorage.h.
|
private |
Do not delete temporary TSV file if true.
Definition at line 101 of file DbTsvStorage.h.
|
private |
Definition at line 105 of file DbTsvStorage.h.
|
private |
Directory pathname for temporary TSV file.
Definition at line 102 of file DbTsvStorage.h.