should be it

This commit is contained in:
2025-10-24 19:21:19 -05:00
parent a4b23fc57c
commit f09560c7b1
14047 changed files with 3161551 additions and 1 deletions

View File

@@ -0,0 +1,81 @@
#ifndef AREA_CODE_DATA_FILE_RECORD_H
#define AREA_CODE_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the AreaCode data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class AreaCodeDataFileRecord {
private:
static const int maxAreaCodeLen = 3;
char areaCodeCStr[maxAreaCodeLen + 1];
std::string areaCode;
static const unsigned int fieldCount = 1;
public:
explicit AreaCodeDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~AreaCodeDataFileRecord()
// AreaCodeDataFileRecord(const AreaCodeDataFileRecord&);
// AreaCodeDataFileRecord& operator=(const AreaCodeDataFileRecord&);
//
const std::string &AREA_CODE() const;
const char *AREA_CODE_CSTR() const;
std::string ToString() const;
};
} // namespace TPCE
#endif // AREA_CODE_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,148 @@
#ifndef BUCKETED_DATA_FILE_H
#define BUCKETED_DATA_FILE_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
*/
#include <vector>
//#include <string> // for stoi C++11
#include <cstdlib> // for atoi
#include "ITextSplitter.h"
#include "ShrinkToFit.h"
namespace TPCE {
//
// Description:
// A template class for converting a series of text records into a
// bucketed binary in-memory structure for quick easy access.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
//
// Assumptions:
// - bucket IDs start at 1.
// - records are sorted by bucket ID smallest to largest.
//
template <class T> class BucketedDataFile {
public:
// Leverage the size type of our underlying storage container but
// insulate clients from the implementation particulars by creating
// our own type.
// Set this first so we can use it for recordCount.
typedef typename std::vector<T>::size_type size_type;
private:
std::vector<std::vector<T>> buckets;
size_type recordCount;
public:
enum SizeFilter { AllRecords, BucketsOnly };
explicit BucketedDataFile(ITextSplitter &splitter) : recordCount(0) {
// eof only returns true after trying to read the end, so
// "prime the pump" by doing an initial read.
std::deque<std::string> fields = splitter.getNextRecord();
// Process each record.
while (!splitter.eof()) {
if (1 == fields.size() && "" == fields[0]) {
// We found a blank line so skip it and move on.
fields = splitter.getNextRecord();
continue;
}
// The first field is the bucket ID for this record.
// int bucketID = std::stoi(fields[0]); // C++11
unsigned int bucketID = std::atoi(fields[0].c_str());
fields.pop_front();
if (buckets.size() == bucketID - 1) {
// First record of a new bucket so add the bucket.
buckets.push_back(std::vector<T>());
}
// Now we know the bucket exists so go ahead and add the record.
buckets[bucketID - 1].push_back(T(fields));
++recordCount;
// Move on to the next record.
fields = splitter.getNextRecord();
}
// Now that everything has been loaded tighten up our storage.
// NOTE: shrinking the outer bucket vector has the side effect of
// shrinking all the internal bucket vectors.
shrink_to_fit<std::vector<std::vector<T>>>(buckets);
// buckets.shrink_to_fit(); // C++11
}
//
// Default copies and destructor are ok.
//
// ~BucketedDataFile();
// BucketedDataFile(const BucketedDataFile&);
// BucketedDataFile& operator=(const BucketedDataFile&);
//
size_type size(SizeFilter filter = AllRecords) const {
return (filter == AllRecords ? recordCount : buckets.size());
}
// Provide 0-based access to the buckets.
const std::vector<T> &operator[](size_type idx) const {
return buckets[idx];
}
// Provide range-checked 0-based access to the buckets.
const std::vector<T> &at(size_type idx) const {
return buckets.at(idx);
}
// Provide range-checked bucket-ID-based access by to the buckets.
const std::vector<T> &getBucket(size_type bucketID, bool rangeCheckedAccess = false) const {
size_type idx = bucketID - 1;
return (rangeCheckedAccess ? buckets.at(idx) : buckets[idx]);
}
};
} // namespace TPCE
#endif // BUCKETED_DATA_FILE_H

View File

@@ -0,0 +1,87 @@
#ifndef CHARGE_DATA_FILE_RECORD_H
#define CHARGE_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the Charge data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class ChargeDataFileRecord {
private:
static const int maxCh_tt_idLen = 3;
char ch_tt_idCStr[maxCh_tt_idLen + 1];
std::string ch_tt_id;
int ch_c_tier;
double ch_chrg;
static const unsigned int fieldCount = 3;
public:
explicit ChargeDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~ChargeDataFileRecord()
// ChargeDataFileRecord(const ChargeDataFileRecord&);
// ChargeDataFileRecord& operator=(const ChargeDataFileRecord&);
//
const std::string &CH_TT_ID() const;
const char *CH_TT_ID_CSTR() const;
int CH_C_TIER() const;
double CH_CHRG() const;
std::string ToString(char fieldSeparator = '\t') const;
};
} // namespace TPCE
#endif // CHARGE_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,101 @@
#ifndef COMMISSION_RATE_DATA_FILE_RECORD_H
#define COMMISSION_RATE_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the CommissionRate data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class CommissionRateDataFileRecord {
private:
int cr_c_tier;
static const int maxCr_tt_idLen = 3;
char cr_tt_idCStr[maxCr_tt_idLen + 1];
std::string cr_tt_id;
static const int maxCr_ex_idLen = 6;
char cr_ex_idCStr[maxCr_ex_idLen + 1];
std::string cr_ex_id;
int cr_from_qty;
int cr_to_qty;
double cr_rate;
static const unsigned int fieldCount = 6;
public:
explicit CommissionRateDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~CommissionRateDataFileRecord()
// CommissionRateDataFileRecord(const CommissionRateDataFileRecord&);
// CommissionRateDataFileRecord& operator=(const
// CommissionRateDataFileRecord&);
//
int CR_C_TIER() const;
const std::string &CR_TT_ID() const;
const char *CR_TT_ID_CSTR() const;
const std::string &CR_EX_ID() const;
const char *CR_EX_ID_CSTR() const;
int CR_FROM_QTY() const;
int CR_TO_QTY() const;
double CR_RATE() const;
std::string ToString(char fieldSeparator = '\t') const;
};
} // namespace TPCE
#endif // COMMISSION_RATE_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,90 @@
#ifndef COMPANY_COMPETITOR_DATA_FILE_RECORD_H
#define COMPANY_COMPETITOR_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
#include "utilities/EGenStandardTypes.h"
namespace TPCE {
//
// Description:
// A class to represent a single record in the CompanyCompetitor data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class CompanyCompetitorDataFileRecord {
private:
TIdent cp_co_id;
TIdent cp_comp_co_id;
static const int maxCp_in_idLen = 2;
char cp_in_idCStr[maxCp_in_idLen + 1];
std::string cp_in_id;
static const int unsigned fieldCount = 3;
public:
explicit CompanyCompetitorDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~CompanyCompetitorDataFileRecord()
// CompanyCompetitorDataFileRecord(const CompanyCompetitorDataFileRecord&);
// CompanyCompetitorDataFileRecord& operator=(const
// CompanyCompetitorDataFileRecord&);
//
TIdent CP_CO_ID() const;
TIdent CP_COMP_CO_ID() const;
const std::string &CP_IN_ID() const;
const char *CP_IN_ID_CSTR() const;
std::string ToString(char fieldSeparator = '\t') const;
};
} // namespace TPCE
#endif // COMPANY_COMPETITOR_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,186 @@
/*
* 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
* - Doug Johnson
*/
/******************************************************************************
* Description: Implementation of the Company Competitor input file
* that scales with the database size.
******************************************************************************/
#ifndef COMPANY_COMPETITOR_FILE_H
#define COMPANY_COMPETITOR_FILE_H
#include <string>
#include "utilities/EGenStandardTypes.h"
#include "DataFileTypes.h"
namespace TPCE {
class CCompanyCompetitorFile {
CompanyCompetitorDataFile_t const *m_dataFile;
// Configured and active number of companies in the database.
// Depends on the configured and active number of customers.
//
TIdent m_iConfiguredCompanyCompetitorCount;
TIdent m_iActiveCompanyCompetitorCount;
// Number of base companies (=rows in Company.txt input file).
//
UINT m_iBaseCompanyCount;
public:
/*
* Constructor.
*
* PARAMETERS:
* IN dataFile - CompanyCompetitorDataFile
* IN iConfiguredCustomerCount - total configured number of
* customers in the database IN iActiveCustomerCount - active number
* of customers in the database (provided for engineering purposes)
*
* RETURNS:
* not applicable.
*/
CCompanyCompetitorFile(const CompanyCompetitorDataFile_t &dataFile, TIdent iConfiguredCustomerCount,
TIdent iActiveCustomerCount, UINT baseCompanyCount);
/*
* Calculate company competitor count for the specified number of
* customers. Sort of a static method. Used in parallel generation of
* company related tables.
*
* PARAMETERS:
* IN iCustomerCount - number of customers
*
* RETURNS:
* number of company competitors.
*/
TIdent CalculateCompanyCompetitorCount(TIdent iCustomerCount) const;
/*
* Calculate the first company competitor id (0-based) for the specified
* customer id.
*
* PARAMETERS:
* IN iStartFromCustomer - customer id
*
* RETURNS:
* company competitor id.
*/
TIdent CalculateStartFromCompanyCompetitor(TIdent iStartFromCustomer) const;
/*
* Return company id for the specified row.
* Index can exceed the size of the Company Competitor input file.
*
* PARAMETERS:
* IN iIndex - row number in the Company Competitor file
* (0-based)
*
* RETURNS:
* company id.
*/
TIdent GetCompanyId(TIdent iIndex) const;
/*
* Return company competitor id for the specified row.
* Index can exceed the size of the Company Competitor input file.
*
* PARAMETERS:
* IN iIndex - row number in the Company Competitor file
* (0-based)
*
* RETURNS:
* company competitor id.
*/
TIdent GetCompanyCompetitorId(TIdent iIndex) const;
/*
* Return industry id for the specified row.
* Index can exceed the size of the Company Competitor input file.
*
* PARAMETERS:
* IN iIndex - row number in the Company Competitor file
* (0-based)
*
* RETURNS:
* industry id.
*/
const std::string &GetIndustryId(TIdent iIndex) const;
const char *GetIndustryIdCSTR(TIdent iIndex) const;
/*
* Return the number of company competitors in the database for
* the configured number of customers.
*
* PARAMETERS:
* none.
*
* RETURNS:
* configured company competitor count.
*/
TIdent GetConfiguredCompanyCompetitorCount() const;
/*
* Return the number of company competitors in the database for
* the active number of customers.
*
* PARAMETERS:
* none.
*
* RETURNS:
* active company competitor count.
*/
TIdent GetActiveCompanyCompetitorCount() const;
/*
* Overload GetRecord to wrap around indices that
* are larger than the flat file
*
* PARAMETERS:
* IN iIndex - row number in the Company Competitor file
* (0-based)
*
* RETURNS:
* reference to the row structure in the Company Competitor file.
*/
const CompanyCompetitorDataFileRecord &GetRecord(TIdent index) const;
};
} // namespace TPCE
#endif // COMPANY_COMPETITOR_FILE_H

View File

@@ -0,0 +1,108 @@
#ifndef COMPANY_DATA_FILE_RECORD_H
#define COMPANY_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
#include "utilities/EGenStandardTypes.h"
namespace TPCE {
//
// Description:
// A class to represent a single record in the Company data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class CompanyDataFileRecord {
private:
TIdent co_id;
static const int maxCo_st_idLen = 4;
char co_st_idCStr[maxCo_st_idLen + 1];
std::string co_st_id;
static const int maxCo_nameLen = 60;
char co_nameCStr[maxCo_nameLen + 1];
std::string co_name;
static const int maxCo_in_idLen = 2;
char co_in_idCStr[maxCo_in_idLen + 1];
std::string co_in_id;
static const int maxCo_descLen = 150;
char co_descCStr[maxCo_descLen + 1];
std::string co_desc;
static const unsigned int fieldCount = 5;
public:
explicit CompanyDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~CompanyDataFileRecord()
// CompanyDataFileRecord(const CompanyDataFileRecord&);
// CompanyDataFileRecord& operator=(const CompanyDataFileRecord&);
//
TIdent CO_ID() const;
const std::string &CO_ST_ID() const;
const char *CO_ST_ID_CSTR() const;
const std::string &CO_NAME() const;
const char *CO_NAME_CSTR() const;
const std::string &CO_IN_ID() const;
const char *CO_IN_ID_CSTR() const;
const std::string &CO_DESC() const;
const char *CO_DESC_CSTR() const;
std::string ToString(char fieldSeparator = '\t') const;
};
} // namespace TPCE
#endif // COMPANY_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,181 @@
/*
* 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
* - Doug Johnson
*/
/******************************************************************************
* Description: Implementation of the Company input file that scales
* with the database size.
******************************************************************************/
#ifndef COMPANY_FILE_H
#define COMPANY_FILE_H
#include "utilities/EGenStandardTypes.h"
#include "DataFileTypes.h"
namespace TPCE {
class CCompanyFile {
CompanyDataFile_t const *m_dataFile;
// Configured and active number of companies in the database.
// Depends on the configured and active number of customers.
//
TIdent m_iConfiguredCompanyCount;
TIdent m_iActiveCompanyCount;
public:
/*
* Constructor.
*
* PARAMETERS:
* IN str - file name of the
* CompanyCompetitor input flat file IN iConfiguredCustomerCount - total
* configured number of customers in the database IN iActiveCustomerCount
* - active number of customers in the database (provided for engineering
* purposes)
*
* RETURNS:
* not applicable.
*/
CCompanyFile(const CompanyDataFile_t &dataFile, TIdent iConfiguredCustomerCount, TIdent iActiveCustomerCount);
/*
* Calculate company count for the specified number of customers.
* Sort of a static method. Used in parallel generation of company related
* tables.
*
* PARAMETERS:
* IN iCustomerCount - number of customers
*
* RETURNS:
* number of company competitors.
*/
TIdent CalculateCompanyCount(TIdent iCustomerCount) const;
/*
* Calculate the first company id (0-based) for the specified customer id.
*
* PARAMETERS:
* IN iStartFromCustomer - customer id
*
* RETURNS:
* company competitor id.
*/
TIdent CalculateStartFromCompany(TIdent iStartFromCustomer) const;
/*
* Create company name with appended suffix based on the
* load unit number.
*
* PARAMETERS:
* IN iIndex - row number in the Company Competitor file
* (0-based) IN szOutput - output buffer for company name IN iOutputLen
* - size of the output buffer
*
* RETURNS:
* none.
*/
void CreateName(TIdent iIndex, // row number
char *szOutput, // output buffer
size_t iOutputLen // size of the output buffer
) const;
/*
* Return company id for the specified row.
* Index can exceed the size of the Company input file.
*
* PARAMETERS:
* IN iIndex - row number in the Company Competitor file
* (0-based)
*
* RETURNS:
* company id.
*/
TIdent GetCompanyId(TIdent iIndex) const;
/*
* Return the number of companies in the database for
* the configured number of customers.
*
* PARAMETERS:
* none.
*
* RETURNS:
* number of rows in the file.
*/
TIdent GetSize() const;
/*
* Return the number of companies in the database for
* the configured number of customers.
*
* PARAMETERS:
* none.
*
* RETURNS:
* configured company count.
*/
TIdent GetConfiguredCompanyCount() const;
/*
* Return the number of companies in the database for
* the active number of customers.
*
* PARAMETERS:
* none.
*
* RETURNS:
* active company count.
*/
TIdent GetActiveCompanyCount() const;
/*
* Overload GetRecord to wrap around indices that
* are larger than the flat file
*
* PARAMETERS:
* IN iIndex - row number in the Company file (0-based)
*
* RETURNS:
* reference to the row structure in the Company file.
*/
const CompanyDataFileRecord &GetRecord(TIdent index) const;
};
} // namespace TPCE
#endif // COMPANY_FILE_H

View File

@@ -0,0 +1,82 @@
#ifndef COMPANY_SP_RATE_DATA_FILE_RECORD_H
#define COMPANY_SP_RATE_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the CompanySPRate data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class CompanySPRateDataFileRecord {
private:
static const int maxCo_sp_rateLen = 4;
char co_sp_rateCStr[maxCo_sp_rateLen + 1];
std::string co_sp_rate;
static const unsigned int fieldCount = 1;
public:
explicit CompanySPRateDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~CompanySPRateDataFileRecord()
// CompanySPRateDataFileRecord(const CompanySPRateDataFileRecord&);
// CompanySPRateDataFileRecord& operator=(const
// CompanySPRateDataFileRecord&);
//
const std::string &CO_SP_RATE() const;
const char *CO_SP_RATE_CSTR() const;
std::string ToString() const;
};
} // namespace TPCE
#endif // COMPANY_SP_RATE_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,121 @@
#ifndef DATA_FILE_H
#define DATA_FILE_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
*/
#include <deque>
#include <sstream>
#include <string>
#include <vector>
#include <stdexcept>
#include "ITextSplitter.h"
#include "ShrinkToFit.h"
namespace TPCE {
//
// Description:
// A template class for converting a series of text records into a binary
// in-memory structure for quick easy access.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
template <class RecordType> class DataFile {
private:
typedef std::vector<RecordType> Records; // For convenience and readability
Records records;
public:
// Leverage the size type of our underlying storage container but
// insulate clients from the implementation particulars by creating
// our own type.
typedef typename Records::size_type size_type;
explicit DataFile(ITextSplitter &splitter) {
// eof only returns true after trying to read the end, so
// "prime the pump" by doing an initial read.
std::deque<std::string> fields = splitter.getNextRecord();
// Process each record.
while (!splitter.eof()) {
if (1 == fields.size() && "" == fields[0]) {
// We found a blank line so skip it and move on.
fields = splitter.getNextRecord();
continue;
}
// Add the record.
records.push_back(RecordType(fields));
// Move on to the next record.
fields = splitter.getNextRecord();
}
// Now that everything has been loaded tighten up our storage.
shrink_to_fit<Records>(records);
// records.shrink_to_fit(); // C++11
}
//
// Default copies and destructor are ok.
//
// ~DataFile();
// DataFile(const DataFile&);
// DataFile& operator=(const DataFile&);
//
size_type size() const {
return records.size();
}
// Provide un-checked const access to the records.
const RecordType &operator[](size_type idx) const {
return records[idx];
}
// Provide range-checked const access to the records.
const RecordType &at(size_type idx) const {
return records.at(idx);
}
};
} // namespace TPCE
#endif // DATA_FILE_H

View File

@@ -0,0 +1,185 @@
#ifndef DATA_FILE_MANAGER_H
#define DATA_FILE_MANAGER_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
*/
#include <istream>
#include <string>
#include "DataFileTypes.h"
#include "StreamSplitter.h"
#include "utilities/EGenStandardTypes.h"
#include "CompanyCompetitorFile.h"
#include "CompanyFile.h"
#include "SecurityFile.h"
#include "TaxRateFile.h"
#include "utilities/MiscConsts.h"
namespace TPCE {
//
// Description:
// A class for managing all data files. There are several important
// characteristics of this class.
//
// - Thread Saftey. This class is currently not thread safe. The onus is on
// the client to make sure this class is used safely in a multi-threaded
// environment.
//
// - Load Type. This class supports both immediate and lazy loading of the data
// files. The type of load can be specified at object creation time.
//
// - Const-ness. Because of the lazy-load, const-correctness is a bit funky. In
// general, logical constness is what is honored. Public interfaces that clearly
// alter things are not considered const but lazy loading of a file on file
// access is considered const even though that lazy load may trigger an
// exception (e.g. if the file doesn't exist).
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is disallowed.
//
class DataFileManager {
private:
// Disallow copying.
DataFileManager(const DataFileManager &);
DataFileManager &operator=(const DataFileManager &);
// Customer counts needed for scaling file abstractions.
TIdent configuredCustomers;
TIdent activeCustomers;
// Data Files (mutable to support const-appearing lazy load)
mutable AreaCodeDataFile_t *areaCodeDataFile;
mutable ChargeDataFile_t *chargeDataFile;
mutable CommissionRateDataFile_t *commissionRateDataFile;
mutable CompanyCompetitorDataFile_t *companyCompetitorDataFile;
mutable CompanyDataFile_t *companyDataFile;
mutable CompanySPRateDataFile_t *companySPRateDataFile;
mutable ExchangeDataFile_t *exchangeDataFile;
mutable FemaleFirstNameDataFile_t *femaleFirstNameDataFile;
mutable IndustryDataFile_t *industryDataFile;
mutable LastNameDataFile_t *lastNameDataFile;
mutable MaleFirstNameDataFile_t *maleFirstNameDataFile;
mutable NewsDataFile_t *newsDataFile;
mutable NonTaxableAccountNameDataFile_t *nonTaxableAccountNameDataFile;
mutable SectorDataFile_t *sectorDataFile;
mutable SecurityDataFile_t *securityDataFile;
mutable StatusTypeDataFile_t *statusTypeDataFile;
mutable StreetNameDataFile_t *streetNameDataFile;
mutable StreetSuffixDataFile_t *streetSuffixDataFile;
mutable TaxableAccountNameDataFile_t *taxableAccountNameDataFile;
mutable TaxRateCountryDataFile_t *taxRateCountryDataFile;
mutable TaxRateDivisionDataFile_t *taxRateDivisionDataFile;
mutable TradeTypeDataFile_t *tradeTypeDataFile;
mutable ZipCodeDataFile_t *zipCodeDataFile;
// Scaling Data File Abstractions (mutable to support const-appearing lazy
// load)
mutable CCompanyCompetitorFile *companyCompetitorFile;
mutable CCompanyFile *companyFile;
mutable CSecurityFile *securityFile;
mutable CTaxRateFile *taxRateFile;
// Template for loading any file.
// Logically const for lazy load.
// If the file has already been loaded then no action is taken.
template <class SourceFileT, class SplitterT, class DataFileT>
void loadFile(SourceFileT sourceFile, DataFileT **dataFile) const {
// Only load if it hasn't already been loaded.
if (!(*dataFile)) {
SplitterT splitter(sourceFile);
*dataFile = new DataFileT(splitter);
}
}
// Helper method for lazy loading (hence logically const) by file type.
void loadFile(DataFileType fileType) const;
// Centralized clean up of any allocated resources.
void CleanUp();
public:
// Constructor - default to lazy load from the current directory
// for the default number of customers.
explicit DataFileManager(TIdent configuredCustomerCount = iDefaultCustomerCount,
TIdent activeCustomerCount = iDefaultCustomerCount);
~DataFileManager();
// Load a file using an istream.
void loadFile(std::istream &file, DataFileType fileType);
// Load a file using a file type.
void loadFile(DataFileType fileType);
// Accessors for files.
const AreaCodeDataFile_t &AreaCodeDataFile() const;
const ChargeDataFile_t &ChargeDataFile() const;
const CommissionRateDataFile_t &CommissionRateDataFile() const;
const CompanyCompetitorDataFile_t &CompanyCompetitorDataFile() const;
const CompanyDataFile_t &CompanyDataFile() const;
const CompanySPRateDataFile_t &CompanySPRateDataFile() const;
const ExchangeDataFile_t &ExchangeDataFile() const;
const FemaleFirstNameDataFile_t &FemaleFirstNameDataFile() const;
const IndustryDataFile_t &IndustryDataFile() const;
const LastNameDataFile_t &LastNameDataFile() const;
const MaleFirstNameDataFile_t &MaleFirstNameDataFile() const;
const NewsDataFile_t &NewsDataFile() const;
const NonTaxableAccountNameDataFile_t &NonTaxableAccountNameDataFile() const;
const SectorDataFile_t &SectorDataFile() const;
const SecurityDataFile_t &SecurityDataFile() const;
const StatusTypeDataFile_t &StatusTypeDataFile() const;
const StreetNameDataFile_t &StreetNameDataFile() const;
const StreetSuffixDataFile_t &StreetSuffixDataFile() const;
const TaxableAccountNameDataFile_t &TaxableAccountNameDataFile() const;
const TaxRateCountryDataFile_t &TaxRateCountryDataFile() const;
const TaxRateDivisionDataFile_t &TaxRateDivisionDataFile() const;
const TradeTypeDataFile_t &TradeTypeDataFile() const;
const ZipCodeDataFile_t &ZipCodeDataFile() const;
// Data file abstractions.
const CCompanyCompetitorFile &CompanyCompetitorFile() const;
const CCompanyFile &CompanyFile() const;
const CSecurityFile &SecurityFile() const;
const CTaxRateFile &TaxRateFile() const;
};
} // namespace TPCE
#endif // DATA_FILE_MANAGER_H

View File

@@ -0,0 +1,156 @@
#ifndef DATA_FILE_TYPES_H
#define DATA_FILE_TYPES_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
*/
#include <string>
// General data file types.
#include "DataFile.h"
#include "WeightedDataFile.h"
#include "BucketedDataFile.h"
// Specific data file types.
#include "AreaCodeDataFileRecord.h"
#include "ChargeDataFileRecord.h"
#include "CommissionRateDataFileRecord.h"
#include "CompanyCompetitorDataFileRecord.h"
#include "CompanyDataFileRecord.h"
#include "CompanySPRateDataFileRecord.h"
#include "ExchangeDataFileRecord.h"
#include "FemaleFirstNameDataFileRecord.h"
#include "IndustryDataFileRecord.h"
#include "LastNameDataFileRecord.h"
#include "MaleFirstNameDataFileRecord.h"
#include "NewsDataFileRecord.h"
#include "NonTaxableAccountNameDataFileRecord.h"
#include "SectorDataFileRecord.h"
#include "SecurityDataFileRecord.h"
#include "StatusTypeDataFileRecord.h"
#include "StreetNameDataFileRecord.h"
#include "StreetSuffixDataFileRecord.h"
#include "TaxableAccountNameDataFileRecord.h"
#include "TaxRateCountryDataFileRecord.h"
#include "TaxRateDivisionDataFileRecord.h"
#include "TradeTypeDataFileRecord.h"
#include "ZipCodeDataFileRecord.h"
namespace TPCE {
// For convenience provide a type for each specific data file type.
typedef WeightedDataFile<AreaCodeDataFileRecord> AreaCodeDataFile_t;
typedef DataFile<ChargeDataFileRecord> ChargeDataFile_t;
typedef DataFile<CommissionRateDataFileRecord> CommissionRateDataFile_t;
typedef DataFile<CompanyCompetitorDataFileRecord> CompanyCompetitorDataFile_t;
typedef DataFile<CompanyDataFileRecord> CompanyDataFile_t;
typedef WeightedDataFile<CompanySPRateDataFileRecord> CompanySPRateDataFile_t;
typedef DataFile<ExchangeDataFileRecord> ExchangeDataFile_t;
typedef WeightedDataFile<FemaleFirstNameDataFileRecord> FemaleFirstNameDataFile_t;
typedef DataFile<IndustryDataFileRecord> IndustryDataFile_t;
typedef WeightedDataFile<LastNameDataFileRecord> LastNameDataFile_t;
typedef WeightedDataFile<MaleFirstNameDataFileRecord> MaleFirstNameDataFile_t;
typedef WeightedDataFile<NewsDataFileRecord> NewsDataFile_t;
typedef DataFile<NonTaxableAccountNameDataFileRecord> NonTaxableAccountNameDataFile_t;
typedef DataFile<SectorDataFileRecord> SectorDataFile_t;
typedef DataFile<SecurityDataFileRecord> SecurityDataFile_t;
typedef DataFile<StatusTypeDataFileRecord> StatusTypeDataFile_t;
typedef WeightedDataFile<StreetNameDataFileRecord> StreetNameDataFile_t;
typedef WeightedDataFile<StreetSuffixDataFileRecord> StreetSuffixDataFile_t;
typedef DataFile<TaxableAccountNameDataFileRecord> TaxableAccountNameDataFile_t;
typedef BucketedDataFile<TaxRateCountryDataFileRecord> TaxRateCountryDataFile_t;
typedef BucketedDataFile<TaxRateDivisionDataFileRecord> TaxRateDivisionDataFile_t;
typedef DataFile<TradeTypeDataFileRecord> TradeTypeDataFile_t;
typedef WeightedDataFile<ZipCodeDataFileRecord> ZipCodeDataFile_t;
// WARNING: the DataFileManager constructor is tightly coupled to the order of
// this enum. List of file types.
enum DataFileType {
AREA_CODE_DATA_FILE,
CHARGE_DATA_FILE,
COMMISSION_RATE_DATA_FILE,
COMPANY_COMPETITOR_DATA_FILE,
COMPANY_DATA_FILE,
COMPANY_SP_RATE_DATA_FILE,
EXCHANGE_DATA_FILE,
FEMALE_FIRST_NAME_DATA_FILE,
INDUSTRY_DATA_FILE,
LAST_NAME_DATA_FILE,
MALE_FIRST_NAME_DATA_FILE,
NEWS_DATA_FILE,
NON_TAXABLE_ACCOUNT_NAME_DATA_FILE,
SECTOR_DATA_FILE,
SECURITY_DATA_FILE,
STATUS_TYPE_DATA_FILE,
STREET_NAME_DATA_FILE,
STREET_SUFFIX_DATA_FILE,
TAXABLE_ACCOUNT_NAME_DATA_FILE,
TAX_RATE_COUNTRY_DATA_FILE,
TAX_RATE_DIVISION_DATA_FILE,
TRADE_TYPE_DATA_FILE,
ZIPCODE_DATA_FILE
};
// Default data file names.
static const char *const DataFileNames[] = {"AreaCode",
"Charge",
"CommissionRate",
"CompanyCompetitor",
"Company",
"CompanySPRate",
"Exchange",
"FemaleFirstName",
"Industry",
"LastName",
"MaleFirstName",
"LastName", // News uses last names as a source of words.
"NonTaxableAccountName",
"Sector",
"Security",
"StatusType",
"StreetName",
"StreetSuffix",
"TaxableAccountName",
"TaxRatesCountry",
"TaxRatesDivision",
"TradeType",
"ZipCode"};
// Default data file extension.
static const std::string DataFileExtension(".txt");
} // namespace TPCE
#endif // DATA_FILE_TYPES_H

