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

Fix for boolean vector bug NA -> TRUE #6

Merged
merged 1 commit into from
Jul 21, 2016
Merged

Fix for boolean vector bug NA -> TRUE #6

merged 1 commit into from
Jul 21, 2016

Conversation

sichoudh
Copy link
Contributor

When a Boolean vector is passed into Rserve which can have NA
NA is converted to TRUE, this is because the during the parsing we directly assign the values from buffer into logical vector and any non zero values are assumed to be true.

Fix is to properly assign TRUE, FALSE and NA values to logical vector

@@ -1123,7 +1123,8 @@ static SEXP decode_to_SEXP(unsigned int **buf, int *UPC)
(*UPC)++;
i = 0;
while (i < vl) {
LOGICAL(val)[i] = cb[i];
// LOGICAL(val)[i] = cb[i];
LOGICAL(val)[i] = (cb[i] == 1) ? TRUE : ((cb[i] == 0) ? FALSE : NA_LOGICAL);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does that mean? when does cb[I] is 1 and what does it mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a REXPLogical vector is passed to Rserve using Buffer, TRUE = 1, FALSE = 0, NA = -124
cb is buffer which would contain the values passed from Rserve client
while parsing this buffer and creating a Logical vector for R, we check for correct values and assing them in in LOGICAL vector

This is the Fix I found in latest version of Rserve 1.7 and I have used the same logic for parsing the Logical vector

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@swells swells merged commit 8b75ec4 into master Jul 21, 2016
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.

6 participants