@@ -1255,22 +1255,18 @@ setMethod("flatMapValues",
12551255# ' rdd <- parallelize(sc, list(3, 2, 1))
12561256# ' collect(sortBy(rdd, function(x) { x })) # list (1, 2, 3)
12571257# '}
1258- setGeneric ("sortBy ", function(rdd, func, ascending, numPartitions) { standardGeneric("sortBy") })
1258+ setGeneric ("sortBy ", function(rdd,
1259+ func ,
1260+ ascending = TRUE ,
1261+ numPartitions = 1L ) {
1262+ standardGeneric(" sortBy" )
1263+ })
12591264
1260- setClassUnion(" missingOrLogical" , c(" missing" , " logical" ))
12611265# ' @rdname sortBy
12621266# ' @aliases sortBy,RDD,RDD-method
12631267setMethod ("sortBy ",
1264- signature(rdd = " RDD" , func = " function" ,
1265- ascending = " missingOrLogical" , numPartitions = " missingOrInteger" ),
1266- function (rdd , func , ascending , numPartitions ) {
1267- if (missing(ascending )) {
1268- ascending = TRUE
1269- }
1270- if (missing(numPartitions )) {
1271- numPartitions = SparkR :: numPartitions(rdd )
1272- }
1273-
1268+ signature(rdd = " RDD" , func = " function" ),
1269+ function (rdd , func , ascending = TRUE , numPartitions = SparkR :: numPartitions(rdd )) {
12741270 values(sortByKey(keyBy(rdd , func ), ascending , numPartitions ))
12751271 })
12761272
@@ -1844,20 +1840,17 @@ setMethod("cogroup",
18441840# ' rdd <- parallelize(sc, list(list(3, 1), list(2, 2), list(1, 3)))
18451841# ' collect(sortByKey(rdd)) # list (list(1, 3), list(2, 2), list(3, 1))
18461842# '}
1847- setGeneric ("sortByKey ", function(rdd, ascending, numPartitions) { standardGeneric("sortByKey") })
1843+ setGeneric ("sortByKey ", function(rdd,
1844+ ascending = TRUE ,
1845+ numPartitions = 1L ) {
1846+ standardGeneric(" sortByKey" )
1847+ })
18481848
18491849# ' @rdname sortByKey
18501850# ' @aliases sortByKey,RDD,RDD-method
18511851setMethod ("sortByKey ",
1852- signature(rdd = " RDD" , ascending = " missingOrLogical" , numPartitions = " missingOrInteger" ),
1853- function (rdd , ascending , numPartitions ) {
1854- if (missing(ascending )) {
1855- ascending = TRUE
1856- }
1857- if (missing(numPartitions )) {
1858- numPartitions = SparkR :: numPartitions(rdd )
1859- }
1860-
1852+ signature(rdd = " RDD" ),
1853+ function (rdd , ascending = TRUE , numPartitions = SparkR :: numPartitions(rdd )) {
18611854 rangeBounds <- list ()
18621855
18631856 if (numPartitions > 1 ) {
0 commit comments