@SuppressWarnings("unchecked") public <O> O get(long key) { return (O) properties.get(key); }
@SuppressWarnings("unchecked") public <O> O get(long key) { return (O) properties.get(key); }
/** * Return true if all keys of some other container exist in this container. * Values are compared using {@link Objects#equals(Object)} method. */ protected boolean equalElements(LongObjectHashMap<?> other) { if (other.size() != size()) { return false; } for (LongObjectCursor<?> c : other) { long key = c.key; if (!containsKey(key) || !java.util.Objects.equals(get(key), c.value)) { return false; } } return true; }
/** * Marks this sequence number and returns {@code true} if it is seen before. */ boolean getAndSet(long value) { assert value >= 0; final long key = value / BIT_SET_SIZE; CountedBitSet bitset = bitSets.get(key); if (bitset == null) { bitset = new CountedBitSet(BIT_SET_SIZE); bitSets.put(key, bitset); } final int index = Math.toIntExact(value % BIT_SET_SIZE); final boolean wasOn = bitset.get(index); bitset.set(index); return wasOn; } }
/** * Checks if the given sequence number was marked as completed in this tracker. */ public boolean contains(final long seqNo) { assert seqNo >= 0 : "invalid seq_no=" + seqNo; if (seqNo >= nextSeqNo) { return false; } if (seqNo <= checkpoint) { return true; } final long bitSetKey = getBitSetKey(seqNo); final CountedBitSet bitSet; synchronized (this) { bitSet = processedSeqNo.get(bitSetKey); } return bitSet != null && bitSet.get(seqNoToBitSetOffset(seqNo)); }
@SuppressWarnings("unchecked") public <O> O get(long key) { return (O) properties.get(key); }
public void add(long id, long ts, long value) { Entry<Long,Long> entry = new SimpleEntry<>(ts, value); Deque<Entry<Long,Long>> list = data.get(id); if (list == null) { list = new ConcurrentLinkedDeque<>(); } list.add(entry); while (ts - list.peekFirst().getKey() > RETAIN_INTERVAL) { list.removeFirst(); } data.put(id, list); }
public Integer getTrailingAverage(long id, int seconds) { Deque<Entry<Long,Long>> list = data.get(id); if (list == null) { return null; } return getTrailingAverage(list, seconds); }
/** * Return true if all keys of some other container exist in this container. * Values are compared using {@link Objects#equals(Object)} method. */ protected boolean equalElements(LongObjectHashMap<?> other) { if (other.size() != size()) { return false; } for (LongObjectCursor<?> c : other) { long key = c.key; if (!containsKey(key) || !java.util.Objects.equals(get(key), c.value)) { return false; } } return true; }
private void updateCheckpoint() { assert Thread.holdsLock(this); assert getBitSetForSeqNo(checkpoint + 1).get(seqNoToBitSetOffset(checkpoint + 1)) : "updateCheckpoint is called but the bit following the checkpoint is not set"; try { CountedBitSet current = processedSeqNo.get(bitSetKey); if (current == null) { current = processedSeqNo.get(++bitSetKey); } while (current != null && current.get(seqNoToBitSetOffset(checkpoint + 1))); } finally {
/** * Marks this sequence number and returns {@code true} if it is seen before. */ boolean getAndSet(long value) { assert value >= 0; final long key = value / BIT_SET_SIZE; CountedBitSet bitset = bitSets.get(key); if (bitset == null) { bitset = new CountedBitSet(BIT_SET_SIZE); bitSets.put(key, bitset); } final int index = Math.toIntExact(value % BIT_SET_SIZE); final boolean wasOn = bitset.get(index); bitset.set(index); return wasOn; } }
/** * Marks this sequence number and returns {@code true} if it is seen before. */ boolean getAndSet(long value) { assert value >= 0; final long key = value / BIT_SET_SIZE; CountedBitSet bitset = bitSets.get(key); if (bitset == null) { bitset = new CountedBitSet(BIT_SET_SIZE); bitSets.put(key, bitset); } final int index = Math.toIntExact(value % BIT_SET_SIZE); final boolean wasOn = bitset.get(index); bitset.set(index); return wasOn; } }
/** * Checks if the given sequence number was marked as completed in this tracker. */ public boolean contains(final long seqNo) { assert seqNo >= 0 : "invalid seq_no=" + seqNo; if (seqNo >= nextSeqNo) { return false; } if (seqNo <= checkpoint) { return true; } final long bitSetKey = getBitSetKey(seqNo); final CountedBitSet bitSet; synchronized (this) { bitSet = processedSeqNo.get(bitSetKey); } return bitSet != null && bitSet.get(seqNoToBitSetOffset(seqNo)); }