1a6b510784
This pull request adds following methods to SparkR:
```R
setJobGroup()
cancelJobGroup()
clearJobGroup()
```
For each method, the spark context is passed as the first argument. There does not seem to be a good way to test these in R.
cc shivaram and davies
Author: Hossein <hossein@databricks.com>
Closes #6889 from falaki/SPARK-8452 and squashes the following commits:
9ce9f1e [Hossein] Added basic tests to verify methods can be called and won't throw errors
c706af9 [Hossein] Added examples
a2c19af [Hossein] taking spark context as first argument
343ca77 [Hossein] Added setJobGroup, cancelJobGroup and clearJobGroup to SparkR
(cherry picked from commit 1fa29c2df2
)
Signed-off-by: Shivaram Venkataraman <shivaram@cs.berkeley.edu>
58 lines
1.7 KiB
R
58 lines
1.7 KiB
R
#
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
# this work for additional information regarding copyright ownership.
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
# (the "License"); you may not use this file except in compliance with
|
|
# the License. You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
#
|
|
|
|
context("test functions in sparkR.R")
|
|
|
|
test_that("repeatedly starting and stopping SparkR", {
|
|
for (i in 1:4) {
|
|
sc <- sparkR.init()
|
|
rdd <- parallelize(sc, 1:20, 2L)
|
|
expect_equal(count(rdd), 20)
|
|
sparkR.stop()
|
|
}
|
|
})
|
|
|
|
test_that("rdd GC across sparkR.stop", {
|
|
sparkR.stop()
|
|
sc <- sparkR.init() # sc should get id 0
|
|
rdd1 <- parallelize(sc, 1:20, 2L) # rdd1 should get id 1
|
|
rdd2 <- parallelize(sc, 1:10, 2L) # rdd2 should get id 2
|
|
sparkR.stop()
|
|
|
|
sc <- sparkR.init() # sc should get id 0 again
|
|
|
|
# GC rdd1 before creating rdd3 and rdd2 after
|
|
rm(rdd1)
|
|
gc()
|
|
|
|
rdd3 <- parallelize(sc, 1:20, 2L) # rdd3 should get id 1 now
|
|
rdd4 <- parallelize(sc, 1:10, 2L) # rdd4 should get id 2 now
|
|
|
|
rm(rdd2)
|
|
gc()
|
|
|
|
count(rdd3)
|
|
count(rdd4)
|
|
})
|
|
|
|
test_that("job group functions can be called", {
|
|
sc <- sparkR.init()
|
|
setJobGroup(sc, "groupId", "job description", TRUE)
|
|
cancelJobGroup(sc, "groupId")
|
|
clearJobGroup(sc)
|
|
})
|