Search in sources :

Example 31 with PartitionUpdate

use of org.apache.cassandra.db.partitions.PartitionUpdate in project cassandra by apache.

the class RowTest method testMergeRangeTombstones.

@Test
public void testMergeRangeTombstones() throws InterruptedException {
    PartitionUpdate update1 = new PartitionUpdate(metadata, dk, metadata.regularAndStaticColumns(), 1);
    writeRangeTombstone(update1, "1", "11", 123, 123);
    writeRangeTombstone(update1, "2", "22", 123, 123);
    writeRangeTombstone(update1, "3", "31", 123, 123);
    writeRangeTombstone(update1, "4", "41", 123, 123);
    PartitionUpdate update2 = new PartitionUpdate(metadata, dk, metadata.regularAndStaticColumns(), 1);
    writeRangeTombstone(update2, "1", "11", 123, 123);
    writeRangeTombstone(update2, "111", "112", 1230, 123);
    writeRangeTombstone(update2, "2", "24", 123, 123);
    writeRangeTombstone(update2, "3", "31", 1230, 123);
    writeRangeTombstone(update2, "4", "41", 123, 1230);
    writeRangeTombstone(update2, "5", "51", 123, 1230);
    try (UnfilteredRowIterator merged = UnfilteredRowIterators.merge(ImmutableList.of(update1.unfilteredIterator(), update2.unfilteredIterator()), nowInSeconds)) {
        Object[][] expected = new Object[][] { { "1", "11", 123l, 123 }, { "111", "112", 1230l, 123 }, { "2", "24", 123l, 123 }, { "3", "31", 1230l, 123 }, { "4", "41", 123l, 1230 }, { "5", "51", 123l, 1230 } };
        int i = 0;
        while (merged.hasNext()) {
            RangeTombstoneBoundMarker openMarker = (RangeTombstoneBoundMarker) merged.next();
            ClusteringBound openBound = openMarker.clustering();
            DeletionTime openDeletion = new DeletionTime(openMarker.deletionTime().markedForDeleteAt(), openMarker.deletionTime().localDeletionTime());
            RangeTombstoneBoundMarker closeMarker = (RangeTombstoneBoundMarker) merged.next();
            ClusteringBound closeBound = closeMarker.clustering();
            DeletionTime closeDeletion = new DeletionTime(closeMarker.deletionTime().markedForDeleteAt(), closeMarker.deletionTime().localDeletionTime());
            assertEquals(openDeletion, closeDeletion);
            assertRangeTombstoneMarkers(openBound, closeBound, openDeletion, expected[i++]);
        }
    }
}
Also used : PartitionUpdate(org.apache.cassandra.db.partitions.PartitionUpdate) Test(org.junit.Test)

Example 32 with PartitionUpdate

use of org.apache.cassandra.db.partitions.PartitionUpdate in project cassandra by apache.

the class ScrubTest method fillCF.

protected void fillCF(ColumnFamilyStore cfs, int partitionsPerSSTable) {
    for (int i = 0; i < partitionsPerSSTable; i++) {
        PartitionUpdate update = UpdateBuilder.create(cfs.metadata(), String.valueOf(i)).newRow("r1").add("val", "1").newRow("r1").add("val", "1").build();
        new Mutation(update).applyUnsafe();
    }
    cfs.forceBlockingFlush();
}
Also used : PartitionUpdate(org.apache.cassandra.db.partitions.PartitionUpdate)

Example 33 with PartitionUpdate

use of org.apache.cassandra.db.partitions.PartitionUpdate in project cassandra by apache.

the class ScrubTest method fillCounterCF.

protected void fillCounterCF(ColumnFamilyStore cfs, int partitionsPerSSTable) throws WriteTimeoutException {
    for (int i = 0; i < partitionsPerSSTable; i++) {
        PartitionUpdate update = UpdateBuilder.create(cfs.metadata(), String.valueOf(i)).newRow("r1").add("val", 100L).build();
        new CounterMutation(new Mutation(update), ConsistencyLevel.ONE).apply();
    }
    cfs.forceBlockingFlush();
}
Also used : PartitionUpdate(org.apache.cassandra.db.partitions.PartitionUpdate)

Example 34 with PartitionUpdate

use of org.apache.cassandra.db.partitions.PartitionUpdate in project cassandra by apache.

the class CustomCassandraIndex 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.debug("Removed index entry for value {}", indexKey);
}
Also used : PartitionUpdate(org.apache.cassandra.db.partitions.PartitionUpdate)

Example 35 with PartitionUpdate

use of org.apache.cassandra.db.partitions.PartitionUpdate in project cassandra by apache.

the class TriggerExecutorTest method sameKeySameCfColumnFamilies.

@Test
public void sameKeySameCfColumnFamilies() throws ConfigurationException, InvalidRequestException {
    TableMetadata metadata = makeTableMetadata("ks1", "cf1", TriggerMetadata.create("test", SameKeySameCfTrigger.class.getName()));
    PartitionUpdate mutated = TriggerExecutor.instance.execute(makeCf(metadata, "k1", "v1", null));
    try (RowIterator rowIterator = UnfilteredRowIterators.filter(mutated.unfilteredIterator(), FBUtilities.nowInSeconds())) {
        Iterator<Cell> cells = rowIterator.next().cells().iterator();
        assertEquals(bytes("trigger"), cells.next().value());
        assertTrue(!rowIterator.hasNext());
    }
}
Also used : TableMetadata(org.apache.cassandra.schema.TableMetadata) PartitionUpdate(org.apache.cassandra.db.partitions.PartitionUpdate) Test(org.junit.Test)

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