MetriVis Overview | Download | User Manual | Development
Reference Overview | Design Documentation | Reference Backend | Reference Frontend

metrivis::SQLDriver Class Reference

Driver for the SQLite interface. More...

#include <SQLDriver.h>


Public Member Functions

 SQLDriver (unsigned int max_cache_size=METRIVIS_DEFAULT_CACHE_SIZE)
 Constructor, creates an SQLDriver with a vertain cache size.
 ~SQLDriver ()
 Deconstructor.
MultiTypePtr Insert (std::string table_name, std::string values)
 Inserts data into a SQLite table.
MultiTypePtr Insert (std::string table_name, std::string columns, std::string values)
 Inserts data into a SQLite table.
MultiTypePtr Delete (std::string table_name, std::string where)
 Deletes data from a SQLite table.
MultiTypePtr Select (std::vector< std::string > columns, std::string table_name)
 Selects data from a SQLite table and writes them as double array.
MultiTypePtr SelectString (std::vector< std::string > columns, std::string table_name)
 Selects data from a SQLite table and writes them as string array.
MultiTypePtr SelectString (std::vector< std::string > columns, std::string table_name, std::string where)
 Selects data from a SQLite table and writes them as string array.
MultiTypePtr Select (std::vector< std::string > columns, std::string table_name, std::string where)
 Selects data from a SQLite table.
MultiTypePtr SelectCached (std::vector< std::string > columns, std::string table_name)
 Selects data from a SQLite table cached reading.
MultiTypePtr SelectStringCached (std::vector< std::string > columns, std::string table_name)
 Selects data from a SQLite table cached reading.
void PreCacheSelectString (std::vector< std::string > columns, std::string table_name)
 Preexecutes the specified SQL select query and caches it.
void PreCacheSelect (std::vector< std::string > columns, std::string table_name)
 Preexecutes the specified SQL select query and caches it.
void set_max_cache_size (long max_cache_size)
 Interface function to max cache size.
long max_cache_size () const
 Interface function to max cache size.
long cache_size () const
 Interface function to cache size.
void set_db_file_name (const std::string &db_file_name)
 Interface function to database_file_name.

Private Member Functions

 SQLDriver (const SQLDriver &sql_driver)
 Hide evil Constructors.

Private Attributes

LRUCache
< std::string,
MultiTypePtr > 
cache_
 Last recently used cache.
boost::mutex cache_mutex_
 Mutex locks running/stopping changes.
long cache_size_
 The size of the current cache in bytes.
long max_cache_size_
 The maximal cache size in bytes.
std::string db_file_name_
 File name of the data base.


Detailed Description

Driver for the SQLite interface.

Allows synchronized access to the SQLite data base. Thread safety is implemented:


Constructor & Destructor Documentation

metrivis::SQLDriver::SQLDriver ( unsigned int  max_cache_size = METRIVIS_DEFAULT_CACHE_SIZE  ) 

Constructor, creates an SQLDriver with a vertain cache size.

Parameters:
cache_size,: The size of the loacal cache int bytes.


Member Function Documentation

MultiTypePtr metrivis::SQLDriver::Insert ( std::string  table_name,
std::string  values 
)

Inserts data into a SQLite table.

Parameters:
values,: Comma separated list of values.
table_name,: Strings containing the name of the SQL table.
Returns:
A MultiType smart pointer containing status of the query.
This command is a parser function for the SQL command:
INSERT INTO table-name VALUES(value-list);
   * 
. This function is thread safe, because the underlaying SQLite function is thread safe.

See header file for more information.

MultiTypePtr metrivis::SQLDriver::Insert ( std::string  table_name,
std::string  columns,
std::string  values 
)

Inserts data into a SQLite table.

Parameters:
values,: Comma separated list of values.
table_name,: Strings containing the name of the SQL table.
columns,: The sql table column names.
Returns:
A MultiType smart pointer containing status of the query.
This command is a parser function for the SQL command:
INSERT INTO table-name (column-list) VALUES(value-list);
   * 
. This function is thread safe, because the underlaying SQLite function is thread safe.

See header file for more information.

MultiTypePtr metrivis::SQLDriver::Delete ( std::string  table_name,
std::string  where 
)

Deletes data from a SQLite table.

Parameters:
table_name,: Strings containing the name of the SQL table.
where,: SQL criterion for the rows to be deleted.
Returns:
A MultiType smart pointer containing status of the query.
This command is a parser function for the SQL command:
IDELETE FROM [database-name .] table-name [WHERE expr];
   * 
. This function is thread safe, because the underlaying SQLite function is thread safe.

See header file for more information.

MultiTypePtr metrivis::SQLDriver::Select ( std::vector< std::string >  columns,
std::string  table_name 
)

Selects data from a SQLite table and writes them as double array.

Parameters:
colums,: String containing selected columns, comma separated.
table_name,: Strings containing the name of the SQL table.
Returns:
A MultiType smart pointer containing the data in array format.
This command is a parser function for the SQL command:
SELECT columns FROM table_name; 
This function is thread safe, because the underlaying SQLite function is thread safe.

See header file for more information.

MultiTypePtr metrivis::SQLDriver::SelectString ( std::vector< std::string >  columns,
std::string  table_name 
)

Selects data from a SQLite table and writes them as string array.

