Search in sources :

Example 36 with PartitionUpdate

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;
}
Also used : PartitionUpdate(org.apache.cassandra.db.partitions.PartitionUpdate)

Example 37 with PartitionUpdate

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;
}
Also used : PartitionUpdate(org.apache.cassandra.db.partitions.PartitionUpdate)

Example 38 with PartitionUpdate

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();
}
Also used : Collections.singletonMap(java.util.Collections.singletonMap) Collections.emptyMap(java.util.Collections.emptyMap) ImmutableMap(com.google.common.collect.ImmutableMap) PartitionUpdate(org.apache.cassandra.db.partitions.PartitionUpdate)

Example 39 with PartitionUpdate

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);
}
Also used : PartitionUpdate(org.apache.cassandra.db.partitions.PartitionUpdate)

Example 40 with PartitionUpdate

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);
}
Also used : PartitionUpdate(org.apache.cassandra.db.partitions.PartitionUpdate)

Aggregations

PartitionUpdate (org.apache.cassandra.db.partitions.PartitionUpdate)40 Test (org.junit.Test)14 TableMetadata (org.apache.cassandra.schema.TableMetadata)7 ColumnIdentifier (org.apache.cassandra.cql3.ColumnIdentifier)3 Mutation (org.apache.cassandra.db.Mutation)3 ColumnMetadata (org.apache.cassandra.schema.ColumnMetadata)3 Commit (org.apache.cassandra.service.paxos.Commit)3 UntypedResultSet (org.apache.cassandra.cql3.UntypedResultSet)2 InvalidRequestException (org.apache.cassandra.exceptions.InvalidRequestException)2 TableId (org.apache.cassandra.schema.TableId)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 InetAddress (java.net.InetAddress)1 ByteBuffer (java.nio.ByteBuffer)1 Collections.emptyMap (java.util.Collections.emptyMap)1 Collections.singletonMap (java.util.Collections.singletonMap)1 HashSet (java.util.HashSet)1 UUID (java.util.UUID)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1