예제 #1
0
  /**
   * 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;
    }
  }
예제 #2
0
 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();
 }
예제 #3
0
  /**
   * 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;
  }
예제 #4
0
 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);
 }
예제 #5
0
  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);
  }
예제 #6
0
 /** 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());
 }
예제 #7
0
 public DeletionInfo copy() {
   return new DeletionInfo(topLevel, ranges == null ? null : ranges.copy());
 }
예제 #8
0
  // 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);
  }
예제 #9
0
 @Override
 public String toString() {
   if (ranges == null || ranges.isEmpty()) return String.format("{%s}", topLevel);
   else return String.format("{%s, ranges=%s}", topLevel, rangesAsString());
 }
예제 #10
0
 public boolean hasRanges() {
   return ranges != null && !ranges.isEmpty();
 }
예제 #11
0
 public int dataSize() {
   int size = TypeSizes.NATIVE.sizeof(topLevel.markedForDeleteAt);
   return size + (ranges == null ? 0 : ranges.dataSize());
 }
예제 #12
0
 public DeletionTime rangeCovering(ByteBuffer name) {
   return ranges == null ? null : ranges.search(name);
 }
예제 #13
0
 // Use sparingly, not the most efficient thing
 public Iterator<RangeTombstone> rangeIterator() {
   return ranges == null ? Iterators.<RangeTombstone>emptyIterator() : ranges.iterator();
 }
예제 #14
0
 /** The maximum timestamp mentioned by this DeletionInfo. */
 public long maxTimestamp() {
   return ranges == null
       ? topLevel.markedForDeleteAt
       : Math.max(topLevel.markedForDeleteAt, ranges.maxMarkedAt());
 }
예제 #15
0
  public void add(RangeTombstone tombstone, Comparator<ByteBuffer> comparator) {
    if (ranges == null) ranges = new RangeTombstoneList(comparator, 1);

    ranges.add(tombstone);
  }
예제 #16
0
  public boolean hasIrrelevantData(int gcBefore) {
    if (topLevel.localDeletionTime < gcBefore) return true;

    return ranges != null && ranges.hasIrrelevantData(gcBefore);
  }