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++]);
}
}
}
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();
}
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();
}
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);
}
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());
}
}
Aggregations