Skip to content

Commit

Permalink
change to method sorting logic for auto-generated bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
sllynn committed Nov 14, 2023
1 parent 5a25e59 commit d205b8a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/generate_R_bindings.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ get_function_names <- function(scala_file_path){
############################################################
sort_methods_by_argcount <- function(methods) {
# Split the strings by colon and calculate the number of colons
argcount <- sapply(strsplit(methods, ":"), function(x) length(x) - 1)
method_names <- sapply(strsplit(methods, "\\("), function(x) x[1])
argcount <- sapply(strsplit(methods, ","), function(x) length(x) - 1)

# Use the order function to sort first alphabetically and then by the number of colons
order_indices <- order(methods, argcount)
order_indices <- order(method_names, argcount)

# Return the sorted list
methods_sorted <- methods[order_indices]
Expand Down Expand Up @@ -224,9 +225,9 @@ main <- function(scala_file_path){
# supplementary files
sparkr_supplementary_files <- c("sparklyr-mosaic/enableMosaic.R", "sparklyr-mosaic/sparkFunctions.R")
copy_supplementary_file(sparkr_supplementary_files, "sparklyr-mosaic/sparklyrMosaic/R/")

}


args <- commandArgs(trailingOnly = T)
if (length(args) != 1){
stop("Please provide the MosaicContext.scala file path to generate_sparkr_functions.R")
Expand Down

0 comments on commit d205b8a

Please sign in to comment.