GPUdb C++ API  Version 7.0.19.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_utils.h File Reference
#include "gpudb/GPUdb.hpp"
#include <string>
#include <log4cplus/logger.h>
#include <log4cplus/loggingmacros.h>
+ Include dependency graph for test_utils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define KINETICA_STREAM_TO_STRING(...)   ( static_cast<const std::ostringstream&> (std::ostringstream() << __VA_ARGS__).str() )
 
#define KINETICA_STREAM_TO_CSTRING(...)   ( KINETICA_STREAM_TO_STRING(__VA_ARGS__).c_str() )
 
#define LOG_KINETICA_INFO(logger, logEvent)   do { LOG4CPLUS_INFO(logger, logEvent); } while(0)
 
#define LOG_KINETICA_DEBUG(logger, logEvent)   do { LOG4CPLUS_DEBUG(logger, logEvent); } while(0)
 
#define LOG_KINETICA_WARN(logger, logEvent)   do { LOG4CPLUS_WARN(logger, logEvent); } while(0)
 
#define LOG_KINETICA_ERROR(logger, logEvent)   do { LOG4CPLUS_ERROR(logger, logEvent); } while(0)
 
#define NORMALIZER   100
 
#define USE_NULL_VALUE(null_percentage)   ((std::rand() % NORMALIZER) < null_percentage)
 
#define PERFORM_ACTION(percentage)   ((std::rand() % NORMALIZER) < percentage)
 
#define GENERATE_INT8()   ( (std::rand() % 256) - 128)
 
#define GENERATE_INT16()   ( (std::rand() % 65536) - 32768)
 
#define GENERATE_FLOAT()   ( ((float)std::rand()) / std::rand() * std::pow(-1, (std::rand() % 2)) )
 
#define GENERATE_DOUBLE()   ( ((double)std::rand()) / std::rand() * std::pow(-1, (std::rand() % 2)) )
 
#define GENERATE_UNSIGNED_INT16()   ( std::rand() % 65536 )
 
#define GENERATE_UNSIGNED_LONG_LONG()
 
#define GENERATE_UNSIGNED_LONG_LONG_STRING()   ( std::to_string( GENERATE_UNSIGNED_LONG_LONG() ) )
 
#define GENERATE_TIMESTAMP()   ( std::rand() - std::rand() )
 
#define GENERATE_IPV4()
 Generate a random IPv4 address ('x.x.x.x' where x is in [0, 255]) More...
 

Functions

std::string generate_random_string ()
 
std::string generate_random_string (const std::string &prefix)
 
std::string generate_charN (size_t N)
 
std::string generate_unsigned_long_long_str ()
 
std::string generate_unsigned_long_long_str_no_leading_zero ()
 
std::string generate_date ()
 
std::string generate_datetime (int chance_percentage_has_time, int chance_percentage_has_ms)
 
std::string generate_time (int chance_percentage_has_ms)
 
std::string generate_decimal (int frac_only_percentage, int has_frac_percentage, int negative_percentage, int positive_percentage)
 
std::string generate_table_name (const std::string &prefix)
 Generate a table name with the given prefix. More...
 
void create_table (const gpudb::GPUdb &db, const std::string table_name, const gpudb::Type &type)
 Create a table given a DB hancle, table name, and a type. More...
 
void create_table (const gpudb::GPUdb &db, const std::string table_name, const std::vector< gpudb::Type::Column > &columns)
 Create a table given a DB hancle, table name, and a list of columns. More...
 
void clear_table (const gpudb::GPUdb &db, const std::string table_name)
 Clear a given table. More...
 
size_t get_table_size (const gpudb::GPUdb &db, const std::string table_name)
 Get a given table's size. More...
 

Variables

log4cplus::Logger logger
 
static const char alphanum [] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
 
static const char numeric [] = "0123456789"
 
static const int alphabet_size = 62
 

Macro Definition Documentation

#define GENERATE_DOUBLE ( )    ( ((double)std::rand()) / std::rand() * std::pow(-1, (std::rand() % 2)) )

Definition at line 63 of file test_utils.h.

#define GENERATE_FLOAT ( )    ( ((float)std::rand()) / std::rand() * std::pow(-1, (std::rand() % 2)) )

Definition at line 60 of file test_utils.h.

#define GENERATE_INT16 ( )    ( (std::rand() % 65536) - 32768)

Definition at line 57 of file test_utils.h.

#define GENERATE_INT8 ( )    ( (std::rand() % 256) - 128)

Definition at line 54 of file test_utils.h.

