should be it
This commit is contained in:
95
external/duckdb/third_party/tpce-tool/include/utilities/BigMath.h
vendored
Normal file
95
external/duckdb/third_party/tpce-tool/include/utilities/BigMath.h
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Cecil Reames, Matt Emmerton
|
||||
*/
|
||||
|
||||
#ifndef BIGMATH_H
|
||||
#define BIGMATH_H
|
||||
|
||||
#include "EGenStandardTypes.h"
|
||||
|
||||
namespace TPCE {
|
||||
|
||||
// For 128-bit integer multiplication
|
||||
#define BIT63 UINT64_CONST(0x8000000000000000)
|
||||
#define CARRY32 UINT64_CONST(0x100000000)
|
||||
#define MASK32 UINT64_CONST(0xFFFFFFFF)
|
||||
#define UPPER32 32
|
||||
|
||||
// Multiply 64-bit and 32-bit factors, followed by a right-shift of 64 bits
|
||||
// (retaining upper 64-bit quantity) This is implemented as two 64-bit
|
||||
// multiplications with summation of partial products.
|
||||
inline UINT Mul6432WithShiftRight64(UINT64 seed, UINT range) {
|
||||
UINT64 SL = (seed & MASK32), // lower 32 bits of seed
|
||||
SU = (seed >> UPPER32), // upper 32 bits of seed
|
||||
RL = range; // range
|
||||
|
||||
UINT64 p0 = (SL * RL), // partial products
|
||||
p1 = (SU * RL), s;
|
||||
|
||||
s = p0;
|
||||
s >>= UPPER32;
|
||||
s += p1;
|
||||
s >>= UPPER32;
|
||||
|
||||
return (UINT)s;
|
||||
}
|
||||
|
||||
// Multiply two 64-bit factors, followed by a right-shift of 64 bits (retaining
|
||||
// upper 64-bit quantity) This is implemented as four 64-bit multiplications
|
||||
// with summation of partial products and carry.
|
||||
inline UINT64 Mul6464WithShiftRight64(UINT64 seed, UINT64 range) {
|
||||
UINT64 SL = (seed & MASK32), // lower 32 bits of seed
|
||||
SU = (seed >> UPPER32), // upper 32 bits of seed
|
||||
RL = (range & MASK32), // lower 32 bits of range
|
||||
RU = (range >> UPPER32); // upper 32 bits of range
|
||||
|
||||
UINT64 p0 = (SL * RL), // partial products
|
||||
p1 = (SU * RL), p2 = (SL * RU), p3 = (SU * RU), p12_carry = 0, s;
|
||||
|
||||
s = p0;
|
||||
s >>= UPPER32;
|
||||
s += p1;
|
||||
p12_carry = ((((p1 & BIT63) || (s & BIT63)) && (p2 & BIT63)) ? CARRY32 : 0);
|
||||
s += p2;
|
||||
s >>= UPPER32;
|
||||
s += p12_carry;
|
||||
s += p3;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
} // namespace TPCE
|
||||
|
||||
#endif // BIGMATH_H
|
||||
61
external/duckdb/third_party/tpce-tool/include/utilities/BufferFiller.h
vendored
Normal file
61
external/duckdb/third_party/tpce-tool/include/utilities/BufferFiller.h
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef BUFFER_FILLER_H
|
||||
#define BUFFER_FILLER_H
|
||||
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Doug Johnson
|
||||
*/
|
||||
|
||||
/*
|
||||
* Utility class to encapsulate functionality for filling character buffers.
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace TPCE {
|
||||
|
||||
class BufferFiller {
|
||||
public:
|
||||
static inline void Fill(void *c, int filler, std::size_t size) {
|
||||
std::memset(c, filler, size);
|
||||
}
|
||||
|
||||
static inline void Clear(void *c, std::size_t size) {
|
||||
Fill(c, '\0', size);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TPCE
|
||||
|
||||
#endif // BUFFER_FILLER_H
|
||||
217
external/duckdb/third_party/tpce-tool/include/utilities/DateTime.h
vendored
Normal file
217
external/duckdb/third_party/tpce-tool/include/utilities/DateTime.h
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Sergey Vasilevskiy
|
||||
*/
|
||||
|
||||
#ifndef DATE_TIME_H
|
||||
#define DATE_TIME_H
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef COMPILE_ODBC_LOAD
|
||||
// ODBC headers
|
||||
#include <sql.h>
|
||||
#include <sqlext.h>
|
||||
#include <odbcss.h>
|
||||
#endif // COMPILE_ODBC_LOAD
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "EGenStandardTypes.h"
|
||||
|
||||
namespace TPCE {
|
||||
|
||||
// Common datetime structure.
|
||||
// Identical to ODBC's TIMESTAMP_STRUCT
|
||||
//
|
||||
typedef struct tagTIMESTAMP_STRUCT {
|
||||
INT16 year;
|
||||
UINT16 month;
|
||||
UINT16 day;
|
||||
UINT16 hour;
|
||||
UINT16 minute;
|
||||
UINT16 second;
|
||||
UINT32 fraction;
|
||||
} TIMESTAMP_STRUCT;
|
||||
|
||||
// Date/Time constants
|
||||
const double NsPerSecondDivisor = 1000000000.0;
|
||||
const INT32 NsPerSecond = 1000000000;
|
||||
const double MsPerSecondDivisor = 1000.000;
|
||||
const INT32 MsPerSecond = 1000;
|
||||
const INT32 SecondsPerMinute = 60;
|
||||
const INT32 MinutesPerHour = 60;
|
||||
const INT32 HoursPerDay = 24;
|
||||
const INT32 HoursPerWorkDay = 8;
|
||||
const INT32 DaysPerWorkWeek = 5;
|
||||
const INT32 DaysPerWeek = 7;
|
||||
|
||||
const INT32 SecondsPerHour = SecondsPerMinute * MinutesPerHour;
|
||||
const INT32 SecondsPerDay = SecondsPerMinute * MinutesPerHour * HoursPerDay;
|
||||
const INT32 SecondsPerWorkDay = SecondsPerMinute * MinutesPerHour * HoursPerWorkDay;
|
||||
const INT32 MsPerDay = SecondsPerDay * MsPerSecond;
|
||||
const INT32 MsPerWorkDay = SecondsPerWorkDay * MsPerSecond;
|
||||
|
||||
#define RoundToNearestNsec(d_Seconds) (((INT64)(((d_Seconds)*NsPerSecond) + 0.5)) / NsPerSecondDivisor)
|
||||
|
||||
class CDateTime {
|
||||
private:
|
||||
INT32 m_dayno; // absolute day number since 1-Jan-0001, starting from zero
|
||||
INT32 m_msec; // milliseconds from the beginning of the day
|
||||
char *m_szText; // text representation; only allocated if needed
|
||||
|
||||
friend bool operator>(const CDateTime &l_dt, const CDateTime &r_dt);
|
||||
|
||||
//
|
||||
// Ranges used for date/time validation
|
||||
//
|
||||
static const INT32 minValidYear = 1;
|
||||
static const INT32 maxValidYear = 9999;
|
||||
static const INT32 minValidMonth = 1;
|
||||
static const INT32 maxValidMonth = 12;
|
||||
static const INT32 minValidDay = 1;
|
||||
static const INT32 maxValidDay = 31;
|
||||
static const INT32 minValidHour = 0;
|
||||
static const INT32 maxValidHour = 23;
|
||||
static const INT32 minValidMinute = 0;
|
||||
static const INT32 maxValidMinute = 59;
|
||||
static const INT32 minValidSecond = 0;
|
||||
static const INT32 maxValidSecond = 59;
|
||||
static const INT32 minValidMilliSecond = 0;
|
||||
static const INT32 maxValidMilliSecond = 999;
|
||||
|
||||
static const INT32 minValidDayNumber = 0;
|
||||
|
||||
// days in 1-year period (not including any leap year exceptions) = 365
|
||||
static const INT32 dy1 = 365;
|
||||
// days in 4-year period (not including 400 and 100-year exceptions) = 1,461
|
||||
static const INT32 dy4 = 4 * dy1 + 1; // fourth year is a leap year
|
||||
// days in 100-year period (not including 400-year exception) = 36,524
|
||||
static const INT32 dy100 = 25 * dy4 - 1; // 100th year is not a leap year
|
||||
// days in 400-year period = 146,097
|
||||
static const INT32 dy400 = 4 * dy100 + 1; // 400th year is a leap year
|
||||
|
||||
// month array contains days of months for months in a non leap-year
|
||||
static const INT32 monthArray[12];
|
||||
|
||||
// month array contains days of months for months in a leap-year
|
||||
static const INT32 monthArrayLY[12];
|
||||
|
||||
// MonthArray contains cumulative days for months in a non leap-year
|
||||
static const INT32 cumulativeMonthArray[];
|
||||
|
||||
//
|
||||
// Utility routine to calculate the day number for a given year/month/day.
|
||||
//
|
||||
static INT32 CalculateDayNumber(INT32 year, INT32 month, INT32 day);
|
||||
|
||||
//
|
||||
// Validation routines used to check inputs to constructors and Set methods.
|
||||
//
|
||||
static bool IsValid(INT32 year, INT32 month, INT32 day, INT32 hour, INT32 minute, INT32 second, INT32 msec);
|
||||
static void Validate(INT32 year, INT32 month, INT32 day, INT32 hour, INT32 minute, INT32 second, INT32 msec);
|
||||
static void Validate(INT32 dayNumber);
|
||||
static void Validate(INT32 dayNumber, INT32 msecSoFarToday);
|
||||
|
||||
//
|
||||
// Leap Year determinination routine.
|
||||
//
|
||||
static bool IsLeapYear(INT32 year);
|
||||
|
||||
public:
|
||||
CDateTime(void); // current local date/time
|
||||
CDateTime(INT32 dayno); // date as specified; time set to 0:00:00 (midnight)
|
||||
CDateTime(INT32 year, INT32 month,
|
||||
INT32 day); // date as specified; time set to 0:00:00 (midnight)
|
||||
CDateTime(INT32 year, INT32 month, INT32 day, INT32 hour, INT32 minute, INT32 second, INT32 msec);
|
||||
|
||||
CDateTime(TIMESTAMP_STRUCT *ts); // date specified in the TIMESTAMP struct
|
||||
|
||||
CDateTime(const CDateTime &dt); // proper copy constructor - does not copy m_szText
|
||||
~CDateTime(void);
|
||||
|
||||
void Set(void); // set to current local date/time
|
||||
void Set(INT32 dayno); // set to specified day number
|
||||
void Set(INT32 year, INT32 month,
|
||||
INT32 day); // set to specified date; time set to 0:00:00 (midnight)
|
||||
void Set(INT32 hour, INT32 minute, INT32 second,
|
||||
INT32 msec); // set to specified time, date not changed.
|
||||
void Set(INT32 year, INT32 month, INT32 day, INT32 hour, INT32 minute, INT32 second, INT32 msec);
|
||||
|
||||
inline INT32 DayNo(void) {
|
||||
return m_dayno;
|
||||
};
|
||||
inline INT32 MSec(void) {
|
||||
return m_msec;
|
||||
};
|
||||
void GetYMD(INT32 *year, INT32 *month, INT32 *day);
|
||||
void GetYMDHMS(INT32 *year, INT32 *month, INT32 *day, INT32 *hour, INT32 *minute, INT32 *second, INT32 *msec);
|
||||
void GetHMS(INT32 *hour, INT32 *minute, INT32 *second, INT32 *msec);
|
||||
|
||||
void GetTimeStamp(TIMESTAMP_STRUCT *ts);
|
||||
|
||||
#ifdef COMPILE_ODBC_LOAD
|
||||
void GetDBDATETIME(DBDATETIME *dt);
|
||||
#endif // COMPILE_ODBC_LOAD
|
||||
|
||||
static INT32 YMDtoDayno(INT32 yr, INT32 mm, INT32 dd);
|
||||
char *ToStr(INT32 style);
|
||||
|
||||
void Add(INT32 days, INT32 msec, bool adjust_weekend = false);
|
||||
void AddMinutes(INT32 Minutes);
|
||||
void AddWorkMs(INT64 WorkMs);
|
||||
|
||||
bool operator<(const CDateTime &);
|
||||
bool operator<=(const CDateTime &);
|
||||
// operator > is defined as an external (not in-class) operator in
|
||||
// CDateTime.cpp
|
||||
bool operator>=(const CDateTime &);
|
||||
bool operator==(const CDateTime &);
|
||||
|
||||
// compute the difference between two DateTimes;
|
||||
// result in seconds
|
||||
double operator-(const CDateTime &dt);
|
||||
INT32 DiffInMilliSeconds(const CDateTime &BaseTime);
|
||||
INT32 DiffInMilliSeconds(CDateTime *pBaseTime);
|
||||
// add another DateTime to this one
|
||||
CDateTime &operator+=(const CDateTime &dt);
|
||||
// Proper assignment operator - does not copy szText
|
||||
CDateTime &operator=(const CDateTime &dt);
|
||||
};
|
||||
|
||||
} // namespace TPCE
|
||||
|
||||
#endif // DATE_TIME_H
|
||||
143
external/duckdb/third_party/tpce-tool/include/utilities/EGenStandardTypes.h
vendored
Normal file
143
external/duckdb/third_party/tpce-tool/include/utilities/EGenStandardTypes.h
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Doug Johnson, Matt Emmerton, Larry Loen, Chris Chan-Nui
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Description: This file contains mappings from platform specific
|
||||
* data types to platform indepenent data types used
|
||||
* throughout EGen.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef EGEN_STANDARD_TYPES_H
|
||||
#define EGEN_STANDARD_TYPES_H
|
||||
|
||||
////////////////////
|
||||
// Standard types //
|
||||
////////////////////
|
||||
|
||||
// Define unsigned type for convenience
|
||||
typedef unsigned int UINT;
|
||||
|
||||
// This is a template that can be used for each
|
||||
// platform type.
|
||||
//
|
||||
// #ifdef {platform flag}
|
||||
// // Mapping for {platform} data types.
|
||||
// typedef {platform type} INT8, *PINT8;
|
||||
// typedef {platform type} INT16, *PINT16;
|
||||
// typedef {platform type} INT32, *PINT32;
|
||||
// typedef {platform type} INT64, *PINT64;
|
||||
//
|
||||
// typedef {platform type} UINT8, *PUINT8;
|
||||
// typedef {platform type} UINT16, *PUINT16;
|
||||
// typedef {platform type} UINT32, *PUINT32;
|
||||
// typedef {platform type} UINT64, *PUINT64;
|
||||
// #endif
|
||||
//
|
||||
|
||||
#define PRId64 "lld"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
typedef int8_t INT8, *PINT8;
|
||||
typedef int16_t INT16, *PINT16;
|
||||
typedef int32_t INT32, *PINT32;
|
||||
typedef int64_t INT64, *PINT64;
|
||||
|
||||
typedef uint8_t UINT8, *PUINT8;
|
||||
typedef uint16_t UINT16, *PUINT16;
|
||||
typedef uint32_t UINT32, *PUINT32;
|
||||
typedef uint64_t UINT64, *PUINT64;
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// 64-bit integer printf format specifier //
|
||||
/////////////////////////////////////////////
|
||||
// Assume everyone else is a flavor of Unix, has __unix defined,
|
||||
// and the 64-bit integer printf specifier is defined in <inttypes.h> as PRId64
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// integer constant suffixes //
|
||||
/////////////////////////////////////////////
|
||||
#define INT64_CONST(x) INT64_C(x)
|
||||
#define UINT64_CONST(x) UINT64_C(x)
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// mutex and thread types //
|
||||
/////////////////////////////////////////////
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
typedef pthread_t TThread;
|
||||
typedef pthread_attr_t TThreadAttr;
|
||||
typedef pthread_mutex_t TMutex;
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// Database dependant indicator value types //
|
||||
//////////////////////////////////////////////
|
||||
|
||||
#if defined(DB2)
|
||||
//
|
||||
// Mapping for DB2 data types.
|
||||
typedef UINT16 DB_INDICATOR;
|
||||
//
|
||||
#elif defined(MSSQL)
|
||||
//
|
||||
// Mapping for MSSQL data types.
|
||||
typedef long DB_INDICATOR;
|
||||
//
|
||||
#elif defined(ORACLE)
|
||||
//
|
||||
// Mapping for Oracle data types.
|
||||
typedef sb2 DB_INDICATOR;
|
||||
//
|
||||
#else
|
||||
//
|
||||
// Arbitrary default just so we can compile
|
||||
typedef INT32 DB_INDICATOR;
|
||||
#endif // ORACLE
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// Identifier type for all integer primary key fields. //
|
||||
// Corresponds to IDENT_T metatype in TPC-E spec. //
|
||||
/////////////////////////////////////////////////////////
|
||||
typedef INT64 TIdent;
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// Identifier type for all trade id primary key fields.//
|
||||
// Corresponds to TRADE_T metatype in TPC-E spec. //
|
||||
/////////////////////////////////////////////////////////
|
||||
typedef INT64 TTrade;
|
||||
|
||||
#endif // #ifndef EGEN_STANDARD_TYPES_H
|
||||
79
external/duckdb/third_party/tpce-tool/include/utilities/EGenUtilities_stdafx.h
vendored
Normal file
79
external/duckdb/third_party/tpce-tool/include/utilities/EGenUtilities_stdafx.h
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Sergey Vasilevskiy
|
||||
*/
|
||||
|
||||
#ifndef EGEN_UTILITIES_STDAFX_H
|
||||
#define EGEN_UTILITIES_STDAFX_H
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#ifdef WIN32 // for Windows platform
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <cerrno> //for Unix
|
||||
#include <sys/time.h> //for gettimeofday() on Linux
|
||||
#endif
|
||||
#include <ctime>
|
||||
#include <cassert>
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifdef NEED_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
#include "EGenStandardTypes.h"
|
||||
#include "DateTime.h"
|
||||
#include "Random.h"
|
||||
#include "error.h"
|
||||
#include "TableConsts.h"
|
||||
#include "MiscConsts.h"
|
||||
|
||||
#include "locking.h"
|
||||
#include "RNGSeeds.h"
|
||||
#include "EGenVersion.h"
|
||||
#include "Money.h"
|
||||
|
||||
#endif // #ifndef EGEN_UTILITIES_STDAFX_H
|
||||
87
external/duckdb/third_party/tpce-tool/include/utilities/EGenVersion.h
vendored
Normal file
87
external/duckdb/third_party/tpce-tool/include/utilities/EGenVersion.h
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Sergey Vasilevskiy
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Description: Versioning information for the EGen package.
|
||||
* Updated on every release.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef EGEN_VERSION_H
|
||||
#define EGEN_VERSION_H
|
||||
|
||||
#include "EGenStandardTypes.h"
|
||||
|
||||
namespace TPCE {
|
||||
|
||||
extern "C" {
|
||||
void GetEGenVersion_C(INT32 &iMajorVersion, INT32 &iMinorVersion, INT32 &iRevisionNumber, INT32 &iBetaLevel);
|
||||
void GetEGenVersionString_C(char *szOutput, size_t iOutputBufferLen);
|
||||
void PrintEGenVersion_C();
|
||||
void GetEGenVersionUpdateTimestamp_C(char *szOutput, size_t iOutputBufferLen);
|
||||
}
|
||||
|
||||
// Retrieve major, minor, revision, and beta level numbers for EGen.
|
||||
// For example, v3.10 beta 1 has:
|
||||
// major 3
|
||||
// minor 10
|
||||
// revision 0
|
||||
// beta level 1
|
||||
// v3.10 release has:
|
||||
// major 3
|
||||
// minor 10
|
||||
// revision 0
|
||||
// beta level 0
|
||||
//
|
||||
void GetEGenVersion(INT32 &iMajorVersion, INT32 &iMinorVersion, INT32 &iRevisionNumber, INT32 &iBetaLevel);
|
||||
|
||||
// Return versioning information formated as a string
|
||||
//
|
||||
// Note: requires output buffer at least 64 characters long, or nothing will be
|
||||
// returned.
|
||||
//
|
||||
void GetEGenVersionString(char *szOutput, size_t iOutputBufferLen);
|
||||
|
||||
// Output EGen versioning information on stdout
|
||||
//
|
||||
void PrintEGenVersion();
|
||||
|
||||
// Return the date/time when the EGen versioning information was last updated.
|
||||
//
|
||||
void GetEGenVersionUpdateTimestamp(char *szOutput, size_t iOutputBufferLen);
|
||||
|
||||
} // namespace TPCE
|
||||
|
||||
#endif // #ifndef EGEN_VERSION_H
|
||||
169
external/duckdb/third_party/tpce-tool/include/utilities/MiscConsts.h
vendored
Normal file
169
external/duckdb/third_party/tpce-tool/include/utilities/MiscConsts.h
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Sergey Vasilevskiy
|
||||
*/
|
||||
|
||||
/*
|
||||
* Miscellaneous constants used throughout EGenLoader.
|
||||
*/
|
||||
#ifndef MISC_CONSTS_H
|
||||
#define MISC_CONSTS_H
|
||||
|
||||
#include "EGenStandardTypes.h"
|
||||
|
||||
namespace TPCE {
|
||||
|
||||
static const TIdent iDefaultStartFromCustomer = 1;
|
||||
|
||||
// Minimum number of customers in a database.
|
||||
// Broker-Volume transations requires 40 broker names as input,
|
||||
// which translates into minimum 4000 customers in a database.
|
||||
//
|
||||
const TIdent iDefaultCustomerCount = 5000;
|
||||
|
||||
const TIdent iBrokersDiv = 100; // by what number to divide the customer count to get the broker count
|
||||
|
||||
// Number of customers in default load unit.
|
||||
// Note: this value must not be changed. EGen code depends
|
||||
// on load unit consisting of exactly 1000 customers.
|
||||
//
|
||||
const TIdent iDefaultLoadUnitSize = 1000;
|
||||
|
||||
// Base counts for scaling companines and securities.
|
||||
//
|
||||
const int iBaseCompanyCount = 5000; // number of base companies in the flat file
|
||||
const int iBaseCompanyCompetitorCount = 3 * iBaseCompanyCount; // number of base company competitor rows
|
||||
const int iOneLoadUnitCompanyCount = 500;
|
||||
const int iOneLoadUnitSecurityCount = 685;
|
||||
const int iOneLoadUnitCompanyCompetitorCount = 3 * iOneLoadUnitCompanyCount;
|
||||
|
||||
// Number by which all IDENT_T columns (C_ID, CA_ID, etc.) are shifted.
|
||||
//
|
||||
const TIdent iTIdentShift = INT64_CONST(4300000000); // 4.3 billion
|
||||
|
||||
// Number by which all TRADE_T columns (T_ID, TH_T_ID, etc.) are shifted.
|
||||
//
|
||||
const TTrade iTTradeShift = INT64_CONST(200000000000000); // 200 trillion (2 * 10^14)
|
||||
|
||||
const int iMaxHostname = 64;
|
||||
const int iMaxDBName = 64;
|
||||
const int iMaxPath = 512;
|
||||
|
||||
// NOTE: Changing the initial trade populate base date
|
||||
// can break code used in CCETxnInputGenerator for generating
|
||||
// Trade-Lookup data.
|
||||
const INT16 InitialTradePopulationBaseYear = 2005;
|
||||
const UINT16 InitialTradePopulationBaseMonth = 1;
|
||||
const UINT16 InitialTradePopulationBaseDay = 3;
|
||||
const UINT16 InitialTradePopulationBaseHour = 9;
|
||||
const UINT16 InitialTradePopulationBaseMinute = 0;
|
||||
const UINT16 InitialTradePopulationBaseSecond = 0;
|
||||
const UINT32 InitialTradePopulationBaseFraction = 0;
|
||||
|
||||
// At what trade count multiple to abort trades.
|
||||
// One trade in every iAboutTrade block is aborted (trade id is thrown out).
|
||||
// NOTE: this really is 10 * Trade-Order mix percentage!
|
||||
//
|
||||
const int iAbortTrade = 101;
|
||||
|
||||
// Used at load and run time to determine which intial trades
|
||||
// simulate rollback by "aborting" - I.e. used to skip over a
|
||||
// trade ID.
|
||||
const int iAbortedTradeModFactor = 51;
|
||||
|
||||
// Start date for DAILY_MARKET and FINANCIAL.
|
||||
//
|
||||
const int iDailyMarketBaseYear = 2000;
|
||||
const int iDailyMarketBaseMonth = 1;
|
||||
const int iDailyMarketBaseDay = 3;
|
||||
const int iDailyMarketBaseHour = 0;
|
||||
const int iDailyMarketBaseMinute = 0;
|
||||
const int iDailyMarketBaseSecond = 0;
|
||||
const int iDailyMarketBaseMsec = 0;
|
||||
|
||||
// Range of financial rows to return from Security Detail
|
||||
const int iSecurityDetailMinRows = 5;
|
||||
const int iSecurityDetailMaxRows = 20; // max_fin_len
|
||||
|
||||
// Trade-Lookup constants
|
||||
const INT32 TradeLookupMaxTradeHistoryRowsReturned =
|
||||
3; // Based on the maximum number of status changes a trade can go through.
|
||||
const INT32 TradeLookupMaxRows = 20; // Max number of rows for the frames
|
||||
const INT32 TradeLookupFrame1MaxRows = TradeLookupMaxRows;
|
||||
const INT32 TradeLookupFrame2MaxRows = TradeLookupMaxRows;
|
||||
const INT32 TradeLookupFrame3MaxRows = TradeLookupMaxRows;
|
||||
const INT32 TradeLookupFrame4MaxRows = TradeLookupMaxRows;
|
||||
|
||||
// Trade-Update constants
|
||||
const INT32 TradeUpdateMaxTradeHistoryRowsReturned =
|
||||
3; // Based on the maximum number of status changes a trade can go through.
|
||||
const INT32 TradeUpdateMaxRows = 20; // Max number of rows for the frames
|
||||
const INT32 TradeUpdateFrame1MaxRows = TradeUpdateMaxRows;
|
||||
const INT32 TradeUpdateFrame2MaxRows = TradeUpdateMaxRows;
|
||||
const INT32 TradeUpdateFrame3MaxRows = TradeUpdateMaxRows;
|
||||
|
||||
// These two arrays are used for platform independence
|
||||
const char UpperCaseLetters[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
const char LowerCaseLetters[] = "abcdefghijklmnopqrstuvwxyz";
|
||||
const char Numerals[] = "0123456789";
|
||||
const int MaxLowerCaseLetters = sizeof(LowerCaseLetters) - 1;
|
||||
|
||||
//
|
||||
// Constants for non-uniform distribution of various transaction parameters.
|
||||
//
|
||||
|
||||
// Trade Lookup
|
||||
const INT32 TradeLookupAValueForTradeIDGenFrame1 = 65535;
|
||||
const INT32 TradeLookupSValueForTradeIDGenFrame1 = 7;
|
||||
const INT32 TradeLookupAValueForTimeGenFrame2 = 4095;
|
||||
const INT32 TradeLookupSValueForTimeGenFrame2 = 16;
|
||||
const INT32 TradeLookupAValueForSymbolFrame3 = 0;
|
||||
const INT32 TradeLookupSValueForSymbolFrame3 = 0;
|
||||
const INT32 TradeLookupAValueForTimeGenFrame3 = 4095;
|
||||
const INT32 TradeLookupSValueForTimeGenFrame3 = 16;
|
||||
const INT32 TradeLookupAValueForTimeGenFrame4 = 4095;
|
||||
const INT32 TradeLookupSValueForTimeGenFrame4 = 16;
|
||||
// Trade Update
|
||||
const INT32 TradeUpdateAValueForTradeIDGenFrame1 = 65535;
|
||||
const INT32 TradeUpdateSValueForTradeIDGenFrame1 = 7;
|
||||
const INT32 TradeUpdateAValueForTimeGenFrame2 = 4095;
|
||||
const INT32 TradeUpdateSValueForTimeGenFrame2 = 16;
|
||||
const INT32 TradeUpdateAValueForSymbolFrame3 = 0;
|
||||
const INT32 TradeUpdateSValueForSymbolFrame3 = 0;
|
||||
const INT32 TradeUpdateAValueForTimeGenFrame3 = 4095;
|
||||
const INT32 TradeUpdateSValueForTimeGenFrame3 = 16;
|
||||
|
||||
} // namespace TPCE
|
||||
|
||||
#endif // MISC_CONSTS_H
|
||||
228
external/duckdb/third_party/tpce-tool/include/utilities/Money.h
vendored
Normal file
228
external/duckdb/third_party/tpce-tool/include/utilities/Money.h
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Sergey Vasilevskiy
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Description: Money type that keeps all calculations in integer
|
||||
* number of cents. Needed for consistency of initial
|
||||
* database population.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef MONEY_H
|
||||
#define MONEY_H
|
||||
|
||||
#include "EGenStandardTypes.h"
|
||||
|
||||
namespace TPCE {
|
||||
|
||||
class CMoney {
|
||||
INT64 m_iAmountInCents; // dollar amount * 100
|
||||
|
||||
// Define binary operators when CMoney is the right operand
|
||||
//
|
||||
friend CMoney operator*(int l_i, CMoney r_m);
|
||||
friend CMoney operator*(double l_f, CMoney r_m);
|
||||
friend double operator/(double l_f, CMoney r_m);
|
||||
|
||||
public:
|
||||
// Default constructor - initialize to $0
|
||||
//
|
||||
CMoney() : m_iAmountInCents(0) {
|
||||
}
|
||||
|
||||
// Initialize from another CMoney
|
||||
//
|
||||
CMoney(CMoney *m) : m_iAmountInCents(m->m_iAmountInCents) {
|
||||
}
|
||||
|
||||
// Initialize CMoney from double
|
||||
//
|
||||
CMoney(double fAmount)
|
||||
: m_iAmountInCents((INT64)(100.0 * fAmount + 0.5)) // round floating-point number correctly
|
||||
{
|
||||
}
|
||||
|
||||
// Return amount in integer dollars and fractional cents e.g. $123.99
|
||||
//
|
||||
double DollarAmount() {
|
||||
return m_iAmountInCents / 100.0;
|
||||
}
|
||||
|
||||
// Return amount in integer cents e.g. 12399
|
||||
INT64 CentsAmount() {
|
||||
return m_iAmountInCents;
|
||||
}
|
||||
|
||||
// Define arithmetic operations on CMoney and CMoney
|
||||
//
|
||||
CMoney operator+(const CMoney &m) {
|
||||
CMoney ret(this);
|
||||
|
||||
ret.m_iAmountInCents += m.m_iAmountInCents;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CMoney &operator+=(const CMoney &m) {
|
||||
m_iAmountInCents += m.m_iAmountInCents;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CMoney operator-(const CMoney &m) {
|
||||
CMoney ret(this);
|
||||
|
||||
ret.m_iAmountInCents -= m.m_iAmountInCents;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CMoney &operator-=(const CMoney &m) {
|
||||
m_iAmountInCents -= m.m_iAmountInCents;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CMoney operator*(const CMoney &m) {
|
||||
CMoney ret(this);
|
||||
|
||||
ret.m_iAmountInCents *= m.m_iAmountInCents;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CMoney operator/(const CMoney &m) {
|
||||
CMoney ret(this);
|
||||
|
||||
ret.m_iAmountInCents /= m.m_iAmountInCents;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Define arithmetic operations on CMoney and int
|
||||
//
|
||||
CMoney operator*(int i) {
|
||||
CMoney ret(this);
|
||||
|
||||
ret.m_iAmountInCents *= i;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Define arithmetic operations on CMoney and double
|
||||
//
|
||||
CMoney operator+(double f) {
|
||||
CMoney ret(this);
|
||||
|
||||
ret.m_iAmountInCents += (INT64)(100.0 * f + 0.5);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CMoney operator-(double f) {
|
||||
CMoney ret(this);
|
||||
|
||||
ret.m_iAmountInCents -= (INT64)(100.0 * f + 0.5);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CMoney &operator-=(double f) {
|
||||
m_iAmountInCents -= (INT64)(100.0 * f + 0.5);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CMoney operator*(double f) {
|
||||
CMoney ret(this);
|
||||
|
||||
// Do a trick for correct rounding. Can't use ceil or floor functions
|
||||
// because they do not round properly (e.g. down when < 0.5, up when >=
|
||||
// 0.5).
|
||||
//
|
||||
if (ret.m_iAmountInCents > 0) {
|
||||
ret.m_iAmountInCents = (INT64)(ret.m_iAmountInCents * f + 0.5);
|
||||
} else {
|
||||
ret.m_iAmountInCents = (INT64)(ret.m_iAmountInCents * f - 0.5);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CMoney operator/(double f) {
|
||||
CMoney ret(this);
|
||||
|
||||
if (ret.m_iAmountInCents > 0) {
|
||||
ret.m_iAmountInCents = (INT64)(ret.m_iAmountInCents / f + 0.5);
|
||||
} else {
|
||||
ret.m_iAmountInCents = (INT64)(ret.m_iAmountInCents / f - 0.5);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Assignment of a double (presumed fractional dollar amount e.g. in the
|
||||
// form $123.89)
|
||||
//
|
||||
CMoney &operator=(double f) {
|
||||
m_iAmountInCents = (INT64)(100.0 * f + 0.5);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Comparison operators
|
||||
//
|
||||
bool operator==(const CMoney &m) {
|
||||
return m_iAmountInCents == m.m_iAmountInCents;
|
||||
}
|
||||
|
||||
bool operator>(const CMoney &m) {
|
||||
return m_iAmountInCents > m.m_iAmountInCents;
|
||||
}
|
||||
bool operator>=(const CMoney &m) {
|
||||
return m_iAmountInCents >= m.m_iAmountInCents;
|
||||
}
|
||||
|
||||
bool operator<(const CMoney &m) {
|
||||
return m_iAmountInCents < m.m_iAmountInCents;
|
||||
}
|
||||
bool operator<=(const CMoney &m) {
|
||||
return m_iAmountInCents <= m.m_iAmountInCents;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TPCE
|
||||
|
||||
#endif // #ifndef MONEY_H
|
||||
125
external/duckdb/third_party/tpce-tool/include/utilities/RNGSeeds.h
vendored
Normal file
125
external/duckdb/third_party/tpce-tool/include/utilities/RNGSeeds.h
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Doug Johnson
|
||||
*/
|
||||
|
||||
/*
|
||||
* Contains all seeds used with the Random Number Generator (RNG).
|
||||
*/
|
||||
|
||||
#ifndef RNGSEEDS_H
|
||||
#define RNGSEEDS_H
|
||||
|
||||
#include "Random.h"
|
||||
|
||||
namespace TPCE {
|
||||
// Default seed used for all tables.
|
||||
const RNGSEED RNGSeedTableDefault = 37039940;
|
||||
|
||||
// This value is added to the AD_ID when seeding the RNG for
|
||||
// generating a threshold into the TownDivisionZipCode list.
|
||||
const RNGSEED RNGSeedBaseTownDivZip = 26778071;
|
||||
|
||||
// This is the base seed used when generating C_TIER.
|
||||
const RNGSEED RNGSeedBaseC_TIER = 16225173;
|
||||
|
||||
// Base seeds used for generating C_AREA_1, C_AREA_2, C_AREA_3
|
||||
const RNGSEED RNGSeedBaseC_AREA_1 = 97905013;
|
||||
const RNGSEED RNGSeedBaseC_AREA_2 = 68856487;
|
||||
const RNGSEED RNGSeedBaseC_AREA_3 = 67142295;
|
||||
|
||||
// Base seed used when generating names.
|
||||
const RNGSEED RNGSeedBaseFirstName = 95066470;
|
||||
const RNGSEED RNGSeedBaseMiddleInitial = 71434514;
|
||||
const RNGSEED RNGSeedBaseLastName = 35846049;
|
||||
|
||||
// Base seed used when generating gender.
|
||||
const RNGSEED RNGSeedBaseGender = 9568922;
|
||||
|
||||
// Base seed used when generating tax ID
|
||||
const RNGSEED RNGSeedBaseTaxID = 8731255;
|
||||
|
||||
// Base seed used when generating the number of accounts for a customer
|
||||
// const RNGSEED RNGSeedBaseNumberOfAccounts = 37486207;
|
||||
|
||||
// Base seed used when generating the number of permissions on an account
|
||||
const RNGSEED RNGSeedBaseNumberOfAccountPermissions = 27794203;
|
||||
|
||||
// Base seeds used when generating CIDs for additional account permissions
|
||||
const RNGSEED RNGSeedBaseCIDForPermission1 = 76103629;
|
||||
const RNGSEED RNGSeedBaseCIDForPermission2 = 103275149;
|
||||
|
||||
// Base seed used when generating acount tax status
|
||||
const RNGSEED RNGSeedBaseAccountTaxStatus = 34376701;
|
||||
|
||||
// Base seed for determining account broker id
|
||||
const RNGSEED RNGSeedBaseBrokerId = 75607774;
|
||||
|
||||
// Base seed used when generating tax rate row
|
||||
const RNGSEED RNGSeedBaseTaxRateRow = 92740731;
|
||||
|
||||
// Base seed used when generating the number of holdings for an account
|
||||
const RNGSEED RNGSeedBaseNumberOfSecurities = 23361736;
|
||||
|
||||
// Base seed used when generating the starting security ID for the
|
||||
// set of securities associated with a particular account.
|
||||
const RNGSEED RNGSeedBaseStartingSecurityID = 12020070;
|
||||
|
||||
// Base seed used when generating a company's SP Rate
|
||||
const RNGSEED RNGSeedBaseSPRate = 56593330;
|
||||
|
||||
// Base seed for initial trade generation class
|
||||
const RNGSEED RNGSeedTradeGen = 32900134;
|
||||
|
||||
// Base seed for the MEESecurity class
|
||||
const RNGSEED RNGSeedBaseMEESecurity = 75791232;
|
||||
|
||||
// Base seed for non-uniform customer selection
|
||||
const RNGSEED RNGSeedCustomerSelection = 9270899;
|
||||
|
||||
// Base seed for MEE Ticker Tape
|
||||
const RNGSEED RNGSeedBaseMEETickerTape = 42065035;
|
||||
|
||||
// Base seed for MEE Trading Floor
|
||||
const RNGSEED RNGSeedBaseMEETradingFloor = 25730774;
|
||||
|
||||
// Base seed for TxnMixGenerator
|
||||
const RNGSEED RNGSeedBaseTxnMixGenerator = 87944308;
|
||||
|
||||
// Base seed for TxnInputGenerator
|
||||
const RNGSEED RNGSeedBaseTxnInputGenerator = 80534927;
|
||||
|
||||
} // namespace TPCE
|
||||
|
||||
#endif // RNGSEEDS_H
|
||||
194
external/duckdb/third_party/tpce-tool/include/utilities/Random.h
vendored
Normal file
194
external/duckdb/third_party/tpce-tool/include/utilities/Random.h
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Sergey Vasilevskiy, Cecil Reames, Matt Emmerton
|
||||
*/
|
||||
|
||||
#ifndef RANDOM_H
|
||||
#define RANDOM_H
|
||||
|
||||
#include "EGenStandardTypes.h"
|
||||
|
||||
/*
|
||||
* Notes to Future EGen Coders:
|
||||
*
|
||||
* The Random routines have been rewritten to eliminate all uses of
|
||||
* floating-point operations, so as to improve portability of EGen across
|
||||
* platforms and compilers.
|
||||
*
|
||||
* All Random routines now generate a random range of integer values, even if
|
||||
* those values are later converted back to floating-point for the caller.
|
||||
*
|
||||
* The same rules apply in the Random code as in the CMoney class:
|
||||
* - It is OK to store and transport a value in a double.
|
||||
* - It is not OK to perform calculations directly on a value in a double.
|
||||
*
|
||||
* Performing calculations directly on doubles can cause EGen subtle problems:
|
||||
* - Rounding differences between 80-bit and 64-bit double operands.
|
||||
* - Precision loss for large integers stored into 64-bit doubles.
|
||||
* - Integer range operations that rarely return an output one too large.
|
||||
* - Differences between initial database population and runtime inputs
|
||||
* when executed on two different platforms / compilers.
|
||||
*
|
||||
* The RndDouble() and RndDoubleRange() routines are now deprecated. The
|
||||
* RndDoubleIncrRange() routine is the replacement for these deprecated
|
||||
* routines. This routine takes a pair of range parameters, plus an increment
|
||||
* argument. It produces a range of integer values, which are converted to a
|
||||
* discrete (not continuous) range of double values.
|
||||
*
|
||||
* All integer range routines now perform 96-bit or 128-bit integer
|
||||
* multiplication with integer truncation of the lower 64 bits, thus avoiding
|
||||
* use of RndDouble().
|
||||
*/
|
||||
|
||||
namespace TPCE {
|
||||
|
||||
// Constants
|
||||
#define UInt64Rand_A_MULTIPLIER UINT64_CONST(6364136223846793005)
|
||||
#define UInt64Rand_C_INCREMENT UINT64_CONST(1)
|
||||
#define UInt64Rand_ONE UINT64_CONST(1)
|
||||
|
||||
// Independent RNG seed type.
|
||||
typedef UINT64 RNGSEED;
|
||||
|
||||
#ifdef EGEN_USE_DEPRECATED_CODE
|
||||
|
||||
// For efficiency, use a constant for 1/2^64.
|
||||
#define UInt64Rand_RECIPROCAL_2_POWER_64 (5.421010862427522e-20)
|
||||
|
||||
#endif // EGEN_USE_DEPRECATED_CODE
|
||||
|
||||
class CRandom {
|
||||
private:
|
||||
RNGSEED m_seed;
|
||||
inline RNGSEED UInt64Rand(void);
|
||||
|
||||
public:
|
||||
CRandom(void);
|
||||
CRandom(RNGSEED seed);
|
||||
~CRandom(void){};
|
||||
|
||||
void SetSeed(RNGSEED seed);
|
||||
inline RNGSEED GetSeed(void) {
|
||||
return m_seed;
|
||||
};
|
||||
RNGSEED RndNthElement(RNGSEED nSeed, RNGSEED nCount);
|
||||
|
||||
// returns a random integer value in the range [min .. max]
|
||||
int RndIntRange(int min, int max);
|
||||
|
||||
// returns a random 64-bit integer value in the range [min .. max]
|
||||
INT64 RndInt64Range(INT64 min, INT64 max);
|
||||
|
||||
// returns a random integer value in the range [low .. high] excluding the
|
||||
// value (exclude)
|
||||
INT64 RndInt64RangeExclude(INT64 low, INT64 high, INT64 exclude);
|
||||
|
||||
// return Nth element in the sequence over the integer range
|
||||
int RndNthIntRange(RNGSEED Seed, RNGSEED N, int min, int max);
|
||||
|
||||
// return Nth element in the sequence over the integer range
|
||||
INT64 RndNthInt64Range(RNGSEED Seed, RNGSEED N, INT64 min, INT64 max);
|
||||
|
||||
// returns a random integer value in the range [low .. high] excluding the
|
||||
// value (exclude)
|
||||
int RndIntRangeExclude(int low, int high, int exclude);
|
||||
|
||||
#ifdef EGEN_USE_DEPRECATED_CODE
|
||||
|
||||
// returns a random value in the range [0 ..
|
||||
// 0.99999999999999999994578989137572] care should be taken in casting the
|
||||
// result as a float because of the potential loss of precision.
|
||||
double RndDouble(void);
|
||||
|
||||
// return Nth element in the sequence converted to double
|
||||
double RndNthDouble(RNGSEED Seed, RNGSEED N);
|
||||
|
||||
#endif // EGEN_USE_DEPRECATED_CODE
|
||||
|
||||
// returns a random double value in the range of [min .. max]
|
||||
double RndDoubleRange(double min, double max);
|
||||
|
||||
// returns a random double value in the range of [min .. max] with incr
|
||||
// precision
|
||||
double RndDoubleIncrRange(double min, double max, double incr);
|
||||
|
||||
// returns a random double value from a negative exponential distribution
|
||||
// with the given mean
|
||||
double RndDoubleNegExp(double mean);
|
||||
|
||||
// returns TRUE or FALSE, with the chance of TRUE being as specified by
|
||||
// (percent)
|
||||
inline bool RndPercent(int percent) {
|
||||
return (RndIntRange(1, 100) <= percent);
|
||||
};
|
||||
|
||||
// Returns a random integer percentage (i.e. whole number between 1 and 100,
|
||||
// inclusive)
|
||||
inline UINT RndGenerateIntegerPercentage() {
|
||||
return ((UINT)RndIntRange(1, 100));
|
||||
}
|
||||
|
||||
/* Returns a non-uniform random 64-bit integer in range of [P .. Q].
|
||||
*
|
||||
* NURnd is used to create a skewed data access pattern. The function is
|
||||
* similar to NURand in TPC-C. (The two functions are identical when C=0
|
||||
* and s=0.)
|
||||
*
|
||||
* The parameter A must be of the form 2^k - 1, so that Rnd[0..A] will
|
||||
* produce a k-bit field with all bits having 50/50 probability of being 0
|
||||
* or 1.
|
||||
*
|
||||
* With a k-bit A value, the weights range from 3^k down to 1 with the
|
||||
* number of equal probability values given by C(k,i) = k! /(i!(k-i)!) for
|
||||
* 0 <= i <= k. So a bigger A value from a larger k has much more skew.
|
||||
*
|
||||
* Left shifting of Rnd[0..A] by "s" bits gets a larger interval without
|
||||
* getting huge amounts of skew. For example, when applied to elapsed time
|
||||
* in milliseconds, s=10 effectively ignores the milliseconds, while s=16
|
||||
* effectively ignores seconds and milliseconds, giving a granularity of
|
||||
* just over 1 minute (65.536 seconds). A smaller A value can then give
|
||||
* the desired amount of skew at effectively one-minute resolution.
|
||||
*/
|
||||
INT64 NURnd(INT64 P, INT64 Q, INT32 A, INT32 s);
|
||||
|
||||
// Returns random alphanumeric string obeying a specific format.
|
||||
// For the format: n - given character must be numeric
|
||||
// a - given character must be alphabetical
|
||||
// Example: "nnnaannnnaannn"
|
||||
void RndAlphaNumFormatted(char *szReturnString, const char *szFormat);
|
||||
};
|
||||
|
||||
} // namespace TPCE
|
||||
|
||||
#endif // RANDOM_H
|
||||
151
external/duckdb/third_party/tpce-tool/include/utilities/TableConsts.h
vendored
Normal file
151
external/duckdb/third_party/tpce-tool/include/utilities/TableConsts.h
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Sergey Vasilevskiy
|
||||
*/
|
||||
|
||||
/*
|
||||
* Table column length constants used by the loader and
|
||||
* transactions.
|
||||
*/
|
||||
#ifndef TABLE_CONSTS_H
|
||||
#define TABLE_CONSTS_H
|
||||
|
||||
#include "EGenStandardTypes.h"
|
||||
|
||||
namespace TPCE {
|
||||
|
||||
// ADDRESS / ZIP_CODE tables
|
||||
const int cTOWN_len = 80;
|
||||
const int cDIV_len = 80;
|
||||
const int cCODE_len = 12;
|
||||
|
||||
// ACCOUNT_PERMISSION table
|
||||
const int cACL_len = 4;
|
||||
|
||||
// ADDRESS table
|
||||
const int cAD_NAME_len = 80;
|
||||
const int cAD_LINE_len = 80;
|
||||
const int cAD_TOWN_len = cTOWN_len;
|
||||
const int cAD_DIV_len = cDIV_len; // state/provice abreviation
|
||||
const int cAD_ZIP_len = cCODE_len;
|
||||
const int cAD_CTRY_len = 80;
|
||||
|
||||
// CASH_TRANSACTION table
|
||||
const int cCT_NAME_len = 100;
|
||||
|
||||
// CUSTOMER table
|
||||
const int cL_NAME_len = 25;
|
||||
const int cF_NAME_len = 20;
|
||||
const int cM_NAME_len = 1;
|
||||
const int cDOB_len = 30;
|
||||
const int cTAX_ID_len = 20;
|
||||
const int cGNDR_len = 1;
|
||||
const int cCTRY_len = 3;
|
||||
const int cAREA_len = 3;
|
||||
const int cLOCAL_len = 10;
|
||||
const int cEXT_len = 5;
|
||||
const int cEMAIL_len = 50;
|
||||
|
||||
// BROKER table
|
||||
const int cB_NAME_len = cF_NAME_len + cM_NAME_len + cL_NAME_len + 3; // two spaces and one period
|
||||
|
||||
// COMPANY table
|
||||
const int cCO_NAME_len = 60;
|
||||
const int cSP_RATE_len = 4;
|
||||
const int cCEO_NAME_len = cF_NAME_len + cL_NAME_len + 1; // one space
|
||||
const int cCO_DESC_len = 150;
|
||||
const int cCO_SP_RATE_len = 4;
|
||||
|
||||
// CUSTOMER_ACCOUNT table
|
||||
const int cCA_NAME_len = 50;
|
||||
|
||||
// EXCHANGE table
|
||||
const int cEX_ID_len = 6;
|
||||
const int cEX_NAME_len = 100;
|
||||
const int cEX_DESC_len = 150;
|
||||
// const int cEX_OPEN_len = 8;
|
||||
// const int cEX_CLOSE_len = 8;
|
||||
|
||||
// HOLDING table
|
||||
const int cH_BUY_DTS_len = 30; // date of purchase
|
||||
|
||||
// INDUSTRY table
|
||||
const int cIN_ID_len = 2;
|
||||
const int cIN_NAME_len = 50;
|
||||
|
||||
// NEWS_ITEM table
|
||||
const int cNI_HEADLINE_len = 80;
|
||||
const int cNI_SUMMARY_len = 255;
|
||||
const int cNI_ITEM_len = 100 * 1000;
|
||||
const int cNI_SOURCE_len = 30;
|
||||
const int cNI_AUTHOR_len = 30;
|
||||
|
||||
// SECURITY table
|
||||
const int cS_NAME_len = 70;
|
||||
const int cSYMBOL_len = 7 + 1 + 7; // base + separator + extended
|
||||
const int cS_ISSUE_len = 6;
|
||||
|
||||
// SETTLEMENT table
|
||||
const int cSE_CASH_TYPE_len = 40;
|
||||
|
||||
// SECTOR table
|
||||
const int cSC_NAME_len = 30;
|
||||
const int cSC_ID_len = 2;
|
||||
|
||||
// STATUS_TYPE table
|
||||
const int cST_ID_len = 4;
|
||||
const int cST_NAME_len = 10;
|
||||
|
||||
// TAX RATE table
|
||||
const int cTX_ID_len = 4;
|
||||
const int cTX_NAME_len = 50;
|
||||
|
||||
// TRADE table
|
||||
const int cEXEC_NAME_len = cF_NAME_len + cM_NAME_len + cL_NAME_len + 3; // two spaces and one extra
|
||||
|
||||
// TRADE_HISTORY table
|
||||
const int cTH_ST_ID_len = cST_ID_len;
|
||||
|
||||
// TRADE TYPE table
|
||||
const int cTT_ID_len = 3;
|
||||
const int cTT_NAME_len = 12;
|
||||
|
||||
// ZIP_CODE table
|
||||
const int cZC_TOWN_len = cTOWN_len;
|
||||
const int cZC_DIV_len = cDIV_len;
|
||||
const int cZC_CODE_len = cCODE_len;
|
||||
|
||||
} // namespace TPCE
|
||||
|
||||
#endif // TABLE_CONSTS_H
|
||||
73
external/duckdb/third_party/tpce-tool/include/utilities/condition.h
vendored
Normal file
73
external/duckdb/third_party/tpce-tool/include/utilities/condition.h
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Christopher Chan-Nui
|
||||
*/
|
||||
|
||||
#ifndef CONDITION_H_INCLUDED
|
||||
#define CONDITION_H_INCLUDED
|
||||
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "locking.h"
|
||||
|
||||
namespace TPCE {
|
||||
|
||||
// Condition class, requires a separate mutex to pair with.
|
||||
class CCondition {
|
||||
private:
|
||||
CMutex &mutex_;
|
||||
#ifdef WIN32
|
||||
mutable CONDITION_VARIABLE cond_;
|
||||
#else
|
||||
mutable pthread_cond_t cond_;
|
||||
bool timedwait(const struct timespec &timeout) const;
|
||||
#endif
|
||||
protected:
|
||||
CMutex &mutex();
|
||||
|
||||
public:
|
||||
CCondition(CMutex &mutex);
|
||||
void wait() const;
|
||||
bool timedwait(long timeout = -1 /*us*/) const;
|
||||
void lock();
|
||||
void unlock();
|
||||
void signal();
|
||||
void broadcast();
|
||||
};
|
||||
|
||||
} // namespace TPCE
|
||||
|
||||
#endif // CONDITION_H_INCLUDED
|
||||
250
external/duckdb/third_party/tpce-tool/include/utilities/error.h
vendored
Normal file
250
external/duckdb/third_party/tpce-tool/include/utilities/error.h
vendored
Normal file
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Sergey Vasilevskiy, Matt Emmerton
|
||||
*/
|
||||
|
||||
#ifndef ERROR_H
|
||||
#define ERROR_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace TPCE {
|
||||
|
||||
#define ERR_TYPE_LOGIC -1 // logic error in program; internal error
|
||||
#define ERR_SUCCESS 0 // success (a non-error error)
|
||||
#define ERR_TYPE_OS 11 // operating system error
|
||||
#define ERR_TYPE_MEMORY 12 // memory allocation error
|
||||
#define ERR_TYPE_FIXED_MAP 27 // Error from CFixedMap
|
||||
#define ERR_TYPE_FIXED_ARRAY 28 // Error from CFixedArray
|
||||
#define ERR_TYPE_CHECK 29 // Check assertion error (from DriverParamSettings)
|
||||
|
||||
#define ERR_INS_MEMORY "Insufficient Memory to continue."
|
||||
#define ERR_UNKNOWN "Unknown error."
|
||||
#define ERR_MSG_BUF_SIZE 512
|
||||
#define INV_ERROR_CODE -1
|
||||
|
||||
class CBaseErr : public std::exception {
|
||||
protected:
|
||||
std::string m_location;
|
||||
int m_idMsg;
|
||||
|
||||
public:
|
||||
CBaseErr() : m_location(), m_idMsg(INV_ERROR_CODE) {
|
||||
}
|
||||
|
||||
CBaseErr(char const *szLoc) : m_location(szLoc), m_idMsg(INV_ERROR_CODE) {
|
||||
}
|
||||
|
||||
CBaseErr(int idMsg) : m_location(), m_idMsg(idMsg) {
|
||||
}
|
||||
|
||||
CBaseErr(int idMsg, char const *szLoc) : m_location(szLoc), m_idMsg(idMsg) {
|
||||
}
|
||||
|
||||
~CBaseErr() throw() {
|
||||
}
|
||||
|
||||
virtual const char *what() const throw() {
|
||||
return ErrorText();
|
||||
}
|
||||
|
||||
virtual int ErrorNum() {
|
||||
return m_idMsg;
|
||||
}
|
||||
virtual int ErrorType() = 0; // a value which distinguishes the kind of
|
||||
// error that occurred
|
||||
|
||||
virtual const char *ErrorText() const = 0; // a string (i.e., human readable) representation of
|
||||
// the error
|
||||
virtual const char *ErrorLoc() {
|
||||
return m_location.c_str();
|
||||
}
|
||||
};
|
||||
|
||||
class CMemoryErr : public CBaseErr {
|
||||
public:
|
||||
CMemoryErr() : CBaseErr() {
|
||||
}
|
||||
|
||||
CMemoryErr(char const *szLoc) : CBaseErr(szLoc) {
|
||||
}
|
||||
|
||||
int ErrorType() {
|
||||
return ERR_TYPE_MEMORY;
|
||||
}
|
||||
const char *ErrorText() const {
|
||||
return ERR_INS_MEMORY;
|
||||
}
|
||||
};
|
||||
|
||||
class CSystemErr : public CBaseErr {
|
||||
public:
|
||||
enum Action {
|
||||
eNone = 0,
|
||||
eTransactNamedPipe,
|
||||
eWaitNamedPipe,
|
||||
eSetNamedPipeHandleState,
|
||||
eCreateFile,
|
||||
eCreateProcess,
|
||||
eCallNamedPipe,
|
||||
eCreateEvent,
|
||||
eCreateThread,
|
||||
eVirtualAlloc,
|
||||
eReadFile = 10,
|
||||
eWriteFile,
|
||||
eMapViewOfFile,
|
||||
eCreateFileMapping,
|
||||
eInitializeSecurityDescriptor,
|
||||
eSetSecurityDescriptorDacl,
|
||||
eCreateNamedPipe,
|
||||
eConnectNamedPipe,
|
||||
eWaitForSingleObject,
|
||||
eRegOpenKeyEx,
|
||||
eRegQueryValueEx = 20,
|
||||
ebeginthread,
|
||||
eRegEnumValue,
|
||||
eRegSetValueEx,
|
||||
eRegCreateKeyEx,
|
||||
eWaitForMultipleObjects,
|
||||
eRegisterClassEx,
|
||||
eCreateWindow,
|
||||
eCreateSemaphore,
|
||||
eReleaseSemaphore,
|
||||
eFSeek,
|
||||
eFRead,
|
||||
eFWrite,
|
||||
eTmpFile,
|
||||
eSetFilePointer,
|
||||
eNew,
|
||||
eCloseHandle,
|
||||
eCreateMutex,
|
||||
eReleaseMutex
|
||||
};
|
||||
|
||||
CSystemErr(Action eAction, char const *szLocation);
|
||||
CSystemErr(int iError, Action eAction, char const *szLocation);
|
||||
int ErrorType() {
|
||||
return ERR_TYPE_OS;
|
||||
};
|
||||
const char *ErrorText(void) const;
|
||||
|
||||
Action m_eAction;
|
||||
|
||||
~CSystemErr() throw() {
|
||||
}
|
||||
};
|
||||
|
||||
class CBaseTxnErr {
|
||||
public:
|
||||
enum {
|
||||
// Expected Transaction Status Values
|
||||
SUCCESS = 0,
|
||||
EXPECTED_ROLLBACK = 1, // returned from Trade-Order Frame 5 to indicate
|
||||
// transaction rollback
|
||||
|
||||
// Unexpected Transaction Status Values
|
||||
// Negative values are errors
|
||||
// Positive values are warnings
|
||||
|
||||
BVF1_ERROR1 = -111, // list_len not in [0..max_broker_list_len]
|
||||
|
||||
CPF1_ERROR1 = -211, // acct_len not in [1..max_acct_len]
|
||||
CPF2_ERROR1 = -221, // hist_len not in [min_hist_len..max_hist_len]
|
||||
|
||||
MFF1_ERROR1 = -311, // num_updated < unique symbols
|
||||
|
||||
MWF1_ERROR1 = -411, // invalid input
|
||||
|
||||
SDF1_ERROR1 = -511, // day_len not in [min_day_len..max_day_len]
|
||||
SDF1_ERROR2 = -512, // fin_len <> max_fin_len
|
||||
SDF1_ERROR3 = -513, // news_len <> max_news_len
|
||||
|
||||
TLF1_ERROR1 = -611, // num_found <> max_trades
|
||||
TLF2_ERROR1 = -621, // num_found not in [0..max_trades]
|
||||
TLF2_WARN1 = +621, // num_found == 0
|
||||
TLF3_ERROR1 = -631, // num_found not in [0..max_trades]
|
||||
TLF3_WARN1 = +631, // num_found == 0
|
||||
TLF4_ERROR1 = -641, // num_trades_found not in [0..1]
|
||||
TLF4_WARN1 = +641, // num_trades_found == 0
|
||||
TLF4_ERROR2 = -642, // num_found not in [1..20]
|
||||
|
||||
TOF1_ERROR1 = -711, // num_found <> 1
|
||||
TOF2_ERROR1 = -721, // ap_acl[0] == '\0'
|
||||
TOF3_ERROR1 = -731, // tax_amount == 0 (for profitable, taxable trade)
|
||||
TOF3_ERROR2 = -732, // comm_rate == 0
|
||||
TOF3_ERROR3 = -733, // charge_amount == 0
|
||||
|
||||
TRF1_ERROR1 = -811, // num_found <> 1
|
||||
TRF3_ERROR1 = -831, // tax_amount < 0
|
||||
TRF4_ERROR1 = -841, // comm_rate <= 0
|
||||
|
||||
TSF1_ERROR1 = -911, // num_found <> max_trade_status_len
|
||||
|
||||
TUF1_ERROR1 = -1011, // num_found <> max_trades
|
||||
TUF1_ERROR2 = -1012, // num_updated <> max_updates
|
||||
TUF2_ERROR1 = -1021, // num_found not in [0..max_trades]
|
||||
TUF2_ERROR2 = -1022, // num_updated <> num_found
|
||||
TUF2_WARN1 = +1021, // num_updated == 0
|
||||
TUF3_ERROR1 = -1031, // num_found not in [0..max_trades]
|
||||
TUF3_ERROR2 = -1032, // num_updated > num_found
|
||||
TUF3_WARN1 = +1031 // num_updated == 0
|
||||
} mErrCode;
|
||||
};
|
||||
|
||||
class CCheckErr : public CBaseErr {
|
||||
private:
|
||||
std::string name_;
|
||||
std::string msg_;
|
||||
|
||||
public:
|
||||
CCheckErr() : CBaseErr() {
|
||||
}
|
||||
|
||||
~CCheckErr() throw() {
|
||||
}
|
||||
|
||||
CCheckErr(const char *name, const std::string &msg) : CBaseErr(name), msg_(msg) {
|
||||
}
|
||||
|
||||
int ErrorType() {
|
||||
return ERR_TYPE_CHECK;
|
||||
}
|
||||
const char *ErrorText() const {
|
||||
return msg_.c_str();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TPCE
|
||||
|
||||
#endif // ERROR_H
|
||||
77
external/duckdb/third_party/tpce-tool/include/utilities/locking.h
vendored
Normal file
77
external/duckdb/third_party/tpce-tool/include/utilities/locking.h
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Christopher Chan-Nui, Matt Emmerton
|
||||
*/
|
||||
|
||||
#ifndef LOCKING_H_INCLUDED
|
||||
#define LOCKING_H_INCLUDED
|
||||
|
||||
#include "EGenStandardTypes.h"
|
||||
|
||||
namespace TPCE {
|
||||
|
||||
// Standard mutex
|
||||
class CMutex {
|
||||
private:
|
||||
TMutex mutex_;
|
||||
TMutex *mutex();
|
||||
|
||||
public:
|
||||
CMutex();
|
||||
~CMutex();
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
friend class CCondition;
|
||||
};
|
||||
|
||||
// Provide a RAII style lock for any class which supports
|
||||
// lock() and unlock()
|
||||
template <typename T> class Locker {
|
||||
private:
|
||||
T &mutex_;
|
||||
|
||||
public:
|
||||
explicit Locker<T>(T &mutex) : mutex_(mutex) {
|
||||
mutex_.lock();
|
||||
}
|
||||
|
||||
~Locker<T>() {
|
||||
mutex_.unlock();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TPCE
|
||||
|
||||
#endif // LOCKING_H_INCLUDED
|
||||
177
external/duckdb/third_party/tpce-tool/include/utilities/threading.h
vendored
Normal file
177
external/duckdb/third_party/tpce-tool/include/utilities/threading.h
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Chris Chan-nui, Matt Emmerton
|
||||
*/
|
||||
|
||||
#ifndef THREADING_H_INCLUDED
|
||||
#define THREADING_H_INCLUDED
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <sstream>
|
||||
#include <cstring>
|
||||
#endif
|
||||
|
||||
#include "EGenStandardTypes.h"
|
||||
|
||||
namespace TPCE {
|
||||
|
||||
// Base class to provide a run() method for objects which can be threaded.
|
||||
// This is required because under pthreads we have to provide an interface
|
||||
// through a C ABI call, which we can't do with templated classes.
|
||||
class ThreadBase {
|
||||
public:
|
||||
virtual ~ThreadBase();
|
||||
virtual void invoke() = 0;
|
||||
};
|
||||
|
||||
// Call the run() method of passed argument. Always returns NULL.
|
||||
#ifdef WIN32
|
||||
DWORD WINAPI start_thread(LPVOID arg);
|
||||
#else
|
||||
extern "C" void *start_thread(void *arg);
|
||||
#endif
|
||||
|
||||
// Template to wrap around a class that has a ThreadBase::run() method and
|
||||
// spawn it in a thread of its own.
|
||||
template <typename T> class Thread : public ThreadBase {
|
||||
private:
|
||||
std::unique_ptr<T> obj_;
|
||||
TThread tid_;
|
||||
#ifndef WIN32
|
||||
TThreadAttr attr_;
|
||||
#endif
|
||||
int stacksize_;
|
||||
|
||||
public:
|
||||
Thread(std::unique_ptr<T> throbj)
|
||||
: obj_(throbj), tid_()
|
||||
#ifndef WIN32
|
||||
,
|
||||
attr_()
|
||||
#endif
|
||||
,
|
||||
stacksize_(0) {
|
||||
#ifndef WIN32
|
||||
pthread_attr_init(&attr_);
|
||||
#endif
|
||||
}
|
||||
Thread(std::unique_ptr<T> throbj, int stacksize)
|
||||
: obj_(throbj), tid_()
|
||||
#ifndef WIN32
|
||||
,
|
||||
attr_()
|
||||
#endif
|
||||
,
|
||||
stacksize_(stacksize) {
|
||||
#ifndef WIN32
|
||||
pthread_attr_init(&attr_);
|
||||
#endif
|
||||
}
|
||||
T *obj() {
|
||||
return obj_.get();
|
||||
}
|
||||
void invoke() {
|
||||
obj_->run(this);
|
||||
}
|
||||
void start();
|
||||
void stop();
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// Windows Implementation
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
template <typename T> void Thread<T>::start() {
|
||||
tid_ = CreateThread(NULL, stacksize_, start_thread, this, NULL, NULL);
|
||||
if (tid_ == NULL) {
|
||||
std::ostringstream strm;
|
||||
strm << "CreateThread error: " << GetLastError();
|
||||
throw std::runtime_error(strm.str());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T> void Thread<T>::stop() {
|
||||
DWORD rc = WaitForSingleObject(tid_, INFINITE);
|
||||
if (rc != 0) {
|
||||
std::ostringstream strm;
|
||||
strm << "WaitForSingleObject error: " << GetLastError();
|
||||
throw std::runtime_error(strm.str());
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// Non-Windows (pthread) Implementation
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
#else
|
||||
|
||||
template <typename T> void Thread<T>::start() {
|
||||
int rc = 0;
|
||||
|
||||
if (stacksize_ > 0) {
|
||||
rc = pthread_attr_setstacksize(&attr_, stacksize_);
|
||||
if (rc != 0) {
|
||||
std::ostringstream strm;
|
||||
strm << "pthread_attr_setstacksize error: " << strerror(rc) << "(" << rc << ")";
|
||||
throw std::runtime_error(strm.str());
|
||||
}
|
||||
}
|
||||
|
||||
rc = pthread_create(&tid_, &attr_, start_thread, this);
|
||||
if (rc != 0) {
|
||||
std::ostringstream strm;
|
||||
strm << "pthread_create error: " << strerror(rc) << "(" << rc << ")";
|
||||
throw std::runtime_error(strm.str());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T> void Thread<T>::stop() {
|
||||
int rc = pthread_join(tid_, NULL);
|
||||
if (rc != 0) {
|
||||
std::ostringstream strm;
|
||||
strm << "pthread_join error: " << strerror(rc) << "(" << rc << ")";
|
||||
throw std::runtime_error(strm.str());
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace TPCE
|
||||
|
||||
#endif // THREADING_H_INCLUDED
|
||||
Reference in New Issue
Block a user