Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back compression in GenotypeStream (unconditional). #1690

Merged
merged 1 commit into from
Apr 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/main/scala/is/hail/variant/GenotypeStream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package is.hail.variant
import java.nio.ByteBuffer

import is.hail.expr.{TBinary, TInt, TStruct, Type}
import is.hail.utils._
import is.hail.utils.{ByteIterator, _}
import net.jpountz.lz4.LZ4Factory
import org.apache.spark.sql.Row
import org.apache.spark.sql.types._
import org.apache.spark.sql.types.{StructType, _}

import scala.collection.mutable

Expand Down Expand Up @@ -56,7 +56,7 @@ object LZ4Utils {
compressed.take(compressedLen)
}

def decompress(decompLen: Int, a: Array[Byte]): Array[Byte] = {
def decompress(decompLen: Int, a: Array[Byte]) = {
val decomp = Array.ofDim[Byte](decompLen)
val compLen = decompressor.decompress(a, 0, decomp, 0, decompLen)
assert(compLen == a.length)
Expand Down Expand Up @@ -169,5 +169,8 @@ class GenotypeStreamBuilder(nAlleles: Int, isDosage: Boolean = false)
b.clear()
}

override def result(): GenotypeStream = GenotypeStream(nAlleles, isDosage, None, b.result())
override def result(): GenotypeStream = {
val a = b.result()
GenotypeStream(nAlleles, isDosage, Some(a.length), LZ4Utils.compress(a))
}
}