GlobalObjects
Loading...
Searching...
No Matches
glo::IndexPool::SchemaIndex Class Reference

Is the index manager class for a schema resp. a database. More...

#include <GloIndexPool.h>

Public Member Functions

 SchemaIndex (const SchemaIndex &rT)
 
 SchemaIndex (const std::string &rstrName)
 
 ~SchemaIndex ()
 
int getFreeObjIDPos (std::streampos &rPos, unsigned long ulClassID) const
 
int getObjectStrIndex (ObjectStrIndex *&prRetVal, unsigned long ulClassID, const std::string &rsIndexName)
 
int getObjectStrIndexIterator (ObjectStrIndexIterator *&prObjectStrIndexIterators, unsigned long ulClassID, const std::string &rsIndexName) const
 
const std::multimap< unsigned long, IndexPool::ObjectStrIndex *, std::less< unsigned long > > & getObjectStrIndexMapRef () const
 
int getObjIdPosTuple (ObjIdPosTuple *&prRetVal, unsigned long ulClassID, const ObjID &rObjID) const
 
std::string getSchemaName () const
 
int getTableObjIdIndex (TableObjIdIndex *&prRetVal, unsigned long ulClassID) const
 
int getTableObjIdIndexIterator (TableObjIdIndexIterator *&prTableIterators, unsigned long ulClassID) const
 
const std::map< unsigned long, IndexPool::TableObjIdIndex *, std::less< unsigned long > > & getTableObjIdIndexMapRef () const
 
int insertDeletedObjID (const ObjID &rDeletedObjId)
 
int insertFreeObjIDPos (unsigned long ulClassID, std::streampos Pos)
 
int insertObjIdPosTuple (unsigned long ulClassID, const ObjIdPosTuple &rIndexTuple)
 
int insertObjStrIdTuple (unsigned long ulClassID, const std::string &rsIndexName, const ObjStrIdTuple &rIndexTuple)
 
int insertTransactionDeletedObjID (const ObjID &rDeletedObjId)
 
int isIndexFree (unsigned long ulClassID, const ObjID &rObjID, const std::string &rsIndexName, const std::string &rsIndex) const
 
bool isObjIdDeleted (const ObjID &rObjID) const
 
int isObjIdFree (unsigned long ulClassID, const ObjID &rObjID) const
 
int makeObjectStrIndex (const std::string &rsPathName, unsigned long ulClassID, const std::string &rsIndexName, bool bUnique)
 
int makeTableObjIdIndex (const std::string &rsPathName, unsigned long ulClassID)
 
IndexPool::SchemaIndexoperator= (const SchemaIndex &rT)
 
int releaseObjStrIdTuple (unsigned long ulClassID, const std::string &rsIndexName, const NUM_PTR ipReservingComunicatorTrx)
 
int removeFreeObjIDPos (unsigned long ulClassID, std::streampos Pos)
 
int removeObjectStrIndex (unsigned long ulClassID, const std::string &rsIndexName)
 
int removeObjId (unsigned long ulClassID, const ObjID &rObjID)
 
int removeObjStrIdTuple (unsigned long ulClassID, const std::string &rsIndexName, const ObjID &rObjID, NUM_PTR ipReservingComunicatorTrx=0)
 
int removeTableObjIdIndex (unsigned long ulClassID)
 
int removeTransactionDeletedObjID (const ObjID &rDeletedObjId)
 
int reserveObjStrIdTuple (unsigned long ulClassID, const std::string &rsIndexName, const ObjStrIdTuple &rIndexTuple)
 

Protected Member Functions

 SchemaIndex ()
 
void copyMapsFrom (const SchemaIndex &rT)
 
void deleteAllTableIndexValues ()
 

Private Attributes

std::map< ObjID, ObjID *, std::less< ObjID > > m_DeletedObjIdMap
 
std::multimap< unsigned long, ObjectStrIndex *, std::less< unsigned long > > m_ObjectStrIndexMap
 
std::string m_sSchemaName
 
std::map< unsigned long, TableObjIdIndex *, std::less< unsigned long > > m_TableObjIdIndexMap
 
std::map< ObjID, DeletedObjIdTuple *, std::less< ObjID > > m_TransactionDeletedObjIdMap
 

Detailed Description

Is the index manager class for a schema resp. a database.

Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ SchemaIndex() [1/3]

glo::IndexPool::SchemaIndex::SchemaIndex ( )
protected

The default constructor is not available.

◆ SchemaIndex() [2/3]

