GPUdb C++ API  Version 6.2.0.3
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:

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_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_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_time (int chance_percentage_has_ms)
 
std::string generate_decimal (int frac_only_percentage, int has_frac_percentage, int negative_percentage, int positive_percentage)
 
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...
 

Variables

static const char alphanum [] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
 
static const int alphabet_size = 62
 

Macro Definition Documentation

◆ GENERATE_DOUBLE

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

Definition at line 60 of file test_utils.h.

◆ GENERATE_FLOAT

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

Definition at line 56 of file test_utils.h.

◆ GENERATE_INT16

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

Definition at line 53 of file test_utils.h.

◆ GENERATE_INT8

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

Definition at line 50 of file test_utils.h.

◆ GENERATE_IPV4

#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 86 of file test_utils.h.

◆ GENERATE_TIMESTAMP

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

Definition at line 63 of file test_utils.h.

◆ KINETICA_STREAM_TO_CSTRING

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

Definition at line 23 of file test_utils.h.

◆ KINETICA_STREAM_TO_STRING

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

Definition at line 18 of file test_utils.h.

◆ LOG_KINETICA_DEBUG

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

Definition at line 29 of file test_utils.h.

◆ LOG_KINETICA_ERROR

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

Definition at line 35 of file test_utils.h.

◆ LOG_KINETICA_INFO

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

Definition at line 26 of file test_utils.h.

◆ LOG_KINETICA_WARN

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

Definition at line 32 of file test_utils.h.

◆ NORMALIZER

#define NORMALIZER   100

Definition at line 43 of file test_utils.h.

◆ PERFORM_ACTION

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

Definition at line 47 of file test_utils.h.

◆ USE_NULL_VALUE

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

Definition at line 44 of file test_utils.h.

Function Documentation

◆ clear_table()

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

Clear a given table.

◆ create_table() [1/2]

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

◆ create_table() [2/2]

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

◆ generate_charN()

std::string generate_charN ( size_t  N)

◆ generate_date()

std::string generate_date ( )

◆ generate_datetime()

std::string generate_datetime ( int  chance_percentage_has_time,
int  chance_percentage_has_ms 
)

◆ generate_decimal()

std::string generate_decimal ( int  frac_only_percentage,
int  has_frac_percentage,
int  negative_percentage,
int  positive_percentage 
)

◆ generate_random_string()

std::string generate_random_string ( )

◆ generate_time()

std::string generate_time ( int  chance_percentage_has_ms)

Variable Documentation

◆ alphabet_size

const int alphabet_size = 62
static

Definition at line 69 of file test_utils.h.

◆ alphanum

const char alphanum[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
static

Definition at line 68 of file test_utils.h.