NCBI C++ ToolKit
|
Search Toolkit Book for CWriteDB_Column
CWriteDB_Column class. More...
#include "writedb_column.hpp"
(Private to src/objtools/blast/seqdb_writer
.)
Public Types | |
typedef map< string, string > | TColumnMeta |
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< Uint8 > | TCounter |
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... | |
CObject & | operator= (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_ColumnIndex > | m_IFile |
Index file, contains meta data and samples of the key/oid pairs. More... | |
CRef< CWriteDB_ColumnData > | m_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_ColumnData > | m_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... | |
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.
typedef map<string, string> CWriteDB_Column::TColumnMeta |
Type used for database column meta-data.
Definition at line 227 of file writedb_column.hpp.
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.
dbname | Base of filename. |
extn1 | Extension used for index file. |
extn2 | Extension used for data file in big endian. |
index | Volume index. |
title | Title of this column. |
meta | User-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 | ( | ) |
Destructor.
Definition at line 80 of file writedb_column.cpp.
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.
blob | The 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().
void CWriteDB_Column::AddBlob | ( | const CBlastDbBlob & | blob, |
const CBlastDbBlob & | blob2 | ||
) |
Definition at line 103 of file writedb_column.cpp.
References AddBlob(), m_DFile2, m_UseBothByteOrder, and CWriteDB_ColumnData::WriteBlob().
void CWriteDB_Column::AddByteOrder | ( | const string & | dbname, |
const string & | extn, | ||
int | index, | ||
Uint8 | max_file_size | ||
) |
Add support for multiple byte order.
dbname | Base of filename. |
extn | Extension used for index file. |
index | Volume index. |
Definition at line 68 of file writedb_column.cpp.
References dbname(), m_DFile2, m_UseBothByteOrder, and CRef< C, Locker >::Reset().
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.
key | Key string. |
value | Value 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().
Tests whether there is room for a given blob.
bytes | Size of the blob that would be added. |
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.
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().
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.
files | The 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().
void CWriteDB_Column::RenameFileIndex | ( | unsigned int | num_digits | ) |
Definition at line 128 of file writedb_column.cpp.
References m_DFile, m_DFile2, m_IFile, m_UseBothByteOrder, and CWriteDB_File::RenameFileIndex().
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().
|
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().
|
private |
Definition at line 317 of file writedb_column.hpp.
Referenced by AddBlob(), AddByteOrder(), Close(), ListFiles(), RenameFileIndex(), and RenameSingle().
|
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().
|
private |
Support for multiple byte order.
Definition at line 316 of file writedb_column.hpp.
Referenced by AddBlob(), AddByteOrder(), Close(), ListFiles(), RenameFileIndex(), and RenameSingle().