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

Manages the individual string indices of a class. If this is a unique index, the ObjStrIdTuple are in a map, otherwise in a MultiMap. Then indexes in a MultiMap can be inserted as reserved, this is taken into account when inserting further. More...

#include <GloIndexPool.h>

Public Member Functions

 ObjectStrIndex (const ObjectStrIndex &rT)
 
 ObjectStrIndex (const std::string &rsPathName, unsigned long ulClassID, const std::string &rsIndexName, bool bUnique)
 
virtual ~ObjectStrIndex ()
 
void deleteAllIndexValues ()
 
unsigned long getClassID () const
 
const std::string & getIndexName () const
 
const std::multimap< std::string, IndexPool::ObjStrIdTuple *, std::less< std::string > > & getNonUniqueIndexMapRef () const
 
const std::map< ObjID, IndexPool::ObjStrIdTuple *, std::less< ObjID > > & getObjIdIndexMapRef () const
 
const std::string & getPathName () const
 
const std::map< std::string, IndexPool::ObjStrIdTuple *, std::less< std::string > > & getUniqueIndexMapRef () const
 
int insertObjStrIdTuple (const ObjStrIdTuple &rIndexTuple)
 
bool isIndexFree (const std::string &rsIndex, const ObjID &rObjID) const
 
bool isObjIdAlreadyAvailable (const ObjID &rObjID) const
 
bool isUnique () const
 
IndexPool::ObjectStrIndexoperator= (const ObjectStrIndex &rT)
 
void releaseObjStrIdTuple (const NUM_PTR ipReservingComunicatorTrx)
 
int removeObjStrIdTuple (const ObjID &rObjID, NUM_PTR ipReservingComunicatorTrx=0)
 
void reserveObjStrIdTuple (const ObjStrIdTuple &rIndexTuple)
 

Protected Member Functions

 ObjectStrIndex ()
 
void copyMapsFrom (const ObjectStrIndex &rT)
 
IndexPool::ObjStrIdTuplegetObjStrIdTuple (const ObjID &rObjID)
 
IndexPool::ObjStrIdTuplegetObjStrIdTuple (EnSeekMode eMode)
 
int removeObjStrIdTuple (const ObjID &rObjID, bool bDelete, NUM_PTR ipReservingComunicatorTrx=0)
 

Private Attributes

bool m_bUnique
 
std::multimap< std::string, ObjStrIdTuple *, std::less< std::string > > m_NonUniqueIndexMultiMap
 
std::multimap< std::string, ObjStrIdTuple * >::iterator m_NonUniqueIndexMultiMapIterator
 
std::map< ObjID, ObjStrIdTuple *, std::less< ObjID > > m_ObjIdIndexMap
 
std::multimap< std::string, ObjStrIdTuple *, std::less< std::string > > m_ReservedIndexMultiMap
 
std::string m_sIndexName
 
std::string m_strPathName
 
unsigned long m_ulClassID
 
std::map< std::string, ObjStrIdTuple *, std::less< std::string > > m_UniqueIndexMap
 
std::map< std::string, ObjStrIdTuple * >::iterator m_UniqueIndexMapIterator
 

Friends

class RealIndexPool
 

Detailed Description

Manages the individual string indices of a class. If this is a unique index, the ObjStrIdTuple are in a map, otherwise in a MultiMap. Then indexes in a MultiMap can be inserted as reserved, this is taken into account when inserting further.

Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ ObjectStrIndex() [1/3]

glo::IndexPool::ObjectStrIndex::ObjectStrIndex ( )
protected

The default constructor is not available.

◆ ObjectStrIndex() [2/3]

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

Constructor with parameter passing.

Parameters
[in]rsPathNameThe complete directory name where the tables can be found such as "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.

◆ ObjectStrIndex() [3/3]

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

Copy constructor.

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

◆ ~ObjectStrIndex()

virtual glo::IndexPool::ObjectStrIndex::~ObjectStrIndex ( )
virtual

Destructor.

Member Function Documentation

◆ copyMapsFrom()

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

Removes all elements from the maps. Then all elements of the same maps of the passed Object-StringIndex are copied.

Parameters
[in]rTThe Object StringIndex whose elements are to be copied from the maps.
Exceptions
eut::ErrorNExceptionAn exception is thrown if an error occurs.

◆ deleteAllIndexValues()

void glo::IndexPool::ObjectStrIndex::deleteAllIndexValues ( )

Empties all maps; i.e. m_UniqueIndexMap with m_ReservedIndexMultiMap or m_NonUniqueIndexMultiMap and m_ObjIdIndexMap. The ObjStrIdTuple are removed from memory and the iterators are set to the beginning.

◆ getClassID()

unsigned long glo::IndexPool::ObjectStrIndex::getClassID ( ) const

Returns the class ID of the managed object StringIndex.

Returns
The class ID.

◆ getIndexName()

