private void removeNodeKeySlots(String key) { long[] hashes = nodeKeyHashes.get(key); for (long hash : hashes) { nodeKeySlots.remove(hash); } } }
private void removeNodeKeySlots(String key) { long[] hashes = nodeKeyHashes.get(key); for (long hash : hashes) { nodeKeySlots.remove(hash); } } }
private void removeNodeKeySlots(String key) { long[] hashes = nodeKeyHashes.get(key); for (long hash : hashes) { nodeKeySlots.remove(hash); } } }
public void delete(Level level) { levels.remove(level.getPrice()); }
public void delete(Level level) { levels.remove(level.getPrice()); }
@Nullable public MinKSet<RowSnapshot> add(@Nullable MinKSet<RowSnapshot>left, @Nullable MinKSet<RowSnapshot> right) { assert left != null; assert right != null; Comparator<RowSnapshot> comp = left.comp; RowSnapshot minRS, maxRS; long present = left.presentCount + right.presentCount; if (left.presentCount == 0) { minRS = right.min; maxRS = right.max; } else if (right.presentCount == 0) { minRS = right.min; maxRS = right.max; } else { minRS = comp.compare(left.min, right.min) < 0 ? left.min : right.min; maxRS = comp.compare(left.max, right.max) > 0 ? left.max : right.max; } Long2ObjectRBTreeMap<RowSnapshot> data = new Long2ObjectRBTreeMap<>(); data.putAll(left.data); data.putAll(right.data); while (data.size() > this.numSamples) { long maxKey = data.lastLongKey(); data.remove(maxKey); } return new MinKSet<RowSnapshot>(this.numSamples, data, comp, minRS, maxRS, present, 0); } }
while (data.size() > this.maxSize) { long maxKey = data.lastLongKey(); data.remove(maxKey);
private void buy(long orderId, long price, long size) { long remainingQuantity = size; PriceLevel bestLevel = getBestLevel(asks); while (remainingQuantity > 0 && bestLevel != null && bestLevel.getPrice() <= price) { remainingQuantity = bestLevel.match(orderId, Side.BUY, remainingQuantity, orders, listener); if (bestLevel.isEmpty()) asks.remove(bestLevel.getPrice()); bestLevel = getBestLevel(asks); } if (remainingQuantity > 0) { orders.put(orderId, add(bids, orderId, Side.BUY, price, remainingQuantity)); listener.add(orderId, Side.BUY, price, remainingQuantity); } }
private void sell(long orderId, long price, long size) { long remainingQuantity = size; PriceLevel bestLevel = getBestLevel(bids); while (remainingQuantity > 0 && bestLevel != null && bestLevel.getPrice() >= price) { remainingQuantity = bestLevel.match(orderId, Side.SELL, remainingQuantity, orders, listener); if (bestLevel.isEmpty()) bids.remove(bestLevel.getPrice()); bestLevel = getBestLevel(bids); } if (remainingQuantity > 0) { orders.put(orderId, add(asks, orderId, Side.SELL, price, remainingQuantity)); listener.add(orderId, Side.SELL, price, remainingQuantity); } }
private void buy(long orderId, long price, long size) { long remainingQuantity = size; PriceLevel bestLevel = getBestLevel(asks); while (remainingQuantity > 0 && bestLevel != null && bestLevel.price() <= price) { remainingQuantity = bestLevel.match(orderId, Side.BUY, remainingQuantity, matchListener); if (bestLevel.isEmpty()) { asks.remove(bestLevel.price()); } bestLevel = getBestLevel(asks); } if (remainingQuantity > 0) { orders.put(orderId, add(bids, orderId, Side.BUY, price, remainingQuantity)); addListener.onNext(new AddOrder(orderId, Side.BUY, price, remainingQuantity)); } }
private void sell(long orderId, long price, long size) { long remainingQuantity = size; PriceLevel bestLevel = getBestLevel(bids); while (remainingQuantity > 0 && bestLevel != null && bestLevel.price() >= price) { remainingQuantity = bestLevel.match(orderId, Side.SELL, remainingQuantity, matchListener); if (bestLevel.isEmpty()) { bids.remove(bestLevel.price()); } bestLevel = getBestLevel(bids); } if (remainingQuantity > 0) { orders.put(orderId, add(asks, orderId, Side.SELL, price, remainingQuantity)); addListener.onNext(new AddOrder(orderId, Side.SELL, price, remainingQuantity)); } }