You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2020/04/28 02:01:30 UTC
[spark] branch branch-3.0 updated: [SPARK-31568][R] Replaces
paste(sep="") to paste0
This is an automated email from the ASF dual-hosted git repository.
gurwls223 pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 9b41ae2 [SPARK-31568][R] Replaces paste(sep="") to paste0
9b41ae2 is described below
commit 9b41ae20cf450d26c9f0311d342722a0e6309255
Author: Michael Chirico <mi...@grabtaxi.com>
AuthorDate: Tue Apr 28 10:58:48 2020 +0900
[SPARK-31568][R] Replaces paste(sep="") to paste0
### What changes were proposed in this pull request?
All instances of `paste(..., sep = "")` in the code are replaced with `paste0` which is more performant
### Why are the changes needed?
Performance & consistency (`paste0` is already used extensively in the R package)
### Does this PR introduce any user-facing change?
No
### How was this patch tested?
None
Closes #28374 from MichaelChirico/r-paste0.
Authored-by: Michael Chirico <mi...@grabtaxi.com>
Signed-off-by: HyukjinKwon <gu...@apache.org>
(cherry picked from commit a68d98cf4f25cb357353860ca4f9a8d909a52ee1)
Signed-off-by: HyukjinKwon <gu...@apache.org>
---
R/pkg/R/DataFrame.R | 10 +++++-----
R/pkg/R/RDD.R | 2 +-
R/pkg/R/mllib_classification.R | 2 +-
R/pkg/R/schema.R | 7 +++----
R/pkg/R/sparkR.R | 2 +-
R/pkg/R/utils.R | 2 +-
R/pkg/tests/fulltests/test_sparkSQL.R | 32 ++++++++++++++++----------------
7 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/R/pkg/R/DataFrame.R b/R/pkg/R/DataFrame.R
index 2ebd42a..a734804 100644
--- a/R/pkg/R/DataFrame.R
+++ b/R/pkg/R/DataFrame.R
@@ -271,7 +271,7 @@ setMethod("show", "SparkDataFrame",
paste(l, collapse = ":")
})
s <- paste(cols, collapse = ", ")
- cat(paste(class(object), "[", s, "]\n", sep = ""))
+ cat(paste0(class(object), "[", s, "]\n"))
}
})
@@ -2755,10 +2755,10 @@ setMethod("merge",
colY <- joinY[[i]]
if (colX %in% by) {
- colX <- paste(colX, suffixes[1], sep = "")
+ colX <- paste0(colX, suffixes[1])
}
if (colY %in% by) {
- colY <- paste(colY, suffixes[2], sep = "")
+ colY <- paste0(colY, suffixes[2])
}
colX <- getColumn(xsel, colX)
@@ -2773,7 +2773,7 @@ setMethod("merge",
# sorts the result by 'by' columns if sort = TRUE
if (sort && length(by) > 0) {
- colNameWithSuffix <- paste(by, suffixes[2], sep = "")
+ colNameWithSuffix <- paste0(by, suffixes[2])
joinRes <- do.call("arrange", c(joinRes, colNameWithSuffix, decreasing = FALSE))
}
@@ -2796,7 +2796,7 @@ genAliasesForIntersectedCols <- function(x, intersectedColNames, suffix) {
cols <- lapply(allColNames, function(colName) {
col <- getColumn(x, colName)
if (colName %in% intersectedColNames) {
- newJoin <- paste(colName, suffix, sep = "")
+ newJoin <- paste0(colName, suffix)
if (newJoin %in% allColNames) {
stop("The following column name: ", newJoin, " occurs more than once in the 'DataFrame'.",
"Please use different suffixes for the intersected columns.")
diff --git a/R/pkg/R/RDD.R b/R/pkg/R/RDD.R
index 6e89b4b..7ee725d 100644
--- a/R/pkg/R/RDD.R
+++ b/R/pkg/R/RDD.R
@@ -69,7 +69,7 @@ setMethod("initialize", "RDD", function(.Object, jrdd, serializedMode,
setMethod("showRDD", "RDD",
function(object) {
- cat(paste(callJMethod(getJRDD(object), "toString"), "\n", sep = ""))
+ cat(paste0(callJMethod(getJRDD(object), "toString"), "\n"))
})
setMethod("initialize", "PipelinedRDD", function(.Object, prev, func, jrdd_val) {
diff --git a/R/pkg/R/mllib_classification.R b/R/pkg/R/mllib_classification.R
index 3ad824e..1af81f8 100644
--- a/R/pkg/R/mllib_classification.R
+++ b/R/pkg/R/mllib_classification.R
@@ -332,7 +332,7 @@ setMethod("spark.logit", signature(data = "SparkDataFrame", formula = "formula")
if (!is.null(lowerBoundsOnCoefficients) && (row != nrow(upperBoundsOnCoefficients)
|| col != ncol(upperBoundsOnCoefficients))) {
stop(paste0("dimension of upperBoundsOnCoefficients ",
- "is not the same as lowerBoundsOnCoefficients", sep = ""))
+ "is not the same as lowerBoundsOnCoefficients"))
}
if (is.null(lowerBoundsOnCoefficients)) {
diff --git a/R/pkg/R/schema.R b/R/pkg/R/schema.R
index 9831fc3..8d2d9a1 100644
--- a/R/pkg/R/schema.R
+++ b/R/pkg/R/schema.R
@@ -99,10 +99,9 @@ print.structType <- function(x, ...) {
cat("StructType\n",
sapply(x$fields(),
function(field) {
- paste("|-", "name = \"", field$name(),
- "\", type = \"", field$dataType.toString(),
- "\", nullable = ", field$nullable(), "\n",
- sep = "")
+ paste0("|-", "name = \"", field$name(),
+ "\", type = \"", field$dataType.toString(),
+ "\", nullable = ", field$nullable(), "\n")
}),
sep = "")
}
diff --git a/R/pkg/R/sparkR.R b/R/pkg/R/sparkR.R
index cc8c92b..2ece83a 100644
--- a/R/pkg/R/sparkR.R
+++ b/R/pkg/R/sparkR.R
@@ -244,7 +244,7 @@ sparkR.sparkContext <- function(
uriSep <- "////"
}
localJarPaths <- lapply(jars,
- function(j) { utils::URLencode(paste("file:", uriSep, j, sep = "")) })
+ function(j) { utils::URLencode(paste0("file:", uriSep, j)) })
# Set the start time to identify jobjs
# Seconds resolution is good enough for this purpose, so use ints
diff --git a/R/pkg/R/utils.R b/R/pkg/R/utils.R
index a8c1ddb..9d7d1a4 100644
--- a/R/pkg/R/utils.R
+++ b/R/pkg/R/utils.R
@@ -137,7 +137,7 @@ hashCode <- function(key) {
as.integer(hashC)
}
} else {
- warning(paste("Could not hash object, returning 0", sep = ""))
+ warning("Could not hash object, returning 0")
as.integer(0)
}
}
diff --git a/R/pkg/tests/fulltests/test_sparkSQL.R b/R/pkg/tests/fulltests/test_sparkSQL.R
index 32536de..0b55271 100644
--- a/R/pkg/tests/fulltests/test_sparkSQL.R
+++ b/R/pkg/tests/fulltests/test_sparkSQL.R
@@ -2507,8 +2507,8 @@ test_that("join(), crossJoin() and merge() on a DataFrame", {
writeLines(mockLines3, jsonPath3)
df3 <- read.json(jsonPath3)
expect_error(merge(df, df3),
- paste("The following column name: name_y occurs more than once in the 'DataFrame'.",
- "Please use different suffixes for the intersected columns.", sep = ""))
+ paste0("The following column name: name_y occurs more than once in the 'DataFrame'.",
+ "Please use different suffixes for the intersected columns."))
unlink(jsonPath2)
unlink(jsonPath3)
@@ -2551,20 +2551,20 @@ test_that("toJSON() on DataFrame", {
test_that("showDF()", {
df <- read.json(jsonPath)
- expected <- paste("+----+-------+\n",
- "| age| name|\n",
- "+----+-------+\n",
- "|null|Michael|\n",
- "| 30| Andy|\n",
- "| 19| Justin|\n",
- "+----+-------+\n", sep = "")
- expected2 <- paste("+---+----+\n",
- "|age|name|\n",
- "+---+----+\n",
- "|nul| Mic|\n",
- "| 30| And|\n",
- "| 19| Jus|\n",
- "+---+----+\n", sep = "")
+ expected <- paste("+----+-------+",
+ "| age| name|",
+ "+----+-------+",
+ "|null|Michael|",
+ "| 30| Andy|",
+ "| 19| Justin|",
+ "+----+-------+\n", sep = "\n")
+ expected2 <- paste("+---+----+",
+ "|age|name|",
+ "+---+----+",
+ "|nul| Mic|",
+ "| 30| And|",
+ "| 19| Jus|",
+ "+---+----+\n", sep = "\n")
expect_output(showDF(df), expected)
expect_output(showDF(df, truncate = 3), expected2)
})
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org