use of org.apache.cassandra.db.partitions.PartitionUpdate in project cassandra by apache.
the class Mutation method without.
public Mutation without(Set<TableId> tableIds) {
if (tableIds.isEmpty())
return this;
Mutation copy = copy();
copy.modifications.keySet().removeAll(tableIds);
copy.cdcEnabled = false;
for (PartitionUpdate pu : modifications.values()) copy.cdcEnabled |= pu.metadata().params.cdc;
return copy;
}
use of org.apache.cassandra.db.partitions.PartitionUpdate in project cassandra by apache.
the class UpdatesCollector method getPartitionUpdate.
/**
* Gets the <code>PartitionUpdate</code> for the specified column family and key. If the update does not
* exist it will be created.
*
* @param metadata the column family meta data
* @param dk the partition key
* @param consistency the consistency level
* @return the <code>PartitionUpdate</code> for the specified column family and key
*/
public PartitionUpdate getPartitionUpdate(TableMetadata metadata, DecoratedKey dk, ConsistencyLevel consistency) {
Mutation mut = getMutation(metadata, dk, consistency);
PartitionUpdate upd = mut.get(metadata);
if (upd == null) {
RegularAndStaticColumns columns = updatedColumns.get(metadata.id);
assert columns != null;
upd = new PartitionUpdate(metadata, dk, columns, updatedRows);
mut.add(upd);
}
return upd;
}
use of org.apache.cassandra.db.partitions.PartitionUpdate in project cassandra by apache.
the class SystemKeyspace method updateSizeEstimates.
/**
* Writes the current partition count and size estimates into SIZE_ESTIMATES_CF
*/
public static void updateSizeEstimates(String keyspace, String table, Map<Range<Token>, Pair<Long, Long>> estimates) {
long timestamp = FBUtilities.timestampMicros();
PartitionUpdate update = new PartitionUpdate(SizeEstimates, UTF8Type.instance.decompose(keyspace), SizeEstimates.regularAndStaticColumns(), estimates.size());
Mutation mutation = new Mutation(update);
// delete all previous values with a single range tombstone.
int nowInSec = FBUtilities.nowInSeconds();
update.add(new RangeTombstone(Slice.make(SizeEstimates.comparator, table), new DeletionTime(timestamp - 1, nowInSec)));
// add a CQL row for each primary token range.
for (Map.Entry<Range<Token>, Pair<Long, Long>> entry : estimates.entrySet()) {
Range<Token> range = entry.getKey();
Pair<Long, Long> values = entry.getValue();
update.add(Rows.simpleBuilder(SizeEstimates, table, range.left.toString(), range.right.toString()).timestamp(timestamp).add("partitions_count", values.left).add("mean_partition_size", values.right).build());
}
mutation.apply();
}
use of org.apache.cassandra.db.partitions.PartitionUpdate in project cassandra by apache.
the class CassandraIndex method doDelete.
private void doDelete(DecoratedKey indexKey, Clustering indexClustering, DeletionTime deletion, OpOrder.Group opGroup) {
Row row = BTreeRow.emptyDeletedRow(indexClustering, Row.Deletion.regular(deletion));
PartitionUpdate upd = partitionUpdate(indexKey, row);
indexCfs.apply(upd, UpdateTransaction.NO_OP, opGroup, null);
logger.trace("Removed index entry for value {}", indexKey);
}
use of org.apache.cassandra.db.partitions.PartitionUpdate in project cassandra by apache.
the class CassandraIndex method insert.
/**
* Called when adding a new entry to the index
*/
private void insert(ByteBuffer rowKey, Clustering clustering, Cell cell, LivenessInfo info, OpOrder.Group opGroup) {
DecoratedKey valueKey = getIndexKeyFor(getIndexedValue(rowKey, clustering, cell));
Row row = BTreeRow.noCellLiveRow(buildIndexClustering(rowKey, clustering, cell), info);
PartitionUpdate upd = partitionUpdate(valueKey, row);
indexCfs.apply(upd, UpdateTransaction.NO_OP, opGroup, null);
logger.trace("Inserted entry into index for value {}", valueKey);
}
Aggregations