View File

@@ -0,0 +1,107 @@
#ifndef EXCHANGE_DATA_FILE_RECORD_H
#define EXCHANGE_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
#include "utilities/EGenStandardTypes.h"
namespace TPCE {
//
// Description:
// A class to represent a single record in the Exchange data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class ExchangeDataFileRecord {
private:
static const int maxEx_idLen = 6;
char ex_idCStr[maxEx_idLen + 1];
std::string ex_id;
static const int maxEx_nameLen = 100;
char ex_nameCStr[maxEx_nameLen + 1];
std::string ex_name;
int ex_open;
int ex_close;
static const int maxEx_descLen = 150;
char ex_descCStr[maxEx_descLen + 1];
std::string ex_desc;
TIdent ex_ad_id;
static const int unsigned fieldCount = 6;
public:
explicit ExchangeDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~ExchangeDataFileRecord()
// ExchangeDataFileRecord(const ExchangeDataFileRecord&);
// ExchangeDataFileRecord& operator=(const ExchangeDataFileRecord&);
//
const std::string &EX_ID() const;
const char *EX_ID_CSTR() const;
const std::string &EX_NAME() const;
const char *EX_NAME_CSTR() const;
int EX_OPEN() const;
int EX_CLOSE() const;
const std::string &EX_DESC() const;
const char *EX_DESC_CSTR() const;
TIdent EX_AD_ID() const;
std::string ToString(char fieldSeparator = '\t') const;
};
} // namespace TPCE
#endif // EXCHANGE_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,82 @@
#ifndef FEMALE_FIRST_NAME_DATA_FILE_RECORD_H
#define FEMALE_FIRST_NAME_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the FemaleFirstName data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class FemaleFirstNameDataFileRecord {
private:
static const int maxNameLen = 20;
char nameCStr[maxNameLen + 1];
std::string name;
static const unsigned int fieldCount = 1;
public:
explicit FemaleFirstNameDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~FemaleFirstNameDataFileRecord()
// FemaleFirstNameDataFileRecord(const FemaleFirstNameDataFileRecord&);
// FemaleFirstNameDataFileRecord& operator=(const
// FemaleFirstNameDataFileRecord&);
//
const std::string &NAME() const;
const char *NAME_CSTR() const;
std::string ToString() const;
};
} // namespace TPCE
#endif // FEMALE_FIRST_NAME_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,63 @@
#ifndef I_TAX_RATE_FILE_RECORD_H
#define I_TAX_RATE_FILE_RECORD_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
*/
namespace TPCE {
//
// Description:
// An interface to represent a single record in the TaxRate data file.
//
class ITaxRateFileRecord {
public:
virtual ~ITaxRateFileRecord() {
}
virtual const std::string &TX_ID() const = 0;
virtual const char *TX_ID_CSTR() const = 0;
virtual const std::string &TX_NAME() const = 0;
virtual const char *TX_NAME_CSTR() const = 0;
virtual double TX_RATE() const = 0;
virtual std::string ToString(char fieldSeparator = '\t') const = 0;
};
} // namespace TPCE
#endif // I_TAX_RATE_FILE_RECORD_H

View File

@@ -0,0 +1,63 @@
#ifndef I_TEXT_SPLITTER
#define I_TEXT_SPLITTER
/*
* 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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Interface for splitting a text source into a series of records and fields.
//
class ITextSplitter {
public:
virtual ~ITextSplitter() {
}
// Have we already reached the end of the stream?
virtual bool eof() const = 0;
// Returns a record as a deque of strings. Each
// string is one field in the record.
virtual std::deque<std::string> getNextRecord() = 0;
};
} // namespace TPCE
#endif // I_TEXT_SPLITTER

View File

@@ -0,0 +1,95 @@
#ifndef INDUSTRY_DATA_FILE_RECORD_H
#define INDUSTRY_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the Industry data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class IndustryDataFileRecord {
private:
static const int maxIn_idLen = 2;
char in_idCStr[maxIn_idLen + 1];
std::string in_id;
static const int maxIn_nameLen = 50;
char in_nameCStr[maxIn_nameLen + 1];
std::string in_name;
static const int maxIn_sc_idLen = 2;
char in_sc_idCStr[maxIn_sc_idLen + 1];
std::string in_sc_id;
static const unsigned int fieldCount = 3;
public:
explicit IndustryDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~IndustryDataFileRecord()
// IndustryDataFileRecord(const IndustryDataFileRecord&);
// IndustryDataFileRecord& operator=(const IndustryDataFileRecord&);
//
const std::string &IN_ID() const;
const char *IN_ID_CSTR() const;
const std::string &IN_NAME() const;
const char *IN_NAME_CSTR() const;
const std::string &IN_SC_ID() const;
const char *IN_SC_ID_CSTR() const;
std::string ToString(char fieldSeparator = '\t') const;
};
} // namespace TPCE
#endif // INDUSTRY_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,81 @@
#ifndef LAST_NAME_DATA_FILE_RECORD_H
#define LAST_NAME_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the LastName data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class LastNameDataFileRecord {
private:
static const int maxNameLen = 25;
char nameCStr[maxNameLen + 1];
std::string name;
static const unsigned int fieldCount = 1;
public:
explicit LastNameDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~LastNameDataFileRecord()
// LastNameDataFileRecord(const LastNameDataFileRecord&);
// LastNameDataFileRecord& operator=(const LastNameDataFileRecord&);
//
const std::string &NAME() const;
const char *NAME_CSTR() const;
std::string ToString() const;
};
} // namespace TPCE
#endif // LAST_NAME_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,82 @@
#ifndef MALE_FIRST_NAME_DATA_FILE_RECORD_H
#define MALE_FIRST_NAME_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the MaleFirstName data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class MaleFirstNameDataFileRecord {
private:
static const int maxNameLen = 20;
char nameCStr[maxNameLen + 1];
std::string name;
static const unsigned int fieldCount = 1;
public:
explicit MaleFirstNameDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~MaleFirstNameDataFileRecord()
// MaleFirstNameDataFileRecord(const MaleFirstNameDataFileRecord&);
// MaleFirstNameDataFileRecord& operator=(const
// MaleFirstNameDataFileRecord&);
//
const std::string &NAME() const;
const char *NAME_CSTR() const;
std::string ToString() const;
};
} // namespace TPCE
#endif // MALE_FIRST_NAME_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,81 @@
#ifndef NEWS_DATA_FILE_RECORD_H
#define NEWS_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the News data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class NewsDataFileRecord {
private:
static const int maxWordLen = 25; // News uses LastNames for words.
char wordCStr[maxWordLen + 1];
std::string word;
static const unsigned int fieldCount = 1;
public:
explicit NewsDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~NewsDataFileRecord()
// NewsDataFileRecord(const NewsDataFileRecord&);
// NewsDataFileRecord& operator=(const NewsDataFileRecord&);
//
const std::string &WORD() const;
const char *WORD_CSTR() const;
std::string ToString() const;
};
} // namespace TPCE
#endif // NEWS_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,83 @@
#ifndef NON_TAXABLE_ACCOUNT_NAME_DATA_FILE_RECORD_H
#define NON_TAXABLE_ACCOUNT_NAME_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the NonTaxableAccountName data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class NonTaxableAccountNameDataFileRecord {
private:
static const int maxNameLen = 50;
char nameCStr[maxNameLen + 1];
std::string name;
static const unsigned int fieldCount = 1;
public:
explicit NonTaxableAccountNameDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~NonTaxableAccountNameDataFileRecord()
// NonTaxableAccountNameDataFileRecord(const
// NonTaxableAccountNameDataFileRecord&);
// NonTaxableAccountNameDataFileRecord& operator=(const
// NonTaxableAccountNameDataFileRecord&);
//
const std::string &NAME() const;
const char *NAME_CSTR() const;
std::string ToString() const;
};
} // namespace TPCE
#endif // NON_TAXABLE_ACCOUNT_NAME_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,88 @@
#ifndef SECTOR_DATA_FILE_RECORD_H
#define SECTOR_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the Sector data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class SectorDataFileRecord {
private:
static const int maxSc_idLen = 2;
char sc_idCStr[maxSc_idLen + 1];
std::string sc_id;
static const int maxSc_nameLen = 30;
char sc_nameCStr[maxSc_nameLen + 1];
std::string sc_name;
static const unsigned int fieldCount = 2;
public:
explicit SectorDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~SectorDataFileRecord()
// SectorDataFileRecord(const SectorDataFileRecord&);
// SectorDataFileRecord& operator=(const SectorDataFileRecord&);
//
const std::string &SC_ID() const;
const char *SC_ID_CSTR() const;
const std::string &SC_NAME() const;
const char *SC_NAME_CSTR() const;
std::string ToString(char fieldSeparator = '\t') const;
};
} // namespace TPCE
#endif // SECTOR_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,112 @@
#ifndef SECURITY_DATA_FILE_RECORD_H
#define SECURITY_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
#include "utilities/EGenStandardTypes.h"
namespace TPCE {
//
// Description:
// A class to represent a single record in the Security data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class SecurityDataFileRecord {
private:
TIdent s_id;
static const int maxS_st_idLen = 4;
char s_st_idCStr[maxS_st_idLen + 1];
std::string s_st_id;
static const int maxS_symbLen = 7 + 1 + 7; // base + separator + extended
char s_symbCStr[maxS_symbLen + 1];
std::string s_symb;
static const int maxS_issueLen = 6;
char s_issueCStr[maxS_issueLen + 1];
std::string s_issue;
static const int maxS_ex_idLen = 6;
char s_ex_idCStr[maxS_ex_idLen + 1];
std::string s_ex_id;
TIdent s_co_id;
static const unsigned int fieldCount = 6;
public:
explicit SecurityDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~SecurityDataFileRecord()
// SecurityDataFileRecord(const SecurityDataFileRecord&);
// SecurityDataFileRecord& operator=(const SecurityDataFileRecord&);
//
TIdent S_ID() const;
const std::string &S_ST_ID() const;
const char *S_ST_ID_CSTR() const;
const std::string &S_SYMB() const;
const char *S_SYMB_CSTR() const;
const std::string &S_ISSUE() const;
const char *S_ISSUE_CSTR() const;
const std::string &S_EX_ID() const;
const char *S_EX_ID_CSTR() const;
TIdent S_CO_ID() const;
std::string ToString(char fieldSeparator = '\t') const;
};
} // namespace TPCE
#endif // SECURITY_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,146 @@
/*
* 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
* - Doug Johnson
*/
/******************************************************************************
* Description: Implementation of the Security input file that scales
* with the database size.
******************************************************************************/
#ifndef SECURITY_FILE_H
#define SECURITY_FILE_H
#include <map>
#include <cassert>
#include "utilities/EGenStandardTypes.h"
#include "DataFileTypes.h"
#include "main/ExchangeIDs.h"
namespace TPCE {
class CSecurityFile {
SecurityDataFile_t const *m_dataFile;
// Total number of securities in the database.
// Depends on the total number of customers.
//
TIdent m_iConfiguredSecurityCount;
TIdent m_iActiveSecurityCount;
// Number of base companies (=rows in Company.txt input file).
//
UINT m_iBaseCompanyCount;
// Used to map a symbol to it's id value. To support logical const-ness
// these are mutable since they don't change the "real" contents of the
// Security File.
mutable bool m_SymbolToIdMapIsLoaded;
mutable std::map<std::string, TIdent> m_SymbolToIdMap;
mutable std::map<char, int> m_LowerCaseLetterToIntMap;
char m_SUFFIX_SEPARATOR;
void CreateSuffix(TIdent Multiplier, char *pBuf, size_t BufSize) const;
INT64 ParseSuffix(const char *pSymbol) const;
public:
// Constructor.
//
CSecurityFile(const SecurityDataFile_t &dataFile, TIdent iConfiguredCustomerCount, TIdent iActiveCustomerCount,
UINT baseCompanyCount);
// Calculate total security count for the specified number of customers.
// Sort of a static method. Used in parallel generation of securities
// related tables.
//
TIdent CalculateSecurityCount(TIdent iCustomerCount) const;
// Calculate the first security id (0-based) for the specified customer id
//
TIdent CalculateStartFromSecurity(TIdent iStartFromCustomer) const;
// Create security symbol with mod/div magic.
//
// This function is needed to scale unique security
// symbols with the database size.
//
void CreateSymbol(TIdent iIndex, // row number
char *szOutput, // output buffer
size_t iOutputLen // size of the output buffer (including null)
) const;
// Return company id for the specified row of the SECURITY table.
// Index can exceed the size of the Security flat file.
//
TIdent GetCompanyId(TIdent iIndex) const;
TIdent GetCompanyIndex(TIdent Index) const;
// Return the number of securities in the database for
// a certain number of customers.
//
TIdent GetSize() const;
// Return the number of securities in the database for
// the configured number of customers.
//
TIdent GetConfiguredSecurityCount() const;
// Return the number of securities in the database for
// the active number of customers.
//
TIdent GetActiveSecurityCount() const;
// Overload GetRecord to wrap around indices that
// are larger than the flat file
//
const SecurityDataFileRecord &GetRecord(TIdent index) const;
// Load the symbol-to-id map
// Logical const-ness - the maps and the is-loaded flag may change but the
// "real" Security File data is unchanged.
bool LoadSymbolToIdMap(void) const;
TIdent GetId(char *pSymbol) const;
TIdent GetIndex(char *pSymbol) const;
eExchangeID GetExchangeIndex(TIdent index) const;
};
} // namespace TPCE
#endif // SECURITY_FILE_H

View File

@@ -0,0 +1,63 @@
#ifndef SHRINK_TO_FIT_H
#define SHRINK_TO_FIT_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
*/
namespace TPCE {
// Utility functions for tightening up STL containers and strings.
// With C++11 STL containers and strings have a
// shrink_to_fit method. But since C++11 features
// are not supported equally well by all compilers we'll use a
// general trick that works well but just isn't as obvious to the
// casual reader of the code. This way, for now, everyone executes
// the smae code path. When C++11 support is more ubiquitous calls
// to this function can be replaced by calls to the shrink_to_fit
// method associated with the object.
template <class T> void shrink_to_fit(T &container) {
T(container).swap(container);
}
template <class T> void shrink_to_fit(T &container, const std::string &name) {
printf("%s: shrinking from %d to ", name.c_str(), container.capacity());
T(container).swap(container);
printf("%d.\n", container.capacity());
}
} // namespace TPCE
#endif // SHRINK_TO_FIT_H

View File

@@ -0,0 +1,88 @@
#ifndef STATUS_TYPE_DATA_FILE_RECORD_H
#define STATUS_TYPE_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the StatusType data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class StatusTypeDataFileRecord {
private:
static const int maxSt_idLen = 4;
char st_idCStr[maxSt_idLen + 1];
std::string st_id;
static const int maxSt_nameLen = 10;
char st_nameCStr[maxSt_nameLen + 1];
std::string st_name;
static const unsigned int fieldCount = 2;
public:
explicit StatusTypeDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~StatusTypeDataFileRecord()
// StatusTypeDataFileRecord(const StatusTypeDataFileRecord&);
// StatusTypeDataFileRecord& operator=(const StatusTypeDataFileRecord&);
//
const std::string &ST_ID() const;
const char *ST_ID_CSTR() const;
const std::string &ST_NAME() const;
const char *ST_NAME_CSTR() const;
std::string ToString(char fieldSeparator = '\t') const;
};
} // namespace TPCE
#endif // STATUS_TYPE_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,84 @@
#ifndef STREAM_SPLITTER_H
#define STREAM_SPLITTER_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
*/
#include <istream>
#include <deque>
#include <string>
#include "ITextSplitter.h"
namespace TPCE {
//
// Description:
// A class to split a text stream into a series of records made up
// of fields.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is disallowed.
//
class StreamSplitter : public ITextSplitter {
private:
char recordDelim;
char fieldDelim;
std::istream &stream;
// Copying a StreamSplitter doesn't make sense so disallow it.
StreamSplitter(const StreamSplitter &);
StreamSplitter &operator=(const StreamSplitter &);
public:
static const char DEFAULT_RECORD_DELIMITER = '\n';
static const char DEFAULT_FIELD_DELIMITER = '\t';
explicit StreamSplitter(std::istream &textStream, char recordDelimiter = DEFAULT_RECORD_DELIMITER,
char fieldDelimiter = DEFAULT_FIELD_DELIMITER);
//~StreamSplitter() - default destructor is ok.
// ITextSplitter implementation
bool eof() const;
std::deque<std::string> getNextRecord();
};
} // namespace TPCE
#endif // STREAM_SPLITTER_H

View File

@@ -0,0 +1,81 @@
#ifndef STREET_NAME_DATA_FILE_RECORD_H
#define STREET_NAME_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the StreetName data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class StreetNameDataFileRecord {
private:
static const int maxStreetLen = 80;
char streetCStr[maxStreetLen + 1];
std::string street;
static const unsigned int fieldCount = 1;
public:
explicit StreetNameDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~StreetNameDataFileRecord()
// StreetNameDataFileRecord(const StreetNameDataFileRecord&);
// StreetNameDataFileRecord& operator=(const StreetNameDataFileRecord&);
//
const std::string &STREET() const;
const char *STREET_CSTR() const;
std::string ToString() const;
};
} // namespace TPCE
#endif // STREET_NAME_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,81 @@
#ifndef STREET_SUFFIX_DATA_FILE_RECORD_H
#define STREET_SUFFIX_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the StreetSuffix data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class StreetSuffixDataFileRecord {
private:
static const int maxSuffixLen = 80;
char suffixCStr[maxSuffixLen + 1];
std::string suffix;
static const unsigned int fieldCount = 1;
public:
explicit StreetSuffixDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~StreetSuffixDataFileRecord()
// StreetSuffixDataFileRecord(const StreetSuffixDataFileRecord&);
// StreetSuffixDataFileRecord& operator=(const StreetSuffixDataFileRecord&);
//
const std::string &SUFFIX() const;
const char *SUFFIX_CSTR() const;
std::string ToString() const;
};
} // namespace TPCE
#endif // STREET_SUFFIX_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,82 @@
#ifndef STRING_SPLITTER_H
#define STRING_SPLITTER_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
*/
#include <sstream>
#include "ITextSplitter.h"
#include "StreamSplitter.h"
namespace TPCE {
//
// Description:
// A class for managing a text string stream and splitting it
// into records made up of fields.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is disallowed.
//
class StringSplitter : public ITextSplitter {
private:
std::istringstream stream;
StreamSplitter splitter;
// Copying a StreamSplitter doesn't make sense so disallow it.
StringSplitter(const StringSplitter &);
StringSplitter &operator=(const StringSplitter &);
public:
static const char DEFAULT_RECORD_DELIMITER = StreamSplitter::DEFAULT_RECORD_DELIMITER;
static const char DEFAULT_FIELD_DELIMITER = StreamSplitter::DEFAULT_FIELD_DELIMITER;
explicit StringSplitter(const std::string &textString, char recordDelimiter = DEFAULT_RECORD_DELIMITER,
char fieldDelimiter = DEFAULT_FIELD_DELIMITER);
//~StringSplitter() - default destructor is ok.
// ITextSplitter implementation
bool eof() const;
std::deque<std::string> getNextRecord();
};
} // namespace TPCE
#endif // STRING_SPLITTER_H

View File

@@ -0,0 +1,95 @@
#ifndef TAX_RATE_COUNTRY_DATA_FILE_RECORD_H
#define TAX_RATE_COUNTRY_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
#include "ITaxRateFileRecord.h"
namespace TPCE {
//
// Description:
// A class to represent a single record in the TaxRateCountry data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class TaxRateCountryDataFileRecord : public ITaxRateFileRecord {
private:
static const int maxTx_idLen = 4;
char tx_idCStr[maxTx_idLen + 1];
std::string tx_id;
static const int maxTx_nameLen = 50;
char tx_nameCStr[maxTx_nameLen + 1];
std::string tx_name;
double tx_rate;
static const unsigned int fieldCount = 3;
public:
explicit TaxRateCountryDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~TaxRateCountryDataFileRecord()
// TaxRateCountryDataFileRecord(const TaxRateCountryDataFileRecord&);
// TaxRateCountryDataFileRecord& operator=(const
// TaxRateCountryDataFileRecord&);
//
const std::string &TX_ID() const;
const char *TX_ID_CSTR() const;
const std::string &TX_NAME() const;
const char *TX_NAME_CSTR() const;
double TX_RATE() const;
std::string ToString(char fieldSeparator = '\t') const;
};
} // namespace TPCE
#endif // TAX_RATE_COUNTRY_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,95 @@
#ifndef TAX_RATE_DIVISION_DATA_FILE_RECORD_H
#define TAX_RATE_DIVISION_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
#include "ITaxRateFileRecord.h"
namespace TPCE {
//
// Description:
// A class to represent a single record in the TaxRateDivision data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class TaxRateDivisionDataFileRecord : public ITaxRateFileRecord {
private:
static const int maxTx_idLen = 4;
char tx_idCStr[maxTx_idLen + 1];
std::string tx_id;
static const int maxTx_nameLen = 50;
char tx_nameCStr[maxTx_nameLen + 1];
std::string tx_name;
double tx_rate;
static const unsigned int fieldCount = 3;
public:
explicit TaxRateDivisionDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~TaxRateDivisionDataFileRecord()
// TaxRateDivisionDataFileRecord(const TaxRateDivisionDataFileRecord&);
// TaxRateDivisionDataFileRecord& operator=(const
// TaxRateDivisionDataFileRecord&);
//
const std::string &TX_ID() const;
const char *TX_ID_CSTR() const;
const std::string &TX_NAME() const;
const char *TX_NAME_CSTR() const;
double TX_RATE() const;
std::string ToString(char fieldSeparator = '\t') const;
};
} // namespace TPCE
#endif // TAX_RATE_DIVISION_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,68 @@
#ifndef TAX_RATE_FILE_H
#define TAX_RATE_FILE_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
*/
#include "DataFileTypes.h"
#include "ITaxRateFileRecord.h"
namespace TPCE {
class CTaxRateFile {
private:
TaxRateCountryDataFile_t const *cdf;
TaxRateDivisionDataFile_t const *ddf;
struct RecordLocation {
int bucketIdx;
int recordIdx;
RecordLocation(int bIdx = -1, int rIdx = -1) : bucketIdx(bIdx), recordIdx(rIdx){};
};
std::vector<RecordLocation> locations;
public:
typedef std::vector<int>::size_type size_type;
CTaxRateFile(const TaxRateCountryDataFile_t &countryDataFile, const TaxRateDivisionDataFile_t &divisionDataFile);
// Provide range-checked access to the records.
const ITaxRateFileRecord &operator[](unsigned int idx) const;
size_type size() const;
};
} // namespace TPCE
#endif // TAX_RATE_FILE_H

View File

@@ -0,0 +1,82 @@
#ifndef TAXABLE_ACCOUNT_NAME_DATA_FILE_RECORD_H
#define TAXABLE_ACCOUNT_NAME_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the TaxableAccountName data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class TaxableAccountNameDataFileRecord {
private:
static const int maxNameLen = 50;
char nameCStr[maxNameLen + 1];
std::string name;
static const unsigned int fieldCount = 1;
public:
explicit TaxableAccountNameDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~TaxableAccountNameDataFileRecord()
// TaxableAccountNameDataFileRecord(const
// TaxableAccountNameDataFileRecord&); TaxableAccountNameDataFileRecord&
// operator=(const TaxableAccountNameDataFileRecord&);
//
const std::string &NAME() const;
const char *NAME_CSTR() const;
std::string ToString() const;
};
} // namespace TPCE
#endif // TAXABLE_ACCOUNT_NAME_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,82 @@
#ifndef TEXT_FILE_SPLITTER_H
#define TEXT_FILE_SPLITTER_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
*/
#include <sstream>
#include "ITextSplitter.h"
#include "StreamSplitter.h"
namespace TPCE {
//
// Description:
// A class for managing a text file stream and splitting it
// into records made up of fields.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is disallowed.
//
class TextFileSplitter : public ITextSplitter {
private:
std::istringstream file;
StreamSplitter splitter;
// Copying a StreamSplitter doesn't make sense so disallow it.
TextFileSplitter(const TextFileSplitter &);
TextFileSplitter &operator=(const TextFileSplitter &);
public:
static const char DEFAULT_RECORD_DELIMITER = StreamSplitter::DEFAULT_RECORD_DELIMITER;
static const char DEFAULT_FIELD_DELIMITER = StreamSplitter::DEFAULT_FIELD_DELIMITER;
explicit TextFileSplitter(const std::string &string, char recordDelimiter = DEFAULT_RECORD_DELIMITER,
char fieldDelimiter = DEFAULT_FIELD_DELIMITER);
~TextFileSplitter();
// ITextSplitter implementation
bool eof() const;
std::deque<std::string> getNextRecord();
};
} // namespace TPCE
#endif // TEXT_FILE_SPLITTER_H

View File

@@ -0,0 +1,94 @@
#ifndef TRADE_TYPE_DATA_FILE_RECORD_H
#define TRADE_TYPE_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the TradeType data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class TradeTypeDataFileRecord {
private:
static const int maxTt_idLen = 3;
char tt_idCStr[maxTt_idLen + 1];
std::string tt_id;
static const int maxTt_nameLen = 12;
char tt_nameCStr[maxTt_nameLen + 1];
std::string tt_name;
bool tt_is_sell;
bool tt_is_mrkt;
static const unsigned int fieldCount = 4;
public:
explicit TradeTypeDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~TradeTypeDataFileRecord()
// TradeTypeDataFileRecord(const TradeTypeDataFileRecord&);
// TradeTypeDataFileRecord& operator=(const TradeTypeDataFileRecord&);
//
const std::string &TT_ID() const;
const char *TT_ID_CSTR() const;
const std::string &TT_NAME() const;
const char *TT_NAME_CSTR() const;
bool TT_IS_SELL() const;
bool TT_IS_MRKT() const;
std::string ToString(char fieldSeparator = '\t') const;
};
} // namespace TPCE
#endif // TRADE_TYPE_DATA_FILE_RECORD_H

