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