glo::IndexPool::SchemaIndex::SchemaIndex ( const std::string & rstrName)

Constructor with parameter passing.

Parameters
[in]rstrNameThe schema name (e.g. "MyGloBase").

◆ SchemaIndex() [3/3]

glo::IndexPool::SchemaIndex::SchemaIndex ( const SchemaIndex & rT)

Copy constructor.

Parameters
[in]rTThe data is copied from this object.
Exceptions
eut::ErrorNExceptionAn exception is thrown if an error occurs.

◆ ~SchemaIndex()

glo::IndexPool::SchemaIndex::~SchemaIndex ( )

Destructor.

Member Function Documentation

◆ copyMapsFrom()

void glo::IndexPool::SchemaIndex::copyMapsFrom ( const SchemaIndex & rT)
protected

Removes all elements from its maps. Then all elements of the same maps of the passed SchemaIndex are copied.

Parameters
[in]rTThe SchemaIndex whose elements are to be copied from the maps.

◆ deleteAllTableIndexValues()

void glo::IndexPool::SchemaIndex::deleteAllTableIndexValues ( )
protected

Removes all elements from its maps and from memory.

◆ getFreeObjIDPos()

int glo::IndexPool::SchemaIndex::getFreeObjIDPos ( std::streampos & rPos,
unsigned long ulClassID ) const

Returns a free table position in a table.

Parameters
[in,out]rPosThe free table position, if one exists.
[in]ulClassIDThe class ID to identify the TableObjIdIndex.
Returns
A return value < 0 indicates an error.

◆ getObjectStrIndex()

int glo::IndexPool::SchemaIndex::getObjectStrIndex ( ObjectStrIndex *& prRetVal,
unsigned long ulClassID,
const std::string & rsIndexName )

Returns an ObjectStrIndex of a specific class with a specific name.

Parameters
[in,out]prRetValThe ObjectStrIndex, if available.
[in]ulClassIDThe class ID.
[in]rsIndexNameThe index name. E.g., if "[MyClassName.Index.IDX_MyIndexName]" in the schema, then "IDX_MyIndexName".
Returns
A return value < 0 indicates an error.
Attention
The calling instance must NOT remove the returned object from memory. It only lives as long as this object.

◆ getObjectStrIndexIterator()

int glo::IndexPool::SchemaIndex::getObjectStrIndexIterator ( ObjectStrIndexIterator *& prObjectStrIndexIterators,
unsigned long ulClassID,
const std::string & rsIndexName ) const

Returns an iterator on a TableObjIdIndex of a certain class.

Parameters
[in,out]prObjectStrIndexIteratorsThe iterator.
[in]ulClassIDThe class ID.
[in]rsIndexNameThe index name. For example, if "[MyClassName.Index.IDX_MyIndexName]" is indexed in the schema, then "IDX_MyIndexName".
Returns
A return value < 0 indicates an error.
Attention
The calling instance must remove the returned object from memory (is a copy).

◆ getObjectStrIndexMapRef()

const std::multimap< unsigned long, IndexPool::ObjectStrIndex *, std::less< unsigned long > > & glo::IndexPool::SchemaIndex::getObjectStrIndexMapRef ( ) const

Returns a reference to m_ObjectStrIndexMap.

Returns
reference to m_ObjectStrIndexMap.

◆ getObjIdPosTuple()

int glo::IndexPool::SchemaIndex::getObjIdPosTuple ( ObjIdPosTuple *& prRetVal,
unsigned long ulClassID,
const ObjID & rObjID ) const

Returns an ObjIdPosTuple with the passed object ID.

Parameters
[in,out]prRetValIf present, a pointer to a copy of the object ID with the table position.
[in]ulClassIDThe class ID to identify the TableObjIdIndex.
[in]rObjIDThe object ID of the entry to be returned.
Returns
A return value < 0 indicates an error.
Attention
The calling instance must remove the returned object from memory.

◆ getSchemaName()

std::string glo::IndexPool::SchemaIndex::getSchemaName ( ) const

Returns the schema name.

Returns
The schema name (e.g. "MyGloBase").

◆ getTableObjIdIndex()

int glo::IndexPool::SchemaIndex::getTableObjIdIndex ( TableObjIdIndex *& prRetVal,
unsigned long ulClassID ) const

Returns a TableObjIdIndex of a certain class.

