Skip to content

Commit 8838edb

Browse files
committed
Merge branch 'master' of github.com:apache/spark into r-submit
2 parents e5b5a06 + 26d9b6b commit 8838edb

File tree

369 files changed

+10177
-3427
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

369 files changed

+10177
-3427
lines changed

R/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SparkR is an R package that provides a light-weight frontend to use Spark from R
66

77
#### Build Spark
88

9-
Build Spark with [Maven](http://spark.apache.org/docs/latest/building-spark.html#building-with-buildmvn) and include the `-PsparkR` profile to build the R package. For example to use the default Hadoop versions you can run
9+
Build Spark with [Maven](http://spark.apache.org/docs/latest/building-spark.html#building-with-buildmvn) and include the `-Psparkr` profile to build the R package. For example to use the default Hadoop versions you can run
1010
```
1111
build/mvn -DskipTests -Psparkr package
1212
```

R/pkg/R/generics.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
# @rdname aggregateRDD
2121
# @seealso reduce
2222
# @export
23-
setGeneric("aggregateRDD", function(x, zeroValue, seqOp, combOp) { standardGeneric("aggregateRDD") })
23+
setGeneric("aggregateRDD",
24+
function(x, zeroValue, seqOp, combOp) { standardGeneric("aggregateRDD") })
2425

2526
# @rdname cache-methods
2627
# @export

R/pkg/R/pairRDD.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,8 @@ setMethod("join",
560560
# Left outer join two RDDs
561561
#
562562
# @description
563-
# \code{leftouterjoin} This function left-outer-joins two RDDs where every element is of the form list(K, V).
564-
# The key types of the two RDDs should be the same.
563+
# \code{leftouterjoin} This function left-outer-joins two RDDs where every element is of
564+
# the form list(K, V). The key types of the two RDDs should be the same.
565565
#
566566
# @param x An RDD to be joined. Should be an RDD where each element is
567567
# list(K, V).
@@ -597,8 +597,8 @@ setMethod("leftOuterJoin",
597597
# Right outer join two RDDs
598598
#
599599
# @description
600-
# \code{rightouterjoin} This function right-outer-joins two RDDs where every element is of the form list(K, V).
601-
# The key types of the two RDDs should be the same.
600+
# \code{rightouterjoin} This function right-outer-joins two RDDs where every element is of
601+
# the form list(K, V). The key types of the two RDDs should be the same.
602602
#
603603
# @param x An RDD to be joined. Should be an RDD where each element is
604604
# list(K, V).
@@ -634,8 +634,8 @@ setMethod("rightOuterJoin",
634634
# Full outer join two RDDs
635635
#
636636
# @description
637-
# \code{fullouterjoin} This function full-outer-joins two RDDs where every element is of the form list(K, V).
638-
# The key types of the two RDDs should be the same.
637+
# \code{fullouterjoin} This function full-outer-joins two RDDs where every element is of
638+
# the form list(K, V). The key types of the two RDDs should be the same.
639639
#
640640
# @param x An RDD to be joined. Should be an RDD where each element is
641641
# list(K, V).

R/pkg/R/sparkR.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,12 @@ sparkR.init <- function(
105105
sparkPackages = "") {
106106

107107
if (exists(".sparkRjsc", envir = .sparkREnv)) {
108-
cat("Re-using existing Spark Context. Please stop SparkR with sparkR.stop() or restart R to create a new Spark Context\n")
108+
cat(paste("Re-using existing Spark Context.",
109+
"Please stop SparkR with sparkR.stop() or restart R to create a new Spark Context\n"))
109110
return(get(".sparkRjsc", envir = .sparkREnv))
110111
}
111112

112-
sparkMem <- Sys.getenv("SPARK_MEM", "512m")
113+
sparkMem <- Sys.getenv("SPARK_MEM", "1024m")
113114
jars <- suppressWarnings(normalizePath(as.character(sparkJars)))
114115

115116
# Classpath separator is ";" on Windows
@@ -180,14 +181,16 @@ sparkR.init <- function(
180181

181182
sparkExecutorEnvMap <- new.env()
182183
if (!any(names(sparkExecutorEnv) == "LD_LIBRARY_PATH")) {
183-
sparkExecutorEnvMap[["LD_LIBRARY_PATH"]] <- paste0("$LD_LIBRARY_PATH:",Sys.getenv("LD_LIBRARY_PATH"))
184+
sparkExecutorEnvMap[["LD_LIBRARY_PATH"]] <-
185+
paste0("$LD_LIBRARY_PATH:",Sys.getenv("LD_LIBRARY_PATH"))
184186
}
185187
for (varname in names(sparkExecutorEnv)) {
186188
sparkExecutorEnvMap[[varname]] <- sparkExecutorEnv[[varname]]
187189
}
188190

189191
nonEmptyJars <- Filter(function(x) { x != "" }, jars)
190-
localJarPaths <- sapply(nonEmptyJars, function(j) { utils::URLencode(paste("file:", uriSep, j, sep = "")) })
192+
localJarPaths <- sapply(nonEmptyJars,
193+
function(j) { utils::URLencode(paste("file:", uriSep, j, sep = "")) })
191194

192195
# Set the start time to identify jobjs
193196
# Seconds resolution is good enough for this purpose, so use ints

R/pkg/R/utils.R

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -334,18 +334,21 @@ getStorageLevel <- function(newLevel = c("DISK_ONLY",
334334
"MEMORY_ONLY_SER_2",
335335
"OFF_HEAP")) {
336336
match.arg(newLevel)
337+
storageLevelClass <- "org.apache.spark.storage.StorageLevel"
337338
storageLevel <- switch(newLevel,
338-
"DISK_ONLY" = callJStatic("org.apache.spark.storage.StorageLevel", "DISK_ONLY"),
339-
"DISK_ONLY_2" = callJStatic("org.apache.spark.storage.StorageLevel", "DISK_ONLY_2"),
340-
"MEMORY_AND_DISK" = callJStatic("org.apache.spark.storage.StorageLevel", "MEMORY_AND_DISK"),
341-
"MEMORY_AND_DISK_2" = callJStatic("org.apache.spark.storage.StorageLevel", "MEMORY_AND_DISK_2"),
342-
"MEMORY_AND_DISK_SER" = callJStatic("org.apache.spark.storage.StorageLevel", "MEMORY_AND_DISK_SER"),
343-
"MEMORY_AND_DISK_SER_2" = callJStatic("org.apache.spark.storage.StorageLevel", "MEMORY_AND_DISK_SER_2"),
344-
"MEMORY_ONLY" = callJStatic("org.apache.spark.storage.StorageLevel", "MEMORY_ONLY"),
345-
"MEMORY_ONLY_2" = callJStatic("org.apache.spark.storage.StorageLevel", "MEMORY_ONLY_2"),
346-
"MEMORY_ONLY_SER" = callJStatic("org.apache.spark.storage.StorageLevel", "MEMORY_ONLY_SER"),
347-
"MEMORY_ONLY_SER_2" = callJStatic("org.apache.spark.storage.StorageLevel", "MEMORY_ONLY_SER_2"),
348-
"OFF_HEAP" = callJStatic("org.apache.spark.storage.StorageLevel", "OFF_HEAP"))
339+
"DISK_ONLY" = callJStatic(storageLevelClass, "DISK_ONLY"),
340+
"DISK_ONLY_2" = callJStatic(storageLevelClass, "DISK_ONLY_2"),
341+
"MEMORY_AND_DISK" = callJStatic(storageLevelClass, "MEMORY_AND_DISK"),
342+
"MEMORY_AND_DISK_2" = callJStatic(storageLevelClass, "MEMORY_AND_DISK_2"),
343+
"MEMORY_AND_DISK_SER" = callJStatic(storageLevelClass,
344+
"MEMORY_AND_DISK_SER"),
345+
"MEMORY_AND_DISK_SER_2" = callJStatic(storageLevelClass,
346+
"MEMORY_AND_DISK_SER_2"),
347+
"MEMORY_ONLY" = callJStatic(storageLevelClass, "MEMORY_ONLY"),
348+
"MEMORY_ONLY_2" = callJStatic(storageLevelClass, "MEMORY_ONLY_2"),
349+
"MEMORY_ONLY_SER" = callJStatic(storageLevelClass, "MEMORY_ONLY_SER"),
350+
"MEMORY_ONLY_SER_2" = callJStatic(storageLevelClass, "MEMORY_ONLY_SER_2"),
351+
"OFF_HEAP" = callJStatic(storageLevelClass, "OFF_HEAP"))
349352
}
350353

351354
# Utility function for functions where an argument needs to be integer but we want to allow
@@ -545,9 +548,11 @@ mergePartitions <- function(rdd, zip) {
545548
lengthOfKeys <- part[[len - lengthOfValues]]
546549
stopifnot(len == lengthOfKeys + lengthOfValues)
547550

548-
# For zip operation, check if corresponding partitions of both RDDs have the same number of elements.
551+
# For zip operation, check if corresponding partitions
552+
# of both RDDs have the same number of elements.
549553
if (zip && lengthOfKeys != lengthOfValues) {
550-
stop("Can only zip RDDs with same number of elements in each pair of corresponding partitions.")
554+
stop(paste("Can only zip RDDs with same number of elements",
555+
"in each pair of corresponding partitions."))
551556
}
552557

553558
if (lengthOfKeys > 1) {

R/pkg/inst/tests/test_binaryFile.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ test_that("saveAsObjectFile()/objectFile() works with multiple paths", {
8282
saveAsObjectFile(rdd2, fileName2)
8383

8484
rdd <- objectFile(sc, c(fileName1, fileName2))
85-
expect_true(count(rdd) == 2)
85+
expect_equal(count(rdd), 2)
8686

8787
unlink(fileName1, recursive = TRUE)
8888
unlink(fileName2, recursive = TRUE)

R/pkg/inst/tests/test_binary_function.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ test_that("union on two RDDs", {
3838
union.rdd <- unionRDD(rdd, text.rdd)
3939
actual <- collect(union.rdd)
4040
expect_equal(actual, c(as.list(nums), mockFile))
41-
expect_true(getSerializedMode(union.rdd) == "byte")
41+
expect_equal(getSerializedMode(union.rdd), "byte")
4242

4343
rdd<- map(text.rdd, function(x) {x})
4444
union.rdd <- unionRDD(rdd, text.rdd)
4545
actual <- collect(union.rdd)
4646
expect_equal(actual, as.list(c(mockFile, mockFile)))
47-
expect_true(getSerializedMode(union.rdd) == "byte")
47+
expect_equal(getSerializedMode(union.rdd), "byte")
4848

4949
unlink(fileName)
5050
})

R/pkg/inst/tests/test_includeJAR.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ context("include an external JAR in SparkContext")
1818

1919
runScript <- function() {
2020
sparkHome <- Sys.getenv("SPARK_HOME")
21-
jarPath <- paste("--jars",
22-
shQuote(file.path(sparkHome, "R/lib/SparkR/test_support/sparktestjar_2.10-1.0.jar")))
21+
sparkTestJarPath <- "R/lib/SparkR/test_support/sparktestjar_2.10-1.0.jar"
22+
jarPath <- paste("--jars", shQuote(file.path(sparkHome, sparkTestJarPath)))
2323
scriptPath <- file.path(sparkHome, "R/lib/SparkR/tests/jarTest.R")
2424
submitPath <- file.path(sparkHome, "bin/spark-submit")
2525
res <- system2(command = submitPath,
@@ -31,7 +31,7 @@ runScript <- function() {
3131
test_that("sparkJars tag in SparkContext", {
3232
testOutput <- runScript()
3333
helloTest <- testOutput[1]
34-
expect_true(helloTest == "Hello, Dave")
34+
expect_equal(helloTest, "Hello, Dave")
3535
basicFunction <- testOutput[2]
36-
expect_true(basicFunction == 4L)
36+
expect_equal(basicFunction, "4")
3737
})

R/pkg/inst/tests/test_parallelize_collect.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ test_that("parallelize() on simple vectors and lists returns an RDD", {
5757
strListRDD2)
5858

5959
for (rdd in rdds) {
60-
expect_true(inherits(rdd, "RDD"))
60+
expect_is(rdd, "RDD")
6161
expect_true(.hasSlot(rdd, "jrdd")
6262
&& inherits(rdd@jrdd, "jobj")
6363
&& isInstanceOf(rdd@jrdd, "org.apache.spark.api.java.JavaRDD"))

R/pkg/inst/tests/test_rdd.R

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ test_that("get number of partitions in RDD", {
3333
})
3434

3535
test_that("first on RDD", {
36-
expect_true(first(rdd) == 1)
36+
expect_equal(first(rdd), 1)
3737
newrdd <- lapply(rdd, function(x) x + 1)
38-
expect_true(first(newrdd) == 2)
38+
expect_equal(first(newrdd), 2)
3939
})
4040

4141
test_that("count and length on RDD", {
@@ -669,27 +669,31 @@ test_that("fullOuterJoin() on pairwise RDDs", {
669669
rdd1 <- parallelize(sc, list(list(1,2), list(1,3), list(3,3)))
670670
rdd2 <- parallelize(sc, list(list(1,1), list(2,4)))
671671
actual <- collect(fullOuterJoin(rdd1, rdd2, 2L))
672-
expected <- list(list(1, list(2, 1)), list(1, list(3, 1)), list(2, list(NULL, 4)), list(3, list(3, NULL)))
672+
expected <- list(list(1, list(2, 1)), list(1, list(3, 1)),
673+
list(2, list(NULL, 4)), list(3, list(3, NULL)))
673674
expect_equal(sortKeyValueList(actual), sortKeyValueList(expected))
674675

675676
rdd1 <- parallelize(sc, list(list("a",2), list("a",3), list("c", 1)))
676677
rdd2 <- parallelize(sc, list(list("a",1), list("b",4)))
677678
actual <- collect(fullOuterJoin(rdd1, rdd2, 2L))
678-
expected <- list(list("b", list(NULL, 4)), list("a", list(2, 1)), list("a", list(3, 1)), list("c", list(1, NULL)))
679+
expected <- list(list("b", list(NULL, 4)), list("a", list(2, 1)),
680+
list("a", list(3, 1)), list("c", list(1, NULL)))
679681
expect_equal(sortKeyValueList(actual),
680682
sortKeyValueList(expected))
681683

682684
rdd1 <- parallelize(sc, list(list(1,1), list(2,2)))
683685
rdd2 <- parallelize(sc, list(list(3,3), list(4,4)))
684686
actual <- collect(fullOuterJoin(rdd1, rdd2, 2L))
685687
expect_equal(sortKeyValueList(actual),
686-
sortKeyValueList(list(list(1, list(1, NULL)), list(2, list(2, NULL)), list(3, list(NULL, 3)), list(4, list(NULL, 4)))))
688+
sortKeyValueList(list(list(1, list(1, NULL)), list(2, list(2, NULL)),
689+
list(3, list(NULL, 3)), list(4, list(NULL, 4)))))
687690

688691
rdd1 <- parallelize(sc, list(list("a",1), list("b",2)))
689692
rdd2 <- parallelize(sc, list(list("c",3), list("d",4)))
690693
actual <- collect(fullOuterJoin(rdd1, rdd2, 2L))
691694
expect_equal(sortKeyValueList(actual),
692-
sortKeyValueList(list(list("a", list(1, NULL)), list("b", list(2, NULL)), list("d", list(NULL, 4)), list("c", list(NULL, 3)))))
695+
sortKeyValueList(list(list("a", list(1, NULL)), list("b", list(2, NULL)),
696+
list("d", list(NULL, 4)), list("c", list(NULL, 3)))))
693697
})
694698

695699
test_that("sortByKey() on pairwise RDDs", {

0 commit comments

Comments
 (0)