NCBI C++ ToolKit
|
Search Toolkit Book for CSeqDBRawFile
Raw file. More...
#include <objtools/blast/seqdb_reader/impl/seqdbfile.hpp>
Public Types | |
typedef CSeqDBAtlas::TIndx | TIndx |
Type which spans possible file offsets. More... | |
Public Member Functions | |
CSeqDBRawFile (CSeqDBAtlas &atlas) | |
Constructor. More... | |
bool | Open (const CSeqDB_Path &name) |
MMap or Open a file. More... | |
const char * | GetFileDataPtr (CSeqDBFileMemMap &lease, TIndx start, TIndx end) const |
Get a pointer to a section of the file. More... | |
TIndx | GetFileLength () const |
Get the length of the file. More... | |
TIndx | ReadSwapped (CSeqDBFileMemMap &lease, TIndx offset, Uint4 *value) const |
Read a four byte numerical object from the file. More... | |
TIndx | ReadSwapped (CSeqDBFileMemMap &lease, TIndx offset, Uint8 *value) const |
Read an eight byte numerical object from the file. More... | |
TIndx | ReadSwapped (CSeqDBFileMemMap &lease, TIndx offset, string *value) const |
Read a string object from the file. More... | |
void | ReadBytes (CSeqDBFileMemMap &lease, char *buf, TIndx start, TIndx end) const |
Read part of the file into a buffer. More... | |
Private Attributes | |
CSeqDBAtlas & | m_Atlas |
The memory management layer object. More... | |
string | m_FileName |
The name of this file. More... | |
TIndx | m_Length |
The length of this file. More... | |
Raw file.
This is the lowest level of SeqDB file object. It controls basic (byte data) access to the file, isolating higher levels from differences in handling mmapped vs opened files. This has mostly become a thin wrapper around the Atlas functionality.
Definition at line 64 of file seqdbfile.hpp.
Type which spans possible file offsets.
Definition at line 67 of file seqdbfile.hpp.
|
inline |
Constructor.
Builds a "raw" file object, which is the lowest level of the SeqDB file objects. It provides byte swapping and reading methods, which are implemented via the atlas layer.
atlas | The memory management layer object. |
Definition at line 77 of file seqdbfile.hpp.
|
inline |
Get a pointer to a section of the file.
This method insures that the memory lease has a hold that includes the requested section of the file, and returns a pointer to the start offset.
lease | The memory lease object for this file. |
start | The starting offset for the first byte of the region. |
end | The offset for the first byte after the region. |
locked | The lock holder object for this thread. |
Definition at line 123 of file seqdbfile.hpp.
References _ASSERT, CSeqDBFileMemMap::GetFileDataPtr(), m_FileName, m_Length, and SEQDB_FILE_ASSERT.
Referenced by CSeqDBGiMask::GetMaskData(), CSeqDBOIDList::x_GetOidMask(), and CSeqDBGiMask::x_ReadFields().
|
inline |
Get the length of the file.
The file length is returned as a four byte integer, which is the current maximum size for the blastdb component files.
Definition at line 143 of file seqdbfile.hpp.
References m_Length.
Referenced by CSeqDBOIDList::x_GetOidMask(), CSeqDBColumn::x_ReadFields(), and CSeqDBGiMask::x_ReadFields().
|
inline |
MMap or Open a file.
This serves to verify the existence of, open, and cache the length of a file.
name | The filename to open. |
locked | The lock holder object for this thread. |
Definition at line 93 of file seqdbfile.hpp.
References _ASSERT, CSeqDBAtlas::GetFileSizeL(), CSeqDB_Path::GetPathS(), m_Atlas, m_FileName, m_Length, and CSeqDB_Path::Valid().
Referenced by CSeqDBColumn::CSeqDBColumn(), CSeqDBExtFile::CSeqDBExtFile(), CSeqDBOIDList::x_GetOidMask(), and CSeqDBGiMask::x_Open().
|
inline |
Read part of the file into a buffer.
Copy the file data from offsets start to end into the array at buf, which is assumed to already have been allocated. This method assumes the atlas lock is held.
lease | A memory lease object to use for the read. |
buf | The destination for the data to be read. |
start | The starting offset for the first byte to read. |
end | The offset for the first byte after the area to read. |
Definition at line 922 of file seqdbfile.hpp.
References buf, CSeqDBFileMemMap::GetFileDataPtr(), and m_FileName.
Referenced by CSeqDBExtFile::x_ReadBytes().
TIndx CSeqDBRawFile::ReadSwapped | ( | CSeqDBFileMemMap & | lease, |
TIndx | offset, | ||
string * | value | ||
) | const |
Read a string object from the file.
Given a pointer to a string object, this reads a string value for it from the file. The data in the file is assumed to be a four byte length in network byte order, followed by the bytes of the string. The amount of data is this length + 4.
lease | A memory lease object to use for the read. |
offset | The starting offset of the string length in the file. |
value | A pointer to the returned string. |
locked | The lock holder object for this thread. |
Definition at line 91 of file seqdbfile.cpp.
References CSeqDBFileMemMap::GetFileDataPtr(), int, len, m_FileName, offset, SeqDB_GetStdOrd(), and rapidjson::value.
TIndx CSeqDBRawFile::ReadSwapped | ( | CSeqDBFileMemMap & | lease, |
TIndx | offset, | ||
Uint4 * | value | ||
) | const |
Read a four byte numerical object from the file.
Given a pointer to an object in memory, this reads a numerical value for it from the file. The data in the file is assumed to be in network byte order, and the user version in the local default byte order (host order). The size of the object is taken as sizeof(Uint4).
lease | A memory lease object to use for the read. |
offset | The starting offset of the value in the file. |
value | A pointer to the object. |
The | lock holder object for this thread. |
Definition at line 71 of file seqdbfile.cpp.
References CSeqDBFileMemMap::GetFileDataPtr(), m_FileName, offset, SeqDB_GetStdOrd(), and rapidjson::value.
Referenced by CSeqDBOIDList::x_GetOidMask(), and CSeqDBExtFile::x_ReadSwapped().
TIndx CSeqDBRawFile::ReadSwapped | ( | CSeqDBFileMemMap & | lease, |
TIndx | offset, | ||
Uint8 * | value | ||
) | const |
Read an eight byte numerical object from the file.
Given a pointer to an object in memory, this reads a numerical value for it from the file. The data in the file is assumed to be in network byte order, and the user version in the local default byte order (host order). The size of the object is taken as sizeof(Uint8).
lease | A memory lease object to use for the read. |
offset | The starting offset of the value in the file. |
value | A pointer to the object. |
locked | The lock holder object for this thread. |
Definition at line 81 of file seqdbfile.cpp.
References CSeqDBFileMemMap::GetFileDataPtr(), m_FileName, offset, SeqDB_GetBroken(), and rapidjson::value.
|
private |
The memory management layer object.
Definition at line 237 of file seqdbfile.hpp.
Referenced by Open().
|
private |
The name of this file.
Definition at line 240 of file seqdbfile.hpp.
Referenced by GetFileDataPtr(), Open(), ReadBytes(), and ReadSwapped().
|
private |
The length of this file.
Definition at line 243 of file seqdbfile.hpp.
Referenced by GetFileDataPtr(), GetFileLength(), and Open().