Main Page | Class Hierarchy | Class List | File List | Class Members

dbReplicatedDatabase Class Reference

#include <replicator.h>

Inheritance diagram for dbReplicatedDatabase:

dbDatabase List of all members.

Public Types

typedef void(* dbErrorHandler )(int error, char const *msg, int msgarg)
enum  DetachFlags { COMMIT = 1, DESTROY_CONTEXT = 2 }
enum  dbErrorClass {
  NoError, QueryError, ArithmeticError, IndexOutOfRangeError,
  DatabaseOpenError, FileError, OutOfMemoryError, Deadlock,
  NullReferenceError, FileLimitExeeded, DatabaseReadOnly
}
enum  dbAccessType { dbReadOnly = 0, dbAllAccess = 1 }

Public Member Functions

void stopMasterReplication ()
 dbReplicatedDatabase (dbReplicationManager *mng=NULL, size_t poolSize=0, size_t dbExtensionQuantum=dbDefaultExtensionQuantum, size_t dbInitIndexSize=dbDefaultInitIndexSize, int nThreads=1)
bool open (char const *masterHostAddress, int nReplicas, char_t const *databaseName, time_t transactionCommitDelay=0, int openAttr=dbFile::no_buffering)
void close ()
bool open (char_t const *databaseName, time_t transactionCommitDelay=0, int openAttr=dbFile::no_buffering)
bool open (dbFile *file, time_t transactionCommitDelay=0, bool deleteFileOnClose=false)
void commit ()
void executeBatch ()
void precommit ()
void rollback ()
void attach ()
void detach (int flags=COMMIT|DESTROY_CONTEXT)
void lock (dbLockType type=dbExclusiveLock)
bool backup (char_t const *backupFileName, bool compactify)
bool restore (char_t const *backupFileName, char_t const *databaseFileName)
int getVersion ()
void assign (dbTableDescriptor &desc)
dbTableDescriptorlookupTable (dbTableDescriptor *desc)
void setConcurrency (unsigned nThreads)
long getAllocatedSize ()
void allowColumnsDeletion (bool enabled=true)
dbErrorHandler setErrorHandler (dbErrorHandler newHandler)
virtual void scheduleBackup (char_t const *fileName, time_t periodSec)
virtual void handleError (dbErrorClass error, char const *msg=NULL, int arg=0)
void insertRecord (dbTableDescriptor *table, dbAnyReference *ref, void const *record, bool batch)
offs_t used ()
bool isOpen () const
offs_t getDatabaseSize ()
void setFileExtensionQuantum (offs_t quantum)
void setFileSizeLimit (offs_t limit)
template<class T> dbReference< T > insert (T const &record)
template<class T> dbReference< T > batchInsert (T const &record)

Public Attributes

const dbAccessType accessType
const size_t extensionQuantum
const size_t initIndexSize

Static Public Attributes

unsigned dbParallelScanThreshold

Protected Member Functions

