Thread portable class


Gate portable class


Timer class


Pool class


Terimber 2.0


About C++


Downloads Products & Services Support Clients Open Source About



Home / Open source / Terimber 2.0

memtable Class Reference

interface to memory table More...

#include <memdb.h>

Inheritance diagram for memtable:

terimber_memtable terimber_log_helper terimber_log

List of all members.

Public Member Functions

 memtable ()
 constructor
virtual ~memtable ()
 destructor user is responsible for destoying memtable object
virtual const char * get_last_error ()
 returns the last occured error
virtual bool populate (dbserver *server, size_t start_row, size_t max_rows)
 create internal table structure from server object db_server has to be after executing query or stored procedure and ready to fetch data memtable automatically detects the list of columns in recordset and creates table in memory with the same columns' order and types. max_rows sets a restriction on max rows to be retrived, -1 - all of them start_row means absolute number of row to start with unless you specify 0, the memtable starts with the current row to create an empty table, the fake select can be used for instanse, select CAST(0 as NUMBER) as col1, CAST('' as VARCHAR2(255)) as col2 from dual; or you can specifiy the max_rows = 0
virtual bool create (size_t columns, const terimber_table_column_desc desc[])
 the other alternative for creating an empty table in the memory is column specification the list of columns descriptions explicitly
virtual void refresh ()
 resets all new, update rows status to original, removes deleted rows update all indexes
virtual size_t get_row_count ()
 after population and any time after that you can request the number of rows in table
virtual size_t get_column_count () const
 columns description is pretty much the same as db_server provides
virtual dbtypes get_column_type (size_t index) const
 returns the virtual terimber dbtype like db_bool, ...
virtual const char * get_column_name (size_t index) const
 returns the name of the column
virtual bool get_column_nullable (size_t index) const
 returns the nullable - database specific
virtual size_t get_column_scale (size_t index) const
 returns the scale
virtual size_t get_column_precision (size_t index) const
 returns the precision
virtual size_t get_column_max_length (size_t index) const
 returns the length of the column (only for fixed length columns)
virtual terimber_memindexadd_index (size_t columns, const terimber_index_column_info info[])
 creates index to perform the quick search columns the size of index info - array of index column descriptions returns the new created memindex object user must not to use object after returning it back or after memtable will be destoyed this is an expensive operation in order to consume memory and CPU time
virtual bool remove_index (terimber_memindex *obj)
 destroy index memtable data is still valid all memlookups on the current index will be destroyed!
virtual terimber_db_value_vectorallocate_db_values (size_t count)
 requests value array
virtual void destroy_db_values (terimber_db_value_vector *obj)
 destroys value array
const memdb_rowset_tget_rowset () const
 returns rowset
const binders_tget_cols () const
 returns column binders
bool insert_row (const terimber_db_value_vector *info)
 inserts new row if row is modified it will still have a status = new if row is removed it's just deleted from recordset inserted row has all columns' value as null
bool update_row (memdb_rowset_citerator_t iter, const terimber_db_value_vector *info)
 updates row
bool delete_row (memdb_rowset_citerator_t iter)
 deletes existing row if row was in original recordset (modified or not), it will have a status = delete, and will not be accessible anymore deleting of new row will just remove row from recordset

Private Types

typedef list< memindex * > list_indexes_t
 list of memindex pointers
typedef list
< terimber_db_value_vector_impl * > 
list_values_t
 list of value vector pointers

Private Member Functions

void uninit ()
 uninit

Private Attributes

byte_allocator _allocator
 internal allocator
binders_t _cols
 columns binders
memdb_rowset_t _rowset
 rowset
string_t _error
 last error
mutex _mtx
 mutex
list_indexes_t _indexes
 list of indexes
list_values_t _values
 list of value vectors


Detailed Description

interface to memory table

Definition at line 464 of file memdb.h.


Member Typedef Documentation

list of memindex pointers

Definition at line 468 of file memdb.h.

list of value vector pointers

Definition at line 471 of file memdb.h.


Constructor & Destructor Documentation

BEGIN_TERIMBER_NAMESPACE memtable::memtable (  ) 

constructor

Definition at line 38 of file memtable.cpp.

memtable::~memtable (  )  [virtual]

destructor user is responsible for destoying memtable object

Definition at line 46 of file memtable.cpp.

References uninit().


Member Function Documentation

const char * memtable::get_last_error (  )  [virtual]

returns the last occured error

Implements terimber_memtable.

Definition at line 74 of file memtable.cpp.

References _error.

