Search in sources :

Example 21 with RandomAccessReader

use of org.apache.cassandra.io.util.RandomAccessReader in project eiger by wlloyd.

the class SSTableTest method verifyMany.

private void verifyMany(SSTableReader sstable, Map<ByteBuffer, ByteBuffer> map) throws IOException {
    List<ByteBuffer> keys = new ArrayList<ByteBuffer>(map.keySet());
    Collections.shuffle(keys);
    RandomAccessReader file = sstable.openDataReader(false);
    for (ByteBuffer key : keys) {
        file.seek(sstable.getPosition(sstable.partitioner.decorateKey(key), SSTableReader.Operator.EQ));
        assert key.equals(ByteBufferUtil.readWithShortLength(file));
        int size = (int) SSTableReader.readRowSize(file, sstable.descriptor);
        byte[] bytes2 = new byte[size];
        file.readFully(bytes2);
        assert Arrays.equals(bytes2, map.get(key).array());
    }
}
Also used : RandomAccessReader(org.apache.cassandra.io.util.RandomAccessReader) ByteBuffer(java.nio.ByteBuffer)

Aggregations

RandomAccessReader (org.apache.cassandra.io.util.RandomAccessReader)21 File (java.io.File)12 SequentialWriter (org.apache.cassandra.io.util.SequentialWriter)6 ByteBuffer (java.nio.ByteBuffer)5 MappedBuffer (org.apache.cassandra.index.sasi.utils.MappedBuffer)5 LongSet (com.carrotsearch.hppc.LongSet)2 LZFOutputStream (com.ning.compress.lzf.LZFOutputStream)2 IOException (java.io.IOException)2 RandomAccessFile (java.io.RandomAccessFile)2 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)2 SyncSegment (org.apache.cassandra.db.commitlog.CommitLogSegmentReader.SyncSegment)2 Descriptor (org.apache.cassandra.io.sstable.Descriptor)2 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)2 Test (org.junit.Test)2 LongOpenHashSet (com.carrotsearch.hppc.LongOpenHashSet)1 FileOutputStream (java.io.FileOutputStream)1 IOError (java.io.IOError)1 FileChannel (java.nio.channels.FileChannel)1 Cipher (javax.crypto.Cipher)1 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)1