ibis::util Namespace Reference


Classes

class  buffer
 A buffer is intended to some temporary workspace in memory. More...
class  counter
 A simple global counter. More...
class  ioLock
 A global IO mutex lock. More...
class  logger
 A class for logging error messages. More...
class  mutexLock
 An wrapper class for perform pthread_mutex_lock/unlock. More...
class  quietLock
 An wrapper class for perform pthread_mutex_lock/unlock. More...
class  readLock
 An wrapper class for perform pthread_rwlock_rdlock/unlock. More...
class  timer
 Print simply timing information. More...
class  writeLock
 An wrapper class for perform pthread_rwlock_wrlock/unlock. More...

Functions

uint32_t checksum (uint32_t a, uint32_t b)
 Fletcher's checksum on two integers. Returns an integer.
int closeLogFile ()
 Close the log file.
double coarsen (const double in, const unsigned prec)
 Reduce the decimal precision of the incoming floating-point value to specified precision.
int copy (const char *to, const char *from)
 Copy "from" to "to".
off_t getFileSize (const char *name)
 Return size of the file in bytes.
void getGMTime (char *str)
void getLocalTime (char *str)
 Return the current time in string format as asctime_r.
FILE * getLogFile ()
 Retrieve the pointer to the log file.
const char * getLogFileName ()
 Return name the of the current log file.
void getString (std::string &str, const char *&buf, const char *delim)
 Extract the next quoted string or the blank delimited string.
char * getString (const char *buf)
 Treat all bytes in buf as the string.
const char * getToken (char *&str, const char *tok_chrs)
char * itoa (int value, char *str, int)
void logMessage (const char *event, const char *fmt,...)
 Print a message to standard output.
int makeDir (const char *dir)
 Recursively create the name directory.
double rand ()
 A pseudo-random number generator (0,1).
double rand ()
 A pseudo-random number generator (0,1).
int readDouble (double &val, const char *&str, const char *del)
 Attempt to convert the incoming string into a double.
int readInt (int64_t &val, const char *&str, const char *del)
 Attempt to convert the incoming string into an integer.
void removeDir (const char *name, bool leaveDir=false)
 Remove the content of named directory.
void removeTail (char *str, char tail)
 Remove trailing character 'tail' from str.
void removeTail (char *str, char tail)
 Remove trailing character 'tail' from str.
template<class T>
void reorder (array_t< T * > &arr, const array_t< uint32_t > &ind)
template<class T>
void reorder (array_t< T > &arr, const array_t< uint32_t > &ind)
 Reorder the array arr according to the indices given in ind.
template void reorder< array_t< ibis::rid_t > > (array_t< array_t< ibis::rid_t > * > &, const array_t< uint32_t > &)
template void reorder< char > (array_t< char > &, const array_t< uint32_t > &)
template void reorder< double > (array_t< double > &, const array_t< uint32_t > &)
template void reorder< float > (array_t< float > &, const array_t< uint32_t > &)
template void reorder< int16_t > (array_t< int16_t > &, const array_t< uint32_t > &)
template void reorder< int32_t > (array_t< int32_t > &, const array_t< uint32_t > &)
template void reorder< int64_t > (array_t< int64_t > &, const array_t< uint32_t > &)
template void reorder< signed char > (array_t< signed char > &, const array_t< uint32_t > &)
template void reorder< uint16_t > (array_t< uint16_t > &, const array_t< uint32_t > &)
template void reorder< uint32_t > (array_t< uint32_t > &, const array_t< uint32_t > &)
template void reorder< uint64_t > (array_t< uint64_t > &, const array_t< uint32_t > &)
template void reorder< unsigned char > (array_t< unsigned char > &, const array_t< uint32_t > &)
void secondsToString (const time_t, char *str)
int setLogFileName (const char *filename)
 Change the current log file to the named file.
std::string shortName (const std::string &de)
template<typename T1, typename T2>
void sort (array_t< T1 > &arr1, array_t< T2 > &arr2)
 Sort two arrays together.
