@Override public Collection<Mutation> augment(ByteBuffer key, ColumnFamily update) { if (!update.deletionInfo().isLive()) { System.out.println("Delete Operation"); } else { System.out.println("Insert Operation"); } }
@Override public int hashCode() { HashCodeBuilder builder = new HashCodeBuilder(373, 75437) .append(metadata) .append(deletionInfo()); for (Cell cell : this) builder.append(cell); return builder.toHashCode(); }
/** * Returns a {@link DeletionInfo.InOrderTester} for the deletionInfo() of * this column family. Please note that for ThreadSafe implementation of ColumnFamily, * this tester will remain valid even if new tombstones are added to this ColumnFamily * *as long as said addition is done in comparator order*. For AtomicSortedColumns, * the tester will correspond to the state of when this method is called. */ public DeletionInfo.InOrderTester inOrderDeletionTester() { return deletionInfo().inOrderTester(); }
/** * If `columns` has any tombstones (top-level or range tombstones), they will be applied to this set of columns. */ public void delete(ColumnFamily columns) { delete(columns.deletionInfo()); }
public boolean isMarkedForDelete() { return !deletionInfo().isLive(); }
@Override public String toString() { StringBuilder sb = new StringBuilder("ColumnFamily("); sb.append(metadata.cfName); if (isMarkedForDelete()) sb.append(" -").append(deletionInfo()).append("-"); sb.append(" [").append(CellNames.getColumnsString(getComparator(), this)).append("])"); return sb.toString(); }
public long maxTimestamp() { long maxTimestamp = deletionInfo().maxTimestamp(); for (Cell cell : this) maxTimestamp = Math.max(maxTimestamp, cell.timestamp()); return maxTimestamp; }
/** * Returns true if this contains no columns or deletion info */ public boolean isEmpty() { return deletionInfo().isLive() && !hasColumns(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof ColumnFamily)) return false; ColumnFamily comparison = (ColumnFamily) o; return metadata.equals(comparison.metadata) && deletionInfo().equals(comparison.deletionInfo()) && ByteBufferUtil.compareUnsigned(digest(this), digest(comparison)) == 0; }
public void delete(DeletionInfo target, ColumnFamily source) { target.add(source.deletionInfo().getTopLevelDeletion()); // source is the CF currently in the memtable, and it can be large compared to what the filter selects, // so only consider those range tombstones that the filter do select. for (Iterator<RangeTombstone> iter = filter.getRangeTombstoneIterator(source); iter.hasNext(); ) target.add(iter.next(), source.getComparator()); } }
public static void deserializerSuperColumnFamily(DataInput in, ColumnFamily cf, ColumnSerializer.Flag flag, int version) throws IOException { // Note that there was no way to insert a range tombstone in a SCF in 1.2 cf.delete(cf.getComparator().deletionInfoSerializer().deserialize(in, version)); assert !cf.deletionInfo().rangeIterator().hasNext(); Iterator<OnDiskAtom> iter = onDiskIterator(in, in.readInt(), flag, Integer.MIN_VALUE, cf.getComparator()); while (iter.hasNext()) cf.addAtom(iter.next()); }
public void updateDigest(MessageDigest digest) { for (Cell cell : this) cell.updateDigest(digest); if (MessagingService.instance().areAllNodesAtLeast21()) deletionInfo().updateDigest(digest); }
/** * Get portion of the columns and serialize in loop while not more columns left in the row * * @param row SSTableIdentityIterator row representation with Column Family * @param key Decorated Key for the required row * @param out output stream */ private static void serializeRow(SSTableIdentityIterator row, DecoratedKey key, PrintStream out) { serializeRow(row.getColumnFamily().deletionInfo(), row, row.getColumnFamily().metadata(), key, out); }
@Override public Collection<Mutation> augment(ByteBuffer key, ColumnFamily update) { List<Mutation> mutations = new ArrayList<>(update.getColumnCount()); String indexKeySpace = properties.getProperty("keyspace"); String indexColumnFamily = properties.getProperty("table"); if (!update.deletionInfo().isLive()) { CFMetaData cfMetaData = Schema.instance.getCFMetaData(indexKeySpace, indexColumnFamily); for (ColumnDefinition columnDefinition : cfMetaData.allColumns()) { Mutation mutation = new Mutation(indexKeySpace, key); mutation.delete(indexColumnFamily, CellNames.simpleSparse(columnDefinition.name), System.currentTimeMillis()); mutations.add(mutation); } } return mutations; }
private static ColumnFamily updatesWithPaxosTime(ColumnFamily updates, UUID ballot) { ColumnFamily cf = updates.cloneMeShallow(); long t = UUIDGen.microsTimestamp(ballot); // For the tombstones, we use t-1 so that when insert a collection literall, the range tombstone that deletes the previous values of // the collection and we want that to have a lower timestamp and our new values. Since tombstones wins over normal insert, using t-1 // should not be a problem in general (see #6069). cf.deletionInfo().updateAllTimestamp(t-1); for (Cell cell : updates) cf.addAtom(cell.withUpdatedTimestamp(t)); return cf; }
private int discardLast(ColumnFamily cf, int toDiscard, ColumnFamily newCf) { boolean isReversed = isReversed(); DeletionInfo.InOrderTester tester = cf.deletionInfo().inOrderTester(isReversed); return isReversed ? discardHead(cf, toDiscard, newCf, cf.reverseIterator(), tester) : discardTail(cf, toDiscard, newCf, cf.iterator(), tester); }
private int discardFirst(ColumnFamily cf, int toDiscard, ColumnFamily newCf) { boolean isReversed = isReversed(); DeletionInfo.InOrderTester tester = cf.deletionInfo().inOrderTester(isReversed); return isReversed ? discardTail(cf, toDiscard, newCf, cf.reverseIterator(), tester) : discardHead(cf, toDiscard, newCf, cf.iterator(), tester); }
public static RowIndexEntry rawAppend(ColumnFamily cf, long startPosition, DecoratedKey key, DataOutputPlus out) throws IOException { assert cf.hasColumns() || cf.isMarkedForDelete(); ColumnIndex.Builder builder = new ColumnIndex.Builder(cf, key.getKey(), out); ColumnIndex index = builder.build(cf); out.writeShort(END_OF_ROW); return RowIndexEntry.create(startPosition, cf.deletionInfo().getTopLevelDeletion(), index); }
public long contentSerializedSize(ColumnFamily cf, TypeSizes typeSizes, int version) { long size = cf.getComparator().deletionInfoSerializer().serializedSize(cf.deletionInfo(), typeSizes, version); size += typeSizes.sizeof(cf.getColumnCount()); ColumnSerializer columnSerializer = cf.getComparator().columnSerializer(); for (Cell cell : cf) size += columnSerializer.serializedSize(cell, typeSizes); return size; }
protected boolean containsPreviousLast(Row first) { if (lastReturned == null) return false; Cell firstCell = isReversed() ? lastCell(first.cf) : firstNonStaticCell(first.cf); // If the row was containing only static columns it has already been returned and we can skip it. if (firstCell == null) return true; CFMetaData metadata = Schema.instance.getCFMetaData(command.getKeyspace(), command.getColumnFamilyName()); // Note: we only return true if the column is the lastReturned *and* it is live. If it is deleted, it is ignored by the // rest of the paging code (it hasn't been counted as live in particular) and we want to act as if it wasn't there. return !first.cf.deletionInfo().isDeleted(firstCell) && firstCell.isLive(timestamp()) && firstCell.name().isSameCQL3RowAs(metadata.comparator, lastReturned); }