Search in sources :

Example 1 with AbstractClusteringIndexFilter

use of org.apache.cassandra.db.filter.AbstractClusteringIndexFilter in project cassandra by apache.

the class SinglePartitionSliceCommandTest method testMultiNamesOrSlicesCommand.

private void testMultiNamesOrSlicesCommand(boolean flush, boolean isSlice) {
    int deletionTime = 5;
    int ck1 = 1;
    int uniqueCk1 = 2;
    int uniqueCk2 = 3;
    DecoratedKey key = Util.dk(ByteBufferUtil.bytes("k"));
    QueryProcessor.executeInternal(String.format("DELETE FROM ks.tbl_slices USING TIMESTAMP %d WHERE k='k' AND c1=%d", deletionTime, ck1));
    if (flush)
        Keyspace.open(KEYSPACE).getColumnFamilyStore(TABLE_SCLICES).forceBlockingFlush();
    AbstractClusteringIndexFilter clusteringFilter = createClusteringFilter(uniqueCk1, uniqueCk2, isSlice);
    ReadCommand cmd = SinglePartitionReadCommand.create(CFM_SLICES, FBUtilities.nowInSeconds(), ColumnFilter.all(CFM_SLICES), RowFilter.NONE, DataLimits.NONE, key, clusteringFilter);
    UnfilteredPartitionIterator partitionIterator = cmd.executeLocally(cmd.executionController());
    assert partitionIterator.hasNext();
    UnfilteredRowIterator partition = partitionIterator.next();
    int count = 0;
    boolean open = true;
    while (partition.hasNext()) {
        Unfiltered unfiltered = partition.next();
        assertTrue(unfiltered.isRangeTombstoneMarker());
        RangeTombstoneMarker marker = (RangeTombstoneMarker) unfiltered;
        // check if it's open-close pair
        assertEquals(open, marker.isOpen(false));
        // check deletion time same as Range Deletion
        DeletionTime delete = (open ? marker.openDeletionTime(false) : marker.closeDeletionTime(false));
        ;
        assertEquals(deletionTime, delete.markedForDeleteAt());
        // check clustering values
        Clustering<?> clustering = Util.clustering(CFM_SLICES.comparator, ck1, count / 2);
        assertArrayEquals(clustering.getRawValues(), marker.clustering().getBufferArray());
        open = !open;
        count++;
    }
    // open and close range tombstones
    assertEquals(uniqueCk2 * 2, count);
}
Also used : UnfilteredRowIterator(org.apache.cassandra.db.rows.UnfilteredRowIterator) AbstractClusteringIndexFilter(org.apache.cassandra.db.filter.AbstractClusteringIndexFilter) RangeTombstoneMarker(org.apache.cassandra.db.rows.RangeTombstoneMarker) UnfilteredPartitionIterator(org.apache.cassandra.db.partitions.UnfilteredPartitionIterator) Unfiltered(org.apache.cassandra.db.rows.Unfiltered)

Aggregations

AbstractClusteringIndexFilter (org.apache.cassandra.db.filter.AbstractClusteringIndexFilter)1 UnfilteredPartitionIterator (org.apache.cassandra.db.partitions.UnfilteredPartitionIterator)1 RangeTombstoneMarker (org.apache.cassandra.db.rows.RangeTombstoneMarker)1 Unfiltered (org.apache.cassandra.db.rows.Unfiltered)1 UnfilteredRowIterator (org.apache.cassandra.db.rows.UnfilteredRowIterator)1