Skip to content

Commit

Permalink
Remove tojson functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cafreeman authored and Davies Liu committed Apr 14, 2015
1 parent 6ef5f2d commit 8526d2e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 35 deletions.
27 changes: 0 additions & 27 deletions pkg/R/schema.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,30 +140,3 @@ print.structField <- function(x, ...) {
")",
sep = "")
}

# cfreeman: Don't think we need this function since we can create
# structType in R and pass to createDataFrame
#
# #' dump the schema into JSON string
# tojson <- function(x) {
# if (inherits(x, "struct")) {
# # schema object
# l <- paste(lapply(x, tojson), collapse = ", ")
# paste('{\"type\":\"struct\", \"fields\":','[', l, ']}', sep = '')
# } else if (inherits(x, "field")) {
# # field object
# names <- names(x)
# items <- lapply(names, function(n) {
# safe_n <- gsub('"', '\\"', n)
# paste(tojson(safe_n), ':', tojson(x[[n]]), sep = '')
# })
# d <- paste(items, collapse = ", ")
# paste('{', d, '}', sep = '')
# } else if (is.character(x)) {
# paste('"', x, '"', sep = '')
# } else if (is.logical(x)) {
# if (x) "true" else "false"
# } else {
# stop(paste("unexpected type:", class(x)))
# }
# }
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@ private[r] object SQLUtils {
StructField(name, dtObj, nullable)
}

// cfreeman: I don't think we need this anymore since we can pass structType from R
// def createDF(rdd: RDD[Array[Byte]], schemaString: String, sqlContext: SQLContext): DataFrame = {
// val schema = DataType.fromJson(schemaString).asInstanceOf[StructType]
// val num = schema.fields.size
// val rowRDD = rdd.map(bytesToRow)
// sqlContext.createDataFrame(rowRDD, schema)
// }

def createDF(rdd: RDD[Array[Byte]], schema: StructType, sqlContext: SQLContext): DataFrame = {
val num = schema.fields.size
val rowRDD = rdd.map(bytesToRow)
Expand Down

0 comments on commit 8526d2e

Please sign in to comment.