#define GENERATE_IPV4 ( )
Value:
( std::to_string(std::rand() % 256) + "." \
+ std::to_string(std::rand() % 256) + "." \
+ std::to_string(std::rand() % 256) + "." \
+ std::to_string(std::rand() % 256) )

Generate a random IPv4 address ('x.x.x.x' where x is in [0, 255])

Definition at line 139 of file test_utils.h.

#define GENERATE_TIMESTAMP ( )    ( std::rand() - std::rand() )

Definition at line 83 of file test_utils.h.

#define GENERATE_UNSIGNED_INT16 ( )    ( std::rand() % 65536 )

Definition at line 66 of file test_utils.h.

#define GENERATE_UNSIGNED_LONG_LONG ( )
Value:
( ( (unsigned long long)GENERATE_UNSIGNED_INT16() << 48 ) | \
( (unsigned long long)GENERATE_UNSIGNED_INT16() << 32 ) | \
( (unsigned long long)GENERATE_UNSIGNED_INT16() << 16 ) | \
( (unsigned long long)GENERATE_UNSIGNED_INT16() ) )
#define GENERATE_UNSIGNED_INT16()
Definition: test_utils.h:66

Definition at line 70 of file test_utils.h.

#define GENERATE_UNSIGNED_LONG_LONG_STRING ( )    ( std::to_string( GENERATE_UNSIGNED_LONG_LONG() ) )

Definition at line 79 of file test_utils.h.

#define KINETICA_STREAM_TO_CSTRING (   ...)    ( KINETICA_STREAM_TO_STRING(__VA_ARGS__).c_str() )

Definition at line 27 of file test_utils.h.

#define KINETICA_STREAM_TO_STRING (   ...)    ( static_cast<const std::ostringstream&> (std::ostringstream() << __VA_ARGS__).str() )

Definition at line 22 of file test_utils.h.

#define LOG_KINETICA_DEBUG (   logger,
  logEvent 
)    do { LOG4CPLUS_DEBUG(logger, logEvent); } while(0)

Definition at line 33 of file test_utils.h.

#define LOG_KINETICA_ERROR (   logger,
  logEvent 
)    do { LOG4CPLUS_ERROR(logger, logEvent); } while(0)

Definition at line 39 of file test_utils.h.

#define LOG_KINETICA_INFO (   logger,
  logEvent 
)    do { LOG4CPLUS_INFO(logger, logEvent); } while(0)

Definition at line 30 of file test_utils.h.

#define LOG_KINETICA_WARN (   logger,
  logEvent 
)    do { LOG4CPLUS_WARN(logger, logEvent); } while(0)

Definition at line 36 of file test_utils.h.

#define NORMALIZER   100

Definition at line 47 of file test_utils.h.

#define PERFORM_ACTION (   percentage)    ((std::rand() % NORMALIZER) < percentage)

Definition at line 51 of file test_utils.h.

#define USE_NULL_VALUE (   null_percentage)    ((std::rand() % NORMALIZER) < null_percentage)

Definition at line 48 of file test_utils.h.

Function Documentation

void clear_table ( const gpudb::GPUdb db,
const std::string  table_name 
)

Clear a given table.

void create_table ( const gpudb::GPUdb db,
const std::string  table_name,
const gpudb::Type type 
)

Create a table given a DB hancle, table name, and a type.

Clear any pre-existing table

void create_table ( const gpudb::GPUdb db,
const std::string  table_name,
const std::vector< gpudb::Type::Column > &  columns 
)

Create a table given a DB hancle, table name, and a list of columns.

Clear any pre-existing table

std::string generate_charN ( size_t  N)
std::string generate_date ( )
std::string generate_datetime ( int  chance_percentage_has_time,
int  chance_percentage_has_ms 
)
std::string generate_decimal ( int  frac_only_percentage,
int  has_frac_percentage,
int  negative_percentage,
int  positive_percentage 
)
std::string generate_random_string ( )
std::string generate_random_string ( const std::string &  prefix)
std::string generate_table_name ( const std::string &  prefix)

Generate a table name with the given prefix.

std::string generate_time ( int  chance_percentage_has_ms)
std::string generate_unsigned_long_long_str ( )
std::string generate_unsigned_long_long_str_no_leading_zero ( )
size_t get_table_size ( const gpudb::GPUdb db,
const std::string  table_name 
)

Get a given table's size.

Variable Documentation

const int alphabet_size = 62
static

Definition at line 90 of file test_utils.h.

const char alphanum[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
static

Definition at line 88 of file test_utils.h.

log4cplus::Logger logger
const char numeric[] = "0123456789"
static

Definition at line 89 of file test_utils.h.