template void sort< double, double > (array_t< double > &, array_t< double > &)
template void sort< double, float > (array_t< double > &, array_t< float > &)
template void sort< double, int32_t > (array_t< double > &, array_t< int32_t > &)
template void sort< double, int64_t > (array_t< double > &, array_t< int64_t > &)
template void sort< double, uint32_t > (array_t< double > &, array_t< uint32_t > &)
template void sort< double, uint64_t > (array_t< double > &, array_t< uint64_t > &)
template void sort< float, double > (array_t< float > &, array_t< double > &)
template void sort< float, float > (array_t< float > &, array_t< float > &)
template void sort< float, int32_t > (array_t< float > &, array_t< int32_t > &)
template void sort< float, int64_t > (array_t< float > &, array_t< int64_t > &)
template void sort< float, uint32_t > (array_t< float > &, array_t< uint32_t > &)
template void sort< float, uint64_t > (array_t< float > &, array_t< uint64_t > &)
template void sort< int32_t, double > (array_t< int32_t > &, array_t< double > &)
template void sort< int32_t, float > (array_t< int32_t > &, array_t< float > &)
template void sort< int32_t, int32_t > (array_t< int32_t > &, array_t< int32_t > &)
template void sort< int32_t, int64_t > (array_t< int32_t > &, array_t< int64_t > &)
template void sort< int32_t, uint32_t > (array_t< int32_t > &, array_t< uint32_t > &)
template void sort< int32_t, uint64_t > (array_t< int32_t > &, array_t< uint64_t > &)
template void sort< int64_t, double > (array_t< int64_t > &, array_t< double > &)
template void sort< int64_t, float > (array_t< int64_t > &, array_t< float > &)
template void sort< int64_t, int32_t > (array_t< int64_t > &, array_t< int32_t > &)
template void sort< int64_t, int64_t > (array_t< int64_t > &, array_t< int64_t > &)
template void sort< int64_t, uint32_t > (array_t< int64_t > &, array_t< uint32_t > &)
template void sort< int64_t, uint64_t > (array_t< int64_t > &, array_t< uint64_t > &)
template void sort< uint32_t, double > (array_t< uint32_t > &, array_t< double > &)
template void sort< uint32_t, float > (array_t< uint32_t > &, array_t< float > &)
template void sort< uint32_t, int32_t > (array_t< uint32_t > &, array_t< int32_t > &)
template void sort< uint32_t, int64_t > (array_t< uint32_t > &, array_t< int64_t > &)
template void sort< uint32_t, uint32_t > (array_t< uint32_t > &, array_t< uint32_t > &)
template void sort< uint32_t, uint64_t > (array_t< uint32_t > &, array_t< uint64_t > &)
template void sort< uint64_t, double > (array_t< uint64_t > &, array_t< double > &)
template void sort< uint64_t, float > (array_t< uint64_t > &, array_t< float > &)
template void sort< uint64_t, int32_t > (array_t< uint64_t > &, array_t< int32_t > &)
template void sort< uint64_t, int64_t > (array_t< uint64_t > &, array_t< int64_t > &)
template void sort< uint64_t, uint32_t > (array_t< uint64_t > &, array_t< uint32_t > &)
template void sort< uint64_t, uint64_t > (array_t< uint64_t > &, array_t< uint64_t > &)
bool strMatch (const char *str, const char *pat)
 Match the string str against a simple pattern pat.
char * strnewdup (const char *s, const uint32_t n)
char * strnewdup (const char *s)
 duplicate string content with C++ default new operator
char * strnewdup (const char *s, const uint32_t n)
char * strnewdup (const char *s)
 duplicate string content with C++ default new operator
void tablesFromDir (ibis::partList &tables, const char *adir, const char *bdir)
 Look for data directories in the given pair of directories.
void tablesFromDir (ibis::partList &tlist, const char *dir1)
 Look into the given directory for table.tdc files.
void tablesFromResources (ibis::partList &tables, const ibis::resource &res)
 Reconstruct partitions using data directories specified in the resources.
char * trim (char *str)
 Remove leading and trailing blank space.
char * trim (char *str)
 Remove leading and trailing blank space.
void uniformFraction (const long unsigned idx, long unsigned &denominator, long unsigned &numerator)
 Compute a denominator and numerator pair to compute a uniform distribution of numbers in a given range.
unsigned long uniqueNumber ()
 Return an integer that is always increasing.
const char * userName ()
 Return the name of the user who is running the program.
