Skip to content

Commit fddb63f

Browse files
actuaryzhangFelix Cheung
authored andcommitted
[SPARK-20889][SPARKR] Grouped documentation for MISC column methods
## What changes were proposed in this pull request? Grouped documentation for column misc methods. Author: actuaryzhang <[email protected]> Author: Wayne Zhang <[email protected]> Closes apache#18448 from actuaryzhang/sparkRDocMisc.
1 parent e2f32ee commit fddb63f

File tree

2 files changed

+55
-58
lines changed

2 files changed

+55
-58
lines changed

R/pkg/R/functions.R

Lines changed: 45 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,27 @@ NULL
150150
#' df <- createDataFrame(cbind(model = rownames(mtcars), mtcars))}
151151
NULL
152152

153+
#' Miscellaneous functions for Column operations
154+
#'
155+
#' Miscellaneous functions defined for \code{Column}.
156+
#'
157+
#' @param x Column to compute on. In \code{sha2}, it is one of 224, 256, 384, or 512.
158+
#' @param y Column to compute on.
159+
#' @param ... additional Columns.
160+
#' @name column_misc_functions
161+
#' @rdname column_misc_functions
162+
#' @family misc functions
163+
#' @examples
164+
#' \dontrun{
165+
#' # Dataframe used throughout this doc
166+
#' df <- createDataFrame(cbind(model = rownames(mtcars), mtcars)[, 1:2])
167+
#' tmp <- mutate(df, v1 = crc32(df$model), v2 = hash(df$model),
168+
#' v3 = hash(df$model, df$mpg), v4 = md5(df$model),
169+
#' v5 = sha1(df$model), v6 = sha2(df$model, 256))
170+
#' head(tmp)
171+
#' }
172+
NULL
173+
153174
#' @details
154175
#' \code{lit}: A new Column is created to represent the literal value.
155176
#' If the parameter is a Column, it is returned unchanged.
@@ -569,19 +590,13 @@ setMethod("count",
569590
column(jc)
570591
})
571592

572-
#' crc32
573-
#'
574-
#' Calculates the cyclic redundancy check value (CRC32) of a binary column and
575-
#' returns the value as a bigint.
576-
#'
577-
#' @param x Column to compute on.
593+
#' @details
594+
#' \code{crc32}: Calculates the cyclic redundancy check value (CRC32) of a binary column
595+
#' and returns the value as a bigint.
578596
#'
579-
#' @rdname crc32
580-
#' @name crc32
581-
#' @family misc functions
582-
#' @aliases crc32,Column-method
597+
#' @rdname column_misc_functions
598+
#' @aliases crc32 crc32,Column-method
583599
#' @export
584-
#' @examples \dontrun{crc32(df$c)}
585600
#' @note crc32 since 1.5.0
586601
setMethod("crc32",
587602
signature(x = "Column"),
@@ -590,19 +605,13 @@ setMethod("crc32",
590605
column(jc)
591606
})
592607

593-
#' hash
594-
#'
595-
#' Calculates the hash code of given columns, and returns the result as a int column.
596-
#'
597-
#' @param x Column to compute on.
598-
#' @param ... additional Column(s) to be included.
608+
#' @details
609+
#' \code{hash}: Calculates the hash code of given columns, and returns the result
610+
#' as an int column.
599611
#'
600-
#' @rdname hash
601-
#' @name hash
602-
#' @family misc functions
603-
#' @aliases hash,Column-method
612+
#' @rdname column_misc_functions
613+
#' @aliases hash hash,Column-method
604614
#' @export
605-
#' @examples \dontrun{hash(df$c)}
606615
#' @note hash since 2.0.0
607616
setMethod("hash",
608617
signature(x = "Column"),
@@ -1055,19 +1064,13 @@ setMethod("max",
10551064
column(jc)
10561065
})
10571066

1058-
#' md5
1059-
#'
1060-
#' Calculates the MD5 digest of a binary column and returns the value
1067+
#' @details
1068+
#' \code{md5}: Calculates the MD5 digest of a binary column and returns the value
10611069
#' as a 32 character hex string.
10621070
#'
1063-
#' @param x Column to compute on.
1064-
#'
1065-
#' @rdname md5
1066-
#' @name md5
1067-
#' @family misc functions
1068-
#' @aliases md5,Column-method
1071+
#' @rdname column_misc_functions
1072+
#' @aliases md5 md5,Column-method
10691073
#' @export
1070-
#' @examples \dontrun{md5(df$c)}
10711074
#' @note md5 since 1.5.0
10721075
setMethod("md5",
10731076
signature(x = "Column"),
@@ -1307,19 +1310,13 @@ setMethod("second",
13071310
column(jc)
13081311
})
13091312