View File

@@ -0,0 +1,43 @@
/*
* 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
*/
#include <string>
namespace TPCE {
void DFRStringInit(const std::string &src, std::string &dest, char *destCStr, int maxLen);
} // namespace TPCE

View File

@@ -0,0 +1,142 @@
#ifndef WEIGHTED_DATA_FILE_H
#define WEIGHTED_DATA_FILE_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
*/
#include <deque>
#include <sstream>
#include <vector>
#include <stdexcept>
//#include <string> // for stoi C++11
#include <cstdlib> // for atoi
#include "ITextSplitter.h"
#include "ShrinkToFit.h"
namespace TPCE {
//
// Description:
// A template class for converting a series of weighted text records
// into a binary in-memory structure for quick easy access.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
template <class RecordType> class WeightedDataFile {
private:
typedef std::vector<RecordType> Records; // For convenience and readability
Records records;
typedef std::vector<int> Weights; // For convenience and readability
Weights weightedIndexes;
public:
// Leverage the size type of our underlying storage container but
// insulate clients from the implementation particulars by creating
// our own type.
typedef typename Records::size_type size_type;
enum SizeFilter { AllRecords, UniqueRecordsOnly };
explicit WeightedDataFile(ITextSplitter &splitter) {
// eof only returns true after trying to read the end, so
// "prime the pump" by doing an initial read.
std::deque<std::string> fields = splitter.getNextRecord();
// Process each record.
while (!splitter.eof()) {
if (1 == fields.size() && "" == fields[0]) {
// We found a blank line so skip it and move on.
fields = splitter.getNextRecord();
continue;
}
// The first field is the weight for this record.
// int weight = std::stoi(fields[0]); // C++11
int weight = std::atoi(fields[0].c_str());
fields.pop_front();
// Set up the weighted indexes for the record.
for (int ii = 0; ii < weight; ++ii) {
weightedIndexes.push_back(records.size());
}
// Add the record.
records.push_back(RecordType(fields));
// Move on to the next record.
fields = splitter.getNextRecord();
}
// Now that everything has been loaded tighten up our storage.
shrink_to_fit<Weights>(weightedIndexes);
shrink_to_fit<Records>(records);
// weightedIndexes.shrink_to_fit(); // C++11
// records.shrink_to_fit(); // C++11
}
//
// Default copies and destructor are ok.
//
// ~WeightedDataFile();
// WeightedDataFile(const WeightedDataFile&);
// WeightedDataFile& operator=(const WeightedDataFile&);
//
size_type size(SizeFilter filter = AllRecords) const {
return (filter == AllRecords ? weightedIndexes.size() : records.size());
}
const RecordType &operator[](size_type weightedIndex) const {
return records[weightedIndexes[weightedIndex]];
}
const RecordType &at(size_type weightedIndex) const {
return records.at(weightedIndexes.at(weightedIndex));
}
const RecordType &getUniqueRecord(size_type idx, bool rangeCheckedAccess = false) const {
return (rangeCheckedAccess ? records.at(idx) : records[idx]);
}
};
} // namespace TPCE
#endif // WEIGHTED_DATA_FILE_H

View File

@@ -0,0 +1,99 @@
#ifndef ZIP_CODE_DATA_FILE_RECORD_H
#define ZIP_CODE_DATA_FILE_RECORD_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
*/
#include <deque>
#include <string>
namespace TPCE {
//
// Description:
// A class to represent a single record in the ZipCode data file.
//
// Exception Safety:
// The Basic guarantee is provided.
//
// Copy Behavior:
// Copying is allowed.
//
class ZipCodeDataFileRecord {
private:
int divisionTaxKey;
static const int maxZc_codeLen = 12;
char zc_codeCStr[maxZc_codeLen + 1];
std::string zc_code;
static const int maxZc_townLen = 80;
char zc_townCStr[maxZc_townLen + 1];
std::string zc_town;
static const int maxZc_divLen = 80;
char zc_divCStr[maxZc_divLen + 1];
std::string zc_div;
static const unsigned int fieldCount = 4;
public:
explicit ZipCodeDataFileRecord(const std::deque<std::string> &fields);
//
// Default copies and destructor are ok.
//
// ~ZipCodeDataFileRecord()
// ZipCodeDataFileRecord(const ZipCodeDataFileRecord&);
// ZipCodeDataFileRecord& operator=(const ZipCodeDataFileRecord&);
//
int DivisionTaxKey() const;
const std::string &ZC_CODE() const;
const char *ZC_CODE_CSTR() const;
const std::string &ZC_TOWN() const;
const char *ZC_TOWN_CSTR() const;
const std::string &ZC_DIV() const;
const char *ZC_DIV_CSTR() const;
std::string ToString(char fieldSeparator = '\t') const;
};
} // namespace TPCE
#endif // ZIP_CODE_DATA_FILE_RECORD_H

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,242 @@
/*
* 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
* - Doug Johnson
*/
/*
* Contains class definition to generate Address table.
* Address table contains addresses for exchanges, companies, and customers.
*/
#ifndef ADDRESS_TABLE_H
#define ADDRESS_TABLE_H
#include "EGenTables_common.h"
#include "input/DataFileManager.h"
namespace TPCE {
class CAddressTable : public TableTemplate<ADDRESS_ROW> {
private:
CDateTime m_date_time;
const CCompanyFile &m_companies;
const StreetNameDataFile_t &m_Street;
const StreetSuffixDataFile_t &m_StreetSuffix;
const ZipCodeDataFile_t &m_ZipCode;
TIdent m_iStartFromCustomer;
TIdent m_iCustomerCount; // total # of customers for whom to generate addresses
bool m_bCustomerAddressesOnly; // whether generating only customer addresses
bool m_bCustomerAddress; // whether the currently generated row is for a
// customer
TIdent m_iCompanyCount; // total # of companies for which to generate addresses
UINT m_iExchangeCount; // total # of exchanges for which to generate
// addresses
TIdent m_iTotalAddressCount; // total # of address rows to generate
bool m_bCacheEnabled;
int m_iCacheSize;
TIdent m_iCacheOffset;
int *m_CacheZipCode;
const int INVALID_CACHE_ENTRY;
/*
* Generate AD_LINE_1 and store it in the record structure.
* Does not increment the number of rows generated.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAD_LINE_1();
/*
* Generate AD_LINE_2 and store it in the record structure.
* Does not increment the number of rows generated.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAD_LINE_2();
/*
* For a given address id returns the same Threshold used to
* select the town, division, zip, and country.
* Needed to return a specific division/country for a given address id
* (for customer tax rates).
*
* PARAMETERS:
* IN ADID - address id
*
* RETURNS:
* none.
*/
int GetTownDivisionZipCodeThreshold(TIdent ADID);
/*
* Return the country code code for a given zip code.
*
* PARAMETERS:
* IN szZipCode - string with a US or Canada zip code
*
* RETURNS:
* country code.
*/
UINT GetCountryCode(const char *pZipCode);
/*
* Generate zip code and country for the current address id
* and store them in the record structure.
* Does not increment the number of rows generated.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAD_ZC_CODE_CTRY();
public:
/*
* Constructor for the ADDRESS table class.
*
* PARAMETERS:
* IN dfm - input flat files loaded in memory
* IN iCustomerCount - number of customers to generate
* IN iStartFromCustomer - ordinal position of the first
* customer in the sequence (Note: 1-based) for whom to generate the
* addresses. Used if generating customer addresses only. IN
* bCustomerAddressesOnly - if true, generate only customer addresses if
* false, generate exchange, company, and customer addresses (always start
* from the first customer in this case) RETURNS: not applicable.
*/
CAddressTable(const DataFileManager &dfm, TIdent iCustomerCount, TIdent iStartFromCustomer,
bool bCustomerAddressesOnly = false, bool bCacheEnabled = false);
/*
* Destructor for the ADDRESS table class.
*
* PARAMETERS:
* none.
*
* RETURNS:
* not applicable.
*/
~CAddressTable();
/*
* Reset the state for the next load unit.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void InitNextLoadUnit();
/*
* Generates the next A_ID value.
* It is stored in the internal record structure and also returned.
* The number of rows generated is incremented. This is why
* this function cannot be called more than once for a record.
*
* PARAMETERS:
* none.
*
* RETURNS:
* next address id.
*/
TIdent GenerateNextAD_ID();
/*
* Returns the address id of the customer specified by the customer id.
*
* PARAMETERS:
* IN C_ID - customer id (1-based)
*
* RETURNS:
* address id.
*/
TIdent GetAD_IDForCustomer(TIdent C_ID); // return address id for the customer id
/*
* Return a certain division/country code (from the input file) for a
* given address id. Used in the loader to properly calculate tax on a
* trade.
*
* PARAMETERS:
* IN AD_ID - address id
* OUT iDivCode - division (state/province) code
* OUT iCtryCode - country (USA/CANADA) code
*
* RETURNS:
* none.
*/
void GetDivisionAndCountryCodesForAddress(TIdent AD_ID, UINT &iDivCode, UINT &iCtryCode);
/*
* Return division and country codes for current address.
* Used in generating customer taxrates.
*
* PARAMETERS:
* OUT iDivCode - division (state/province) code
* OUT iCtryCode - country (USA/CANADA) code
*
* RETURNS:
* none.
*/
void GetDivisionAndCountryCodes(UINT &iDivCode, UINT &iCtryCode) {
GetDivisionAndCountryCodesForAddress(m_row.AD_ID, iDivCode, iCtryCode);
}
/*
* Generate all column values for the next row
* and store them in the record structure.
* Increment the number of rows generated.
*
* PARAMETERS:
* none.
*
* RETURNS:
* TRUE, if there are more records in the ADDRESS table; FALSE
* othewise.
*/
bool GenerateNextRecord(); // generates the next table row
};
} // namespace TPCE
#endif // ADDRESS_TABLE_H

View File

