NCBI C++ ToolKit
Public Types | Public Member Functions | Private Attributes | List of all members
CWriteDB_Isam Class Reference

Search Toolkit Book for CWriteDB_Isam

CWriteDB_Isam class. More...

#include <objtools/blast/seqdb_writer/writedb_isam.hpp>

+ Inheritance diagram for CWriteDB_Isam:
+ Collaboration diagram for CWriteDB_Isam:

Public Types

typedef EWriteDBIsamType EIsamType
 Type of identifier stored in this ISAM index. More...
 
typedef vector< CRef< CSeq_id > > TIdList
 Type used for lists of sequence identifiers. More...
 
- Public Types inherited from CObject
enum  EAllocFillMode { eAllocFillNone = 1 , eAllocFillZero , eAllocFillPattern }
 Control filling of newly allocated memory. More...
 
typedef CObjectCounterLocker TLockerType
 Default locker type for CRef. More...
 
typedef atomic< Uint8TCounter
 Counter type is CAtomiCounter. More...
 
typedef Uint8 TCount
 Alias for value type of counter. More...
 

Public Member Functions

 CWriteDB_Isam (EIsamType itype, const string &dbname, bool protein, int index, Uint8 max_file_size, bool sparse)
 Constructor for an ISAM index file. More...
 
 ~CWriteDB_Isam ()
 Destructor. More...
 
void AddIds (int oid, const TIdList &ids)
 Add sequence IDs to the index file. More...
 
void AddPig (int oid, int pig)
 Set PIG for a protein sequence. More...
 
void AddHash (int oid, int hash)
 Set a sequence's hash value. More...
 
void RenameSingle ()
 Rename files to single-volume names. More...
 
void RenameFileIndex (unsigned int num_digits)
 
void Close ()
 Flush data to disk and close all associated files. More...
 
bool CanFit (int num)
 Tests whether there is room for a given number of IDs. More...
 
void ListFiles (vector< string > &files) const
 List Filenames. More...
 
- Public Member Functions inherited from CObject
 CObject (void)
 Constructor. More...
 
 CObject (const CObject &src)
 Copy constructor. More...
 
virtual ~CObject (void)
 Destructor. More...
 
CObjectoperator= (const CObject &src) THROWS_NONE
 Assignment operator. More...
 
bool CanBeDeleted (void) const THROWS_NONE
 Check if object can be deleted. More...
 
bool IsAllocatedInPool (void) const THROWS_NONE
 Check if object is allocated in memory pool (not system heap) More...
 
bool Referenced (void) const THROWS_NONE
 Check if object is referenced. More...
 
bool ReferencedOnlyOnce (void) const THROWS_NONE
 Check if object is referenced only once. More...
 
void AddReference (void) const
 Add reference to object. More...
 
void RemoveReference (void) const
 Remove reference to object. More...
 
void ReleaseReference (void) const
 Remove reference without deleting object. More...
 
virtual void DoNotDeleteThisObject (void)
 Mark this object as not allocated in heap – do not delete this object. More...
 
virtual void DoDeleteThisObject (void)
 Mark this object as allocated in heap – object can be deleted. More...
 
void * operator new (size_t size)
 Define new operator for memory allocation. More...
 
void * operator new[] (size_t size)
 Define new[] operator for 'array' memory allocation. More...
 
void operator delete (void *ptr)
 Define delete operator for memory deallocation. More...
 
void operator delete[] (void *ptr)
 Define delete[] operator for memory deallocation. More...
 
void * operator new (size_t size, void *place)
 Define new operator. More...
 
void operator delete (void *ptr, void *place)
 Define delete operator. More...
 
void * operator new (size_t size, CObjectMemoryPool *place)
 Define new operator using memory pool. More...
 
void operator delete (void *ptr, CObjectMemoryPool *place)
 Define delete operator. More...
 
virtual void DebugDump (CDebugDumpContext ddc, unsigned int depth) const
 Define method for dumping debug information. More...
 
- Public Member Functions inherited from CDebugDumpable
 CDebugDumpable (void)
 
virtual ~CDebugDumpable (void)
 
