41 #if ((!defined(NCBI_COMPILER_WORKSHOP) || (NCBI_COMPILER_VERSION > 550)) && \
42 (!defined(NCBI_COMPILER_MIPSPRO)) )
51 string index_extn =
"x_a";
52 index_extn[1] = file_id;
54 string data_extn = index_extn;
103 const string & index_extn,
104 const string & data_extn,
106 : m_AtlasHolder (lockedp,
true),
107 m_Atlas (m_AtlasHolder.
Get()),
108 m_IndexFile (m_Atlas),
109 m_DataFile (m_Atlas),
110 m_IndexLease (m_Atlas),
111 m_DataLease (m_Atlas),
115 m_OffsetArrayStart (0)
119 if (lockedp ==
NULL) {
132 if (! (found1 && found2)) {
134 "Could not open database column files.");
188 bool index = (select_file ==
e_Index);
194 const char * ptr =
file.GetFileDataPtr(lease, begin, end);
208 const int kFixedFieldBytes = 32;
217 int fmt_version = header.
ReadInt4();
219 if (fmt_version != 1) {
222 "Column file uses unknown format_version.");
225 int column_type = header.
ReadInt4();
227 if (column_type != 1) {
230 "Column file uses unknown data type.");
233 int offset_size = header.
ReadInt4();
235 if (offset_size != 4) {
238 "Column file uses unsupported offset size.");
269 "CSeqDBColumn: File format error.");
280 _ASSERT(begin > 0 && end > begin);
290 "CSeqDBColumn: File format error.");
293 int count = (
int) count8;
295 for(
int j = 0; j < count; j++) {
302 "CSeqDBColumn: Error; duplicate metadata key.");
318 "CSeqDBColumn: File format error.");
331 if (lockedp ==
NULL) {
337 int iend = istart + (2 * item_size);
342 int dstart = offsets.ReadInt4();
343 int dend = offsets.ReadInt4();
364 : m_VolIndices(indices), m_HaveMap(
false)
`Blob' Class for SeqDB (and WriteDB).
void SkipPadBytes(int align, EPadding fmt)
Align the offset by skipping bytes.
int GetReadOffset() const
Get the current read pointer offset.
Int4 ReadInt4()
Read a 4 byte integer at the pointer (and move the pointer).
@ eString
Pad using NUL terminated string of '#' bytes.
int Size() const
Get size of blob contents.
void ReferTo(CTempString data)
Refer to an existing memory area.
CTempString ReadString(EStringFormat fmt)
Read string data from the blob (moving the read pointer).
void Clear()
Clear all owned data and reference an empty string.
Int8 ReadInt8()
Read an 8 byte integer at the pointer (and move the pointer).
Int8 ReadVarInt()
Read a variable length integer from the blob.
bool DoesFileExist(const string &fname)
Check if file exists.
void Lock(CSeqDBLockHold &locked)
Lock the atlas.
void Unlock(CSeqDBLockHold &locked)
Unlock the atlas.
string m_Title
The title identifies this column's purpose.
Int4 m_NumOIDs
Number of OIDs (Blobs) in this column.
CSeqDBColumn(const string &basename, const string &index_extn, const string &data_extn, CSeqDBLockHold *lockedp)
Constructor.
static bool ColumnExists(const string &basename, const string &extn, CSeqDBAtlas &atlas)
Determine if the column exists.
void x_ReadMetaData(CSeqDBLockHold &locked)
Open files and read field data from the atlas.
void Flush()
Flush any held memory.
ESelectFile
Which file to access.
Int8 m_DataLength
Total length of data stored in the data file.
Int4 m_OffsetArrayStart
Start offset (in the index file) of the offset array.
int GetNumOIDs() const
Get the number of OIDs stored here.
CSeqDBRawFile m_DataFile
Data file.
map< string, string > m_MetaData
All key/value metadata for this column.
const map< string, string > & GetMetaData()
Get the column's Key/Value meta data.
CSeqDBFileMemMap m_DataLease
Data file lease.
void x_GetFileRange(TIndx begin, TIndx end, ESelectFile select_file, bool lifetime, CBlastDbBlob &blob, CSeqDBLockHold &locked)
Get a range of the index or data file.
static const CBlastDbBlob::EStringFormat kStringFmt
String format used by column files.
void GetBlob(int oid, CBlastDbBlob &blob, bool keep, CSeqDBLockHold *lockedp)
Fetch the data blob for the given oid.
string m_Date
The create date of the column files.
CSeqDBAtlas & m_Atlas
Reference to the atlas.
const string & GetTitle() const
Get the column title.
CSeqDBRawFile m_IndexFile
Index file.
Int4 m_MetaDataStart
Start offset (in the index file) of the metadata section.
CSeqDBFileMemMap m_IndexLease
Index file lease.
~CSeqDBColumn()
Destructor.
void x_ReadFields(CSeqDBLockHold &locked)
Open files and read field data from the atlas.
CSeqDBAtlas::TIndx TIndx
File offset type.
void Clear()
Clears the memory mapobject.
TIndx GetFileLength() const
Get the length of the file.
bool Open(const CSeqDB_Path &name)
MMap or Open a file.
Hold a memory region refcount, return to atlas when destroyed.
CSeqDB_ColumnEntry(const vector< int > &indices)
Constructor.
map< string, string > m_Map
The combined metadata map for this column.
void SetMapValue(const string &k, const string &v)
Add a meta-data key/value association.
void GetBlob(int oid, CBlastDbBlob &blob)
Fetch the data blob for the given oid.
const map< string, string > & GetMetaData()
Get the column's key/value meta data.
CSeqDB_ColumnReader(const string &basename, char file_id='a')
Read a BlastDb format column.
const string & GetTitle() const
Get the column title.
int GetNumOIDs() const
Get the number of rows stored in this column.
class CSeqDBColumn * m_Impl
Implementation object.
~CSeqDB_ColumnReader()
Destructor.
const string & GetValue(const string &key)
Look up one metadata value.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
const_iterator end() const
const_iterator find(const key_type &key) const
Defines column reader class for SeqDB.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
int64_t Int8
8-byte (64-bit) signed integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
unsigned int
A callback function used to compare two keys in a database.
const TYPE & Get(const CNamedParameterList *param)
const struct ncbi::grid::netcache::search::fields::KEY key
Defines database column access classes.
This file defines several SeqDB utility functions related to byte order and file system portability.
const U & SeqDB_MapFind(const std::map< T, U > &m, const T &k, const U &dflt)
Find a map value or return a default.
#define SEQDB_FILE_ASSERT(YESNO)