private void addNodeKeySlots(String key) { long[] hashes = nodeKeyHashes.get(key); for (long hash : hashes) { nodeKeySlots.put(hash, key); } }
private void removeNodeKeySlots(String key) { long[] hashes = nodeKeyHashes.get(key); for (long hash : hashes) { nodeKeySlots.remove(hash); } } }
public String findKey(byte[] obj) { if (nodeKeySlots.size() == 0) { return null; } long objHash = hashFn.hashBytes(obj).asLong(); Long2ObjectSortedMap<String> subMap = nodeKeySlots.tailMap(objHash); if (subMap.isEmpty()) { return nodeKeySlots.long2ObjectEntrySet().first().getValue(); } Long2ObjectMap.Entry<String> firstEntry = subMap.long2ObjectEntrySet().first(); return firstEntry.getValue(); }
@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); } }
private PriceLevel getBestLevel(Long2ObjectRBTreeMap<PriceLevel> levels) { if (levels.isEmpty()) return null; return levels.get(levels.firstLongKey()); }
Long2ObjectRBTreeMap<String> map = new Long2ObjectRBTreeMap<String>(); for (long hashKey: mkRows.hashMap.keySet()) map.put(hashKey, col.getString(mkRows.hashMap.get(hashKey))); return new MinKSet<String>(this.maxSize, map, Comparator.naturalOrder(), minString, maxString, numPresent, numMissing);
public Orders(OrderBook parent, Side side, LongComparator priceComparator) { this.parent = parent; this.side = side; this.levels = new Long2ObjectRBTreeMap<>(priceComparator); }
public void scoreDocument() { result = new HashMap<Long, Long>(); long[] us = uids; int size = uids.length; for (int i = 0; i < size; i++) { long uid = us[i]; String d = data.get(uid); Iterator<String> iterator = Splitter.on("_").split(d).iterator(); long created = Long.parseLong(iterator.next()); long cfav = Long.parseLong(iterator.next()); long zfavctu = Long.parseLong(iterator.next()); long zeditor = Long.parseLong(iterator.next()); long score = getValue(created, cfav, zfavctu, zeditor); result.put(uid, score); } }
/** * Returns true if we have fewer or equal strings to the number of buckets. * @param buckets Number of buckets we want. */ public boolean allStringsKnown(int buckets) { if (this.min == null) // no non-null values return true; return this.data.size() <= buckets; }
maxString = (left.max.compareTo(right.max) > 0) ? left.max : right.max; Long2ObjectRBTreeMap<String> data = new Long2ObjectRBTreeMap<>(); data.putAll(left.data); data.putAll(right.data); while (data.size() > this.maxSize) { long maxKey = data.lastLongKey(); data.remove(maxKey);
private PriceLevel getBestLevel(Long2ObjectRBTreeMap<PriceLevel> levels) { if (levels.isEmpty()) { return null; } return levels.get(levels.firstLongKey()); }
currRow = rowIt.getNextRow(); Long2ObjectRBTreeMap<RowSnapshot> hMap = new Long2ObjectRBTreeMap<RowSnapshot>(); for (long hashKey: mkRows.hashMap.keySet()) hMap.put(hashKey, new RowSnapshot(data, mkRows.hashMap.get(hashKey), schema)); RowSnapshot minRS = new RowSnapshot(data, minRow, schema); RowSnapshot maxRS = new RowSnapshot(data, maxRow, schema);
MinKSet(int maxSize, Comparator<T> comp) { this.maxSize = maxSize; this.comp = comp; this.data = new Long2ObjectRBTreeMap<T>(); this.min = null; this.max = null; this.presentCount = 0; this.missingCount = 0; }
public int size() { return this.data.size(); }
public Level getBestLevel() { if (levels.isEmpty()) return null; return levels.get(levels.firstLongKey()); }
private void removeNodeKeySlots(String key) { long[] hashes = nodeKeyHashes.get(key); for (long hash : hashes) { nodeKeySlots.remove(hash); } } }
@Override protected Long2ObjectRBTreeMap<V> create(Kryo kryo, Input input, Class<? extends Long2ObjectRBTreeMap<V>> type, int size, LongComparator comparator) { return new Long2ObjectRBTreeMap<V>(comparator); } }