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

Make TabixReader take a hadoop configuration in the constructor #5033

Merged
merged 3 commits into from
Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Make TabixReader take a hadoop configuration
This fixes a bug in import_vcfs as reading the indices and generating
partitions is parallelized.
  • Loading branch information
chrisvittal committed Dec 21, 2018
commit 70e5026e8afab68a91487d70cc2827b61d0443bb
4 changes: 1 addition & 3 deletions hail/src/main/scala/is/hail/io/tabix/TabixReader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ object TabixReader {

}

class TabixReader(val filePath: String, private val idxFilePath: Option[String] = None) {
class TabixReader(val filePath: String, private val hConf: hd.conf.Configuration, private val idxFilePath: Option[String] = None) {
import TabixReader._

val indexPath: String = idxFilePath match {
Expand All @@ -108,8 +108,6 @@ class TabixReader(val filePath: String, private val idxFilePath: Option[String]
}
}

private val hConf = HailContext.get.hadoopConf

val index: Tabix = hConf.readFile(indexPath) { is =>
var buf = new Array[Byte](4)
is.read(buf, 0, 4) // read magic bytes "TBI\1"
Expand Down
2 changes: 1 addition & 1 deletion hail/src/main/scala/is/hail/io/vcf/LoadVCF.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ case class VCFsReader(
entryType = genotypeSignature)

val partitions = {
val r = new TabixReader(file)
val r = new TabixReader(file, hConf)
localRangeBounds.zipWithIndex.map { case (b, i) =>
if (!(b.includesStart && b.includesEnd))
fatal("range bounds must be inclusive")
Expand Down
4 changes: 2 additions & 2 deletions hail/src/test/scala/is/hail/io/TabixSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class TabixSuite extends SparkSuite {
val vcfGzFile = vcfFile + ".gz"
val vcfGzTbiFile = vcfGzFile + ".tbi"

lazy val reader = new TabixReader(vcfGzFile)
lazy val bcConf = hc.sc.broadcast(new SerializableHadoopConfiguration(hc.hadoopConf))
lazy val reader = new TabixReader(vcfGzFile, hc.hadoopConf)

@BeforeTest def initialize() {
hc // reference to initialize
Expand Down Expand Up @@ -96,7 +96,7 @@ class TabixSuite extends SparkSuite {
val vcfFile = "src/test/resources/sample.vcf.bgz"
val chr = "20"
val htsjdkrdr = new HtsjdkTabixReader(vcfFile)
val hailrdr = new TabixReader(vcfFile)
val hailrdr = new TabixReader(vcfFile, hc.hadoopConf)
val tid = hailrdr.chr2tid(chr)

for ((start, end) <-
Expand Down