Search in sources :

Example 6 with SSTable

use of org.apache.cassandra.io.sstable.SSTable in project eiger by wlloyd.

the class ColumnFamilyStoreTest method testSliceByNamesCommandOldMetatada.

@Test
public void testSliceByNamesCommandOldMetatada() throws Throwable {
    String tableName = "Keyspace1";
    String cfName = "Standard1";
    DecoratedKey key = Util.dk("slice-name-old-metadata");
    ByteBuffer cname = ByteBufferUtil.bytes("c1");
    Table table = Table.open(tableName);
    ColumnFamilyStore cfs = table.getColumnFamilyStore(cfName);
    cfs.clearUnsafe();
    // Create a column a 'high timestamp'
    putColsStandard(cfs, key, new Column(cname, ByteBufferUtil.bytes("a"), 2));
    cfs.forceBlockingFlush();
    // Nuke the metadata and reload that sstable
    Collection<SSTableReader> ssTables = cfs.getSSTables();
    assertEquals(1, ssTables.size());
    cfs.clearUnsafe();
    assertEquals(0, cfs.getSSTables().size());
    new File(ssTables.iterator().next().descriptor.filenameFor(SSTable.COMPONENT_STATS)).delete();
    cfs.loadNewSSTables();
    // Add another column with a lower timestamp
    putColsStandard(cfs, key, new Column(cname, ByteBufferUtil.bytes("b"), 1));
    // Test fetching the column by name returns the first column
    SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(tableName, key.key, new QueryPath(cfName), Collections.singletonList(cname));
    ColumnFamily cf = cmd.getRow(table).cf;
    Column column = (Column) cf.getColumn(cname);
    assert column.value().equals(ByteBufferUtil.bytes("a")) : "expecting a, got " + ByteBufferUtil.string(column.value());
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.SSTableReader) SSTable(org.apache.cassandra.io.sstable.SSTable) ByteBuffer(java.nio.ByteBuffer) File(java.io.File) Test(org.junit.Test)

Aggregations

SSTable (org.apache.cassandra.io.sstable.SSTable)6 ByteBuffer (java.nio.ByteBuffer)2 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)2 File (org.apache.cassandra.io.util.File)2 Test (org.junit.Test)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 Longs (com.google.common.primitives.Longs)1 File (java.io.File)1 IOException (java.io.IOException)1 FileChannel (java.nio.channels.FileChannel)1 Path (java.nio.file.Path)1 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1