StateMap — use LZ4 instead of snappy

This commit is contained in:
Vladimir Krivosheev
2018-04-13 18:12:14 +02:00
parent 0edbc64a1b
commit be6a9822e3
2 changed files with 5 additions and 4 deletions
@@ -20,5 +20,6 @@
<orderEntry type="module" module-name="intellij.platform.testExtensions" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.testFramework" scope="TEST" />
<orderEntry type="library" name="XStream" level="project" />
<orderEntry type="library" name="lz4-java" level="project" />
</component>
</module>
@@ -9,8 +9,8 @@ import com.intellij.util.ArrayUtil
import com.intellij.util.SystemProperties
import com.intellij.util.isEmpty
import gnu.trove.THashMap
import org.iq80.snappy.SnappyFramedInputStream
import org.iq80.snappy.SnappyFramedOutputStream
import net.jpountz.lz4.LZ4BlockInputStream
import net.jpountz.lz4.LZ4BlockOutputStream
import org.jdom.Element
import java.io.ByteArrayInputStream
import java.util.*
@@ -18,13 +18,13 @@ import java.util.concurrent.atomic.AtomicReferenceArray
fun archiveState(state: Element): BufferExposingByteArrayOutputStream {
val byteOut = BufferExposingByteArrayOutputStream()
SnappyFramedOutputStream(byteOut).use {
LZ4BlockOutputStream(byteOut).use {
serializeElementToBinary(state, it)
}
return byteOut
}
private fun unarchiveState(state: ByteArray) = SnappyFramedInputStream(ByteArrayInputStream(state), false).use { deserializeElementFromBinary(it) }
private fun unarchiveState(state: ByteArray) = LZ4BlockInputStream(ByteArrayInputStream(state)).use { deserializeElementFromBinary(it) }
fun getNewByteIfDiffers(key: String, newState: Any, oldState: ByteArray): ByteArray? {
val newBytes: ByteArray