Package com.oltpbenchmark.benchmarks.auctionmark.util

Examples of com.oltpbenchmark.benchmarks.auctionmark.util.ItemInfo


       
        Integer temp = SQLUtil.getInteger(row[col++]);
        if (temp == null) throw new RuntimeException("DJELLEL IS STILL THE MAN! --> " + row[col-1] + " / " + row[col-1].getClass());
        ItemStatus i_status = ItemStatus.get(temp); // i_status
       
        ItemInfo itemInfo = new ItemInfo(i_id, i_current_price, i_end_date, (int)i_num_bids);
        itemInfo.status = i_status;
       
        UserId sellerId = new UserId(i_u_id);
        assert (i_id.getSellerId().equals(sellerId));
        
View Full Code Here


    // GetItem
    // ----------------------------------------------------------------
   
    protected boolean executeGetItem(GetItem proc) throws SQLException {
        Timestamp benchmarkTimes[] = this.getTimestampParameterArray();
        ItemInfo itemInfo = profile.getRandomAvailableItemId();
       
        Object results[][] = proc.run(conn, benchmarkTimes, itemInfo.itemId.encode(),
                                                            itemInfo.getSellerId().encode());
        conn.commit();
       
        // The first row will have our item data that we want
        // We don't care about the user information...
        ItemId itemId = this.processItemRecord(results[0]);
View Full Code Here

    // NewBid
    // ----------------------------------------------------------------
   
    protected boolean executeNewBid(NewBid proc) throws SQLException {
        Timestamp benchmarkTimes[] = this.getTimestampParameterArray();
        ItemInfo itemInfo = null;
        UserId sellerId;
        UserId buyerId;
        double bid;
        double maxBid;
       
        boolean has_available = (profile.getAvailableItemsCount() > 0);
        boolean has_ending = (profile.getEndingSoonItemsCount() > 0);
        boolean has_waiting = (profile.getWaitForPurchaseItemsCount() > 0);
        boolean has_completed = (profile.getCompleteItemsCount() > 0);
       
        // Some NewBids will be for items that have already ended.
        // This will simulate somebody trying to bid at the very end but failing
        if ((has_waiting || has_completed) &&
            (profile.rng.number(1, 100) <= AuctionMarkConstants.PROB_NEWBID_CLOSED_ITEM || has_available == false)) {
            if (has_waiting) {
                itemInfo = profile.getRandomWaitForPurchaseItem();
                assert(itemInfo != null) : "Failed to get WaitForPurchase itemInfo [" + profile.getWaitForPurchaseItemsCount() + "]";
            } else {
                itemInfo = profile.getRandomCompleteItem();
                assert(itemInfo != null) : "Failed to get Completed itemInfo [" + profile.getCompleteItemsCount() + "]";
            }
            sellerId = itemInfo.getSellerId();
            buyerId = profile.getRandomBuyerId(sellerId);
           
            // The bid/maxBid do not matter because they won't be able to actually
            // update the auction
            bid = profile.rng.nextDouble();
            maxBid = bid + 100;
        }
       
        // Otherwise we want to generate information for a real bid
        else {
            assert(has_available || has_ending);
            // 50% of NewBids will be for items that are ending soon
            if ((has_ending && profile.rng.number(1, 100) <= AuctionMarkConstants.PROB_NEWBID_CLOSED_ITEM) || has_available == false) {
                itemInfo = profile.getRandomEndingSoonItem(true);
            }
            if (itemInfo == null) {
                itemInfo = profile.getRandomAvailableItem(true);
            }
            if (itemInfo == null) {
                itemInfo = profile.getRandomItem();
            }
           
            sellerId = itemInfo.getSellerId();
            buyerId = profile.getRandomBuyerId(sellerId);
           
            double currentPrice = itemInfo.getCurrentPrice();
            bid = profile.rng.fixedPoint(2, currentPrice, currentPrice * (1 + (AuctionMarkConstants.ITEM_BID_PERCENT_STEP / 2)));
            maxBid = profile.rng.fixedPoint(2, bid, (bid * (1 + (AuctionMarkConstants.ITEM_BID_PERCENT_STEP / 2))));
        }

        Object results[] = proc.run(conn, benchmarkTimes, itemInfo.itemId.encode(),
View Full Code Here

    // NewComment
    // ----------------------------------------------------------------
   
    protected boolean executeNewComment(NewComment proc) throws SQLException {
        Timestamp benchmarkTimes[] = this.getTimestampParameterArray();
        ItemInfo itemInfo = profile.getRandomCompleteItem();
        UserId sellerId = itemInfo.getSellerId();
        UserId buyerId = profile.getRandomBuyerId(sellerId);
        String question = profile.rng.astring(AuctionMarkConstants.ITEM_COMMENT_LENGTH_MIN,
                                              AuctionMarkConstants.ITEM_COMMENT_LENGTH_MAX);
       
        Object results[] = proc.run(conn, benchmarkTimes,
View Full Code Here

    // NewFeedback
    // ----------------------------------------------------------------
   
    protected boolean executeNewFeedback(NewFeedback proc) throws SQLException {
        Timestamp benchmarkTimes[] = this.getTimestampParameterArray();
        ItemInfo itemInfo = profile.getRandomCompleteItem();
        UserId sellerId = itemInfo.getSellerId();
        UserId buyerId = profile.getRandomBuyerId(sellerId);
        long rating = (long) profile.rng.number(-1, 1);
        String feedback = profile.rng.astring(10, 80);
       
        long user_id;
View Full Code Here

    // NewPurchase
    // ----------------------------------------------------------------
   
    protected boolean executeNewPurchase(NewPurchase proc) throws SQLException {
        Timestamp benchmarkTimes[] = this.getTimestampParameterArray();
        ItemInfo itemInfo = profile.getRandomWaitForPurchaseItem();
        long encodedItemId = itemInfo.itemId.encode();
        UserId sellerId = itemInfo.getSellerId();
        double buyer_credit = 0d;
        long ip_id = AuctionMarkUtil.getUniqueElementId(encodedItemId, profile.rng.nextInt());
       
        // Whether the buyer will not have enough money
        if (itemInfo.hasCurrentPrice()) {
            if (profile.rng.number(1, 100) < AuctionMarkConstants.PROB_NEWPURCHASE_NOT_ENOUGH_MONEY) {
                buyer_credit = -1 * itemInfo.getCurrentPrice();
            } else {
                buyer_credit = itemInfo.getCurrentPrice();
                itemInfo.status = ItemStatus.CLOSED;
            }
        }
       
        Object results[] = proc.run(conn, benchmarkTimes, encodedItemId,
View Full Code Here

    // UpdateItem
    // ----------------------------------------------------------------
   
    protected boolean executeUpdateItem(UpdateItem proc) throws SQLException {
        Timestamp benchmarkTimes[] = this.getTimestampParameterArray();
        ItemInfo itemInfo = profile.getRandomAvailableItemId();
        UserId sellerId = itemInfo.getSellerId();
        String description = profile.rng.astring(50, 255);
       
        boolean delete_attribute = false;
        long add_attribute[] = {
            -1,
View Full Code Here

            Timestamp i_end_date = vt.getTimestamp(col++);
            int i_num_bids = (int)vt.getLong(col++);
           
            // IMPORTANT: Do not set the status here so that we make sure that
            // it is added to the right queue
            ItemInfo itemInfo = new ItemInfo(i_id, i_current_price, i_end_date, i_num_bids);
            profile.addItemToProperQueue(itemInfo, false);
            ctr++;
        } // WHILE
       
        if (LOG.isDebugEnabled())
View Full Code Here

       
        int idx = items.indexOf(itemInfo);
        if (idx != -1) {
            // HACK: Always swap existing ItemInfos with our new one, since it will
            // more up-to-date information
            ItemInfo existing = items.set(idx, itemInfo);
            assert(existing != null);
            return (true);
        }
        if (itemInfo.hasCurrentPrice())
            assert(itemInfo.getCurrentPrice() > 0) : "Negative current price for " + itemInfo;
View Full Code Here

     */
    private ItemInfo getRandomItem(LinkedList<ItemInfo> itemSet, boolean needCurrentPrice, boolean needFutureEndDate) {
        Timestamp currentTime = this.updateAndGetCurrentTime();
        int num_items = itemSet.size();
        int idx = -1;
        ItemInfo itemInfo = null;
       
        if (LOG.isTraceEnabled())
            LOG.trace(String.format("Getting random ItemInfo [numItems=%d, currentTime=%s, needCurrentPrice=%s]",
                                    num_items, currentTime, needCurrentPrice));
        long tries = 1000;
        tmp_seenItems.clear();
        while (num_items > 0 && tries-- > 0 && tmp_seenItems.size() < num_items) {
            idx = this.rng.nextInt(num_items);
            ItemInfo temp = itemSet.get(idx);
            assert(temp != null);
            if (tmp_seenItems.contains(temp)) continue;
            tmp_seenItems.add(temp);
           
            // Needs to have an embedded currentPrice
            if (needCurrentPrice && temp.hasCurrentPrice() == false) {
                continue;
            }
           
            // If they want an item that is ending in the future, then we compare it with
            // the current timestamp
            if (needFutureEndDate) {
                boolean compareTo = (temp.getEndDate().compareTo(currentTime) < 0);
                if (LOG.isTraceEnabled())
                    LOG.trace("CurrentTime:" + currentTime + " / EndTime:" + temp.getEndDate() + " [compareTo=" + compareTo + "]");
                if (temp.hasEndDate() == false || compareTo) {
                    continue;
                }
            }
           
            // Uniform
View Full Code Here

TOP

Related Classes of com.oltpbenchmark.benchmarks.auctionmark.util.ItemInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.