Search in sources :

Example 11 with ByteSequence

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;
}
Also used : BufferExposingByteArrayOutputStream(com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream) ByteSequence(com.intellij.openapi.util.io.ByteSequence)

Aggregations

ByteSequence (com.intellij.openapi.util.io.ByteSequence)11 NotNull (org.jetbrains.annotations.NotNull)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 File (java.io.File)3 ArchiveFileType (com.intellij.ide.highlighter.ArchiveFileType)2 ModuleFileType (com.intellij.ide.highlighter.ModuleFileType)2 ProjectFileType (com.intellij.ide.highlighter.ProjectFileType)2 PsiBinaryFile (com.intellij.psi.PsiBinaryFile)2 PsiFile (com.intellij.psi.PsiFile)2 PsiPlainTextFile (com.intellij.psi.PsiPlainTextFile)2 Nullable (org.jetbrains.annotations.Nullable)2 BufferExposingByteArrayOutputStream (com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 JarOutputStream (java.util.jar.JarOutputStream)1 Manifest (java.util.jar.Manifest)1