void DebugDumpText (ostream &out, const string &bundle, unsigned int depth) const
 
void DebugDumpFormat (CDebugDumpFormatter &ddf, const string &bundle, unsigned int depth) const
 
void DumpToConsole (void) const
 

Private Attributes

CRef< CWriteDB_IsamIndexm_IFile
 Index file, contains meta data and samples of the key/oid pairs. More...
 
CRef< CWriteDB_IsamDatam_DFile
 Data file, contains one record for each key/oid pair. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from CObject
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (void)
 Define method to throw null pointer exception. More...
 
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (const type_info &type)
 
static EAllocFillMode GetAllocFillMode (void)
 
static void SetAllocFillMode (EAllocFillMode mode)
 
static void SetAllocFillMode (const string &value)
 Set mode from configuration parameter value. More...
 
- Static Public Member Functions inherited from CDebugDumpable
static void EnableDebugDump (bool on)
 
- Static Public Attributes inherited from CObject
static const TCount eCounterBitsCanBeDeleted = 1 << 0
 Define possible object states. More...
 
static const TCount eCounterBitsInPlainHeap = 1 << 1
 Heap signature was found. More...
 
static const TCount eCounterBitsPlaceMask
 Mask for 'in heap' state flags. More...
 
static const int eCounterStep = 1 << 2
 Skip over the "in heap" bits. More...
 
static const TCount eCounterValid = TCount(1) << (sizeof(TCount) * 8 - 2)
 Minimal value for valid objects (reference counter is zero) Must be a single bit value. More...
 
static const TCount eCounterStateMask
 Valid object, and object in heap. More...
 
- Protected Member Functions inherited from CObject
virtual void DeleteThis (void)
 Virtual method "deleting" this object. More...
 

Detailed Description

CWriteDB_Isam class.

This manufactures isam indices.

Definition at line 401 of file writedb_isam.hpp.

Member Typedef Documentation

◆ EIsamType

Type of identifier stored in this ISAM index.

Definition at line 404 of file writedb_isam.hpp.

◆ TIdList

typedef vector< CRef<CSeq_id> > CWriteDB_Isam::TIdList

Type used for lists of sequence identifiers.

Definition at line 407 of file writedb_isam.hpp.

Constructor & Destructor Documentation

◆ CWriteDB_Isam()

CWriteDB_Isam::CWriteDB_Isam ( EIsamType  itype,
const string dbname,
bool  protein,
int  index,
Uint8  max_file_size,
bool  sparse 
)

Constructor for an ISAM index file.

Parameters
itypeType (GI, PIG, or string). [in]
dbnameDatabase name (same for all volumes). [in]
proteinTrue for protein, false for nucleotide. [in]
indexIndex of the associated volume. [in]
max_file_sizeMaximum size of any generated file in bytes. [in]
sparseSet to true if sparse mode should be used. [in]

Definition at line 98 of file writedb_isam.cpp.

References dbname(), m_DFile, m_IFile, and CRef< C, Locker >::Reset().

◆ ~CWriteDB_Isam()

CWriteDB_Isam::~CWriteDB_Isam ( )

Destructor.

Definition at line 120 of file writedb_isam.cpp.

Member Function Documentation

◆ AddHash()

void CWriteDB_Isam::AddHash ( int  oid,
int  hash 
)

Set a sequence's hash value.

The sequence hash is a hash of a sequence. This adds that hash for the purpose of building an ISAM file mapping hash values to OIDs.

Parameters
oidOID of the sequence. [in]
hashSequence hash for this sequence. [in]

Definition at line 139 of file writedb_isam.cpp.

References CWriteDB_IsamIndex::AddHash(), and m_IFile.

Referenced by CWriteDB_Volume::WriteSequence().

◆ AddIds()

void CWriteDB_Isam::AddIds ( int  oid,
const TIdList ids 
)

Add sequence IDs to the index file.

If this is a GI index, GIs are collected and added to an internal list. If this is a string index, various strings are constructed from the identifiers and added to a sorting class. How many and what kind of strings are indexed depends on whether the "sparse" flag is specified.

