@Override public boolean equals(Object obj) { if (!(obj instanceof ValueTimeWrapper)) { return false; } @SuppressWarnings("unchecked") ValueTimeWrapper<V> other = (ValueTimeWrapper<V>) obj; return timestamp == other.getTimestamp() && Objects.equals(value, other.getValue()) && counter == other.getCounter(); }
/** * Removes all entries from the map whose timestamp is smaller than the pruning timestamp. * * @param pruningTimestamp Timestamp for the pruning */ public void prune(long pruningTimestamp) { Iterator<Map.Entry<ValueTimeWrapper<V>, SharedBufferEntry<K, V>>> iterator = entries.entrySet().iterator(); boolean continuePruning = true; while (iterator.hasNext() && continuePruning) { SharedBufferEntry<K, V> entry = iterator.next().getValue(); if (entry.getValueTime().getTimestamp() <= pruningTimestamp) { iterator.remove(); } else { continuePruning = false; } } }
target.writeLong(valueTimeWrapper.getTimestamp()); target.writeInt(valueTimeWrapper.getCounter());
private int put( final K key, final V value, final long timestamp, final SharedBufferEntry<K, V> previousSharedBufferEntry, final DeweyNumber version) { SharedBufferPage<K, V> page = pages.get(key); if (page == null) { page = new SharedBufferPage<>(key); pages.put(key, page); } // this assumes that elements are processed in order (in terms of time) int counter = 0; if (previousSharedBufferEntry != null) { ValueTimeWrapper<V> prev = previousSharedBufferEntry.getValueTime(); if (prev != null && prev.getTimestamp() == timestamp) { counter = prev.getCounter() + 1; } } page.add(new ValueTimeWrapper<>(value, timestamp, counter), previousSharedBufferEntry, version); return counter; }
@Override public boolean equals(Object obj) { if (!(obj instanceof ValueTimeWrapper)) { return false; } @SuppressWarnings("unchecked") ValueTimeWrapper<V> other = (ValueTimeWrapper<V>) obj; return timestamp == other.getTimestamp() && Objects.equals(value, other.getValue()) && counter == other.getCounter(); }
@Override public boolean equals(Object obj) { if (!(obj instanceof ValueTimeWrapper)) { return false; } @SuppressWarnings("unchecked") ValueTimeWrapper<V> other = (ValueTimeWrapper<V>) obj; return timestamp == other.getTimestamp() && Objects.equals(value, other.getValue()) && counter == other.getCounter(); }
@Override public boolean equals(Object obj) { if (obj instanceof ValueTimeWrapper) { @SuppressWarnings("unchecked") ValueTimeWrapper<V> other = (ValueTimeWrapper<V>) obj; return timestamp == other.getTimestamp() && value.equals(other.getValue()) && counter == other.getCounter(); } else { return false; } }