Search in sources :

Example 11 with SequentialWriter

use of org.apache.cassandra.io.util.SequentialWriter in project cassandra by apache.

the class TokenTreeTest method buildTree.

private static TokenTree buildTree(TokenTreeBuilder builder) throws Exception {
    builder.finish();
    final File treeFile = FileUtils.createTempFile("token-tree-", "db");
    treeFile.deleteOnExit();
    try (SequentialWriter writer = new SequentialWriter(treeFile, DEFAULT_OPT)) {
        builder.write(writer);
        writer.sync();
    }
    final RandomAccessReader reader = RandomAccessReader.open(treeFile);
    return new TokenTree(new MappedBuffer(reader));
}
Also used : RandomAccessReader(org.apache.cassandra.io.util.RandomAccessReader) SequentialWriter(org.apache.cassandra.io.util.SequentialWriter) File(org.apache.cassandra.io.util.File) MappedBuffer(org.apache.cassandra.index.sasi.utils.MappedBuffer)

Example 12 with SequentialWriter

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

the class SSTableWriter method maybeWriteDigest.

private void maybeWriteDigest() throws IOException {
    byte[] digest = dataFile.digest();
    if (digest == null)
        return;
    SequentialWriter out = SequentialWriter.open(new File(descriptor.filenameFor(SSTable.COMPONENT_DIGEST)), true);
    // Writting output compatible with sha1sum
    Descriptor newdesc = descriptor.asTemporary(false);
    String[] tmp = newdesc.filenameFor(SSTable.COMPONENT_DATA).split(Pattern.quote(File.separator));
    String dataFileName = tmp[tmp.length - 1];
    out.write(String.format("%s  %s", Hex.bytesToHex(digest), dataFileName).getBytes());
    out.close();
}
Also used : DatabaseDescriptor(org.apache.cassandra.config.DatabaseDescriptor) SequentialWriter(org.apache.cassandra.io.util.SequentialWriter) CompressedSequentialWriter(org.apache.cassandra.io.compress.CompressedSequentialWriter) SegmentedFile(org.apache.cassandra.io.util.SegmentedFile)

Aggregations

SequentialWriter (org.apache.cassandra.io.util.SequentialWriter)12 File (org.apache.cassandra.io.util.File)10 RandomAccessReader (org.apache.cassandra.io.util.RandomAccessReader)6 MappedBuffer (org.apache.cassandra.index.sasi.utils.MappedBuffer)5 ByteBuffer (java.nio.ByteBuffer)4 Test (org.junit.Test)4 CRC32 (java.util.zip.CRC32)3 LongSet (com.carrotsearch.hppc.LongSet)2 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)2 CompressedSequentialWriter (org.apache.cassandra.io.compress.CompressedSequentialWriter)2 DataOutputBuffer (org.apache.cassandra.io.util.DataOutputBuffer)2 LongHashSet (com.carrotsearch.hppc.LongHashSet)1 Sets (com.google.common.collect.Sets)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Function (java.util.function.Function)1