uint32_t checksum (uint32_t a, uint32_t b)
 Fletcher's checksum on two integers. Returns an integer.
uint32_t checksum (const char *str, uint32_t sz)
 Fletcher's arithmetic checksum with 32-bit result.
std::string shortName (const std::string &longname)
 Fletcher's checksum on two integers. Returns an integer.
double coarsen (const double in, const unsigned prec=2)
 Reduce the decimal precision of the incoming floating-point value to specified precision.
double compactValue (double left, double right, double start=0.0)
 Compute a compact 64-bit floating-point value with a short decimal representation in the range (left, right].
double decrDouble (const double &in)
 Reduce the decimal precision of the incoming floating-point value to specified precision.
void eq2range (const double &in, double &left, double &right)
 Reduce the decimal precision of the incoming floating-point value to specified precision.
double incrDouble (const double &in)
 Functions to handle manipulation of floating-point numbers.
void setNaN (float &val)
 Reduce the decimal precision of the incoming floating-point value to specified precision.
void setNaN (double &val)
 Set a double to NaN.
void int2string (std::string &str, const std::vector< unsigned > &val)
void int2string (std::string &str, unsigned v1, unsigned v2, unsigned v3)
void int2string (std::string &str, unsigned v1, unsigned v2)
void int2string (std::string &str, unsigned val)
 convert 32-bit integers to base-64 printable characters
void isortRIDs (ibis::RIDSet &, uint32_t, uint32_t)
void sortRIDs (ibis::RIDSet &, uint32_t, uint32_t)
void sortRIDs (ibis::RIDSet &rids)
 Sorting RID lists.

Variables

const short unsigned charIndex []
 charIndex maps the characters (ASCII) back to integer [0-64]
const char * charTable
 charTable lists the 64 printable characters to be used for names
const char * delimiters
 Delimiters used to separate a string of names.
pthread_mutex_t envLock
 A mutex intended to be used for ensuring there is only one function that modifies the environment and other conditions.


Function Documentation

uint32_t ibis::util::checksum ( uint32_t  a,
uint32_t  b 
) [inline]

Fletcher's checksum on two integers. Returns an integer.

uint32_t ibis::util::checksum ( uint32_t  a,
uint32_t  b 
) [inline]

Fletcher's checksum on two integers. Returns an integer.

uint32_t ibis::util::checksum ( const char *  str,
uint32_t  sz 
)

Fletcher's arithmetic checksum with 32-bit result.

int ibis::util::closeLogFile (  ) 

Close the log file.

double ibis::util::coarsen ( const double  in,
const unsigned  prec 
) [inline]

Reduce the decimal precision of the incoming floating-point value to specified precision.

double ibis::util::coarsen ( const double  in,
const unsigned  prec = 2 
) [inline]

Reduce the decimal precision of the incoming floating-point value to specified precision.

double ibis::util::compactValue ( double  left,
double  right,
double  start = 0.0 
)

Compute a compact 64-bit floating-point value with a short decimal representation in the range (left, right].

The shortest number is considered to be zero (0.0).

int ibis::util::copy ( const char *  to,
const char *  from 
)

Copy "from" to "to".

Return zero (0) on success, a negative number otherwise.

double ibis::util::decrDouble ( const double &  in  )  [inline]

Reduce the decimal precision of the incoming floating-point value to specified precision.

void ibis::util::eq2range ( const double &  in,
double &  left,
double &  right 
) [inline]

Reduce the decimal precision of the incoming floating-point value to specified precision.

off_t ibis::util::getFileSize ( const char *  name  ) 

Return size of the file in bytes.

The value 0 is returned if file does not exist.

void ibis::util::getGMTime ( char *  str  ) 

void ibis::util::getLocalTime ( char *  str  ) 

Return the current time in string format as asctime_r.

The argument str must have 26 or more bytes and is used to carry the time output.

FILE* ibis::util::getLogFile (  ) 

Retrieve the pointer to the log file.

The value of stdout will be returned if no log file was specified. A log file name be specified through the following means (in the specified order), -- setLogFile -- environment variable FASTBITLOGFILE -- configuration parameter logfile

const char* ibis::util::getLogFileName (  ) 

Return name the of the current log file.

Blank string or null string indicate standard output.

