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

Search Toolkit Book for CWriteDB_Column

CWriteDB_Column class. More...

#include "writedb_column.hpp"
(Private to src/objtools/blast/seqdb_writer.)

+ Inheritance diagram for CWriteDB_Column:
+ Collaboration diagram for CWriteDB_Column:

Public Types

typedef map< string, stringTColumnMeta
 Type used for database column meta-data. 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_Column (const string &dbname, const string &extn1, const string &extn2, int index, const string &title, const TColumnMeta &meta, Uint8 max_file_size)
 Construct WriteDB style database column. More...
 
void AddByteOrder (const string &dbname, const string &extn, int index, Uint8 max_file_size)
 Add support for multiple byte order. More...
 
 ~CWriteDB_Column ()
 Destructor. 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 bytes) const
 Tests whether there is room for a given blob. More...
 
void ListFiles (vector< string > &files, bool skip_empty) const
 List Filenames. More...
 
void AddBlob (const CBlastDbBlob &blob)
 Add a blob to the column. More...
 
void AddBlob (const CBlastDbBlob &blob, const CBlastDbBlob &blob2)
 
void AddMetaData (const string &key, const string &value)
 Add meta data to the column. 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_ColumnIndexm_IFile
 Index file, contains meta data and samples of the key/oid pairs. More...
 
CRef< CWriteDB_ColumnDatam_DFile
 Data file, contains one record for each key/oid pair, in big and small endian. More...
 
bool m_UseBothByteOrder
 Support for multiple byte order. More...
 
CRef< CWriteDB_ColumnDatam_DFile2
 

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_Column class.

This manages construction of a WriteDB column, which maps OIDs to blob data.

Definition at line 224 of file writedb_column.hpp.

Member Typedef Documentation

◆ TColumnMeta

Type used for database column meta-data.

Definition at line 227 of file writedb_column.hpp.

Constructor & Destructor Documentation

◆ CWriteDB_Column()

CWriteDB_Column::CWriteDB_Column ( const string dbname,
const string extn1,
const string extn2,
int  index,
const string title,
const TColumnMeta meta,
Uint8  max_file_size 
)

Construct WriteDB style database column.

Parameters
dbnameBase of filename.
extn1Extension used for index file.
extn2Extension used for data file in big endian.
indexVolume index.
titleTitle of this column.
metaUser-defined meta data for this file.

Definition at line 45 of file writedb_column.cpp.

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

◆ ~CWriteDB_Column()

CWriteDB_Column::~CWriteDB_Column ( )

Destructor.

Definition at line 80 of file writedb_column.cpp.

Member Function Documentation

◆ AddBlob() [1/2]

void CWriteDB_Column::AddBlob ( const CBlastDbBlob blob)

Add a blob to the column.

The data described by `blob' is added to the column. If the blob is empty, no data is stored but the OID is incremented.

Parameters
blobThe blob to add to the column.

Definition at line 93 of file writedb_column.cpp.

References m_DFile, m_IFile, CWriteDB_ColumnData::WriteBlob(), and CWriteDB_ColumnIndex::WriteBlobIndex().

Referenced by CWriteDB_ColumnBuilder::AddBlob(), and AddBlob().

◆ AddBlob() [2/2]

void CWriteDB_Column::AddBlob ( const CBlastDbBlob blob,
const CBlastDbBlob blob2 
)

◆ AddByteOrder()

void CWriteDB_Column::AddByteOrder ( const string dbname,
const string extn,
int  index,
Uint8  max_file_size 
)

Add support for multiple byte order.

Parameters
dbnameBase of filename.
extnExtension used for index file.
indexVolume index.

Definition at line 68 of file writedb_column.cpp.

References dbname(), m_DFile2, m_UseBothByteOrder, and CRef< C, Locker >::Reset().

◆ AddMetaData()

void CWriteDB_Column::AddMetaData ( const string key,
const string value 
)

Add meta data to the column.

In addition to normal blob data, database columns can store a `dictionary' of user-defined metadata in key/value form. This method adds one such key/value pair to the column. Specifying a key a second time causes replacement of the previous value. Using this mechanism to store large amounts of data may have a negative impact on performance.

Parameters
keyKey string.
valueValue string.

Definition at line 135 of file writedb_column.cpp.

References CWriteDB_ColumnIndex::AddMetaData(), ncbi::grid::netcache::search::fields::key, m_IFile, and rapidjson::value.

Referenced by CWriteDB_ColumnBuilder::AddMetaData().

◆ CanFit()

bool CWriteDB_Column::CanFit ( int  bytes) const

Tests whether there is room for a given blob.

Parameters
bytesSize of the blob that would be added.
Returns
Returns true if the IDs can fit into the volume.

Definition at line 116 of file writedb_column.cpp.

References CWriteDB_ColumnIndex::CanFit(), CWriteDB_ColumnData::CanFit(), m_DFile, m_IFile, and ncbi::grid::netcache::search::fields::size.

◆ Close()

void CWriteDB_Column::Close ( void  )

Flush data to disk and close all associated files.

Definition at line 109 of file writedb_column.cpp.

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

Referenced by CWriteDB_ColumnBuilder::Close().

◆ ListFiles()

void CWriteDB_Column::ListFiles ( vector< string > &  files,
bool  skip_empty 
) 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.

Definition at line 84 of file writedb_column.cpp.

References CWriteDB_ColumnData::Empty(), CWriteDB_File::GetFilename(), m_DFile, m_DFile2, m_IFile, and m_UseBothByteOrder.

Referenced by CWriteDB_ColumnBuilder::ListFiles().

◆ RenameFileIndex()

void CWriteDB_Column::RenameFileIndex ( unsigned int  num_digits)

◆ RenameSingle()

void CWriteDB_Column::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 121 of file writedb_column.cpp.

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

Referenced by CWriteDB_ColumnBuilder::Close().

Member Data Documentation

◆ m_DFile

CRef<CWriteDB_ColumnData> CWriteDB_Column::m_DFile
private

Data file, contains one record for each key/oid pair, in big and small endian.

Definition at line 313 of file writedb_column.hpp.

Referenced by AddBlob(), CanFit(), Close(), CWriteDB_Column(), ListFiles(), RenameFileIndex(), and RenameSingle().

◆ m_DFile2

CRef<CWriteDB_ColumnData> CWriteDB_Column::m_DFile2
private

◆ m_IFile

CRef<CWriteDB_ColumnIndex> CWriteDB_Column::m_IFile
private

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

Definition at line 310 of file writedb_column.hpp.

Referenced by AddBlob(), AddMetaData(), CanFit(), Close(), CWriteDB_Column(), ListFiles(), RenameFileIndex(), and RenameSingle().

◆ m_UseBothByteOrder

bool CWriteDB_Column::m_UseBothByteOrder
private

Support for multiple byte order.

Definition at line 316 of file writedb_column.hpp.

Referenced by AddBlob(), AddByteOrder(), Close(), ListFiles(), RenameFileIndex(), and RenameSingle().


The documentation for this class was generated from the following files:
Modified on Fri Sep 20 14:58:26 2024 by modify_doxy.py rev. 669887