Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NativeReaderOptions to abstract indexed read options
- Loading branch information
1 parent
9412c0c
commit 6249db3
Showing
7 changed files
with
69 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
hail/src/main/scala/is/hail/expr/ir/NativeReaderOptions.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package is.hail.expr.ir | ||
|
||
import is.hail.annotations._ | ||
import is.hail.expr.types.virtual._ | ||
import is.hail.expr.JSONAnnotationImpex | ||
import is.hail.utils._ | ||
import org.json4s.{Formats, ShortTypeHints, CustomSerializer, JObject} | ||
import org.json4s.JsonAST.{JArray, JInt, JNull, JString, JField, JNothing} | ||
import org.json4s.JsonDSL._ | ||
import org.json4s.jackson.JsonMethods | ||
|
||
class NativeReaderOptionsSerializer() extends CustomSerializer[NativeReaderOptions]( | ||
format => | ||
({ case jObj: JObject => | ||
implicit val fmt = format | ||
val filterIntervals = (jObj \ "filterIntervals").extract[Boolean] | ||
val intervalPointType = IRParser.parseType((jObj \ "intervalPointType").extract[String]) | ||
val intervals = { | ||
val jv = jObj \ "intervals" | ||
val ty = TArray(TInterval(intervalPointType)) | ||
JSONAnnotationImpex.importAnnotation(jv, ty).asInstanceOf[IndexedSeq[Interval]] | ||
} | ||
NativeReaderOptions(intervals, intervalPointType, filterIntervals) | ||
}, { case opts: NativeReaderOptions => | ||
implicit val fmt = format | ||
val ty = TArray(TInterval(opts.intervalPointType)) | ||
(("name" -> opts.getClass.getSimpleName) ~ | ||
("intervals" -> JSONAnnotationImpex.exportAnnotation(opts.intervals, ty)) ~ | ||
("intervalPointType" -> opts.intervalPointType.parsableString()) ~ | ||
("filterIntervals" -> opts.filterIntervals)) | ||
}) | ||
) | ||
|
||
case class NativeReaderOptions( | ||
intervals: IndexedSeq[Interval], | ||
intervalPointType: Type, | ||
filterIntervals: Boolean = false | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters