Search in sources :

Example 21 with ColumnFamilyStore

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

the class SSTableMetadataTrackingTest method testMinMaxtimestampRange.

@Test
public void testMinMaxtimestampRange() throws Throwable {
    createTable("CREATE TABLE %s (a int, b int, c text, PRIMARY KEY (a, b))");
    ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(currentTable());
    execute("INSERT INTO %s (a,b,c) VALUES (1,1,'1') using timestamp 10000");
    execute("DELETE FROM %s USING TIMESTAMP 9999 WHERE a = 1 and b = 1");
    cfs.forceBlockingFlush();
    StatsMetadata metadata = cfs.getLiveSSTables().iterator().next().getSSTableMetadata();
    assertEquals(9999, metadata.minTimestamp);
    assertEquals(10000, metadata.maxTimestamp);
    assertEquals(Integer.MAX_VALUE, metadata.maxLocalDeletionTime, 5);
    cfs.forceMajorCompaction();
    metadata = cfs.getLiveSSTables().iterator().next().getSSTableMetadata();
    assertEquals(9999, metadata.minTimestamp);
    assertEquals(10000, metadata.maxTimestamp);
    assertEquals(Integer.MAX_VALUE, metadata.maxLocalDeletionTime, 5);
}
Also used : StatsMetadata(org.apache.cassandra.io.sstable.metadata.StatsMetadata) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) Test(org.junit.Test)

Example 22 with ColumnFamilyStore

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

the class SSTablesIteratedTest method executeAndCheck.

private void executeAndCheck(String query, int numSSTables, Object[]... rows) throws Throwable {
    ColumnFamilyStore cfs = getCurrentColumnFamilyStore(KEYSPACE_PER_TEST);
    // resets counts
    ((ClearableHistogram) cfs.metric.sstablesPerReadHistogram.cf).clear();
    assertRows(execute(query), rows);
    // max sstables read
    long numSSTablesIterated = cfs.metric.sstablesPerReadHistogram.cf.getSnapshot().getMax();
    assertEquals(String.format("Expected %d sstables iterated but got %d instead, with %d live sstables", numSSTables, numSSTablesIterated, cfs.getLiveSSTables().size()), numSSTables, numSSTablesIterated);
}
Also used : ClearableHistogram(org.apache.cassandra.metrics.ClearableHistogram) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore)

Example 23 with ColumnFamilyStore

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

the class DeleteTest method isMemtableEmpty.

/**
     * Checks if the memtable is empty or not
     * @return {@code true} if the memtable is empty, {@code false} otherwise.
     */
private boolean isMemtableEmpty() {
    Keyspace keyspace = Keyspace.open(KEYSPACE);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(currentTable());
    return cfs.metric.allMemtablesLiveDataSize.getValue() == 0;
}
Also used : Keyspace(org.apache.cassandra.db.Keyspace) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore)

Example 24 with ColumnFamilyStore

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

the class UpdateTest method isMemtableEmpty.

/**
     * Checks if the memtable is empty or not
     * @return {@code true} if the memtable is empty, {@code false} otherwise.
     */
private boolean isMemtableEmpty() {
    Keyspace keyspace = Keyspace.open(KEYSPACE);
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(currentTable());
    return cfs.metric.allMemtablesLiveDataSize.getValue() == 0;
}
Also used : Keyspace(org.apache.cassandra.db.Keyspace) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore)

Example 25 with ColumnFamilyStore

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

the class AlterTest method testAlterIndexInterval.

@Test
public // tests CASSANDRA-7976
void testAlterIndexInterval() throws Throwable {
    String tableName = createTable("CREATE TABLE IF NOT EXISTS %s (id uuid, album text, artist text, data blob, PRIMARY KEY (id))");
    ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(tableName);
    alterTable("ALTER TABLE %s WITH min_index_interval=256 AND max_index_interval=512");
    assertEquals(256, cfs.metadata().params.minIndexInterval);
    assertEquals(512, cfs.metadata().params.maxIndexInterval);
    alterTable("ALTER TABLE %s WITH caching = {}");
    assertEquals(256, cfs.metadata().params.minIndexInterval);
    assertEquals(512, cfs.metadata().params.maxIndexInterval);
}
Also used : ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) Test(org.junit.Test)

Aggregations

ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)175 Test (org.junit.Test)110 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)90 Keyspace (org.apache.cassandra.db.Keyspace)64 File (java.io.File)30 Directories (org.apache.cassandra.db.Directories)25 LifecycleTransaction (org.apache.cassandra.db.lifecycle.LifecycleTransaction)24 DecoratedKey (org.apache.cassandra.db.DecoratedKey)22 RowUpdateBuilder (org.apache.cassandra.db.RowUpdateBuilder)20 AbstractTransactionalTest (org.apache.cassandra.utils.concurrent.AbstractTransactionalTest)20 RandomAccessFile (java.io.RandomAccessFile)19 CompactionController (org.apache.cassandra.db.compaction.CompactionController)14 ArrayList (java.util.ArrayList)13 ByteBuffer (java.nio.ByteBuffer)12 CompactionIterator (org.apache.cassandra.db.compaction.CompactionIterator)12 Range (org.apache.cassandra.dht.Range)11 Table (org.apache.cassandra.db.Table)9 Token (org.apache.cassandra.dht.Token)9 Descriptor (org.apache.cassandra.io.sstable.Descriptor)9 StatsMetadata (org.apache.cassandra.io.sstable.metadata.StatsMetadata)9