should be it
This commit is contained in:
64
external/duckdb/third_party/tpce-tool/input/AreaCodeDataFileRecord.cpp
vendored
Normal file
64
external/duckdb/third_party/tpce-tool/input/AreaCodeDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 "input/AreaCodeDataFileRecord.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
AreaCodeDataFileRecord::AreaCodeDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
//// Should we check to see if this is a 3-digit number?
|
||||
DFRStringInit(fields[0], areaCode, areaCodeCStr, maxAreaCodeLen);
|
||||
}
|
||||
|
||||
const std::string &AreaCodeDataFileRecord::AREA_CODE() const {
|
||||
return areaCode;
|
||||
}
|
||||
|
||||
const char *AreaCodeDataFileRecord::AREA_CODE_CSTR() const {
|
||||
return areaCodeCStr;
|
||||
}
|
||||
|
||||
std::string AreaCodeDataFileRecord::ToString() const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
return AREA_CODE();
|
||||
}
|
||||
38
external/duckdb/third_party/tpce-tool/input/CMakeLists.txt
vendored
Normal file
38
external/duckdb/third_party/tpce-tool/input/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
add_library(tpce_input OBJECT
|
||||
AreaCodeDataFileRecord.cpp
|
||||
ChargeDataFileRecord.cpp
|
||||
CommissionRateDataFileRecord.cpp
|
||||
CompanyCompetitorDataFileRecord.cpp
|
||||
CompanyCompetitorFile.cpp
|
||||
CompanyDataFileRecord.cpp
|
||||
CompanyFile.cpp
|
||||
CompanySPRateDataFileRecord.cpp
|
||||
DataFileManager.cpp
|
||||
ExchangeDataFileRecord.cpp
|
||||
FemaleFirstNameDataFileRecord.cpp
|
||||
IndustryDataFileRecord.cpp
|
||||
LastNameDataFileRecord.cpp
|
||||
MaleFirstNameDataFileRecord.cpp
|
||||
NewsDataFileRecord.cpp
|
||||
NonTaxableAccountNameDataFileRecord.cpp
|
||||
SectorDataFileRecord.cpp
|
||||
SecurityDataFileRecord.cpp
|
||||
SecurityFile.cpp
|
||||
StatusTypeDataFileRecord.cpp
|
||||
StreamSplitter.cpp
|
||||
StreetNameDataFileRecord.cpp
|
||||
StreetSuffixDataFileRecord.cpp
|
||||
StringSplitter.cpp
|
||||
TaxRateCountryDataFileRecord.cpp
|
||||
TaxRateDivisionDataFileRecord.cpp
|
||||
TaxRateFile.cpp
|
||||
TaxableAccountNameDataFileRecord.cpp
|
||||
TextFileSplitter.cpp
|
||||
TradeTypeDataFileRecord.cpp
|
||||
Utilities.cpp
|
||||
ZipCodeDataFileRecord.cpp)
|
||||
set(TPCE_OBJECT_FILES
|
||||
${TPCE_OBJECT_FILES} $<TARGET_OBJECTS:tpce_input>
|
||||
PARENT_SCOPE)
|
||||
|
||||
disable_target_warnings(tpce_input)
|
||||
83
external/duckdb/third_party/tpce-tool/input/ChargeDataFileRecord.cpp
vendored
Normal file
83
external/duckdb/third_party/tpce-tool/input/ChargeDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 "input/ChargeDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib> // for atoi, atof
|
||||
// #include <string> // C++11 for stoi, stod
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
ChargeDataFileRecord::ChargeDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], ch_tt_id, ch_tt_idCStr, maxCh_tt_idLen);
|
||||
|
||||
ch_c_tier = std::atoi(fields[1].c_str());
|
||||
// ch_c_tier = std::stoi(fields[1]); // C++11
|
||||
|
||||
ch_chrg = std::atof(fields[2].c_str());
|
||||
// ch_chrg = std::stod(fields[2]); // C++11
|
||||
}
|
||||
|
||||
const std::string &ChargeDataFileRecord::CH_TT_ID() const {
|
||||
return ch_tt_id;
|
||||
}
|
||||
|
||||
const char *ChargeDataFileRecord::CH_TT_ID_CSTR() const {
|
||||
return ch_tt_idCStr;
|
||||
}
|
||||
|
||||
int ChargeDataFileRecord::CH_C_TIER() const {
|
||||
return ch_c_tier;
|
||||
}
|
||||
|
||||
double ChargeDataFileRecord::CH_CHRG() const {
|
||||
return ch_chrg;
|
||||
}
|
||||
|
||||
std::string ChargeDataFileRecord::ToString(char fieldSeparator) const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
std::ostringstream msg;
|
||||
msg << CH_TT_ID() << fieldSeparator << CH_C_TIER() << fieldSeparator << CH_CHRG();
|
||||
return msg.str();
|
||||
}
|
||||
106
external/duckdb/third_party/tpce-tool/input/CommissionRateDataFileRecord.cpp
vendored
Normal file
106
external/duckdb/third_party/tpce-tool/input/CommissionRateDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Doug Johnson
|
||||
*/
|
||||
|
||||
#include "input/CommissionRateDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib> // for atoi, atof
|
||||
// #include <string> // C++11 for stoi, stod
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
CommissionRateDataFileRecord::CommissionRateDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
cr_c_tier = std::atoi(fields[0].c_str());
|
||||
// cr_c_tier = std::stoi(fields[0]); // C++11
|
||||
|
||||
DFRStringInit(fields[1], cr_tt_id, cr_tt_idCStr, maxCr_tt_idLen);
|
||||
|
||||
DFRStringInit(fields[2], cr_ex_id, cr_ex_idCStr, maxCr_ex_idLen);
|
||||
|
||||
cr_from_qty = std::atoi(fields[3].c_str());
|
||||
// cr_from_qty = std::stoi(fields[3]); // C++11
|
||||
cr_to_qty = std::atoi(fields[4].c_str());
|
||||
// cr_to_qty = std::stoi(fields[4]); // C++11
|
||||
cr_rate = std::atof(fields[5].c_str());
|
||||
// cr_rate = std::stod(fields[5]); // C++11
|
||||
}
|
||||
|
||||
int CommissionRateDataFileRecord::CR_C_TIER() const {
|
||||
return cr_c_tier;
|
||||
}
|
||||
|
||||
const std::string &CommissionRateDataFileRecord::CR_TT_ID() const {
|
||||
return cr_tt_id;
|
||||
}
|
||||
|
||||
const char *CommissionRateDataFileRecord::CR_TT_ID_CSTR() const {
|
||||
return cr_tt_idCStr;
|
||||
}
|
||||
|
||||
const std::string &CommissionRateDataFileRecord::CR_EX_ID() const {
|
||||
return cr_ex_id;
|
||||
}
|
||||
|
||||
const char *CommissionRateDataFileRecord::CR_EX_ID_CSTR() const {
|
||||
return cr_ex_idCStr;
|
||||
}
|
||||
|
||||
int CommissionRateDataFileRecord::CR_FROM_QTY() const {
|
||||
return cr_from_qty;
|
||||
}
|
||||
|
||||
int CommissionRateDataFileRecord::CR_TO_QTY() const {
|
||||
return cr_to_qty;
|
||||
}
|
||||
|
||||
double CommissionRateDataFileRecord::CR_RATE() const {
|
||||
return cr_rate;
|
||||
}
|
||||
|
||||
std::string CommissionRateDataFileRecord::ToString(char fieldSeparator) const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
std::ostringstream msg;
|
||||
msg << CR_C_TIER() << fieldSeparator << CR_TT_ID() << fieldSeparator << CR_EX_ID() << fieldSeparator
|
||||
<< CR_FROM_QTY() << fieldSeparator << CR_TO_QTY() << fieldSeparator << CR_RATE();
|
||||
return msg.str();
|
||||
}
|
||||
82
external/duckdb/third_party/tpce-tool/input/CompanyCompetitorDataFileRecord.cpp
vendored
Normal file
82
external/duckdb/third_party/tpce-tool/input/CompanyCompetitorDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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 "input/CompanyCompetitorDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib> // for atoi, atof
|
||||
// #include <string> // C++11 for stoi, stod
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
CompanyCompetitorDataFileRecord::CompanyCompetitorDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
cp_co_id = std::atoi(fields[0].c_str());
|
||||
// cp_co_id = std::stoi(fields[0]); // C++11
|
||||
cp_comp_co_id = std::atoi(fields[1].c_str());
|
||||
// cp_comp_co_id = std::stoi(fields[1]); // C++11
|
||||
|
||||
DFRStringInit(fields[2], cp_in_id, cp_in_idCStr, maxCp_in_idLen);
|
||||
}
|
||||
|
||||
TIdent CompanyCompetitorDataFileRecord::CP_CO_ID() const {
|
||||
return cp_co_id;
|
||||
}
|
||||
|
||||
TIdent CompanyCompetitorDataFileRecord::CP_COMP_CO_ID() const {
|
||||
return cp_comp_co_id;
|
||||
}
|
||||
|
||||
const std::string &CompanyCompetitorDataFileRecord::CP_IN_ID() const {
|
||||
return cp_in_id;
|
||||
}
|
||||
|
||||
const char *CompanyCompetitorDataFileRecord::CP_IN_ID_CSTR() const {
|
||||
return cp_in_idCStr;
|
||||
}
|
||||
|
||||
std::string CompanyCompetitorDataFileRecord::ToString(char fieldSeparator) const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
std::ostringstream msg;
|
||||
msg << CP_CO_ID() << fieldSeparator << CP_COMP_CO_ID() << fieldSeparator << CP_IN_ID();
|
||||
return msg.str();
|
||||
}
|
||||
189
external/duckdb/third_party/tpce-tool/input/CompanyCompetitorFile.cpp
vendored
Normal file
189
external/duckdb/third_party/tpce-tool/input/CompanyCompetitorFile.cpp
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "input/CompanyCompetitorFile.h"
|
||||
#include "utilities/MiscConsts.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
/*
|
||||
* 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::CCompanyCompetitorFile(const CompanyCompetitorDataFile_t &dataFile,
|
||||
TIdent iConfiguredCustomerCount, TIdent iActiveCustomerCount,
|
||||
UINT baseCompanyCount)
|
||||
: m_dataFile(&dataFile),
|
||||
m_iConfiguredCompanyCompetitorCount(CalculateCompanyCompetitorCount(iConfiguredCustomerCount)),
|
||||
m_iActiveCompanyCompetitorCount(CalculateCompanyCompetitorCount(iActiveCustomerCount)),
|
||||
m_iBaseCompanyCount(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 CCompanyCompetitorFile::CalculateCompanyCompetitorCount(TIdent iCustomerCount) const {
|
||||
return iCustomerCount / iDefaultLoadUnitSize * iOneLoadUnitCompanyCompetitorCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the first company competitor id (0-based) for the specified
|
||||
* customer id.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* IN iStartFromCustomer - customer id
|
||||
*
|
||||
* RETURNS:
|
||||
* company competitor id.
|
||||
*/
|
||||
TIdent CCompanyCompetitorFile::CalculateStartFromCompanyCompetitor(TIdent iStartFromCustomer) const {
|
||||
return iStartFromCustomer / iDefaultLoadUnitSize * iOneLoadUnitCompanyCompetitorCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 CCompanyCompetitorFile::GetCompanyId(TIdent iIndex) const {
|
||||
// Index wraps around every 15000 companies.
|
||||
//
|
||||
return (*m_dataFile)[(int)(iIndex % m_dataFile->size())].CP_CO_ID() + iTIdentShift +
|
||||
iIndex / m_dataFile->size() * m_iBaseCompanyCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 CCompanyCompetitorFile::GetCompanyCompetitorId(TIdent iIndex) const {
|
||||
// Index wraps around every 5000 companies.
|
||||
//
|
||||
return (*m_dataFile)[(int)(iIndex % m_dataFile->size())].CP_COMP_CO_ID() + iTIdentShift +
|
||||
iIndex / m_dataFile->size() * m_iBaseCompanyCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 &CCompanyCompetitorFile::GetIndustryId(TIdent iIndex) const {
|
||||
// Index wraps around every 5000 companies.
|
||||
//
|
||||
return (*m_dataFile)[(int)(iIndex % m_dataFile->size())].CP_IN_ID();
|
||||
}
|
||||
|
||||
const char *CCompanyCompetitorFile::GetIndustryIdCSTR(TIdent iIndex) const {
|
||||
// Index wraps around every 5000 companies.
|
||||
//
|
||||
return (*m_dataFile)[(int)(iIndex % m_dataFile->size())].CP_IN_ID_CSTR();
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the number of company competitors in the database for
|
||||
* the configured number of customers.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* none.
|
||||
*
|
||||
* RETURNS:
|
||||
* configured company competitor count.
|
||||
*/
|
||||
TIdent CCompanyCompetitorFile::GetConfiguredCompanyCompetitorCount() const {
|
||||
return m_iConfiguredCompanyCompetitorCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the number of company competitors in the database for
|
||||
* the active number of customers.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* none.
|
||||
*
|
||||
* RETURNS:
|
||||
* active company competitor count.
|
||||
*/
|
||||
TIdent CCompanyCompetitorFile::GetActiveCompanyCompetitorCount() const {
|
||||
return m_iActiveCompanyCompetitorCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 &CCompanyCompetitorFile::GetRecord(TIdent index) const {
|
||||
return (*m_dataFile)[(int)(index % m_dataFile->size())];
|
||||
}
|
||||
107
external/duckdb/third_party/tpce-tool/input/CompanyDataFileRecord.cpp
vendored
Normal file
107
external/duckdb/third_party/tpce-tool/input/CompanyDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Doug Johnson
|
||||
*/
|
||||
|
||||
#include "input/CompanyDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib> // for atoi, atof
|
||||
// #include <string> // C++11 for stoi, stod
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
CompanyDataFileRecord::CompanyDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
co_id = std::atoi(fields[0].c_str());
|
||||
// co_id = std::stoi(fields[0]); // C++11
|
||||
|
||||
DFRStringInit(fields[1], co_st_id, co_st_idCStr, maxCo_st_idLen);
|
||||
|
||||
DFRStringInit(fields[2], co_name, co_nameCStr, maxCo_nameLen);
|
||||
|
||||
DFRStringInit(fields[3], co_in_id, co_in_idCStr, maxCo_in_idLen);
|
||||
|
||||
DFRStringInit(fields[4], co_desc, co_descCStr, maxCo_descLen);
|
||||
}
|
||||
|
||||
TIdent CompanyDataFileRecord::CO_ID() const {
|
||||
return co_id;
|
||||
}
|
||||
|
||||
const std::string &CompanyDataFileRecord::CO_ST_ID() const {
|
||||
return co_st_id;
|
||||
}
|
||||
|
||||
const char *CompanyDataFileRecord::CO_ST_ID_CSTR() const {
|
||||
return co_st_idCStr;
|
||||
}
|
||||
|
||||
const std::string &CompanyDataFileRecord::CO_NAME() const {
|
||||
return co_name;
|
||||
}
|
||||
|
||||
const char *CompanyDataFileRecord::CO_NAME_CSTR() const {
|
||||
return co_nameCStr;
|
||||
}
|
||||
|
||||
const std::string &CompanyDataFileRecord::CO_IN_ID() const {
|
||||
return co_in_id;
|
||||
}
|
||||
|
||||
const char *CompanyDataFileRecord::CO_IN_ID_CSTR() const {
|
||||
return co_in_idCStr;
|
||||
}
|
||||
|
||||
const std::string &CompanyDataFileRecord::CO_DESC() const {
|
||||
return co_desc;
|
||||
}
|
||||
|
||||
const char *CompanyDataFileRecord::CO_DESC_CSTR() const {
|
||||
return co_descCStr;
|
||||
}
|
||||
|
||||
std::string CompanyDataFileRecord::ToString(char fieldSeparator) const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
std::ostringstream msg;
|
||||
msg << CO_ID() << fieldSeparator << CO_ST_ID() << fieldSeparator << CO_NAME() << fieldSeparator << CO_IN_ID()
|
||||
<< fieldSeparator << CO_DESC();
|
||||
return msg.str();
|
||||
}
|
||||
190
external/duckdb/third_party/tpce-tool/input/CompanyFile.cpp
vendored
Normal file
190
external/duckdb/third_party/tpce-tool/input/CompanyFile.cpp
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "input/CompanyFile.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#include "utilities/MiscConsts.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
/*
|
||||
* 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::CCompanyFile(const CompanyDataFile_t &dataFile, TIdent iConfiguredCustomerCount,
|
||||
TIdent iActiveCustomerCount)
|
||||
: m_dataFile(&dataFile), m_iConfiguredCompanyCount(CalculateCompanyCount(iConfiguredCustomerCount)),
|
||||
m_iActiveCompanyCount(CalculateCompanyCount(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 CCompanyFile::CalculateCompanyCount(TIdent iCustomerCount) const {
|
||||
return iCustomerCount / iDefaultLoadUnitSize * iOneLoadUnitCompanyCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the first company id (0-based) for the specified customer id.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* IN iStartFromCustomer - customer id
|
||||
*
|
||||
* RETURNS:
|
||||
* company competitor id.
|
||||
*/
|
||||
TIdent CCompanyFile::CalculateStartFromCompany(TIdent iStartFromCustomer) const {
|
||||
return iStartFromCustomer / iDefaultLoadUnitSize * iOneLoadUnitCompanyCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 CCompanyFile::CreateName(TIdent iIndex, // row number
|
||||
char *szOutput, // output buffer
|
||||
size_t iOutputLen) // size of the output buffer
|
||||
const {
|
||||
TIdent iFileIndex = iIndex % m_dataFile->size();
|
||||
TIdent iAdd = iIndex / m_dataFile->size();
|
||||
|
||||
if (iAdd > 0) {
|
||||
snprintf(szOutput, iOutputLen, "%s #%" PRId64, GetRecord(iFileIndex).CO_NAME_CSTR(), iAdd);
|
||||
} else {
|
||||
strncpy(szOutput, GetRecord(iFileIndex).CO_NAME_CSTR(), iOutputLen);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 CCompanyFile::GetCompanyId(TIdent iIndex) const {
|
||||
// Index wraps around every 5000 companies.
|
||||
//
|
||||
return (*m_dataFile)[(int)(iIndex % m_dataFile->size())].CO_ID() + iTIdentShift +
|
||||
iIndex / m_dataFile->size() * m_dataFile->size();
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the number of companies in the database for
|
||||
* the configured number of customers.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* none.
|
||||
*
|
||||
* RETURNS:
|
||||
* number of rows in the file.
|
||||
*/
|
||||
TIdent CCompanyFile::GetSize() const {
|
||||
return m_iConfiguredCompanyCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the number of companies in the database for
|
||||
* the configured number of customers.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* none.
|
||||
*
|
||||
* RETURNS:
|
||||
* configured company count.
|
||||
*/
|
||||
TIdent CCompanyFile::GetConfiguredCompanyCount() const {
|
||||
return m_iConfiguredCompanyCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the number of companies in the database for
|
||||
* the active number of customers.
|
||||
*
|
||||
* PARAMETERS:
|
||||
* none.
|
||||
*
|
||||
* RETURNS:
|
||||
* active company count.
|
||||
*/
|
||||
TIdent CCompanyFile::GetActiveCompanyCount() const {
|
||||
return m_iActiveCompanyCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 &CCompanyFile::GetRecord(TIdent index) const {
|
||||
return (*m_dataFile)[(int)(index % m_dataFile->size())];
|
||||
}
|
||||
64
external/duckdb/third_party/tpce-tool/input/CompanySPRateDataFileRecord.cpp
vendored
Normal file
64
external/duckdb/third_party/tpce-tool/input/CompanySPRateDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 "input/CompanySPRateDataFileRecord.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
CompanySPRateDataFileRecord::CompanySPRateDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], co_sp_rate, co_sp_rateCStr, maxCo_sp_rateLen);
|
||||
}
|
||||
|
||||
const std::string &CompanySPRateDataFileRecord::CO_SP_RATE() const {
|
||||
return co_sp_rate;
|
||||
}
|
||||
|
||||
const char *CompanySPRateDataFileRecord::CO_SP_RATE_CSTR() const {
|
||||
return co_sp_rateCStr;
|
||||
}
|
||||
|
||||
std::string CompanySPRateDataFileRecord::ToString() const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
return CO_SP_RATE();
|
||||
}
|
||||
551
external/duckdb/third_party/tpce-tool/input/DataFileManager.cpp
vendored
Normal file
551
external/duckdb/third_party/tpce-tool/input/DataFileManager.cpp
vendored
Normal file
@@ -0,0 +1,551 @@
|
||||
/*
|
||||
* 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 "input/DataFileManager.h"
|
||||
#include "input/tpce_flat_input.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdexcept>
|
||||
|
||||
//#include "utilities/MiscConsts.h"
|
||||
#include "input/TextFileSplitter.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
// Centralized clean up of any allocated resources.
|
||||
void DataFileManager::CleanUp() {
|
||||
// Clean up any/all data files.
|
||||
if (areaCodeDataFile) {
|
||||
delete areaCodeDataFile;
|
||||
}
|
||||
if (chargeDataFile) {
|
||||
delete chargeDataFile;
|
||||
}
|
||||
if (commissionRateDataFile) {
|
||||
delete commissionRateDataFile;
|
||||
}
|
||||
if (companyCompetitorDataFile) {
|
||||
delete companyCompetitorDataFile;
|
||||
}
|
||||
if (companyDataFile) {
|
||||
delete companyDataFile;
|
||||
}
|
||||
if (companySPRateDataFile) {
|
||||
delete companySPRateDataFile;
|
||||
}
|
||||
if (exchangeDataFile) {
|
||||
delete exchangeDataFile;
|
||||
}
|
||||
if (femaleFirstNameDataFile) {
|
||||
delete femaleFirstNameDataFile;
|
||||
}
|
||||
if (industryDataFile) {
|
||||
delete industryDataFile;
|
||||
}
|
||||
if (lastNameDataFile) {
|
||||
delete lastNameDataFile;
|
||||
}
|
||||
if (maleFirstNameDataFile) {
|
||||
delete maleFirstNameDataFile;
|
||||
}
|
||||
if (newsDataFile) {
|
||||
delete newsDataFile;
|
||||
}
|
||||
if (nonTaxableAccountNameDataFile) {
|
||||
delete nonTaxableAccountNameDataFile;
|
||||
}
|
||||
if (sectorDataFile) {
|
||||
delete sectorDataFile;
|
||||
}
|
||||
if (securityDataFile) {
|
||||
delete securityDataFile;
|
||||
}
|
||||
if (statusTypeDataFile) {
|
||||
delete statusTypeDataFile;
|
||||
}
|
||||
if (streetNameDataFile) {
|
||||
delete streetNameDataFile;
|
||||
}
|
||||
if (streetSuffixDataFile) {
|
||||
delete streetSuffixDataFile;
|
||||
}
|
||||
if (taxableAccountNameDataFile) {
|
||||
delete taxableAccountNameDataFile;
|
||||
}
|
||||
if (taxRateCountryDataFile) {
|
||||
delete taxRateCountryDataFile;
|
||||
}
|
||||
if (taxRateDivisionDataFile) {
|
||||
delete taxRateDivisionDataFile;
|
||||
}
|
||||
if (tradeTypeDataFile) {
|
||||
delete tradeTypeDataFile;
|
||||
}
|
||||
if (zipCodeDataFile) {
|
||||
delete zipCodeDataFile;
|
||||
}
|
||||
|
||||
// Clean up any/all file abstractions.
|
||||
if (companyCompetitorFile) {
|
||||
delete companyCompetitorFile;
|
||||
}
|
||||
if (companyFile) {
|
||||
delete companyFile;
|
||||
}
|
||||
if (securityFile) {
|
||||
delete securityFile;
|
||||
}
|
||||
if (taxRateFile) {
|
||||
delete taxRateFile;
|
||||
}
|
||||
}
|
||||
|
||||
DataFileManager::DataFileManager(TIdent configuredCustomerCount, TIdent activeCustomerCount)
|
||||
: configuredCustomers(configuredCustomerCount), activeCustomers(activeCustomerCount), areaCodeDataFile(0),
|
||||
chargeDataFile(0), commissionRateDataFile(0), companyCompetitorDataFile(0), companyDataFile(0),
|
||||
companySPRateDataFile(0), exchangeDataFile(0), femaleFirstNameDataFile(0), industryDataFile(0),
|
||||
lastNameDataFile(0), maleFirstNameDataFile(0), newsDataFile(0), nonTaxableAccountNameDataFile(0),
|
||||
sectorDataFile(0), securityDataFile(0), statusTypeDataFile(0), streetNameDataFile(0), streetSuffixDataFile(0),
|
||||
taxableAccountNameDataFile(0), taxRateCountryDataFile(0), taxRateDivisionDataFile(0), tradeTypeDataFile(0),
|
||||
zipCodeDataFile(0), companyCompetitorFile(0), companyFile(0), securityFile(0), taxRateFile(0) {
|
||||
|
||||
// WARNING: This code is "brittle" since it is highly dependant on
|
||||
// the enum definition.
|
||||
for (int fileType = AREA_CODE_DATA_FILE; fileType <= ZIPCODE_DATA_FILE; ++fileType) {
|
||||
loadFile((DataFileType)fileType);
|
||||
}
|
||||
}
|
||||
|
||||
DataFileManager::~DataFileManager() {
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
// Load a file using an istream.
|
||||
void DataFileManager::loadFile(std::istream &source, DataFileType fileType) {
|
||||
switch (fileType) {
|
||||
case AREA_CODE_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, AreaCodeDataFile_t>(source, &areaCodeDataFile);
|
||||
break;
|
||||
case CHARGE_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, ChargeDataFile_t>(source, &chargeDataFile);
|
||||
break;
|
||||
case COMMISSION_RATE_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, CommissionRateDataFile_t>(source, &commissionRateDataFile);
|
||||
break;
|
||||
case COMPANY_COMPETITOR_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, CompanyCompetitorDataFile_t>(source, &companyCompetitorDataFile);
|
||||
break;
|
||||
case COMPANY_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, CompanyDataFile_t>(source, &companyDataFile);
|
||||
break;
|
||||
case COMPANY_SP_RATE_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, CompanySPRateDataFile_t>(source, &companySPRateDataFile);
|
||||
break;
|
||||
case EXCHANGE_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, ExchangeDataFile_t>(source, &exchangeDataFile);
|
||||
break;
|
||||
case FEMALE_FIRST_NAME_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, FemaleFirstNameDataFile_t>(source, &femaleFirstNameDataFile);
|
||||
break;
|
||||
case INDUSTRY_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, IndustryDataFile_t>(source, &industryDataFile);
|
||||
break;
|
||||
case LAST_NAME_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, LastNameDataFile_t>(source, &lastNameDataFile);
|
||||
break;
|
||||
case MALE_FIRST_NAME_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, MaleFirstNameDataFile_t>(source, &maleFirstNameDataFile);
|
||||
break;
|
||||
case NEWS_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, NewsDataFile_t>(source, &newsDataFile);
|
||||
break;
|
||||
case NON_TAXABLE_ACCOUNT_NAME_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, NonTaxableAccountNameDataFile_t>(source,
|
||||
&nonTaxableAccountNameDataFile);
|
||||
break;
|
||||
case SECTOR_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, SectorDataFile_t>(source, §orDataFile);
|
||||
break;
|
||||
case SECURITY_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, SecurityDataFile_t>(source, &securityDataFile);
|
||||
break;
|
||||
case STATUS_TYPE_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, StatusTypeDataFile_t>(source, &statusTypeDataFile);
|
||||
break;
|
||||
case STREET_NAME_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, StreetNameDataFile_t>(source, &streetNameDataFile);
|
||||
break;
|
||||
case STREET_SUFFIX_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, StreetSuffixDataFile_t>(source, &streetSuffixDataFile);
|
||||
break;
|
||||
case TAXABLE_ACCOUNT_NAME_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, TaxableAccountNameDataFile_t>(source, &taxableAccountNameDataFile);
|
||||
break;
|
||||
case TAX_RATE_COUNTRY_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, TaxRateCountryDataFile_t>(source, &taxRateCountryDataFile);
|
||||
break;
|
||||
case TAX_RATE_DIVISION_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, TaxRateDivisionDataFile_t>(source, &taxRateDivisionDataFile);
|
||||
break;
|
||||
case TRADE_TYPE_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, TradeTypeDataFile_t>(source, &tradeTypeDataFile);
|
||||
break;
|
||||
case ZIPCODE_DATA_FILE:
|
||||
loadFile<std::istream &, StreamSplitter, ZipCodeDataFile_t>(source, &zipCodeDataFile);
|
||||
break;
|
||||
default:
|
||||
// Should never get here.
|
||||
throw std::logic_error("Attempt to load by istream an unrecognized data file type.");
|
||||
}
|
||||
}
|
||||
|
||||
// Load a file using a file type.
|
||||
void DataFileManager::loadFile(DataFileType fileType) {
|
||||
// Under the covers, call the pseudo-const overload.
|
||||
const_cast<const DataFileManager *>(this)->loadFile(fileType);
|
||||
}
|
||||
|
||||
// Helper method for lazy loading (hence logically const) by file type.
|
||||
void DataFileManager::loadFile(DataFileType fileType) const {
|
||||
// Set up the appropriate file name.
|
||||
switch (fileType) {
|
||||
case AREA_CODE_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, AreaCodeDataFile_t>(AreaCodeConstantString, &areaCodeDataFile);
|
||||
break;
|
||||
case CHARGE_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, ChargeDataFile_t>(ChargeConstantString, &chargeDataFile);
|
||||
break;
|
||||
case COMMISSION_RATE_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, CommissionRateDataFile_t>(CommissionRateConstantString,
|
||||
&commissionRateDataFile);
|
||||
break;
|
||||
case COMPANY_COMPETITOR_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, CompanyCompetitorDataFile_t>(CompanyCompetitorConstantString,
|
||||
&companyCompetitorDataFile);
|
||||
break;
|
||||
case COMPANY_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, CompanyDataFile_t>(CompanyConstantString, &companyDataFile);
|
||||
break;
|
||||
case COMPANY_SP_RATE_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, CompanySPRateDataFile_t>(CompanySPRateConstantString,
|
||||
&companySPRateDataFile);
|
||||
break;
|
||||
case EXCHANGE_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, ExchangeDataFile_t>(ExchangeConstantString, &exchangeDataFile);
|
||||
break;
|
||||
case FEMALE_FIRST_NAME_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, FemaleFirstNameDataFile_t>(FemaleFirstNameConstantString,
|
||||
&femaleFirstNameDataFile);
|
||||
break;
|
||||
case INDUSTRY_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, IndustryDataFile_t>(IndustryConstantString, &industryDataFile);
|
||||
break;
|
||||
case LAST_NAME_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, LastNameDataFile_t>(LastNameConstantString, &lastNameDataFile);
|
||||
break;
|
||||
case MALE_FIRST_NAME_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, MaleFirstNameDataFile_t>(MaleFirstNameConstantString,
|
||||
&maleFirstNameDataFile);
|
||||
break;
|
||||
case NEWS_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, NewsDataFile_t>(LastNameConstantString, &newsDataFile);
|
||||
break;
|
||||
case NON_TAXABLE_ACCOUNT_NAME_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, NonTaxableAccountNameDataFile_t>(NonTaxableAccountNameConstantString,
|
||||
&nonTaxableAccountNameDataFile);
|
||||
break;
|
||||
case SECTOR_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, SectorDataFile_t>(SectorConstantString, §orDataFile);
|
||||
break;
|
||||
case SECURITY_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, SecurityDataFile_t>(SecurityConstantString, &securityDataFile);
|
||||
break;
|
||||
case STATUS_TYPE_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, StatusTypeDataFile_t>(StatusTypeConstantString, &statusTypeDataFile);
|
||||
break;
|
||||
case STREET_NAME_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, StreetNameDataFile_t>(StreetNameConstantString, &streetNameDataFile);
|
||||
break;
|
||||
case STREET_SUFFIX_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, StreetSuffixDataFile_t>(StreetSuffixConstantString,
|
||||
&streetSuffixDataFile);
|
||||
break;
|
||||
case TAXABLE_ACCOUNT_NAME_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, TaxableAccountNameDataFile_t>(TaxableAccountNameConstantString,
|
||||
&taxableAccountNameDataFile);
|
||||
break;
|
||||
case TAX_RATE_COUNTRY_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, TaxRateCountryDataFile_t>(TaxRatesCountryConstantString,
|
||||
&taxRateCountryDataFile);
|
||||
break;
|
||||
case TAX_RATE_DIVISION_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, TaxRateDivisionDataFile_t>(TaxRatesDivisionConstantString,
|
||||
&taxRateDivisionDataFile);
|
||||
break;
|
||||
case TRADE_TYPE_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, TradeTypeDataFile_t>(TradeTypeConstantString, &tradeTypeDataFile);
|
||||
break;
|
||||
case ZIPCODE_DATA_FILE:
|
||||
loadFile<std::string &, TextFileSplitter, ZipCodeDataFile_t>(ZipCodeConstantString, &zipCodeDataFile);
|
||||
break;
|
||||
default:
|
||||
// Should never get here.
|
||||
assert(!"Attempt to load an unrecognized data file type.");
|
||||
}
|
||||
}
|
||||
|
||||
// Accessors for files.
|
||||
const AreaCodeDataFile_t &DataFileManager::AreaCodeDataFile() const {
|
||||
if (!areaCodeDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(AREA_CODE_DATA_FILE);
|
||||
}
|
||||
return *areaCodeDataFile;
|
||||
}
|
||||
|
||||
const ChargeDataFile_t &DataFileManager::ChargeDataFile() const {
|
||||
if (!chargeDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(CHARGE_DATA_FILE);
|
||||
}
|
||||
return *chargeDataFile;
|
||||
}
|
||||
|
||||
const CommissionRateDataFile_t &DataFileManager::CommissionRateDataFile() const {
|
||||
if (!commissionRateDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(COMMISSION_RATE_DATA_FILE);
|
||||
}
|
||||
return *commissionRateDataFile;
|
||||
}
|
||||
|
||||
const CompanyCompetitorDataFile_t &DataFileManager::CompanyCompetitorDataFile() const {
|
||||
if (!companyCompetitorDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(COMPANY_COMPETITOR_DATA_FILE);
|
||||
}
|
||||
return *companyCompetitorDataFile;
|
||||
}
|
||||
|
||||
const CompanyDataFile_t &DataFileManager::CompanyDataFile() const {
|
||||
if (!companyDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(COMPANY_DATA_FILE);
|
||||
}
|
||||
return *companyDataFile;
|
||||
}
|
||||
|
||||
const CompanySPRateDataFile_t &DataFileManager::CompanySPRateDataFile() const {
|
||||
if (!companySPRateDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(COMPANY_SP_RATE_DATA_FILE);
|
||||
}
|
||||
return *companySPRateDataFile;
|
||||
}
|
||||
|
||||
const ExchangeDataFile_t &DataFileManager::ExchangeDataFile() const {
|
||||
if (!exchangeDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(EXCHANGE_DATA_FILE);
|
||||
}
|
||||
return *exchangeDataFile;
|
||||
}
|
||||
|
||||
const FemaleFirstNameDataFile_t &DataFileManager::FemaleFirstNameDataFile() const {
|
||||
if (!femaleFirstNameDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(FEMALE_FIRST_NAME_DATA_FILE);
|
||||
}
|
||||
return *femaleFirstNameDataFile;
|
||||
}
|
||||
|
||||
const IndustryDataFile_t &DataFileManager::IndustryDataFile() const {
|
||||
if (!industryDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(INDUSTRY_DATA_FILE);
|
||||
}
|
||||
return *industryDataFile;
|
||||
}
|
||||
|
||||
const LastNameDataFile_t &DataFileManager::LastNameDataFile() const {
|
||||
if (!lastNameDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(LAST_NAME_DATA_FILE);
|
||||
}
|
||||
return *lastNameDataFile;
|
||||
}
|
||||
|
||||
const MaleFirstNameDataFile_t &DataFileManager::MaleFirstNameDataFile() const {
|
||||
if (!maleFirstNameDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(MALE_FIRST_NAME_DATA_FILE);
|
||||
}
|
||||
return *maleFirstNameDataFile;
|
||||
}
|
||||
|
||||
const NewsDataFile_t &DataFileManager::NewsDataFile() const {
|
||||
if (!newsDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(NEWS_DATA_FILE);
|
||||
}
|
||||
return *newsDataFile;
|
||||
}
|
||||
|
||||
const NonTaxableAccountNameDataFile_t &DataFileManager::NonTaxableAccountNameDataFile() const {
|
||||
if (!nonTaxableAccountNameDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(NON_TAXABLE_ACCOUNT_NAME_DATA_FILE);
|
||||
}
|
||||
return *nonTaxableAccountNameDataFile;
|
||||
}
|
||||
|
||||
const SectorDataFile_t &DataFileManager::SectorDataFile() const {
|
||||
if (!sectorDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(SECTOR_DATA_FILE);
|
||||
}
|
||||
return *sectorDataFile;
|
||||
}
|
||||
|
||||
const SecurityDataFile_t &DataFileManager::SecurityDataFile() const {
|
||||
if (!securityDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(SECURITY_DATA_FILE);
|
||||
}
|
||||
return *securityDataFile;
|
||||
}
|
||||
|
||||
const StatusTypeDataFile_t &DataFileManager::StatusTypeDataFile() const {
|
||||
if (!statusTypeDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(STATUS_TYPE_DATA_FILE);
|
||||
}
|
||||
return *statusTypeDataFile;
|
||||
}
|
||||
|
||||
const StreetNameDataFile_t &DataFileManager::StreetNameDataFile() const {
|
||||
if (!streetNameDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(STREET_NAME_DATA_FILE);
|
||||
}
|
||||
return *streetNameDataFile;
|
||||
}
|
||||
|
||||
const StreetSuffixDataFile_t &DataFileManager::StreetSuffixDataFile() const {
|
||||
if (!streetSuffixDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(STREET_SUFFIX_DATA_FILE);
|
||||
}
|
||||
return *streetSuffixDataFile;
|
||||
}
|
||||
|
||||
const TaxableAccountNameDataFile_t &DataFileManager::TaxableAccountNameDataFile() const {
|
||||
if (!taxableAccountNameDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(TAXABLE_ACCOUNT_NAME_DATA_FILE);
|
||||
}
|
||||
return *taxableAccountNameDataFile;
|
||||
}
|
||||
|
||||
const TaxRateCountryDataFile_t &DataFileManager::TaxRateCountryDataFile() const {
|
||||
if (!taxRateCountryDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(TAX_RATE_COUNTRY_DATA_FILE);
|
||||
}
|
||||
return *taxRateCountryDataFile;
|
||||
}
|
||||
|
||||
const TaxRateDivisionDataFile_t &DataFileManager::TaxRateDivisionDataFile() const {
|
||||
if (!taxRateDivisionDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(TAX_RATE_DIVISION_DATA_FILE);
|
||||
}
|
||||
return *taxRateDivisionDataFile;
|
||||
}
|
||||
|
||||
const TradeTypeDataFile_t &DataFileManager::TradeTypeDataFile() const {
|
||||
if (!tradeTypeDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(TRADE_TYPE_DATA_FILE);
|
||||
}
|
||||
return *tradeTypeDataFile;
|
||||
}
|
||||
|
||||
const ZipCodeDataFile_t &DataFileManager::ZipCodeDataFile() const {
|
||||
if (!zipCodeDataFile) {
|
||||
// Need to load the file.
|
||||
loadFile(ZIPCODE_DATA_FILE);
|
||||
}
|
||||
return *zipCodeDataFile;
|
||||
}
|
||||
|
||||
const CCompanyCompetitorFile &DataFileManager::CompanyCompetitorFile() const {
|
||||
if (!companyCompetitorFile) {
|
||||
// Need to create the "file". Fully qualify constructor to distinquish
|
||||
// from this method.
|
||||
companyCompetitorFile = new CCompanyCompetitorFile(CompanyCompetitorDataFile(), configuredCustomers,
|
||||
activeCustomers, CompanyDataFile().size());
|
||||
}
|
||||
return *companyCompetitorFile;
|
||||
}
|
||||
|
||||
const CCompanyFile &DataFileManager::CompanyFile() const {
|
||||
if (!companyFile) {
|
||||
// Need to create the "file". Fully qualify constructor to distinquish
|
||||
// from this method.
|
||||
companyFile = new CCompanyFile(CompanyDataFile(), configuredCustomers, activeCustomers);
|
||||
}
|
||||
return *companyFile;
|
||||
}
|
||||
|
||||
const CSecurityFile &DataFileManager::SecurityFile() const {
|
||||
if (!securityFile) {
|
||||
// Need to create the "file". Fully qualify constructor to distinquish
|
||||
// from this method.
|
||||
securityFile =
|
||||
new CSecurityFile(SecurityDataFile(), configuredCustomers, activeCustomers, CompanyDataFile().size());
|
||||
}
|
||||
return *securityFile;
|
||||
}
|
||||
|
||||
const CTaxRateFile &DataFileManager::TaxRateFile() const {
|
||||
if (!taxRateFile) {
|
||||
// Need to create the "file". Fully qualify constructor to distinquish
|
||||
// from this method.
|
||||
taxRateFile = new CTaxRateFile(TaxRateCountryDataFile(), TaxRateDivisionDataFile());
|
||||
}
|
||||
return *taxRateFile;
|
||||
}
|
||||
112
external/duckdb/third_party/tpce-tool/input/ExchangeDataFileRecord.cpp
vendored
Normal file
112
external/duckdb/third_party/tpce-tool/input/ExchangeDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Doug Johnson
|
||||
*/
|
||||
|
||||
#include "input/ExchangeDataFileRecord.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib> // for atoi, atof
|
||||
// #include <string> // C++11 for stoi, stod
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
ExchangeDataFileRecord::ExchangeDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], ex_id, ex_idCStr, maxEx_idLen);
|
||||
|
||||
DFRStringInit(fields[1], ex_name, ex_nameCStr, maxEx_nameLen);
|
||||
|
||||
ex_open = std::atoi(fields[2].c_str());
|
||||
// ex_open = std::stoi(fields[2]); // C++11
|
||||
ex_close = std::atoi(fields[3].c_str());
|
||||
// ex_close = std::stoi(fields[3]); // C++11
|
||||
|
||||
DFRStringInit(fields[4], ex_desc, ex_descCStr, maxEx_descLen);
|
||||
|
||||
ex_ad_id = std::atoi(fields[5].c_str());
|
||||
// ex_ad_id = std::stoi(fields[5]); // C++11
|
||||
}
|
||||
|
||||
const std::string &ExchangeDataFileRecord::EX_ID() const {
|
||||
return ex_id;
|
||||
}
|
||||
|
||||
const char *ExchangeDataFileRecord::EX_ID_CSTR() const {
|
||||
return ex_idCStr;
|
||||
}
|
||||
|
||||
const std::string &ExchangeDataFileRecord::EX_NAME() const {
|
||||
return ex_name;
|
||||
}
|
||||
|
||||
const char *ExchangeDataFileRecord::EX_NAME_CSTR() const {
|
||||
return ex_nameCStr;
|
||||
}
|
||||
|
||||
int ExchangeDataFileRecord::EX_OPEN() const {
|
||||
return ex_open;
|
||||
}
|
||||
|
||||
int ExchangeDataFileRecord::EX_CLOSE() const {
|
||||
return ex_close;
|
||||
}
|
||||
|
||||
const std::string &ExchangeDataFileRecord::EX_DESC() const {
|
||||
return ex_desc;
|
||||
}
|
||||
|
||||
const char *ExchangeDataFileRecord::EX_DESC_CSTR() const {
|
||||
return ex_descCStr;
|
||||
}
|
||||
|
||||
TIdent ExchangeDataFileRecord::EX_AD_ID() const {
|
||||
return ex_ad_id;
|
||||
}
|
||||
|
||||
std::string ExchangeDataFileRecord::ToString(char fieldSeparator) const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
std::ostringstream msg;
|
||||
msg << EX_ID() << fieldSeparator << EX_NAME() << fieldSeparator << std::setfill('0') << std::setw(4) << EX_OPEN()
|
||||
<< fieldSeparator << std::setfill('0') << std::setw(4) << EX_CLOSE() << fieldSeparator << EX_DESC()
|
||||
<< fieldSeparator << EX_AD_ID();
|
||||
return msg.str();
|
||||
}
|
||||
65
external/duckdb/third_party/tpce-tool/input/FemaleFirstNameDataFileRecord.cpp
vendored
Normal file
65
external/duckdb/third_party/tpce-tool/input/FemaleFirstNameDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 "input/FemaleFirstNameDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
FemaleFirstNameDataFileRecord::FemaleFirstNameDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], name, nameCStr, maxNameLen);
|
||||
}
|
||||
|
||||
const std::string &FemaleFirstNameDataFileRecord::NAME() const {
|
||||
return name;
|
||||
}
|
||||
|
||||
const char *FemaleFirstNameDataFileRecord::NAME_CSTR() const {
|
||||
return nameCStr;
|
||||
}
|
||||
|
||||
std::string FemaleFirstNameDataFileRecord::ToString() const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
return NAME();
|
||||
}
|
||||
87
external/duckdb/third_party/tpce-tool/input/IndustryDataFileRecord.cpp
vendored
Normal file
87
external/duckdb/third_party/tpce-tool/input/IndustryDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Doug Johnson
|
||||
*/
|
||||
|
||||
#include "input/IndustryDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
IndustryDataFileRecord::IndustryDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], in_id, in_idCStr, maxIn_idLen);
|
||||
|
||||
DFRStringInit(fields[1], in_name, in_nameCStr, maxIn_nameLen);
|
||||
|
||||
DFRStringInit(fields[2], in_sc_id, in_sc_idCStr, maxIn_sc_idLen);
|
||||
}
|
||||
|
||||
const std::string &IndustryDataFileRecord::IN_ID() const {
|
||||
return in_id;
|
||||
}
|
||||
|
||||
const char *IndustryDataFileRecord::IN_ID_CSTR() const {
|
||||
return in_idCStr;
|
||||
}
|
||||
|
||||
const std::string &IndustryDataFileRecord::IN_NAME() const {
|
||||
return in_name;
|
||||
}
|
||||
|
||||
const char *IndustryDataFileRecord::IN_NAME_CSTR() const {
|
||||
return in_nameCStr;
|
||||
}
|
||||
|
||||
const std::string &IndustryDataFileRecord::IN_SC_ID() const {
|
||||
return in_sc_id;
|
||||
}
|
||||
|
||||
const char *IndustryDataFileRecord::IN_SC_ID_CSTR() const {
|
||||
return in_sc_idCStr;
|
||||
}
|
||||
|
||||
std::string IndustryDataFileRecord::ToString(char fieldSeparator) const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
std::ostringstream msg;
|
||||
msg << IN_ID() << fieldSeparator << IN_NAME() << fieldSeparator << IN_SC_ID();
|
||||
return msg.str();
|
||||
}
|
||||
65
external/duckdb/third_party/tpce-tool/input/LastNameDataFileRecord.cpp
vendored
Normal file
65
external/duckdb/third_party/tpce-tool/input/LastNameDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 "input/LastNameDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
LastNameDataFileRecord::LastNameDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], name, nameCStr, maxNameLen);
|
||||
}
|
||||
|
||||
const std::string &LastNameDataFileRecord::NAME() const {
|
||||
return name;
|
||||
}
|
||||
|
||||
const char *LastNameDataFileRecord::NAME_CSTR() const {
|
||||
return nameCStr;
|
||||
}
|
||||
|
||||
std::string LastNameDataFileRecord::ToString() const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
return NAME();
|
||||
}
|
||||
65
external/duckdb/third_party/tpce-tool/input/MaleFirstNameDataFileRecord.cpp
vendored
Normal file
65
external/duckdb/third_party/tpce-tool/input/MaleFirstNameDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 "input/MaleFirstNameDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
MaleFirstNameDataFileRecord::MaleFirstNameDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], name, nameCStr, maxNameLen);
|
||||
}
|
||||
|
||||
const std::string &MaleFirstNameDataFileRecord::NAME() const {
|
||||
return name;
|
||||
}
|
||||
|
||||
const char *MaleFirstNameDataFileRecord::NAME_CSTR() const {
|
||||
return nameCStr;
|
||||
}
|
||||
|
||||
std::string MaleFirstNameDataFileRecord::ToString() const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
return NAME();
|
||||
}
|
||||
65
external/duckdb/third_party/tpce-tool/input/NewsDataFileRecord.cpp
vendored
Normal file
65
external/duckdb/third_party/tpce-tool/input/NewsDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 "input/NewsDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
NewsDataFileRecord::NewsDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], word, wordCStr, maxWordLen);
|
||||
}
|
||||
|
||||
const std::string &NewsDataFileRecord::WORD() const {
|
||||
return word;
|
||||
}
|
||||
|
||||
const char *NewsDataFileRecord::WORD_CSTR() const {
|
||||
return wordCStr;
|
||||
}
|
||||
|
||||
std::string NewsDataFileRecord::ToString() const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
return WORD();
|
||||
}
|
||||
65
external/duckdb/third_party/tpce-tool/input/NonTaxableAccountNameDataFileRecord.cpp
vendored
Normal file
65
external/duckdb/third_party/tpce-tool/input/NonTaxableAccountNameDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 "input/NonTaxableAccountNameDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
NonTaxableAccountNameDataFileRecord::NonTaxableAccountNameDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], name, nameCStr, maxNameLen);
|
||||
}
|
||||
|
||||
const std::string &NonTaxableAccountNameDataFileRecord::NAME() const {
|
||||
return name;
|
||||
}
|
||||
|
||||
const char *NonTaxableAccountNameDataFileRecord::NAME_CSTR() const {
|
||||
return nameCStr;
|
||||
}
|
||||
|
||||
std::string NonTaxableAccountNameDataFileRecord::ToString() const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
return NAME();
|
||||
}
|
||||
77
external/duckdb/third_party/tpce-tool/input/SectorDataFileRecord.cpp
vendored
Normal file
77
external/duckdb/third_party/tpce-tool/input/SectorDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Doug Johnson
|
||||
*/
|
||||
|
||||
#include "input/SectorDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
SectorDataFileRecord::SectorDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], sc_id, sc_idCStr, maxSc_idLen);
|
||||
|
||||
DFRStringInit(fields[1], sc_name, sc_nameCStr, maxSc_nameLen);
|
||||
}
|
||||
|
||||
const std::string &SectorDataFileRecord::SC_ID() const {
|
||||
return sc_id;
|
||||
}
|
||||
|
||||
const char *SectorDataFileRecord::SC_ID_CSTR() const {
|
||||
return sc_idCStr;
|
||||
}
|
||||
|
||||
const std::string &SectorDataFileRecord::SC_NAME() const {
|
||||
return sc_name;
|
||||
}
|
||||
|
||||
const char *SectorDataFileRecord::SC_NAME_CSTR() const {
|
||||
return sc_nameCStr;
|
||||
}
|
||||
|
||||
std::string SectorDataFileRecord::ToString(char fieldSeparator) const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
std::ostringstream msg;
|
||||
msg << SC_ID() << fieldSeparator << SC_NAME();
|
||||
return msg.str();
|
||||
}
|
||||
114
external/duckdb/third_party/tpce-tool/input/SecurityDataFileRecord.cpp
vendored
Normal file
114
external/duckdb/third_party/tpce-tool/input/SecurityDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* 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 "input/SecurityDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib> // for atoi
|
||||
// #include <string> // C++11 for stoi
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
SecurityDataFileRecord::SecurityDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
s_id = std::atoi(fields[0].c_str());
|
||||
// s_id = std::stoi(fields[0]); // C++11
|
||||
|
||||
DFRStringInit(fields[1], s_st_id, s_st_idCStr, maxS_st_idLen);
|
||||
|
||||
DFRStringInit(fields[2], s_symb, s_symbCStr, maxS_symbLen);
|
||||
|
||||
DFRStringInit(fields[3], s_issue, s_issueCStr, maxS_issueLen);
|
||||
|
||||
DFRStringInit(fields[4], s_ex_id, s_ex_idCStr, maxS_ex_idLen);
|
||||
|
||||
s_co_id = std::atoi(fields[5].c_str());
|
||||
// s_co_id = std::stoi(fields[5]); // C++11
|
||||
}
|
||||
|
||||
TIdent SecurityDataFileRecord::S_ID() const {
|
||||
return s_id;
|
||||
}
|
||||
|
||||
const std::string &SecurityDataFileRecord::S_ST_ID() const {
|
||||
return s_st_id;
|
||||
}
|
||||
|
||||
const char *SecurityDataFileRecord::S_ST_ID_CSTR() const {
|
||||
return s_st_idCStr;
|
||||
}
|
||||
|
||||
const std::string &SecurityDataFileRecord::S_SYMB() const {
|
||||
return s_symb;
|
||||
}
|
||||
|
||||
const char *SecurityDataFileRecord::S_SYMB_CSTR() const {
|
||||
return s_symbCStr;
|
||||
}
|
||||
|
||||
const std::string &SecurityDataFileRecord::S_ISSUE() const {
|
||||
return s_issue;
|
||||
}
|
||||
|
||||
const char *SecurityDataFileRecord::S_ISSUE_CSTR() const {
|
||||
return s_issueCStr;
|
||||
}
|
||||
|
||||
const std::string &SecurityDataFileRecord::S_EX_ID() const {
|
||||
return s_ex_id;
|
||||
}
|
||||
|
||||
const char *SecurityDataFileRecord::S_EX_ID_CSTR() const {
|
||||
return s_ex_idCStr;
|
||||
}
|
||||
|
||||
TIdent SecurityDataFileRecord::S_CO_ID() const {
|
||||
return s_co_id;
|
||||
}
|
||||
|
||||
std::string SecurityDataFileRecord::ToString(char fieldSeparator) const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
std::ostringstream msg;
|
||||
msg << S_ID() << fieldSeparator << S_ST_ID() << fieldSeparator << S_SYMB() << fieldSeparator << S_ISSUE()
|
||||
<< fieldSeparator << S_EX_ID() << fieldSeparator << S_CO_ID();
|
||||
return msg.str();
|
||||
}
|
||||
273
external/duckdb/third_party/tpce-tool/input/SecurityFile.cpp
vendored
Normal file
273
external/duckdb/third_party/tpce-tool/input/SecurityFile.cpp
vendored
Normal file
@@ -0,0 +1,273 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "input/SecurityFile.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "utilities/MiscConsts.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace TPCE;
|
||||
|
||||
namespace TPCE {
|
||||
// We use a small set of values for 26 raised to a power, so store them in
|
||||
// a constant array to save doing calls to pow( 26.0, ? )
|
||||
static const UINT Power26[] = {1, 26, 676, 17576, 456976, 11881376, 308915776};
|
||||
|
||||
// For index i > 0, this array holds the sum of 26^0 ... 26^(i-1)
|
||||
static const UINT64 Power26Sum[] = {0, 1, 27, 703, 18279, 475255, 12356631, 321272407, UINT64_CONST(8353082583)};
|
||||
|
||||
} // namespace TPCE
|
||||
|
||||
void CSecurityFile::CreateSuffix(TIdent Multiplier, char *pBuf, size_t BufSize) const {
|
||||
size_t CharCount(0);
|
||||
INT64 Offset(0);
|
||||
INT64 LCLIndex(0); // LowerCaseLetter array index
|
||||
|
||||
while ((UINT64)Multiplier >= Power26Sum[CharCount + 1]) {
|
||||
CharCount++;
|
||||
}
|
||||
|
||||
if (CharCount + 2 <= BufSize) // 1 extra for separator and 1 extra for terminating NULL
|
||||
{
|
||||
*pBuf = m_SUFFIX_SEPARATOR;
|
||||
pBuf++;
|
||||
// CharCount is the number of letters needed in the suffix
|
||||
// The base string is a string of 'a's of length CharCount
|
||||
// Find the offset from the base value represented by the string
|
||||
// of 'a's to the desired number, and modify the base string
|
||||
// accordingly.
|
||||
Offset = Multiplier - Power26Sum[CharCount];
|
||||
|
||||
while (CharCount > 0) {
|
||||
LCLIndex = Offset / Power26[CharCount - 1];
|
||||
*pBuf = LowerCaseLetters[LCLIndex];
|
||||
pBuf++;
|
||||
Offset -= (LCLIndex * Power26[CharCount - 1]);
|
||||
CharCount--;
|
||||
}
|
||||
*pBuf = '\0';
|
||||
} else {
|
||||
// Not enough room in the buffer
|
||||
CharCount = BufSize - 1;
|
||||
while (CharCount > 0) {
|
||||
*pBuf = m_SUFFIX_SEPARATOR;
|
||||
pBuf++;
|
||||
CharCount--;
|
||||
}
|
||||
*pBuf = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
INT64 CSecurityFile::ParseSuffix(const char *pSymbol) const {
|
||||
int CharCount(0);
|
||||
INT64 Multiplier(0);
|
||||
|
||||
CharCount = (int)strlen(pSymbol);
|
||||
|
||||
Multiplier = Power26Sum[CharCount];
|
||||
|
||||
while (CharCount > 0) {
|
||||
Multiplier += (INT64)Power26[CharCount - 1] * m_LowerCaseLetterToIntMap[*pSymbol];
|
||||
CharCount--;
|
||||
pSymbol++;
|
||||
}
|
||||
return (Multiplier);
|
||||
}
|
||||
|
||||
CSecurityFile::CSecurityFile(const SecurityDataFile_t &dataFile, TIdent iConfiguredCustomerCount,
|
||||
TIdent iActiveCustomerCount, UINT baseCompanyCount)
|
||||
: m_dataFile(&dataFile), m_iConfiguredSecurityCount(CalculateSecurityCount(iConfiguredCustomerCount)),
|
||||
m_iActiveSecurityCount(CalculateSecurityCount(iActiveCustomerCount)), m_iBaseCompanyCount(baseCompanyCount),
|
||||
m_SymbolToIdMapIsLoaded(false), m_SUFFIX_SEPARATOR('-') {
|
||||
}
|
||||
|
||||
// Calculate total security count for the specified number of customers.
|
||||
// Sort of a static method. Used in parallel generation of securities related
|
||||
// tables.
|
||||
//
|
||||
TIdent CSecurityFile::CalculateSecurityCount(TIdent iCustomerCount) const {
|
||||
return iCustomerCount / iDefaultLoadUnitSize * iOneLoadUnitSecurityCount;
|
||||
}
|
||||
|
||||
// Calculate the first security id (0-based) for the specified customer id
|
||||
//
|
||||
TIdent CSecurityFile::CalculateStartFromSecurity(TIdent iStartFromCustomer) const {
|
||||
return iStartFromCustomer / iDefaultLoadUnitSize * iOneLoadUnitSecurityCount;
|
||||
}
|
||||
|
||||
// Create security symbol with mod/div magic.
|
||||
//
|
||||
// This function is needed to scale unique security
|
||||
// symbols with the database size.
|
||||
//
|
||||
void CSecurityFile::CreateSymbol(TIdent iIndex, // row number
|
||||
char *szOutput, // output buffer
|
||||
size_t iOutputLen) // size of the output buffer (including null)
|
||||
const {
|
||||
TIdent iFileIndex = iIndex % m_dataFile->size();
|
||||
TIdent iAdd = iIndex / m_dataFile->size();
|
||||
size_t iNewLen;
|
||||
|
||||
// Load the base symbol
|
||||
strncpy(szOutput, GetRecord(iFileIndex).S_SYMB_CSTR(), iOutputLen);
|
||||
|
||||
szOutput[iOutputLen - 1] = '\0'; // Ensure NULL termination
|
||||
|
||||
// Add a suffix if needed
|
||||
if (iAdd > 0) {
|
||||
iNewLen = strlen(szOutput);
|
||||
CreateSuffix(iAdd, &szOutput[iNewLen], iOutputLen - iNewLen);
|
||||
}
|
||||
}
|
||||
|
||||
// Return company id for the specified row of the SECURITY table.
|
||||
// Index can exceed the size of the Security flat file.
|
||||
//
|
||||
TIdent CSecurityFile::GetCompanyId(TIdent iIndex) const {
|
||||
// Index wraps around every 6850 securities (5000 companies).
|
||||
//
|
||||
return (*m_dataFile)[(int)(iIndex % m_dataFile->size())].S_CO_ID() + iTIdentShift +
|
||||
iIndex / m_dataFile->size() * m_iBaseCompanyCount;
|
||||
}
|
||||
|
||||
TIdent CSecurityFile::GetCompanyIndex(TIdent Index) const {
|
||||
// Indices and Id's are offset by 1
|
||||
return (GetCompanyId(Index) - 1 - iTIdentShift);
|
||||
}
|
||||
|
||||
// Return the number of securities in the database for
|
||||
// a certain number of customers.
|
||||
//
|
||||
TIdent CSecurityFile::GetSize() const {
|
||||
return m_iConfiguredSecurityCount;
|
||||
}
|
||||
|
||||
// Return the number of securities in the database for
|
||||
// the configured number of customers.
|
||||
//
|
||||
TIdent CSecurityFile::GetConfiguredSecurityCount() const {
|
||||
return m_iConfiguredSecurityCount;
|
||||
}
|
||||
|
||||
// Return the number of securities in the database for
|
||||
// the active number of customers.
|
||||
//
|
||||
TIdent CSecurityFile::GetActiveSecurityCount() const {
|
||||
return m_iActiveSecurityCount;
|
||||
}
|
||||
|
||||
// Overload GetRecord to wrap around indices that
|
||||
// are larger than the flat file
|
||||
//
|
||||
const SecurityDataFileRecord &CSecurityFile::GetRecord(TIdent index) const {
|
||||
return (*m_dataFile)[(int)(index % m_dataFile->size())];
|
||||
}
|
||||
|
||||
// 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 CSecurityFile::LoadSymbolToIdMap(void) const {
|
||||
if (!m_SymbolToIdMapIsLoaded) {
|
||||
int ii;
|
||||
int limit = m_dataFile->size();
|
||||
|
||||
for (ii = 0; ii < limit; ii++) {
|
||||
string sSymbol((*m_dataFile)[ii].S_SYMB());
|
||||
m_SymbolToIdMap[sSymbol] = (*m_dataFile)[ii].S_ID();
|
||||
}
|
||||
m_SymbolToIdMapIsLoaded = true;
|
||||
|
||||
for (ii = 0; ii < MaxLowerCaseLetters; ii++) {
|
||||
m_LowerCaseLetterToIntMap[LowerCaseLetters[ii]] = ii;
|
||||
}
|
||||
}
|
||||
return (m_SymbolToIdMapIsLoaded);
|
||||
}
|
||||
|
||||
TIdent CSecurityFile::GetId(char *pSymbol) const {
|
||||
char *pSeparator(NULL);
|
||||
|
||||
if (!m_SymbolToIdMapIsLoaded) {
|
||||
LoadSymbolToIdMap();
|
||||
}
|
||||
if (NULL == (pSeparator = strchr(pSymbol, m_SUFFIX_SEPARATOR))) {
|
||||
// we're dealing with a base symbol
|
||||
string sSymbol(pSymbol);
|
||||
return (m_SymbolToIdMap[sSymbol]);
|
||||
} else {
|
||||
// we're dealing with an extended symbol
|
||||
char *pSuffix(NULL);
|
||||
TIdent BaseId(0);
|
||||
TIdent Multiplier(0);
|
||||
|
||||
string sSymbol(pSymbol, static_cast<size_t>(pSeparator - pSymbol));
|
||||
BaseId = m_SymbolToIdMap[sSymbol];
|
||||
|
||||
pSuffix = pSeparator + 1; // The suffix starts right after the separator character
|
||||
Multiplier = (int)ParseSuffix(pSuffix); // For now, suffix values fit in an int, cast ParseSuffix
|
||||
// to avoid compiler warning
|
||||
|
||||
return ((Multiplier * m_dataFile->size()) + BaseId);
|
||||
}
|
||||
}
|
||||
|
||||
TIdent CSecurityFile::GetIndex(char *pSymbol) const {
|
||||
// Indices and Id's are offset by 1
|
||||
return (GetId(pSymbol) - 1);
|
||||
}
|
||||
|
||||
eExchangeID CSecurityFile::GetExchangeIndex(TIdent index) const {
|
||||
// The mod converts a scaled security index into a base security index
|
||||
const char *pExchange = (*m_dataFile)[(int)(index % m_dataFile->size())].S_EX_ID_CSTR();
|
||||
eExchangeID eExchangeIndex;
|
||||
|
||||
if (!strcmp(pExchange, "NYSE")) {
|
||||
eExchangeIndex = eNYSE;
|
||||
} else if (!strcmp(pExchange, "NASDAQ")) {
|
||||
eExchangeIndex = eNASDAQ;
|
||||
} else if (!strcmp(pExchange, "AMEX")) {
|
||||
eExchangeIndex = eAMEX;
|
||||
} else if (!strcmp(pExchange, "PCX")) {
|
||||
eExchangeIndex = ePCX;
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
|
||||
return eExchangeIndex;
|
||||
}
|
||||
77
external/duckdb/third_party/tpce-tool/input/StatusTypeDataFileRecord.cpp
vendored
Normal file
77
external/duckdb/third_party/tpce-tool/input/StatusTypeDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Doug Johnson
|
||||
*/
|
||||
|
||||
#include "input/StatusTypeDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
StatusTypeDataFileRecord::StatusTypeDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], st_id, st_idCStr, maxSt_idLen);
|
||||
|
||||
DFRStringInit(fields[1], st_name, st_nameCStr, maxSt_nameLen);
|
||||
}
|
||||
|
||||
const std::string &StatusTypeDataFileRecord::ST_ID() const {
|
||||
return st_id;
|
||||
}
|
||||
|
||||
const char *StatusTypeDataFileRecord::ST_ID_CSTR() const {
|
||||
return st_idCStr;
|
||||
}
|
||||
|
||||
const std::string &StatusTypeDataFileRecord::ST_NAME() const {
|
||||
return st_name;
|
||||
}
|
||||
|
||||
const char *StatusTypeDataFileRecord::ST_NAME_CSTR() const {
|
||||
return st_nameCStr;
|
||||
}
|
||||
|
||||
std::string StatusTypeDataFileRecord::ToString(char fieldSeparator) const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
std::ostringstream msg;
|
||||
msg << ST_ID() << fieldSeparator << ST_NAME();
|
||||
return msg.str();
|
||||
}
|
||||
79
external/duckdb/third_party/tpce-tool/input/StreamSplitter.cpp
vendored
Normal file
79
external/duckdb/third_party/tpce-tool/input/StreamSplitter.cpp
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Doug Johnson
|
||||
*/
|
||||
|
||||
#include "input/StreamSplitter.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
StreamSplitter::StreamSplitter(std::istream &textStream, char recordDelimiter, char fieldDelimiter)
|
||||
: recordDelim(recordDelimiter), fieldDelim(fieldDelimiter), stream(textStream) {
|
||||
}
|
||||
|
||||
//
|
||||
// ITextSplitter implementation
|
||||
//
|
||||
|
||||
bool StreamSplitter::eof() const {
|
||||
return stream.eof();
|
||||
}
|
||||
|
||||
std::deque<std::string> StreamSplitter::getNextRecord() {
|
||||
std::string recordString;
|
||||
std::getline(stream, recordString, recordDelim);
|
||||
|
||||
std::deque<std::string> fields;
|
||||
std::istringstream recordStream(recordString);
|
||||
|
||||
// Either or both of eof and fail can occur so check
|
||||
// for both.
|
||||
while (!recordStream.eof() && !recordStream.fail()) {
|
||||
std::string field;
|
||||
std::getline(recordStream, field, fieldDelim);
|
||||
fields.push_back(field);
|
||||
}
|
||||
|
||||
// Fail can get set on eof which we don't want to treat
|
||||
// as a failure. So instead of testing for fail we test
|
||||
// for !eof.
|
||||
if (!recordStream.eof()) {
|
||||
throw std::runtime_error("Error reading record from stream.");
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
65
external/duckdb/third_party/tpce-tool/input/StreetNameDataFileRecord.cpp
vendored
Normal file
65
external/duckdb/third_party/tpce-tool/input/StreetNameDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 "input/StreetNameDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
StreetNameDataFileRecord::StreetNameDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], street, streetCStr, maxStreetLen);
|
||||
}
|
||||
|
||||
const std::string &StreetNameDataFileRecord::STREET() const {
|
||||
return street;
|
||||
}
|
||||
|
||||
const char *StreetNameDataFileRecord::STREET_CSTR() const {
|
||||
return streetCStr;
|
||||
}
|
||||
|
||||
std::string StreetNameDataFileRecord::ToString() const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
return STREET();
|
||||
}
|
||||
65
external/duckdb/third_party/tpce-tool/input/StreetSuffixDataFileRecord.cpp
vendored
Normal file
65
external/duckdb/third_party/tpce-tool/input/StreetSuffixDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 "input/StreetSuffixDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
StreetSuffixDataFileRecord::StreetSuffixDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], suffix, suffixCStr, maxSuffixLen);
|
||||
}
|
||||
|
||||
const std::string &StreetSuffixDataFileRecord::SUFFIX() const {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
const char *StreetSuffixDataFileRecord::SUFFIX_CSTR() const {
|
||||
return suffixCStr;
|
||||
}
|
||||
|
||||
std::string StreetSuffixDataFileRecord::ToString() const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
return SUFFIX();
|
||||
}
|
||||
55
external/duckdb/third_party/tpce-tool/input/StringSplitter.cpp
vendored
Normal file
55
external/duckdb/third_party/tpce-tool/input/StringSplitter.cpp
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 "input/StringSplitter.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
StringSplitter::StringSplitter(const std::string &textString, char recordDelimiter, char fieldDelimiter)
|
||||
: stream(textString), splitter(stream, recordDelimiter, fieldDelimiter) {
|
||||
}
|
||||
|
||||
//
|
||||
// ITextSplitter interface implementation
|
||||
//
|
||||
|
||||
bool StringSplitter::eof() const {
|
||||
return splitter.eof();
|
||||
}
|
||||
|
||||
std::deque<std::string> StringSplitter::getNextRecord() {
|
||||
return splitter.getNextRecord();
|
||||
}
|
||||
85
external/duckdb/third_party/tpce-tool/input/TaxRateCountryDataFileRecord.cpp
vendored
Normal file
85
external/duckdb/third_party/tpce-tool/input/TaxRateCountryDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Doug Johnson
|
||||
*/
|
||||
|
||||
#include "input/TaxRateCountryDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib> // for atof
|
||||
// #include <string> // C++11 for stod
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
TaxRateCountryDataFileRecord::TaxRateCountryDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], tx_id, tx_idCStr, maxTx_idLen);
|
||||
|
||||
DFRStringInit(fields[1], tx_name, tx_nameCStr, maxTx_nameLen);
|
||||
|
||||
tx_rate = std::atof(fields[2].c_str());
|
||||
}
|
||||
|
||||
const std::string &TaxRateCountryDataFileRecord::TX_ID() const {
|
||||
return tx_id;
|
||||
}
|
||||
|
||||
const char *TaxRateCountryDataFileRecord::TX_ID_CSTR() const {
|
||||
return tx_idCStr;
|
||||
}
|
||||
|
||||
const std::string &TaxRateCountryDataFileRecord::TX_NAME() const {
|
||||
return tx_name;
|
||||
}
|
||||
|
||||
const char *TaxRateCountryDataFileRecord::TX_NAME_CSTR() const {
|
||||
return tx_nameCStr;
|
||||
}
|
||||
|
||||
double TaxRateCountryDataFileRecord::TX_RATE() const {
|
||||
return tx_rate;
|
||||
}
|
||||
|
||||
std::string TaxRateCountryDataFileRecord::ToString(char fieldSeparator) const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
std::ostringstream msg;
|
||||
msg << TX_ID() << fieldSeparator << TX_NAME() << fieldSeparator << TX_RATE();
|
||||
return msg.str();
|
||||
}
|
||||
84
external/duckdb/third_party/tpce-tool/input/TaxRateDivisionDataFileRecord.cpp
vendored
Normal file
84
external/duckdb/third_party/tpce-tool/input/TaxRateDivisionDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Doug Johnson
|
||||
*/
|
||||
|
||||
#include "input/TaxRateDivisionDataFileRecord.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
TaxRateDivisionDataFileRecord::TaxRateDivisionDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], tx_id, tx_idCStr, maxTx_idLen);
|
||||
|
||||
DFRStringInit(fields[1], tx_name, tx_nameCStr, maxTx_nameLen);
|
||||
|
||||
tx_rate = std::atof(fields[2].c_str());
|
||||
}
|
||||
|
||||
const std::string &TaxRateDivisionDataFileRecord::TX_ID() const {
|
||||
return tx_id;
|
||||
}
|
||||
|
||||
const char *TaxRateDivisionDataFileRecord::TX_ID_CSTR() const {
|
||||
return tx_idCStr;
|
||||
}
|
||||
|
||||
const std::string &TaxRateDivisionDataFileRecord::TX_NAME() const {
|
||||
return tx_name;
|
||||
}
|
||||
|
||||
const char *TaxRateDivisionDataFileRecord::TX_NAME_CSTR() const {
|
||||
return tx_nameCStr;
|
||||
}
|
||||
|
||||
double TaxRateDivisionDataFileRecord::TX_RATE() const {
|
||||
return tx_rate;
|
||||
}
|
||||
|
||||
std::string TaxRateDivisionDataFileRecord::ToString(char fieldSeparator) const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
std::ostringstream msg;
|
||||
msg << TX_ID() << fieldSeparator << TX_NAME() << fieldSeparator << TX_RATE();
|
||||
return msg.str();
|
||||
}
|
||||
87
external/duckdb/third_party/tpce-tool/input/TaxRateFile.cpp
vendored
Normal file
87
external/duckdb/third_party/tpce-tool/input/TaxRateFile.cpp
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Legal Notice
|
||||
*
|
||||
* This document and associated source code (the "Work") is a part of a
|
||||
* benchmark specification maintained by the TPC.
|
||||
*
|
||||
* The TPC reserves all right, title, and interest to the Work as provided
|
||||
* under U.S. and international laws, including without limitation all patent
|
||||
* and trademark rights therein.
|
||||
*
|
||||
* No Warranty
|
||||
*
|
||||
* 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION
|
||||
* CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE
|
||||
* AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER
|
||||
* WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
|
||||
* INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES,
|
||||
* DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR
|
||||
* PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF
|
||||
* WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE.
|
||||
* ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT,
|
||||
* QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT
|
||||
* WITH REGARD TO THE WORK.
|
||||
* 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO
|
||||
* ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE
|
||||
* COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS
|
||||
* OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT,
|
||||
* INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY,
|
||||
* OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT
|
||||
* RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD
|
||||
* ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* Contributors
|
||||
* - Doug Johnson
|
||||
*/
|
||||
|
||||
#include "input/TaxRateFile.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
CTaxRateFile::CTaxRateFile(const TaxRateCountryDataFile_t &countryDataFile,
|
||||
const TaxRateDivisionDataFile_t &divisionDataFile)
|
||||
: cdf(&countryDataFile), ddf(&divisionDataFile) {
|
||||
locations.reserve(cdf->size() + ddf->size());
|
||||
|
||||
int maxBucketIdx = cdf->size(cdf->BucketsOnly);
|
||||
for (int bucketIdx = 0; bucketIdx < maxBucketIdx; ++bucketIdx) {
|
||||
int maxRecordIdx = (*cdf)[bucketIdx].size();
|
||||
for (int recordIdx = 0; recordIdx < maxRecordIdx; ++recordIdx) {
|
||||
locations.push_back(RecordLocation(bucketIdx, recordIdx));
|
||||
}
|
||||
}
|
||||
|
||||
maxBucketIdx = ddf->size(ddf->BucketsOnly);
|
||||
for (int bucketIdx = 0; bucketIdx < maxBucketIdx; ++bucketIdx) {
|
||||
int maxRecordIdx = (*ddf)[bucketIdx].size();
|
||||
for (int recordIdx = 0; recordIdx < maxRecordIdx; ++recordIdx) {
|
||||
locations.push_back(RecordLocation(bucketIdx, recordIdx));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Provide range-checked access to the records.
|
||||
const ITaxRateFileRecord &CTaxRateFile::operator[](unsigned int idx) const {
|
||||
if (0 == size()) {
|
||||
// This is an attempt to access an empty container.
|
||||
throw std::out_of_range("Attemt to index into an emtpy DataFile.");
|
||||
}
|
||||
|
||||
unsigned int maxIdx = size() - 1;
|
||||
|
||||
if (maxIdx < idx) {
|
||||
std::ostringstream msg;
|
||||
msg << "Provided index (" << idx << ") is outside the legal range (0:" << maxIdx << ").";
|
||||
throw std::out_of_range(msg.str());
|
||||
}
|
||||
|
||||
if (idx < cdf->size()) {
|
||||
return (*cdf)[locations[idx].bucketIdx][locations[idx].recordIdx];
|
||||
} else {
|
||||
return (*ddf)[locations[idx].bucketIdx][locations[idx].recordIdx];
|
||||
}
|
||||
}
|
||||
|
||||
CTaxRateFile::size_type CTaxRateFile::size() const {
|
||||
return locations.size();
|
||||
}
|
||||
65
external/duckdb/third_party/tpce-tool/input/TaxableAccountNameDataFileRecord.cpp
vendored
Normal file
65
external/duckdb/third_party/tpce-tool/input/TaxableAccountNameDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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 "input/TaxableAccountNameDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
TaxableAccountNameDataFileRecord::TaxableAccountNameDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], name, nameCStr, maxNameLen);
|
||||
}
|
||||
|
||||
const std::string &TaxableAccountNameDataFileRecord::NAME() const {
|
||||
return name;
|
||||
}
|
||||
|
||||
const char *TaxableAccountNameDataFileRecord::NAME_CSTR() const {
|
||||
return nameCStr;
|
||||
}
|
||||
|
||||
std::string TaxableAccountNameDataFileRecord::ToString() const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
return NAME();
|
||||
}
|
||||
67
external/duckdb/third_party/tpce-tool/input/TextFileSplitter.cpp
vendored
Normal file
67
external/duckdb/third_party/tpce-tool/input/TextFileSplitter.cpp
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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 "input/TextFileSplitter.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "input/StreamSplitter.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
TextFileSplitter::TextFileSplitter(const std::string &content, char recordDelimiter, char fieldDelimiter)
|
||||
: file(content), splitter(file, recordDelimiter, fieldDelimiter) {
|
||||
if (file.fail()) {
|
||||
throw std::runtime_error("Unable to open file");
|
||||
}
|
||||
}
|
||||
|
||||
TextFileSplitter::~TextFileSplitter() {
|
||||
}
|
||||
|
||||
//
|
||||
// ITextSplitter interface implementation
|
||||
//
|
||||
|
||||
bool TextFileSplitter::eof() const {
|
||||
return splitter.eof();
|
||||
}
|
||||
|
||||
std::deque<std::string> TextFileSplitter::getNextRecord() {
|
||||
return splitter.getNextRecord();
|
||||
}
|
||||
88
external/duckdb/third_party/tpce-tool/input/TradeTypeDataFileRecord.cpp
vendored
Normal file
88
external/duckdb/third_party/tpce-tool/input/TradeTypeDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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 "input/TradeTypeDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
TradeTypeDataFileRecord::TradeTypeDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
DFRStringInit(fields[0], tt_id, tt_idCStr, maxTt_idLen);
|
||||
|
||||
DFRStringInit(fields[1], tt_name, tt_nameCStr, maxTt_nameLen);
|
||||
|
||||
tt_is_sell = ("1" == fields[2]);
|
||||
tt_is_mrkt = ("1" == fields[3]);
|
||||
}
|
||||
|
||||
const std::string &TradeTypeDataFileRecord::TT_ID() const {
|
||||
return tt_id;
|
||||
}
|
||||
|
||||
const char *TradeTypeDataFileRecord::TT_ID_CSTR() const {
|
||||
return tt_idCStr;
|
||||
}
|
||||
|
||||
const std::string &TradeTypeDataFileRecord::TT_NAME() const {
|
||||
return tt_name;
|
||||
}
|
||||
|
||||
const char *TradeTypeDataFileRecord::TT_NAME_CSTR() const {
|
||||
return tt_nameCStr;
|
||||
}
|
||||
|
||||
bool TradeTypeDataFileRecord::TT_IS_SELL() const {
|
||||
return tt_is_sell;
|
||||
}
|
||||
|
||||
bool TradeTypeDataFileRecord::TT_IS_MRKT() const {
|
||||
return tt_is_mrkt;
|
||||
}
|
||||
|
||||
std::string TradeTypeDataFileRecord::ToString(char fieldSeparator) const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
std::ostringstream msg;
|
||||
msg << TT_ID() << fieldSeparator << TT_NAME() << fieldSeparator << TT_IS_SELL() << fieldSeparator << TT_IS_MRKT();
|
||||
return msg.str();
|
||||
}
|
||||
47
external/duckdb/third_party/tpce-tool/input/Utilities.cpp
vendored
Normal file
47
external/duckdb/third_party/tpce-tool/input/Utilities.cpp
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 "input/Utilities.h"
|
||||
#include "input/ShrinkToFit.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
void TPCE::DFRStringInit(const std::string &src, std::string &dest, char *destCStr, int maxLen) {
|
||||
dest = src;
|
||||
shrink_to_fit<std::string>(dest);
|
||||
size_t len = dest.copy(destCStr, maxLen);
|
||||
destCStr[len] = '\0';
|
||||
}
|
||||
96
external/duckdb/third_party/tpce-tool/input/ZipCodeDataFileRecord.cpp
vendored
Normal file
96
external/duckdb/third_party/tpce-tool/input/ZipCodeDataFileRecord.cpp
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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 "input/ZipCodeDataFileRecord.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <cstdlib> // for atoi
|
||||
// #include <string> // C++11 for stoi
|
||||
|
||||
#include "input/Utilities.h"
|
||||
|
||||
using namespace TPCE;
|
||||
|
||||
ZipCodeDataFileRecord::ZipCodeDataFileRecord(const std::deque<std::string> &fields) {
|
||||
if (fieldCount != fields.size()) {
|
||||
throw std::runtime_error("Incorrect field count.");
|
||||
}
|
||||
|
||||
divisionTaxKey = std::atoi(fields[0].c_str());
|
||||
// divisionTaxKey = std::stoi(fields[0]); // C++11
|
||||
|
||||
DFRStringInit(fields[1], zc_code, zc_codeCStr, maxZc_codeLen);
|
||||
|
||||
DFRStringInit(fields[2], zc_town, zc_townCStr, maxZc_townLen);
|
||||
|
||||
DFRStringInit(fields[3], zc_div, zc_divCStr, maxZc_divLen);
|
||||
}
|
||||
|
||||
int ZipCodeDataFileRecord::DivisionTaxKey() const {
|
||||
return divisionTaxKey;
|
||||
}
|
||||
|
||||
const std::string &ZipCodeDataFileRecord::ZC_CODE() const {
|
||||
return zc_code;
|
||||
}
|
||||
|
||||
const char *ZipCodeDataFileRecord::ZC_CODE_CSTR() const {
|
||||
return zc_codeCStr;
|
||||
}
|
||||
|
||||
const std::string &ZipCodeDataFileRecord::ZC_TOWN() const {
|
||||
return zc_town;
|
||||
}
|
||||
|
||||
const char *ZipCodeDataFileRecord::ZC_TOWN_CSTR() const {
|
||||
return zc_townCStr;
|
||||
}
|
||||
|
||||
const std::string &ZipCodeDataFileRecord::ZC_DIV() const {
|
||||
return zc_div;
|
||||
}
|
||||
|
||||
const char *ZipCodeDataFileRecord::ZC_DIV_CSTR() const {
|
||||
return zc_divCStr;
|
||||
}
|
||||
|
||||
std::string ZipCodeDataFileRecord::ToString(char fieldSeparator) const {
|
||||
// Facilitate encapsulation by using public interface to fields.
|
||||
std::ostringstream msg;
|
||||
msg << DivisionTaxKey() << fieldSeparator << ZC_CODE() << fieldSeparator << ZC_TOWN() << fieldSeparator << ZC_DIV();
|
||||
return msg.str();
|
||||
}
|
||||
Reference in New Issue
Block a user