Github user shivaram commented on a diff in the pull request:
https://github.com/apache/spark/pull/6190#discussion_r31935500
--- Diff: R/pkg/R/serialize.R ---
@@ -37,24 +37,38 @@ writeObject <- function(con, object, writeType = TRUE) {
# passing in vectors as arrays and instead require arrays to be passed
# as lists.
type <- class(object)[[1]] # class of POSIXlt is c("POSIXlt", "POSIXt")
- if (writeType) {
- writeType(con, type)
+ isNA <- FALSE
+ if (type %in% c("integer", "character", "logical", "double", "numeric"))
{
+ isNA <- writeNA(con, object)
}
- switch(type,
- NULL = writeVoid(con),
- integer = writeInt(con, object),
- character = writeString(con, object),
- logical = writeBoolean(con, object),
- double = writeDouble(con, object),
- numeric = writeDouble(con, object),
- raw = writeRaw(con, object),
- list = writeList(con, object),
- jobj = writeJobj(con, object),
- environment = writeEnv(con, object),
- Date = writeDate(con, object),
- POSIXlt = writeTime(con, object),
- POSIXct = writeTime(con, object),
- stop(paste("Unsupported type for serialization", type)))
+ if (!isNA) {
+ if (writeType) {
+ writeType(con, type)
+ }
+ switch(type,
+ NULL = writeVoid(con),
+ integer = writeInt(con, object),
+ character = writeString(con, object),
+ logical = writeBoolean(con, object),
+ double = writeDouble(con, object),
+ numeric = writeDouble(con, object),
+ raw = writeRaw(con, object),
+ list = writeList(con, object),
+ jobj = writeJobj(con, object),
+ environment = writeEnv(con, object),
+ Date = writeDate(con, object),
+ POSIXlt = writeTime(con, object),
+ POSIXct = writeTime(con, object),
+ stop(paste("Unsupported type for serialization", type)))
+ }
+}
+
+writeNA <- function(con, value) {
+ if(is.na(value)) {
+ writeBin(charToRaw("n"), con)
+ writeVoid(con)
+ TRUE
+ } else FALSE
--- End diff --
Lets include `{` even for one line else statements. i.e.
```
else {
FALSE
}
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]