Search in sources :

Example 6 with DataOutputStreamPlus

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

the class SerializationsTest method testEstimatedHistogramWrite.

private static void testEstimatedHistogramWrite() throws IOException {
    EstimatedHistogram hist0 = new EstimatedHistogram();
    EstimatedHistogram hist1 = new EstimatedHistogram(5000);
    long[] offsets = new long[1000];
    long[] data = new long[offsets.length + 1];
    for (int i = 0; i < offsets.length; i++) {
        offsets[i] = i;
        data[i] = 10 * i;
    }
    data[offsets.length] = 100000;
    EstimatedHistogram hist2 = new EstimatedHistogram(offsets, data);
    try (DataOutputStreamPlus out = getOutput("utils.EstimatedHistogram.bin")) {
        EstimatedHistogram.serializer.serialize(hist0, out);
        EstimatedHistogram.serializer.serialize(hist1, out);
        EstimatedHistogram.serializer.serialize(hist2, out);
    }
}
Also used : DataOutputStreamPlus(org.apache.cassandra.io.util.DataOutputStreamPlus)

Example 7 with DataOutputStreamPlus

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

the class MetadataSerializer method rewriteSSTableMetadata.

private void rewriteSSTableMetadata(Descriptor descriptor, Map<MetadataType, MetadataComponent> currentComponents) throws IOException {
    String filePath = descriptor.tmpFilenameFor(Component.STATS);
    try (DataOutputStreamPlus out = new BufferedDataOutputStreamPlus(new FileOutputStream(filePath))) {
        serialize(currentComponents, out, descriptor.version);
        out.flush();
    }
    // we cant move a file on top of another file in windows:
    if (FBUtilities.isWindows)
        FileUtils.delete(descriptor.filenameFor(Component.STATS));
    FileUtils.renameWithConfirm(filePath, descriptor.filenameFor(Component.STATS));
}
Also used : BufferedDataOutputStreamPlus(org.apache.cassandra.io.util.BufferedDataOutputStreamPlus) BufferedDataOutputStreamPlus(org.apache.cassandra.io.util.BufferedDataOutputStreamPlus) DataOutputStreamPlus(org.apache.cassandra.io.util.DataOutputStreamPlus)

Aggregations

DataOutputStreamPlus (org.apache.cassandra.io.util.DataOutputStreamPlus)7 BufferedDataOutputStreamPlus (org.apache.cassandra.io.util.BufferedDataOutputStreamPlus)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InetAddress (java.net.InetAddress)1 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 DataInputStreamPlus (org.apache.cassandra.io.util.DataInputPlus.DataInputStreamPlus)1 WrappedDataOutputStreamPlus (org.apache.cassandra.io.util.WrappedDataOutputStreamPlus)1