Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert null to NA and vice versa #32

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Kevin-Jin
Copy link

Rserve.create().eval() converts NAs to null and Rserve.create().set() converts null to NA.
R's NA is still distinguished from R's NULL with this scheme because NA can only be found inside an array (possibly of length 1) while NULL can only be found outside an array.
Fix some inconsistent use of whitespace.

Rserve.create().eval() converts NAs to null and Rserve.create().set() converts null to NA.
R's NA is still distinguished from R's NULL with this scheme because NA can only be found inside an array (possibly of length 1) while NULL can only be found outside an array.
Fix some inconsistent use of whitespace.
@cscheid
Copy link
Owner

cscheid commented Apr 2, 2016

I'm nervous about this one because it's possible it'll break things inside of RCloud. @gordonwoodhull, can you take a look at this?

@gordonwoodhull
Copy link
Contributor

Sure.

Most likely there are things broken in RCloud, and this will break the workarounds. We have 2 months until feature freeze so I'll check it in soon and see how it fares.

Thanks @Kevin-Jin!

@gordonwoodhull
Copy link
Contributor

Actually, this looks like a complete overhaul and not just about NA. Can you give a brief overview of the other fixes here?

@Kevin-Jin
Copy link
Author

The only changes I've made to src/ were related to NA. I also replaced some typeof checks with underscore.js calls, fixed some inconsistent whitespace, made use of BOOL_TRUE and BOOL_FALSE constants in place of 1 and 0, and added an optional forced_type parameter to Rserve.create().set().

I realize that a lot of changes were made elsewhere in main.js, rserve.js, and rserve.min.js. This is just a consequence of "make" not being run in a long time so a lot of previous commits are reflected in those files now. In order to test out the changes I made in src, I really had no choice but to execute "make".

@gordonwoodhull
Copy link
Contributor

Ah got it. I can review the changes in isolation. The standard practice is not to commit build artifacts into a PR, but it's easy enough to work around.

@Kevin-Jin
Copy link
Author

Thanks Gordon, that makes sense. I have never committed updates to binaries because that bloats the repository, but now I know not to include the changes to text files resulting from a build.

In that case, I'll unstage the changes I made to main.js, rserve.js, and rserve.min.js in that commit and force push the branch.

@gordonwoodhull
Copy link
Contributor

Sorry I still have not gotten to this. I hope to try it later this week. When I do, I will merge it to a branch on att/rserve since that's a little bit ahead of that fork. I'll pull you into the conversation when I do.

@gordonwoodhull
Copy link
Contributor

I have merged this and #31 into branch kevin on att/rserve-js and will start testing this on the develop branch of RCloud.

The code looks good, some annoying special cases but that's the nature of this kind of work...

gordonwoodhull added a commit to att/rcloud that referenced this pull request Apr 18, 2016
@gordonwoodhull
Copy link
Contributor

Hi @Kevin-Jin, I tried this out on RCloud for a few days and it produces a couple of new errors.

The first is that when I send an empty object from JavaScript it gets decoded as a list containing NULL, when it used to be an empty list.

content.files
Object {}
> foo$files
[[1]]
NULL

Then this produces another error while processing the error, because a vector containing either NA or NULL gets transformed into just the value NULL, so decoding breaks here:

            var result = proto.json.call(this, resolver);
            result.r_type = type;

https://github.com/cscheid/rserve-js/blob/master/src/robj.js#L12

The subtleties of transcoding R and JavaScript data structures are... subtle. A transformation that seems really obvious for one application will not work for another application. Consider, for example this very long thread when Shiny switched JSON libraries. Fascinating stuff, but it makes it hard to transition from one scheme to another.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants