diff --git a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkProfile.java b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkProfile.java index 214d576d4..fb3a38f00 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkProfile.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkProfile.java @@ -746,8 +746,8 @@ public void updateItemQueues() { continue; } - for (ItemInfo itemInfo : items) { - this.addItemToProperQueue(itemInfo, currentTime); + for (Iterator it = items.iterator(); it.hasNext();) { + this.addItemToProperQueue(it.next(), currentTime, it); } } @@ -767,10 +767,10 @@ public ItemStatus addItemToProperQueue(ItemInfo itemInfo, boolean is_loader) { Timestamp baseTime = (is_loader ? this.getLoaderStartTime() : this.getCurrentTime()); - return addItemToProperQueue(itemInfo, baseTime); + return addItemToProperQueue(itemInfo, baseTime, null); } - private ItemStatus addItemToProperQueue(ItemInfo itemInfo, Timestamp baseTime) { + private ItemStatus addItemToProperQueue(ItemInfo itemInfo, Timestamp baseTime, Iterator currentQueueIterator) { // Always check whether we even want it for this client // The loader's profile and the cache profile will always have a negative client_id, // which means that we always want to keep it @@ -799,30 +799,25 @@ private ItemStatus addItemToProperQueue(ItemInfo itemInfo, Timestamp baseTime) { if (!new_status.equals(existingStatus)) { + // Remove the item from the current queue + if (currentQueueIterator != null) { + currentQueueIterator.remove(); + } + switch (new_status) { case OPEN: this.addItem(this.items_available, itemInfo); break; case ENDING_SOON: - this.items_available.remove(itemInfo); this.addItem(this.items_endingSoon, itemInfo); break; case WAITING_FOR_PURCHASE: - (existingStatus == ItemStatus.OPEN ? this.items_available : this.items_endingSoon).remove(itemInfo); this.addItem(this.items_waitingForPurchase, itemInfo); break; case CLOSED: - if (existingStatus == ItemStatus.OPEN) { - this.items_available.remove(itemInfo); - } else if (existingStatus == ItemStatus.ENDING_SOON) { - this.items_endingSoon.remove(itemInfo); - } else { - this.items_waitingForPurchase.remove(itemInfo); - } this.addItem(this.items_completed, itemInfo); break; default: - } itemInfo.setStatus(new_status); }