Parameters
[in,out]prRetValThe TableObjIdIndex, if available.
[in]ulClassIDThe class ID.
Returns
A return value < 0 indicates an error.
Attention
The calling instance must NOT remove the returned object from memory. It lives at most as long as this object.

◆ getTableObjIdIndexIterator()

int glo::IndexPool::SchemaIndex::getTableObjIdIndexIterator ( TableObjIdIndexIterator *& prTableIterators,
unsigned long ulClassID ) const

Returns an iterator on a TableObjIdIndex of a certain class.

Parameters
[in,out]prTableIteratorsThe iterator.
[in]ulClassIDThe class ID.
Returns
A return value < 0 indicates an error.
Attention
The calling instance must remove the returned object from memory (is a copy).

◆ getTableObjIdIndexMapRef()

const std::map< unsigned long, IndexPool::TableObjIdIndex *, std::less< unsigned long > > & glo::IndexPool::SchemaIndex::getTableObjIdIndexMapRef ( ) const

Returns a reference to m_TableObjIdIndexMap.

Returns
The reference to m_TableObjIdIndexMap.

◆ insertDeletedObjID()

int glo::IndexPool::SchemaIndex::insertDeletedObjID ( const ObjID & rDeletedObjId)

Registers the passed object ID for this database as deleted.

Parameters
[in]rDeletedObjIdThe object ID to register as deleted.
Returns
A return value < 0 indicates an error.

◆ insertFreeObjIDPos()

int glo::IndexPool::SchemaIndex::insertFreeObjIDPos ( unsigned long ulClassID,
std::streampos Pos )

Registriert eine freie Tabellen-Position in einer Tabelle.

Parameters
[in]ulClassIDDie Klassen-ID, um den TableObjIdIndex zu identifizieren.
[in]PosDie als 'frei' zu registrierende Tabellen-Position.
Returns
Ein Rückgabewert < 0 zeigt einen Fehler an.

◆ insertObjIdPosTuple()

int glo::IndexPool::SchemaIndex::insertObjIdPosTuple ( unsigned long ulClassID,
const ObjIdPosTuple & rIndexTuple )

Inserts an object ID with the table position, where the corresponding data set is stored, into the TableObjIdIndex with passed class ID.

Parameters
[in]ulClassIDThe class ID to identify the TableObjIdIndex.
[in]rIndexTupleThe object ID to be inserted with the table position.
Returns
A return value < 0 indicates an error.

◆ insertObjStrIdTuple()

int glo::IndexPool::SchemaIndex::insertObjStrIdTuple ( unsigned long ulClassID,
const std::string & rsIndexName,
const ObjStrIdTuple & rIndexTuple )

Inserts a StringIndex into an ObjectStrIndex.

Parameters
[in]ulClassIDThe class ID to identify the ObjectStrIndex.
[in]rsIndexNameThe name of the ObjectStrIndex. For example, if in the schema "[MyClassName.Index.IDX_MyIndexName]", then "IDX_MyIndexName".
[in]rIndexTupleThe StringIndex to be inserted.
Returns
A return value < 0 indicates an error.
See also
ObjectStrIndex::insertObjStrIdTuple(const ObjStrIdTuple & rIndexTuple)

◆ insertTransactionDeletedObjID()

int glo::IndexPool::SchemaIndex::insertTransactionDeletedObjID ( const ObjID & rDeletedObjId)