void slaveReplication ()
void replicatePage (offs_t pageOffs, void *pageData)
void commit (dbDatabaseThreadContext *ctx)
void releaseFile ()
void delayedCommit ()
void backupScheduler ()
offs_t getPos (oid_t oid)
void setPos (oid_t oid, offs_t pos)
dbRecordgetRow (dbGetTie &tie, oid_t oid)
void getHeader (dbRecord &rec, oid_t oid)
byte * put (oid_t oid)
byte * put (dbPutTie &tie, oid_t oid)
byte * get (oid_t oid)
dbRecordputRow (dbPutTie &tie, oid_t oid, size_t newSize)
dbRecordputRow (dbPutTie &tie, oid_t oid)
void restoreTablesConsistency ()
void applyIndex (dbFieldDescriptor *field, dbSearchContext &sc)
bool isIndexApplicable (dbAnyCursor *cursor, dbExprNode *expr, dbQuery &query, dbFieldDescriptor *&indexedField, bool &truncate, bool ascent, bool forAll)
bool isIndexApplicableToExpr (dbSearchContext &sc, dbExprNode *expr)
bool followInverseReference (dbExprNode *expr, dbExprNode *andExpr, dbAnyCursor *cursor, oid_t iref)
bool existsInverseReference (dbExprNode *expr, int nExistsClauses)
bool evaluateBoolean (dbExprNode *expr, oid_t oid, dbTableDescriptor *table, dbAnyCursor *cursor)
size_t evaluateString (dbExprNode *expr, oid_t oid, dbTableDescriptor *table, char_t *buf, size_t bufSize)
void evaluate (dbExprNode *expr, oid_t oid, dbTableDescriptor *table, dbSynthesizedAttribute &result)
void select (dbAnyCursor *cursor)
void select (dbAnyCursor *cursor, dbQuery &query)
void traverse (dbAnyCursor *cursor, dbQuery &query)
void update (oid_t oid, dbTableDescriptor *table, void const *record)
void remove (dbTableDescriptor *table, oid_t oid)
offs_t allocate (size_t size, oid_t oid=0)
void free (offs_t pos, size_t size)
void extend (offs_t size)
void cloneBitmap (offs_t pos, size_t size)
oid_t allocateId ()
void freeId (oid_t oid)
void updateCursors (oid_t oid, bool removed=false)
oid_t allocatePage ()
void freePage (oid_t oid)
oid_t allocateRow (oid_t tableId, size_t size, dbTableDescriptor *desc=NULL)
void allocateRow (oid_t tableId, oid_t oid, size_t size, dbTableDescriptor *desc)
void freeRow (oid_t tableId, oid_t oid, dbTableDescriptor *desc=NULL)
void beginTransaction (dbLockType type)
void endTransaction (dbDatabaseThreadContext *ctx)
void initializeMetaTable ()
bool loadScheme ()
bool completeDescriptorsInitialization ()
void reformatTable (oid_t tableId, dbTableDescriptor *desc)
void addIndices (dbTableDescriptor *desc)
oid_t addNewTable (dbTableDescriptor *desc)
void updateTableDescriptor (dbTableDescriptor *desc, oid_t tableId, dbTable *table)
void removeInverseReferences (dbTableDescriptor *desc, oid_t oid)
void insertInverseReference (dbFieldDescriptor *desc, oid_t reverseId, oid_t targetId)
void removeInverseReference (dbFieldDescriptor *desc, oid_t reverseId, oid_t targetId)
void deleteTable (dbTableDescriptor *desc)
void dropTable (dbTableDescriptor *desc)
void createIndex (dbFieldDescriptor *fd)
void createHashTable (dbFieldDescriptor *fd)
void dropIndex (dbFieldDescriptor *fd)
void dropHashTable (dbFieldDescriptor *fd)
void linkTable (dbTableDescriptor *table, oid_t tableId)
void unlinkTable (dbTableDescriptor *table)
bool wasReserved (offs_t pos, size_t size)
void reserveLocation (dbLocation &location, offs_t pos, size_t size)
void commitLocation ()
dbTableDescriptorfindTable (char_t const *name)
dbTableDescriptorfindTableByName (char_t const *name)
dbTableDescriptorgetTables ()
void cleanupOnOpenError ()
void setDirty ()

Static Protected Member Functions

void thread_proc slaveReplicationProc (void *arg)
void thread_proc delayedCommitProc (void *arg)
void thread_proc backupSchedulerProc (void *arg)
void _fastcall execute (dbExprNode *expr, dbInheritedAttribute &iattr, dbSynthesizedAttribute &sattr)
void deleteCompiledQuery (dbExprNode *tree)

Protected Attributes

