public Object put(long id, Object v) { Object result; if (id == 0) { throw new IllegalArgumentException(); } else if (id > 0 && id <= 0x00000000FFFFFFFFL) { result = this.ints.put((int) id, v); } else { result = this.longs.put(id, v); } return result; }
@Override public void record(long key) { policyStats.recordOperation(); Node node = data.get(key); if (node == null) { node = new Node(key); data.put(key,node); onMiss(node); } else if (node.status == Status.FILTER) { onFilterHit(node); } else if (node.status == Status.MAIN) { onMainHit(node); } else if (node.status == Status.NON_RESIDENT) { onNonResidentHit(node); } else { throw new IllegalStateException(); } }
private void adaptFilterToMain(Node node) { /** * Cache miss and history hit with adaptation: * Evict from filter stack. Then insert to main stack. */ policyStats.recordEviction(); policyStats.recordMiss(); Node victim = headFilter.prevFilter; victim.removeFrom(StackType.FILTER); if (victim.isInMain) { victim.status = Status.NON_RESIDENT; } else { data.remove(victim.key); } residentFilter--; node.moveToTop(StackType.MAIN); node.status = Status.MAIN; data.put(node.key, node); residentMain++; }
private void adaptFilterToMain(Node node) { /** * Cache miss and history hit with adaptation: * Evict from filter stack. Then insert to main stack */ policyStats.recordEviction(); policyStats.recordMiss(); missesInSample++; sample++; Node victim = headFilter.prevFilter; victim.removeFrom(StackType.FILTER); if (victim.isInMain) { victim.status = Status.NON_RESIDENT; } else { data.remove(victim.key); } residentFilter--; node.moveToTop(StackType.MAIN); node.status = Status.MAIN; data.put(node.key, node); residentMain++; }
@Override public void record(long key) { policyStats.recordOperation(); adapt(key); Node node = data.get(key); if (node == null) { node = new Node(key); data.put(key, node); onMiss(node); } else if (node.status == Status.FILTER) { onFilterHit(node); } else if (node.status == Status.MAIN) { onMainHit(node); } else if (node.status == Status.NON_RESIDENT) { if (residentMain < maximumMainResidentSize) { checkState(residentFilter > maximumFilterSize); adaptFilterToMain(node); } else { onNonResidentHit(node); } } else { throw new IllegalStateException(); } }
@Override public void record(long key) { policyStats.recordOperation(); adapt(); Node node = data.get(key); if (node == null) { node = new Node(key); data.put(key, node); onMiss(node); } else if (node.status == Status.FILTER) { onFilterHit(node); } else if (node.status == Status.MAIN) { onMainHit(node); } else if (node.status == Status.NON_RESIDENT) { if (residentMain < maximumMainResidentSize) { checkState(residentFilter > maximumFilterSize); adaptFilterToMain(node); } else { onNonResidentHit(node); } } else { throw new IllegalStateException(); } }
private void onNonResidentHit(Node node) { // Cache miss but history hit: Remove all history blocks between the 2nd oldest and the oldest // resident blocks. Next, evict the oldest resident block from the reuse distance stack. Then, // move the history hit block to the MRU position in the reuse distance stack and change it to a // resident block. No insertion or eviction occurs in the filter stack. policyStats.recordEviction(); policyStats.recordMiss(); pruneStack(); Node victim = headMain.prevMain; victim.removeFrom(StackType.MAIN); data.remove(victim.key); pruneStack(); node.moveToTop(StackType.MAIN); node.status = Status.MAIN; data.put(node.key, node); }
private void onNonResidentHit(Node node) { /** * Cache miss but history hit: Remove all history blocks between the 2nd oldest and the oldest * resident blocks. Next, evict the oldest resident block from the reuse distance stack. Then, * move the history hit block to the MRU position in the reuse distance stack and change it to a * resident block. No insertion or eviction occurs in the filter stack. */ policyStats.recordEviction(); policyStats.recordMiss(); pruneStack(); Node victim = headMain.prevMain; victim.removeFrom(StackType.MAIN); data.remove(victim.key); pruneStack(); node.moveToTop(StackType.MAIN); node.status = Status.MAIN; data.put(node.key, node); }
private void onNonResidentHit(Node node) { /** * Cache miss but history hit: Remove all history blocks between the 2nd oldest and the oldest * resident blocks. Next, evict the oldest resident block from the reuse distance stack. Then, * move the history hit block to the MRU position in the reuse distance stack and change it to a * resident block. No insertion or eviction occurs in the filter stack. */ policyStats.recordEviction(); policyStats.recordMiss(); missesInSample++; sample++; pruneStack(); Node victim = headMain.prevMain; victim.removeFrom(StackType.MAIN); data.remove(victim.key); pruneStack(); node.moveToTop(StackType.MAIN); node.status = Status.MAIN; data.put(node.key, node); }
for (LongIterator iter = items.iterator(); iter.hasNext();) { long item = iter.nextLong(); heaps.put(item, SortedListAccumulator.decreasing(neighborhoodSize, Neighbor.SIMILARITY_COMPARATOR));
@Override public <T> T store(long entityId, Class<? super T> type, T entity) { map.get(type).put(entityId, entity); return entity; }
@Override public <T> T store(long entityId, T entity) { map.get(entity.getClass()).put(entityId, entity); return entity; }
@Override public void postFilling() { // not thread-safe for (Long id : concurrentIdToBytes.keySet()) { idToBytes.put(id, concurrentIdToBytes.get(id)); } concurrentIdToBytes.clear(); concurrentIdToBytes = null; }
public Object put(long id, Object v) { Object result; if (id == 0) { throw new IllegalArgumentException(); } else if (id > 0 && id <= 0x00000000FFFFFFFFL) { result = this.ints.put((int) id, v); } else { result = this.longs.put(id, v); } return result; }
@Override public void readFields(DataInput in) throws IOException { int size = in.readInt(); map.clear(); map.trim(size); while (size-- > 0) { long key = in.readLong(); V value = valueWriter.readFields(in); map.put(key, value); } } }
/** * Open an order book. * * <p>If the order book for the instrument is already open, do nothing.</p> * * @param instrument an instrument */ public void open(long instrument) { if (books.containsKey(instrument)) return; books.put(instrument, new OrderBook(instrument)); }
private void track(Order order) { orders.put(order.getOrderNumber(), order); order.getSession().track(order); }
private void addToLookup(int offset, long kmer, int start, int end, Long2ObjectOpenHashMap<RangeMap<Integer, Integer>> lookup) { RangeMap<Integer, Integer> rm = lookup.get(kmer); if (rm == null) { rm = TreeRangeMap.create(); lookup.put(kmer, rm); } rm.put(Range.closedOpen(start, end + 1), offset); } }
private void sell(long orderId, long price, long size) { long remainingQuantity = size; Level top = bids.getBestLevel(); while (remainingQuantity > 0 && top != null && top.getPrice() >= price) { remainingQuantity = top.match(orderId, Side.SELL, remainingQuantity, listener); top = bids.getBestLevel(); } if (remainingQuantity > 0) { orders.put(orderId, asks.add(orderId, price, remainingQuantity)); listener.add(orderId, Side.SELL, price, remainingQuantity); } }
private void buy(long orderId, long price, long size) { long remainingQuantity = size; Level top = asks.getBestLevel(); while (remainingQuantity > 0 && top != null && top.getPrice() <= price) { remainingQuantity = top.match(orderId, Side.BUY, remainingQuantity, listener); top = asks.getBestLevel(); } if (remainingQuantity > 0) { orders.put(orderId, bids.add(orderId, price, remainingQuantity)); listener.add(orderId, Side.BUY, price, remainingQuantity); } }