@@ -0,0 +1,126 @@
/*
* 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
* - Doug Johnson
*/
/*
* Base interface for all loader classes.
*/
#ifndef BASE_LOADER_H
#define BASE_LOADER_H
namespace TPCE {
template <typename T> class CBaseLoader {
public:
/*
* Virtual destructor. Provided so that a sponsor-specific
* destructor can be called on destruction from the base-class pointer.
*
* PARAMETERS:
* none.
*
* RETURNS:
* not applicable.
*/
virtual ~CBaseLoader(){};
/*
* This function is provided to reset the loader to
* a clean state. "Clean state" here means a sequence of
* WriteNextRecord(), followed by Commit(), followed by FinishLoad()
* can be called.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
virtual void Init(){}; // default implementation is empty
/*
* Receive a new record to be loaded into the database.
* This is the main function that is called
* for every generated record.
*
* Note: the records are not guaranteed to actually be inserted
* into the database after this call. It is Commit() that ensures that
* all records received by WriteNextRecord are persisted in the database.
*
* PARAMETERS:
* IN next_record - a pointer to a structure, containing
* the record
*
* RETURNS:
* none.
*/
virtual void WriteNextRecord(const T &next_record) {
printf("BaseLoader - const ref\n");
};
/*
* Commit any records that might have been kept in temporary
* storage to the database. After this call, all records received
* by WriteNextRecord should be present in the database.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
virtual void Commit(){}; // default implementation is empty
/*
* Release any resources held for loading.
* Also, commit any records that might have been kept in temporary
* storage to the database.
* This function is called once, after the last record has been loaded.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
virtual void FinishLoad() = 0; // must be defined in subclasses
};
} // namespace TPCE
#endif // #ifndef BASE_LOADER_H

View File

@@ -0,0 +1,465 @@
/*
* 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
* - Doug Johnson
*/
/*
* Base interface for a loader class factory.
* This class instantiates particular table loader classs.
*/
#ifndef BASE_LOADER_FACTORY_H
#define BASE_LOADER_FACTORY_H
#include "BaseLoader.h"
#include "TableRows.h"
namespace TPCE {
class CBaseLoaderFactory {
public:
/*
* Virtual destructor. Provided so that a sponsor-specific
* destructor can be called on destruction from the base-class pointer.
*
* PARAMETERS:
* none.
*
* RETURNS:
* not applicable.
*/
virtual ~CBaseLoaderFactory(){};
/*
* Create loader class for ACCOUNT_PERMISSION table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<ACCOUNT_PERMISSION_ROW> *CreateAccountPermissionLoader() = 0;
/*
* Create loader class for ADDRESS table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<ADDRESS_ROW> *CreateAddressLoader() = 0;
/*
* Create loader class for BROKER table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<BROKER_ROW> *CreateBrokerLoader() = 0;
/*
* Create loader class for CASH_TRANSACTION table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<CASH_TRANSACTION_ROW> *CreateCashTransactionLoader() = 0;
/*
* Create loader class for CHARGE table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<CHARGE_ROW> *CreateChargeLoader() = 0;
/*
* Create loader class for COMMISSION_RATE table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<COMMISSION_RATE_ROW> *CreateCommissionRateLoader() = 0;
/*
* Create loader class for COMPANY_COMPETITOR table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<COMPANY_COMPETITOR_ROW> *CreateCompanyCompetitorLoader() = 0;
/*
* Create loader class for COMPANY table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<COMPANY_ROW> *CreateCompanyLoader() = 0;
/*
* Create loader class for CUSTOMER_ACCOUNT table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<CUSTOMER_ACCOUNT_ROW> *CreateCustomerAccountLoader() = 0;
/*
* Create loader class for CUSTOMER table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<CUSTOMER_ROW> *CreateCustomerLoader() = 0;
/*
* Create loader class for CUSTOMER_TAXRATE table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<CUSTOMER_TAXRATE_ROW> *CreateCustomerTaxrateLoader() = 0;
/*
* Create loader class for DAILY_MARKET table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<DAILY_MARKET_ROW> *CreateDailyMarketLoader() = 0;
/*
* Create loader class for EXCHANGE table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<EXCHANGE_ROW> *CreateExchangeLoader() = 0;
/*
* Create loader class for FINANCIAL table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<FINANCIAL_ROW> *CreateFinancialLoader() = 0;
/*
* Create loader class for HOLDING table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<HOLDING_ROW> *CreateHoldingLoader() = 0;
/*
* Create loader class for HOLDING_HISTORY table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<HOLDING_HISTORY_ROW> *CreateHoldingHistoryLoader() = 0;
/*
* Create loader class for HOLDING_SUMMARY table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<HOLDING_SUMMARY_ROW> *CreateHoldingSummaryLoader() = 0;
/*
* Create loader class for INDUSTRY table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<INDUSTRY_ROW> *CreateIndustryLoader() = 0;
/*
* Create loader class for LAST_TRADE table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<LAST_TRADE_ROW> *CreateLastTradeLoader() = 0;
/*
* Create loader class for NEWS_ITEM table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<NEWS_ITEM_ROW> *CreateNewsItemLoader() = 0;
/*
* Create loader class for NEWS_XREF table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<NEWS_XREF_ROW> *CreateNewsXRefLoader() = 0;
/*
* Create loader class for SECTOR table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<SECTOR_ROW> *CreateSectorLoader() = 0;
/*
* Create loader class for SECURITY table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<SECURITY_ROW> *CreateSecurityLoader() = 0;
/*
* Create loader class for SETTLEMENT table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<SETTLEMENT_ROW> *CreateSettlementLoader() = 0;
/*
* Create loader class for STATUS_TYPE table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<STATUS_TYPE_ROW> *CreateStatusTypeLoader() = 0;
/*
* Create loader class for TAXRATE table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<TAX_RATE_ROW> *CreateTaxRateLoader() = 0;
/*
* Create loader class for TRADE_HISTORY table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<TRADE_HISTORY_ROW> *CreateTradeHistoryLoader() = 0;
/*
* Create loader class for TRADE table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<TRADE_ROW> *CreateTradeLoader() = 0;
/*
* Create loader class for TRADE_REQUEST table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<TRADE_REQUEST_ROW> *CreateTradeRequestLoader() = 0;
/*
* Create loader class for TRADE_TYPE table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<TRADE_TYPE_ROW> *CreateTradeTypeLoader() = 0;
/*
* Create loader class for WATCH_ITEM table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<WATCH_ITEM_ROW> *CreateWatchItemLoader() = 0;
/*
* Create loader class for WATCH_LIST table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<WATCH_LIST_ROW> *CreateWatchListLoader() = 0;
/*
* Create loader class for ZIP_CODE table.
* Should be defined in a subclass according to the subclass load type.
*
* PARAMETERS:
* none.
*
* RETURNS:
* Reference to the loader class.
*/
virtual CBaseLoader<ZIP_CODE_ROW> *CreateZipCodeLoader() = 0;
};
} // namespace TPCE
#endif // #ifndef BASE_LOADER_FACTORY_H

View File

@@ -0,0 +1,84 @@
/*
* 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
* - Matt Emmerton
*/
/******************************************************************************
* Description: This file implements the interface for
* formatting logger entries.
******************************************************************************/
#ifndef BASE_LOG_FORMATTER_H
#define BASE_LOG_FORMATTER_H
#include <string>
#include "DriverParamSettings.h"
namespace TPCE {
enum eLogFormat { eLogTab, eLogCustom };
class CBaseLogFormatter {
public:
/*
* Virtual destructor. Provided so that a sponsor-specific
* destructor can be called on destruction from the base-class pointer.
*
* PARAMETERS:
* none.
*
* RETURNS:
* not applicable.
*/
virtual ~CBaseLogFormatter(){};
virtual string GetLogOutput(CBrokerVolumeSettings &parms) = 0;
virtual string GetLogOutput(CCustomerPositionSettings &parms) = 0;
virtual string GetLogOutput(CMarketWatchSettings &parms) = 0;
virtual string GetLogOutput(CSecurityDetailSettings &parms) = 0;
virtual string GetLogOutput(CTradeLookupSettings &parms) = 0;
virtual string GetLogOutput(CTradeOrderSettings &parms) = 0;
virtual string GetLogOutput(CTradeUpdateSettings &parms) = 0;
virtual string GetLogOutput(CTxnMixGeneratorSettings &parms) = 0;
virtual string GetLogOutput(CLoaderSettings &parms) = 0;
virtual string GetLogOutput(CDriverGlobalSettings &parms) = 0;
virtual string GetLogOutput(CDriverCESettings &parms) = 0;
virtual string GetLogOutput(CDriverCEPartitionSettings &parms) = 0;
virtual string GetLogOutput(CDriverMEESettings &parms) = 0;
virtual string GetLogOutput(CDriverDMSettings &parms) = 0;
};
} // namespace TPCE
#endif // BASE_LOG_FORMATTER_H

View File

@@ -0,0 +1,94 @@
/*
* 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
* - Matt Emmerton
*/
/******************************************************************************
* Description: This file implements the interface for data logging.
******************************************************************************/
#ifndef BASE_LOGGER_H
#define BASE_LOGGER_H
#include "utilities/EGenStandardTypes.h"
#include "DriverTypes.h"
#include "DriverParamSettings.h"
#include "BaseLogFormatter.h"
namespace TPCE {
/********************************* Generic Logger Class
* ************************************/
class CBaseLogger {
private:
char m_Prefix[64];
CBaseLogFormatter *m_pLogFormatter;
bool SendToLogger(const char *szPrefix, const char *szMsg);
protected:
CBaseLogger(eDriverType drvType, INT32 UniqueId, CBaseLogFormatter *pFormatter);
virtual bool SendToLoggerImpl(const char *szPrefix, const char *szTimestamp, const char *szMsg) = 0;
public:
// Destructor
virtual ~CBaseLogger() {
}
// Strings
bool SendToLogger(const char *str);
bool SendToLogger(string str);
// Parameter Structures
bool SendToLogger(CLoaderSettings &parms);
bool SendToLogger(CDriverGlobalSettings &parms);
bool SendToLogger(CDriverCESettings &parms);
bool SendToLogger(CDriverCEPartitionSettings &parms);
bool SendToLogger(CDriverMEESettings &parms);
bool SendToLogger(CDriverDMSettings &parms);
bool SendToLogger(CBrokerVolumeSettings &parms);
bool SendToLogger(CCustomerPositionSettings &parms);
bool SendToLogger(CMarketWatchSettings &parms);
bool SendToLogger(CSecurityDetailSettings &parms);
bool SendToLogger(CTradeLookupSettings &parms);
bool SendToLogger(CTradeOrderSettings &parms);
bool SendToLogger(CTradeUpdateSettings &parms);
bool SendToLogger(CTxnMixGeneratorSettings &parms);
bool SendToLogger(TDriverCETxnSettings &parms);
};
} // namespace TPCE
#endif // BASE_LOGGER_H

View File

@@ -0,0 +1,278 @@
/*
* 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
* - Doug Johnson
*/
/*
* Class representing the Brokers table.
*/
#ifndef BROKERS_H
#define BROKERS_H
#include <stdio.h> // for snprintf which is not part of the C++ headers
#include "EGenTables_common.h"
#include "CustomerAccountsAndPermissionsTable.h"
#include "input/DataFileManager.h"
#include "StatusTypeIDs.h"
namespace TPCE {
const TIdent iBrokerNameIDShift = 1000 * 1000; // starting ID to generate names from for brokers
const int iBrokerInitialTradesYTDMin = 10000;
const int iBrokerInitialTradesYTDMax = 100000;
const double fBrokerInitialCommissionYTDMin = 10000.0;
const double fBrokerInitialCommissionYTDMax = 100000.0;
class CBrokersTable : public TableTemplate<BROKER_ROW> {
TIdent m_iTotalBrokers; // total number of brokers rows to generate
TIdent m_iStartFromBroker;
TIdent m_iStartFromCustomer;
CPerson m_person;
const StatusTypeDataFile_t &m_StatusTypeFile; // STATUS_TYPE table from the flat file
int *m_pNumTrades; // array of B_NUM_TRADES values
double *m_pCommTotal; // array of B_COMM_TOTAL values
public:
/*
* Constructor for the BROKER table class.
*
* PARAMETERS:
* IN inputFiles - input flat files loaded in memory
* IN iCustomerCount - customer count
* IN iStartFromCustomer - starting customer id (1-based)
*
* RETURNS:
* not applicable.
*/
CBrokersTable(const DataFileManager &dfm, TIdent iCustomerCount, TIdent iStartFromCustomer)
: TableTemplate<BROKER_ROW>(), m_iTotalBrokers(iCustomerCount / iBrokersDiv),
m_iStartFromBroker((iStartFromCustomer / iBrokersDiv) + iStartingBrokerID + iTIdentShift),
m_iStartFromCustomer(iStartFromCustomer), m_person(dfm, iBrokerNameIDShift, true),
m_StatusTypeFile(dfm.StatusTypeDataFile()), m_pNumTrades(NULL), m_pCommTotal(NULL){};
/*
* Destructor.
*
* PARAMETERS:
* not applicable.
*
* RETURNS:
* not applicable.
*/
~CBrokersTable() {
if (m_pNumTrades != NULL) {
delete[] m_pNumTrades;
}
if (m_pCommTotal != NULL) {
delete[] m_pCommTotal;
}
}
/*
* Initialization method; required when generating data but not for
* run-time.
*
* It is called by CTradeGen at the beginning of every load unit.
*
* PARAMETERS:
* IN iCustomerCount - new customer count
* IN iStartFromCustomer - new starting customer id (1-based)
*
* RETURNS:
* none.
*/
void InitForGen(TIdent iCustomerCount, TIdent iStartFromCustomer) {
TIdent i;
if (m_iTotalBrokers != iCustomerCount / iBrokersDiv || m_pNumTrades == NULL || m_pCommTotal == NULL)
{
// Reallocate arrays for the new number of brokers
//
m_iTotalBrokers = iCustomerCount / iBrokersDiv;
if (m_pNumTrades != NULL) {
delete[] m_pNumTrades;
}
m_pNumTrades = new int[(size_t)m_iTotalBrokers];
if (m_pCommTotal != NULL) {
delete[] m_pCommTotal;
}
m_pCommTotal = new double[(size_t)m_iTotalBrokers];
}
// Initialize array to 0
//
if (m_pNumTrades != NULL) {
for (i = 0; i < m_iTotalBrokers; ++i) {
m_pNumTrades[i] = 0;
}
}
// Initialize array to 0
//
if (m_pCommTotal != NULL) {
for (i = 0; i < m_iTotalBrokers; ++i) {
m_pCommTotal[i] = 0.0;
}
}
if (m_iStartFromBroker != ((iStartFromCustomer / iBrokersDiv) + iStartingBrokerID + iTIdentShift)) {
// Multiplying by iBrokersDiv again to get 64-bit broker ids
// with 4.3bln IDENT_T shift value.
// Removing shift factor prior to arithmetic so that contiguous
// B_IDs values are obtained, and then add it back so that we
// get shifted values.
//
m_iStartFromBroker = (iStartFromCustomer / iBrokersDiv) + iStartingBrokerID + iTIdentShift;
}
m_iLastRowNumber = 0;
ClearRecord(); // this is needed for EGenTest to work
// Don't re-initialize the cache for the first load unit
if (m_iStartFromCustomer != iStartFromCustomer) {
m_person.InitNextLoadUnit(iDefaultLoadUnitSize / iBrokersDiv);
}
};
/*
* Increment year-to-date values for broker trades and commissions.
* Used to preserve consistency with initial trades.
*
* PARAMETERS:
* IN B_ID - broker for whom to update YTD
* values IN iTradeIncrement - number of trades to add IN
* fCommissionIncrement - amount of commission to add
*
* RETURNS:
* none.
*/
void UpdateTradeAndCommissionYTD(TIdent B_ID, int iTradeIncrement, double fCommissionIncrement) {
if ((B_ID >= m_iStartFromBroker) && (B_ID < (m_iStartFromBroker + m_iTotalBrokers))) {
m_pNumTrades[B_ID - m_iStartFromBroker] += iTradeIncrement;
m_pCommTotal[B_ID - m_iStartFromBroker] += fCommissionIncrement;
}
}
/*
* Generate random broker id.
* Exposed mostly for the driver to ensure unique
* broker names for Broker Volume.
* External RNG object is used in order to honor CCE autoseed behavior.
*
* PARAMETERS:
* IN rnd - external RNG
*
* RETURNS:
* random broker id
*/
TIdent GenerateRandomBrokerId(CRandom *pRnd) {
return pRnd->RndInt64Range(m_iStartFromBroker, m_iStartFromBroker + m_iTotalBrokers - 1);
}
/*
* Generate broker name into the provided buffer.
* Exposed mostly for the driver (Broker Volume).
*
* PARAMETERS:
* IN B_ID - broker id
* IN B_NAME - buffer for broker name
* IN B_NAME_len - length of the name buffer
*
* RETURNS:
* none.
*/
void GenerateBrokerName(TIdent B_ID, char *B_NAME, size_t B_NAME_len) {
snprintf(B_NAME, B_NAME_len, "%s %c. %s", m_person.GetFirstName(B_ID + iBrokerNameIDShift).c_str(),
m_person.GetMiddleName(B_ID + iBrokerNameIDShift),
m_person.GetLastName(B_ID + iBrokerNameIDShift).c_str());
}
/*
* Return total broker count.
* Exposed mostly for the driver (Broker Volume).
*
* PARAMETERS:
* none.
*
* RETURNS:
* total number of brokers in the table
*/
TIdent GetBrokerCount() {
return m_iTotalBrokers;
}
/*
* Generates all column values for the next row
* and store them in the internal record structure.
* Increments the number of rows generated.
*
* PARAMETERS:
* none.
*
* RETURNS:
* TRUE, if there are more records in the ADDRESS table; FALSE
* othewise.
*/
bool GenerateNextRecord() {
m_row.B_ID = m_iStartFromBroker + m_iLastRowNumber;
strncpy(m_row.B_ST_ID, m_StatusTypeFile[eActive].ST_ID_CSTR(), sizeof(m_row.B_ST_ID));
GenerateBrokerName(m_row.B_ID, m_row.B_NAME, static_cast<int>(sizeof(m_row.B_NAME)));
m_row.B_NUM_TRADES = m_pNumTrades[m_row.B_ID - m_iStartFromBroker];
m_row.B_COMM_TOTAL = m_pCommTotal[m_row.B_ID - m_iStartFromBroker];
// Update state info
++m_iLastRowNumber;
m_bMoreRecords = m_iLastRowNumber < m_iTotalBrokers;
// Return false if all the rows have been generated
return (MoreRecords());
}
};
} // namespace TPCE
#endif // BROKERS_H

View File

@@ -0,0 +1,208 @@
/*
* 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
*/
/******************************************************************************
* Description: This class provides Customer Emulator functionality.
* It controls the mix of customer-initiated transactions
* and generates all required inputs for each of these
* transactions. These inputs are then made available to
* a sponsor provided callback interface to the SUT (see
* CESUTInterface.h). In addition, a set of constants used
* to uniquely identify each transaction type is exposed.
*
* The constructor for this class is overloaded. The first
* form of the constructor accepts 7 inputs, the last one
* of which is optional (i.e. it has a default value).
* - pSUT: a pointer to an instance of a sponsor provided
* subclassing of the CCESUTInterface class.
* - pLogger: a pointer to an
*instance of CEGenLogger or a sponsor provided subclassing of the CBaseLogger
*class.
* - inputFiles: a reference to an instance of the
* CInputFiles class containing all input files loaded
* into memory.
* - iCustomerCount: the total number of customers to
* emulate. C_IDs will be generated in the range of
* 1 to iCustomerCount.
* - iScaleFactor: the number of customers per tpsE. This
* should match the scale factor used at load time.
* - iDaysOfInitialTrades: the number of days of initial
* trades that was populated during load time.
* - RandomSeed: seed to be used for the RNG.
* - pTxnTunables: (optional). a pointer to a tuning
* structure used to configure the behavior of the CE
* class.
*
* The second form of the constructor accepts all of the
* same inputs as the first form. In addition, however,
* it accepts 3 additional inputs between iCustomerCount
* and iScaleFacto that facilitate partitioning by C_ID
* during runtime.
* - iMyStartingCustomerId: the starting customer ID for
* this instance's partition of C_IDs. This ID must be
* the first ID in a load unit.
* - iMyCustomerCount: the number of customers in this
* instance's partition. The number of customers specified
* must be an integral multiple of the load unit size.
* - iPartitionPercent: the percentage of C_IDs
* that should be generated within this instance's
* partition. 100-iParititionPercent percent of the C_IDs
* will be generated across the full range of C_IDs.
*
* Paritioning Example.
* Based on a load unit size of 1000, assume the following
* valid inputs.
* - iCustomerCount = 5000
* - iMyStartingCustomerID = 2001
* - iMyCustomerCount = 2000
* - iPartitionPercent = 40
* These setting will configure the CE to generated C_IDs
* as follows.
* - 40% of the time in the range [2001 - 4000]
* - 60% of the time in the range [1-5000]
*
* The CE provides the following entry point.
*
* - DoTxn: this entry point will select the next
* transaction type based on the mix settings, generate
* all required inputs for the selected transaction type,
* and provide those inputs to sponsor code at the
* appropriate callback interface.
*
******************************************************************************/
#ifndef CE_H
#define CE_H
#include "utilities/EGenUtilities_stdafx.h"
#include "CETxnInputGenerator.h"
#include "CETxnMixGenerator.h"
#include "CESUTInterface.h"
#include "BaseLogger.h"
#include "DriverParamSettings.h"
#include "input/DataFileManager.h"
namespace TPCE {
class CCE {
private:
CDriverGlobalSettings m_DriverGlobalSettings;
CDriverCESettings m_DriverCESettings;
CDriverCEPartitionSettings m_DriverCEPartitionSettings;
TDriverCETxnSettings m_DriverCETxnSettings;
CCESUTInterface *m_pSUT;
CBaseLogger *m_pLogger;
CCETxnMixGenerator m_TxnMixGenerator;
CCETxnInputGenerator m_TxnInputGenerator;
TBrokerVolumeTxnInput m_BrokerVolumeTxnInput;
TCustomerPositionTxnInput m_CustomerPositionTxnInput;
TMarketWatchTxnInput m_MarketWatchTxnInput;
TSecurityDetailTxnInput m_SecurityDetailTxnInput;
TTradeLookupTxnInput m_TradeLookupTxnInput;
TTradeOrderTxnInput m_TradeOrderTxnInput;
TTradeStatusTxnInput m_TradeStatusTxnInput;
TTradeUpdateTxnInput m_TradeUpdateTxnInput;
// Initialization that is common for all constructors.
void Initialize(PDriverCETxnSettings pTxnParamSettings);
// Automatically generate unique RNG seeds
void AutoSetRNGSeeds(UINT32 UniqueId);
/*
* Zero transaction input buffer.
*
* PARAMETERS:
* IN iTxnType - what transaction to zero the buffer for.
*
* RETURNS:
* none.
*/
void ZeroInputBuffer(int iTxnType);
public:
static const INT32 INVALID_TRANSACTION_TYPE = CCETxnMixGenerator::INVALID_TRANSACTION_TYPE;
static const INT32 SECURITY_DETAIL = CCETxnMixGenerator::SECURITY_DETAIL;
static const INT32 BROKER_VOLUME = CCETxnMixGenerator::BROKER_VOLUME;
static const INT32 CUSTOMER_POSITION = CCETxnMixGenerator::CUSTOMER_POSITION;
static const INT32 MARKET_WATCH = CCETxnMixGenerator::MARKET_WATCH;
static const INT32 TRADE_STATUS = CCETxnMixGenerator::TRADE_STATUS;
static const INT32 TRADE_LOOKUP = CCETxnMixGenerator::TRADE_LOOKUP;
static const INT32 TRADE_ORDER = CCETxnMixGenerator::TRADE_ORDER;
static const INT32 TRADE_UPDATE = CCETxnMixGenerator::TRADE_UPDATE;
// Trade-Result and Market-Feed are included for completness.
static const INT32 MARKET_FEED = CCETxnMixGenerator::MARKET_FEED;
static const INT32 TRADE_RESULT = CCETxnMixGenerator::TRADE_RESULT;
// Constructor - no partitioning by C_ID, automatic RNG seed generation
// (requires unique input)
CCE(CCESUTInterface *pSUT, CBaseLogger *pLogger, const DataFileManager &dfm, TIdent iConfiguredCustomerCount,
TIdent iActiveCustomerCount, INT32 iScaleFactor, INT32 iDaysOfInitialTrades, UINT32 UniqueId,
const PDriverCETxnSettings pParameterSettings = NULL);
// Constructor - no partitioning by C_ID, RNG seeds provided
CCE(CCESUTInterface *pSUT, CBaseLogger *pLogger, const DataFileManager &dfm, TIdent iConfiguredCustomerCount,
TIdent iActiveCustomerCount, INT32 iScaleFactor, INT32 iDaysOfInitialTrades, UINT32 UniqueId,
RNGSEED TxnMixRNGSeed, RNGSEED TxnInputRNGSeed, const PDriverCETxnSettings pParameterSettings = NULL);
// Constructor - partitioning by C_ID, automatic RNG seed generation
// (requires unique input)
CCE(CCESUTInterface *pSUT, CBaseLogger *pLogger, const DataFileManager &dfm, TIdent iConfiguredCustomerCount,
TIdent iActiveCustomerCount, TIdent iMyStartingCustomerId, TIdent iMyCustomerCount, INT32 iPartitionPercent,
INT32 iScaleFactor, INT32 iDaysOfInitialTrades, UINT32 UniqueId,
const PDriverCETxnSettings pParameterSettings = NULL);
// Constructor - partitioning by C_ID, RNG seeds provided
CCE(CCESUTInterface *pSUT, CBaseLogger *pLogger, const DataFileManager &dfm, TIdent iConfiguredCustomerCount,
TIdent iActiveCustomerCount, TIdent iMyStartingCustomerId, TIdent iMyCustomerCount, INT32 iPartitionPercent,
INT32 iScaleFactor, INT32 iDaysOfInitialTrades, UINT32 UniqueId, RNGSEED TxnMixRNGSeed, RNGSEED TxnInputRNGSeed,
const PDriverCETxnSettings pParameterSettings = NULL);
~CCE(void);
RNGSEED GetTxnInputGeneratorRNGSeed(void);
RNGSEED GetTxnMixGeneratorRNGSeed(void);
void SetTxnTunables(const PDriverCETxnSettings pTxnParamSettings);
void DoTxn(void);
};
} // namespace TPCE
#endif // CE_H

View 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
* - Doug Johnson
*/
/******************************************************************************
* Description: Interface base class to be used for deriving a sponsor
* specific class for commmunicating with the SUT for all
* customer-initiated transactions.
******************************************************************************/
#ifndef CE_SUT_INTERFACE_H
#define CE_SUT_INTERFACE_H
#include "TxnHarnessStructs.h"
namespace TPCE {
class CCESUTInterface {
public:
/*
* Virtual destructor. Provided so that a sponsor-specific
* destructor can be called on destruction from the base-class pointer.
*
* PARAMETERS:
* none.
*
* RETURNS:
* not applicable.
*/
virtual ~CCESUTInterface(){};
virtual bool BrokerVolume(PBrokerVolumeTxnInput pTxnInput) = 0; // return whether it was successful
virtual bool CustomerPosition(PCustomerPositionTxnInput pTxnInput) = 0; // return whether it was successful
virtual bool MarketWatch(PMarketWatchTxnInput pTxnInput) = 0; // return whether it was successful
virtual bool SecurityDetail(PSecurityDetailTxnInput pTxnInput) = 0; // return whether it was successful
virtual bool TradeLookup(PTradeLookupTxnInput pTxnInput) = 0; // return whether it was successful
virtual bool TradeOrder(PTradeOrderTxnInput pTxnInput, INT32 iTradeType,
bool bExecutorIsAccountOwner) = 0; // return whether it was successful
virtual bool TradeStatus(PTradeStatusTxnInput pTxnInput) = 0; // return whether it was successful
virtual bool TradeUpdate(PTradeUpdateTxnInput pTxnInput) = 0; // return whether it was successful
};
} // namespace TPCE
#endif // CE_SUT_INTERFACE_H

View File

@@ -0,0 +1,408 @@
/*
* 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
* - Doug Johnson
*/
/*
* Class that generates transaction input data for the Customer Emulator (CE).
*/
#ifndef CE_TXN_INPUT_GENERATOR_H
#define CE_TXN_INPUT_GENERATOR_H
#include "utilities/EGenUtilities_stdafx.h"
#include "TxnHarnessStructs.h"
#include "DriverParamSettings.h"
#include "EGenLogger.h"
#include "input/DataFileManager.h"
#include "Brokers.h"
#include "HoldingsAndTradesTable.h"
namespace TPCE {
class CCETxnInputGenerator {
CRandom m_rnd; // used inside for parameter generation
CPerson m_Person;
CCustomerSelection m_CustomerSelection;
CCustomerAccountsAndPermissionsTable m_AccsAndPerms;
CHoldingsAndTradesTable m_Holdings;
CBrokersTable m_Brokers;
const CCompanyFile &m_pCompanies;
const CSecurityFile &m_pSecurities;
const IndustryDataFile_t &m_pIndustries;
const SectorDataFile_t &m_pSectors;
const StatusTypeDataFile_t &m_pStatusType;
const TradeTypeDataFile_t &m_pTradeType;
PDriverCETxnSettings m_pDriverCETxnSettings;
CBaseLogger *m_pLogger;
TIdent m_iConfiguredCustomerCount;
TIdent m_iActiveCustomerCount;
TIdent m_iMyStartingCustomerId;
TIdent m_iMyCustomerCount;
INT32 m_iPartitionPercent;
INT32 m_iScaleFactor;
INT32 m_iHoursOfInitialTrades;
INT64 m_iMaxActivePrePopulatedTradeID;
INT64 m_iTradeLookupFrame2MaxTimeInMilliSeconds;
INT64 m_iTradeLookupFrame3MaxTimeInMilliSeconds;
INT64 m_iTradeLookupFrame4MaxTimeInMilliSeconds;
INT64 m_iTradeUpdateFrame2MaxTimeInMilliSeconds;
INT64 m_iTradeUpdateFrame3MaxTimeInMilliSeconds;
// number of securities (scaled based on active customers)
TIdent m_iActiveSecurityCount;
TIdent m_iActiveCompanyCount;
// number of industries (from flat file)
INT32 m_iIndustryCount;
// number of sector names (from flat file)
INT32 m_iSectorCount;
// starting ids
TIdent m_iStartFromCompany;
CDateTime m_StartTime; // start time of initial trades
CDateTime m_EndTime; // end time of initial trades
INT32 m_iTradeOrderRollbackLimit;
INT32 m_iTradeOrderRollbackLevel;
/*
* Perform initialization common to all constructors.
*
* PARAMETERS:
* IN pDriverCETxnSettings - initial transaction parameter
* settings
*
* RETURNS:
* none.
*/
void Initialize();
/*
* Generate Non-Uniform customer ID.
*
* PARAMETERS:
* OUT iCustomerId - generated C_ID
* OUT iCustomerTier - generated C_TIER
*
* RETURNS:
* none.
*/
void GenerateNonUniformRandomCustomerId(TIdent &iCustomerId, eCustomerTier &iCustomerTier);
/*
* Generate customer account ID (uniformly distributed).
*
* PARAMETERS:
* none.
*
* RETURNS:
* CA_ID uniformly distributed across all load units.
*/
TIdent GenerateRandomCustomerAccountId(void);
/*
* Generate a trade id to be used in Trade-Lookup / Trade-Update Frame 1.
*
* PARAMETERS:
* IN AValue - parameter to NURAND function
* IN SValue - parameter to NURAND function
*
* RETURNS:
* T_ID, distributed non-uniformly.
*/
TTrade GenerateNonUniformTradeID(INT32 AValue, INT32 SValue);
/*
* Generate a trade timestamp to be used in Trade-Lookup / Trade-Update.
*
* PARAMETERS:
* OUT dts - returned timestamp
* IN MaxTimeInMilliSeconds - time interval (from the first
* initial trade) in which to generate the timestamp IN AValue - parameter
* to NURAND function IN SValue - parameter to NURAND
* function
*
* RETURNS:
* none.
*/
void GenerateNonUniformTradeDTS(TIMESTAMP_STRUCT &dts, INT64 MaxTimeInMilliSeconds, INT32 AValue, INT32 SValue);
public:
/*
* Constructor - no partitioning by C_ID.
*
* PARAMETERS:
* IN dfm - Data file manager
* IN iConfiguredCustomerCount - number of configured
* customers in the database IN iActiveCustomerCount - number of
* active customers in the database IN iScaleFactor - scale
* factor (number of customers per 1 tpsE) of the database IN
* iHoursOfInitialTrades - number of hours of the initial trades
* portion of the database IN pLogger - reference to
* parameter logging object IN pDriverCETxnSettings - initial
* transaction parameter settings
*
* RETURNS:
* not applicable.
*/
CCETxnInputGenerator(const DataFileManager &dfm, TIdent iConfiguredCustomerCount, TIdent iActiveCustomerCount,
INT32 iScaleFactor, INT32 iHoursOfInitialTrades, CBaseLogger *pLogger,
const PDriverCETxnSettings pDriverCETxnTunables);
/*
* Constructor - no partitioning by C_ID, RNG seed provided.
*
* RNG seed is for testing/engineering work allowing repeatable transaction
* parameter stream. This constructor is NOT legal for a benchmark
* publication.
*
* PARAMETERS:
* IN dfm - Data file manager
* IN iConfiguredCustomerCount - number of configured
* customers in the database IN iActiveCustomerCount - number of
* active customers in the database IN iScaleFactor - scale
* factor (number of customers per 1 tpsE) of the database IN
* iHoursOfInitialTrades - number of hours of the initial trades
* portion of the database IN RNGSeed - initial seed
* for random number generator IN pLogger - reference
* to parameter logging object IN pDriverCETxnSettings - initial
* transaction parameter settings
*
* RETURNS:
* not applicable.
*/
CCETxnInputGenerator(const DataFileManager &dfm, TIdent iConfiguredCustomerCount, TIdent iActiveCustomerCount,
INT32 iScaleFactor, INT32 iHoursOfInitialTrades, RNGSEED RNGSeed, CBaseLogger *pLogger,
const PDriverCETxnSettings pDriverCETxnTunables);
/*
* Constructor - partitioning by C_ID.
*
* PARAMETERS:
* IN dfm - Data file manager
* IN iConfiguredCustomerCount - number of configured
* customers in the database IN iActiveCustomerCount - number of
* active customers in the database IN iScaleFactor - scale
* factor (number of customers per 1 tpsE) of the database IN
* iHoursOfInitialTrades - number of hours of the initial trades
* portion of the database IN iMyStartingCustomerId - first customer
* id (1-based) of the partition for this instance IN iMyCustomerCount -
* number of customers in the partition for this instance IN
* iPartitionPercent - the percentage of C_IDs generated within
* this instance's partition IN pLogger - reference to
* parameter logging object IN pDriverCETxnSettings - initial
* transaction parameter settings
*
* RETURNS:
* not applicable.
*/
CCETxnInputGenerator(const DataFileManager &dfm, TIdent iConfiguredCustomerCount, TIdent iActiveCustomerCount,
INT32 iScaleFactor, INT32 iHoursOfInitialTrades, TIdent iMyStartingCustomerId,
TIdent iMyCustomerCount, INT32 iPartitionPercent, CBaseLogger *pLogger,
const PDriverCETxnSettings pDriverCETxnTunables);
/*
* Constructor - partitioning by C_ID, RNG seed provided.
*
* RNG seed is for testing/engineering work allowing repeatable transaction
* parameter stream. This constructor is NOT legal for a benchmark
* publication.
*
* PARAMETERS:
* IN dfm - Data file manager
* IN iConfiguredCustomerCount - number of configured
* customers in the database IN iActiveCustomerCount - number of
* active customers in the database IN iScaleFactor - scale
* factor (number of customers per 1 tpsE) of the database IN
* iHoursOfInitialTrades - number of hours of the initial trades
* portion of the database IN iMyStartingCustomerId - first customer
* id (1-based) of the partition for this instance IN iMyCustomerCount -
* number of customers in the partition for this instance IN
* iPartitionPercent - the percentage of C_IDs generated within
* this instance's partition IN pLogger - reference to
* parameter logging object IN pDriverCETxnSettings - initial
* transaction parameter settings
*
* RETURNS:
* not applicable.
*/
CCETxnInputGenerator(const DataFileManager &dfm, TIdent iConfiguredCustomerCount, TIdent iActiveCustomerCount,
INT32 iScaleFactor, INT32 iHoursOfInitialTrades, TIdent iMyStartingCustomerId,
TIdent iMyCustomerCount, INT32 iPartitionPercent, RNGSEED RNGSeed, CBaseLogger *pLogger,
const PDriverCETxnSettings pDriverCETxnTunables);
/*
* Return internal random number generator seed.
*
* PARAMETERS:
* none.
*
* RETURNS:
* current random number generator seed.
*/
RNGSEED GetRNGSeed(void);
/*
* Set internal random number generator seed.
*
* PARAMETERS:
* IN RNGSeed - new random number generator seed
*
* RETURNS:
* none.
*/
void SetRNGSeed(RNGSEED RNGSeed);
/*
* Refresh internal information from the external transaction parameters.
* This function should be called anytime the external transaction
* parameter structure changes.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void UpdateTunables();
/*
* Generate Broker-Volume transaction input.
*
* PARAMETERS:
* OUT TxnReq - input parameter structure filled
* in for the transaction.
*
* RETURNS:
* the number of brokers generated.
*/
void GenerateBrokerVolumeInput(TBrokerVolumeTxnInput &TxnReq);
/*
* Generate Customer-Position transaction input.
*
* PARAMETERS:
* OUT TxnReq - input parameter structure filled
* in for the transaction.
*
* RETURNS:
* none.
*/
void GenerateCustomerPositionInput(TCustomerPositionTxnInput &TxnReq);
/*
* Generate Market-Watch transaction input.
*
* PARAMETERS:
* OUT TxnReq - input parameter structure filled
* in for the transaction.
*
* RETURNS:
* none.
*/
void GenerateMarketWatchInput(TMarketWatchTxnInput &TxnReq);
/*
* Generate Security-Detail transaction input.
*
* PARAMETERS:
* OUT TxnReq - input parameter structure filled
* in for the transaction.
*
* RETURNS:
* none.
*/
void GenerateSecurityDetailInput(TSecurityDetailTxnInput &TxnReq);
/*
* Generate Trade-Lookup transaction input.
*
* PARAMETERS:
* OUT TxnReq - input parameter structure filled
* in for the transaction.
*
* RETURNS:
* none.
*/
void GenerateTradeLookupInput(TTradeLookupTxnInput &TxnReq);
/*
* Generate Trade-Order transaction input.
*
* PARAMETERS:
* OUT TxnReq - input parameter structure filled
* in for the transaction. OUT TradeType - integer
* representation of generated trade type (as eTradeTypeID enum). OUT
* bExecutorIsAccountOwner - whether Trade-Order frame 2 should (FALSE) or
* shouldn't (TRUE) be called.
*
* RETURNS:
* none.
*/
void GenerateTradeOrderInput(TTradeOrderTxnInput &TxnReq, INT32 &iTradeType, bool &bExecutorIsAccountOwner);
/*
* Generate Trade-Status transaction input.
*
* PARAMETERS:
* OUT TxnReq - input parameter structure filled
* in for the transaction.
*
* RETURNS:
* none.
*/
void GenerateTradeStatusInput(TTradeStatusTxnInput &TxnReq);
/*
* Generate Trade-Update transaction input.
*
* PARAMETERS:
* OUT TxnReq - input parameter structure filled
* in for the transaction.
*
* RETURNS:
* none.
*/
void GenerateTradeUpdateInput(TTradeUpdateTxnInput &TxnReq);
};
} // namespace TPCE
#endif // #ifndef CE_TXN_INPUT_GENERATOR_H

View File

@@ -0,0 +1,107 @@
/*
* 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, Cecil Reames, Matt Emmerton
*/
/******************************************************************************
* Description: EGenDriverCE class to generate transaction types for
* execution
******************************************************************************/
#ifndef CE_TXN_MIX_GENERATOR_H
#define CE_TXN_MIX_GENERATOR_H
#include "utilities/EGenUtilities_stdafx.h"
#include "DriverParamSettings.h"
#include "EGenLogger.h"
namespace TPCE {
class CCETxnMixGenerator {
private:
const PDriverCETxnSettings m_pDriverCETxnSettings;
CRandom m_rnd;
CBaseLogger *m_pLogger;
// Transaction mixes are expressed out of a total of 1000.
//
// NOTE that Trade-Result and Market-Feed are not generated by this class
// as possible runtime transaction types. They happen as an automatic
// by-product of Trade-Order transactions.
INT32 m_CETransactionMixTotal;
/*INT32 m_BrokerVolumeMixLimit;
INT32 m_CustomerPositionMixLimit;
INT32 m_MarketWatchMixLimit;
INT32 m_SecurityDetailMixLimit;
INT32 m_TradeLookupMixLimit;
INT32 m_TradeOrderMixLimit;
INT32 m_TradeStatusMixLimit;
INT32 m_TradeUpdateMixLimit;*/
// Array of transaction types used for "shuffle a deck of cards"
// algorithm (also known as Knuth shuffle).
//
INT32 m_iTxnArrayCurrentIndex;
char *m_pTxnArray;
public:
static const INT32 INVALID_TRANSACTION_TYPE = -1;
static const INT32 SECURITY_DETAIL = 0;
static const INT32 BROKER_VOLUME = 1;
static const INT32 CUSTOMER_POSITION = 2;
static const INT32 MARKET_WATCH = 3;
static const INT32 TRADE_STATUS = 4;
static const INT32 TRADE_LOOKUP = 5;
static const INT32 TRADE_ORDER = 6;
static const INT32 TRADE_UPDATE = 7;
// Trade-Result and Market-Feed are included for completness.
static const INT32 MARKET_FEED = 8;
static const INT32 TRADE_RESULT = 9;
CCETxnMixGenerator(const PDriverCETxnSettings pTxnParamSettings, CBaseLogger *pLogger);
CCETxnMixGenerator(const PDriverCETxnSettings pTxnParamSettings, RNGSEED RNGSeed, CBaseLogger *pLogger);
~CCETxnMixGenerator();
RNGSEED GetRNGSeed(void);
void SetRNGSeed(RNGSEED RNGSeed);
void UpdateTunables(void);
int GenerateNextTxnType(void);
};
} // namespace TPCE
#endif // #ifndef CE_TXN_MIX_GENERATOR_H

View File

@@ -0,0 +1,59 @@
/*
* 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
*/
/*
* Class representing the Charge table.
*/
#ifndef CHARGE_TABLE_H
#define CHARGE_TABLE_H
#include "FixedTable.h"
#include "input/DataFileTypes.h"
#include "TableRows.h"
namespace TPCE {
class CChargeTable : public FixedTable<ChargeDataFile_t, CHARGE_ROW> {
public:
CChargeTable(const ChargeDataFile_t &dataFile);
~CChargeTable();
virtual void LoadTableRow();
};
} // namespace TPCE
#endif // CHARGE_TABLE_H

View File

@@ -0,0 +1,61 @@
/*
* 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
*/
/*
* Class representing the CommissionRate table.
*/
#ifndef COMMISSION_RATE_TABLE_H
#define COMMISSION_RATE_TABLE_H
#include <cstring>
#include "FixedTable.h"
#include "input/DataFileTypes.h"
#include "TableRows.h"
namespace TPCE {
class CCommissionRateTable : public FixedTable<CommissionRateDataFile_t, COMMISSION_RATE_ROW> {
public:
CCommissionRateTable(const CommissionRateDataFile_t &dataFile);
~CCommissionRateTable();
virtual void LoadTableRow();
};
} // namespace TPCE
#endif // COMMISSION_RATE_TABLE_H

View File

@@ -0,0 +1,106 @@
/*
* 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
*/
/*
* Class representing the CompanyCompetitor table.
*/
#ifndef COMPANY_COMPETITOR_TABLE_H
#define COMPANY_COMPETITOR_TABLE_H
#include "EGenTables_common.h"
#include "input/DataFileManager.h"
namespace TPCE {
class CCompanyCompetitorTable : public TableTemplate<COMPANY_COMPETITOR_ROW> {
const CCompanyCompetitorFile &m_CompanyCompetitorFile;
TIdent m_iCompanyCompetitorCount;
TIdent m_iStartFromCompanyCompetitor;
TIdent m_iCompanyCompetitorCountForOneLoadUnit;
/*
* Reset the state for the next load unit.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void InitNextLoadUnit() {
// No RNG calls in this class, so don't need to reset the RNG.
ClearRecord(); // this is needed for EGenTest to work
}
public:
CCompanyCompetitorTable(const DataFileManager &dfm, TIdent iCustomerCount, TIdent iStartFromCustomer)
: TableTemplate<COMPANY_COMPETITOR_ROW>(), m_CompanyCompetitorFile(dfm.CompanyCompetitorFile()) {
m_iCompanyCompetitorCount = m_CompanyCompetitorFile.CalculateCompanyCompetitorCount(iCustomerCount);
m_iStartFromCompanyCompetitor = m_CompanyCompetitorFile.CalculateStartFromCompanyCompetitor(iStartFromCustomer);
m_iLastRowNumber = m_iStartFromCompanyCompetitor;
m_iCompanyCompetitorCountForOneLoadUnit =
m_CompanyCompetitorFile.CalculateCompanyCompetitorCount(iDefaultLoadUnitSize);
};
/*
* Generates all column values for the next row.
*/
bool GenerateNextRecord() {
if (m_iLastRowNumber % m_iCompanyCompetitorCountForOneLoadUnit == 0) {
InitNextLoadUnit();
}
m_row.CP_CO_ID = m_CompanyCompetitorFile.GetCompanyId(m_iLastRowNumber);
m_row.CP_COMP_CO_ID = m_CompanyCompetitorFile.GetCompanyCompetitorId(m_iLastRowNumber);
strncpy(m_row.CP_IN_ID, m_CompanyCompetitorFile.GetIndustryIdCSTR(m_iLastRowNumber), sizeof(m_row.CP_IN_ID));
++m_iLastRowNumber;
m_bMoreRecords = m_iLastRowNumber < m_iStartFromCompanyCompetitor + m_iCompanyCompetitorCount;
return (MoreRecords());
}
};
} // namespace TPCE
#endif // COMPANY_COMPETITOR_TABLE_H

View File

@@ -0,0 +1,234 @@
/*
* 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
* - Doug Johnson
*/
/*
* Class representing the Company table.
*/
#ifndef COMPANY_TABLE_H
#define COMPANY_TABLE_H
#include "EGenTables_common.h"
#include "input/DataFileManager.h"
namespace TPCE {
const int iCEOMult = 1000; // for generating CEO name
// Number of RNG calls to skip for one row in order
// to not use any of the random values from the previous row.
//
const int iRNGSkipOneRowCompany = 2; // one for SP rate and one for CO_OPEN_DATE
class CCompanyTable : public TableTemplate<COMPANY_ROW> {
const CCompanyFile &m_CompanyFile;
const CompanySPRateDataFile_t &m_CompanySPRateFile;
CPerson m_person; // for CEO
CDateTime m_date;
TIdent m_iCO_AD_ID_START; // starting address id for companies
int m_iJan1_1800_DayNo;
int m_iJan2_2000_DayNo;
int m_iCurrentDayNo;
TIdent m_iCompanyCountForOneLoadUnit;
TIdent m_iCompanyCount;
TIdent m_iStartFromCompany;
/*
* Generate distribution for the company inside S&P Rating file.
*
* PARAMETERS:
* none.
*
* RETURNS:
* threshold in the set of S&P credit ratings.
*/
int GetCompanySPRateThreshold() {
RNGSEED OldSeed;
int iCompanySPRateThreshold;
OldSeed = m_rnd.GetSeed();
m_rnd.SetSeed(m_rnd.RndNthElement(RNGSeedBaseSPRate, (RNGSEED)m_row.CO_ID));
iCompanySPRateThreshold = m_rnd.RndIntRange(0, m_CompanySPRateFile.size() - 1);
m_rnd.SetSeed(OldSeed);
return (iCompanySPRateThreshold);
}
/*
* S&P Credit Rating for the current company.
* It is stored in the current record structure.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateCompanySPRate(void) {
int iThreshold = GetCompanySPRateThreshold();
// Select the row in the input file
strncpy(m_row.CO_SP_RATE, m_CompanySPRateFile[iThreshold].CO_SP_RATE_CSTR(), sizeof(m_row.CO_SP_RATE));
}
/*
* Reset the state for the next load unit.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void InitNextLoadUnit() {
m_rnd.SetSeed(m_rnd.RndNthElement(RNGSeedTableDefault, (RNGSEED)m_iLastRowNumber * iRNGSkipOneRowCompany));
ClearRecord(); // this is needed for EGenTest to work
}
public:
/*
* Constructor.
*
* PARAMETERS:
* IN inputFiles - input flat files loaded in memory
* IN iCustomerCount - number of customers to generate
* IN iStartFromCustomer - ordinal position of the first
* customer in the sequence (Note: 1-based)
*
* RETURNS:
* not applicable.
*/
CCompanyTable(const DataFileManager &dfm, TIdent iCustomerCount, TIdent iStartFromCustomer)
: TableTemplate<COMPANY_ROW>(), m_CompanyFile(dfm.CompanyFile()),
m_CompanySPRateFile(dfm.CompanySPRateDataFile()), m_person(dfm, 0, false) {
m_iJan1_1800_DayNo = CDateTime::YMDtoDayno(1800, 1, 1); // days number for Jan 1, 1800
m_iJan2_2000_DayNo = CDateTime::YMDtoDayno(2000, 1, 2); // days number for Jan 2, 2000
m_iCurrentDayNo = m_date.DayNo(); // today's days number
m_iCompanyCountForOneLoadUnit = m_CompanyFile.CalculateCompanyCount(iDefaultLoadUnitSize);
m_iCompanyCount = m_CompanyFile.CalculateCompanyCount(iCustomerCount);
m_iStartFromCompany = m_CompanyFile.CalculateStartFromCompany(iStartFromCustomer);
m_iLastRowNumber = m_iStartFromCompany;
// Start Company addresses immediately after Exchange addresses,
// and company addresses for prior companies
m_iCO_AD_ID_START = dfm.ExchangeDataFile().size() + m_iStartFromCompany + iTIdentShift;
};
/*
* Generate and store state information for the next CO_ID.
* The number of rows generated is incremented. This is why
* this function cannot be called more than once for a record.
*
* PARAMETERS:
* none.
*
* RETURNS:
* TRUE, if there are more company ids to generate; FALSE, otherwise.
*/
bool GenerateNextCO_ID() {
++m_iLastRowNumber;
m_bMoreRecords = m_iLastRowNumber < (m_iStartFromCompany + m_iCompanyCount);
return (MoreRecords());
}
/*
* Return the current CO_ID. Since it doesn't generate the next CO_ID,
* this function can be called many times for the same record.
*
* PARAMETERS:
* none.
*
* RETURNS:
* CO_ID in the current record.
*/
TIdent GetCurrentCO_ID() {
return (m_CompanyFile.GetCompanyId(m_iLastRowNumber));
}
/*
* Generate all column values for the next row
* and store them in the internal record structure.
* Increment the number of rows generated.
*
* PARAMETERS:
* none.
*
* RETURNS:
* TRUE, if there are more records in the ADDRESS table; FALSE
* othewise.
*/
bool GenerateNextRecord() {
int iFoundDayNo;
// Reset RNG at Load Unit boundary, so that all data is repeatable.
//
if (m_iLastRowNumber % m_iCompanyCountForOneLoadUnit == 0) {
InitNextLoadUnit();
}
m_row.CO_ID = GetCurrentCO_ID();
strncpy(m_row.CO_ST_ID, m_CompanyFile.GetRecord(m_iLastRowNumber).CO_ST_ID_CSTR(), sizeof(m_row.CO_ST_ID));
m_CompanyFile.CreateName(m_iLastRowNumber, m_row.CO_NAME, static_cast<int>(sizeof(m_row.CO_NAME)));
strncpy(m_row.CO_IN_ID, m_CompanyFile.GetRecord(m_iLastRowNumber).CO_IN_ID_CSTR(), sizeof(m_row.CO_IN_ID));
GenerateCompanySPRate();
snprintf(m_row.CO_CEO, sizeof(m_row.CO_CEO), "%s %s", m_person.GetFirstName(iCEOMult * m_row.CO_ID).c_str(),
m_person.GetLastName(iCEOMult * m_row.CO_ID).c_str());
strncpy(m_row.CO_DESC, m_CompanyFile.GetRecord(m_iLastRowNumber).CO_DESC_CSTR(), sizeof(m_row.CO_DESC));
m_row.CO_AD_ID = ++m_iCO_AD_ID_START;
iFoundDayNo = m_rnd.RndIntRange(m_iJan1_1800_DayNo, m_iJan2_2000_DayNo);
m_row.CO_OPEN_DATE.Set(iFoundDayNo);
// Update state info
return GenerateNextCO_ID();
}
};
} // namespace TPCE
#endif // COMPANY_TABLE_H

View File

@@ -0,0 +1,764 @@
/*
* 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
* - Doug Johnson
*/
/*
* Class representing the Customer Accounts table.
*/
#ifndef CUSTOMER_ACCOUNTS_AND_PERMISSIONS_TABLE_H
#define CUSTOMER_ACCOUNTS_AND_PERMISSIONS_TABLE_H
#include "EGenTables_common.h"
#include "CustomerTable.h"
#include "AddressTable.h"
#include "input/DataFileManager.h"
namespace TPCE {
const UINT iMaxCAPerms = 3; // maximum # of customers having permissions to the same account
const UINT iMinAccountsPerCustRange[3] = {1, 2, 5};
const UINT iMaxAccountsPerCustRange[3] = {4, 8, 10};
const UINT iMaxAccountsPerCust = 10; // must be the biggest number in iMaxAccountsPerCustRange array
const TIdent iStartingBrokerID = 1;
// This is the fixed range from which person ids (like CIDs) are selected
// for the *additional* permissions on the account that make the
// content of ACCOUNT_PERMISSION table.
//
// The range is fixed for any size database in order for the parallel loaders
// to select person ids the same way and be compatible with runtime driver
// (and to avoid database size parameter to the loader executable).
//
const TIdent iAccountPermissionIDRange = INT64_CONST(4024) * 1024 * 1024 - iDefaultStartFromCustomer;
const UINT iPercentAccountsWithPositiveInitialBalance = 80;
const double fAccountInitialPositiveBalanceMax = 9999999.99;
const double fAccountInitialNegativeBalanceMin = -9999999.99;
const UINT iPercentAccountAdditionalPermissions_0 = 60;
const UINT iPercentAccountAdditionalPermissions_1 = 38;
const UINT iPercentAccountAdditionalPermissions_2 = 2;
const UINT iPercentAccountTaxStatusNonTaxable = 20;
const UINT iPercentAccountTaxStatusTaxableAndWithhold = 50;
const UINT iPercentAccountTaxStatusTaxableAndDontWithhold = 30;
// Number of RNG calls to skip for one row in order
// to not use any of the random values from the previous row.
const UINT iRNGSkipOneRowCustomerAccount = 10; // real max count in v3.5: 7
enum eTaxStatus { eNone = -1, eNonTaxable = 0, eTaxableAndWithhold, eTaxableAndDontWithhold };
typedef struct CUSTOMER_ACCOUNT_AND_PERMISSION_ROW {
CUSTOMER_ACCOUNT_ROW m_ca;
ACCOUNT_PERMISSION_ROW m_perm[iMaxCAPerms + 1];
} * PCUSTOMER_ACCOUNT_AND_PERMISSION_ROW;
class CCustomerAccountsAndPermissionsTable : public TableTemplate<CUSTOMER_ACCOUNT_AND_PERMISSION_ROW> {
const TaxableAccountNameDataFile_t &m_TaxableAccountName;
const NonTaxableAccountNameDataFile_t &m_NonTaxableAccountName;
TIdent m_iStartFromCustomer;
TIdent m_iCustomerCount;
TIdent m_iStartingCA_ID; // first CA_ID for the current customer
UINT m_iRowsToGenForCust; // total # of rows to generate for a given
// portfolio
UINT m_iRowsGeneratedForCust; // rows already generated for a particular
// portfolio
CCustomerTable m_cust;
CPerson m_person;
UINT m_iPermsForCA;
TIdent m_iBrokersCount;
CAddressTable m_addr; // ADDRESS table - to calculate tax for TRADE
UINT m_iLoadUnitSize;
CCustomerSelection m_CustomerSelection;
bool m_bCacheEnabled;
int m_iCacheSizeNA;
TIdent m_iCacheOffsetNA;
UINT *m_CacheNA;
int m_iCacheSizeTS;
TIdent m_iCacheOffsetTS;
eTaxStatus *m_CacheTS;
/*
* Generate only the Customer Account row.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateCARow() {
int iAcctType;
// Generate customer account row.
//
GenerateNextCA_AD();
m_row.m_ca.CA_C_ID = GetCurrentC_ID(); // get from CUSTOMER
// Generate broker id.
m_row.m_ca.CA_B_ID = GenerateBrokerIdForAccount(m_row.m_ca.CA_ID);
// Generate tax status and account name.
if ((m_row.m_ca.CA_TAX_ST = (char)GetAccountTaxStatus(m_row.m_ca.CA_ID)) ==
eNonTaxable) { // non-taxable account
iAcctType = (int)m_row.m_ca.CA_ID % m_NonTaxableAccountName.size(); // select account type
snprintf(m_row.m_ca.CA_NAME, sizeof(m_row.m_ca.CA_NAME), "%s %s %s",
m_person.GetFirstName(m_row.m_ca.CA_C_ID).c_str(),
m_person.GetLastName(m_row.m_ca.CA_C_ID).c_str(), m_NonTaxableAccountName[iAcctType].NAME_CSTR());
} else { // taxable account
iAcctType = (int)m_row.m_ca.CA_ID % m_TaxableAccountName.size(); // select account type
snprintf(m_row.m_ca.CA_NAME, sizeof(m_row.m_ca.CA_NAME), "%s %s %s",
m_person.GetFirstName(m_row.m_ca.CA_C_ID).c_str(),
m_person.GetLastName(m_row.m_ca.CA_C_ID).c_str(), m_TaxableAccountName[iAcctType].NAME_CSTR());
}
if (m_rnd.RndPercent(iPercentAccountsWithPositiveInitialBalance)) {
m_row.m_ca.CA_BAL = m_rnd.RndDoubleIncrRange(0.00, fAccountInitialPositiveBalanceMax, 0.01);
} else {
m_row.m_ca.CA_BAL = m_rnd.RndDoubleIncrRange(fAccountInitialNegativeBalanceMin, 0.00, 0.01);
}
}
/*
* Helper function to generate parts of an ACCOUNT_PERMISSION row.
*
* PARAMETERS:
* IN CA_ID - customer account id
* IN C_ID - customer id
* IN szACL - Access-Control-List string on the account
* OUT row - ACCOUNT_PERMISSION row structure to fill
*
* RETURNS:
* none.
*/
void FillAPRow(TIdent CA_ID, TIdent C_ID, const char *szACL, ACCOUNT_PERMISSION_ROW &row) {
row.AP_CA_ID = CA_ID;
m_cust.GetC_TAX_ID(C_ID, row.AP_TAX_ID);
strncpy(row.AP_L_NAME, m_person.GetLastName(C_ID).c_str(), sizeof(row.AP_L_NAME));
strncpy(row.AP_F_NAME, m_person.GetFirstName(C_ID).c_str(), sizeof(row.AP_F_NAME));
strncpy(row.AP_ACL, szACL, sizeof(row.AP_ACL));
}
/*
* Generate only the Account Permissions row(s).
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAPRows() {
int iAdditionalPerms;
TIdent CID_1, CID_2;
// Generate account permissions rows.
// Generate the owner row
FillAPRow(m_row.m_ca.CA_ID, m_row.m_ca.CA_C_ID, "0000", m_row.m_perm[0]);
iAdditionalPerms = GetNumPermsForCA(m_row.m_ca.CA_ID);
switch (iAdditionalPerms) {
case 0:
m_iPermsForCA = 1; // 60%
break;
case 1:
GetCIDsForPermissions(m_row.m_ca.CA_ID, m_row.m_ca.CA_C_ID, &CID_1, NULL);
m_iPermsForCA = 2; // 38%
// generate second account permission row
FillAPRow(m_row.m_ca.CA_ID, CID_1, "0001", m_row.m_perm[1]);
break;
case 2:
GetCIDsForPermissions(m_row.m_ca.CA_ID, m_row.m_ca.CA_C_ID, &CID_1, &CID_2);
m_iPermsForCA = 3; // 2%
// generate second account permission row
FillAPRow(m_row.m_ca.CA_ID, CID_1, "0001", m_row.m_perm[1]);
// generate third account permission row
FillAPRow(m_row.m_ca.CA_ID, CID_2, "0011", m_row.m_perm[2]);
break;
}
}
public:
/*
* Constructor.
*
* PARAMETERS:
* IN dfm - input flat files loaded in memory
* IN iLoadUnitSize - should always be 1000
* IN iCustomerCount - number of customers to generate
* IN iStartFromCustomer - ordinal position of the first
* customer in the sequence (Note: 1-based)
*
* RETURNS:
* not applicable.
*/
CCustomerAccountsAndPermissionsTable(const DataFileManager &dfm,
UINT iLoadUnitSize, // # of customers in one load unit
TIdent iCustomerCount, TIdent iStartFromCustomer, bool bCacheEnabled = false)
: TableTemplate<CUSTOMER_ACCOUNT_AND_PERMISSION_ROW>(), m_TaxableAccountName(dfm.TaxableAccountNameDataFile()),
m_NonTaxableAccountName(dfm.NonTaxableAccountNameDataFile()), m_iStartFromCustomer(iStartFromCustomer),
m_iCustomerCount(iCustomerCount), m_iRowsToGenForCust(0), m_iRowsGeneratedForCust(0),
m_cust(dfm, iCustomerCount, iStartFromCustomer), m_person(dfm, iStartFromCustomer, bCacheEnabled),
m_iPermsForCA(0), m_iBrokersCount(iLoadUnitSize / iBrokersDiv),
m_addr(dfm, iCustomerCount, iStartFromCustomer, bCacheEnabled), m_iLoadUnitSize(iLoadUnitSize),
m_bCacheEnabled(bCacheEnabled) {
if (m_bCacheEnabled) {
m_iCacheSizeNA = iDefaultLoadUnitSize;
m_iCacheOffsetNA = iStartFromCustomer + iTIdentShift;
m_CacheNA = new UINT[m_iCacheSizeNA];
for (int i = 0; i < m_iCacheSizeNA; i++) {
m_CacheNA[i] = 0;
}
m_iCacheSizeTS = iDefaultLoadUnitSize * iMaxAccountsPerCust;
m_iCacheOffsetTS = ((iStartFromCustomer - 1) + iTIdentShift) * iMaxAccountsPerCust;
m_CacheTS = new eTaxStatus[m_iCacheSizeTS];
for (int i = 0; i < m_iCacheSizeTS; i++) {
m_CacheTS[i] = eNone;
}
}
};
/*
* Destructor.
*/
~CCustomerAccountsAndPermissionsTable() {
if (m_bCacheEnabled) {
delete[] m_CacheNA;
delete[] m_CacheTS;
}
};
/*
* Reset the state for the next load unit.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void InitNextLoadUnit() {
m_rnd.SetSeed(m_rnd.RndNthElement(
RNGSeedTableDefault, (RNGSEED)(GetCurrentC_ID() * iMaxAccountsPerCust * iRNGSkipOneRowCustomerAccount)));
ClearRecord(); // this is needed for EGenTest to work
if (m_bCacheEnabled) {
m_iCacheOffsetNA += iDefaultLoadUnitSize;
for (int i = 0; i < m_iCacheSizeNA; i++) {
m_CacheNA[i] = 0;
}
m_iCacheOffsetTS += iDefaultLoadUnitSize * iMaxAccountsPerCust;
for (int i = 0; i < m_iCacheSizeTS; i++) {
m_CacheTS[i] = eNone;
}
}
}
/*
* Generate the number of accounts for a given customer id.
*
* PARAMETERS:
* IN CID - customer id
* IN iCustomerTier - customer tier (indicating trading
* frequency)
*
* RETURNS:
* number of accounts
*/
UINT GetNumberOfAccounts(TIdent CID, eCustomerTier iCustomerTier) {
UINT iNumAccounts = 0;
// We will sometimes get CID values that are outside the current
// load unit (cached range). We need to check for this case
// and avoid the lookup (as we will segfault or get bogus data.)
TIdent index = CID - m_iCacheOffsetNA;
bool bCheckCache = (index >= 0 && index < m_iCacheSizeNA);
if (m_bCacheEnabled && bCheckCache) {
iNumAccounts = m_CacheNA[index];
}
if (iNumAccounts == 0) {
UINT iMinAccountCount;
UINT iMod;
UINT iInverseCID;
iMinAccountCount = iMinAccountsPerCustRange[iCustomerTier - eCustomerTierOne];
iMod = iMaxAccountsPerCustRange[iCustomerTier - eCustomerTierOne] - iMinAccountCount + 1;
iInverseCID = m_CustomerSelection.GetInverseCID(CID);
// Note: the calculations below assume load unit contains 1000
// customers.
//
if (iInverseCID < 200) // Tier 1
{
iNumAccounts = (iInverseCID % iMod) + iMinAccountCount;
} else {
if (iInverseCID < 800) // Tier 2
{
iNumAccounts = ((iInverseCID - 200 + 1) % iMod) + iMinAccountCount;
} else // Tier 3
{
iNumAccounts = ((iInverseCID - 800 + 2) % iMod) + iMinAccountCount;
}
}
if (m_bCacheEnabled && bCheckCache) {
m_CacheNA[index] = iNumAccounts;
}
}
return iNumAccounts;
}
/*
* Generate a random account for the specified customer.
* The distribution is uniform across all the accounts for the customer.
*
* PARAMETERS:
* IN RND - external Random Number Generator
* IN iCustomerId - customer id
* IN iCustomerTier - customer tier (indicating trading
* frequency) OUT piCustomerAccount - customer account id OUT
* piAccountCount - total number of accounts that the customer has
*
* RETURNS:
* none.
*/
void GenerateRandomAccountId(CRandom &RND, // in - external RNG
TIdent iCustomerId, // in
eCustomerTier iCustomerTier, // in
TIdent *piCustomerAccount, // out
int *piAccountCount) // out
{
TIdent iCustomerAccount;
int iAccountCount;
TIdent iStartingAccount;
iAccountCount = GetNumberOfAccounts(iCustomerId, iCustomerTier);
iStartingAccount = GetStartingCA_ID(iCustomerId);
// Select random account for the customer
//
iCustomerAccount = RND.RndInt64Range(iStartingAccount, iStartingAccount + iAccountCount - 1);
if (piCustomerAccount != NULL) {
*piCustomerAccount = iCustomerAccount;
}
if (piAccountCount != NULL) {
*piAccountCount = iAccountCount;
}
}
/*
* Generate a random account for the specified customer.
*
* PARAMETERS:
* IN RND - external Random Number Generator
* IN iCustomerId - customer id
* IN iCustomerTier - customer tier (indicating trading
* frequency)
*
* RETURNS:
* customer account id.
*/
TIdent GenerateRandomAccountId(CRandom &RND, TIdent iCustomerId, eCustomerTier iCustomerTier) {
TIdent iAccountOffset;
INT32 iAccountCount;
TIdent iStartingAccount;
iAccountCount = GetNumberOfAccounts(iCustomerId, iCustomerTier);
iStartingAccount = GetStartingCA_ID(iCustomerId);
iAccountOffset = (TIdent)RND.RndInt64Range(0, (INT64)iAccountCount - 1);
return (iStartingAccount + iAccountOffset);
}
/*
* Get starting account id for a given customer id.
* This is needed for the driver to know what account ids belong to a
* given customer.
*
* PARAMETERS:
* IN CID - customer id
*
* RETURNS:
* first account id of the customer.
*/
TIdent GetStartingCA_ID(TIdent CID) {
// start account ids on the next boundary for the new customer
return ((CID - 1) * iMaxAccountsPerCust + 1);
}
/*
* Get (maximum potential) ending account id for a given customer id.
* This is needed for the driver to restrict query results to active
* accounts.
*
* PARAMETERS:
* IN CID - customer id
*
* RETURNS:
* last account id of the customer.
*/
TIdent GetEndingCA_ID(TIdent CID) {
return (CID + iTIdentShift) * iMaxAccountsPerCust;
}
/*
* Generate next CA_ID and update state information.
* It is stored in the internal record structure and also returned.
* The number of rows generated is incremented. This is why
* this function cannot be called more than once for a record.
*
* PARAMETERS:
* none.
*
* RETURNS:
* next account id of the customer.
*/
TIdent GenerateNextCA_AD() {
if (GetCurrentC_ID() % iDefaultLoadUnitSize == 0) {
InitNextLoadUnit();
}
++m_iLastRowNumber;
if (m_iRowsGeneratedForCust == m_iRowsToGenForCust) { // select next customer id as all the rows
// for this customer have been generated
m_cust.GenerateNextC_ID();
m_addr.GenerateNextAD_ID(); // next address id (to get the one for
// this customer)
m_iRowsGeneratedForCust = 0; // no row generated yet
// total # of accounts for this customer
m_iRowsToGenForCust =
GetNumberOfAccounts(m_cust.GetCurrentC_ID(), m_cust.GetC_TIER(m_cust.GetCurrentC_ID()));
m_iStartingCA_ID = GetStartingCA_ID(m_cust.GetCurrentC_ID());
}
m_row.m_ca.CA_ID = m_iStartingCA_ID + m_iRowsGeneratedForCust;
++m_iRowsGeneratedForCust;
// store state info
m_bMoreRecords = m_cust.MoreRecords() || m_iRowsGeneratedForCust < m_iRowsToGenForCust;
return m_row.m_ca.CA_ID;
}
/*
* Generate the number (0-2) of additional permission rows for a certain
* account. This number is needed by the driver.
*
* PARAMETERS:
* IN CA_ID - customer account id
*
* RETURNS:
* number of ACCOUNT_PERMISSION rows.
*/
int GetNumPermsForCA(TIdent CA_ID) {
RNGSEED OldSeed;
UINT iThreshold;
UINT iNumberOfPermissions;
OldSeed = m_rnd.GetSeed();
m_rnd.SetSeed(m_rnd.RndNthElement(RNGSeedBaseNumberOfAccountPermissions, (RNGSEED)CA_ID));
iThreshold = m_rnd.RndGenerateIntegerPercentage();
if (iThreshold <= iPercentAccountAdditionalPermissions_0) {
iNumberOfPermissions = 0; // 60% of accounts have just the owner row permissions
} else {
if (iThreshold <= iPercentAccountAdditionalPermissions_0 + iPercentAccountAdditionalPermissions_1) {
iNumberOfPermissions = 1; // 38% of accounts have one additional permisison row
} else {
iNumberOfPermissions = 2; // 2% of accounts have two additional permission rows
}
}
m_rnd.SetSeed(OldSeed);
return (iNumberOfPermissions);
}
/*
* Generate customer ids for ACCOUNT_PERMISSION table for a given account
* id. Driver needs to know what those customer ids are based on the account
* id.
*
* PARAMETERS:
* IN CA_ID - customer account id
* IN Owner_CID - customer id of the account owner
* OUT CID_1 - first customer id in the ACL list of the
* account OUT CID_2 - second customer id in the ACL list of the
* account
*
* RETURNS:
* none.
*/
void GetCIDsForPermissions(TIdent CA_ID, TIdent Owner_CID, TIdent *CID_1, TIdent *CID_2) {
RNGSEED OldSeed;
if (CID_1 == NULL)
return;
OldSeed = m_rnd.GetSeed();
m_rnd.SetSeed(m_rnd.RndNthElement(RNGSeedBaseCIDForPermission1, (RNGSEED)CA_ID));
// Select from a fixed range that doesn't depend on the number of
// customers in the database. This allows not to specify the total
// number of customers to EGenLoader, only how many a particular
// instance needs to generate (may be a fraction of total). Note: this
// is not implemented right now.
*CID_1 = m_rnd.RndInt64RangeExclude(iDefaultStartFromCustomer,
iDefaultStartFromCustomer + iAccountPermissionIDRange, Owner_CID);
if (CID_2 != NULL) {
// NOTE: Reseeding the RNG here for the second CID value. The use of
// this sequence is fuzzy because the number of RNG values consumed
// is dependant on not only the CA_ID, but also the CID value chosen
// above for the first permission. Using a different sequence here
// may help prevent potential overlaps that might occur if the same
// sequence from above were used.
m_rnd.SetSeed(m_rnd.RndNthElement(RNGSeedBaseCIDForPermission2, (RNGSEED)CA_ID));
do // make sure the second id is different from the first
{
*CID_2 = m_rnd.RndInt64RangeExclude(iDefaultStartFromCustomer,
iDefaultStartFromCustomer + iAccountPermissionIDRange, Owner_CID);
} while (*CID_2 == *CID_1);
}
m_rnd.SetSeed(OldSeed);
}
/*
* Generate tax id for a given CA_ID.
* This is needed to calculate tax on sale proceeds for the TRADE table.
*
* PARAMETERS:
* IN iCA_ID - customer account id
*
* RETURNS:
* tax status for the account.
*/
eTaxStatus GetAccountTaxStatus(TIdent iCA_ID) {
eTaxStatus eCATaxStatus = eNone;
// We will sometimes get CA values that are outside the current
// load unit (cached range). We need to check for this case
// and avoid the lookup (as we will segfault or get bogus data.)
TIdent index = iCA_ID - m_iCacheOffsetTS;
bool bCheckCache = (index >= 0 && index < m_iCacheSizeTS);
if (m_bCacheEnabled && bCheckCache) {
eCATaxStatus = m_CacheTS[index];
}
if (eCATaxStatus == eNone) {
RNGSEED OldSeed;
UINT iThreshold;
OldSeed = m_rnd.GetSeed();
m_rnd.SetSeed(m_rnd.RndNthElement(RNGSeedBaseAccountTaxStatus, (RNGSEED)iCA_ID));
iThreshold = m_rnd.RndGenerateIntegerPercentage();
if (iThreshold <= iPercentAccountTaxStatusNonTaxable) {
eCATaxStatus = eNonTaxable;
} else {
if (iThreshold <= iPercentAccountTaxStatusNonTaxable + iPercentAccountTaxStatusTaxableAndWithhold) {
eCATaxStatus = eTaxableAndWithhold;
} else {
eCATaxStatus = eTaxableAndDontWithhold;
}
}
m_rnd.SetSeed(OldSeed);
if (m_bCacheEnabled && bCheckCache) {
m_CacheTS[index] = eCATaxStatus;
}
}
return eCATaxStatus;
}
/*
* Get the country and division address codes for the customer that
* owns the current account.
* These codes are used to get the tax rates and calculate tax on trades
* in the TRADE table.
*
* PARAMETERS:
* OUT iDivCode - division (state/province) code
* OUT iCtryCode - country (USA/CANADA) code
*
* RETURNS:
* none.
*/
void GetDivisionAndCountryCodesForCurrentAccount(UINT &iDivCode, UINT &iCtryCode) {
m_addr.GetDivisionAndCountryCodes(iDivCode, iCtryCode);
}
/*
* Generate a broker id for a certain account.
* Used in CTradeGen for updating YTD values.
*
* PARAMETERS:
* IN iCA_ID - customer account id
*
* RETURNS:
* broker id that corresponds to the account.
*/
TIdent GenerateBrokerIdForAccount(TIdent iCA_ID) {
// Customer that own the account (actually, customer id minus 1)
//
TIdent iCustomerId = ((iCA_ID - 1) / iMaxAccountsPerCust) - iTIdentShift;
// Set the starting broker to be the first broker for the current load
// unit of customers.
//
TIdent iStartFromBroker = (iCustomerId / m_iLoadUnitSize) * m_iBrokersCount + iStartingBrokerID + iTIdentShift;
// Note: this depends on broker ids being integer numbers from
// contiguous range. The method of generating broker ids should be in
// sync with the CBrokerTable.
return m_rnd.RndNthInt64Range(RNGSeedBaseBrokerId, (RNGSEED)iCA_ID - (10 * iTIdentShift), iStartFromBroker,
iStartFromBroker + m_iBrokersCount - 1);
}
/*
* Generate all column values for the next row
* and store them in the internal record structure.
* Increment the number of rows generated.
*
* PARAMETERS:
* none.
*
* RETURNS:
* TRUE, if there are more records in the ADDRESS table; FALSE
* othewise.
*/
bool GenerateNextRecord() {
GenerateCARow();
GenerateAPRows();
// Return false if all the rows have been generated
return (MoreRecords());
}
/*
* Return CUSTOMER_ACCOUNT row from the internal structure.
*
* PARAMETERS:
* none.
*
* RETURNS:
* current CUSTOMER_ACCOUNT record.
*/
// PCUSTOMER_ACCOUNT_ROW GetCARow() {return &m_row.m_ca;}
const CUSTOMER_ACCOUNT_ROW &GetCARow() {
return m_row.m_ca;
}
/*
* Return ACCOUNT_PERMISSION row from the internal structure.
*
* PARAMETERS:
* none.
*
* RETURNS:
* current ACCOUNT_PERMISSION record.
*/
const ACCOUNT_PERMISSION_ROW &GetAPRow(UINT i) {
if (i < m_iPermsForCA)
return m_row.m_perm[i];
else
throw std::range_error("Account Permission row index out of bounds.");
}
/*
* Return the number of ACCOUNT_PERMISSION rows for the current
* CUSTOMER_ACCOUNT row.
*
* PARAMETERS:
* none.
*
* RETURNS:
* the number of permissions for the account.
*/
UINT GetCAPermsCount() {
return m_iPermsForCA;
}
/*
* Return the customer ID for the currently generated CA_ID id.
*
* PARAMETERS:
* none.
*
* RETURNS:
* customer id of the account in the current CUSTOMER_ACCOUNT
* record.
*/
TIdent GetCurrentC_ID() {
return m_cust.GetCurrentC_ID();
}
/*
* Return the customer tier for the currently generated CA_ID id.
*
* PARAMETERS:
* none.
*
* RETURNS:
* customer tier of the customer, whose account is in the current
* CUSTOMER_ACCOUNT record.
*/
eCustomerTier GetCurrentC_TIER() {
return m_cust.GetC_TIER(m_cust.GetCurrentC_ID());
}
};
} // namespace TPCE
#endif // CUSTOMER_ACCOUNTS_AND_PERMISSIONS_TABLE_H

View File

@@ -0,0 +1,138 @@
/*
* 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, Doug Johnson
*/
/******************************************************************************
* Description: This class encapsulates customer tier distribution
* functions and provides functionality to:
* - Generate customer tier based on customer ID
* - Generate non-uniform customer ID
* - Generate customer IDs in a specified partition, and
* outside the specified partition a set percentage of
* the time.
******************************************************************************/
#ifndef CUSTOMER_SELECTION_H
#define CUSTOMER_SELECTION_H
#include "utilities/Random.h"
namespace TPCE {
/*
* Define customer tier type.
*/
enum eCustomerTier { eCustomerTierOne = 1, eCustomerTierTwo, eCustomerTierThree };
class CCustomerSelection {
CRandom *m_pRND; // external random number generator
TIdent m_iStartFromCustomer;
TIdent m_iCustomerCount;
/*
* Used when partitioning by C_ID.
*/
bool m_bPartitionByCID;
int m_iPartitionPercent;
TIdent m_iMyStartFromCustomer;
TIdent m_iMyCustomerCount;
/*
* Forward permutation (used to convert ordinal C_ID into real C_ID).
*/
TIdent Permute(TIdent iLow, TIdent iHigh);
/*
* Inverse permutation (used to convert real C_ID into it's ordinal
* number).
*/
TIdent InversePermute(TIdent iLow, TIdent iHigh);
/*
* Get lower 3 digits.
*/
inline TIdent CLow(TIdent C_ID) {
return ((C_ID - 1) % 1000);
}
/*
* Get higher digits.
*/
inline TIdent CHigh(TIdent C_ID) {
return ((C_ID - 1) / 1000);
}
public:
/*
* Default constructor.
*/
CCustomerSelection();
/*
* Constructor to set the customer range.
*/
CCustomerSelection(CRandom *pRND, TIdent iStartFromCustomer, TIdent iCustomerCount);
/*
* Constructor to set subrange when paritioning by C_ID.
*/
CCustomerSelection(CRandom *pRND, TIdent iStartFromCustomer, TIdent iCustomerCount, int iPartitionPercent,
TIdent iMyStartFromCustomer, TIdent iMyCustomerCount);
/*
* Re-set the customer range for the parition.
*/
void SetPartitionRange(TIdent iStartFromCustomer, TIdent iCustomerCount);
/*
* Return scrambled inverse customer id.
*/
UINT GetInverseCID(TIdent C_ID);
/*
* Return customer tier.
*/
eCustomerTier GetTier(TIdent C_ID);
/*
* Return a non-uniform random customer and the associated tier.
*/
void GenerateRandomCustomer(TIdent &C_ID, eCustomerTier &C_TIER);
};
} // namespace TPCE
#endif // CUSTOMER_SELECTION_H

View File

@@ -0,0 +1,110 @@
/*
* 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
* - Doug Johnson
*/
/*
* Contains class definition to generate Customer table.
*/
#ifndef CUSTOMER_TABLE_H
#define CUSTOMER_TABLE_H
#include "EGenTables_common.h"
#include "input/DataFileManager.h"
namespace TPCE {
const int iNumEMAIL_DOMAINs = 6;
class CCustomerTable : public TableTemplate<CUSTOMER_ROW> {
private:
TIdent m_iRowsToGenerate; // total # of rows to generate
CPerson m_person;
const AreaCodeDataFile_t &m_Phones;
TIdent m_iStartFromCustomer;
TIdent m_iCustomerCount;
const StatusTypeDataFile_t &m_StatusTypeFile; // STATUS_TYPE table from the flat file
CCustomerSelection m_CustomerSelection;
TIdent m_iCompanyCount; // number of Companies
unsigned int m_iExchangeCount; // number of Exchanges
void GenerateC_ST_ID();
void GeneratePersonInfo(); // generate last name, first name, and gender.
void GenerateC_DOB();
void GenerateC_AD_ID();
void GenerateC_CTRY_1();
void GenerateC_LOCAL_1();
void GenerateC_AREA_1();
void GenerateC_EXT_1();
void GenerateC_CTRY_2();
void GenerateC_LOCAL_2();
void GenerateC_AREA_2();
void GenerateC_EXT_2();
void GenerateC_CTRY_3();
void GenerateC_LOCAL_3();
void GenerateC_AREA_3();
void GenerateC_EXT_3();
void GenerateC_EMAIL_1_and_C_EMAIL_2();
/*
* Reset the state for the next load unit
*/
void InitNextLoadUnit();
public:
/*
* Constructor for the CUSTOMER table class.
*
* PARAMETERS:
* IN dfm - input flat files loaded in memory
* IN iCustomerCount - number of customers to generate
* IN iStartFromCustomer - ordinal position of the first customer in
* the sequence (Note: 1-based)
*/
CCustomerTable(const DataFileManager &dfm, TIdent iCustomerCount, TIdent iStartFromCustomer);
TIdent GenerateNextC_ID(); // generate C_ID and store state information;
// return false if all ids are generated
TIdent GetCurrentC_ID(); // return current customer id
void GetC_TAX_ID(TIdent C_ID,
char *szOutput); // return tax id (ala Social Security number)
eCustomerTier GetC_TIER(TIdent C_ID); // returns unique C_TIER for a given customer id
bool GenerateNextRecord(); // generates the next table row
};
} // namespace TPCE
#endif // CUSTOMER_TABLE_H

View 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
* - Doug Johnson
*/
/*
* Class representing the Customer Taxrates table.
*/
#ifndef CUSTOMER_TAX_RATE_TABLE_H
#define CUSTOMER_TAX_RATE_TABLE_H
#include "EGenTables_common.h"
#include "CustomerTable.h"
#include "AddressTable.h"
#include "input/DataFileManager.h"
namespace TPCE {
const UINT iTaxRatesPerCust = 2; // number of tax rates per customer
const int iMaxDivOrCtryName = 6;
// Number of RNG calls to skip for one row in order
// to not use any of the random values from the previous row.
const int iRNGSkipOneRowCustomerTaxrate = 5; // real max count in v3.5: 2
typedef struct CUSTOMER_TAXRATE_ROWS {
CUSTOMER_TAXRATE_ROW
m_row[iTaxRatesPerCust]; // multiple tax rates rows per customer
} * PCUSTOMER_TAXRATE_ROWS;
class CCustomerTaxRateTable : public TableTemplate<CUSTOMER_TAXRATE_ROWS> {
CCustomerTable m_cust;
CAddressTable m_addr;
const TaxRateDivisionDataFile_t &m_division_rates;
const TaxRateCountryDataFile_t &m_country_rates;
/*
* Reset the state for the next load unit
*/
void InitNextLoadUnit() {
m_rnd.SetSeed(
m_rnd.RndNthElement(RNGSeedTableDefault, (RNGSEED)m_cust.GetCurrentC_ID() * iRNGSkipOneRowCustomerTaxrate));
ClearRecord(); // this is needed for EGenTest to work
}
// generate the tax row deterministically for a given customer and country
// or division code
const ITaxRateFileRecord &GetTaxRow(TIdent C_ID, UINT iCode, bool bCtry) {
RNGSEED OldSeed;
UINT iThreshold;
// const vector<TTaxRateInputRow> *pRates;
OldSeed = m_rnd.GetSeed();
m_rnd.SetSeed(m_rnd.RndNthElement(RNGSeedBaseTaxRateRow, (RNGSEED)C_ID));
if (bCtry) {
// Return appropriate country record.
iThreshold = (UINT)m_rnd.RndIntRange(0, m_country_rates.getBucket(iCode).size() - 1);
m_rnd.SetSeed(OldSeed);
return m_country_rates.getBucket(iCode)[iThreshold];
}
// It's not a country so return the appropriate division record.
iThreshold = (UINT)m_rnd.RndIntRange(0, m_division_rates.getBucket(iCode).size() - 1);
m_rnd.SetSeed(OldSeed);
return m_division_rates.getBucket(iCode)[iThreshold];
}
public:
CCustomerTaxRateTable(const DataFileManager &dfm, TIdent iCustomerCount, TIdent iStartFromCustomer,
bool bCacheEnabled = false)
: TableTemplate<CUSTOMER_TAXRATE_ROWS>(), m_cust(dfm, iCustomerCount, iStartFromCustomer),
m_addr(dfm, iCustomerCount, iStartFromCustomer, true, bCacheEnabled),
m_division_rates(dfm.TaxRateDivisionDataFile()), m_country_rates(dfm.TaxRateCountryDataFile()){};
/*
* Generates all column values for the next row.
*/
bool GenerateNextRecord() {
UINT iDivCode, iCtryCode;
if (m_cust.GetCurrentC_ID() % iDefaultLoadUnitSize == 0) {
InitNextLoadUnit();
}
++m_iLastRowNumber;
m_cust.GenerateNextC_ID(); // next customer id
m_addr.GenerateNextAD_ID(); // next address id (to get the one for this
// customer)
m_addr.GetDivisionAndCountryCodes(iDivCode, iCtryCode);
// Fill the country tax rate row
m_row.m_row[0].CX_C_ID = m_cust.GetCurrentC_ID(); // fill the customer
// id
// Select the country rate
strncpy(m_row.m_row[0].CX_TX_ID, GetCountryTaxRow(m_cust.GetCurrentC_ID(), iCtryCode).TX_ID_CSTR(),
sizeof(m_row.m_row[0].CX_TX_ID));
// Fill the division tax rate row
m_row.m_row[1].CX_C_ID = m_cust.GetCurrentC_ID(); // fill the customer
// id
// Select the division rate
strncpy(m_row.m_row[1].CX_TX_ID, GetDivisionTaxRow(m_cust.GetCurrentC_ID(), iDivCode).TX_ID_CSTR(),
sizeof(m_row.m_row[0].CX_TX_ID));
m_bMoreRecords = m_cust.MoreRecords();
return (MoreRecords());
}
const CUSTOMER_TAXRATE_ROW &GetRowByIndex(UINT i) {
if (i < iTaxRatesPerCust)
return m_row.m_row[i];
else
throw std::range_error("Customer Taxrate row index out of bounds.");
}
UINT GetTaxRatesCount() {
return iTaxRatesPerCust;
} // tax rates per customer
// generate country tax row for a given customer
const ITaxRateFileRecord &GetCountryTaxRow(TIdent C_ID, UINT iCtryCode) {
return GetTaxRow(C_ID, iCtryCode, true);
}
// generate division tax row for a given customer
const ITaxRateFileRecord &GetDivisionTaxRow(TIdent C_ID, UINT iDivCode) {
return GetTaxRow(C_ID, iDivCode, false);
}
};
} // namespace TPCE
#endif // CUSTOMER_TAX_RATE_TABLE_H

View File

@@ -0,0 +1,140 @@
/*
* 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
*/
/******************************************************************************
* Description: This class provides Data-Maintenance functionality.
* It generates all necessary inputs for the
* Data-Maintenance transaction. These inputs are then
* made available to a sponsor provided callback interface
* to the SUT (see DMSUTInterface.h).
*
* The constructor to this class accepts the following
* parameters.
*
* - pSUT: a pointer to an instance of a sponsor provided
* subclassing of the CCESUTInterface class.
* - pLogger: a pointer to an
*instance of CEGenLogger or a sponsor provided subclassing of the CBaseLogger
*class.
* - dfm: a reference to an instance of the
* CInputFiles class containing all input files loaded
* into memory.
* - iActiveCustomerCount: the total number of customers
* to emulate. C_IDs will be generated in the range of
* 1 to iActiveCustomerCount.
* - RandomSeed: seed to be used for the RNG.
*
* The DM class provides the following entry point.
*
* - DoTxn: this entry point will generate all required
* inputs and provide those inputs to sponsor code at the
* - DoCleanupTxn: this entry point will execute the
* Trade-Cleanup transaction. This must be run at the
* start of each measurement run before any CE or MEE
* transactions are executed.
******************************************************************************/
#ifndef DM_H
#define DM_H
#include "utilities/EGenUtilities_stdafx.h"
#include "TxnHarnessStructs.h"
#include "DMSUTInterface.h"
#include "BaseLogger.h"
#include "DriverParamSettings.h"
#include "input/DataFileManager.h"
namespace TPCE {
class CDM {
private:
CDriverGlobalSettings m_DriverGlobalSettings;
CDriverDMSettings m_DriverDMSettings;
CRandom m_rnd;
CCustomerSelection m_CustomerSelection;
CCustomerAccountsAndPermissionsTable m_AccsAndPerms;
const CSecurityFile &m_Securities;
const CCompanyFile &m_Companies;
const TaxRateDivisionDataFile_t &m_TaxRatesDivision;
const StatusTypeDataFile_t &m_StatusType;
TIdent m_iSecurityCount;
TIdent m_iCompanyCount;
TIdent m_iStartFromCompany;
INT32 m_iDivisionTaxCount;
TIdent m_iStartFromCustomer;
INT32 m_DataMaintenanceTableNum;
TDataMaintenanceTxnInput m_TxnInput;
TTradeCleanupTxnInput m_CleanupTxnInput;
CDMSUTInterface *m_pSUT;
CBaseLogger *m_pLogger;
// Automatically generate unique RNG seeds
void AutoSetRNGSeeds(UINT32 UniqueId);
TIdent GenerateRandomCustomerId();
TIdent GenerateRandomCustomerAccountId();
TIdent GenerateRandomCompanyId();
TIdent GenerateRandomSecurityId();
// Initialization that is common for all constructors.
void Initialize();
public:
// Constructor - automatice RNG seed generation
CDM(CDMSUTInterface *pSUT, CBaseLogger *pLogger, const DataFileManager &dfm, TIdent iConfiguredCustomerCount,
TIdent iActiveCustomerCount, INT32 iScaleFactor, INT32 iDaysOfInitialTrades, UINT32 UniqueId);
// Constructor - RNG seed provided
CDM(CDMSUTInterface *pSUT, CBaseLogger *pLogger, const DataFileManager &dfm, TIdent iConfiguredCustomerCount,
TIdent iActiveCustomerCount, INT32 iScaleFactor, INT32 iDaysOfInitialTrades, UINT32 UniqueId, RNGSEED RNGSeed);
~CDM(void);
RNGSEED GetRNGSeed(void);
void DoTxn(void);
void DoCleanupTxn(void);
};
} // namespace TPCE
#endif // #ifndef DM_H

View File

@@ -0,0 +1,69 @@
/*
* 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
*/
/******************************************************************************
* Description: Interface base class to be used for deriving a sponsor
* specific class for commmunicating with the SUT for
* the Data-Maintenance transaction.
******************************************************************************/
#ifndef DM_SUT_INTERFACE_H
#define DM_SUT_INTERFACE_H
#include "TxnHarnessStructs.h"
namespace TPCE {
class CDMSUTInterface {
public:
/*
* Virtual destructor. Provided so that a sponsor-specific
* destructor can be called on destruction from the base-class pointer.
*
* PARAMETERS:
* none.
*
* RETURNS:
* not applicable.
*/
virtual ~CDMSUTInterface(){};
virtual bool DataMaintenance(PDataMaintenanceTxnInput pTxnInput) = 0; // return whether it was successful
virtual bool TradeCleanup(PTradeCleanupTxnInput pTxnInput) = 0; // return whether it was successful
};
} // namespace TPCE
#endif // DM_SUT_INTERFACE_H

View File

@@ -0,0 +1,200 @@
/*
* 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
* - Doug Johnson
*/
/*
* Class representing the DAILY_MARKET table.
*/
#ifndef DAILY_MARKET_TABLE_H
#define DAILY_MARKET_TABLE_H
#include "EGenTables_common.h"
#include "SecurityPriceRange.h"
#include "input/DataFileManager.h"
namespace TPCE {
const int iTradeDaysInYear = 261; // the number of trading days in a year (for DAILY_MARKET)
const int iDailyMarketYears = 5; // number of years of history in DAILY_MARKET
const int iDailyMarketTotalRows = iDailyMarketYears * iTradeDaysInYear;
const double fDailyMarketCloseMin = fMinSecPrice;
const double fDailyMarketCloseMax = fMaxSecPrice;
const double fDailyMarketHighRelativeToClose = 1.05;
const double fDailyMarketLowRelativeToClose = 0.92;
const INT64 iDailyMarketVolumeMax = 10000;
const INT64 iDailyMarketVolumeMin = 1000;
const int iRNGSkipOneRowDailyMarket = 2; // number of RNG calls for one row
typedef struct DAILY_MARKET_GEN_ROW {
// big array of all the history for one security
DAILY_MARKET_ROW m_daily_market[iDailyMarketTotalRows];
} * PDAILY_MARKET_GEN_ROW;
class CDailyMarketTable : public TableTemplate<DAILY_MARKET_GEN_ROW> {
TIdent m_iStartFromSecurity;
TIdent m_iSecurityCount;
const CSecurityFile &m_SecurityFile;
CDateTime m_StartFromDate;
int m_iDailyMarketTotalRows;
// Number of times GenerateNextRecord() was called for the current security
// data. Needed to decide when to generate next security's data.
int m_iRowsGeneratedPerSecurity;
// Stores whether there is another security(s) for which to
// generate daily market data.
bool m_bMoreSecurities;
TIdent m_iSecurityCountForOneLoadUnit;
/*
* DAILY_MARKET table rows generation
*/
void GenerateDailyMarketRows() {
int i;
int iDayNo = 0; // start from the oldest date (start date)
char szSymbol[cSYMBOL_len + 1];
// Create symbol only once.
//
m_SecurityFile.CreateSymbol(m_iLastRowNumber, szSymbol, static_cast<int>(sizeof(szSymbol)));
for (i = 0; i < m_iDailyMarketTotalRows; ++i) {
// copy the symbol
strncpy(m_row.m_daily_market[i].DM_S_SYMB, szSymbol, sizeof(m_row.m_daily_market[i].DM_S_SYMB));
// generate trade date
m_row.m_daily_market[i].DM_DATE = m_StartFromDate;
m_row.m_daily_market[i].DM_DATE.Add(iDayNo, 0);
// generate prices
m_row.m_daily_market[i].DM_CLOSE =
m_rnd.RndDoubleIncrRange(fDailyMarketCloseMin, fDailyMarketCloseMax, 0.01);
m_row.m_daily_market[i].DM_HIGH = m_row.m_daily_market[i].DM_CLOSE * fDailyMarketHighRelativeToClose;
m_row.m_daily_market[i].DM_LOW = m_row.m_daily_market[i].DM_CLOSE * fDailyMarketLowRelativeToClose;
// generate volume
m_row.m_daily_market[i].DM_VOL = m_rnd.RndInt64Range(iDailyMarketVolumeMin, iDailyMarketVolumeMax);
++iDayNo; // go one day forward for the next row
if ((iDayNo % DaysPerWeek) == DaysPerWorkWeek)
iDayNo += 2; // skip weekend
}
}
/*
* Reset the state for the next load unit.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void InitNextLoadUnit() {
m_rnd.SetSeed(m_rnd.RndNthElement(RNGSeedTableDefault, (RNGSEED)m_iLastRowNumber * iRNGSkipOneRowDailyMarket));
ClearRecord(); // this is needed for EGenTest to work
}
public:
/*
* Constructor.
*/
CDailyMarketTable(const DataFileManager &dfm, TIdent iCustomerCount, TIdent iStartFromCustomer)
: TableTemplate<DAILY_MARKET_GEN_ROW>(), m_SecurityFile(dfm.SecurityFile()),
m_iDailyMarketTotalRows(sizeof(m_row.m_daily_market) / sizeof(m_row.m_daily_market[0])),
m_iRowsGeneratedPerSecurity(sizeof(m_row.m_daily_market) / sizeof(m_row.m_daily_market[0])),
m_bMoreSecurities(true) // initialize once
{
// Set DAILY_MARKET start date to Jan 03, 2000.
//
m_StartFromDate.Set(iDailyMarketBaseYear, iDailyMarketBaseMonth, iDailyMarketBaseDay, iDailyMarketBaseHour,
iDailyMarketBaseMinute, iDailyMarketBaseSecond, iDailyMarketBaseMsec);
m_bMoreRecords = true; // initialize once
m_iSecurityCount = m_SecurityFile.CalculateSecurityCount(iCustomerCount);
m_iStartFromSecurity = m_SecurityFile.CalculateStartFromSecurity(iStartFromCustomer);
m_iSecurityCountForOneLoadUnit = m_SecurityFile.CalculateSecurityCount(iDefaultLoadUnitSize);
m_iLastRowNumber = m_iStartFromSecurity;
};
bool GenerateNextRecord() {
++m_iRowsGeneratedPerSecurity;
if (m_iRowsGeneratedPerSecurity >= m_iDailyMarketTotalRows) {
if (m_bMoreSecurities) {
// Reset RNG at Load Unit boundary, so that all data is
// repeatable.
//
if (m_iLastRowNumber % m_iSecurityCountForOneLoadUnit == 0) {
InitNextLoadUnit();
}
GenerateDailyMarketRows(); // generate all rows for the current
// security
++m_iLastRowNumber;
// Update state info
m_bMoreSecurities = m_iLastRowNumber < (m_iStartFromSecurity + m_iSecurityCount);
m_iRowsGeneratedPerSecurity = 0;
}
}
// Return false when generated the last row of the last security
if (!m_bMoreSecurities && (m_iRowsGeneratedPerSecurity == m_iDailyMarketTotalRows - 1)) {
m_bMoreRecords = false;
}
return (MoreRecords());
}
const DAILY_MARKET_ROW &GetRow() {
return m_row.m_daily_market[m_iRowsGeneratedPerSecurity];
}
};
} // namespace TPCE
#endif // DAILY_MARKET_TABLE_H

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
/*
* 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
* - Matt Emmerton
*/
/******************************************************************************
* Description: Driver types and names
******************************************************************************/
#ifndef DRIVER_TYPES_H
#define DRIVER_TYPES_H
namespace TPCE {
enum eDriverType { eDriverEGenLoader, eDriverAll, eDriverCE, eDriverMEE, eDriverDM, eDriverMax };
extern char szDriverTypeNames[eDriverMax][14];
} // namespace TPCE
#endif // DRIVER_TYPES_H

View File

@@ -0,0 +1,43 @@
/*
* 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_BASELOADER_STDAFX_H
#define EGEN_BASELOADER_STDAFX_H
#include "BaseLoader.h"
#include "BaseLoaderFactory.h"
#endif // #ifndef EGEN_BASELOADER_STDAFX_H

View File

@@ -0,0 +1,378 @@
/*
* 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
* - Doug Johnson
*/
/*
* This file contains a class that acts as a client to the table
* generation classes (EGenTables) and to the loader classes (EGenBaseLoader).
* It provides routines for generating and loading the table data or its
* subset.
*/
#ifndef EGEN_GENERATE_AND_LOAD_H
#define EGEN_GENERATE_AND_LOAD_H
#include <string>
#include "utilities/EGenStandardTypes.h"
#include "input/DataFileManager.h"
#include "EGenGenerateAndLoadBaseOutput.h"
#include "utilities/MiscConsts.h"
#include "BaseLoaderFactory.h"
#include "BaseLogger.h"
namespace TPCE {
class CGenerateAndLoad {
// Data File Manager
const DataFileManager &m_dfm;
// Ordinal position (1-based) of the first customer in the sequence
TIdent m_iStartFromCustomer;
// The number of customers to generate from the starting position
TIdent m_iCustomerCount;
// Total number of customers in the database
TIdent m_iTotalCustomers;
// Number of customers in one load unit for generating initial trades
UINT m_iLoadUnitSize;
// Number of customers per 1 tpsE
UINT m_iScaleFactor;
// Time period for which to generate initial trades
UINT m_iHoursOfInitialTrades;
// External loader factory to create table loaders
CBaseLoaderFactory *m_pLoaderFactory;
// External class used to output load progress
CGenerateAndLoadBaseOutput *m_pOutput;
// Logger instance
CBaseLogger *m_pLogger;
// Parameter instance
CLoaderSettings m_LoaderSettings;
// Whether to use cache when generating initial population
bool m_bCacheEnabled;
public:
/*
* Constructor.
*
* PARAMETERS:
* IN inputFiles - in-memory representation of input
* flat files IN iCustomerCount - number of customers to build (for
* this class instance) IN iStartFromCustomer - first customer id IN
* iTotalCustomers - total number of customers in the database IN
* iLoadUnitSize - minimal number of customers that can be build
* (should always be 1000) IN iScaleFactor - number of customers for
* 1tpsE IN iDaysOfInitialTrades- number of 8-hour days of initial trades
* per customer IN pLoaderFactory - factory to create loader classes
* IN pLogger - parameter logging interface
* IN pOutput - interface to output information to a
* user during the build process IN szInDir - input flat file
* directory needed for tables loaded from flat files IN bCacheEnabled -
* whether or not to use caching during data generation
*
* RETURNS:
* not applicable.
*/
CGenerateAndLoad(const DataFileManager &dfm, TIdent iCustomerCount, TIdent iStartFromCustomer,
TIdent iTotalCustomers, UINT iLoadUnitSize, UINT iScaleFactor, UINT iDaysOfInitialTrades,
CBaseLoaderFactory *pLoaderFactory, CBaseLogger *pLogger, CGenerateAndLoadBaseOutput *pOutput,
bool bCacheEnabled = false);
/*
* Generate and load ADDRESS table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadAddress();
/*
* Generate and load CHARGE table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadCharge();
/*
* Generate and load COMMISSION_RATE table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadCommissionRate();
/*
* Generate and load COMPANY_COMPETITOR table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadCompanyCompetitor();
/*
* Generate and load COMPANY table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadCompany();
/*
* Generate and load CUSTOMER_ACCOUNT, ACCOUNT_PERMISSION table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadCustomerAccountAndAccountPermission();
/*
* Generate and load CUSTOMER table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadCustomer();
/*
* Generate and load CUSTOMER_TAXRATE table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadCustomerTaxrate();
/*
* Generate and load DAILY_MARKET table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadDailyMarket();
/*
* Generate and load EXCHANGE table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadExchange();
/*
* Generate and load FINANCIAL table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadFinancial();
/*
* Generate and load HOLDING, HOLDING_HISTORY, TRADE, TRADE_HISTORY,
* SETTLEMENT, CASH_TRANSACTION, BROKER table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadHoldingAndTrade();
/*
* Generate and load INDUSTRY table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadIndustry();
/*
* Generate and load LAST_TRADE table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadLastTrade();
/*
* Generate and load NEWS_ITEM, NEWS_XREF table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadNewsItemAndNewsXRef();
/*
* Generate and load SECTOR table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadSector();
/*
* Generate and load SECURITY table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadSecurity();
/*
* Generate and load STATUS_TYPE table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadStatusType();
/*
* Generate and load TAXRATE table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadTaxrate();
/*
* Generate and load TRADE_TYPE table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadTradeType();
/*
* Generate and load WATCH_LIST, WATCH_ITEM table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadWatchListAndWatchItem();
/*
* Generate and load ZIP_CODE table.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadZipCode();
/*
* Generate and load All tables that are constant in size.
*
* Spec definition: Fixed tables.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadFixedTables();
/*
* Generate and load All tables (except BROKER) that scale with the size
* of the CUSTOMER table, but do not grow in runtime.
*
* Spec definition: Scaling tables.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadScalingTables();
/*
* Generate and load All trade related tables and BROKER (included here to
* facilitate generation of a consistent database).
*
* Spec definition: Growing tables.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void GenerateAndLoadGrowingTables();
};
} // namespace TPCE
#endif // EGEN_GENERATE_AND_LOAD_H

View File

@@ -0,0 +1,112 @@
/*
* 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
*/
/*
* Base interface used to output generation and load progress
* and any other supporting information.
*/
#ifndef EGEN_GENERATE_AND_LOAD_BASE_OUTPUT_H
#define EGEN_GENERATE_AND_LOAD_BASE_OUTPUT_H
#include <string>
using namespace std;
namespace TPCE {
class CGenerateAndLoadBaseOutput {
public:
/*
* Virtual destructor. Provided so that a sponsor-specific
* destructor can be called on destruction from the base-class pointer.
*
* PARAMETERS:
* none.
*
* RETURNS:
* not applicable.
*/
virtual ~CGenerateAndLoadBaseOutput(){};
/*
* Output beginning of table generation.
*
* PARAMETERS:
* IN szMsg - string to output to the user
*
* RETURNS:
* none.
*/
virtual void OutputStart(string szMsg) = 0;
/*
* Output progress of table generation.
*
* PARAMETERS:
* IN szMsg - string to output to the user
*
* RETURNS:
* none.
*/
virtual void OutputProgress(string szMsg) = 0;
/*
* Output completion of table generation.
*
* PARAMETERS:
* IN szMsg - string to output to the user
*
* RETURNS:
* none.
*/
virtual void OutputComplete(string szMsg) = 0;
/*
* Output end-of-line.
*
* PARAMETERS:
* IN szMsg - string to output to the user
*
* RETURNS:
* none.
*/
virtual void OutputNewline() = 0;
};
} // namespace TPCE
#endif // EGEN_GENERATE_AND_LOAD_BASE_OUTPUT_H

View File

@@ -0,0 +1,112 @@
/*
* 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
*/
/*
* Class for generation and load output to stdout.
*/
#ifndef EGEN_GENERATE_AND_LOAD_STANDARD_OUTPUT_H
#define EGEN_GENERATE_AND_LOAD_STANDARD_OUTPUT_H
#include <cstdio>
#include <string>
#include "EGenGenerateAndLoadBaseOutput.h"
using namespace std;
namespace TPCE {
class CGenerateAndLoadStandardOutput : public CGenerateAndLoadBaseOutput {
public:
/*
* Output beginning of table generation.
*
* PARAMETERS:
* IN szMsg - string to output to the user
*
* RETURNS:
* none.
*/
void OutputStart(string szMsg) {
// printf("%s", szMsg.c_str());
// fflush(stdout); // in case there is no newline character in szMsg
}
/*
* Output progress of table generation.
*
* PARAMETERS:
* IN szMsg - string to output to the user
*
* RETURNS:
* none.
*/
void OutputProgress(string szMsg) {
// printf("%s", szMsg.c_str());
// fflush(stdout); // in case there is no newline character in szMsg
}
/*
* Output completion of table generation.
*
* PARAMETERS:
* IN szMsg - string to output to the user
*
* RETURNS:
* none.
*/
void OutputComplete(string szMsg) {
// printf("%s", szMsg.c_str());
// fflush(stdout); // in case there is no newline character in szMsg
}
/*
* Output end-of-line.
*
* PARAMETERS:
* IN szMsg - string to output to the user
*
* RETURNS:
* none.
*/
void OutputNewline() {
// printf("\n");
}
};
} // namespace TPCE
#endif // EGEN_GENERATE_AND_LOAD_STANDARD_OUTPUT_H

View File

@@ -0,0 +1,61 @@
/*
* 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_GENERATE_AND_LOAD_STDAFX_H
#define EGEN_GENERATE_AND_LOAD_STDAFX_H
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <cstdio>
#include <cassert>
#include <fstream>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
#include "EGenTables_stdafx.h"
#include "EGenBaseLoader_stdafx.h"
#include "EGenGenerateAndLoadBaseOutput.h"
#include "EGenGenerateAndLoadStandardOutput.h"
#include "DriverParamSettings.h"
#include "EGenLogger.h"
#include "EGenGenerateAndLoad.h"
#endif // #ifndef EGEN_GENERATE_AND_LOAD_STDAFX_H

View File

@@ -0,0 +1,90 @@
/*
* 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_LOADER_STDAFX_H
#define EGEN_LOADER_STDAFX_H
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <cstdio>
#include <cassert>
#include <fstream>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#ifdef COMPILE_ODBC_LOAD
#ifdef WIN32
#include <windows.h>
#endif // WIN32
// ODBC headers
#include <sql.h>
#include <sqlext.h>
#include <odbcss.h>
#endif // COMPILE_ODBC_LOAD
// TODO: reference additional headers your program requires here
using namespace std;
#include "EGenTables_stdafx.h"
#include "EGenBaseLoader_stdafx.h"
#include "EGenGenerateAndLoad_stdafx.h"
// Include one or more load types.
#include "NullLoad_stdafx.h"
#ifdef COMPILE_FLAT_FILE_LOAD
#include "FlatFileLoad_stdafx.h"
#endif
#ifdef COMPILE_ODBC_LOAD
#include "win/ODBCLoad_stdafx.h"
#endif
#ifdef COMPILE_CUSTOM_LOAD
#include "custom/CustomLoad_stdafx.h"
#endif
#ifdef CUSTOM_LOAD_INCLUDE
#define COMPILE_CUSTOM_LOAD
#include CUSTOM_LOAD_INCLUDE
#endif
// Generic Error Codes
#define ERROR_BAD_OPTION 1
#define ERROR_INPUT_FILE 2
#define ERROR_INVALID_OPTION_VALUE 3
#endif // #ifndef EGEN_LOADER_STDAFX_H

View File

@@ -0,0 +1,117 @@
/*
* 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
* - Matt Emmerton
*/
/******************************************************************************
* Description: This file implements the methods for formatting
* log entries in TSV or CSV format.
******************************************************************************/
#ifndef EGEN_LOG_FORMATTER_H
#define EGEN_LOG_FORMATTER_H
#include <iostream>
#include <iomanip> // for log message formatting
#include <sstream> // for log message construction
#include "utilities/EGenUtilities_stdafx.h"
#include "DriverParamSettings.h"
#include "BaseLogFormatter.h"
namespace TPCE {
class CLogFormatTab : public CBaseLogFormatter {
friend class EGenLogger;
private:
ostringstream logmsg;
string emptyString;
public:
////////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////////
CLogFormatTab() : emptyString("") {
}
////////////////////////////////////////////////////////////////
// CE Transaction Settings
////////////////////////////////////////////////////////////////
string GetLogOutput(CBrokerVolumeSettings &parms);
string GetLogOutput(CCustomerPositionSettings &parms);
string GetLogOutput(CMarketWatchSettings &parms);
string GetLogOutput(CSecurityDetailSettings &parms);
string GetLogOutput(CTradeLookupSettings &parms);
string GetLogOutput(CTradeOrderSettings &parms);
string GetLogOutput(CTradeUpdateSettings &parms);
////////////////////////////////////////////////////////////////
// CE Transaction Mix Settings
////////////////////////////////////////////////////////////////
string GetLogOutput(CTxnMixGeneratorSettings &parms);
////////////////////////////////////////////////////////////////
// Loader Settings
////////////////////////////////////////////////////////////////
string GetLogOutput(CLoaderSettings &parms);
////////////////////////////////////////////////////////////////
// Driver Settings
////////////////////////////////////////////////////////////////
string GetLogOutput(CDriverGlobalSettings &parms);
string GetLogOutput(CDriverCESettings &parms);
string GetLogOutput(CDriverCEPartitionSettings &parms);
string GetLogOutput(CDriverMEESettings &parms);
string GetLogOutput(CDriverDMSettings &parms);
};
} // namespace TPCE
#endif // EGEN_LOG_FORMATTER_H

View File

@@ -0,0 +1,93 @@
/*
* 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
* - Matt Emmerton
*/
/******************************************************************************
* Description: This file implements the interface for data logging.
******************************************************************************/
#ifndef EGEN_LOGGER_H
#define EGEN_LOGGER_H
#include <sstream>
#include <fstream>
#include <cstring>
#include "utilities/EGenStandardTypes.h"
#include "DriverParamSettings.h"
#include "utilities/EGenVersion.h"
#include "BaseLogger.h"
#include "EGenLogFormatterTab.h"
namespace TPCE {
class CEGenLogger : public CBaseLogger {
private:
char m_Filename[iMaxPath];
ofstream m_Log;
CMutex m_LogLock;
bool SendToLoggerImpl(const char *szPrefix, const char *szTimestamp, const char *szMsg) {
// m_LogLock.lock();
// cerr << szPrefix << " " << szTimestamp << " " << szMsg << endl;
// // m_Log.flush();
// if (!m_Log)
// {
// throw CSystemErr(CSystemErr::eWriteFile,
// "CEGenLogger::SendToLoggerImpl");
// }
// m_LogLock.unlock();
return true;
}
public:
CEGenLogger(eDriverType drvType, UINT32 UniqueId, const char *szFilename, CBaseLogFormatter *pLogFormatter)
: CBaseLogger(drvType, UniqueId, pLogFormatter){
// Copy Log Filename
// strncpy(m_Filename, szFilename, sizeof(m_Filename));
// // Open Log File
// m_Log.open(m_Filename);
// if (!m_Log)
// {
// throw CSystemErr(CSystemErr::eCreateFile,
// "CEGenLogger::CEGenLogger");
// }
};
};
} // namespace TPCE
#endif // EGEN_LOGGER_H

View File

@@ -0,0 +1,48 @@
/*
* 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
*/
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#ifndef EGEN_NULLLOADER_STDAFX_H
#define EGEN_NULLLOADER_STDAFX_H
#include "NullLoader.h"
#include "NullLoaderFactory.h"
#endif // #ifndef EGEN_NULLLOADER_STDAFX_H

View File

@@ -0,0 +1,63 @@
/*
* 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 Ruemmler
*/
#ifndef EGEN_TABLES_COMMON_H
#define EGEN_TABLES_COMMON_H
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <cassert>
#include <cmath>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;
#include "utilities/EGenStandardTypes.h"
#include "utilities/EGenUtilities_stdafx.h"
#include "TableRows.h"
#include "TableTemplate.h"
#include "Person.h"
#include "CustomerSelection.h"
#endif // #ifndef EGEN_TABLES_COMMON_H

View File

@@ -0,0 +1,81 @@
/*
* 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_TABLES_STDAFX_H
#define EGEN_TABLES_STDAFX_H
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <cassert>
#include <cmath>
#include <fstream>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
// TODO: reference additional headers your program requires here
using namespace std;
#include "utilities/EGenStandardTypes.h"
#include "utilities/EGenUtilities_stdafx.h"
#include "TableRows.h"
#include "TableTemplate.h"
#include "Person.h"
#include "CustomerSelection.h"
#include "CustomerTable.h"
#include "CompanyTable.h" //must be before Address and Financial tables
#include "FinancialTable.h"
#include "AddressTable.h"
#include "CustomerAccountsAndPermissionsTable.h"
#include "CustomerTaxRateTable.h"
#include "HoldingsAndTradesTable.h"
#include "WatchListsAndItemsTable.h"
#include "SecurityTable.h"
#include "DailyMarketTable.h"
#include "Brokers.h"
#include "ExchangeTable.h"
#include "CompanyCompetitorTable.h"
#include "ZipCodeTable.h"
#include "NewsItemAndXRefTable.h"
#include "MEESecurity.h" // must be before LastTradeTable.h
#include "LastTradeTable.h"
#include "TradeGen.h"
#endif // #ifndef EGEN_TABLES_STDAFX_H

View File

@@ -0,0 +1,49 @@
/*
* 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
*/
#ifndef EXCHANGE_IDS_H
#define EXCHANGE_IDS_H
namespace TPCE {
// Exchange IDs corresponding to the Exchange.txt flat file.
// Note: The order of enumeration members must match the order
// of rows in the Exchange.txt flat file.
enum eExchangeID { eNYSE = 0, eNASDAQ, eAMEX, ePCX };
} // namespace TPCE
#endif // EXCHANGE_IDS_H

View File

@@ -0,0 +1,70 @@
/*
* 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
*/
/*
* Class representing the Exchange table.
*/
#ifndef EXCHANGE_TABLE_H
#define EXCHANGE_TABLE_H
#include "FixedTable.h"
#include "input/DataFileTypes.h"
#include "TableRows.h"
namespace TPCE {
class CExchangeTable : public FixedTable<ExchangeDataFile_t, EXCHANGE_ROW> {
private:
INT32 securityCount[4];
/*
* Computes the number of securities in each exchange.
* Assumption is that exchanges are ordered in NYSE, NASDAQ, AMEX, PCX
* order. (This is the current ordering of exchanges in the
* flat_in/Exchange.txt file.)
*/
void ComputeNumSecurities(TIdent iCustomerCount);
public:
CExchangeTable(const ExchangeDataFile_t &dataFile, TIdent configuredCustomers);
~CExchangeTable();
virtual void LoadTableRow();
};
} // namespace TPCE
#endif // EXCHANGE_TABLE_H

View File

@@ -0,0 +1,243 @@
/*
* 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, Doug Johnson
*/
/*
* Class representing the Financial table.
*/
#ifndef FINANCIAL_TABLE_H
#define FINANCIAL_TABLE_H
#include "EGenTables_common.h"
#include "CompanyTable.h"
#include "utilities/Money.h"
#include "input/DataFileManager.h"
namespace TPCE {
const int iYearsForFins = 5;
const int iQuartersInYear = 4;
const int iFinsPerCompany = iYearsForFins * iQuartersInYear; // 5 years of 4 quaters each year
// multiplier to get the diluted number of shares from outstanding
const double fDilutedSharesMultiplier = 1.1;
// Multipliers for previous quarter to get the current quarter data
const double fFinDataDownMult = 0.9;
const double fFinDataUpMult = 1.15;
const double fFinDataIncr = 0.00000000000001;
const double fFinancialRevenueMin = 100000.00;
const double fFinancialRevenueMax = 16000000000.00;
const double fFinancialEarningsMin = -300000000.00;
const double fFinancialEarningsMax = 3000000000.00;
const INT64 iFinancialOutBasicMin = 400000;
const INT64 iFinancialOutBasicMax = INT64_CONST(9500000000);
const double fFinancialInventMin = 0.00;
const double fFinancialInventMax = 2000000000.00;
const double fFinancialAssetsMin = 100000.00;
const double fFinancialAssetsMax = 65000000000.00;
const double fFinancialLiabMin = 100000.00;
const double fFinancialLiabMax = 35000000000.00;
// Number of RNG calls to skip for one row in order
// to not use any of the random values from the previous row.
//
const int iRNGSkipOneRowFinancial = 6 + iFinsPerCompany * 6;
typedef struct FINANCIAL_GEN_ROW {
FINANCIAL_ROW m_financials[iFinsPerCompany];
} * PFINANCIAL_GEN_ROW;
class CFinancialTable : public TableTemplate<FINANCIAL_GEN_ROW> {
CCompanyTable m_CompanyTable;
int m_iFinYear; // first year to generate financials
int m_iFinQuarter; // first quarter to generate financials (0-based)
// Number of times GenerateNextRecord() was called for the current company
// data. Needed to decide when to generate next company's data.
int m_iRowsGeneratedPerCompany;
// Stores whether there is another company(s) for which to
// generate financial data.
bool m_bMoreCompanies;
TIdent m_iFinancialCountForOneLoadUnit;
//
// Generate the financial data for the next company.
//
// Return whether there are more companies to generate data for.
//
bool GenerateFinancialRows() {
TIdent FI_CO_ID;
int iFinYear, iFinQuarter;
int i;
CMoney fRev, fEarn, fInvent, fAssets, fLiab, fBasicEPS, fDilutEPS, fMargin;
INT64 iOutBasic, iOutDilut;
// Set starting values for financial values
FI_CO_ID = m_CompanyTable.GetCurrentCO_ID();
iFinYear = m_iFinYear;
iFinQuarter = m_iFinQuarter;
fRev = m_rnd.RndDoubleIncrRange(fFinancialRevenueMin, fFinancialRevenueMax, 0.01);
fEarn = m_rnd.RndDoubleIncrRange(
fFinancialEarningsMin, fRev < fFinancialEarningsMax ? fRev.DollarAmount() : fFinancialEarningsMax, 0.01);
iOutBasic = m_rnd.RndInt64Range(iFinancialOutBasicMin, iFinancialOutBasicMax);
iOutDilut = 0;
fInvent = m_rnd.RndDoubleIncrRange(fFinancialInventMin, fFinancialInventMax, 0.01);
fAssets = m_rnd.RndDoubleIncrRange(fFinancialAssetsMin, fFinancialAssetsMax, 0.01);
fLiab = m_rnd.RndDoubleIncrRange(fFinancialLiabMin, fFinancialLiabMax, 0.01);
fBasicEPS = 0.00;
fDilutEPS = 0.00;
fMargin = 0.00;
for (i = 0; i < iFinsPerCompany; ++i) {
// Compute values for this quarter
fRev = fRev * m_rnd.RndDoubleIncrRange(fFinDataDownMult, fFinDataUpMult, fFinDataIncr);
fEarn = fEarn * m_rnd.RndDoubleIncrRange(fFinDataDownMult, fFinDataUpMult, fFinDataIncr);
if (fEarn >= fRev) { // earnings cannot be greater than the revenue
fEarn = fEarn * fFinDataDownMult;
}
iOutBasic =
(INT64)((double)iOutBasic * m_rnd.RndDoubleIncrRange(fFinDataDownMult, fFinDataUpMult, fFinDataIncr));
iOutDilut = (INT64)((double)iOutBasic * fDilutedSharesMultiplier);
fInvent = fInvent * m_rnd.RndDoubleIncrRange(fFinDataDownMult, fFinDataUpMult, fFinDataIncr);
fAssets = fAssets * m_rnd.RndDoubleIncrRange(fFinDataDownMult, fFinDataUpMult, fFinDataIncr);
fLiab = fLiab * m_rnd.RndDoubleIncrRange(fFinDataDownMult, fFinDataUpMult, fFinDataIncr);
fBasicEPS = fEarn / (double)iOutBasic;
fDilutEPS = fEarn / (double)iOutDilut;
fMargin = fEarn / fRev.DollarAmount();
// Assign values for this quarter
m_row.m_financials[i].FI_CO_ID = FI_CO_ID;
m_row.m_financials[i].FI_YEAR = iFinYear;
m_row.m_financials[i].FI_QTR = iFinQuarter + 1;
m_row.m_financials[i].FI_QTR_START_DATE.Set(iFinYear, iFinQuarter * 3 + 1, 1);
m_row.m_financials[i].FI_REVENUE = fRev.DollarAmount();
m_row.m_financials[i].FI_NET_EARN = fEarn.DollarAmount();
m_row.m_financials[i].FI_OUT_BASIC = iOutBasic;
m_row.m_financials[i].FI_OUT_DILUT = iOutDilut;
m_row.m_financials[i].FI_INVENTORY = fInvent.DollarAmount();
m_row.m_financials[i].FI_ASSETS = fAssets.DollarAmount();
m_row.m_financials[i].FI_LIABILITY = fLiab.DollarAmount();
m_row.m_financials[i].FI_BASIC_EPS = fBasicEPS.DollarAmount();
m_row.m_financials[i].FI_DILUT_EPS = fDilutEPS.DollarAmount();
m_row.m_financials[i].FI_MARGIN = fMargin.DollarAmount();
// Increment quarter
iFinQuarter++;
if (iFinQuarter == iQuartersInYear) { // reached the last quarter in the year
iFinQuarter = 0; // start from the first quarter
++iFinYear; // increment year
}
}
return m_CompanyTable.GenerateNextCO_ID();
}
/*
* Reset the state for the next load unit.
*
* PARAMETERS:
* none.
*
* RETURNS:
* none.
*/
void InitNextLoadUnit() {
m_rnd.SetSeed(m_rnd.RndNthElement(RNGSeedTableDefault, (RNGSEED)m_iLastRowNumber * iRNGSkipOneRowFinancial));
ClearRecord(); // this is needed for EGenTest to work
}
public:
CFinancialTable(const DataFileManager &dfm, TIdent iCustomerCount, TIdent iStartFromCustomer)
: TableTemplate<FINANCIAL_GEN_ROW>(), m_CompanyTable(dfm, iCustomerCount, iStartFromCustomer),
m_iRowsGeneratedPerCompany(iFinsPerCompany), m_bMoreCompanies(true) {
// Start year to generate financials.
// Count by quaters
m_iFinYear = iDailyMarketBaseYear; // first financial year
m_iFinQuarter = iDailyMarketBaseMonth / 3; // first financial quarter in the year (0-based)
m_bMoreRecords = true; // initialize once
m_iFinancialCountForOneLoadUnit =
dfm.CompanyFile().CalculateCompanyCount(iDefaultLoadUnitSize) * iFinsPerCompany;
m_iLastRowNumber = dfm.CompanyFile().CalculateStartFromCompany(iStartFromCustomer) * iFinsPerCompany;
};
bool GenerateNextRecord() {
// Reset RNG at Load Unit boundary, so that all data is repeatable.
//
if (m_iLastRowNumber % m_iFinancialCountForOneLoadUnit == 0) {
InitNextLoadUnit();
}
++m_iLastRowNumber;
++m_iRowsGeneratedPerCompany;
if (m_iRowsGeneratedPerCompany >= iFinsPerCompany) {
if (m_bMoreCompanies) {
// All rows for the current company have been returned
// therefore move on to the next company
m_bMoreCompanies = GenerateFinancialRows();
m_iRowsGeneratedPerCompany = 0;
}
}
// Return false when generated the last row of the last company
if (!m_bMoreCompanies && (m_iRowsGeneratedPerCompany == iFinsPerCompany - 1)) {
m_bMoreRecords = false;
}
return MoreRecords();
}
const FINANCIAL_ROW &GetRow() {
return m_row.m_financials[m_iRowsGeneratedPerCompany];
}
};
} // namespace TPCE
#endif // FINANCIAL_TABLE_H

View File

@@ -0,0 +1,93 @@
/*
* 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
*/
/*
* Class representing the Fixed table.
*/
#ifndef FIXED_TABLE_H
#define FIXED_TABLE_H
namespace TPCE {
template <class DataFileT, class TableRowT> class FixedTable {
protected:
const DataFileT &df;
TableRowT tableRow;
int recordIdx;
public:
FixedTable(const DataFileT &dataFile) : df(dataFile), tableRow(), recordIdx(-1) {
}
virtual ~FixedTable() {
}
/*
* Generates all fields for the next record.
* Template Method Pattern used to accommodate
* subtle variations in underlying data files
* (i.e. DataFile vs. WeightedDataFile).
*/
bool GenerateNextRecord() {
// Don't increment past size().
if (MaxRecordIdx() != recordIdx) {
++recordIdx;
}
// See if we just went past the end.
if (MaxRecordIdx() == recordIdx) {
return false;
}
LoadTableRow();
// We have a valid record.
return true;
}
virtual unsigned int MaxRecordIdx() const {
return df.size();
}
const TableRowT &GetRow() const {
return tableRow;
}
virtual void LoadTableRow() = 0;
};
} // namespace TPCE
#endif // FIXED_TABLE_H

View File

@@ -0,0 +1,72 @@
/*
* 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
*/
/*
* Flat file loader for Account Permission.
*/
#ifndef FLAT_ACCOUNT_PERMISSION_LOAD_H
#define FLAT_ACCOUNT_PERMISSION_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatAccountPermissionLoad : public CFlatFileLoader<ACCOUNT_PERMISSION_ROW> {
private:
const std::string AccountPermissionRowFmt;
public:
CFlatAccountPermissionLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<ACCOUNT_PERMISSION_ROW>(szFileName, FlatFileOutputMode),
AccountPermissionRowFmt("%" PRId64 "|%s|%s|%s|%s\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const ACCOUNT_PERMISSION_ROW &next_record) {
int rc = fprintf(hOutFile, AccountPermissionRowFmt.c_str(), next_record.AP_CA_ID, next_record.AP_ACL,
next_record.AP_TAX_ID, next_record.AP_L_NAME, next_record.AP_F_NAME);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatAccountPermissionLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_ACCOUNT_PERMISSION_LOAD_H

View File

@@ -0,0 +1,71 @@
/*
* 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
*/
/*
* Flat file loader for Address.
*/
#ifndef FLAT_ADDRESS_LOAD_H
#define FLAT_ADDRESS_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatAddressLoad : public CFlatFileLoader<ADDRESS_ROW> {
private:
const std::string AddressRowFmt;
public:
CFlatAddressLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<ADDRESS_ROW>(szFileName, FlatFileOutputMode), AddressRowFmt("%" PRId64 "|%s|%s|%s|%s\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const ADDRESS_ROW &next_record) {
int rc = fprintf(hOutFile, AddressRowFmt.c_str(), next_record.AD_ID, next_record.AD_LINE1, next_record.AD_LINE2,
next_record.AD_ZC_CODE, next_record.AD_CTRY);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatAddressLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_ADDRESS_LOAD_H

View File

@@ -0,0 +1,71 @@
/*
* 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
*/
/*
* Flat file loader for BROKER.
*/
#ifndef FLAT_BROKER_LOAD_H
#define FLAT_BROKER_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatBrokerLoad : public CFlatFileLoader<BROKER_ROW> {
private:
const std::string BrokerRowFmt;
public:
CFlatBrokerLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<BROKER_ROW>(szFileName, FlatFileOutputMode), BrokerRowFmt("%" PRId64 "|%s|%s|%d|%.2f\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const BROKER_ROW &next_record) {
int rc = fprintf(hOutFile, BrokerRowFmt.c_str(), next_record.B_ID, next_record.B_ST_ID, next_record.B_NAME,
next_record.B_NUM_TRADES, next_record.B_COMM_TOTAL);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatBrokerLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_BROKER_LOAD_H

View 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
* - Doug Johnson
*/
/*
* Flat file loader for CASH_TRANSACTION.
*/
#ifndef FLAT_CASH_TRANSACTION_LOAD_H
#define FLAT_CASH_TRANSACTION_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatCashTransactionLoad : public CFlatFileLoader<CASH_TRANSACTION_ROW> {
private:
CDateTime Flat_CT_DTS;
const std::string CashTransactionRowFmt;
public:
CFlatCashTransactionLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<CASH_TRANSACTION_ROW>(szFileName, FlatFileOutputMode),
CashTransactionRowFmt("%" PRId64 "|%s|%.2f|%s\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const CASH_TRANSACTION_ROW &next_record) {
Flat_CT_DTS = next_record.CT_DTS;
int rc = fprintf(hOutFile, CashTransactionRowFmt.c_str(), next_record.CT_T_ID,
Flat_CT_DTS.ToStr(FlatFileDateTimeFormat), next_record.CT_AMT, next_record.CT_NAME);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatCashTransactionLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_CASH_TRANSACTION_LOAD_H

View File

@@ -0,0 +1,72 @@
/*
* 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
*/
/*
* Flat file loader for CHARGE.
*/
#ifndef FLAT_CHARGE_LOAD_H
#define FLAT_CHARGE_LOAD_H
#include "FlatFileLoad_common.h"
#include "TableTypes.h"
namespace TPCE {
class CFlatChargeLoad : public CFlatFileLoader<CHARGE_ROW> {
private:
const std::string ChargeRowFmt;
public:
CFlatChargeLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<CHARGE_ROW>(szFileName, FlatFileOutputMode), ChargeRowFmt("%s|%d|%.2f\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const CHARGE_ROW &next_record) {
// fprintf(hOutFile, "%s\n", next_record.ToString('|').c_str());
int rc =
fprintf(hOutFile, ChargeRowFmt.c_str(), next_record.CH_TT_ID, next_record.CH_C_TIER, next_record.CH_CHRG);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatChargeLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_CHARGE_LOAD_H

View File

@@ -0,0 +1,72 @@
/*
* 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
*/
/*
* Flat file loader for COMMISSIOIN_RATE.
*/
#ifndef FLAT_COMMISSION_RATE_LOAD_H
#define FLAT_COMMISSION_RATE_LOAD_H
#include "FlatFileLoad_common.h"
#include "TableTypes.h"
namespace TPCE {
class CFlatCommissionRateLoad : public CFlatFileLoader<COMMISSION_RATE_ROW> {
private:
const std::string CommissionRateRowFmt;
public:
CFlatCommissionRateLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<COMMISSION_RATE_ROW>(szFileName, FlatFileOutputMode),
CommissionRateRowFmt("%d|%s|%s|%d|%d|%.2f\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const COMMISSION_RATE_ROW &next_record) {
int rc = fprintf(hOutFile, CommissionRateRowFmt.c_str(), next_record.CR_C_TIER, next_record.CR_TT_ID,
next_record.CR_EX_ID, next_record.CR_FROM_QTY, next_record.CR_TO_QTY, next_record.CR_RATE);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatCommissionRateLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_COMMISSION_RATE_LOAD_H

View File

@@ -0,0 +1,70 @@
/*
* 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
*/
/*
* Flat file loader for COMPANY_COMPETITOR.
*/
#ifndef FLAT_COMPANY_COMPETITOR_LOAD_H
#define FLAT_COMPANY_COMPETITOR_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatCompanyCompetitorLoad : public CFlatFileLoader<COMPANY_COMPETITOR_ROW> {
private:
const std::string CompanyCompetitorRowFmt;
public:
CFlatCompanyCompetitorLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<COMPANY_COMPETITOR_ROW>(szFileName, FlatFileOutputMode),
CompanyCompetitorRowFmt("%" PRId64 "|%" PRId64 "|%s\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const COMPANY_COMPETITOR_ROW &next_record) {
int rc = fprintf(hOutFile, CompanyCompetitorRowFmt.c_str(), next_record.CP_CO_ID, next_record.CP_COMP_CO_ID,
next_record.CP_IN_ID);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatCompanyCompetitorLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_COMPANY_COMPETITOR_LOAD_H

View 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
* - Doug Johnson
*/
/*
* Flat file loader for COMPANY.
*/
#ifndef FLAT_COMPANY_LOAD_H
#define FLAT_COMPANY_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatCompanyLoad : public CFlatFileLoader<COMPANY_ROW> {
private:
CDateTime Flat_CO_OPEN_DATE;
const std::string CompanyRowFmt;
public:
CFlatCompanyLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<COMPANY_ROW>(szFileName, FlatFileOutputMode),
CompanyRowFmt("%" PRId64 "|%s|%s|%s|%s|%s|%" PRId64 "|%s|%s\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const COMPANY_ROW &next_record) {
Flat_CO_OPEN_DATE = next_record.CO_OPEN_DATE;
int rc = fprintf(hOutFile, CompanyRowFmt.c_str(), next_record.CO_ID, next_record.CO_ST_ID, next_record.CO_NAME,
next_record.CO_IN_ID, next_record.CO_SP_RATE, next_record.CO_CEO, next_record.CO_AD_ID,
next_record.CO_DESC, Flat_CO_OPEN_DATE.ToStr(FlatFileDateFormat));
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatCompanyLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_COMPANY_LOAD_H

View File

@@ -0,0 +1,70 @@
/*
* 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
*/
/*
* Flat file loader for CUSTOMER_ACCOUNT.
*/
#ifndef FLAT_CUSTOMER_ACCOUNT_LOAD_H
#define FLAT_CUSTOMER_ACCOUNT_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatCustomerAccountLoad : public CFlatFileLoader<CUSTOMER_ACCOUNT_ROW> {
private:
const std::string CustomerAccountRowFmt;
public:
CFlatCustomerAccountLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<CUSTOMER_ACCOUNT_ROW>(szFileName, FlatFileOutputMode),
CustomerAccountRowFmt("%" PRId64 "|%" PRId64 "|%" PRId64 "|%s|%d|%.2f\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const CUSTOMER_ACCOUNT_ROW &next_record) {
int rc = fprintf(hOutFile, CustomerAccountRowFmt.c_str(), next_record.CA_ID, next_record.CA_B_ID,
next_record.CA_C_ID, next_record.CA_NAME, (int)next_record.CA_TAX_ST, next_record.CA_BAL);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatCustomerAccountLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_CUSTOMER_ACCOUNT_LOAD_H

View 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
* - Doug Johnson
*/
/*
* Flat file loader for CUSTOMER.
*/
#ifndef FLAT_CUSTOMER_LOAD_H
#define FLAT_CUSTOMER_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatCustomerLoad : public CFlatFileLoader<CUSTOMER_ROW> {
private:
CDateTime Flat_C_DOB;
const std::string CustomerRowFmt;
public:
CFlatCustomerLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<CUSTOMER_ROW>(szFileName, FlatFileOutputMode),
CustomerRowFmt("%" PRId64 "|%s|%s|%s|%s|%s|%c|%d|%s|%" PRId64
"|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const CUSTOMER_ROW &next_record) {
Flat_C_DOB = next_record.C_DOB;
int rc = fprintf(hOutFile, CustomerRowFmt.c_str(), next_record.C_ID, next_record.C_TAX_ID, next_record.C_ST_ID,
next_record.C_L_NAME, next_record.C_F_NAME, next_record.C_M_NAME, next_record.C_GNDR,
(int)next_record.C_TIER, Flat_C_DOB.ToStr(FlatFileDateFormat), next_record.C_AD_ID,
next_record.C_CTRY_1, next_record.C_AREA_1, next_record.C_LOCAL_1, next_record.C_EXT_1,
next_record.C_CTRY_2, next_record.C_AREA_2, next_record.C_LOCAL_2, next_record.C_EXT_2,
next_record.C_CTRY_3, next_record.C_AREA_3, next_record.C_LOCAL_3, next_record.C_EXT_3,
next_record.C_EMAIL_1, next_record.C_EMAIL_2);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatCustomerLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_CUSTOMER_LOAD_H

View File

@@ -0,0 +1,69 @@
/*
* 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
*/
/*
* Flat file loader for CUSTOMER_TAXRATE.
*/
#ifndef FLAT_CUSTOMER_TAXRATE_LOAD_H
#define FLAT_CUSTOMER_TAXRATE_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatCustomerTaxrateLoad : public CFlatFileLoader<CUSTOMER_TAXRATE_ROW> {
private:
const std::string CustomerTaxrateRowFmt;
public:
CFlatCustomerTaxrateLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<CUSTOMER_TAXRATE_ROW>(szFileName, FlatFileOutputMode),
CustomerTaxrateRowFmt("%s|%" PRId64 "\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const CUSTOMER_TAXRATE_ROW &next_record) {
int rc = fprintf(hOutFile, CustomerTaxrateRowFmt.c_str(), next_record.CX_TX_ID, next_record.CX_C_ID);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatCustomerTaxrateLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_CUSTOMER_TAXRATE_LOAD_H

View File

@@ -0,0 +1,74 @@
/*
* 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
*/
/*
* Flat file loader for DAILY_MARKET.
*/
#ifndef FLAT_DAILY_MARKET_LOAD_H
#define FLAT_DAILY_MARKET_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatDailyMarketLoad : public CFlatFileLoader<DAILY_MARKET_ROW> {
private:
CDateTime Flat_DM_DATE;
const std::string DailyMarketRowFmt;
public:
CFlatDailyMarketLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<DAILY_MARKET_ROW>(szFileName, FlatFileOutputMode),
DailyMarketRowFmt("%s|%s|%.2f|%.2f|%.2f|%" PRId64 "\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const DAILY_MARKET_ROW &next_record) {
Flat_DM_DATE = next_record.DM_DATE;
int rc =
fprintf(hOutFile, DailyMarketRowFmt.c_str(), Flat_DM_DATE.ToStr(FlatFileDateFormat), next_record.DM_S_SYMB,
next_record.DM_CLOSE, next_record.DM_HIGH, next_record.DM_LOW, next_record.DM_VOL);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatDailyMarketLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_DAILY_MARKET_LOAD_H

View File

@@ -0,0 +1,72 @@
/*
* 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
*/
/*
* Flat file loader for EXCHANGE.
*/
#ifndef FLAT_EXCHANGE_LOAD_H
#define FLAT_EXCHANGE_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatExchangeLoad : public CFlatFileLoader<EXCHANGE_ROW> {
private:
const std::string ExchangeRowFmt;
public:
CFlatExchangeLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<EXCHANGE_ROW>(szFileName, FlatFileOutputMode),
ExchangeRowFmt("%s|%s|%d|%d|%d|%s|%" PRId64 "\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const EXCHANGE_ROW &next_record) {
int rc =
fprintf(hOutFile, ExchangeRowFmt.c_str(), next_record.EX_ID, next_record.EX_NAME, next_record.EX_NUM_SYMB,
next_record.EX_OPEN, next_record.EX_CLOSE, next_record.EX_DESC, next_record.EX_AD_ID);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatExchangeLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_EXCHANGE_LOAD_H

View File

@@ -0,0 +1,52 @@
/*
* 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 Ruemmler
*/
#ifndef FLAT_FILE_LOAD_COMMON_H
#define FLAT_FILE_LOAD_COMMON_H
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include "FlatFileLoader.h"
#include "TableRows.h"
#include "utilities/DateTime.h"
#include "utilities/error.h"
#endif // #ifndef FLAT_FILE_LOAD_COMMON_H

View File

@@ -0,0 +1,85 @@
/*
* 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 FLAT_FILE_LOAD_STDAFX_H
#define FLAT_FILE_LOAD_STDAFX_H
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <iostream>
#include <fstream>
#include <cstdio>
#include "utilities/EGenUtilities_stdafx.h"
#include "TableRows.h"
#include "EGenBaseLoader_stdafx.h"
#include "FlatFileLoader.h"
#include "FlatAccountPermissionLoad.h"
#include "FlatAddressLoad.h"
#include "FlatBrokerLoad.h"
#include "FlatCashTransactionLoad.h"
#include "FlatChargeLoad.h"
#include "FlatCommissionRateLoad.h"
#include "FlatCompanyLoad.h"
#include "FlatCompanyCompetitorLoad.h"
#include "FlatCustomerLoad.h"
#include "FlatCustomerAccountLoad.h"
#include "FlatCustomerTaxrateLoad.h"
#include "FlatDailyMarketLoad.h"
#include "FlatExchangeLoad.h"
#include "FlatFinancialLoad.h"
#include "FlatHoldingLoad.h"
#include "FlatHoldingHistoryLoad.h"
#include "FlatHoldingSummaryLoad.h"
#include "FlatIndustryLoad.h"
#include "FlatLastTradeLoad.h"
#include "FlatNewsItemLoad.h"
#include "FlatNewsXRefLoad.h"
#include "FlatSectorLoad.h"
#include "FlatSecurityLoad.h"
#include "FlatSettlementLoad.h"
#include "FlatStatusTypeLoad.h"
#include "FlatTaxRateLoad.h"
#include "FlatTradeLoad.h"
#include "FlatTradeHistoryLoad.h"
#include "FlatTradeRequestLoad.h"
#include "FlatTradeTypeLoad.h"
#include "FlatWatchItemLoad.h"
#include "FlatWatchListLoad.h"
#include "FlatZipCodeLoad.h"
#include "FlatLoaderFactory.h"
#endif // #ifndef FLAT_FILE_LOAD_STDAFX_H

View File

@@ -0,0 +1,164 @@
/*
* 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
*/
/*
* Class representing a flat file loader.
*/
#ifndef FLAT_FILE_LOADER_H
#define FLAT_FILE_LOADER_H
#include <cstdio>
#include "BaseLoader.h"
#include "unusedflag.h"
using namespace std;
namespace TPCE {
// EGen Formatting Defaults
#ifndef DATETIME_FORMAT
#define DATETIME_FORMAT 12 // YYYY-MM-DD HH:MM:SS.mmm
#endif
#ifndef TIME_FORMAT
#define TIME_FORMAT 01 // hh:mm:ss
#endif
#ifndef DATE_FORMAT
#define DATE_FORMAT 10 // YYYY-MM-DD
#endif
#ifndef BOOLEAN_TRUE
#define BOOLEAN_TRUE "1"
#endif
#ifndef BOOLEAN_FALSE
#define BOOLEAN_FALSE "0"
#endif
#ifndef BUFFER_SIZE
#define BUFFER_SIZE 0
#endif
#ifndef FILE_OPEN_MODE_OVERWRITE
#ifdef WIN32
#define FILE_OPEN_MODE_OVERWRITE "w+"
#else
#define FILE_OPEN_MODE_OVERWRITE "w"
#endif
#endif
#ifndef FILE_OPEN_MODE_APPEND
#ifdef WIN32
#define FILE_OPEN_MODE_APPEND "a+"
#else
#define FILE_OPEN_MODE_APPEND "a"
#endif
#endif
// EGen Formatting
const int FlatFileDateTimeFormat = DATETIME_FORMAT;
const int FlatFileTimeFormat = TIME_FORMAT;
const int FlatFileDateFormat = DATE_FORMAT;
const char *const FlatFileBoolTrue = BOOLEAN_TRUE;
const char *const FlatFileBoolFalse = BOOLEAN_FALSE;
// EGen Buffering
const int FlatFileBufferSize = BUFFER_SIZE;
// EGen File Open Modes
const char *const FlatFileOpenModeOverwrite = FILE_OPEN_MODE_OVERWRITE;
const char *const FlatFileOpenModeAppend = FILE_OPEN_MODE_APPEND;
// Overwrite vs. append functionality for output flat files.
enum FlatFileOutputModes { FLAT_FILE_OUTPUT_APPEND = 0, FLAT_FILE_OUTPUT_OVERWRITE };
/*
* FlatLoader class.
*/
template <typename T> class CFlatFileLoader : public CBaseLoader<T> {
protected:
FILE *hOutFile;
public:
CFlatFileLoader(char *szFileName, FlatFileOutputModes FlatFileOutputMode);
~CFlatFileLoader(void);
// virtual void WriteNextRecord(const T* next_record UNUSED) {};
// virtual void WriteNextRecord(const T& next_record UNUSED) {};
void FinishLoad(); // finish load
};
/*
* The constructor.
*/
template <typename T> CFlatFileLoader<T>::CFlatFileLoader(char *szFileName, FlatFileOutputModes flatFileOutputMode) {
if (FLAT_FILE_OUTPUT_APPEND == flatFileOutputMode) {
hOutFile = fopen(szFileName, FlatFileOpenModeAppend);
} else if (FLAT_FILE_OUTPUT_OVERWRITE == flatFileOutputMode) {
hOutFile = fopen(szFileName, FlatFileOpenModeOverwrite);
}
if (!hOutFile) {
throw CSystemErr(CSystemErr::eCreateFile, "CFlatFileLoader<T>::CFlatFileLoader");
}
if (FlatFileBufferSize > 0) {
if (setvbuf(hOutFile, NULL, _IOFBF, FlatFileBufferSize)) {
throw CSystemErr(CSystemErr::eCreateFile, "CFlatFileLoader<T>::CFlatFileLoader");
}
}
}
/*
* Destructor.
*/
template <typename T> CFlatFileLoader<T>::~CFlatFileLoader() {
fclose(hOutFile);
}
/*
* Commit sent rows. This needs to be called after the last row has been
* sent and before the object is destructed. Otherwise all rows will be
* discarded.
*/
template <typename T> void CFlatFileLoader<T>::FinishLoad() {
fflush(hOutFile);
}
} // namespace TPCE
#endif // FLAT_FILE_LOADER_H

View File

@@ -0,0 +1,75 @@
/*
* 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
*/
/*
* Flat file loader for FINANCIAL.
*/
#ifndef FLAT_FINANCIAL_LOAD_H
#define FLAT_FINANCIAL_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatFinancialLoad : public CFlatFileLoader<FINANCIAL_ROW> {
private:
CDateTime Flat_FI_QTR_START_DATE;
const std::string FinancialRowFmt;
public:
CFlatFinancialLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<FINANCIAL_ROW>(szFileName, FlatFileOutputMode),
FinancialRowFmt("%" PRId64 "|%d|%d|%s|%.2f|%.2f|%.2f|%.2f|%.2f|%.2f|%.2f|%.2f|%" PRId64 "|%" PRId64 "\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const FINANCIAL_ROW &next_record) {
Flat_FI_QTR_START_DATE = next_record.FI_QTR_START_DATE;
int rc = fprintf(hOutFile, FinancialRowFmt.c_str(), next_record.FI_CO_ID, next_record.FI_YEAR,
next_record.FI_QTR, Flat_FI_QTR_START_DATE.ToStr(FlatFileDateFormat), next_record.FI_REVENUE,
next_record.FI_NET_EARN, next_record.FI_BASIC_EPS, next_record.FI_DILUT_EPS,
next_record.FI_MARGIN, next_record.FI_INVENTORY, next_record.FI_ASSETS,
next_record.FI_LIABILITY, next_record.FI_OUT_BASIC, next_record.FI_OUT_DILUT);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatFinancialLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_FINANCIAL_LOAD_H

View File

@@ -0,0 +1,70 @@
/*
* 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
*/
/*
* Flat file loader for HOLDING_HISTORY.
*/
#ifndef FLAT_HOLDING_HISTORY_LOAD_H
#define FLAT_HOLDING_HISTORY_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatHoldingHistoryLoad : public CFlatFileLoader<HOLDING_HISTORY_ROW> {
private:
const std::string HoldingHistoryRowFmt;
public:
CFlatHoldingHistoryLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<HOLDING_HISTORY_ROW>(szFileName, FlatFileOutputMode),
HoldingHistoryRowFmt("%" PRId64 "|%" PRId64 "|%d|%d\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const HOLDING_HISTORY_ROW &next_record) {
int rc = fprintf(hOutFile, HoldingHistoryRowFmt.c_str(), next_record.HH_H_T_ID, next_record.HH_T_ID,
next_record.HH_BEFORE_QTY, next_record.HH_AFTER_QTY);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatHoldingHistoryLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_HOLDING_HISTORY_LOAD_H

View File

@@ -0,0 +1,72 @@
/*
* 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
*/
/*
* Flat file loader for HOLDING.
*/
#ifndef FLAT_HOLDING_LOAD_H
#define FLAT_HOLDING_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatHoldingLoad : public CFlatFileLoader<HOLDING_ROW> {
private:
CDateTime Flat_H_DTS;
const std::string HoldingRowFmt;
public:
CFlatHoldingLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<HOLDING_ROW>(szFileName, FlatFileOutputMode),
HoldingRowFmt("%" PRId64 "|%" PRId64 "|%s|%s|%.2f|%d\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const HOLDING_ROW &next_record) {
Flat_H_DTS = next_record.H_DTS;
int rc = fprintf(hOutFile, HoldingRowFmt.c_str(), next_record.H_T_ID, next_record.H_CA_ID, next_record.H_S_SYMB,
Flat_H_DTS.ToStr(FlatFileDateTimeFormat), next_record.H_PRICE, next_record.H_QTY);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatHoldingLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_HOLDING_LOAD_H

View File

@@ -0,0 +1,70 @@
/*
* 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
*/
/*
* Flat file loader for HOLDING_SUMMARY.
*/
#ifndef FLAT_HOLDING_SUMMARY_LOAD_H
#define FLAT_HOLDING_SUMMARY_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatHoldingSummaryLoad : public CFlatFileLoader<HOLDING_SUMMARY_ROW> {
private:
const std::string HoldingSummaryRowFmt;
public:
CFlatHoldingSummaryLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<HOLDING_SUMMARY_ROW>(szFileName, FlatFileOutputMode),
HoldingSummaryRowFmt("%" PRId64 "|%s|%d\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const HOLDING_SUMMARY_ROW &next_record) {
int rc = fprintf(hOutFile, HoldingSummaryRowFmt.c_str(), next_record.HS_CA_ID, next_record.HS_S_SYMB,
next_record.HS_QTY);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatHoldingSummaryLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_HOLDING_SUMMARY_LOAD_H

View File

@@ -0,0 +1,71 @@
/*
* 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
*/
/*
* Flat file loader for INDUSTRY.
*/
#ifndef FLAT_INDUSTRY_LOAD_H
#define FLAT_INDUSTRY_LOAD_H
#include "FlatFileLoad_common.h"
#include "TableTypes.h"
namespace TPCE {
class CFlatIndustryLoad : public CFlatFileLoader<INDUSTRY_ROW> {
private:
const std::string IndustryRowFmt;
public:
CFlatIndustryLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<INDUSTRY_ROW>(szFileName, FlatFileOutputMode), IndustryRowFmt("%s|%s|%s\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const INDUSTRY_ROW &next_record) {
int rc =
fprintf(hOutFile, IndustryRowFmt.c_str(), next_record.IN_ID, next_record.IN_NAME, next_record.IN_SC_ID);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatIndustryLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_INDUSTRY_LOAD_H

View 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
* - Doug Johnson
*/
/*
* Flat file loader for LAST_TRADE.
*/
#ifndef FLAT_LAST_TRADE_LOAD_H
#define FLAT_LAST_TRADE_LOAD_H
#include "FlatFileLoad_common.h"
namespace TPCE {
class CFlatLastTradeLoad : public CFlatFileLoader<LAST_TRADE_ROW> {
private:
CDateTime Flat_LT_DTS;
const std::string LastTradeRowFmt;
public:
CFlatLastTradeLoad(char *szFileName, FlatFileOutputModes FlatFileOutputMode)
: CFlatFileLoader<LAST_TRADE_ROW>(szFileName, FlatFileOutputMode),
LastTradeRowFmt("%s|%s|%.2f|%.2f|%" PRId64 "\n"){};
/*
* Writes a record to the file.
*/
void WriteNextRecord(const LAST_TRADE_ROW &next_record) {
Flat_LT_DTS = next_record.LT_DTS;
int rc =
fprintf(hOutFile, LastTradeRowFmt.c_str(), next_record.LT_S_SYMB, Flat_LT_DTS.ToStr(FlatFileDateTimeFormat),
next_record.LT_PRICE, next_record.LT_OPEN_PRICE, next_record.LT_VOL);
if (rc < 0) {
throw CSystemErr(CSystemErr::eWriteFile, "CFlatLastTradeLoad::WriteNextRecord");
}
}
};
} // namespace TPCE
#endif // FLAT_LAST_TRADE_LOAD_H

Some files were not shown because too many files have changed in this diff Show More