@Override public int hashCode() { return Objects.hash(column(), isCounterCell(), timestamp(), ttl(), localDeletionTime(), value(), path()); }
private String livenessInfoString() { if (isExpiring()) return String.format("ts=%d ttl=%d ldt=%d", timestamp(), ttl(), localDeletionTime()); else if (isTombstone()) return String.format("ts=%d ldt=%d", timestamp(), localDeletionTime()); else return String.format("ts=%d", timestamp()); }
public boolean isLive(int nowInSec) { return localDeletionTime() == NO_DELETION_TIME || (ttl() != NO_TTL && nowInSec < localDeletionTime()); }
@Override public String toString() { if (isCounterCell()) return String.format("[%s=%d ts=%d]", column().name, CounterContext.instance().total(value()), timestamp()); AbstractType<?> type = column().type; if (type instanceof CollectionType && type.isMultiCell()) { CollectionType ct = (CollectionType)type; return String.format("[%s[%s]=%s %s]", column().name, ct.nameComparator().getString(path().get(0)), ct.valueComparator().getString(value()), livenessInfoString()); } if (isTombstone()) return String.format("[%s=<tombstone> %s]", column().name, livenessInfoString()); else return String.format("[%s=%s %s]", column().name, type.getString(value()), livenessInfoString()); }
public Cell purge(DeletionPurger purger, int nowInSec) { if (!isLive(nowInSec)) { if (purger.shouldPurge(timestamp(), localDeletionTime())) return null; // We slightly hijack purging to convert expired but not purgeable columns to tombstones. The reason we do that is // that once a column has expired it is equivalent to a tombstone but actually using a tombstone is more compact since // we don't keep the column value. The reason we do it here is that 1) it's somewhat related to dealing with tombstones // so hopefully not too surprising and 2) we want to this and purging at the same places, so it's simpler/more efficient // to do both here. if (isExpiring()) { // Note that as long as the expiring column and the tombstone put together live longer than GC grace seconds, // we'll fulfil our responsibility to repair. See discussion at // http://cassandra-user-incubator-apache-org.3065146.n2.nabble.com/repair-compaction-and-tombstone-rows-td7583481.html return BufferCell.tombstone(column, timestamp(), localDeletionTime() - ttl(), path()); } } return this; }
public Cell updateAllTimestamp(long newTimestamp) { return new BufferCell(column, isTombstone() ? newTimestamp - 1 : newTimestamp, ttl(), localDeletionTime(), value(), path()); }
public void validate() { if (ttl() < 0) throw new MarshalException("A TTL should not be negative"); if (localDeletionTime() < 0) throw new MarshalException("A local deletion time should not be negative"); if (isExpiring() && localDeletionTime() == NO_DELETION_TIME) throw new MarshalException("Shoud not have a TTL without an associated local deletion time"); // non-frozen UDTs require both the cell path & value to validate, // so that logic is pushed down into ColumnDefinition. Tombstone // validation is done there too as it also involves the cell path // for complex columns column().validateCell(this); }
public long maxTimestamp() { return timestamp(); }
public boolean isCounterCell() { return !isTombstone() && column.isCounterColumn(); }
public boolean isExpiring() { return ttl() != NO_TTL; }
@Override public String toString() { if (isCounterCell()) return String.format("[%s=%d ts=%d]", column().name, CounterContext.instance().total(value()), timestamp()); AbstractType<?> type = column().type; if (type instanceof CollectionType && type.isMultiCell()) { CollectionType ct = (CollectionType)type; return String.format("[%s[%s]=%s %s]", column().name, ct.nameComparator().getString(path().get(0)), ct.valueComparator().getString(value()), livenessInfoString()); } if (isTombstone()) return String.format("[%s=<tombstone> %s]", column().name, livenessInfoString()); else return String.format("[%s=%s %s]", column().name, type.getString(value()), livenessInfoString()); }
public Cell purge(DeletionPurger purger, int nowInSec) { if (!isLive(nowInSec)) { if (purger.shouldPurge(timestamp(), localDeletionTime())) return null; // We slightly hijack purging to convert expired but not purgeable columns to tombstones. The reason we do that is // that once a column has expired it is equivalent to a tombstone but actually using a tombstone is more compact since // we don't keep the column value. The reason we do it here is that 1) it's somewhat related to dealing with tombstones // so hopefully not too surprising and 2) we want to this and purging at the same places, so it's simpler/more efficient // to do both here. if (isExpiring()) { // Note that as long as the expiring column and the tombstone put together live longer than GC grace seconds, // we'll fulfil our responsibility to repair. See discussion at // http://cassandra-user-incubator-apache-org.3065146.n2.nabble.com/repair-compaction-and-tombstone-rows-td7583481.html return BufferCell.tombstone(column, timestamp(), localDeletionTime() - ttl(), path()).purge(purger, nowInSec); } } return this; }
public Cell updateAllTimestamp(long newTimestamp) { return new BufferCell(column, isTombstone() ? newTimestamp - 1 : newTimestamp, ttl(), localDeletionTime(), value(), path()); }
public void validate() { if (ttl() < 0) throw new MarshalException("A TTL should not be negative"); if (localDeletionTime() < 0) throw new MarshalException("A local deletion time should not be negative"); if (isExpiring() && localDeletionTime() == NO_DELETION_TIME) throw new MarshalException("Shoud not have a TTL without an associated local deletion time"); // non-frozen UDTs require both the cell path & value to validate, // so that logic is pushed down into ColumnDefinition. Tombstone // validation is done there too as it also involves the cell path // for complex columns column().validateCell(this); }
public boolean isLive(int nowInSec) { return localDeletionTime() == NO_DELETION_TIME || (ttl() != NO_TTL && nowInSec < localDeletionTime()); }
public long maxTimestamp() { return timestamp(); }
public boolean isCounterCell() { return !isTombstone() && column.isCounterColumn(); }
public boolean isExpiring() { return ttl() != NO_TTL; }
@Override public int hashCode() { return Objects.hash(column(), isCounterCell(), timestamp(), ttl(), localDeletionTime(), value(), path()); }
@Override public String toString() { if (isCounterCell()) return String.format("[%s=%d ts=%d]", column().name, CounterContext.instance().total(value()), timestamp()); AbstractType<?> type = column().type; if (type instanceof CollectionType && type.isMultiCell()) { CollectionType ct = (CollectionType)type; return String.format("[%s[%s]=%s %s]", column().name, ct.nameComparator().getString(path().get(0)), ct.valueComparator().getString(value()), livenessInfoString()); } if (isTombstone()) return String.format("[%s=<tombstone> %s]", column().name, livenessInfoString()); else return String.format("[%s=%s %s]", column().name, type.getString(value()), livenessInfoString()); }