Skip to content

Commit

Permalink
Use snappy
Browse files Browse the repository at this point in the history
  • Loading branch information
Friendseeker committed Oct 5, 2024
1 parent d417c73 commit a6ba23f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ lazy val zincPersist = (projectMatrix in internalPath / "zinc-persist")
name := "zinc Persist",
libraryDependencies ++= Seq(
sbinary.exclude("org.scala-lang.modules", "scala-xml_" + scalaBinaryVersion.value),
scalaXml
scalaXml,
snappy,
),
compileOrder := sbt.CompileOrder.Mixed,
Compile / scalacOptions ++= (scalaVersion.value match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ package sbt.internal.inc.consistent
* additional information regarding copyright ownership.
*/

import org.xerial.snappy.{ SnappyInputStream, SnappyOutputStream }

import java.io.{ File, FileInputStream, FileOutputStream }
import java.util.Optional
import sbt.io.{ IO, Using }
Expand Down Expand Up @@ -85,7 +87,7 @@ object ConsistentFileAnalysisStore {
if (!file.getParentFile.exists()) file.getParentFile.mkdirs()
val fout = new FileOutputStream(tmpAnalysisFile)
try {
val gout = new ParallelGzipOutputStream(fout, ec, parallelism)
val gout = new SnappyOutputStream(fout)
val ser = sf.serializerFor(gout)
format.write(ser, analysis, setup)
gout.close()
Expand All @@ -98,11 +100,14 @@ object ConsistentFileAnalysisStore {
allCatch.opt(unsafeGet()).toOptional
}

def unsafeGet(): AnalysisContents =
Using.gzipInputStream(new FileInputStream(file)) { in =>
def unsafeGet(): AnalysisContents = {
Using.resource(new SnappyInputStream(_: FileInputStream))(
new FileInputStream(file)
) { in =>
val deser = sf.deserializerFor(in)
val (analysis, setup) = format.read(deser)
AnalysisContents.create(analysis, setup)
}
}
}
}
1 change: 1 addition & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ object Dependencies {
"com.eed3si9n" %% "sjson-new-scalajson" % contrabandSjsonNewVersion.value
}
val zeroAllocationHashing = "net.openhft" % "zero-allocation-hashing" % "0.16"
val snappy = "org.xerial.snappy" % "snappy-java" % "1.1.10.7"
val scala2BinaryBridge = "org.scala-lang" % "scala2-sbt-bridge" % scala213ForBridge
val scala3BinaryBridge = "org.scala-lang" % "scala3-sbt-bridge" % scala3ForBridge

Expand Down

0 comments on commit a6ba23f

Please sign in to comment.