Package com.oltpbenchmark.benchmarks.auctionmark.util

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


        }
        @Override
        protected int populateRow(Object[] row) {
            int col = 0;

            UserId u_id = this.idGenerator.next();
           
            // U_ID
            row[col++] = u_id;
            // U_RATING
            row[col++] = this.randomRating.nextInt();
View Full Code Here


        @Override
        protected int populateRow(LoaderItemInfo itemInfo, Object[] row, short remaining) {
            int col = 0;
            assert(itemInfo.numBids > 0);
           
            UserId bidderId = null;
           
            // Figure out the UserId for the person bidding on this item now
            if (this.new_item) {
                // If this is a new item and there is more than one bid, then
                // we'll choose the bidder's UserId at random.
View Full Code Here

        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));
        
        ItemStatus qtype = profile.addItemToProperQueue(itemInfo, false);
   
        return (i_id);
View Full Code Here

    // GetUserInfo
    // ----------------------------------------------------------------
   
    protected boolean executeGetUserInfo(GetUserInfo proc) throws SQLException {
        Timestamp benchmarkTimes[] = this.getTimestampParameterArray();
        UserId userId = profile.getRandomBuyerId();
        int rand;
       
        // USER_FEEDBACK records
        rand = profile.rng.number(0, 100);
        boolean get_feedback = (rand <= AuctionMarkConstants.PROB_GETUSERINFO_INCLUDE_FEEDBACK);

        // ITEM_COMMENT records
        rand = profile.rng.number(0, 100);
        boolean get_comments = (rand <= AuctionMarkConstants.PROB_GETUSERINFO_INCLUDE_COMMENTS);
       
        // Seller ITEM records
        rand = profile.rng.number(0, 100);
        boolean get_seller_items = (rand <= AuctionMarkConstants.PROB_GETUSERINFO_INCLUDE_SELLER_ITEMS);

        // Buyer ITEM records
        rand = profile.rng.number(0, 100);
        boolean get_buyer_items = (rand <= AuctionMarkConstants.PROB_GETUSERINFO_INCLUDE_BUYER_ITEMS);
       
        // USER_WATCH records
        rand = profile.rng.number(0, 100);
        boolean get_watched_items = (rand <= AuctionMarkConstants.PROB_GETUSERINFO_INCLUDE_WATCHED_ITEMS);
       
        List<Object[]>[] results = proc.run(conn, benchmarkTimes, userId.encode(),
                                                                  get_feedback,
                                                                  get_comments,
                                                                  get_seller_items,
                                                                  get_buyer_items,
                                                                  get_watched_items);
        conn.commit();
       
        List<Object[]> vt = null;
        int idx = 0;
     
        // USER
        vt = results[idx++];
        assert(vt != null);
        assert(vt.size() > 0) :
            "Failed to find user information for " + userId + " / " + userId.encode();
         
        // USER_FEEDBACK
        if (get_feedback) {
            vt = results[idx];
            assert(vt != null);
View Full Code Here

    // ----------------------------------------------------------------
   
    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(),
                                                          sellerId.encode(),
                                                          buyerId.encode(),
                                                          maxBid,
                                                          itemInfo.endDate);
        conn.commit();
       
        ItemId itemId = this.processItemRecord(results);
View Full Code Here

    // ----------------------------------------------------------------
   
    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,
                                          itemInfo.itemId.encode(),
                                          sellerId.encode(),
                                          buyerId.encode(),
                                          question);
        conn.commit();
        assert(results != null);
       
        profile.pending_commentResponses.add(new ItemCommentResponse(SQLUtil.getLong(results[0]),
View Full Code Here

        ItemCommentResponse cr = profile.pending_commentResponses.remove(idx);
        assert(cr != null);
       
        long commentId = cr.commentId.longValue();;
        ItemId itemId = new ItemId(cr.itemId.longValue());
        UserId sellerId = itemId.getSellerId();
        assert(sellerId.encode() == cr.sellerId);
        String response = profile.rng.astring(AuctionMarkConstants.ITEM_COMMENT_LENGTH_MIN,
                                              AuctionMarkConstants.ITEM_COMMENT_LENGTH_MAX);

        proc.run(conn, benchmarkTimes, itemId.encode(),
                                       sellerId.encode(),
                                       commentId,
                                       response);
        conn.commit();
       
        return (true);
View Full Code Here

    // ----------------------------------------------------------------
   
    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;
        long from_id;
        if (profile.rng.nextBoolean()) {
            user_id = sellerId.encode();
            from_id = buyerId.encode();
        } else {
            user_id = buyerId.encode();
            from_id = sellerId.encode();
        }
       
        proc.run(conn, benchmarkTimes, user_id,
                                       itemInfo.itemId.encode(),
View Full Code Here

    // NewItem
    // ----------------------------------------------------------------

    protected boolean executeNewItem(NewItem proc) throws SQLException {
        Timestamp benchmarkTimes[] = this.getTimestampParameterArray();
        UserId sellerId = profile.getRandomSellerId(this.getId());
        ItemId itemId = profile.getNextItemId(sellerId);

        String name = profile.rng.astring(6, 32);
        String description = profile.rng.astring(50, 255);
        long categoryId = profile.getRandomCategoryId();

        Double initial_price = (double) profile.randomInitialPrice.nextInt();
        String attributes = profile.rng.astring(50, 255);

        int numAttributes = profile.randomNumAttributes.nextInt();
        List<GlobalAttributeValueId> gavList = new ArrayList<GlobalAttributeValueId>(numAttributes);
        for (int i = 0; i < numAttributes; i++) {
            GlobalAttributeValueId gav_id = profile.getRandomGlobalAttributeValue();
            if (!gavList.contains(gav_id)) gavList.add(gav_id);
        } // FOR

        long[] gag_ids = new long[gavList.size()];
        long[] gav_ids = new long[gavList.size()];
        for (int i = 0, cnt = gag_ids.length; i < cnt; i++) {
            GlobalAttributeValueId gav_id = gavList.get(i);
            gag_ids[i] = gav_id.getGlobalAttributeGroup().encode();
            gav_ids[i] = gav_id.encode();
        } // FOR

        int numImages = profile.randomNumImages.nextInt();
        String[] images = new String[numImages];
        for (int i = 0; i < numImages; i++) {
            images[i] = profile.rng.astring(20, 100);
        } // FOR

        long duration = profile.randomDuration.nextInt();

        Object results[] = null;
        try {
            long itemIdEncoded = itemId.encode();
            results = proc.run(conn, benchmarkTimes, itemIdEncoded, sellerId.encode(),
                                                     categoryId, name, description,
                                                     duration, initial_price, attributes,
                                                     gag_ids, gav_ids, images);
        } catch (DuplicateItemIdException ex) {
            profile.seller_item_cnt.set(sellerId, ex.getItemCount());
View Full Code Here

   
    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,
                                                          sellerId.encode(),
                                                          ip_id,
                                                          buyer_credit);
        conn.commit();
       
        ItemId itemId = this.processItemRecord(results);
View Full Code Here

TOP

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

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.