NCBI C++ ToolKit
|
Search Toolkit Book for CWriteDB_File
CWriteDB_IndexFile class. More...
#include <objtools/blast/seqdb_writer/writedb_files.hpp>
Public Member Functions | |
CWriteDB_File (const string &basename, const string &extension, int index, Uint8 max_file_size, bool always_create) | |
Constructor. More... | |
void | Create () |
Create and open the file. More... | |
unsigned int | Write (const CTempString &data) |
Write contents of a string to the file. More... | |
unsigned int | Write (const char *data, int length) |
unsigned int | WriteInt4 (int data) |
Write an Int4 (in bigendian order) to the file. More... | |
unsigned int | WriteInt8 (Int8 data) |
Write an Int8 (in bigendian order) to the file. More... | |
unsigned int | WriteWithNull (const CTempString &data) |
Write contents of a string to the file, appending a NUL. More... | |
void | Close () |
Close the file, flushing any remaining data to disk. More... | |
virtual void | RenameSingle () |
Rename this file, disincluding the volume index. More... | |
virtual void | RenameFileIndex (unsigned int num_digits) |
const string & | GetFilename () const |
Get the current filename for this file. 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 |
Static Public Member Functions | |
static string | MakeShortName (const string &base, int index) |
Construct the short name for a volume. More... | |
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) |
Protected Types | |
typedef ofstream | TFile |
Underlying 'output file' type used here. More... | |
Protected Member Functions | |
Uint8 | x_DefaultByteLimit () |
The default value for max_file_size. More... | |
virtual void | x_Flush ()=0 |
This should flush any unwritten data to disk. More... | |
void | x_MakeFileName () |
Build the filename for this file. More... | |
Protected Member Functions inherited from CObject | |
virtual void | DeleteThis (void) |
Virtual method "deleting" this object. More... | |
Protected Attributes | |
bool | m_Created |
True if the file has already been opened. More... | |
string | m_Nul |
For convenience, a string containing one NUL character. More... | |
string | m_BaseName |
Database base name for all files. More... | |
string | m_Extension |
File extension for this file. More... | |
int | m_Index |
Volume index. More... | |
unsigned int | m_Offset |
Stream position. More... | |
Uint8 | m_MaxFileSize |
Maximum file size in bytes. More... | |
bool | m_UseIndex |
True if filenames should use volume index. More... | |
string | m_Fname |
Current filename for output file. More... | |
TFile | m_RealFile |
Actual stream implementing the output file. More... | |
Additional Inherited Members | |
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... | |
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... | |
CWriteDB_IndexFile class.
This manufactures blast database index files from input data.
Definition at line 57 of file writedb_files.hpp.
|
protected |
Underlying 'output file' type used here.
Definition at line 167 of file writedb_files.hpp.
CWriteDB_File::CWriteDB_File | ( | const string & | basename, |
const string & | extension, | ||
int | index, | ||
Uint8 | max_file_size, | ||
bool | always_create | ||
) |
Constructor.
The filename is constructed from basename, extension, and index, but might be changed if the RenameSingle() method is called. If zero is specified for maximum file size, a default size is provided by this class. The maximum file size is not enforced by this class, instead each derived class must do its own enforcement.
basename | Database base name, shared by all files. [in] |
extension | File name extension for this file. [in] |
index | Volume index used in filename. [in] |
max_file_size | File size limit (in bytes). [in] |
always_create | If true the file will be created now. [in] |
Definition at line 158 of file writedb_files.cpp.
References _ASSERT, Create(), m_MaxFileSize, m_Nul, m_Offset, m_UseIndex, x_DefaultByteLimit(), and x_MakeFileName().
void CWriteDB_File::Close | ( | void | ) |
Close the file, flushing any remaining data to disk.
Definition at line 259 of file writedb_files.cpp.
References m_Created, m_RealFile, and x_Flush().
Referenced by CWriteDB_GiMask::AddGiMask(), CWriteDB_Isam::Close(), CWriteDB_Column::Close(), CWriteDB_GiMask::Close(), CWriteDB_Volume::Close(), and CWriteDB_OidList::Close().
void CWriteDB_File::Create | ( | void | ) |
Create and open the file.
This method must be called before the first time that data is written to the file. If the constructor is passed 'true' for always_create, this method will be called during construction. It is an error to call this method more than once (including via the constructor) or to not call it but to call Write. The rationale for making this explicit is to permit some files to be created optionally, such as ISAM files, which should only be created if the corresponding ID types are found.
Definition at line 197 of file writedb_files.cpp.
References _ASSERT, m_Created, m_Fname, m_RealFile, and out().
Referenced by CWriteDB_GiMaskOffset::AddGIs(), CWriteDB_GiMaskIndex::AddGIs(), CWriteDB_File(), CWriteDB_ColumnData::WriteBlob(), CWriteDB_GiMaskData::WriteMask(), CWriteDB_OidList::x_CreateMaskFile(), CWriteDB_IsamIndex::x_Flush(), CWriteDB_ColumnData::x_Flush(), CWriteDB_ColumnIndex::x_Flush(), and CWriteDB_GiIndex::x_Flush().
Get the current filename for this file.
The filename is returned. The data returned by this method reflects changes made by RenameSingle(), so it is probably best to call it after that method has been called (if it will be called).
Definition at line 157 of file writedb_files.hpp.
References m_Fname.
Referenced by CWriteDB_Isam::ListFiles(), CWriteDB_GiMask::ListFiles(), CWriteDB_Volume::ListFiles(), CWriteDB_Column::ListFiles(), and CWriteDB_Volume::RenameFileIndex().
Construct the short name for a volume.
Volume names consist of the database base name, ".", and the volume index in decimal. The volume index is normally two digits, but if more than 100 volumes are needed, the filename will use three or more index digits as needed.
base | Base name to use. |
index | Volume index. |
Definition at line 235 of file writedb_files.cpp.
Referenced by CWriteDB_Volume::CWriteDB_Volume(), CMakeProfileDBApp::x_InitRPSDbInfo(), and x_MakeFileName().
|
virtual |
Definition at line 279 of file writedb_files.cpp.
References _ASSERT, CDirEntry::fRF_Overwrite, i, log10(), m_BaseName, m_Extension, m_Fname, m_Index, and CDirEntry::Rename().
Referenced by CWriteDB_Isam::RenameFileIndex(), CWriteDB_Column::RenameFileIndex(), and CWriteDB_Volume::RenameFileIndex().
|
virtual |
Rename this file, disincluding the volume index.
Definition at line 267 of file writedb_files.cpp.
References _ASSERT, CDirEntry::fRF_Overwrite, m_Fname, m_UseIndex, CDirEntry::Rename(), and x_MakeFileName().
Referenced by CWriteDB_GiMask::Close(), CWriteDB_Isam::RenameSingle(), CWriteDB_Column::RenameSingle(), and CWriteDB_Volume::RenameSingle().
Definition at line 224 of file writedb_files.cpp.
References _ASSERT, data, m_Created, m_Offset, and m_RealFile.
unsigned int CWriteDB_File::Write | ( | const CTempString & | data | ) |
Write contents of a string to the file.
data | Data to write. |
Definition at line 204 of file writedb_files.cpp.
References _ASSERT, data, m_Created, m_Offset, and m_RealFile.
Referenced by CWriteDB_GiMaskOffset::AddGIs(), CWriteDB_GiMaskIndex::AddGIs(), CWriteDB_HeaderFile::AddSequence(), CWriteDB_SequenceFile::AddSequence(), CWriteDB_ColumnData::WriteBlob(), CWriteDB_GiMaskData::WriteMask(), WriteWithNull(), CWriteDB_GiMaskIndex::x_BuildHeaderFields(), CWriteDB_OidList::x_CreateMaskFile(), CWriteDB_ColumnIndex::x_Flush(), and CWriteDB_IsamIndex::x_FlushStringIndex().
Write an Int4 (in bigendian order) to the file.
data | String to write. |
Definition at line 103 of file writedb_files.hpp.
References data, m_Offset, m_RealFile, and s_WriteInt4().
Referenced by CWriteDB_OidList::x_CreateMaskFile(), CWriteDB_GiIndex::x_Flush(), CWriteDB_IsamIndex::x_FlushNumericIndex(), CWriteDB_IsamIndex::x_FlushStringIndex(), and CWriteDB_IsamIndex::x_WriteHeader().
Write an Int8 (in bigendian order) to the file.
data | String to write. |
Definition at line 113 of file writedb_files.hpp.
References data, m_Offset, m_RealFile, and s_WriteInt8BE().
Referenced by CWriteDB_IsamIndex::x_FlushNumericIndex().
|
inline |
Write contents of a string to the file, appending a NUL.
data | String to write. |
Definition at line 123 of file writedb_files.hpp.
References data, m_Nul, and Write().
Referenced by CWriteDB_SequenceFile::AddSequence(), and CWriteDB_SequenceFile::CWriteDB_SequenceFile().
|
inlineprotected |
The default value for max_file_size.
Definition at line 174 of file writedb_files.hpp.
Referenced by CWriteDB_File().
|
protectedpure virtual |
This should flush any unwritten data to disk.
This method must be implemented by derived classes to flush any unwritten data to disk. In the cases of sequence and header files, it will normally do nothing, because such files are written as the data is available. For index (pin/nin) and ISAM files, this method does most of the disk I/O.
Implemented in CWriteDB_OidList, CWriteDB_GiIndex, CWriteDB_GiMaskOffset, CWriteDB_GiMaskData, CWriteDB_ColumnIndex, CWriteDB_ColumnData, CWriteDB_FileAutoFlush, CWriteDB_IsamData, CWriteDB_IsamIndex, CWriteDB_SequenceFile, CWriteDB_HeaderFile, and CWriteDB_IndexFile.
Referenced by Close().
|
protected |
Build the filename for this file.
Definition at line 247 of file writedb_files.cpp.
References m_BaseName, m_Extension, m_Fname, m_Index, m_UseIndex, and MakeShortName().
Referenced by CWriteDB_File(), and RenameSingle().
|
protected |
Database base name for all files.
Definition at line 194 of file writedb_files.hpp.
Referenced by RenameFileIndex(), x_MakeFileName(), and CWriteDB_IndexFile::x_MakeLmdbName().
|
protected |
True if the file has already been opened.
Definition at line 164 of file writedb_files.hpp.
Referenced by CWriteDB_GiMaskOffset::AddGIs(), CWriteDB_GiMaskIndex::AddGIs(), Close(), Create(), CWriteDB_IsamIndex::Empty(), Write(), CWriteDB_ColumnData::WriteBlob(), CWriteDB_GiMaskData::WriteMask(), CWriteDB_IndexFile::x_Flush(), CWriteDB_ColumnData::x_Flush(), and CWriteDB_ColumnIndex::x_Flush().
|
protected |
File extension for this file.
Definition at line 195 of file writedb_files.hpp.
Referenced by RenameFileIndex(), and x_MakeFileName().
|
protected |
Current filename for output file.
Definition at line 203 of file writedb_files.hpp.
Referenced by Create(), GetFilename(), RenameFileIndex(), RenameSingle(), and x_MakeFileName().
|
protected |
Volume index.
Definition at line 196 of file writedb_files.hpp.
Referenced by RenameFileIndex(), CWriteDB_IndexFile::x_Flush(), and x_MakeFileName().
|
protected |
Maximum file size in bytes.
Definition at line 198 of file writedb_files.hpp.
Referenced by CWriteDB_IndexFile::CanFit(), CWriteDB_ColumnIndex::CanFit(), CWriteDB_IsamIndex::CanFit(), CWriteDB_GiMaskData::CanFit(), CWriteDB_HeaderFile::CanFit(), CWriteDB_ColumnData::CanFit(), CWriteDB_SequenceFile::CanFit(), and CWriteDB_File().
|
protected |
For convenience, a string containing one NUL character.
Definition at line 170 of file writedb_files.hpp.
Referenced by CWriteDB_File(), WriteWithNull(), and CWriteDB_IndexFile::x_Flush().
|
protected |
Stream position.
Definition at line 197 of file writedb_files.hpp.
Referenced by CWriteDB_SequenceFile::CanFit(), CWriteDB_File(), Write(), WriteInt4(), and WriteInt8().
|
protected |
Actual stream implementing the output file.
Definition at line 204 of file writedb_files.hpp.
Referenced by Close(), Create(), Write(), WriteInt4(), WriteInt8(), and CWriteDB_IndexFile::x_Flush().
|
protected |
True if filenames should use volume index.
Definition at line 202 of file writedb_files.hpp.
Referenced by CWriteDB_File(), RenameSingle(), and x_MakeFileName().