int nReplicas
socket_t ** replicationSlaves
socket_t * replicationMaster
dbReplicationManagerreplicationManager
dbThread replicationThread
dbThreadContext< dbDatabaseThreadContext > threadContext
dbThreadPool threadPool
dbHeaderheader
int4 * dirtyPagesMap
unsigned parThreads
bool modified
int curr
bool uncommittedChanges
offs_t dbFileExtensionQuantum
offs_t dbFileSizeLimit
volatile int commitInProgress
volatile int concurrentTransId
size_t currRBitmapPage
size_t currRBitmapOffs
size_t currPBitmapPage
size_t currPBitmapOffs
dbLocation * reservedChain
size_t committedIndexSize
size_t currIndexSize
oid_t updatedRecordId
dbFilefile
dbMutex mutex
dbSemaphore writeSem
dbSemaphore readSem
dbSemaphore upgradeSem
dbEvent backupCompletedEvent
dbMonitor monitor
dbPagePool pool
dbTableDescriptortables
int * bitmapPageAvailableSpace
bool opened
long allocatedSize
int forceCommitCount
time_t commitDelay
time_t commitTimeout
time_t commitTimerStarted
dbMutex commitThreadSyncMutex
dbMutex delayedCommitStartTimerMutex
dbMutex delayedCommitStopTimerMutex
dbEvent commitThreadSyncEvent
dbEvent delayedCommitStartTimerEvent
dbEvent delayedCommitStopTimerEvent
dbDatabaseThreadContext * delayedCommitContext
dbMutex backupMutex
dbEvent backupInitEvent
char_t * backupFileName
time_t backupPeriod
dbThread backupThread
dbThread commitThread
dbTableDescriptorbatchList
int accessCount
dbL2List threadContextList
dbMutex threadContextListMutex
dbErrorHandler errorHandler
bool confirmDeleteColumns
int schemeVersion
dbVisitedObject * visitedChain
bool deleteFile

Detailed Description

Replicated version of GigaBASE


Member Enumeration Documentation

enum dbDatabase::dbErrorClass [inherited]
 

Error codes


Constructor & Destructor Documentation

dbReplicatedDatabase::dbReplicatedDatabase dbReplicationManager mng = NULL,
size_t  poolSize = 0,
size_t  dbExtensionQuantum = dbDefaultExtensionQuantum,
size_t  dbInitIndexSize = dbDefaultInitIndexSize,
int  nThreads = 1
[inline]
 

Constructor of the replicated database

Parameters:
mng replication manager
poolSize number of pages in page pool, if 0 GigaBASE will choose pool size itself depending on size of memory in the system DISKLESS_CONFIGURATION option, then in this parameter MAXIMAL size of the database should be specified (in this mode database can not be reallocated)
dbExtensionQuantum quentum for extending memory allocation bitmap
dbInitIndexSize initial index size (objects)
nThreads concurrency level for sequential search and sort operations
See also:
setConcurrency(unsigned nThreads)


Member Function Documentation

void dbDatabase::addIndices dbTableDescriptor desc  )  [protected, inherited]
 

Add new indices to the table.

Parameters:
desc new table descriptor
Returns:
true if indices were succesfully added

oid_t dbDatabase::addNewTable dbTableDescriptor desc  )  [protected, inherited]
 

Add new table to the database

Parameters:
desc - descriptor of new table
Returns:
oid of created table descriptor record

offs_t dbDatabase::allocate size_t  size,
oid_t  oid = 0
[protected, inherited]
 

Allocate object

Parameters:
size of the allocated object
oid object identifer of allocated object, if not null, then this method write position of allocated object in the object index.
Returns:
offset of allocated object in database file

oid_t dbDatabase::allocateId  )  [protected, inherited]
 

Allocate object identifier

Returns:
allocated object identifier

oid_t dbDatabase::allocatePage  )  [inline, protected, inherited]
 

Allocate page object

Returns:
object identifer of page object

void dbDatabase::allocateRow oid_t  tableId,
oid_t  oid,
size_t  size,
dbTableDescriptor desc
[protected, inherited]
 

Allocate record with specified OID

Parameters:
tableId object identifier of the table
oid record OID
size size of the created record
desc in-memory instance of table desriptor. If not null, then it is also updated, as well as table descriptor in the database

oid_t dbDatabase::allocateRow oid_t  tableId,
size_t  size,
dbTableDescriptor desc = NULL
[inline, protected, inherited]
 

Allocate record

Parameters:
tableId object identifier of the table
size size of the created record
desc in-memory instance of table desriptor. If not null, then it is also updated, as well as table descriptor in the database

void dbDatabase::allowColumnsDeletion bool  enabled = true  )  [inline, inherited]
 

Enable deletion of columns from the table when correspondent fields are renamed from class descriptor. By default it is switched of and database allows to delete fields only from empty table (to prevent unindented loose of data).

Parameters:
enabled true to enable column deletion in non empty tables

void dbDatabase::applyIndex dbFieldDescriptor field,
dbSearchContext &  sc
[protected, inherited]
 

Execute table search using index

Parameters:
field indexed field
sc search content which specified search parameters

void dbDatabase::assign dbTableDescriptor desc  )  [inline, inherited]
 

Assign table to the database

Parameters:
desc table descriptor

void dbDatabase::attach  )  [inherited]
 

Attach current thread to the database. This method should be executed for all threads except one which opened the database.

bool dbDatabase::backup char_t const *  backupFileName,
bool  compactify
[inherited]
 

Perform backup to the specified file

Parameters:
backupFileName path to the backup file
compactify if true then databae will be compactificated during backup - i.e. all used objects will be placed together without holes; if false then backup is performed by just writting memory mapped object to the backup file.
Returns:
whether backup was succeseful or not

void dbDatabase::backupScheduler  )  [protected, inherited]
 

backup scheduler thread

template<class T>
dbReference<T> dbDatabase::batchInsert T const &  record  )  [inline, inherited]
 

Batch insert record in the database. Field of the records will be added to the index at transaction commit time.

Parameters:
record transient object to be insrted in the database
Returns:
reference to the created object

void dbDatabase::beginTransaction dbLockType  type  )  [protected, inherited]
 

Start transaction (set trtansaction lock)

Parameters:
type lock type which has to be set by transaction

void dbDatabase::cleanupOnOpenError  )  [protected, inherited]
 

Release objects created during open(). This method is used when an error occurs during open.

void dbDatabase::cloneBitmap offs_t  pos,
size_t  size
[protected, inherited]
 

Clone bitmap page(s). Thisd method is used to clonepages of the bitmap (if them were not already cloned within this transaction) which will ber affected by free method at the end of transaction.

Parameters:
pos position of the object whcih will be deallocated
size size of the object whcih will be deallocated

void dbReplicatedDatabase::close  )  [virtual]
 

Close database

Reimplemented from dbDatabase.

void dbDatabase::commit dbDatabaseThreadContext *  ctx  )  [protected, inherited]
 

Commit transaction

Parameters:
ctx thread context

void dbDatabase::commit  )  [inherited]
 

Commit transaction

void dbDatabase::commitLocation  )  [protected, inherited]
 

Remove location from list of reserved locations. It is done after location is marked as occupied in bitmap.

bool dbDatabase::completeDescriptorsInitialization  )  [protected, inherited]
 

Complete descriptors initialization. This method checks all relations between records and assigned pointers to referenced tables and inverse fields

Returns:
true is tables definiton is consistent

void dbDatabase::createHashTable dbFieldDescriptor fd  )  [protected, inherited]
 

Create hash table for the field

Parameters:
fd field descriptor

void dbDatabase::createIndex dbFieldDescriptor fd  )  [protected, inherited]
 

Create T-Tree index for the field

Parameters:
fd field descriptor

void dbDatabase::delayedCommit  )  [protected, inherited]
 

Deltayed commit thread

void dbDatabase::deleteCompiledQuery dbExprNode *  tree  )  [static, protected, inherited]
 

Destroy compiled query

Parameters:
tree compiled query expression

void dbDatabase::deleteTable dbTableDescriptor desc  )  [protected, inherited]
 

Delete table from the database

Parameters:
desc table descriptor

void dbDatabase::detach int  flags = COMMIT|DESTROY_CONTEXT  )  [inherited]
 

Detach thread from the database.

Parameters:
flags mask of DetachFlags COMMIT and DESTROY_CONTEXT

void dbDatabase::dropHashTable dbFieldDescriptor fd  )  [protected, inherited]
 

Drop hash table for the field

Parameters:
fd field descriptor

void dbDatabase::dropIndex dbFieldDescriptor fd  )  [protected, inherited]
 

Drop T-Tree index for the field

Parameters:
fd field descriptor

void dbDatabase::dropTable dbTableDescriptor desc  )  [protected, inherited]
 

Delete all table records

Parameters:
desc table descriptor

void dbDatabase::endTransaction dbDatabaseThreadContext *  ctx  )  [protected, inherited]
 

End transaction (release transaction locks)

Parameters:
ctx thread context

void dbDatabase::evaluate dbExprNode *  expr,
oid_t  oid,
dbTableDescriptor table,
dbSynthesizedAttribute &  result
[protected, inherited]
 

