/** * Purge every tombstones that are older than {@code gcbefore}. * * @param gcBefore timestamp (in seconds) before which tombstones should be purged */ public void purge(int gcBefore) { topLevel = topLevel.localDeletionTime < gcBefore ? DeletionTime.LIVE : topLevel; if (ranges != null) { ranges.purge(gcBefore); if (ranges.isEmpty()) ranges = null; } }
private String rangesAsString() { assert !ranges.isEmpty(); StringBuilder sb = new StringBuilder(); AbstractType at = (AbstractType) ranges.comparator(); assert at != null; Iterator<RangeTombstone> iter = rangeIterator(); while (iter.hasNext()) { RangeTombstone i = iter.next(); sb.append("["); sb.append(at.getString(i.min)).append("-"); sb.append(at.getString(i.max)).append(", "); sb.append(i.data); sb.append("]"); } return sb.toString(); }
/** * Adds the provided deletion infos to the current ones. * * @return this object. */ public DeletionInfo add(DeletionInfo newInfo) { add(newInfo.topLevel); if (ranges == null) ranges = newInfo.ranges == null ? null : newInfo.ranges.copy(); else if (newInfo.ranges != null) ranges.addAll(newInfo.ranges); return this; }
public DeletionInfo( ByteBuffer start, ByteBuffer end, Comparator<ByteBuffer> comparator, long markedForDeleteAt, int localDeletionTime) { this(DeletionTime.LIVE, new RangeTombstoneList(comparator, 1)); ranges.add(start, end, markedForDeleteAt, localDeletionTime); }
public boolean isDeleted(ByteBuffer name, long timestamp) { // We do rely on this test: if topLevel.markedForDeleteAt is MIN_VALUE, we should not // consider the column deleted even if timestamp=MIN_VALUE, otherwise this break // QueryFilter.isRelevant if (isLive()) return false; if (timestamp <= topLevel.markedForDeleteAt) return true; return ranges != null && ranges.isDeleted(name, timestamp); }
/** Returns whether this DeletionInfo is live, that is deletes no columns. */ public boolean isLive() { return topLevel.markedForDeleteAt == Long.MIN_VALUE && topLevel.localDeletionTime == Integer.MAX_VALUE && (ranges == null || ranges.isEmpty()); }
public DeletionInfo copy() { return new DeletionInfo(topLevel, ranges == null ? null : ranges.copy()); }
// Updates all the timestamp of the deletion contained in this DeletionInfo to be {@code // timestamp}. public void updateAllTimestamp(long timestamp) { if (topLevel.markedForDeleteAt != Long.MIN_VALUE) topLevel = new DeletionTime(timestamp, topLevel.localDeletionTime); if (ranges != null) ranges.updateAllTimestamp(timestamp); }
@Override public String toString() { if (ranges == null || ranges.isEmpty()) return String.format("{%s}", topLevel); else return String.format("{%s, ranges=%s}", topLevel, rangesAsString()); }
public boolean hasRanges() { return ranges != null && !ranges.isEmpty(); }
public int dataSize() { int size = TypeSizes.NATIVE.sizeof(topLevel.markedForDeleteAt); return size + (ranges == null ? 0 : ranges.dataSize()); }
public DeletionTime rangeCovering(ByteBuffer name) { return ranges == null ? null : ranges.search(name); }
// Use sparingly, not the most efficient thing public Iterator<RangeTombstone> rangeIterator() { return ranges == null ? Iterators.<RangeTombstone>emptyIterator() : ranges.iterator(); }
/** The maximum timestamp mentioned by this DeletionInfo. */ public long maxTimestamp() { return ranges == null ? topLevel.markedForDeleteAt : Math.max(topLevel.markedForDeleteAt, ranges.maxMarkedAt()); }
public void add(RangeTombstone tombstone, Comparator<ByteBuffer> comparator) { if (ranges == null) ranges = new RangeTombstoneList(comparator, 1); ranges.add(tombstone); }
public boolean hasIrrelevantData(int gcBefore) { if (topLevel.localDeletionTime < gcBefore) return true; return ranges != null && ranges.hasIrrelevantData(gcBefore); }