Skip to content

Commit

Permalink
test code for R
Browse files Browse the repository at this point in the history
  • Loading branch information
akmorrow13 committed Jan 25, 2018
1 parent 7cf9628 commit cc93505
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
8 changes: 4 additions & 4 deletions adam-r/bdgenomics.adam/R/rdd.R
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,19 @@ setMethod("cache",
replaceRdd(ardd, sparkR.callJMethod(ardd@jrdd, "cache"))
})


#' Persists the existing ardd
#'
#' @param ardd The RDD to apply this to.
#' @param sl the StorageLevel to persist in.
#'
#' @importFrom SparkR sparkR.callJMethod
#' @importFrom SparkR sparkR.callJMethod sparkR.callJStatic
#'
#' @export
setMethod("persist",
signature(ardd = "GenomicRDD",
sl = "StorageLevel"),
function(ardd) {
sl = "character"),
function(ardd, sl) {
storageLevel <- sparkR.callJStatic("org.apache.spark.storage.StorageLevel", "fromString", sl)
replaceRdd(ardd, sparkR.callJMethod(ardd@jrdd, "persist", sl))
})

Expand Down
20 changes: 20 additions & 0 deletions adam-r/bdgenomics.adam/tests/testthat/test_alignmentRecordRdd.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,23 @@ test_that("transmute to coverage", {
expect_true(is(readsAsCoverage, "CoverageRDD"))
expect_equal(count(toDF(readsAsCoverage)), 5)
})

test_that("reads can cache", {

readsPath <- resourceFile("unsorted.sam")
reads <- loadAlignments(ac, readsPath)

cache(reads)
unpersist(reads)
})

test_that("reads can persist with storage level", {

readsPath <- resourceFile("unsorted.sam")
reads <- loadAlignments(ac, readsPath)
storageLevel <- "MEMORY_AND_DISK"

persist(reads, storageLevel)
unpersist(reads)
})

0 comments on commit cc93505

Please sign in to comment.