Evaluate expression of arbitrary type.

Parameters:
expr evaluated expression
oid object identifier of the current record
table searched table
result synthesized attribute to receive result of expression evaluation

bool dbDatabase::evaluateBoolean dbExprNode *  expr,
oid_t  oid,
dbTableDescriptor table,
dbAnyCursor cursor
[protected, inherited]
 

Evaluate boolean expression

Parameters:
expr evaluated expression
oid object identifier of the current record
table searched table
cursor result set
Returns:
result of expression evaluation

size_t dbDatabase::evaluateString dbExprNode *  expr,
oid_t  oid,
dbTableDescriptor table,
char_t *  buf,
size_t  bufSize
[protected, inherited]
 

Evaluate string expression

Parameters:
expr evaluated expression
oid object identifier of the current record
table searched table
buf buffer to recive value of strign result
bufSize size of the buffer
Returns:
size of result string (if it is larger than buffer size, it will be truncated)

void _fastcall dbDatabase::execute dbExprNode *  expr,
dbInheritedAttribute &  iattr,
dbSynthesizedAttribute &  sattr
[static, protected, inherited]
 

Execute expression. This method is recursively called to calculate value of compund expression.

Parameters:
expr executed expression
iattr inherited attribute (information passed parent expression to childs)
sattr synthesized attribute (passing results of calculations)

void dbDatabase::executeBatch  )  [inherited]
 

Complete all batch inserts

bool dbDatabase::existsInverseReference dbExprNode *  expr,
int  nExistsClauses
[protected, inherited]
 

Check whether inverse reference exists for reference or array of reference field

Parameters:
expr dereference expression
nExistsClauses number of nested exists clauses containing this dereference expression
Returns:
true if it is possible to locate related records in the searched table using selected records in referenced table

void dbDatabase::extend offs_t  size  )  [protected, inherited]
 

Check that allocated object fits in the database file and extend database file if it is not true

Parameters:
size position of the allocated object + size of the object

dbTableDescriptor* dbDatabase::findTable char_t const *  name  )  [protected, inherited]
 

Find table using symbol name

Parameters:
name symbol table entry (returned by dbSymbolTable::add method)
Returns:
table descriptor or NULL if not found

dbTableDescriptor* dbDatabase::findTableByName char_t const *  name  )  [protected, inherited]
 

Find table by name. This method get symbol for specified name and call findTable method.

Parameters:
name name of table
Returns:
table descriptor or NULL if not found

void dbDatabase::free offs_t  pos,
size_t  size
[protected, inherited]
 

Free object

Parameters:
pos position of the object in database file
size size of the object

void dbDatabase::freeId oid_t  oid  )  [protected, inherited]
 

Release obejct identifier

Parameters:
oid deallocated object identifier

void dbDatabase::freePage oid_t  oid  )  [protected, inherited]
 

Deallocate page object

Parameters:
oid object identifer of page object

void dbDatabase::freeRow oid_t  tableId,
oid_t  oid,
dbTableDescriptor desc = NULL
[protected, inherited]
 

Deallocate record

Parameters:
tableId object identifier of the table
oid object identifier of deallocated record
desc in-memory instance of table desriptor. If not null, then it is also updated, as well

byte* dbDatabase::get oid_t  oid  )  [inline, protected, inherited]
 

Get readonly pointer to the body of page object

Parameters:
oid page object identifier
Returns:
pointer to the pinned object

long dbDatabase::getAllocatedSize  )  [inline, inherited]
 

Get size allocated in the database since open

Returns:
delta between size of allocated and deallocated data

offs_t dbDatabase::getDatabaseSize  )  [inline, inherited]
 

Return current size of the database. It can be larger than actual size fo database file (because it includes space reserved for uncommitted data)

Returns:
current database size in bytes

void dbDatabase::getHeader dbRecord rec,
oid_t  oid
[inline, protected, inherited]
 

Get object header

Parameters:
rec variable to receive object header
oid object identifier

offs_t dbDatabase::getPos oid_t  oid  )  [inline, protected, inherited]
 

Get position of the object in the database file

Parameters:
oid object identifier
Returns:
offset of the object in database file