const std::string & glo::IndexPool::ObjectStrIndex::getIndexName ( ) const

Returns the index name. For example, if in the schema "[MyClassName.Index.IDX_MyIndexName]", then "IDX_MyIndexName".

Returns
The index name.

◆ getNonUniqueIndexMapRef()

const std::multimap< std::string, IndexPool::ObjStrIdTuple *, std::less< std::string > > & glo::IndexPool::ObjectStrIndex::getNonUniqueIndexMapRef ( ) const

Returns a reference to m_NonUniqueIndexMultiMap.

Returns
m_NonUniqueIndexMultiMap

◆ getObjIdIndexMapRef()

const std::map< ObjID, IndexPool::ObjStrIdTuple *, std::less< ObjID > > & glo::IndexPool::ObjectStrIndex::getObjIdIndexMapRef ( ) const

Returns a reference to m_ObjIdIndexMap.

Returns
m_ObjIdIndexMap

◆ getObjStrIdTuple() [1/2]

IndexPool::ObjStrIdTuple * glo::IndexPool::ObjectStrIndex::getObjStrIdTuple ( const ObjID & rObjID)
protected

Returns a pointer to an ObjStrIdTuple from m_UniqueIndexMap with the passed object ID.

Parameters
[in]rObjIDThe object ID.
Returns
The object found, if any.
Attention
The calling instance must not modify or remove the returned object from memory. It only lives as long as this object.

◆ getObjStrIdTuple() [2/2]

IndexPool::ObjStrIdTuple * glo::IndexPool::ObjectStrIndex::getObjStrIdTuple ( EnSeekMode eMode)
protected

Returns a pointer to an ObjStrIdTuple depending on m_bUnique from m_UniqueIndexMap or m_NonUniqueIndexMultiMap in relation to eMode

Parameters
[in]eModeThe seek mode.

Parameter examples:

Returns
The objects found, if any.
Attention
The calling instance must NOT change or remove the delivered object from memory. It only lives as long as this object.

◆ getPathName()

const std::string & glo::IndexPool::ObjectStrIndex::getPathName ( ) const

Returns the complete directory name in which the tables can be found.

Returns
The complete directory name such as "C:/Path/Data/".

◆ getUniqueIndexMapRef()

const std::map< std::string, IndexPool::ObjStrIdTuple *, std::less< std::string > > & glo::IndexPool::ObjectStrIndex::getUniqueIndexMapRef ( ) const

Returns a reference to m_UniqueIndexMap.

Returns
m_UniqueIndexMap

◆ insertObjStrIdTuple()

int glo::IndexPool::ObjectStrIndex::insertObjStrIdTuple ( const ObjStrIdTuple & rIndexTuple)

Inserts a string index depending on m_bUnique in m_UniqueIndexMap or m_NonUniqueIndexMultiMap.

Parameters
[in]rIndexTupleThe index to insert.
Returns
A return value < 0 indicates an error.
If m_bUnique and no index with object ID already in m_UniqueIndexMap, but the index as string is already present, then error == ERR_INDEX_ALREADY_EXISTING

◆ isIndexFree()

bool glo::IndexPool::ObjectStrIndex::isIndexFree ( const std::string & rsIndex,
const ObjID & rObjID ) const

Checks if a string index for an object is still free. Only makes sense if m_bUnique is set to true.

Parameters
[in]rsIndexThe index to check.
[in]rObjIDThe object ID to be checked.
Returns
Returns true (always when m_bUnique == false) or false if rsIndex is already assigned.

◆ isObjIdAlreadyAvailable()

bool glo::IndexPool::ObjectStrIndex::isObjIdAlreadyAvailable ( const ObjID & rObjID) const

Checks if an index with the object ID is included in m_ObjIdIndexMap.

Parameters
[in]rObjIDThe object ID to be checked.
Returns
Returns true if an index with the object ID is contained in m_ObjIdIndexMap.

◆ isUnique()

bool glo::IndexPool::ObjectStrIndex::isUnique ( ) const

Returns whether this is a unique index or not.

Returns
If true, then this is a unique index (each entry can only exist once), otherwise several identical entries are possible.

◆ operator=()

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

Assignment operator.

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

◆ releaseObjStrIdTuple()

void glo::IndexPool::ObjectStrIndex::releaseObjStrIdTuple ( const NUM_PTR ipReservingComunicatorTrx)

If m_bUnique == true, any string index is removed from the m_ReservedIndexMultiMap whose ObjStrIdTuple::m_ipReservingComunicatorTrx is equal to the passed parameter.

Parameters
[in]ipReservingComunicatorTrxThe transaction step for which the reservation(s) was requested.
Exceptions
eut::ErrorNExceptionIf ulReservingComunicatorTrx == 0, an exception is thrown.
See also
ObjectStrIndex::reserveObjStrIdTuple (...)

◆ removeObjStrIdTuple() [1/2]

