#include <replicator.h>
Public Types | |
enum | dbAccessType { dbReadOnly, dbAllAccess, dbMulticlientReadOnly, dbMulticlientReadWrite } |
enum | DetachFlags { COMMIT = 1, DESTROY_CONTEXT = 2 } |
enum | BackupFlags { BCK_COMPACTIFY = 1, BCK_INCREMENTAL = 2, BCK_HOLD_LOCK = 4 } |
enum | dbErrorClass { NoError, QueryError, ArithmeticError, IndexOutOfRangeError, DatabaseOpenError, FileError, OutOfMemoryError, Deadlock, NullReferenceError, FileLimitExeeded, DatabaseReadOnly, UniqueConstraintViolation, InconsistentInverseReference, OperationNotSupported, SocketError, CursorError, AccessToDeletedObject, IncompatibleSchemaChange, RejectedByTransactionLogger } |
enum | SelectionMethod { sel_all, sel_all_except, sel_named_only } |
typedef void(* | dbErrorHandler )(int error, char const *msg, int msgarg, void *context) |
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=0) |
bool | open (dbFile *file, time_t transactionCommitDelay=0, bool deleteFileOnClose=false) |
bool | open (OpenParameters ¶ms) |
void | commit () |
void | executeBatch () |
void | precommit () |
void | rollback () |
void | attach () |
void | attach (dbDatabaseThreadContext *ctx) |
void | detach (int flags=COMMIT|DESTROY_CONTEXT) |
void | lock (dbLockType type=dbExclusiveLock) |
bool | backup (char_t const *backupFileName, int flags=0) |
bool | backup (dbOSFile *file, int flags=0) |
bool | restore (char_t const *backupFileName, char_t const *databaseFileName) |
int | getVersion () |
void | assign (dbTableDescriptor &desc) |
dbTableDescriptor * | lookupTable (dbTableDescriptor *desc) |
void | getMemoryStatistic (dbMemoryStatistic &stat) |
void | setConcurrency (unsigned nThreads) |
soffs_t | getAllocatedSize () |
void | allowColumnsDeletion (bool enabled=true) |
void | enableInverseReferencesUpdate (bool enabled=true) |
void | disableOidReuseOnClose (bool disabled=true) |
bool | prepareQuery (dbAnyCursor *cursor, dbQuery &query) |
dbErrorHandler | setErrorHandler (dbErrorHandler newHandler, void *errorHandlerContext=NULL) |
void | setTransactionLogger (dbTransactionLogger *logger) |
virtual void | scheduleBackup (char_t const *fileName, time_t periodSec) |
virtual void | handleError (dbErrorClass error, char const *msg=NULL, int arg=0) |
bool | 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) |
void | createCluster (offs_t size) |
template<class T > | |
dbReference< T > | insert (T const &record) |
template<class T > | |
dbReference< T > | batchInsert (T const &record) |
bool | isValidOid (oid_t oid) |
void | exportDatabaseToXml (FILE *out, char_t const *const *tables, size_t nTables, SelectionMethod method) |
void | exportDatabaseToXml (FILE *out, char_t const *const *tables, size_t nTables, SelectionMethod method, char_t const *encoding) |
bool | importDatabaseFromXml (FILE *in) |
dbTableDescriptor * | findTableByName (char_t const *name) |
dbTableDescriptor * | findTableByID (oid_t id) |
dbTableDescriptor * | getTables () |
Public Attributes | |
dbAccessType | accessType |
size_t | extensionQuantum |
size_t | initIndexSize |
offs_t | freeSpaceReuseThreshold |
dbTableDescriptor * | tableHash [dbTableHashSize] |
Static Public Attributes | |
static char const *const | errorMessage [] |
static unsigned | dbParallelScanThreshold |
Protected Member Functions | |
void | slaveReplication () |
void | replicatePage (offs_t pageOffs, void *pageData) |
void | commit (dbDatabaseThreadContext *ctx) |
bool | insertRecord (dbTableDescriptor *desc, oid_t oid, void const *record) |
oid_t | mapId (long id) |
bool | importField (char_t *terminator, dbFieldDescriptor *fd, byte *rec, dbXmlScanner &scanner) |
bool | importRecord (char_t *terminator, dbFieldDescriptor *fieldList, byte *rec, dbXmlScanner &scanner) |
dbTableDescriptor * | loadMetaTable () |
void | releaseFile () |
void | delayedCommit () |
void | backupScheduler () |
offs_t | getPos (oid_t oid) |
void | setPos (oid_t oid, offs_t pos) |
dbRecord * | getRow (dbGetTie &tie, oid_t oid) |
dbRecord * | getRow (dbGetTie &tie, oid_t oid, size_t size) |
dbRecord * | fetchRow (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) |
dbRecord * | putRow (dbPutTie &tie, oid_t oid, size_t newSize) |
dbRecord * | putRow (dbPutTie &tie, oid_t oid) |
void | restoreTablesConsistency () |
void | applyIndex (dbFieldDescriptor *field, dbSearchContext &sc) |
bool | isIndicesApplicable (dbAnyCursor *cursor, dbExprNode *expr, bool &unique) |
bool | applyIndices (dbAnyCursor *cursor, dbExprNode *expr, dbExprNode *topExpr, dbExprNode *filter, dbQuery &query, dbFieldDescriptor *&indexedField, bool &truncate, bool ascent) |
bool | isIndexApplicableToExpr (dbSearchContext &sc, dbExprNode *expr) |
bool | followInverseReference (dbExprNode *expr, dbExprNode *andExpr, dbAnyCursor *cursor, oid_t iref) |
bool | existsInverseReference (dbExprNode *expr, int nExistsClauses) |
bool | existsIndexedReference (dbExprNode *expr) |
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) |
bool | update (oid_t oid, dbTableDescriptor *table, void const *record) |
void | remove (dbTableDescriptor *table, oid_t oid) |
offs_t | allocate (offs_t size, oid_t oid=0) |
void | free (offs_t pos, offs_t size) |
void | extend (offs_t size) |
void | cloneBitmap (offs_t pos, offs_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, offs_t size) |
void | reserveLocation (dbLocation &location, offs_t pos, offs_t size) |
void | commitLocation () |
dbTableDescriptor * | findTable (char_t const *name) |
void | cleanupOnOpenError () |
void | setDirty () |
void | refreshTable (dbTableDescriptor *desc) |
Static Protected Member Functions | |
static void thread_proc | slaveReplicationProc (void *arg) |
static void thread_proc | delayedCommitProc (void *arg) |
static void thread_proc | backupSchedulerProc (void *arg) |
static void _fastcall | execute (dbExprNode *expr, dbInheritedAttribute &iattr, dbSynthesizedAttribute &sattr) |
static void | deleteCompiledQuery (dbExprNode *tree) |
Protected Attributes | |
int | nReplicas |
socket_t ** | replicationSlaves |
socket_t * | replicationMaster |
dbReplicationManager * | replicationManager |
dbThread | replicationThread |
dbThreadContext < dbDatabaseThreadContext > | threadContext |
dbThreadPool | threadPool |
dbHeader * | header |
int4 * | dirtyPagesMap |
unsigned | parThreads |
bool | modified |
int | curr |
int | transactionId |
bool | uncommittedChanges |
offs_t | dbFileExtensionQuantum |
offs_t | dbFileSizeLimit |
volatile int | commitInProgress |
volatile int | concurrentTransId |
oid_t | currRBitmapPage |
size_t | currRBitmapOffs |
oid_t | currPBitmapPage |
size_t | currPBitmapOffs |
dbLocation * | reservedChain |
oid_t | committedIndexSize |
oid_t | currIndexSize |
oid_t | updatedRecordId |
dbFile * | file |
dbMutex | mutex |
dbSemaphore | writeSem |
dbSemaphore | readSem |
dbSemaphore | upgradeSem |
dbEvent | backupCompletedEvent |
dbMonitor | monitor |
dbPagePool | pool |
dbTableDescriptor * | tables |
int * | bitmapPageAvailableSpace |
bool | opened |
soffs_t | allocatedSize |
offs_t | deallocatedSize |
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 |
dbTableDescriptor * | batchList |
int | accessCount |
dbL2List | threadContextList |
dbMutex | threadContextListMutex |
dbErrorHandler | errorHandler |
void * | errorHandlerContext |
dbTransactionLogger * | logger |
bool | confirmDeleteColumns |
bool | inverseReferencesUpdate |
int | schemeVersion |
dbVisitedObject * | visitedChain |
int * | btreeBuf |
bool | deleteFile |
bool | doNotReuseOidAfterClose |
bool | preserveExistedIndices |
dbXmlContext * | xmlContext |
int * | dirtyPageBitmap |
size_t | dirtyPageBitmapSize |
Replicated version of GigaBASE
enum dbDatabase::dbErrorClass [inherited] |
Error codes
enum dbDatabase::SelectionMethod [inherited] |
When naming tables in `export' method:
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
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 |
void dbDatabase::addIndices | ( | dbTableDescriptor * | desc | ) | [protected, inherited] |
Add new indices to the table.
desc | new table descriptor |
oid_t dbDatabase::addNewTable | ( | dbTableDescriptor * | desc | ) | [protected, inherited] |
Add new table to the database
desc | - descriptor of new table |
offs_t dbDatabase::allocate | ( | offs_t | size, | |
oid_t | oid = 0 | |||
) | [protected, inherited] |
Allocate object
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. |
oid_t dbDatabase::allocateId | ( | ) | [protected, inherited] |
Allocate object identifier
oid_t dbDatabase::allocatePage | ( | ) | [inline, protected, inherited] |
Allocate page object
void dbDatabase::allocateRow | ( | oid_t | tableId, | |
oid_t | oid, | |||
size_t | size, | |||
dbTableDescriptor * | desc | |||
) | [protected, inherited] |
Allocate record with specified OID
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
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).
enabled | true to enable column deletion in non empty tables |
void dbDatabase::applyIndex | ( | dbFieldDescriptor * | field, | |
dbSearchContext & | sc | |||
) | [protected, inherited] |
Execute table search using index
field | indexed field | |
sc | search content which specified search parameters |
bool dbDatabase::applyIndices | ( | dbAnyCursor * | cursor, | |
dbExprNode * | expr, | |||
dbExprNode * | topExpr, | |||
dbExprNode * | filter, | |||
dbQuery & | query, | |||
dbFieldDescriptor *& | indexedField, | |||
bool & | truncate, | |||
bool | ascent | |||
) | [protected, inherited] |
Try to execute query using indices. This recursive functions tries to split execution of request in one or more index search operations.
cursor | result set | |
expr | selection criteria | |
topExpr | top expression | |
filter | filter expression | |
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 |
void dbDatabase::assign | ( | dbTableDescriptor & | desc | ) | [inline, inherited] |
Assign table to the database
desc | table descriptor |
References dbTableDescriptor::db, dbTableDescriptor::fixedDatabase, and dbTableDescriptor::tableId.
void dbDatabase::attach | ( | ) | [inherited] |
Attach current thread to the database. This method should be executed for all threads except one which opened the database.
void dbDatabase::attach | ( | dbDatabaseThreadContext * | ctx | ) | [inherited] |
Set transaction context for the current thread. Using this method allows to share the same transaction between different threads
ctx | transaction context which will be associated with the current thread |
bool dbDatabase::backup | ( | char_t const * | backupFileName, | |
int | flags = 0 | |||
) | [inherited] |
Perform backup to the specified file
backupFileName | path to the backup file | |
flags | combination of BCK_* backup flags |
bool dbDatabase::backup | ( | dbOSFile * | file, | |
int | flags = 0 | |||
) | [inherited] |
Perform backup to the specified file
file | opened file to path to the backup file. This file will not be closed after backup completion. | |
flags | combination of BCK_* backup flags |
void dbDatabase::backupScheduler | ( | ) | [protected, inherited] |
backup scheduler thread
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.
record | transient object to be insrted in the database |
void dbDatabase::beginTransaction | ( | dbLockType | type | ) | [protected, inherited] |
Start transaction (set trtansaction lock)
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, | |
offs_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.
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 | ( | ) | [inherited] |
Commit transaction
void dbDatabase::commit | ( | dbDatabaseThreadContext * | ctx | ) | [protected, inherited] |
Commit transaction
ctx | thread context |
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
true
is tables definiton is consistent void dbDatabase::createCluster | ( | offs_t | size | ) | [inherited] |
Reserve space for sequential allocation of objects. This method can be used for placing several objects which are used to be access together sequentially in the disk and so increase locality of references. This method can be used when objects are allocated (but please notice that GigaBASE allocator in any case tries to do it best to allocate objects sequentially) and what it more important it can be used to reallocate object cluster if object access pattern is different from object allocation order.
size | size of the cluster. Calling this method will guaranty that subsequent allocation requests will allocate objects object sequentially until their size becomes larger then size of the cluster. |
void dbDatabase::createHashTable | ( | dbFieldDescriptor * | fd | ) | [protected, inherited] |
Create hash table for the field
fd | field descriptor |
void dbDatabase::createIndex | ( | dbFieldDescriptor * | fd | ) | [protected, inherited] |
Create T-Tree index for the field
fd | field descriptor |
void dbDatabase::delayedCommit | ( | ) | [protected, inherited] |
Deltayed commit thread
static void dbDatabase::deleteCompiledQuery | ( | dbExprNode * | tree | ) | [static, protected, inherited] |
Destroy compiled query
tree | compiled query expression |
void dbDatabase::deleteTable | ( | dbTableDescriptor * | desc | ) | [protected, inherited] |
Delete all table records
desc | table descriptor |
void dbDatabase::detach | ( | int | flags = COMMIT|DESTROY_CONTEXT |
) | [inherited] |
Detach thread from the database.
flags | mask of DetachFlags COMMIT and DESTROY_CONTEXT |
void dbDatabase::disableOidReuseOnClose | ( | bool | disabled = true |
) | [inline, inherited] |
Disable or enable reuse of OIDs of deallocated objects when session is closed
void dbDatabase::dropHashTable | ( | dbFieldDescriptor * | fd | ) | [protected, inherited] |
Drop hash table for the field
fd | field descriptor |
void dbDatabase::dropIndex | ( | dbFieldDescriptor * | fd | ) | [protected, inherited] |
Drop T-Tree index for the field
fd | field descriptor |
void dbDatabase::dropTable | ( | dbTableDescriptor * | desc | ) | [protected, inherited] |
Delete table from the database
desc | table descriptor |
void dbDatabase::enableInverseReferencesUpdate | ( | bool | enabled = true |
) | [inline, inherited] |
Enable or disable automatic update of inverse references
enabled | true to enable automatic update of inverse references, false to disable it |
void dbDatabase::endTransaction | ( | dbDatabaseThreadContext * | ctx | ) | [protected, inherited] |
End transaction (release transaction locks)
ctx | thread context |
void dbDatabase::evaluate | ( | dbExprNode * | expr, | |
oid_t | oid, | |||
dbTableDescriptor * | table, | |||
dbSynthesizedAttribute & | result | |||
) | [protected, inherited] |
Evaluate expression of arbitrary type.
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
expr | evaluated expression | |
oid | object identifier of the current record | |
table | searched table | |
cursor | result set |
size_t dbDatabase::evaluateString | ( | dbExprNode * | expr, | |
oid_t | oid, | |||
dbTableDescriptor * | table, | |||
char_t * | buf, | |||
size_t | bufSize | |||
) | [protected, inherited] |
Evaluate string expression
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 |
static 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.
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::existsIndexedReference | ( | dbExprNode * | expr | ) | [protected, inherited] |
Check whether index exists for derefenced field
expr | dereference expression |
true
if reference field is indexed bool dbDatabase::existsInverseReference | ( | dbExprNode * | expr, | |
int | nExistsClauses | |||
) | [protected, inherited] |
Check whether inverse reference exists for reference or array of reference field
expr | dereference expression | |
nExistsClauses | number of nested exists clauses containing this dereference expression |
true
if it is possible to locate related records in the searched table using selected records in referenced table void dbDatabase::exportDatabaseToXml | ( | FILE * | out, | |
char_t const *const * | tables, | |||
size_t | nTables, | |||
SelectionMethod | method | |||
) | [inherited] |
Export database in XML format to the specified stream
out | stream where XML representation of database will be printed | |
tables | array of table names to be exported | |
nTables | number of exported tables | |
method | method of selecting table to be exported |
void dbDatabase::exportDatabaseToXml | ( | FILE * | out, | |
char_t const *const * | tables, | |||
size_t | nTables, | |||
SelectionMethod | method, | |||
char_t const * | encoding | |||
) | [inherited] |
Export database in XML format to the specified stream
out | stream where XML representation of database will be printed | |
tables | array of table names to be exported | |
nTables | number of exported tables | |
method | method of selecting table to be exported | |
encoding | generated XML document encoding (no conversion to the specified encoding is performed, it just specified in xml document header) |
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
size | position of the allocated object + size of the object |
dbRecord* dbDatabase::fetchRow | ( | dbGetTie & | tie, | |
oid_t | oid | |||
) | [inline, protected, inherited] |
Fetch table row (unlike getRow this method always copy content of the row and do not keep references to the page pool)
tie | get tie used to pin accessed object | |
oid | object indentifier |
dbTableDescriptor* dbDatabase::findTable | ( | char_t const * | name | ) | [protected, inherited] |
Find table using symbol name
name | symbol table entry (returned by dbSymbolTable::add method) |
NULL
if not found dbTableDescriptor* dbDatabase::findTableByID | ( | oid_t | id | ) | [inherited] |
Find table by its OID
id | OID of the table |
NULL
if not found dbTableDescriptor* dbDatabase::findTableByName | ( | char_t const * | name | ) | [inherited] |
Find table by name. This method get symbol for specified name and call findTable
method.
name | name of table |
NULL
if not found void dbDatabase::free | ( | offs_t | pos, | |
offs_t | size | |||
) | [protected, inherited] |
Free object
pos | position of the object in database file | |
size | size of the object |
void dbDatabase::freeId | ( | oid_t | oid | ) | [protected, inherited] |
Release obejct identifier
oid | deallocated object identifier |
void dbDatabase::freePage | ( | oid_t | oid | ) | [protected, inherited] |
Deallocate page object
oid | object identifer of page object |
void dbDatabase::freeRow | ( | oid_t | tableId, | |
oid_t | oid, | |||
dbTableDescriptor * | desc = NULL | |||
) | [protected, inherited] |
Deallocate record
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
oid | page object identifier |
soffs_t dbDatabase::getAllocatedSize | ( | ) | [inline, inherited] |
Get size allocated in the database since open
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)
void dbDatabase::getHeader | ( | dbRecord & | rec, | |
oid_t | oid | |||
) | [inline, protected, inherited] |
Get object header
rec | variable to receive object header | |
oid | object identifier |
void dbDatabase::getMemoryStatistic | ( | dbMemoryStatistic & | stat | ) | [inherited] |
Get information about state of database memory
stat | placeholder for memory statistic |
offs_t dbDatabase::getPos | ( | oid_t | oid | ) | [inline, protected, inherited] |
Get position of the object in the database file
oid | object identifier |
dbRecord* dbDatabase::getRow | ( | dbGetTie & | tie, | |
oid_t | oid, | |||
size_t | size | |||
) | [inline, protected, inherited] |
Get fixed part of table row
tie | get tie used to pin accessed object | |
oid | object indentifier | |
size | size of fixed part |
dbRecord* dbDatabase::getRow | ( | dbGetTie & | tie, | |
oid_t | oid | |||
) | [inline, protected, inherited] |
Get table row
tie | get tie used to pin accessed object | |
oid | object indentifier |
dbTableDescriptor* dbDatabase::getTables | ( | ) | [inline, inherited] |
Get 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.
error | class of the error | |
msg | error message | |
arg | optional argument |
Referenced by dbCursor< dbTimeSeriesBlock< T > >::operator->().
bool dbDatabase::importDatabaseFromXml | ( | FILE * | in | ) | [inherited] |
Import database from XML data source
in | input stream with XML data |
void dbDatabase::initializeMetaTable | ( | ) | [protected, inherited] |
Create meta table descriptor
dbReference<T> dbDatabase::insert | ( | T const & | record | ) | [inline, inherited] |
Insert record in the database
record | transient object to be insrted in the database |
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).
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 |
bool dbDatabase::insertRecord | ( | dbTableDescriptor * | table, | |
dbAnyReference * | ref, | |||
void const * | record, | |||
bool | batch | |||
) | [inherited] |
Insert record in the database
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::isIndexApplicableToExpr | ( | dbSearchContext & | sc, | |
dbExprNode * | expr | |||
) | [protected, inherited] |
Checks whether expression can be calculated using indicies.
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 |
bool dbDatabase::isIndicesApplicable | ( | dbAnyCursor * | cursor, | |
dbExprNode * | expr, | |||
bool & | unique | |||
) | [protected, inherited] |
Check if indices are applibale for expression evaluation
cursor | result set | |
expr | selection criteria | |
unique | [OUT] is index is uniue |
bool dbDatabase::isOpen | ( | ) | const [inline, inherited] |
Check if database is opened
bool dbDatabase::isValidOid | ( | oid_t | oid | ) | [inline, inherited] |
Check if OID corresponds to the valid object
oid | inspected OID |
void dbDatabase::linkTable | ( | dbTableDescriptor * | table, | |
oid_t | tableId | |||
) | [protected, inherited] |
Link table to the database table list
table | table descriptor | |
tableId | OID of record containing database table descriptor |
dbTableDescriptor* dbDatabase::loadMetaTable | ( | ) | [protected, inherited] |
Loads all class descriptors. This method should be used SubSQL and any other apllication which is should work with ANY database file.
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
true
if schema was successfully loaded void dbDatabase::lock | ( | dbLockType | type = dbExclusiveLock |
) | [inline, inherited] |
Lock database in specified mode
type | lock type |
dbTableDescriptor* dbDatabase::lookupTable | ( | dbTableDescriptor * | desc | ) | [inherited] |
Find cloned table desciptor assigned to this database
desc | static unassigned table descriptor |
Referenced by dbCursor< dbTimeSeriesBlock< T > >::dbCursor().
bool dbDatabase::open | ( | OpenParameters & | params | ) | [inherited] |
Open database with parameters defined in OpenParameters structure
params | parameters for openning database |
true
if database was successfully opened bool dbDatabase::open | ( | dbFile * | file, | |
time_t | transactionCommitDelay = 0 , |
|||
bool | deleteFileOnClose = false | |||
) | [inherited] |
Open database with user specific implementation of file
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 |
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
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 |
true
if database was successfully opened bool dbDatabase::open | ( | char_t const * | databaseName, | |
time_t | transactionCommitDelay = 0 , |
|||
int | openAttr = 0 | |||
) | [inherited] |
Open database
databaseName | path to the database file | |
transactionCommitDelay | delayed commit timeout, by default disabled | |
openAttr | oppen attributes for database file |
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
bool dbDatabase::prepareQuery | ( | dbAnyCursor * | cursor, | |
dbQuery & | query | |||
) | [inherited] |
Prepare query. This method can be used for explicit compilation of query and it's validation
cursor | result set | |
query | query expression |
true
if query is successfully compiled, false
othgerwise byte* dbDatabase::put | ( | dbPutTie & | tie, | |
oid_t | oid | |||
) | [protected, inherited] |
Get pointer to the page object which can be used to uodate this object
tie | put tie used to pin updated object | |
oid | page object identifier |
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
oid | page object identifier |
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.
tie | put tie used to pin updated object | |
oid | page object identifier |
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
tie | put tie used to pin updated object | |
oid | page object identifier | |
newSize | new size of the object |
void dbDatabase::reformatTable | ( | oid_t | tableId, | |
dbTableDescriptor * | desc | |||
) | [protected, inherited] |
Reformat table according to new format
tableId | OID of changed tables | |
desc | new table descriptor |
void dbDatabase::refreshTable | ( | dbTableDescriptor * | desc | ) | [protected, inherited] |
Refresh table descriptor in multiclient mode
void dbDatabase::remove | ( | dbTableDescriptor * | table, | |
oid_t | oid | |||
) | [protected, inherited] |
Remove record
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.
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
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, | |||
offs_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).
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.
backupFileName | path to the backup file | |
databaseFileName | path to the database file |
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
fileName | path to backup file. If name ends with '?', then each backup willbe placed in seprate file with '?' replaced with current timestamp | |
periodSec | period of performing backups in seconds |
void dbDatabase::select | ( | dbAnyCursor * | cursor, | |
dbQuery & | query | |||
) | [protected, inherited] |
Select all records matching the query
cursor | result set | |
query | search predicate |
void dbDatabase::select | ( | dbAnyCursor * | cursor | ) | [protected, inherited] |
Select all records in the table defined by cursor
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.
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, | |
void * | errorHandlerContext = NULL | |||
) | [inherited] |
Set error handler. Handler should be no-return function which perform stack unwind.
newHandler | new error handler | |
errorHandlerContext | extra parameter passed to error 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
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.
limit | maximal file size in bytes |
void dbDatabase::setPos | ( | oid_t | oid, | |
offs_t | pos | |||
) | [inline, protected, inherited] |
Set position of the object
oid | object identifier | |
pos | offset of the object in database file |
void dbDatabase::setTransactionLogger | ( | dbTransactionLogger * | logger | ) | [inherited] |
Set trasnaction logger. This method should be used to log transactions to some external destination. Logger should not be saved when transaction is replayed from this source.
logger | trasnaction logger (NULL to disable logging) |
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...)
cursor | result set | |
query | search predicate |
void dbDatabase::unlinkTable | ( | dbTableDescriptor * | table | ) | [protected, inherited] |
Unlink table from the database tables list
table | table descriptor |
bool dbDatabase::update | ( | oid_t | oid, | |
dbTableDescriptor * | table, | |||
void const * | record | |||
) | [protected, inherited] |
Update record
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
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
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
bool dbDatabase::wasReserved | ( | offs_t | pos, | |
offs_t | size | |||
) | [protected, inherited] |
Check if location is reserved
pos | start position of the location | |
size | location size |