dbRecord* dbDatabase::getRow dbGetTie &  tie,
oid_t  oid
[inline, protected, inherited]
 

Get table row

Parameters:
tie get tie used to pin accessed object
oid object indentifier
Returns:
object with this oid

dbTableDescriptor* dbDatabase::getTables  )  [protected, inherited]
 

Get list of tables attached to the database

Returns:
list of tables attached to the database

int dbDatabase::getVersion  )  [inherited]
 

Get database version

virtual void dbDatabase::handleError dbErrorClass  error,
char const *  msg = NULL,
int  arg = 0
[virtual, inherited]
 

Error handler. It can be redifined by application to implement application specific error handling.

Parameters:
error class of the error
msg error message
arg optional argument

void dbDatabase::initializeMetaTable  )  [protected, inherited]
 

Create meta table descriptor

template<class T>
dbReference<T> dbDatabase::insert T const &  record  )  [inline, inherited]
 

Insert record in the database

Parameters:
record transient object to be insrted in the database
Returns:
reference to the created object

void dbDatabase::insertInverseReference dbFieldDescriptor desc,
oid_t  reverseId,
oid_t  targetId
[protected, inherited]
 

Insert inverse reference. When reference or array of reference which is part of relation is updated then reference to the updated record is inserted in inverse reference field of all new referenced records (which were not referenced by this field before update).

Parameters:
desc descriptor of updated field (inverse reference should exist for this field)
reverseId OID of updated record
targetId OID of record referenced by this field

void dbDatabase::insertRecord dbTableDescriptor table,
dbAnyReference ref,
void const *  record,
bool  batch
[inherited]
 

Insert record in the database

Parameters:
table table descriptor
ref [out] pointer to the references where ID of created object will be stored
record pointer to the transient object to be inserted in the table
batch if true then record will be inserted in the batch mode: it will be included in indices at the trasnaction commit time

bool dbDatabase::isIndexApplicable dbAnyCursor cursor,
dbExprNode *  expr,
dbQuery query,
dbFieldDescriptor *&  indexedField,
bool &  truncate,
bool  ascent,
bool  forAll
[protected, inherited]
 

Try to execute query using indices. This recursive functions tries to split execution of request in one or more index search operations.

Parameters:
cursor result set
expr selection criteria
query executed query
indexedField (IN/OUT) indexed field used to perform index search
truncate (IN/OUT) flag used to indicate whether it is possible to stop search before testing all records (when query limit wis specified)
ascent key order: true - ascending order, false - descending order
forAll if this parameter is true, then indices should be applied to all parts of search condition, if it is false, then it is possible to use indexed search with filtering of the selected records using rest of the expression as filter.
Returns:
true, if query was evaluated using indices and cursor contains valid selection, false otherwise

bool dbDatabase::isIndexApplicableToExpr dbSearchContext &  sc,
dbExprNode *  expr
[protected, inherited]
 

Checks whether expression can be calculated using indicies.

Parameters:
sc search context. If expression can be only prtly evaluated using indices (for example LIKE), then original condition is stored in sc.condition, otherwise sc.condition is null
expr condition to be evaluated
Returns:
true is expression can be calculated using index, false otherwise

bool dbDatabase::isOpen  )  const [inline, inherited]
 

Check if database is opened

void dbDatabase::linkTable dbTableDescriptor table,
oid_t  tableId
[protected, inherited]
 

Link table to the database table list

Parameters:
table table descriptor
tableId OID of record containing database table descriptor

bool dbDatabase::loadScheme  )  [protected, inherited]
 

Load database schema. This method loads table decriptors from database, compare them with application classes, do necessary reformatting and save update andnew table decriptor in database

Returns:
true if schema was successfully loaded

void dbDatabase::lock dbLockType  type = dbExclusiveLock  )  [inline, inherited]
 

Lock database in specified mode

Parameters:
type lock type

dbTableDescriptor* dbDatabase::lookupTable dbTableDescriptor desc  )  [inherited]
 

Find cloned table desciptor assigned to this database

Parameters:
desc static unassigned table descriptor
Returns:
clone of this table descriptor assigned to this databae or NULL if not found.

bool dbDatabase::open dbFile file,
time_t  transactionCommitDelay = 0,
bool  deleteFileOnClose = false
[inherited]
 

