collect {SparkR}R Documentation

Collect elements of an RDD

Description

collect returns a list that contains all of the elements in this RDD.

collectPartition returns a list that contains all of the elements in the specified partition of the RDD.

collectAsMap returns a named list as a map that contains all of the elements in a key-value pair RDD.

Usage

collect(rdd, ...)

## S4 method for signature 'RDD'
collect(rdd, flatten = TRUE)

collectPartition(rdd, partitionId)

## S4 method for signature 'RDD,integer'
collectPartition(rdd, partitionId)

collectAsMap(rdd)

## S4 method for signature 'RDD'
collectAsMap(rdd)

Arguments

rdd

The RDD to collect

...

Other optional arguments to collect

flatten

FALSE if the list should not flattened

partitionId

the partition to collect (starts from 0)

Value

a list containing elements in the RDD

Examples

## Not run: 
##D sc <- sparkR.init()
##D rdd <- parallelize(sc, 1:10, 2L)
##D collect(rdd) # list from 1 to 10
##D collectPartition(rdd, 0L) # list from 1 to 5
## End(Not run)
## Not run: 
##D sc <- sparkR.init()
##D rdd <- parallelize(sc, list(list(1, 2), list(3, 4)), 2L)
##D collectAsMap(rdd) # list(`1` = 2, `3` = 4)
## End(Not run)

[Package SparkR version 0.1 Index]