AllocationMetricCollector(Method method, ThreadMXBean threadMXBean) { this.getThreadAllocatedBytes = method; this.threadMXBean = threadMXBean; previousResults = new Long2LongOpenHashMap(); previousResults.defaultReturnValue(NO_DATA); }
private void addHash(long hash) { short value = minhash.get(hash); if (value < Short.MAX_VALUE) { minhash.put(hash, (short) (value + 1)); } while (minhash.size() > maxHashes) { minhash.remove(minhash.lastLongKey()); } }
@Override public void swap(int a, int b) { long[] elements = valueAddresses.elements(); long temp = elements[a]; elements[a] = elements[b]; elements[b] = temp; }
private static long[] filterLongs(LongSet longSet, long[] source) { LongList longList = new LongArrayList(); for (long value : source) { if (longSet.contains(value)) { longList.add(value); } } if (longList.size() == source.length) { return source; } else { return longList.toLongArray(); } }
public LongToIdMap() { _valueToIdMap = new Long2IntOpenHashMap(); _valueToIdMap.defaultReturnValue(INVALID_KEY); _idToValueMap = new LongArrayList(); }
private LongList getTimers(Node<?, ?> sentinel) { LongList timers = new LongArrayList(); for (Node<?, ?> node = sentinel.getNextInVariableOrder(); node != sentinel; node = node.getNextInVariableOrder()) { timers.add(node.getVariableTime()); } return timers; }
@Override public void open() { tempOut = new LongArrayList(); }
@Override public Long2ObjectMap<Aggregator[]> makeDimExtractionAggregateStore() { return new Long2ObjectOpenHashMap<>(); }
public void mergeWith(SetDigest other) { hll.mergeWith(other.hll); LongBidirectionalIterator iterator = other.minhash.keySet().iterator(); while (iterator.hasNext()) { long key = iterator.nextLong(); int count = minhash.get(key) + other.minhash.get(key); minhash.put(key, Shorts.saturatedCast(count)); } while (minhash.size() > maxHashes) { minhash.remove(minhash.lastLongKey()); } }
public int getPositionCount() { return addresses.size(); }
private void reset() { for (Long2IntMap.Entry entry : counts.long2IntEntrySet()) { entry.setValue(entry.getIntValue() / 2); } size = (size / 2); } }
/** Removes the node from the table and adds the index to the free list. */ private void removeFromTable(Node node) { int last = data.size() - 1; table[node.index] = table[last]; table[node.index].index = node.index; table[last] = null; }
@Override public int frequency(long e) { return counts.get(e); }
public static double jaccardIndex(SetDigest a, SetDigest b) { int sizeOfSmallerSet = Math.min(a.minhash.size(), b.minhash.size()); LongSortedSet minUnion = new LongRBTreeSet(a.minhash.keySet()); minUnion.addAll(b.minhash.keySet()); int intersection = 0; int i = 0; for (long key : minUnion) { if (a.minhash.containsKey(key) && b.minhash.containsKey(key)) { intersection++; } i++; if (i >= sizeOfSmallerSet) { break; } } return intersection / (double) sizeOfSmallerSet; }
@Override public int metaSize() { return 1 + 1 + 1 + Integer.BYTES + (table.size() * Long.BYTES); }
private long toAbsolutePosition(short blockId, int position) { return sumPositions.get(blockId) + position; }
public static boolean in(long longValue, LongOpenCustomHashSet set) { return set.contains(longValue); }
public boolean isExact() { // There's an ambiguity when minhash.size() == maxHashes, since this could either // be an exact set with maxHashes elements, or an inexact one. Which is why strict // inequality is used here. return minhash.size() < maxHashes; }
@Override public Long2ObjectMap<Aggregator[]> makeDimExtractionAggregateStore() { return new Long2ObjectOpenHashMap<>(); }