@@ -219,11 +219,14 @@ sortKeyValueList <- function(kv_list) {
219219 kv_list [order(keys )]
220220}
221221
222- # # Utility function to generate compact R lists from grouped rdd
223- # Used in Join-family functions
222+ # Utility function to generate compact R lists from grouped rdd
223+ # Used in Join-family functions
224+ # param:
225+ # tagged_list R list generated via groupByKey with tags(1L, 2L, ...)
226+ # cnull Boolean list where each element determines whether the corresponding list should
227+ # be converted to list(NULL)
224228genCompactLists <- function (tagged_list , cnull ) {
225229 len <- length(tagged_list )
226- num <- length(cnull )
227230 lists <- list (vector(" list" , len ), vector(" list" , len ))
228231 index <- list (1 , 1 )
229232
@@ -234,8 +237,8 @@ genCompactLists <- function(tagged_list, cnull) {
234237 index [[tag ]] <- idx + 1
235238 }
236239
237- len <- lapply(index , function (x ) x - 1 )
238- for (i in (1 : num )) {
240+ len <- lapply(index , function (x ) x - 1 )
241+ for (i in (1 : 2 )) {
239242 if (cnull [[i ]] && len [[i ]] == 0 ) {
240243 lists [[i ]] <- list (NULL )
241244 } else {
@@ -246,8 +249,10 @@ genCompactLists <- function(tagged_list, cnull) {
246249 lists
247250}
248251
249- # # Utility function to merge compact R lists
250- # Used in Join-family functions
252+ # Utility function to merge compact R lists
253+ # Used in Join-family functions
254+ # param:
255+ # left/right Two compact lists ready for Cartesian product
251256mergeCompactLists <- function (left , right ) {
252257 result <- list ()
253258 length(result ) <- length(left ) * length(right )
@@ -261,10 +266,13 @@ mergeCompactLists <- function(left, right) {
261266 result
262267}
263268
264- # # Utility function to wrapper above two operations
265- # Used in Join-family functions
269+ # Utility function to wrapper above two operations
270+ # Used in Join-family functions
271+ # param (same as genCompactLists):
272+ # tagged_list R list generated via groupByKey with tags(1L, 2L, ...)
273+ # cnull Boolean list where each element determines whether the corresponding list should
274+ # be converted to list(NULL)
266275joinTaggedList <- function (tagged_list , cnull ) {
267276 lists <- genCompactLists(tagged_list , cnull )
268- result <- mergeCompactLists(lists [[1 ]], lists [[2 ]])
269- result
277+ mergeCompactLists(lists [[1 ]], lists [[2 ]])
270278}
0 commit comments