void ibis::util::getString ( std::string &  str,
const char *&  buf,
const char *  delim = 0 
)

Extract the next quoted string or the blank delimited string.

Leading blank spaces are skipped. In addition to blank space, extra delimiters may be supplied at the third argument. The content of str will be empty if buf is nil or an empty string.

char * ibis::util::getString ( const char *  buf  ) 

Treat all bytes in buf as the string.

Returns a copy of the string allocated with the new operator.

const char * ibis::util::getToken ( char *&  str,
const char *  tok_chrs 
)

double ibis::util::incrDouble ( const double &  in  )  [inline]

Functions to handle manipulation of floating-point numbers.

The success of these functions is high sensitive to the definition of DBL_EPSILON. It should be defined as the smallest value x such that (1+x) is different from x. For 64-bit IEEE floating-point number, it is approximately 2.2E-16 (2^{-52}) (May 2, 2001)

void ibis::util::int2string ( std::string &  str,
const std::vector< unsigned > &  val 
)

void ibis::util::int2string ( std::string &  str,
unsigned  v1,
unsigned  v2,
unsigned  v3 
)

void ibis::util::int2string ( std::string &  str,
unsigned  v1,
unsigned  v2 
)

void ibis::util::int2string ( std::string &  str,
unsigned  val 
)

convert 32-bit integers to base-64 printable characters

void ibis::util::isortRIDs ( ibis::RIDSet ,
uint32_t  ,
uint32_t   
)

char* ibis::util::itoa ( int  value,
char *  str,
int   
) [inline]

void ibis::util::logMessage ( const char *  event,
const char *  fmt,
  ... 
)

Print a message to standard output.

The format string is same as printf. A global mutex lock is used to ensure printed messages are ordered.

int ibis::util::makeDir ( const char *  dir  ) 

Recursively create the name directory.

double ibis::util::rand (  )  [inline]

A pseudo-random number generator (0,1).

The integer variable seed is always an odd number. Don't use it directly.

double ibis::util::rand (  )  [inline]

A pseudo-random number generator (0,1).

The integer variable seed is always an odd number. Don't use it directly.

int ibis::util::readDouble ( double &  val,
const char *&  str,
const char *  del 
)

Attempt to convert the incoming string into a double.

int ibis::util::readInt ( int64_t &  val,
const char *&  str,
const char *  del 
)

Attempt to convert the incoming string into an integer.

Return zero (0) if all characters in str are decimal integers and the content does not overflow.

void ibis::util::removeDir ( const char *  name,
bool  leaveDir = false 
)

Remove the content of named directory.

The directory itself is removed unless the second argument is true.

void ibis::util::removeTail ( char *  str,
char  tail 
) [inline]

Remove trailing character 'tail' from str.

void ibis::util::removeTail ( char *  str,
char  tail 
) [inline]

Remove trailing character 'tail' from str.

template<class T>
void ibis::util::reorder ( array_t< T * > &  arr,
const array_t< uint32_t > &  ind 
)

template<class T>
void ibis::util::reorder ( array_t< T > &  arr,
const array_t< uint32_t > &  ind 
)

Reorder the array arr according to the indices given in ind.

template void ibis::util::reorder< array_t< ibis::rid_t > > ( array_t< array_t< ibis::rid_t > * > &  ,
const array_t< uint32_t > &   
)

template void ibis::util::reorder< char > ( array_t< char > &  ,
const array_t< uint32_t > &   
)

template void ibis::util::reorder< double > ( array_t< double > &  ,
const array_t< uint32_t > &   
)

template void ibis::util::reorder< float > ( array_t< float > &  ,
const array_t< uint32_t > &   
)

template void ibis::util::reorder< int16_t > ( array_t< int16_t > &  ,
const array_t< uint32_t > &   
)

template void ibis::util::reorder< int32_t > ( array_t< int32_t > &  ,
const array_t< uint32_t > &   
)

template void ibis::util::reorder< int64_t > ( array_t< int64_t > &  ,
const array_t< uint32_t > &   
)

template void ibis::util::reorder< signed char > ( array_t< signed char > &  ,
const array_t< uint32_t > &   
)

template void ibis::util::reorder< uint16_t > ( array_t< uint16_t > &  ,
const array_t< uint32_t > &   
)

