Java Code Examples for com.teradata.tpcds.Session#getOnlyTableToGenerate()
The following examples show how to use
com.teradata.tpcds.Session#getOnlyTableToGenerate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebSalesRowGenerator.java From tpcds with Apache License 2.0 | 4 votes |
@Override public RowGeneratorResult generateRowAndChildRows(long rowNumber, Session session, RowGenerator parentRowGenerator, RowGenerator childRowGenerator) { Scaling scaling = session.getScaling(); int itemCount = (int) scaling.getIdCount(ITEM); if (itemPermutation == null) { itemPermutation = makePermutation(itemCount, getRandomNumberStream(WS_PERMUTATION)); } if (remainingLineItems == 0) { orderInfo = generateOrderInfo(rowNumber, session); itemIndex = generateUniformRandomInt(1, itemCount, getRandomNumberStream(WS_ITEM_SK)); remainingLineItems = generateUniformRandomInt(8, 16, getRandomNumberStream(WS_ORDER_NUMBER)); } long nullBitMap = createNullBitMap(WEB_SALES, getRandomNumberStream(WS_NULLS)); int shipLag = generateUniformRandomInt(1, 120, getRandomNumberStream(WS_SHIP_DATE_SK)); long wsShipDateSk = orderInfo.wsSoldDateSk + shipLag; if (++itemIndex > itemCount) { itemIndex = 1; } long wsItemSk = matchSurrogateKey(getPermutationEntry(itemPermutation, itemIndex), orderInfo.wsSoldDateSk, ITEM, scaling); // the web page needs to be valid for the sale date long wsWebPageSk = generateJoinKey(WS_WEB_PAGE_SK, getRandomNumberStream(WS_WEB_PAGE_SK), WEB_PAGE, orderInfo.wsSoldDateSk, scaling); long wsWebSiteSk = generateJoinKey(WS_WEB_SITE_SK, getRandomNumberStream(WS_WEB_SITE_SK), WEB_SITE, orderInfo.wsSoldDateSk, scaling); long wsShipModeSk = generateJoinKey(WS_SHIP_MODE_SK, getRandomNumberStream(WS_SHIP_MODE_SK), SHIP_MODE, 1, scaling); long wsWarehouseSk = generateJoinKey(WS_WAREHOUSE_SK, getRandomNumberStream(WS_WAREHOUSE_SK), WAREHOUSE, 1, scaling); long wsPromoSk = generateJoinKey(WS_PROMO_SK, getRandomNumberStream(WS_PROMO_SK), PROMOTION, 1, scaling); Pricing wsPricing = generatePricingForSalesTable(WS_PRICING, getRandomNumberStream(WS_PRICING)); WebSalesRow salesRow = new WebSalesRow(nullBitMap, orderInfo.wsSoldDateSk, orderInfo.wsSoldTimeSk, wsShipDateSk, wsItemSk, orderInfo.wsBillCustomerSk, orderInfo.wsBillCdemoSk, orderInfo.wsBillHdemoSk, orderInfo.wsBillAddrSk, orderInfo.wsShipCustomerSk, orderInfo.wsShipCdemoSk, orderInfo.wsShipHdemoSk, orderInfo.wsShipAddrSk, wsWebPageSk, wsWebSiteSk, wsShipModeSk, wsWarehouseSk, wsPromoSk, orderInfo.wsOrderNumber, wsPricing); List<TableRow> generatedRows = new ArrayList<>(2); generatedRows.add(salesRow); // if the item gets returned, generate a returns row int randomInt = generateUniformRandomInt(0, 99, getRandomNumberStream(WR_IS_RETURNED)); if (randomInt < RETURN_PERCENTAGE && (!session.generateOnlyOneTable() || !(session.getOnlyTableToGenerate() == WEB_SALES))) { TableRow returnsRow = ((WebReturnsRowGenerator) childRowGenerator).generateRow(session, salesRow); generatedRows.add(returnsRow); } remainingLineItems--; return new RowGeneratorResult(generatedRows, remainingLineItems == 0); }
Example 2
Source File: CatalogSalesRowGenerator.java From tpcds with Apache License 2.0 | 4 votes |
@Override public RowGeneratorResult generateRowAndChildRows(long rowNumber, Session session, RowGenerator parentRowGenerator, RowGenerator childRowGenerator) { int itemCount = (int) session.getScaling().getIdCount(ITEM); if (itemPermutation == null) { itemPermutation = makePermutation(itemCount, getRandomNumberStream(CS_PERMUTE)); DateNextIndexPair pair = skipDaysUntilFirstRowOfChunk(CATALOG_SALES, session); julianDate = pair.getJulianDate(); nextDateIndex = pair.getNextDateIndex(); } if (remainingLineItems == 0) { orderInfo = generateOrderInfo(rowNumber, session); ticketItemBase = generateUniformRandomInt(1, itemCount, getRandomNumberStream(CS_SOLD_ITEM_SK)); remainingLineItems = generateUniformRandomInt(4, 14, getRandomNumberStream(CS_ORDER_NUMBER)); } long nullBitMap = createNullBitMap(CATALOG_SALES, getRandomNumberStream(CS_NULLS)); // orders are shipped some number of days after they are ordered int shippingLag = generateUniformRandomInt(CS_MIN_SHIP_DELAY, CS_MAX_SHIP_DELAY, getRandomNumberStream(CS_SHIP_DATE_SK)); long csShipDateSk = orderInfo.getCsSoldDateSk() == -1 ? -1 : orderInfo.getCsSoldDateSk() + shippingLag; // items need to be unique within an order // use a sequence within the permutation // NB: Permutations are 1-based if (++ticketItemBase > itemCount) { ticketItemBase = 1; } Scaling scaling = session.getScaling(); long item = getPermutationEntry(itemPermutation, ticketItemBase); long csSoldItemSk = matchSurrogateKey(item, orderInfo.getCsSoldDateSk(), ITEM, scaling); // catalog page needs to be from a catalog active at the time of the sale long csCatalogPageSk = (orderInfo.getCsSoldDateSk() == -1) ? -1 : generateJoinKey(CS_CATALOG_PAGE_SK, getRandomNumberStream(CS_CATALOG_PAGE_SK), CATALOG_PAGE, orderInfo.getCsSoldDateSk(), scaling); long csShipModeSk = generateJoinKey(CS_SHIP_MODE_SK, getRandomNumberStream(CS_SHIP_MODE_SK), SHIP_MODE, 1, scaling); long csWarehouseSk = generateJoinKey(CS_WAREHOUSE_SK, getRandomNumberStream(CS_WAREHOUSE_SK), WAREHOUSE, 1, scaling); long csPromoSk = generateJoinKey(CS_PROMO_SK, getRandomNumberStream(CS_PROMO_SK), PROMOTION, 1, scaling); Pricing csPricing = generatePricingForSalesTable(CS_PRICING, getRandomNumberStream(CS_PRICING)); CatalogSalesRow catalogSalesRow = new CatalogSalesRow(orderInfo.getCsSoldDateSk(), orderInfo.getCsSoldTimeSk(), csShipDateSk, orderInfo.getCsBillCustomerSk(), orderInfo.getCsBillCdemoSk(), orderInfo.getCsBillHdemoSk(), orderInfo.getCsBillAddrSk(), orderInfo.getCsShipCustomerSk(), orderInfo.getCsShipCdemoSk(), orderInfo.getCsShipHdemoSk(), orderInfo.getCsShipAddrSk(), orderInfo.getCsCallCenterSk(), csCatalogPageSk, csShipModeSk, csWarehouseSk, csSoldItemSk, csPromoSk, orderInfo.getCsOrderNumber(), csPricing, nullBitMap); List<TableRow> generatedRows = new ArrayList<>(2); generatedRows.add(catalogSalesRow); // if the sale gets returned, generate a return row int randomInt = generateUniformRandomInt(0, 99, getRandomNumberStream(CR_IS_RETURNED)); if (randomInt < CatalogReturnsRowGenerator.RETURN_PERCENT && (!session.generateOnlyOneTable() || session.getOnlyTableToGenerate() != CATALOG_SALES)) { TableRow catalogReturnsRow = ((CatalogReturnsRowGenerator) childRowGenerator).generateRow(session, catalogSalesRow); generatedRows.add(catalogReturnsRow); } remainingLineItems--; return new RowGeneratorResult(generatedRows, isLastRowInOrder()); }
Example 3
Source File: StoreSalesRowGenerator.java From tpcds with Apache License 2.0 | 4 votes |
@Override public RowGeneratorResult generateRowAndChildRows(long rowNumber, Session session, RowGenerator parentRowGenerator, RowGenerator childRowGenerator) { int itemCount = (int) session.getScaling().getIdCount(ITEM); if (itemPermutation == null) { itemPermutation = makePermutation(itemCount, getRandomNumberStream(SS_PERMUTATION)); } Scaling scaling = session.getScaling(); if (remainingLineItems == 0) { orderInfo = generateOrderInfo(rowNumber, session); remainingLineItems = generateUniformRandomInt(8, 16, getRandomNumberStream(SS_TICKET_NUMBER)); itemIndex = generateUniformRandomInt(1, (int) scaling.getIdCount(ITEM), getRandomNumberStream(SS_SOLD_ITEM_SK)); } long nullBitMap = createNullBitMap(STORE_SALES, getRandomNumberStream(SS_NULLS)); //items need to be unique within an order // use a sequence within the permutation if (++itemIndex > itemCount) { itemIndex = 1; } long ssSoldItemSk = matchSurrogateKey(getPermutationEntry(itemPermutation, itemIndex), orderInfo.getSsSoldDateSk(), ITEM, scaling); long ssSoldPromoSk = generateJoinKey(SS_SOLD_PROMO_SK, getRandomNumberStream(SS_SOLD_PROMO_SK), PROMOTION, 1, scaling); Pricing ssPricing = generatePricingForSalesTable(SS_PRICING, getRandomNumberStream(SS_PRICING)); StoreSalesRow storeSalesRow = new StoreSalesRow(nullBitMap, orderInfo.getSsSoldDateSk(), orderInfo.getSsSoldTimeSk(), ssSoldItemSk, orderInfo.getSsSoldCustomerSk(), orderInfo.getSsSoldCdemoSk(), orderInfo.getSsSoldHdemoSk(), orderInfo.getSsSoldAddrSk(), orderInfo.getSsSoldStoreSk(), ssSoldPromoSk, orderInfo.getSsTicketNumber(), ssPricing); List<TableRow> generatedRows = new ArrayList<>(2); generatedRows.add(storeSalesRow); // if the sale gets returned, generate a return row int randomInt = generateUniformRandomInt(0, 99, getRandomNumberStream(SR_IS_RETURNED)); if (randomInt < SR_RETURN_PCT && (!session.generateOnlyOneTable() || session.getOnlyTableToGenerate() != STORE_SALES)) { generatedRows.add(((StoreReturnsRowGenerator) childRowGenerator).generateRow(session, storeSalesRow)); } remainingLineItems--; return new RowGeneratorResult(generatedRows, isLastRowInOrder()); }