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

Fix partitioning code to use Long instead of Int #1980

Merged
merged 2 commits into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
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
18 changes: 11 additions & 7 deletions adam-core/src/main/scala/org/bdgenomics/adam/rdd/GenomicRDD.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import org.json4s.JsonDSL._
import org.json4s.jackson.JsonMethods._
import scala.annotation.tailrec
import scala.collection.JavaConversions._
import scala.math.min
import scala.math.{ floor => mathFloor, min }
import scala.reflect.ClassTag
import scala.reflect.runtime.universe._
import scala.util.Try
Expand Down Expand Up @@ -3293,12 +3293,16 @@ trait DatasetBoundGenomicDataset[T, U <: Product, V <: GenomicDataset[T, U, V]]
private def referenceRegionsToDatasetQueryString(regions: Iterable[ReferenceRegion]): String = {

if (Try(dataset("positionBin")).isSuccess) {
regions.map(r =>
s"(contigName=\'${r.referenceName}\' and positionBin >= " +
s"\'${(scala.math.floor(r.start / optPartitionBinSize.get).toInt) - optLookbackPartitions.get}\'" +
s" and positionBin < \'${(scala.math.floor(r.end / optPartitionBinSize.get).toInt + 1)}\'" +
s" and (end > ${r.start} and start < ${r.end}))"
).mkString(" or ")

regions.map(r => {
val startBin = (mathFloor(r.start / optPartitionBinSize.get).toLong) - optLookbackPartitions.get
val endBin = min(Int.MaxValue.toLong, (mathFloor(r.end / optPartitionBinSize.get).toLong + 1)).toInt

(s"(contigName=\'${r.referenceName}\' and positionBin >= " +
s"\'${startBin}\'" +
s" and positionBin < \'${endBin}\'" +
s" and (end > ${r.start} and start < ${r.end}))")
}).mkString(" or ")
} else { // if no positionBin field is found then construct query without bin optimization
regions.map(r =>
s"(contigName=\'${r.referenceName} \' " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,10 @@ class AlignmentRecordRDDSuite extends ADAMFunSuite {
assert(rdd3.dataset.count === 2)
assert(rdd3.rdd.count === 2)

// ADAM-1967: ensure that ReferenceRegion.all works
assert(sc.loadPartitionedParquetAlignments(outputPath,
List(ReferenceRegion.all("1"))).dataset.count === 2)

//test explicit transform to Alignment Record Product
val rdd = rrdd.transformDataset(ds => {
import ds.sqlContext.implicits._
Expand Down