Search in sources :

Example 6 with StatsMetadata

use of org.apache.cassandra.io.sstable.metadata.StatsMetadata in project cassandra by apache.

the class SSTableMetadataTrackingTest method testTrackMetadata_rangeTombstone.

@Test
public void testTrackMetadata_rangeTombstone() throws Throwable {
    createTable("CREATE TABLE %s (a int, b int, c text, PRIMARY KEY (a, b)) WITH gc_grace_seconds = 10000");
    ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(currentTable());
    execute("DELETE FROM %s USING TIMESTAMP 9999 WHERE a = 1 and b = 1");
    cfs.forceBlockingFlush();
    assertEquals(1, cfs.getLiveSSTables().size());
    StatsMetadata metadata = cfs.getLiveSSTables().iterator().next().getSSTableMetadata();
    assertEquals(9999, metadata.minTimestamp);
    assertEquals(9999, metadata.maxTimestamp);
    assertEquals(System.currentTimeMillis() / 1000, metadata.maxLocalDeletionTime, 5);
    cfs.forceMajorCompaction();
    StatsMetadata metadata2 = cfs.getLiveSSTables().iterator().next().getSSTableMetadata();
    assertEquals(metadata.maxLocalDeletionTime, metadata2.maxLocalDeletionTime);
    assertEquals(metadata.minTimestamp, metadata2.minTimestamp);
    assertEquals(metadata.maxTimestamp, metadata2.maxTimestamp);
}
Also used : StatsMetadata(org.apache.cassandra.io.sstable.metadata.StatsMetadata) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) Test(org.junit.Test)

Example 7 with StatsMetadata

use of org.apache.cassandra.io.sstable.metadata.StatsMetadata in project cassandra by apache.

the class SSTableMetadataTrackingTest method testTrackMetadata_rowMarker.

@Test
public void testTrackMetadata_rowMarker() throws Throwable {
    createTable("CREATE TABLE %s (a int, PRIMARY KEY (a))");
    ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(currentTable());
    execute("INSERT INTO %s (a) VALUES (1) USING TIMESTAMP 9999");
    cfs.forceBlockingFlush();
    assertEquals(1, cfs.getLiveSSTables().size());
    StatsMetadata metadata = cfs.getLiveSSTables().iterator().next().getSSTableMetadata();
    assertEquals(9999, metadata.minTimestamp);
    assertEquals(9999, metadata.maxTimestamp);
    assertEquals(Integer.MAX_VALUE, metadata.maxLocalDeletionTime);
    cfs.forceMajorCompaction();
    StatsMetadata metadata2 = cfs.getLiveSSTables().iterator().next().getSSTableMetadata();
    assertEquals(metadata.maxLocalDeletionTime, metadata2.maxLocalDeletionTime);
    assertEquals(metadata.minTimestamp, metadata2.minTimestamp);
    assertEquals(metadata.maxTimestamp, metadata2.maxTimestamp);
}
Also used : StatsMetadata(org.apache.cassandra.io.sstable.metadata.StatsMetadata) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) Test(org.junit.Test)

Example 8 with StatsMetadata

use of org.apache.cassandra.io.sstable.metadata.StatsMetadata in project cassandra by apache.

the class SSTableMetadataTrackingTest method baseCheck.

@Test
public void baseCheck() 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 9999");
    cfs.forceBlockingFlush();
    StatsMetadata metadata = cfs.getLiveSSTables().iterator().next().getSSTableMetadata();
    assertEquals(9999, metadata.minTimestamp);
    assertEquals(Integer.MAX_VALUE, metadata.maxLocalDeletionTime);
    cfs.forceMajorCompaction();
    metadata = cfs.getLiveSSTables().iterator().next().getSSTableMetadata();
    assertEquals(9999, metadata.minTimestamp);
    assertEquals(Integer.MAX_VALUE, metadata.maxLocalDeletionTime);
}
Also used : StatsMetadata(org.apache.cassandra.io.sstable.metadata.StatsMetadata) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) Test(org.junit.Test)

Example 9 with StatsMetadata

use of org.apache.cassandra.io.sstable.metadata.StatsMetadata in project cassandra by apache.

the class SSTableMetadataTrackingTest method testTrackMetadata_rowTombstone.

@Test
public void testTrackMetadata_rowTombstone() throws Throwable {
    createTable("CREATE TABLE %s (a int, b int, c text, PRIMARY KEY (a, b))");
    ColumnFamilyStore cfs = Keyspace.open(keyspace()).getColumnFamilyStore(currentTable());
    execute("DELETE FROM %s USING TIMESTAMP 9999 WHERE a = 1");
    cfs.forceBlockingFlush();
    assertEquals(1, cfs.getLiveSSTables().size());
    StatsMetadata metadata = cfs.getLiveSSTables().iterator().next().getSSTableMetadata();
    assertEquals(9999, metadata.minTimestamp);
    assertEquals(9999, metadata.maxTimestamp);
    assertEquals(System.currentTimeMillis() / 1000, metadata.maxLocalDeletionTime, 5);
    cfs.forceMajorCompaction();
    StatsMetadata metadata2 = cfs.getLiveSSTables().iterator().next().getSSTableMetadata();
    assertEquals(metadata.maxLocalDeletionTime, metadata2.maxLocalDeletionTime);
    assertEquals(metadata.minTimestamp, metadata2.minTimestamp);
    assertEquals(metadata.maxTimestamp, metadata2.maxTimestamp);
}
Also used : StatsMetadata(org.apache.cassandra.io.sstable.metadata.StatsMetadata) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) Test(org.junit.Test)

Example 10 with StatsMetadata

use of org.apache.cassandra.io.sstable.metadata.StatsMetadata 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)

Aggregations

StatsMetadata (org.apache.cassandra.io.sstable.metadata.StatsMetadata)16 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)8 Test (org.junit.Test)7 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)6 File (java.io.File)3 RandomAccessFile (java.io.RandomAccessFile)2 ByteBuffer (java.nio.ByteBuffer)2 CompressedSequentialWriter (org.apache.cassandra.io.compress.CompressedSequentialWriter)2 Descriptor (org.apache.cassandra.io.sstable.Descriptor)2 MetadataCollector (org.apache.cassandra.io.sstable.metadata.MetadataCollector)2 AlwaysPresentFilter (org.apache.cassandra.utils.AlwaysPresentFilter)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Throwables (com.google.common.base.Throwables)1 java.io (java.io)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 java.util (java.util)1 Map (java.util.Map)1 Set (java.util.Set)1 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)1