template void ibis::util::reorder< uint32_t > ( array_t< uint32_t > &  ,
const array_t< uint32_t > &   
)

template void ibis::util::reorder< uint64_t > ( array_t< uint64_t > &  ,
const array_t< uint32_t > &   
)

template void ibis::util::reorder< unsigned char > ( array_t< unsigned char > &  ,
const array_t< uint32_t > &   
)

void ibis::util::secondsToString ( const   time_t,
char *  str 
)

int ibis::util::setLogFileName ( const char *  filename  ) 

Change the current log file to the named file.

Log files are opened in append mode, so the existing content will be preserved. The log file will be changed only if the named file can be opened correctly.

void ibis::util::setNaN ( float &  val  ) 

Reduce the decimal precision of the incoming floating-point value to specified precision.

void ibis::util::setNaN ( double &  val  ) 

Set a double to NaN.

std::string ibis::util::shortName ( const std::string &  de  )  [inline]

std::string ibis::util::shortName ( const std::string &  longname  )  [inline]

Fletcher's checksum on two integers. Returns an integer.

template<typename T1, typename T2>
void ibis::util::sort ( array_t< T1 > &  arr1,
array_t< T2 > &  arr2 
)

Sort two arrays together.

Order arr1 in ascending order first, then when arr1 has the same value, order arr2 in ascending order as well.

template void ibis::util::sort< double, double > ( array_t< double > &  ,
array_t< double > &   
)

template void ibis::util::sort< double, float > ( array_t< double > &  ,
array_t< float > &   
)

template void ibis::util::sort< double, int32_t > ( array_t< double > &  ,
array_t< int32_t > &   
)

template void ibis::util::sort< double, int64_t > ( array_t< double > &  ,
array_t< int64_t > &   
)

template void ibis::util::sort< double, uint32_t > ( array_t< double > &  ,
array_t< uint32_t > &   
)

template void ibis::util::sort< double, uint64_t > ( array_t< double > &  ,
array_t< uint64_t > &   
)

template void ibis::util::sort< float, double > ( array_t< float > &  ,
array_t< double > &   
)

template void ibis::util::sort< float, float > ( array_t< float > &  ,
array_t< float > &   
)

template void ibis::util::sort< float, int32_t > ( array_t< float > &  ,
array_t< int32_t > &   
)

template void ibis::util::sort< float, int64_t > ( array_t< float > &  ,
array_t< int64_t > &   
)

template void ibis::util::sort< float, uint32_t > ( array_t< float > &  ,
array_t< uint32_t > &   
)

template void ibis::util::sort< float, uint64_t > ( array_t< float > &  ,
array_t< uint64_t > &   
)

template void ibis::util::sort< int32_t, double > ( array_t< int32_t > &  ,
array_t< double > &   
)

template void ibis::util::sort< int32_t, float > ( array_t< int32_t > &  ,
array_t< float > &   
)

template void ibis::util::sort< int32_t, int32_t > ( array_t< int32_t > &  ,
array_t< int32_t > &   
)

template void ibis::util::sort< int32_t, int64_t > ( array_t< int32_t > &  ,
array_t< int64_t > &   
)

template void ibis::util::sort< int32_t, uint32_t > ( array_t< int32_t > &  ,
array_t< uint32_t > &   
)

template void ibis::util::sort< int32_t, uint64_t > ( array_t< int32_t > &  ,
array_t< uint64_t > &   
)

template void ibis::util::sort< int64_t, double > ( array_t< int64_t > &  ,
array_t< double > &   
)

template void ibis::util::sort< int64_t, float > ( array_t< int64_t > &  ,
array_t< float > &   
)

template void ibis::util::sort< int64_t, int32_t > ( array_t< int64_t > &  ,
array_t< int32_t > &   
)

template void ibis::util::sort< int64_t, int64_t > ( array_t< int64_t > &  ,
array_t< int64_t > &   
)

template void ibis::util::sort< int64_t, uint32_t > ( array_t< int64_t > &  ,
array_t< uint32_t > &   
)

template void ibis::util::sort< int64_t, uint64_t > ( array_t< int64_t > &  ,
array_t< uint64_t > &   
)

template void ibis::util::sort< uint32_t, double > ( array_t< uint32_t > &  ,
array_t< double > &   
)