@Override public boolean containsKey(LongWritable key) { return map.containsKey(key.get()); }
/** * Auxiliary method to be used by getTarget * * @param vertexId vertexId * @return return byte value of target */ public byte getByteTarget(LongWritable vertexId) { long key = vertexId.get() >>> lowerOrder; int suffix = (int) (vertexId.get() & lowerBitMask); if (!idToBytes.containsKey(key)) { return -1; } return idToBytes.get(key)[suffix]; }
@Override public boolean hasMessagesForVertex(LongWritable vertexId) { return getPartitionMap(vertexId).containsKey(vertexId.get()); }
/** * 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)); }
.flatMap(i -> itemToSessionByTimeMap.containsKey(i.longValue())?
protected <T> void checkAndStore(long entityId, Class<? super T> type) { if (isTransaction) { LongOpenHashSet entityAdded = added.get(type); if (entityAdded.contains(entityId)) return; T oldT = repository.get((Class<T>)type, entityId); Long2ObjectOpenHashMap<Object> data = snapshotted.get(type); if (oldT == null) { entityAdded.add(entityId); } else if (!data.containsKey(entityId)) { data.put(entityId, oldT); } } }
/** * Enter an order to this order book. * * <p>The incoming order is first matched against resting orders in this * order book. This operation results in zero or more Match events.</p> * * <p>If the remaining quantity is not zero after the matching operation, * the remaining quantity is added to this order book and an Add event is * triggered.</p> * * <p>If the order identifier is known, do nothing.</p> * * @param orderId an order identifier * @param side the side * @param price the limit price * @param size the size */ public void enter(long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) return; if (side == Side.BUY) buy(orderId, price, size); else sell(orderId, price, size); }
/** * Enter an order to this order book. * * <p>The incoming order is first matched against resting orders in this order book. This * operation results in zero or more Match events. * * <p>If the remaining quantity is not zero after the matching operation, the remaining quantity * is added to this order book and an Add event is triggered. * * <p>If the order identifier is known, do nothing. * * @param orderId an order identifier * @param side the side * @param price the limit price * @param size the size */ public void enter(long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) { return; } if (side == Side.BUY) { buy(orderId, price, size); } else { sell(orderId, price, size); } }
/** * Enter a market order. * * <p>The incoming order is matched against resting orders in the order * book. This operation results in zero or more Match events.</p> * * <p>If the remaining quantity is not zero after the matching operation, * a Cancel event is triggered for the remaining quantity.</p> * * <p>If the order identifier is known, do nothing.</p> * * @param orderId the order identifier * @param side the side * @param size the size */ public void enter(long orderId, Side side, long size) { if (orders.containsKey(orderId)) return; switch (side) { case BUY: match(orderId, side, asks, size); break; case SELL: match(orderId, side, bids, size); break; } }
/** * Enter a limit order. * * <p>The incoming order is first matched against resting orders in the * order book. This operation results in zero or more Match events.</p> * * <p>If the remaining quantity is not zero after the matching operation, * the remaining quantity is added to the order book and an Add event is * triggered.</p> * * <p>If the order identifier is known, do nothing.</p> * * @param orderId an order identifier * @param side the side * @param price the limit price * @param size the size */ public void enter(long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) return; switch (side) { case BUY: buy(orderId, price, size); break; case SELL: sell(orderId, price, size); break; } }
private boolean sanityCheck() { // kmer lookup is correct assert(byKmer.long2ObjectEntrySet().stream().allMatch(kvp -> kvp.getLongKey() == kvp.getValue().kmer)); // empty aggregators have been removed assert(byKmer.values().stream().allMatch(ag -> !ag.active.isEmpty())); // could have many start position entries, but only one position is valid (and even that could have duplicate entries) assert(byEnd.size() >= byKmer.size()); assert(byEnd.stream().allMatch(snapshot -> !snapshot.isValid() || byKmer.containsKey(snapshot.aggregator().kmer))); assert(byKmer.values().stream().allMatch(ag -> ag.end() >= inputPosition)); if (outputSortBuffer.isEmpty()) { assert(byKmer.isEmpty()); assert(byEnd.isEmpty()); assert(!underlying.hasNext()); } return true; } public int tracking_processedSize() {
/** * Add an order to the order book. * * <p>A BBO event is triggered if the top of the book changes.</p> * * <p>If the order book for the instrument is closed or the order * identifier is known, do nothing.</p> * * @param instrument the instrument * @param orderId the order identifier * @param side the side * @param price the price * @param size the size */ public void add(long instrument, long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) return; OrderBook book = books.get(instrument); if (book == null) return; Order order = book.add(side, price, size); orders.put(orderId, order); if (order.isOnBestLevel()) book.bbo(listener); }
/** * Add an order to an order book. * * <p>An update event is triggered.</p> * * <p>If the order book for the instrument is closed or the order * identifier is known, do nothing.</p> * * @param instrument the instrument * @param orderId the order identifier * @param side the side * @param price the price * @param size the size */ public void add(long instrument, long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) return; OrderBook book = books.get(instrument); if (book == null) return; Order order = new Order(book, side, price, size); boolean bbo = book.add(side, price, size); orders.put(orderId, order); listener.update(book, bbo); }
/** * Add an order to an order book. * * <p>An update event is triggered. * * <p>If the order book for the instrument is closed or the order identifier is known, do nothing. * * @param instrument the instrument * @param orderId the order identifier * @param side the side * @param price the price * @param size the size */ public void add(long instrument, long orderId, Side side, long price, long size) { if (orders.containsKey(orderId)) { return; } OrderBook book = books.get(instrument); if (book == null) { return; } Order order = new Order(book, side, price, size); boolean bbo = book.add(side, price, size); orders.put(orderId, order); listener.update(book, bbo); }
if (!users.containsKey(userId)) { users.put(userId, screenname); long hashtagHash = (long)entity.getText().toLowerCase().hashCode(); tweetHashtagBigraph.addEdge(tweetId, hashtagHash, (byte) 0); if (!hashtags.containsKey(hashtagHash)) { hashtags.put(hashtagHash, entity.getText().toLowerCase());
/** * Get list for the current vertexId * * @param iterator vertexId iterator * @return list for current vertexId */ protected L getList( VertexIdIterator<LongWritable> iterator) { PartitionOwner owner = service.getVertexPartitionOwner(iterator.getCurrentVertexId()); long vertexId = iterator.getCurrentVertexId().get(); int partitionId = owner.getPartitionId(); Long2ObjectOpenHashMap<L> partitionMap = map.get(partitionId); if (!partitionMap.containsKey(vertexId)) { synchronized (nascentMap) { // assumption: not many nascent vertices are created // so overall synchronization is negligible Long2ObjectOpenHashMap<L> nascentPartitionMap = nascentMap.get(partitionId); if (nascentPartitionMap.get(vertexId) == null) { nascentPartitionMap.put(vertexId, createList()); } return nascentPartitionMap.get(vertexId); } } return partitionMap.get(vertexId); }