bool memtable::populate ( dbserver server,
size_t  start_row,
size_t  max_rows 
) [virtual]

create internal table structure from server object db_server has to be after executing query or stored procedure and ready to fetch data memtable automatically detects the list of columns in recordset and creates table in memory with the same columns' order and types. max_rows sets a restriction on max rows to be retrived, -1 - all of them start_row means absolute number of row to start with unless you specify 0, the memtable starts with the current row to create an empty table, the fake select can be used for instanse, select CAST(0 as NUMBER) as col1, CAST('' as VARCHAR2(255)) as col2 from dual; or you can specifiy the max_rows = 0

Parameters:
server  dbserver instance, connected to database and opened the recordset
start_row  row to fetch from, 0 - current row
max_rows  max row to fetch

Implements terimber_memtable.

Definition at line 90 of file memtable.cpp.

References _allocator, _cols, _error, memdb_row::_row, _rowset, memdb_row::_status, base_list< T >::back(), copy_db_row(), dbserver::fetch_data(), dbserver::get_column_count(), dbserver::get_column_max_length(), dbserver::get_column_name(), dbserver::get_column_nullable(), dbserver::get_column_precision(), dbserver::get_column_scale(), dbserver::get_column_type(), dbserver::get_error(), dbserver::next(), list< T >::push_back(), _vector< T, A >::resize(), base_vector< T >::size(), status_original, and uninit().

bool memtable::create ( size_t  columns,
const terimber_table_column_desc  desc[] 
) [virtual]

the other alternative for creating an empty table in the memory is column specification the list of columns descriptions explicitly

Parameters:
columns  number of columns
desc  array of columns' descriptors

Implements terimber_memtable.

Definition at line 143 of file memtable.cpp.

References _allocator, _cols, terimber_table_column_desc::_max_length, terimber_table_column_desc::_nullable, terimber_table_column_desc::_precision, terimber_table_column_desc::_scale, terimber_table_column_desc::_type, _vector< T, A >::resize(), base_vector< T >::size(), and uninit().

void memtable::refresh (  )  [virtual]

resets all new, update rows status to original, removes deleted rows update all indexes

Implements terimber_memtable.

Definition at line 168 of file memtable.cpp.

References _rowset, base_list< T >::begin(), base_list< T >::end(), and status_original.

size_t memtable::get_row_count (  )  [virtual]

after population and any time after that you can request the number of rows in table

Implements terimber_memtable.

Definition at line 181 of file memtable.cpp.

References _rowset, and list< T >::size().

size_t memtable::get_column_count (  )  const [virtual]

columns description is pretty much the same as db_server provides

gets column count

Implements terimber_memtable.

Definition at line 194 of file memtable.cpp.

References _cols, and base_vector< T >::size().

Referenced by memlookup::get_value_as_value(), and memlookup::get_value_is_null().

dbtypes memtable::get_column_type ( size_t  index  )  const [virtual]

returns the virtual terimber dbtype like db_bool, ...

Parameters:
index  index

Implements terimber_memtable.

Definition at line 203 of file memtable.cpp.

References _cols, db_unknown, and base_vector< T >::size().

Referenced by memlookup::get_value_as_value().

const char * memtable::get_column_name ( size_t  index  )  const [virtual]

returns the name of the column

Parameters:
index  index

Implements terimber_memtable.

Definition at line 212 of file memtable.cpp.

References _cols, and base_vector< T >::size().

bool memtable::get_column_nullable ( size_t  index  )  const [virtual]

returns the nullable - database specific

Parameters:
index  index

Implements terimber_memtable.

Definition at line 221 of file memtable.cpp.

References _cols, and base_vector< T >::size().

size_t memtable::get_column_scale ( size_t  index  )  const [virtual]

returns the scale

Parameters:
index  index

Implements terimber_memtable.

Definition at line 230 of file memtable.cpp.

References _cols, and base_vector< T >::size().

size_t memtable::get_column_precision ( size_t  index  )  const [virtual]

returns the precision

Parameters:
index  index

Implements terimber_memtable.

Definition at line 238 of file memtable.cpp.

References _cols, and base_vector< T >::size().

size_t memtable::get_column_max_length ( size_t  index  )  const [virtual]

returns the length of the column (only for fixed length columns)

Parameters:
index  index

Implements terimber_memtable.

Definition at line 247 of file memtable.cpp.

References _cols, and base_vector< T >::size().

terimber_memindex * memtable::add_index ( size_t  columns,
const terimber_index_column_info  info[] 
) [virtual]