Open database with user specific implementation of file

Parameters:
file user specific implementation of dbFile interface (file should open and ready to work)
transactionCommitDelay delayed commit timeout, by default disabled
deleteFileOnClose whether database should delete passed file when database is closed
Returns:
true if database was successfully opened

bool dbDatabase::open char_t const *  databaseName,
time_t  transactionCommitDelay = 0,
int  openAttr = dbFile::no_buffering
[inherited]
 

Open database

Parameters:
databaseName path to the database file
transactionCommitDelay delayed commit timeout, by default disabled
openAttr oppen attributes for database file
Returns:
true if database was successfully opened

bool dbReplicatedDatabase::open char const *  masterHostAddress,
int  nReplicas,
char_t const *  databaseName,
time_t  transactionCommitDelay = 0,
int  openAttr = dbFile::no_buffering
 

Open database

Parameters:
masterHostAddress address of the replication master
nReplicas number of slaves for master or 0 for slave
databaseName path to the database file
transactionCommitDelay delayed commit timeout, by default disabled
openAttr oppen attributes for database file
Returns:
true if database was successfully opened

void dbDatabase::precommit  )  [inherited]
 

Release all locks hold by transaction allowing other clients to proceed but do not flush changes to the disk

byte* dbDatabase::put dbPutTie &  tie,
oid_t  oid
[protected, inherited]
 

Get pointer to the page object which can be used to uodate this object

Parameters:
tie put tie used to pin updated object
oid page object identifier
Returns:
pointer to the page object

byte* dbDatabase::put oid_t  oid  )  [inline, protected, inherited]
 

Get pointer to the body of page object which can be used to update this object

Parameters:
oid page object identifier
Returns:
pointer to the pinned object

dbRecord* dbDatabase::putRow dbPutTie &  tie,
oid_t  oid
[protected, inherited]
 

Get pointer to the record which can be used to uodate this record. Record length is not changed.

Parameters:
tie put tie used to pin updated object
oid page object identifier
Returns:
pointer to the pinned object

dbRecord* dbDatabase::putRow dbPutTie &  tie,
oid_t  oid,
size_t  newSize
[protected, inherited]
 

Get pointer to the record which can be used to uodate this record

Parameters:
tie put tie used to pin updated object
oid page object identifier
newSize new size of the object
Returns:
pointer to the pinned object

void dbDatabase::reformatTable oid_t  tableId,
dbTableDescriptor desc
[protected, inherited]
 

Reformat table according to new format

Parameters:
tableId OID of changed tables
desc new table descriptor

void dbDatabase::remove dbTableDescriptor table,
oid_t  oid
[protected, inherited]
 

Remove record

Parameters:
table table to whcih updated record belongs
oid object identifer of the updated record

void dbDatabase::removeInverseReference dbFieldDescriptor desc,
oid_t  reverseId,
oid_t  targetId
[protected, inherited]
 

Remove inverse reference. When reference or array of reference which is part of relation is updated then reference to the updated record is removed from inverse reference field of all referenced records which are not reference any more from by this field.

Parameters:
desc descriptor of updated field (inverse reference should exist for this field)
reverseId OID of updated record
targetId OID of record referenced by this field

void dbDatabase::removeInverseReferences dbTableDescriptor desc,
oid_t  oid
[protected, inherited]
 

Remove inverse references to the removed record

Parameters:
desc descriptor of table from which record is removed
oid OID of removed record

void dbReplicatedDatabase::replicatePage offs_t  pageOffs,
void *  pageData
[protected, virtual]
 

Replicate page to all online slave nodes

Reimplemented from dbDatabase.

void dbDatabase::reserveLocation dbLocation &  location,
offs_t  pos,
size_t  size
[protected, inherited]
 

Mark location as reserved. This method is used by allocator to protect hole located in memory allocation bitmap, from been used by recursuve call of allocator (needed to clone bitmap pages).

Parameters:
location [out] local structure describing location.
pos start position of the location
size location size

bool dbDatabase::restore char_t const *  backupFileName,
char_t const *  databaseFileName
[inherited]
 

Restore database from the backup. Database should not be opened.

Parameters:
backupFileName path to the backup file
databaseFileName path to the database file
Returns:
true if database was successfully restored

