use of com.intellij.openapi.util.io.ByteSequence in project intellij-community by JetBrains.
the class PersistentHashMapValueStorage method compactChunks.
long compactChunks(PersistentHashMap.ValueDataAppender appender, ReadResult result) throws IOException {
checkCancellation();
long startedTime = ourDumpChunkRemovalTime ? System.nanoTime() : 0;
long newValueOffset;
if (myCompactChunksWithValueDeserialization) {
final BufferExposingByteArrayOutputStream stream = new BufferExposingByteArrayOutputStream(result.buffer.length);
DataOutputStream testStream = new DataOutputStream(stream);
appender.append(testStream);
newValueOffset = appendBytes(stream.getInternalBuffer(), 0, stream.size(), 0);
myChunksBytesAfterRemoval += stream.size();
} else {
newValueOffset = appendBytes(new ByteSequence(result.buffer), 0);
myChunksBytesAfterRemoval += result.buffer.length;
}
if (ourDumpChunkRemovalTime) {
myChunksRemovalTime += System.nanoTime() - startedTime;
if (myChunks - myLastReportedChunksCount > 1000) {
myLastReportedChunksCount = myChunks;
System.out.println(myChunks + " chunks were read " + (myChunksReadingTime / 1000000) + "ms, bytes: " + myChunksOriginalBytes + (myChunksOriginalBytes != myChunksBytesAfterRemoval ? "->" + myChunksBytesAfterRemoval : "") + " compaction:" + (myChunksRemovalTime / 1000000) + "ms in " + myPath);
}
}
return newValueOffset;
}
Aggregations