Search in sources :

Example 1 with SSTableReader

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

the class DataTracker method addNewSSTablesSize.

private void addNewSSTablesSize(Iterable<SSTableReader> newSSTables) {
    for (SSTableReader sstable : newSSTables) {
        assert sstable.getKeySamples() != null;
        if (logger.isDebugEnabled())
            logger.debug(String.format("adding %s to list of files tracked for %s.%s", sstable.descriptor, cfstore.table.name, cfstore.getColumnFamilyName()));
        long size = sstable.bytesOnDisk();
        liveSize.addAndGet(size);
        totalSize.addAndGet(size);
        sstable.setTrackedBy(this);
    }
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.SSTableReader)

Example 2 with SSTableReader

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

the class DataTracker method removeOldSSTablesSize.

private void removeOldSSTablesSize(Iterable<SSTableReader> oldSSTables) {
    for (SSTableReader sstable : oldSSTables) {
        if (logger.isDebugEnabled())
            logger.debug(String.format("removing %s from list of files tracked for %s.%s", sstable.descriptor, cfstore.table.name, cfstore.getColumnFamilyName()));
        liveSize.addAndGet(-sstable.bytesOnDisk());
        boolean firstToCompact = sstable.markCompacted();
        assert firstToCompact : sstable + " was already marked compacted";
        sstable.releaseReference();
    }
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.SSTableReader)

Example 3 with SSTableReader

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

the class DataTracker method getCompressionRatio.

public double getCompressionRatio() {
    double sum = 0;
    int total = 0;
    for (SSTableReader sstable : getSSTables()) {
        if (sstable.getCompressionRatio() != Double.MIN_VALUE) {
            sum += sstable.getCompressionRatio();
            total++;
        }
    }
    return total != 0 ? (double) sum / total : 0;
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.SSTableReader)

Example 4 with SSTableReader

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

the class DataTracker method addSSTables.

public void addSSTables(Collection<SSTableReader> sstables) {
    replace(Collections.<SSTableReader>emptyList(), sstables);
    for (SSTableReader sstable : sstables) {
        incrementallyBackup(sstable);
        notifyAdded(sstable);
    }
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.SSTableReader)

Example 5 with SSTableReader

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

the class CollationController method collectAllData.

/**
 * Collects data the brute-force way: gets an iterator for the filter in question
 * from every memtable and sstable, then merges them together.
 */
private ColumnFamily collectAllData() {
    logger.debug("collectAllData");
    ISortedColumns.Factory factory = mutableColumns ? AtomicSortedColumns.factory() : ArrayBackedSortedColumns.factory();
    List<IColumnIterator> iterators = new ArrayList<IColumnIterator>();
    ColumnFamily returnCF = ColumnFamily.create(cfs.metadata, factory, filter.filter.isReversed());
    ColumnFamilyStore.ViewFragment view = cfs.markReferenced(filter.key);
    try {
        for (Memtable memtable : view.memtables) {
            IColumnIterator iter = filter.getMemtableColumnIterator(memtable);
            if (iter != null) {
                returnCF.delete(iter.getColumnFamily());
                iterators.add(iter);
            }
        }
        for (SSTableReader sstable : view.sstables) {
            IColumnIterator iter = filter.getSSTableColumnIterator(sstable);
            iterators.add(iter);
            if (iter.getColumnFamily() != null) {
                returnCF.delete(iter.getColumnFamily());
                sstablesIterated++;
            }
        }
        // and "there used to be data, but it's gone now" (we should cache the empty CF so we don't need to rebuild that slower)
        if (iterators.isEmpty())
            return null;
        filter.collateColumns(returnCF, iterators, gcBefore);
        // Caller is responsible for final removeDeletedCF.  This is important for cacheRow to work correctly:
        return returnCF;
    } finally {
        for (IColumnIterator iter : iterators) FileUtils.closeQuietly(iter);
        SSTableReader.releaseReferences(view.sstables);
    }
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.SSTableReader) IColumnIterator(org.apache.cassandra.db.columniterator.IColumnIterator)

Aggregations

SSTableReader (org.apache.cassandra.io.sstable.SSTableReader)45 Test (org.junit.Test)16 File (java.io.File)14 ColumnFamily (org.apache.cassandra.db.ColumnFamily)10 QueryPath (org.apache.cassandra.db.filter.QueryPath)10 SSTableUtils.tempSSTableFile (org.apache.cassandra.io.sstable.SSTableUtils.tempSSTableFile)9 IOException (java.io.IOException)8 QueryFilter (org.apache.cassandra.db.filter.QueryFilter)7 SSTableWriter (org.apache.cassandra.io.sstable.SSTableWriter)7 IColumnIterator (org.apache.cassandra.db.columniterator.IColumnIterator)6 PrintStream (java.io.PrintStream)5 FileReader (java.io.FileReader)4 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)4 ExpiringColumn (org.apache.cassandra.db.ExpiringColumn)4 IColumn (org.apache.cassandra.db.IColumn)4 Token (org.apache.cassandra.dht.Token)4 JSONArray (org.json.simple.JSONArray)4 JSONObject (org.json.simple.JSONObject)4 ByteBuffer (java.nio.ByteBuffer)3 CounterColumn (org.apache.cassandra.db.CounterColumn)3