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);
}
}
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));
}
Aggregations