Search in sources :

Example 11 with DeletionTime

use of org.apache.cassandra.db.DeletionTime in project cassandra by apache.

the class RowsTest method copy.

@Test
public void copy() {
    int now = FBUtilities.nowInSeconds();
    long ts = secondToTs(now);
    Row.Builder originalBuilder = BTreeRow.unsortedBuilder(now);
    originalBuilder.newRow(c1);
    LivenessInfo liveness = LivenessInfo.create(ts, now);
    originalBuilder.addPrimaryKeyLivenessInfo(liveness);
    DeletionTime complexDeletion = new DeletionTime(ts - 1, now);
    originalBuilder.addComplexDeletion(m, complexDeletion);
    List<Cell> expectedCells = Lists.newArrayList(BufferCell.live(v, secondToTs(now), BB1), BufferCell.live(m, secondToTs(now), BB1, CellPath.create(BB1)), BufferCell.live(m, secondToTs(now), BB2, CellPath.create(BB2)));
    expectedCells.forEach(originalBuilder::addCell);
    // We need to use ts-1 so the deletion doesn't shadow what we've created
    Row.Deletion rowDeletion = new Row.Deletion(new DeletionTime(ts - 1, now), false);
    originalBuilder.addRowDeletion(rowDeletion);
    RowBuilder builder = new RowBuilder();
    Rows.copy(originalBuilder.build(), builder);
    Assert.assertEquals(c1, builder.clustering);
    Assert.assertEquals(liveness, builder.livenessInfo);
    Assert.assertEquals(rowDeletion, builder.deletionTime);
    Assert.assertEquals(Lists.newArrayList(Pair.create(m, complexDeletion)), builder.complexDeletions);
    Assert.assertEquals(Sets.newHashSet(expectedCells), Sets.newHashSet(builder.cells));
}
Also used : DeletionTime(org.apache.cassandra.db.DeletionTime) LivenessInfo(org.apache.cassandra.db.LivenessInfo) Test(org.junit.Test)

Aggregations

DeletionTime (org.apache.cassandra.db.DeletionTime)11 Test (org.junit.Test)8 LivenessInfo (org.apache.cassandra.db.LivenessInfo)5 Matcher (java.util.regex.Matcher)1 ColumnFilter (org.apache.cassandra.db.filter.ColumnFilter)1