Search in sources :

Example 1 with MetadataCollector

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

the class CompactionManager method createWriterForAntiCompaction.

public static SSTableWriter createWriterForAntiCompaction(ColumnFamilyStore cfs, File compactionFileLocation, int expectedBloomFilterSize, long repairedAt, UUID pendingRepair, Collection<SSTableReader> sstables, LifecycleTransaction txn) {
    FileUtils.createDirectory(compactionFileLocation);
    int minLevel = Integer.MAX_VALUE;
    // after first migration to be able to drop the sstables back in their original place in the repaired sstable manifest
    for (SSTableReader sstable : sstables) {
        if (minLevel == Integer.MAX_VALUE)
            minLevel = sstable.getSSTableLevel();
        if (minLevel != sstable.getSSTableLevel()) {
            minLevel = 0;
            break;
        }
    }
    return SSTableWriter.create(cfs.newSSTableDescriptor(compactionFileLocation), (long) expectedBloomFilterSize, repairedAt, pendingRepair, cfs.metadata, new MetadataCollector(sstables, cfs.metadata().comparator, minLevel), SerializationHeader.make(cfs.metadata(), sstables), cfs.indexManager.listIndexes(), txn);
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) MetadataCollector(org.apache.cassandra.io.sstable.metadata.MetadataCollector)

Example 2 with MetadataCollector

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

the class Upgrader method createCompactionWriter.

private SSTableWriter createCompactionWriter(long repairedAt, UUID parentRepair) {
    MetadataCollector sstableMetadataCollector = new MetadataCollector(cfs.getComparator());
    sstableMetadataCollector.sstableLevel(sstable.getSSTableLevel());
    return SSTableWriter.create(cfs.newSSTableDescriptor(directory), estimatedRows, repairedAt, parentRepair, cfs.metadata, sstableMetadataCollector, SerializationHeader.make(cfs.metadata(), Sets.newHashSet(sstable)), cfs.indexManager.listIndexes(), transaction);
}
Also used : MetadataCollector(org.apache.cassandra.io.sstable.metadata.MetadataCollector)

Example 3 with MetadataCollector

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

the class DefaultCompactionWriter method switchCompactionLocation.

@Override
public void switchCompactionLocation(Directories.DataDirectory directory) {
    @SuppressWarnings("resource") SSTableWriter writer = SSTableWriter.create(cfs.newSSTableDescriptor(getDirectories().getLocationForDisk(directory)), estimatedTotalKeys, minRepairedAt, pendingRepair, cfs.metadata, new MetadataCollector(txn.originals(), cfs.metadata().comparator, sstableLevel), SerializationHeader.make(cfs.metadata(), nonExpiredSSTables), cfs.indexManager.listIndexes(), txn);
    sstableWriter.switchWriter(writer);
}
Also used : SSTableWriter(org.apache.cassandra.io.sstable.format.SSTableWriter) MetadataCollector(org.apache.cassandra.io.sstable.metadata.MetadataCollector)

Example 4 with MetadataCollector

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

the class SplittingSizeTieredCompactionWriter method switchCompactionLocation.

@Override
public void switchCompactionLocation(Directories.DataDirectory location) {
    this.location = location;
    long currentPartitionsToWrite = Math.round(ratios[currentRatioIndex] * estimatedTotalKeys);
    @SuppressWarnings("resource") SSTableWriter writer = SSTableWriter.create(cfs.newSSTableDescriptor(getDirectories().getLocationForDisk(location)), currentPartitionsToWrite, minRepairedAt, pendingRepair, cfs.metadata, new MetadataCollector(allSSTables, cfs.metadata().comparator, 0), SerializationHeader.make(cfs.metadata(), nonExpiredSSTables), cfs.indexManager.listIndexes(), txn);
    logger.trace("Switching writer, currentPartitionsToWrite = {}", currentPartitionsToWrite);
    sstableWriter.switchWriter(writer);
}
Also used : SSTableWriter(org.apache.cassandra.io.sstable.format.SSTableWriter) MetadataCollector(org.apache.cassandra.io.sstable.metadata.MetadataCollector)

Example 5 with MetadataCollector

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

the class SSTableTxnWriter method create.

// log and writer closed during doPostCleanup
@SuppressWarnings("resource")
public static SSTableTxnWriter create(TableMetadataRef metadata, Descriptor descriptor, long keyCount, long repairedAt, UUID pendingRepair, int sstableLevel, SerializationHeader header, Collection<Index> indexes) {
    // if the column family store does not exist, we create a new default SSTableMultiWriter to use:
    LifecycleTransaction txn = LifecycleTransaction.offline(OperationType.WRITE);
    MetadataCollector collector = new MetadataCollector(metadata.get().comparator).sstableLevel(sstableLevel);
    SSTableMultiWriter writer = SimpleSSTableMultiWriter.create(descriptor, keyCount, repairedAt, pendingRepair, metadata, collector, header, indexes, txn);
    return new SSTableTxnWriter(txn, writer);
}
Also used : LifecycleTransaction(org.apache.cassandra.db.lifecycle.LifecycleTransaction) MetadataCollector(org.apache.cassandra.io.sstable.metadata.MetadataCollector)

Aggregations

MetadataCollector (org.apache.cassandra.io.sstable.metadata.MetadataCollector)17 File (java.io.File)9 ClusteringComparator (org.apache.cassandra.db.ClusteringComparator)7 RandomAccessFile (java.io.RandomAccessFile)5 Test (org.junit.Test)5 IOException (java.io.IOException)3 ByteBuffer (java.nio.ByteBuffer)3 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)3 Descriptor (org.apache.cassandra.io.sstable.Descriptor)3 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)3 SSTableWriter (org.apache.cassandra.io.sstable.format.SSTableWriter)3 SerializationHeader (org.apache.cassandra.db.SerializationHeader)2 LifecycleTransaction (org.apache.cassandra.db.lifecycle.LifecycleTransaction)2 CompressedSequentialWriter (org.apache.cassandra.io.compress.CompressedSequentialWriter)2 CompressionMetadata (org.apache.cassandra.io.compress.CompressionMetadata)2 StatsMetadata (org.apache.cassandra.io.sstable.metadata.StatsMetadata)2 AlwaysPresentFilter (org.apache.cassandra.utils.AlwaysPresentFilter)2 Random (java.util.Random)1 FSReadError (org.apache.cassandra.io.FSReadError)1 FSWriteError (org.apache.cassandra.io.FSWriteError)1