Parameters
oidOID of the sequence. [in]
idsList of sequence identifiers. [in]

Definition at line 129 of file writedb_isam.cpp.

References CWriteDB_IsamIndex::AddIds(), and m_IFile.

Referenced by CWriteDB_Volume::WriteSequence().

◆ AddPig()

void CWriteDB_Isam::AddPig ( int  oid,
int  pig 
)

Set PIG for a protein sequence.

The PIG identifier corresponds to a specific string of protein residues rather than to a single defline or GI, and as such is not treated as a true sequence identifier. Each PIG will be associated with one OID in a non-redundant protein database.

Parameters
oidOID of the sequence. [in]
pigPIG identifier for this sequence. [in]

Definition at line 134 of file writedb_isam.cpp.

References CWriteDB_IsamIndex::AddPig(), and m_IFile.

Referenced by CWriteDB_Volume::WriteSequence().

◆ CanFit()

bool CWriteDB_Isam::CanFit ( int  num)

Tests whether there is room for a given number of IDs.

This returns true if the specified number of identifiers can be added to this volume without overflowing the maximum file size. For strings, the estimating technique used is very rough (to avoid excess computation) and will tend to return false several disk blocks before the ISAM file actually reaches the maximum file size. This is done for performance reasons.

Parameters
numNumber of IDs that would be added. [in]
Returns
Returns true if the IDs can fit into the volume.

Definition at line 124 of file writedb_isam.cpp.

References CWriteDB_IsamIndex::CanFit(), and m_IFile.

Referenced by CWriteDB_Volume::WriteSequence().

◆ Close()

void CWriteDB_Isam::Close ( void  )

Flush data to disk and close all associated files.

Definition at line 144 of file writedb_isam.cpp.

References CWriteDB_File::Close(), m_DFile, and m_IFile.

Referenced by CWriteDB_Volume::Close().

◆ ListFiles()

void CWriteDB_Isam::ListFiles ( vector< string > &  files) const

List Filenames.

Returns a list of the files constructed by this class; the returned list may not be complete until Close() has been called. The list is not cleared; instead names are appended to existing contents.

Parameters
filesThe set of resolved database path names. [out]

Definition at line 819 of file writedb_isam.cpp.

References CWriteDB_IsamIndex::Empty(), CWriteDB_File::GetFilename(), m_DFile, and m_IFile.

Referenced by CWriteDB_Volume::ListFiles().

◆ RenameFileIndex()

void CWriteDB_Isam::RenameFileIndex ( unsigned int  num_digits)

Definition at line 160 of file writedb_isam.cpp.

References m_DFile, m_IFile, and CWriteDB_File::RenameFileIndex().

Referenced by CWriteDB_Volume::RenameFileIndex().

◆ RenameSingle()

void CWriteDB_Isam::RenameSingle ( )

Rename files to single-volume names.

When volume component files are generated by WriteDB, the names include a volume index. This method renames the files to names that do not include the volume index. This method should not be called until after Close() is called.

Definition at line 154 of file writedb_isam.cpp.

References m_DFile, m_IFile, and CWriteDB_File::RenameSingle().

Referenced by CWriteDB_Volume::RenameSingle().

Member Data Documentation

◆ m_DFile

CRef<CWriteDB_IsamData> CWriteDB_Isam::m_DFile
private

Data file, contains one record for each key/oid pair.

Definition at line 505 of file writedb_isam.hpp.

Referenced by Close(), CWriteDB_Isam(), ListFiles(), RenameFileIndex(), and RenameSingle().

◆ m_IFile

CRef<CWriteDB_IsamIndex> CWriteDB_Isam::m_IFile
private

Index file, contains meta data and samples of the key/oid pairs.

Definition at line 502 of file writedb_isam.hpp.

Referenced by AddHash(), AddIds(), AddPig(), CanFit(), Close(), CWriteDB_Isam(), ListFiles(), RenameFileIndex(), and RenameSingle().


The documentation for this class was generated from the following files:
Modified on Thu Dec 07 10:09:58 2023 by modify_doxy.py rev. 669887