Turi Create  4.0
Utility Classes and Functions

Modules

 Hashing
 A generic set of hashing functions built around Google's cityhash.
 
 Set And Map Utilities
 Some mathematical Set and Map routines.
 

Classes

class  turi::value_container_mapper< Value, ValueContainer >
 
class  turi::thread_pool
 
class  turi::timer
 A simple class that can be used for benchmarking/timing up to microsecond resolution. More...
 
struct  turi::rdtsc_time
 
class  turi::any
 
class  turi::blocking_queue< T >
 Implements a blocking queue useful for producer/consumer models. More...
 
class  turi::buffer_pool< T >
 
class  turi::dense_bitset
 
class  turi::fast_integer_power
 
class  turi::function_output_iterator< UnaryFunction, MoveFunction >
 
struct  turi::lru_cache< Key, Value >
 
class  turi::mutable_queue< T, Priority >
 
class  turi::safe_circular_char_buffer
 
class  turi::scoped_finally
 

Macros

#define __likely__(x)   __builtin_expect((x),1)
 
#define __unlikely__(x)   __builtin_expect((x),0)
 
#define GL_HOT_INLINE
 
#define GL_HOT_INLINE_FLATTEN
 
#define GL_HOT_FLATTEN
 
#define GL_COLD_NOINLINE_ERROR   __attribute__((cold, noinline, noreturn))
 

Typedefs

typedef boost::iostreams::stream< charstream_impl::resizing_array_sink< true > > turi::charstream
 

Functions

uint32_t turi::get_local_ip (bool print=true)
 
std::string turi::get_local_ip_as_str (bool print=true)
 
std::pair< size_t, int > turi::get_free_tcp_port ()
 
rdtsc_type turi::estimate_ticks_per_second ()
 
rdtsc_type turi::rdtsc (void)
 
template<typename T , typename LessThan >
void turi::extract_and_sort_top_k (std::vector< T > &v, size_t top_k, LessThan less_than)
 
template<typename T >
void turi::extract_and_sort_top_k (std::vector< T > &v, size_t top_k)
 
std::string turi::md5 (std::string val)
 
std::string turi::md5_raw (std::string val)
 
std::string get_last_err_str (unsigned err_code)
 
template<typename T , typename U >
void turi::_save_and_load_object (T &dest, const U &src, std::string dir)
 

Detailed Description

Macro Definition Documentation

◆ __likely__

#define __likely__ (   x)    __builtin_expect((x),1)

Sets a branch as likely.

if (__likely__(age < 100)) {
...
} else if (__unlikely__(age >= 100)) {
...
}

Definition at line 21 of file branch_hints.hpp.

◆ __unlikely__

#define __unlikely__ (   x)    __builtin_expect((x),0)

Sets a branch as unlikely.

if (__likely__(age < 100)) {
...
} else if (__unlikely__(age >= 100)) {
...
}

Definition at line 35 of file branch_hints.hpp.

◆ GL_COLD_NOINLINE_ERROR

#define GL_COLD_NOINLINE_ERROR   __attribute__((cold, noinline, noreturn))

This is used with various assertion routines. It never returns. The noreturn suppresses the "warning: control reaches end of non-void function" messages you get by using it this way.

Definition at line 90 of file code_optimization.hpp.

◆ GL_HOT_FLATTEN

#define GL_HOT_FLATTEN
Value:
GL_OPT_ATTR(flatten, \
_GL_HOT_FUNCTION_FLAGS \
)

Forces flatten

Definition at line 61 of file code_optimization.hpp.

◆ GL_HOT_INLINE

#define GL_HOT_INLINE
Value:
GL_OPT_ATTR(always_inline, \
_GL_HOT_FUNCTION_FLAGS \
)

Forces always inline

Definition at line 42 of file code_optimization.hpp.

◆ GL_HOT_INLINE_FLATTEN

#define GL_HOT_INLINE_FLATTEN
Value:
GL_OPT_ATTR(always_inline, \
flatten, \
_GL_HOT_FUNCTION_FLAGS \
)

Forces always inline and flatten

Definition at line 51 of file code_optimization.hpp.

Typedef Documentation

◆ charstream

typedef boost::iostreams::stream< charstream_impl::resizing_array_sink<true> > turi::charstream

A stream object which stores all streamed output in memory. It can be used like any other stream object. For instance:

charstream cstrm;
cstrm << 123 << 10.0 << "hello world" << std::endl;

stream->size() will return the current length of output and stream->c_str() will return a mutable pointer to the string.

Definition at line 118 of file charstream.hpp.

Function Documentation

◆ _save_and_load_object()

template<typename T , typename U >
void turi::_save_and_load_object ( T &  dest,
const U &  src,
std::string  dir 
)

Serializes and deserializes a model, making sure that the model leaves the stream iterator in the appropriate place.

Definition at line 43 of file testing_utils.hpp.

◆ estimate_ticks_per_second()

rdtsc_type turi::estimate_ticks_per_second ( )

Estimates the number of RDTSC ticks per second.

◆ extract_and_sort_top_k() [1/2]

template<typename T , typename LessThan >
void turi::extract_and_sort_top_k ( std::vector< T > &  v,
size_t  top_k,
LessThan  less_than 
)

Goes through and extracts the top k out of all the elements in v, then resizes v to be of size top_k. After running this, the elements of v are in sorted descending order.

Definition at line 87 of file fast_top_k.hpp.

◆ extract_and_sort_top_k() [2/2]

template<typename T >
void turi::extract_and_sort_top_k ( std::vector< T > &  v,
size_t  top_k 
)

Goes through and extracts the top k out of all the elements in v, then resizes v to be of size top_k. After running this, the elements of v are in sorted descending order.

Definition at line 117 of file fast_top_k.hpp.

◆ get_free_tcp_port()

std::pair<size_t, int> turi::get_free_tcp_port ( )

Find a free tcp port and binds it. Caller must release the port. Returns a pair of [port, socket handle]

◆ get_last_err_str()

std::string get_last_err_str ( unsigned  err_code)

Portable version of strerror

◆ get_local_ip()

uint32_t turi::get_local_ip ( bool  print = true)

Returns the first non-localhost ipv4 address

◆ get_local_ip_as_str()

std::string turi::get_local_ip_as_str ( bool  print = true)

Returns the first non-localhost ipv4 address as a standard dot delimited string

◆ md5()

std::string turi::md5 ( std::string  val)

Computes the md5 checksum of a string, returning the md5 checksum in a hexadecimal string

◆ md5_raw()

std::string turi::md5_raw ( std::string  val)

Returns a 16 byte (non hexadecimal) string of the raw md5.

◆ rdtsc()

rdtsc_type turi::rdtsc ( void  )
inline

Returns the RDTSC value.

Definition at line 199 of file timer.hpp.