Registered Pass object ID for the current transaction as deleted (increments the deletion counter, see also DeletedObjIdTuple::m_iDelCounter.

Parameters
[in]rDeletedObjIdThe object ID to register as deleted.
Returns
A return value < 0 indicates an error.
See also
SchemaIndex::removeTransactionDeletedObjID(const ObjID&)

◆ isIndexFree()

int glo::IndexPool::SchemaIndex::isIndexFree ( unsigned long ulClassID,
const ObjID & rObjID,
const std::string & rsIndexName,
const std::string & rsIndex ) const

Checks if an index string is still free.

Parameters
[in]ulClassIDThe class ID to identify the ObjectStrIndex.
[in]rObjIDThe object ID to identify the item.
[in]rsIndexNameThe name of the index to be checked. For example, if in the schema "[MyClassName.Index.IDX_MyIndexName]", then "IDX_MyIndexName".
[in]rsIndexThe index to be checked.
Returns
Returns 1 if the index is still free, or 0 if it is already assigned.
A return value < 0 indicates an error.

◆ isObjIdDeleted()

bool glo::IndexPool::SchemaIndex::isObjIdDeleted ( const ObjID & rObjID) const

Checks whether an object ID is marked as deleted. Looks not only in the m_DeletedObjIdMap but also in the m_TransactionDeletedObjIdMap.

Parameters
[in]rObjIDThe object ID to be checked.
Returns
Returns true if the passed object ID is marked as deleted, otherwise false.

◆ isObjIdFree()

int glo::IndexPool::SchemaIndex::isObjIdFree ( unsigned long ulClassID,
const ObjID & rObjID ) const

Checks an object ID whether it is already managed.

Parameters
[in]ulClassIDThe class ID to identify the TableObjIdIndex.
[in]rObjIDThe object ID to be checked.
Returns
Returns 1 if rObjID is not managed, otherwise 0.
A return value < 0 indicates an error.

◆ makeObjectStrIndex()

int glo::IndexPool::SchemaIndex::makeObjectStrIndex ( const std::string & rsPathName,
unsigned long ulClassID,
const std::string & rsIndexName,
bool bUnique )

Inserts a new ObjectStrIndex into its m_ObjectStrIndexMap.

Parameters
[in]rsPathNameThe complete directory name where the tables can be found like "C:/Path/Data/".
[in]ulClassIDThe class ID of the managed indexes.
[in]rsIndexNameThe index name. E.g., if "[MyClassName.Index.IDX_MyIndexName]" in the schema, then "IDX_MyIndexName".
[in]bUniqueIf true, then this is a unique index (each entry can only exist once), otherwise several identical entries are possible.
Returns
A return value < 0 indicates an error.

◆ makeTableObjIdIndex()

int glo::IndexPool::SchemaIndex::makeTableObjIdIndex ( const std::string & rsPathName,
unsigned long ulClassID )

Inserts a new TableObjIdIndex into its m_TableObjIdIndexMap.

Parameters
[in]rsPathNameThe complete directory name where the tables are located, e.g. "C:/Path/Data/".
[in]ulClassIDThe class ID of the managed indexes.
Returns
A return value < 0 indicates an error.

◆ operator=()

IndexPool::SchemaIndex & glo::IndexPool::SchemaIndex::operator= ( const SchemaIndex & rT)

Assignment operator.

Parameters
[in]rTThe data is transferred from this object.

◆ releaseObjStrIdTuple()

int glo::IndexPool::SchemaIndex::releaseObjStrIdTuple ( unsigned long ulClassID,
const std::string & rsIndexName,
const NUM_PTR ipReservingComunicatorTrx )

Releases a StringIndex into an ObjectStrIndex if it is a unique index.

Parameters
[in]ulClassIDThe class ID to identify the ObjectStrIndex.
[in]rsIndexNameThe name of the ObjectStrIndex. For example, if in the schema "[MyClassName.Index.IDX_MyIndexName]", then "IDX_MyIndexName".
[in]ipReservingComunicatorTrxThe transaction step for which the reservation was requested.
Returns
A return < 0 indicates an error.
Exceptions
eut::ErrorNExceptionIf ulReservingComunicatorTrx == 0, an exception is thrown.
See also
SchemaIndex::reserveObjStrIdTuple (...)

◆ removeFreeObjIDPos()

int glo::IndexPool::SchemaIndex::removeFreeObjIDPos ( unsigned long ulClassID,
std::streampos Pos )

Removes a free table position from the TableObjIdIndex with corresponding to the passed class ID.

Parameters
[in]ulClassIDThe class ID to identify the TableObjIdIndex.
[in]PosThe table position to be removed.
Returns
A return value < 0 indicates an error.

◆ removeObjectStrIndex()

int glo::IndexPool::SchemaIndex::removeObjectStrIndex ( unsigned long ulClassID,
const std::string & rsIndexName )

Deletes the ObjectStrIndex with passed ClassID and the passed name, if available, from m_ObjectStrIndexMap and from memory.

Parameters
[in]ulClassIDThe class ID of the index to be removed.
[in]rsIndexNameThe name of the index to be removed. E.g., if "[MyClassName.Index.IDX_MyIndexName]" in the schema, then "IDX_MyIndexName".
Returns
A return value < 0 indicates an error.

◆ removeObjId()

int glo::IndexPool::SchemaIndex::removeObjId ( unsigned long ulClassID,
const ObjID & rObjID )

Removes the item with passed object ID from the map, which managed the stored object IDs and table position, from the TableObjIdIndex with passed class ID.

Parameters
[in]ulClassIDThe class ID to identify the TableObjIdIndex.
[in]rObjIDThe object ID to be removed.
Returns
A return value < 0 indicates an error.

◆ removeObjStrIdTuple()

int glo::IndexPool::SchemaIndex::removeObjStrIdTuple ( unsigned long ulClassID,
const std::string & rsIndexName,
const ObjID & rObjID,
NUM_PTR ipReservingComunicatorTrx = 0 )

Removes the string index from the map or MultiMap of the Indiezes of an ObjectStrIndex.

Parameters
[in]ulClassIDThe class ID to identify the ObjectStrIndex.
[in]rsIndexNameThe name of the ObjectStrIndex. For example, if in the schema "[MyClassName.Index.IDX_MyIndexName]", then "IDX_MyIndexName".
[in]rObjIDThe object ID of the index to be removed.
[in]ipReservingComunicatorTrxThe address, casted to NUM_PTR, of a Communicator in whose transaction the index was reserved, if applicable. If this is set, only a reserved index is deleted.
Returns
A return value < 0 indicates an error.

◆ removeTableObjIdIndex()

int glo::IndexPool::SchemaIndex::removeTableObjIdIndex ( unsigned long ulClassID)

Deletes the TableObjIdIndex with passed ClassID, if available from its m_TableObjIdIndexMap and from memory.

Parameters
[in]ulClassIDThe class ID of the index to be removed.
Returns
A return value < 0 indicates an error.

◆ removeTransactionDeletedObjID()

int glo::IndexPool::SchemaIndex::removeTransactionDeletedObjID ( const ObjID & rDeletedObjId)

Deregistered passed object ID for the current transaction as deleted. The deleted object ID with the highest deletion counter is searched for and removed (decrements the deletion counter, see also DeletedObjIdTuple::m_iDelCounter).

Parameters
[in]rDeletedObjIdThe object ID to be deregistered as deleted.
Returns
A return value < 0 indicates an error.
See also
SchemaIndex::insertTransactionDeletedObjID(const ObjID&)

◆ reserveObjStrIdTuple()

int glo::IndexPool::SchemaIndex::reserveObjStrIdTuple ( unsigned long ulClassID,
const std::string & rsIndexName,
const ObjStrIdTuple & rIndexTuple )

Reserves a StringIndex into an ObjectStrIndex if it is a unique index.

Parameters
[in]ulClassIDThe class ID to identify the ObjectStrIndex.
[in]rsIndexNameThe name of the ObjectStrIndex. For example, if in the schema "[MyClassName.Index.IDX_MyIndexName]", then "IDX_MyIndexName".
[in]rIndexTupleThe index to be reserved.
Returns
A return value < 0 indicates an error.
Exceptions
eut::ErrorNExceptionIf ObjStrIdTuple::m_ipReservingComunicatorTrx is not set in the parameter rIndexTuple, an exception is thrown.
See also
SchemaIndex::releaseObjStrIdTuple (...)

Member Data Documentation

◆ m_DeletedObjIdMap

std::map< ObjID, ObjID * , std::less< ObjID > > glo::IndexPool::SchemaIndex::m_DeletedObjIdMap
private

The individual object IDs of the objects that have been deleted since the last time the indexes were loaded. These object IDs must not be saved anymore.

◆ m_ObjectStrIndexMap

std::multimap< unsigned long, ObjectStrIndex * , std::less< unsigned long > > glo::IndexPool::SchemaIndex::m_ObjectStrIndexMap
private

The individual objects of type ObjectStrIndex for the classes of this schema resp. this database.
Index is the class ID.

◆ m_sSchemaName

std::string glo::IndexPool::SchemaIndex::m_sSchemaName
private

The schema name (e.g. "MyGloBase").

◆ m_TableObjIdIndexMap

std::map< unsigned long, TableObjIdIndex * , std::less< unsigned long > > glo::IndexPool::SchemaIndex::m_TableObjIdIndexMap
private

The individual objects of type TableObjIdIndex for each class of this schema resp. database.
Index is the class ID.

◆ m_TransactionDeletedObjIdMap

std::map< ObjID, DeletedObjIdTuple * , std::less< ObjID > > glo::IndexPool::SchemaIndex::m_TransactionDeletedObjIdMap
private

The individual object IDs of the objects that were deleted in a transaction. The object IDs are managed with a deletion counter.
This is necessary because deleting an object from the database multiple times does not constitute an error and if an object is deleted multiple times in a transaction and individual sub-transactions are cancelled, it must be ensured that the current deletion status is known from the deletion counter.


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