159 const string & extension,
165 m_Extension (extension),
168 m_MaxFileSize(max_file_size)
174 static const int MAX_OFFSET_BITS = (
sizeof m_Offset * 8);
175 static const Uint8 MAX_FILE_SIZE = ((
Uint8) 1 << MAX_OFFSET_BITS);
182 _ASSERT(max_file_size <= MAX_FILE_SIZE);
210 static const int MAX_OFFSET_BITS = (
sizeof m_Offset * 8);
211 static const Uint8 MAX_OFFSET = ((
Uint8) 1 << MAX_OFFSET_BITS);
283 if(orig_num_digits == num_digits) {
292 for (
unsigned int i=2;
i< num_digits;
i++){
308 const string & title,
314 protein ?
"pin" :
"nin",
348 const string & lmdbName,
351 return 5 *
sizeof(
int) +
sizeof(
long)
352 + 3 *
sizeof(
int) +
T.size() + lmdbName.size() + D.size();
358 return 4 *
sizeof(
int) +
sizeof(
long)
359 + 2 *
sizeof(
int) +
T.size() + D.size();
376 int overhead = use_lmdb
379 while (overhead & 0x7) {
380 pad_date.append(
m_Nul);
395 if (!lmdb_name.empty()) {
407 for(
unsigned i = 0;
i <
m_Hdr.size();
i++) {
411 for(
unsigned i = 0;
i <
m_Seq.size();
i++) {
416 for(
unsigned i = 0;
i <
m_Amb.size();
i++) {
432 vector<unsigned int> tmp1, tmp2, tmp3;
455 protein ?
"phr" :
"nhr",
469 protein ?
"psq" :
"nsq",
475 m_BaseLimit(max_letters),
478 m_BaseLimit(max_letters)
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
CWriteDB_IndexFile class.
Uint8 m_MaxFileSize
Maximum file size in bytes.
TFile m_RealFile
Actual stream implementing the output file.
void x_MakeFileName()
Build the filename for this file.
bool m_Created
True if the file has already been opened.
string m_Fname
Current filename for output file.
CWriteDB_File(const string &basename, const string &extension, int index, Uint8 max_file_size, bool always_create)
Constructor.
virtual void RenameFileIndex(unsigned int num_digits)
void Create()
Create and open the file.
Uint8 x_DefaultByteLimit()
The default value for max_file_size.
void Close()
Close the file, flushing any remaining data to disk.
static string MakeShortName(const string &base, int index)
Construct the short name for a volume.
string m_BaseName
Database base name for all files.
virtual void x_Flush()=0
This should flush any unwritten data to disk.
unsigned int Write(const CTempString &data)
Write contents of a string to the file.
string m_Nul
For convenience, a string containing one NUL character.
unsigned int m_Offset
Stream position.
virtual void RenameSingle()
Rename this file, disincluding the volume index.
unsigned int WriteWithNull(const CTempString &data)
Write contents of a string to the file, appending a NUL.
bool m_UseIndex
True if filenames should use volume index.
string m_Extension
File extension for this file.
Uint8 m_DataSize
Required space for data once written to disk.
CWriteDB_IndexFile(const string &dbname, bool protein, const string &title, const string &date, int index, Uint8 max_file_size, EBlastDbVersion dbver=eBDB_Version4)
Constructor.
int m_Overhead
Amount of file used by metadata.
int m_OIDs
OIDs added to database so far.
EBlastDbVersion m_Version
BLASTDB version (4 or 5).
bool m_Protein
True if this is a protein database.
virtual void x_Flush()
Flush index data to disk.
string m_Title
Title string for all database volumes.
vector< unsigned int > m_Amb
Offset in sequence file of each OID's ambiguity data.
int x_Overhead(const string &T, const string &lmdbName, const string &D)
Compute index file overhead.
vector< unsigned int > m_Hdr
Start offset in header file of each OID's headers.
const string x_MakeLmdbName()
Form name of LMDB database file.
Uint8 m_Letters
Letters of sequence data accumulated so far.
int m_MaxLength
Length of longest sequence.
string m_Date
Database creation time stamp.
vector< unsigned int > m_Seq
Offset in sequence file of each OID's sequence data.
CWriteDB_SequenceFile(const string &dbname, bool protein, int index, Uint8 max_file_size, Uint8 max_letters)
Constructor.
std::ofstream out("events_result.xml")
main entry point for tests
bool Rename(const string &new_path, TRenameFlags flags=fRF_Default)
Rename entry.
static char GetPathSeparator(void)
Get path separator symbol specific for the current platform.
@ fRF_Overwrite
Remove destination if it exists.
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
const char * data(void) const
Return a pointer to the array represented.
size_type length(void) const
Return the length of the represented array.
char * dbname(DBPROCESS *dbproc)
Get name of current database.
unsigned int
A callback function used to compare two keys in a database.
#define F(x)
Make a parametrized function appear to have only one variable.
static const char * suffix[]
EBlastDbVersion
BLAST database version.
Data conversion tools for CWriteDB and associated code.
void s_WriteInt4(ostream &str, int x)
Write a four byte integer to a stream in big endian format.
void s_WriteInt8LE(ostream &str, Uint8 x)
Write an eight byte integer to a stream in little-endian format.
void s_WriteString(ostream &str, const string &s)
Write a length-prefixed string to a stream.
USING_SCOPE(std)
Use standard C++ definitions.
Code for database files construction.
int s_RoundUp(int value, int blocksize)
Round up to the next multiple of some number.