1310-
#' sha1
1311-
#'
1312-
#' Calculates the SHA-1 digest of a binary column and returns the value
1313+
#' @details
1314+
#' \code{sha1}: Calculates the SHA-1 digest of a binary column and returns the value
13131315
#' as a 40 character hex string.
13141316
#'
1315-
#' @param x Column to compute on.
1316-
#'
1317-
#' @rdname sha1
1318-
#' @name sha1
1319-
#' @family misc functions
1320-
#' @aliases sha1,Column-method
1317+
#' @rdname column_misc_functions
1318+
#' @aliases sha1 sha1,Column-method
13211319
#' @export
1322-
#' @examples \dontrun{sha1(df$c)}
13231320
#' @note sha1 since 1.5.0
13241321
setMethod("sha1",
13251322
signature(x = "Column"),
@@ -2309,19 +2306,14 @@ setMethod("format_number", signature(y = "Column", x = "numeric"),
23092306
column(jc)
23102307
})
23112308

2312-
#' sha2
2313-
#'
2314-
#' Calculates the SHA-2 family of hash functions of a binary column and
2315-
#' returns the value as a hex string.
2309+
#' @details
2310+
#' \code{sha2}: Calculates the SHA-2 family of hash functions of a binary column and
2311+
#' returns the value as a hex string. The second argument \code{x} specifies the number
2312+
#' of bits, and is one of 224, 256, 384, or 512.
23162313
#'
2317-
#' @param y column to compute SHA-2 on.
2318-
#' @param x one of 224, 256, 384, or 512.
2319-
#' @family misc functions
2320-
#' @rdname sha2
2321-
#' @name sha2
2322-
#' @aliases sha2,Column,numeric-method
2314+
#' @rdname column_misc_functions
2315+
#' @aliases sha2 sha2,Column,numeric-method
23232316
#' @export
2324-
#' @examples \dontrun{sha2(df$c, 256)}
23252317
#' @note sha2 since 1.5.0
23262318
setMethod("sha2", signature(y = "Column", x = "numeric"),
23272319
function(y, x) {

R/pkg/R/generics.R

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -992,8 +992,9 @@ setGeneric("conv", function(x, fromBase, toBase) { standardGeneric("conv") })
992992
#' @name NULL
993993
setGeneric("countDistinct", function(x, ...) { standardGeneric("countDistinct") })
994994

995-
#' @rdname crc32
995+
#' @rdname column_misc_functions
996996
#' @export
997+
#' @name NULL
997998
setGeneric("crc32", function(x) { standardGeneric("crc32") })
998999

9991000
#' @rdname column_nonaggregate_functions
@@ -1006,8 +1007,9 @@ setGeneric("create_array", function(x, ...) { standardGeneric("create_array") })
10061007
#' @name NULL
10071008
setGeneric("create_map", function(x, ...) { standardGeneric("create_map") })
10081009

1009-
#' @rdname hash
1010+
#' @rdname column_misc_functions
10101011
#' @export
1012+
#' @name NULL
10111013
setGeneric("hash", function(x, ...) { standardGeneric("hash") })
10121014

10131015
#' @param x empty. Should be used with no argument.
@@ -1205,8 +1207,9 @@ setGeneric("lpad", function(x, len, pad) { standardGeneric("lpad") })
12051207
#' @name NULL
12061208
setGeneric("ltrim", function(x) { standardGeneric("ltrim") })
12071209

1208-
#' @rdname md5
1210+
#' @rdname column_misc_functions
12091211
#' @export
1212+
#' @name NULL
12101213
setGeneric("md5", function(x) { standardGeneric("md5") })
12111214

12121215
#' @rdname column_datetime_functions
@@ -1350,12 +1353,14 @@ setGeneric("sd", function(x, na.rm = FALSE) { standardGeneric("sd") })
13501353
#' @name NULL
13511354
setGeneric("second", function(x) { standardGeneric("second") })
13521355

1353-
#' @rdname sha1
1356+
#' @rdname column_misc_functions
13541357
#' @export
1358+
#' @name NULL
13551359
setGeneric("sha1", function(x) { standardGeneric("sha1") })
13561360

1357-
#' @rdname sha2
1361+
#' @rdname column_misc_functions
13581362
#' @export
1363+
#' @name NULL
13591364
setGeneric("sha2", function(y, x) { standardGeneric("sha2") })
13601365

13611366
#' @rdname column_math_functions

0 commit comments

Comments
 (0)