int glo::IndexPool::ObjectStrIndex::removeObjStrIdTuple ( const ObjID & rObjID,
bool bDelete,
NUM_PTR ipReservingComunicatorTrx = 0 )
protected

Removes or deletes a string index depending on m_bUnique from m_UniqueIndexMap or m_NonUniqueIndexMultiMap and possibly in m_ObjIdIndexMap.

Parameters
[in]rObjIDThe ObjId of the string index to remove.
[in]bDeleteIf true, the string index is removed from all maps and from memory. If false, the index is removed from m_UniqueIndexMap or m_NonUniqueIndexMultiMap depending on m_bUnique.
[in]ipReservingComunicatorTrxThe address of a Communicator, casted to NUM_PTR, in whose transaction the index may have been reserved. If this is set, only a reserved index is deleted.
Returns
A return value < 0 indicates an error.

◆ removeObjStrIdTuple() [2/2]

int glo::IndexPool::ObjectStrIndex::removeObjStrIdTuple ( const ObjID & rObjID,
NUM_PTR ipReservingComunicatorTrx = 0 )

Removes a string index depending on m_bUnique from m_UniqueIndexMap or m_NonUniqueIndexMultiMap.

Parameters
[in]rObjIDThe ObjId of the index to remove.
[in]ipReservingComunicatorTrxThe address of a Communicator casted to NUM_PTR 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.

◆ reserveObjStrIdTuple()

void glo::IndexPool::ObjectStrIndex::reserveObjStrIdTuple ( const ObjStrIdTuple & rIndexTuple)

If m_bUnique == true, the string index is appended to the m_ReservedIndexMultiMap and thus reserved.

Parameters
[in]rIndexTupleThe index to reserve.
Exceptions
eut::ErrorNExceptionIf ObjStrIdTuple::m_ipReservingComunicatorTrx is not set in parameter rIndexTuple, an exception is thrown.
See also
ObjectStrIndex::releaseObjStrIdTuple (...)

Friends And Related Symbol Documentation

◆ RealIndexPool

friend class RealIndexPool
friend

Member Data Documentation

◆ m_bUnique

bool glo::IndexPool::ObjectStrIndex::m_bUnique
private

If true, it is a unique index (each entry can only exist once), otherwise several identical entries are possible.

◆ m_NonUniqueIndexMultiMap

std::multimap< std::string, ObjStrIdTuple * , std::less< std::string > > glo::IndexPool::ObjectStrIndex::m_NonUniqueIndexMultiMap
private

If m_bUnique == false, this map is used.

◆ m_NonUniqueIndexMultiMapIterator

std::multimap<std::string,ObjStrIdTuple*>::iterator glo::IndexPool::ObjectStrIndex::m_NonUniqueIndexMultiMapIterator
private

An internal iterator for m_NonUniqueIndexMultiMap.

◆ m_ObjIdIndexMap

std::map< ObjID, ObjStrIdTuple * , std::less< ObjID > > glo::IndexPool::ObjectStrIndex::m_ObjIdIndexMap
private

Hier sind alle ObjStrIdTuple sortiert nach ObjId, wird gebraucht, um ein ObjStrIdTuple nach ObjId schnell zu finden.

◆ m_ReservedIndexMultiMap

std::multimap< std::string, ObjStrIdTuple * , std::less< std::string > > glo::IndexPool::ObjectStrIndex::m_ReservedIndexMultiMap
private

Unique indexes can be reserved e.g. in transactions that are inserted here.
This is e.g. necessary if an indexed object in a transaction with a unique index is "1" to store in a TransactionManager::TransactionStep.
If the same object in the transaction is stored again, with the unique index "2" for storage in a TransactionManager::TransactionStep, this one will be stored as reserved as well.
These reserved indices are only removed with a commit or abort and transferred to the m_UniqueIndexMap with a commit.

◆ m_sIndexName

std::string glo::IndexPool::ObjectStrIndex::m_sIndexName
private

The index name. For example, if in the schema "[MyClassName.Index.IDX_MyIndexName]", then "IDX_MyIndexName".

◆ m_strPathName

std::string glo::IndexPool::ObjectStrIndex::m_strPathName
private

The complete directory name where the tables can be found such as "C:/Path/Data/".

◆ m_ulClassID

unsigned long glo::IndexPool::ObjectStrIndex::m_ulClassID
private

The class ID of the managed object string index, is only valid for one class (not for tables).

◆ m_UniqueIndexMap

std::map< std::string, ObjStrIdTuple * , std::less< std::string > > glo::IndexPool::ObjectStrIndex::m_UniqueIndexMap
private

If m_bUnique == true, this map is used.

◆ m_UniqueIndexMapIterator

std::map<std::string,ObjStrIdTuple*>::iterator glo::IndexPool::ObjectStrIndex::m_UniqueIndexMapIterator
private

An internal iterator for m_UniqueIndexMap.


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