Parameters:
colums,: String containing selected columns, comma separated.
table_name,: Strings containing the name of the SQL table.
Returns:
A MultiType smart pointer containing the data in array format.
This command is a parser function for the SQL command:
SELECT columns FROM table_name; 
This function is thread safe, because the underlaying SQLite function is thread safe.

See header file for more information.

MultiTypePtr metrivis::SQLDriver::SelectString ( std::vector< std::string >  columns,
std::string  table_name,
std::string  where 
)

Selects data from a SQLite table and writes them as string array.

Parameters:
colums,: String containing selected columns, comma separated.
table_name,: Strings containing the name of the SQL table.
where,: String containing selection criterions (SQL syntax).
Returns:
A MultiType smart pointer containing the data in array format.
Saves the data internally as 2D string array. This command is a parser function for the SQL command:
SELECT columns FROM table_name; 
This function is thread safe, because the underlaying SQLite function is thread safe.

See header file for more information.

MultiTypePtr metrivis::SQLDriver::Select ( std::vector< std::string >  columns,
std::string  table_name,
std::string  where 
)

Selects data from a SQLite table.

Parameters:
colums,: String containing selected columns, comma separated.
table_name,: Strings containing the name of the SQL table.
where,: String containing selection criterions (SQL syntax).
Returns:
A MultiType smart pointer containing the data in array format.
Saves the data internally as 2D double array. This command is a parser function for the SQL command:
SELECT columns FROM table_name WHERE where; 

MultiTypePtr metrivis::SQLDriver::SelectCached ( std::vector< std::string >  columns,
std::string  table_name 
)

Selects data from a SQLite table cached reading.

Parameters:
colums,: Strings containing selected columns, comma separated.
table_name,: String containing the name of the SQL table.
Returns:
A MultiType smart pointer containing the data as double array.
Saves the data internally as 2D double array. This command is a parser function for the SQL command:
SELECT columns FROM table_name; 
This function is thread safe, because the underlaying SQLite function is thread safe.

If exactly the same select command has been executed before, the local LRU cache may contain a copy of the result data, circumventing the SQL lookup. This may safe much time for big data chunks.

Caching makes only sense for big data chunks. It assumes, that the underlaying data does not change at all.

See header file for more information.

MultiTypePtr metrivis::SQLDriver::SelectStringCached ( std::vector< std::string >  columns,
std::string  table_name 
)

Selects data from a SQLite table cached reading.

Parameters:
colums,: Strings containing selected columns, comma separated.
table_name,: String containing the name of the SQL table.
Returns:
A MultiType smart pointer containing the data as string array.
Saves the data internally as string array. This command is a parser function for the SQL command:
SELECT columns FROM table_name; 
This function is thread safe, because the underlaying SQLite function is thread safe.

If exactly the same select command has been executed before, the local LRU cache may contain a copy of the result data, circumventing the SQL lookup. This may safe much time for big data chunks (many seconds).

Caching makes only sense for big data chunks. It assumes, that the underlaying data does not change at all.

See header file for more information.

void metrivis::SQLDriver::PreCacheSelectString ( std::vector< std::string >  columns,
std::string  table_name 
)

Preexecutes the specified SQL select query and caches it.

Parameters:
colums,: Strings containing selected columns, comma separated.
table_name,: String containing the name of the SQL table.
Saves the data internally as 2D string array. This command is a parser function for the SQL command:
SELECT columns FROM table_name; 
This function is thread safe, because the underlaying SQLite function is thread safe.

If exactly the same select command has been executed before, the local LRU cache may contain a copy of the result data, circumventing the SQL lookup. This may safe much time for big data chunks (many seconds).

Caching makes only sense for big data chunks. It assumes, that the underlaying data does not change at all.

See header file for more information.

void metrivis::SQLDriver::PreCacheSelect ( std::vector< std::string >  columns,
std::string  table_name 
)

Preexecutes the specified SQL select query and caches it.

Parameters:
colums,: Strings containing selected columns, comma separated.
table_name,: String containing the name of the SQL table.
Saves the data internally as 2D double array. This command is a parser function for the SQL command:
SELECT columns FROM table_name; 
This function is thread safe, because the underlaying SQLite function is thread safe.

If exactly the same select command has been executed before, the local LRU cache may contain a copy of the result data, circumventing the SQL lookup. This may safe much time for big data chunks (many seconds).

Caching makes only sense for big data chunks. It assumes, that the underlaying data does not change at all.

See header file for more information.

void metrivis::SQLDriver::set_max_cache_size ( long  max_cache_size  )  [inline]

Interface function to max cache size.

Parameters:
cache_size,: The maximal cache size in bytes.
Resetting the cache size during run-time will clear all cache entries in the current cache. Try to avoid it.

long metrivis::SQLDriver::max_cache_size (  )  const [inline]

Interface function to max cache size.

Returns:
: The maximal cache size in bytes.

long metrivis::SQLDriver::cache_size (  )  const [inline]

Interface function to cache size.

Returns:
The current cache size.

void metrivis::SQLDriver::set_db_file_name ( const std::string &  db_file_name  )  [inline]

Interface function to database_file_name.

Parameters:
database_file_name,: String containing the database file name.


The documentation for this class was generated from the following files:
Generated on Fri Feb 29 16:47:20 2008 for MetriVis by  doxygen 1.5.3