Package edu.brown.benchmark.auctionmark.AuctionMarkConstants

Examples of edu.brown.benchmark.auctionmark.AuctionMarkConstants.ItemStatus


                long itemId = dueItemsTable[0].getLong(0);
                long sellerId = dueItemsTable[0].getLong(1);
                double currentPrice = dueItemsTable[0].getDouble(2);
                long numBids = dueItemsTable[0].getLong(3);
                TimestampType endDate = dueItemsTable[0].getTimestampAsTimestamp(4);
                ItemStatus itemStatus = ItemStatus.get(dueItemsTable[0].getLong(5));
               
                if (debug)
                    LOG.debug(String.format("Getting max bid for itemId=%d / sellerId=%d", itemId, sellerId));
                assert(itemStatus == ItemStatus.OPEN);
               
                output_rows[i] = new Object[] { itemId,         // i_id
                                                sellerId,       // i_u_id
                                                numBids,        // i_num_bids
                                                currentPrice,   // i_current_price
                                                endDate,        // i_end_date
                                                itemStatus.ordinal(), // i_status
                                                null,           // imb_ib_id
                                                null            // ib_buyer_id
                };
               
                // Has bid on this item - set status to WAITING_FOR_PURCHASE
                // We'll also insert a new USER_ITEM record as needed
                if (numBids > 0) {
                    voltQueueSQL(getMaxBid, itemId, sellerId);
                    with_bids[i++] = true;
                    waiting_ctr++;
                }
                // No bid on this item - set status to CLOSED
                else {
                    closed_ctr++;
                    with_bids[i++] = false;
                }
            } // FOR
            final VoltTable[] bidResults = voltExecuteSQL();
           
            // We have to do this extra step because H-Store doesn't have good support in the
            // query optimizer for LEFT OUTER JOINs
            int batch_size = 0;
            int bidResultsCtr = 0;
            for (i = 0; i < with_bids.length; i++) {
                long itemId = (Long)output_rows[i][0];
                long sellerId = (Long)output_rows[i][1];
                ItemStatus status = (with_bids[i] ? ItemStatus.WAITING_FOR_PURCHASE : ItemStatus.CLOSED);
                voltQueueSQL(updateItemStatus, status.ordinal(), currentTime, itemId, sellerId);
                if (debug)
                    LOG.debug(String.format("Updated Status for Item %d => %s", itemId, status));
               
                if (with_bids[i]) {
                    final VoltTable vt = bidResults[bidResultsCtr++];
View Full Code Here


            if (vt.hasColumn("i_status")) itemInfo.status = ItemStatus.get(vt.getLong("i_status"));
           
            UserId sellerId = new UserId(vt.getLong("i_u_id"));
            assert (itemId.getSellerId().equals(sellerId));
           
            ItemStatus qtype = profile.addItemToProperQueue(itemInfo, false);
            this.updated.put(qtype);

            return (itemId);
        }
View Full Code Here

        assert (adv);
       
        long i_num_bids = results[0].getLong("i_num_bids");
        double i_current_price = results[0].getDouble("i_current_price");
        TimestampType i_end_date = results[0].getTimestampAsTimestamp("i_end_date");
        ItemStatus i_status = ItemStatus.WAITING_FOR_PURCHASE;
        long ib_id = results[0].getLong("ib_id");
        long ib_buyer_id = results[0].getLong("ib_buyer_id");
        double u_balance = results[0].getDouble("u_balance");
       
        // Make sure that the buyer has enough money to cover this charge
        // We can add in a credit for the buyer's account
        if (i_current_price > (buyer_credit + u_balance)) {
            throw new VoltAbortException(String.format("Buyer does not have enough money in account to purchase item " +
                                                       "[maxBid=%.2f, balance=%.2f, credit=%.2f]",
                                                       i_current_price, u_balance, buyer_credit));
        }

        // Set item_purchase_id
        long ip_id = -1; // FIXME ItemId.getUniqueElementId(item_id, 1);

        // Insert a new purchase
        // System.err.println(String.format("NewPurchase: ip_id=%d, ib_bid=%.2f, item_id=%d, seller_id=%d", ip_id, ib_bid, item_id, seller_id));
        voltQueueSQL(insertPurchase, ip_id, ib_id, item_id, seller_id, currentTime);
       
        // Update item status to close
        voltQueueSQL(updateItem, currentTime, item_id, seller_id);
       
        // And update this the USER_ITEM record to link it to the new ITEM_PURCHASE record
        voltQueueSQL(updateUserItem, ip_id, ib_id, item_id, seller_id, ib_buyer_id, item_id, seller_id);
       
        // Decrement the buyer's account and credit the seller's account
        voltQueueSQL(updateUserBalance, -1*(i_current_price) + buyer_credit, ib_buyer_id);
        voltQueueSQL(updateUserBalance, i_current_price, seller_id);
       
        results = voltExecuteSQL();
        assert(results.length > 0);

        // Return ip_id, ip_ib_id, ip_ib_i_id, u_id, ip_ib_u_id
        VoltTable ret = new VoltTable(RESULT_COLS);
        ret.addRow(new Object[] {
            // ITEM ID
            item_id,
            // SELLER ID
            seller_id,
            // NUM BIDS
            i_num_bids,
            // CURRENT PRICE
            i_current_price,
            // END DATE
            i_end_date,
            // STATUS
            i_status.ordinal(),
            // PURCHASE ID
            ip_id,
            // BID ID
            ib_id,
            // BUYER ID
View Full Code Here

        assert (advRow);
        double i_initial_price = results[0].getDouble(0);
        double i_current_price = results[0].getDouble(1);
        long i_num_bids = results[0].getLong(2);
        TimestampType i_end_date = results[0].getTimestampAsTimestamp(3);
        ItemStatus i_status = ItemStatus.get(results[0].getLong(4));
        long newBidId = 0;
        long newBidMaxBuyerId = buyer_id;
       
        if (i_end_date.compareTo(currentTime) < 0 || i_status != ItemStatus.OPEN) {
            if (debug)
View Full Code Here

            int col = 0;
            ItemId i_id = new ItemId(vt.getLong(col++));
            double i_current_price = vt.getDouble(col++);
            TimestampType i_end_date = vt.getTimestampAsTimestamp(col++);
            int i_num_bids = (int)vt.getLong(col++);
            ItemStatus i_status = ItemStatus.get(vt.getLong(col++));
            assert(i_status == status);
           
            ItemInfo itemInfo = new ItemInfo(i_id, i_current_price, i_end_date, i_num_bids);
            this.addItemToProperQueue(itemInfo, false);
            ctr++;
View Full Code Here

        TimestampType baseTime = (is_loader ? this.getBenchmarkStartTime() :
                                              this.getCurrentTime());
        assert(itemInfo.endDate != null);
        assert(baseTime != null) : "is_loader=" + is_loader;
        long remaining = itemInfo.endDate.getMSTime() - baseTime.getMSTime();
        ItemStatus ret;
       
        // Already ended
        if (remaining <= 100000) {
            if (itemInfo.numBids > 0 && itemInfo.status != ItemStatus.CLOSED) {
                synchronized (this.previousWaitForPurchase) {
View Full Code Here

TOP

Related Classes of edu.brown.benchmark.auctionmark.AuctionMarkConstants.ItemStatus

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.