void dbDatabase::restoreTablesConsistency  )  [protected, inherited]
 

Restore consistency of table list of rows (last record should contain null reference in next field). This method is used during recovery after crash and during rollback.

void dbDatabase::rollback  )  [inherited]
 

Rollback transaction

virtual void dbDatabase::scheduleBackup char_t const *  fileName,
time_t  periodSec
[virtual, inherited]
 

Schedule backup

Parameters:
fileName path to backup file. If name ends with '?', then each backup willbe placed in seprate file with '?' replaced with current timestamp
periodSec preiod of performing backups in seconds

void dbDatabase::select dbAnyCursor cursor,
dbQuery query
[protected, inherited]
 

Select all records matching the query

Parameters:
cursor result set
query search predicate

void dbDatabase::select dbAnyCursor cursor  )  [protected, inherited]
 

Select all records in the table defined by cursor

Parameters:
cursor result set

void dbDatabase::setConcurrency unsigned  nThreads  )  [inherited]
 

Set concurrency level for sequential search and sort operations. By default, FastDB tries to detect number of CPUs in system and create the same number of threads.

Parameters:
nThreads maximal number of threads to be created for perfroming cincurrent sequential search and sorting.

void dbDatabase::setDirty  )  [protected, inherited]
 

Mark database as been modified

dbErrorHandler dbDatabase::setErrorHandler dbErrorHandler  newHandler  )  [inherited]
 

Set error handler. Handler should be no-return function which perform stack unwind.

Parameters:
newHandler new error handler
Returns:
previous handler

void dbDatabase::setFileExtensionQuantum offs_t  quantum  )  [inline, inherited]
 

Set database file extension quantum. When new record as appended to the file, OS ussually has to perform two writes: one to write data itself and one to update files metadata. But specifyig file extension quentums we reduce number of cases when fiel metadata has to be updated and os increase performance

Parameters:
quantum new value of file extension quantum

void dbDatabase::setFileSizeLimit offs_t  limit  )  [inline, inherited]
 

Specify database file size limit. Attempt to exeed this limit cause database error.

Parameters:
limit maximal file size in bytes

void dbDatabase::setPos oid_t  oid,
offs_t  pos
[inline, protected, inherited]
 

Set position of the object

Parameters:
oid object identifier
pos offset of the object in database file

void dbReplicatedDatabase::slaveReplication  )  [protected]
 

Method executed at slave to perform sycnhronization with master node

void dbReplicatedDatabase::stopMasterReplication  ) 
 

Stop replication to slave. Method is anvioked at moster node.

void dbDatabase::traverse dbAnyCursor cursor,
dbQuery query
[protected, inherited]
 

Traverse the table using iterato specified in query (START FROM .. FOLLOW BY...)

Parameters:
cursor result set
query search predicate

void dbDatabase::unlinkTable dbTableDescriptor table  )  [protected, inherited]
 

Unlink table from the database tables list

Parameters:
table table descriptor

void dbDatabase::update oid_t  oid,
dbTableDescriptor table,
void const *  record
[protected, inherited]
 

Update record

Parameters:
oid object identifer of the updated record
table table to whcih updated record belongs
record new unpacked image of the record

void dbDatabase::updateCursors oid_t  oid,
bool  removed = false
[protected, inherited]
 

Update current records in all openned cursors. Check if specified record is selected by some of cursors and perform update in this case

Parameters:
oid object identifier of the modified record
removed true if record was removed

void dbDatabase::updateTableDescriptor dbTableDescriptor desc,
oid_t  tableId,
dbTable table
[protected, inherited]
 

Update database table descriptor

Parameters:
desc application table descriptor
tableId OID of recrods with database table descriptor
table packed descriptor of table in database

offs_t dbDatabase::used  )  [inherited]
 

Calcualte total size of all memory used in ther database

Returns:
total size of all objects in the database

bool dbDatabase::wasReserved offs_t  pos,
size_t  size
[protected, inherited]
 

Check if location is reserved

Parameters:
pos start position of the location
size location size
Returns:
true id location was reserved


The documentation for this class was generated from the following file:
Generated on Thu Feb 12 18:46:28 2004 for GigaBASE by doxygen 1.3.5