| 1 | /* |
| 2 | * Legal Notice |
| 3 | * |
| 4 | * This document and associated source code (the "Work") is a part of a |
| 5 | * benchmark specification maintained by the TPC. |
| 6 | * |
| 7 | * The TPC reserves all right, title, and interest to the Work as provided |
| 8 | * under U.S. and international laws, including without limitation all patent |
| 9 | * and trademark rights therein. |
| 10 | * |
| 11 | * No Warranty |
| 12 | * |
| 13 | * 1.1 TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE INFORMATION |
| 14 | * CONTAINED HEREIN IS PROVIDED "AS IS" AND WITH ALL FAULTS, AND THE |
| 15 | * AUTHORS AND DEVELOPERS OF THE WORK HEREBY DISCLAIM ALL OTHER |
| 16 | * WARRANTIES AND CONDITIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, |
| 17 | * INCLUDING, BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES, |
| 18 | * DUTIES OR CONDITIONS OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR |
| 19 | * PURPOSE, OF ACCURACY OR COMPLETENESS OF RESPONSES, OF RESULTS, OF |
| 20 | * WORKMANLIKE EFFORT, OF LACK OF VIRUSES, AND OF LACK OF NEGLIGENCE. |
| 21 | * ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, |
| 22 | * QUIET POSSESSION, CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT |
| 23 | * WITH REGARD TO THE WORK. |
| 24 | * 1.2 IN NO EVENT WILL ANY AUTHOR OR DEVELOPER OF THE WORK BE LIABLE TO |
| 25 | * ANY OTHER PARTY FOR ANY DAMAGES, INCLUDING BUT NOT LIMITED TO THE |
| 26 | * COST OF PROCURING SUBSTITUTE GOODS OR SERVICES, LOST PROFITS, LOSS |
| 27 | * OF USE, LOSS OF DATA, OR ANY INCIDENTAL, CONSEQUENTIAL, DIRECT, |
| 28 | * INDIRECT, OR SPECIAL DAMAGES WHETHER UNDER CONTRACT, TORT, WARRANTY, |
| 29 | * OR OTHERWISE, ARISING IN ANY WAY OUT OF THIS OR ANY OTHER AGREEMENT |
| 30 | * RELATING TO THE WORK, WHETHER OR NOT SUCH AUTHOR OR DEVELOPER HAD |
| 31 | * ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. |
| 32 | * |
| 33 | * Contributors |
| 34 | * - Sergey Vasilevskiy |
| 35 | * - Doug Johnson |
| 36 | */ |
| 37 | |
| 38 | /* |
| 39 | * This file contains a class that acts as a client to the table |
| 40 | * generation classes (EGenTables) and to the loader classes (EGenBaseLoader). |
| 41 | * It provides routines for generating and loading the table data or its |
| 42 | * subset. |
| 43 | */ |
| 44 | |
| 45 | #ifndef EGEN_GENERATE_AND_LOAD_H |
| 46 | #define EGEN_GENERATE_AND_LOAD_H |
| 47 | |
| 48 | #include <string> |
| 49 | |
| 50 | #include "utilities/EGenStandardTypes.h" |
| 51 | #include "input/DataFileManager.h" |
| 52 | #include "EGenGenerateAndLoadBaseOutput.h" |
| 53 | #include "utilities/MiscConsts.h" |
| 54 | #include "BaseLoaderFactory.h" |
| 55 | #include "BaseLogger.h" |
| 56 | |
| 57 | namespace TPCE { |
| 58 | |
| 59 | class CGenerateAndLoad { |
| 60 | // Data File Manager |
| 61 | const DataFileManager &m_dfm; |
| 62 | // Ordinal position (1-based) of the first customer in the sequence |
| 63 | TIdent m_iStartFromCustomer; |
| 64 | // The number of customers to generate from the starting position |
| 65 | TIdent m_iCustomerCount; |
| 66 | // Total number of customers in the database |
| 67 | TIdent m_iTotalCustomers; |
| 68 | // Number of customers in one load unit for generating initial trades |
| 69 | UINT m_iLoadUnitSize; |
| 70 | // Number of customers per 1 tpsE |
| 71 | UINT m_iScaleFactor; |
| 72 | // Time period for which to generate initial trades |
| 73 | UINT m_iHoursOfInitialTrades; |
| 74 | // External loader factory to create table loaders |
| 75 | CBaseLoaderFactory *m_pLoaderFactory; |
| 76 | // External class used to output load progress |
| 77 | CGenerateAndLoadBaseOutput *m_pOutput; |
| 78 | // Logger instance |
| 79 | CBaseLogger *m_pLogger; |
| 80 | // Parameter instance |
| 81 | CLoaderSettings m_LoaderSettings; |
| 82 | // Whether to use cache when generating initial population |
| 83 | bool m_bCacheEnabled; |
| 84 | |
| 85 | public: |
| 86 | /* |
| 87 | * Constructor. |
| 88 | * |
| 89 | * PARAMETERS: |
| 90 | * IN inputFiles - in-memory representation of input |
| 91 | * flat files IN iCustomerCount - number of customers to build (for |
| 92 | * this class instance) IN iStartFromCustomer - first customer id IN |
| 93 | * iTotalCustomers - total number of customers in the database IN |
| 94 | * iLoadUnitSize - minimal number of customers that can be build |
| 95 | * (should always be 1000) IN iScaleFactor - number of customers for |
| 96 | * 1tpsE IN iDaysOfInitialTrades- number of 8-hour days of initial trades |
| 97 | * per customer IN pLoaderFactory - factory to create loader classes |
| 98 | * IN pLogger - parameter logging interface |
| 99 | * IN pOutput - interface to output information to a |
| 100 | * user during the build process IN szInDir - input flat file |
| 101 | * directory needed for tables loaded from flat files IN bCacheEnabled - |
| 102 | * whether or not to use caching during data generation |
| 103 | * |
| 104 | * RETURNS: |
| 105 | * not applicable. |
| 106 | */ |
| 107 | CGenerateAndLoad(const DataFileManager &dfm, TIdent iCustomerCount, TIdent iStartFromCustomer, |
| 108 | TIdent iTotalCustomers, UINT iLoadUnitSize, UINT iScaleFactor, UINT iDaysOfInitialTrades, |
| 109 | CBaseLoaderFactory *pLoaderFactory, CBaseLogger *pLogger, CGenerateAndLoadBaseOutput *pOutput, |
| 110 | bool bCacheEnabled = false); |
| 111 | |
| 112 | /* |
| 113 | * Generate and load ADDRESS table. |
| 114 | * |
| 115 | * PARAMETERS: |
| 116 | * none. |
| 117 | * |
| 118 | * RETURNS: |
| 119 | * none. |
| 120 | */ |
| 121 | void GenerateAndLoadAddress(); |
| 122 | /* |
| 123 | * Generate and load CHARGE table. |
| 124 | * |
| 125 | * PARAMETERS: |
| 126 | * none. |
| 127 | * |
| 128 | * RETURNS: |
| 129 | * none. |
| 130 | */ |
| 131 | void GenerateAndLoadCharge(); |
| 132 | /* |
| 133 | * Generate and load COMMISSION_RATE table. |
| 134 | * |
| 135 | * PARAMETERS: |
| 136 | * none. |
| 137 | * |
| 138 | * RETURNS: |
| 139 | * none. |
| 140 | */ |
| 141 | void GenerateAndLoadCommissionRate(); |
| 142 | /* |
| 143 | * Generate and load COMPANY_COMPETITOR table. |
| 144 | * |
| 145 | * PARAMETERS: |
| 146 | * none. |
| 147 | * |
| 148 | * RETURNS: |
| 149 | * none. |
| 150 | */ |
| 151 | void GenerateAndLoadCompanyCompetitor(); |
| 152 | /* |
| 153 | * Generate and load COMPANY table. |
| 154 | * |
| 155 | * PARAMETERS: |
| 156 | * none. |
| 157 | * |
| 158 | * RETURNS: |
| 159 | * none. |
| 160 | */ |
| 161 | void GenerateAndLoadCompany(); |
| 162 | /* |
| 163 | * Generate and load CUSTOMER_ACCOUNT, ACCOUNT_PERMISSION table. |
| 164 | * |
| 165 | * PARAMETERS: |
| 166 | * none. |
| 167 | * |
| 168 | * RETURNS: |
| 169 | * none. |
| 170 | */ |
| 171 | void GenerateAndLoadCustomerAccountAndAccountPermission(); |
| 172 | /* |
| 173 | * Generate and load CUSTOMER table. |
| 174 | * |
| 175 | * PARAMETERS: |
| 176 | * none. |
| 177 | * |
| 178 | * RETURNS: |
| 179 | * none. |
| 180 | */ |
| 181 | void GenerateAndLoadCustomer(); |
| 182 | /* |
| 183 | * Generate and load CUSTOMER_TAXRATE table. |
| 184 | * |
| 185 | * PARAMETERS: |
| 186 | * none. |
| 187 | * |
| 188 | * RETURNS: |
| 189 | * none. |
| 190 | */ |
| 191 | void GenerateAndLoadCustomerTaxrate(); |
| 192 | /* |
| 193 | * Generate and load DAILY_MARKET table. |
| 194 | * |
| 195 | * PARAMETERS: |
| 196 | * none. |
| 197 | * |
| 198 | * RETURNS: |
| 199 | * none. |
| 200 | */ |
| 201 | void GenerateAndLoadDailyMarket(); |
| 202 | /* |
| 203 | * Generate and load EXCHANGE table. |
| 204 | * |
| 205 | * PARAMETERS: |
| 206 | * none. |
| 207 | * |
| 208 | * RETURNS: |
| 209 | * none. |
| 210 | */ |
| 211 | void GenerateAndLoadExchange(); |
| 212 | /* |
| 213 | * Generate and load FINANCIAL table. |
| 214 | * |
| 215 | * PARAMETERS: |
| 216 | * none. |
| 217 | * |
| 218 | * RETURNS: |
| 219 | * none. |
| 220 | */ |
| 221 | void GenerateAndLoadFinancial(); |
| 222 | /* |
| 223 | * Generate and load HOLDING, HOLDING_HISTORY, TRADE, TRADE_HISTORY, |
| 224 | * SETTLEMENT, CASH_TRANSACTION, BROKER table. |
| 225 | * |
| 226 | * PARAMETERS: |
| 227 | * none. |
| 228 | * |
| 229 | * RETURNS: |
| 230 | * none. |
| 231 | */ |
| 232 | void GenerateAndLoadHoldingAndTrade(); |
| 233 | /* |
| 234 | * Generate and load INDUSTRY table. |
| 235 | * |
| 236 | * PARAMETERS: |
| 237 | * none. |
| 238 | * |
| 239 | * RETURNS: |
| 240 | * none. |
| 241 | */ |
| 242 | void GenerateAndLoadIndustry(); |
| 243 | /* |
| 244 | * Generate and load LAST_TRADE table. |
| 245 | * |
| 246 | * PARAMETERS: |
| 247 | * none. |
| 248 | * |
| 249 | * RETURNS: |
| 250 | * none. |
| 251 | */ |
| 252 | void GenerateAndLoadLastTrade(); |
| 253 | /* |
| 254 | * Generate and load NEWS_ITEM, NEWS_XREF table. |
| 255 | * |
| 256 | * PARAMETERS: |
| 257 | * none. |
| 258 | * |
| 259 | * RETURNS: |
| 260 | * none. |
| 261 | */ |
| 262 | void GenerateAndLoadNewsItemAndNewsXRef(); |
| 263 | /* |
| 264 | * Generate and load SECTOR table. |
| 265 | * |
| 266 | * PARAMETERS: |
| 267 | * none. |
| 268 | * |
| 269 | * RETURNS: |
| 270 | * none. |
| 271 | */ |
| 272 | void GenerateAndLoadSector(); |
| 273 | /* |
| 274 | * Generate and load SECURITY table. |
| 275 | * |
| 276 | * PARAMETERS: |
| 277 | * none. |
| 278 | * |
| 279 | * RETURNS: |
| 280 | * none. |
| 281 | */ |
| 282 | void GenerateAndLoadSecurity(); |
| 283 | /* |
| 284 | * Generate and load STATUS_TYPE table. |
| 285 | * |
| 286 | * PARAMETERS: |
| 287 | * none. |
| 288 | * |
| 289 | * RETURNS: |
| 290 | * none. |
| 291 | */ |
| 292 | void GenerateAndLoadStatusType(); |
| 293 | /* |
| 294 | * Generate and load TAXRATE table. |
| 295 | * |
| 296 | * PARAMETERS: |
| 297 | * none. |
| 298 | * |
| 299 | * RETURNS: |
| 300 | * none. |
| 301 | */ |
| 302 | void GenerateAndLoadTaxrate(); |
| 303 | /* |
| 304 | * Generate and load TRADE_TYPE table. |
| 305 | * |
| 306 | * PARAMETERS: |
| 307 | * none. |
| 308 | * |
| 309 | * RETURNS: |
| 310 | * none. |
| 311 | */ |
| 312 | void GenerateAndLoadTradeType(); |
| 313 | /* |
| 314 | * Generate and load WATCH_LIST, WATCH_ITEM table. |
| 315 | * |
| 316 | * PARAMETERS: |
| 317 | * none. |
| 318 | * |
| 319 | * RETURNS: |
| 320 | * none. |
| 321 | */ |
| 322 | void GenerateAndLoadWatchListAndWatchItem(); |
| 323 | /* |
| 324 | * Generate and load ZIP_CODE table. |
| 325 | * |
| 326 | * PARAMETERS: |
| 327 | * none. |
| 328 | * |
| 329 | * RETURNS: |
| 330 | * none. |
| 331 | */ |
| 332 | void GenerateAndLoadZipCode(); |
| 333 | |
| 334 | /* |
| 335 | * Generate and load All tables that are constant in size. |
| 336 | * |
| 337 | * Spec definition: Fixed tables. |
| 338 | * |
| 339 | * PARAMETERS: |
| 340 | * none. |
| 341 | * |
| 342 | * RETURNS: |
| 343 | * none. |
| 344 | */ |
| 345 | void GenerateAndLoadFixedTables(); |
| 346 | |
| 347 | /* |
| 348 | * Generate and load All tables (except BROKER) that scale with the size |
| 349 | * of the CUSTOMER table, but do not grow in runtime. |
| 350 | * |
| 351 | * Spec definition: Scaling tables. |
| 352 | * |
| 353 | * PARAMETERS: |
| 354 | * none. |
| 355 | * |
| 356 | * RETURNS: |
| 357 | * none. |
| 358 | */ |
| 359 | void GenerateAndLoadScalingTables(); |
| 360 | |
| 361 | /* |
| 362 | * Generate and load All trade related tables and BROKER (included here to |
| 363 | * facilitate generation of a consistent database). |
| 364 | * |
| 365 | * Spec definition: Growing tables. |
| 366 | * |
| 367 | * PARAMETERS: |
| 368 | * none. |
| 369 | * |
| 370 | * RETURNS: |
| 371 | * none. |
| 372 | */ |
| 373 | void GenerateAndLoadGrowingTables(); |
| 374 | }; |
| 375 | |
| 376 | } // namespace TPCE |
| 377 | |
| 378 | #endif // EGEN_GENERATE_AND_LOAD_H |
| 379 | |