Esempio n. 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;
    }
  }
Esempio n. 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();
 }
Esempio n. 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;
  }
Esempio n. 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);
 }
Esempio n. 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);
  }
Esempio n. 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());
 }
Esempio n. 7
0
 public DeletionInfo copy() {
   return new DeletionInfo(topLevel, ranges == null ? null : ranges.copy());
 }
Esempio n. 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);
  }
Esempio n. 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());
 }
Esempio n. 10
0
 public boolean hasRanges() {
   return ranges != null && !ranges.isEmpty();
 }
Esempio n. 11
0
 public int dataSize() {
   int size = TypeSizes.NATIVE.sizeof(topLevel.markedForDeleteAt);
   return size + (ranges == null ? 0 : ranges.dataSize());
 }
Esempio n. 12
0
 public DeletionTime rangeCovering(ByteBuffer name) {
   return ranges == null ? null : ranges.search(name);
 }
Esempio n. 13
0
 // Use sparingly, not the most efficient thing
 public Iterator<RangeTombstone> rangeIterator() {
   return ranges == null ? Iterators.<RangeTombstone>emptyIterator() : ranges.iterator();
 }
Esempio n. 14
0
 /** The maximum timestamp mentioned by this DeletionInfo. */
 public long maxTimestamp() {
   return ranges == null
       ? topLevel.markedForDeleteAt
       : Math.max(topLevel.markedForDeleteAt, ranges.maxMarkedAt());
 }
Esempio n. 15
0
  public void add(RangeTombstone tombstone, Comparator<ByteBuffer> comparator) {
    if (ranges == null) ranges = new RangeTombstoneList(comparator, 1);

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

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