creates index to perform the quick search columns the size of index info - array of index column descriptions returns the new created memindex object user must not to use object after returning it back or after memtable will be destoyed this is an expensive operation in order to consume memory and CPU time

index management there are no connection between the indexes in the memory and the indexes in the database

Parameters:
columns  columns in index
info  array of index columns' descriptions

Implements terimber_memtable.

Definition at line 267 of file memtable.cpp.

References terimber_index_column_info::_asc_sort, terimber_index_column_info::_case_insensitive, _cols, _error, terimber_index_column_info::_index, _indexes, _mtx, memindex::construct(), terimber_log_helper::log_on(), list< T >::push_back(), vector< T >::resize(), base_vector< T >::size(), and str_template::strprint().

bool memtable::remove_index ( terimber_memindex obj  )  [virtual]

destroy index memtable data is still valid all memlookups on the current index will be destroyed!

Parameters:
obj  index pointer

Implements terimber_memtable.

Definition at line 325 of file memtable.cpp.

References _indexes, _mtx, base_list< T >::begin(), base_list< T >::end(), and list< T >::erase().

terimber_db_value_vector * memtable::allocate_db_values ( size_t  count  )  [virtual]

requests value array

Parameters:
count  array size

Implements terimber_memtable.

Definition at line 341 of file memtable.cpp.

References _mtx, _values, and list< T >::push_back().

void memtable::destroy_db_values ( terimber_db_value_vector obj  )  [virtual]

destroys value array

Parameters:
obj  value array pointer

Implements terimber_memtable.

Definition at line 355 of file memtable.cpp.

References _mtx, _values, base_list< T >::begin(), base_list< T >::end(), and list< T >::erase().

const memdb_rowset_t& memtable::get_rowset (  )  const [inline]

returns rowset

Definition at line 601 of file memdb.h.

References _rowset.

Referenced by memindex::construct().

const binders_t& memtable::get_cols (  )  const [inline]

returns column binders

Definition at line 608 of file memdb.h.

References _cols.

bool memtable::insert_row ( const terimber_db_value_vector info  ) 

inserts new row if row is modified it will still have a status = new if row is removed it's just deleted from recordset inserted row has all columns' value as null

Parameters:
info  value vector

Definition at line 369 of file memtable.cpp.

References _allocator, _cols, _error, _indexes, _mtx, memdb_row::_row, _rowset, memdb_row::_status, base_list< T >::back(), base_list< T >::begin(), copy_db_row(), base_list< T >::end(), terimber_db_value_vector::get_size(), list< T >::push_back(), _vector< T, A >::resize(), base_vector< T >::size(), and status_new.

Referenced by memlookup::insert_row().

bool memtable::update_row ( memdb_rowset_citerator_t  iter,
const terimber_db_value_vector info 
)

updates row

Parameters:
iter  row iterator for update
info  value vector

Definition at line 401 of file memtable.cpp.

References _allocator, _cols, _error, _indexes, _mtx, base_list< T >::begin(), copy_db_row(), base_list< T >::end(), base_vector< T >::size(), status_deleted, status_new, status_original, and status_updated.

Referenced by memlookup::update_row().

bool memtable::delete_row ( memdb_rowset_citerator_t  iter  ) 

deletes existing row if row was in original recordset (modified or not), it will have a status = delete, and will not be accessible anymore deleting of new row will just remove row from recordset

Parameters:
iter  row iterator for deletion

Definition at line 438 of file memtable.cpp.

References _indexes, _mtx, _rowset, base_list< T >::begin(), base_list< T >::end(), list< T >::erase(), status_deleted, status_new, status_original, and status_updated.

Referenced by memlookup::delete_row().

void memtable::uninit (  )  [private]


Member Data Documentation

internal allocator

Definition at line 636 of file memdb.h.

Referenced by create(), insert_row(), populate(), uninit(), and update_row().

rowset

Definition at line 638 of file memdb.h.

Referenced by delete_row(), get_row_count(), get_rowset(), insert_row(), populate(), refresh(), and uninit().

last error

Definition at line 639 of file memdb.h.

Referenced by add_index(), get_last_error(), insert_row(), populate(), and update_row().

list of indexes

Definition at line 641 of file memdb.h.

Referenced by add_index(), delete_row(), insert_row(), remove_index(), uninit(), and update_row().

list of value vectors

Definition at line 642 of file memdb.h.

Referenced by allocate_db_values(), destroy_db_values(), and uninit().


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


© Copyright Terimber 2003-.