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

Documentation improvement on webpage #9

Closed
cscheid opened this issue Aug 22, 2013 · 1 comment
Closed

Documentation improvement on webpage #9

cscheid opened this issue Aug 22, 2013 · 1 comment

Comments

@cscheid
Copy link

cscheid commented Aug 22, 2013

Quoting http://www.rforge.net/Rserve/dev.html:

XT_ARRAY_INT     data: (n*4) int,int,.. 
XT_ARRAY_DOUBLE  data: (n*8) double,double,.. 
XT_ARRAY_STR     data: (?) string,string,.. 
XT_ARRAY_BOOL    data: (n) byte,byte,.. 

Notice that it leads one to think that these are all the same format, aside from element size. That's not the case: XT_ARRAY_BOOL includes an extra size field that needs to be written. From qap_decode.c:

case XT_ARRAY_BOOL:
{
    int vl = ptoi(*(b++));
    char *cb = (char*) b;
    val = allocVector(LGLSXP, vl);
    i = 0;
    while (i < vl) {
    LOGICAL(val)[i] = (cb[i] == 1) ? TRUE : ((cb[i] == 0) ? FALSE : NA_LOGICAL);
    i++;
    }
    while ((i & 3) != 0) i++;
    b = (unsigned int*) (cb + i);
}
*buf = b;
break;

/*...*/

case XT_ARRAY_DOUBLE:
    l = ln / 8;
    val = allocVector(REALSXP, l);
#ifdef NATIVE_COPY
    memcpy(REAL(val), b, sizeof(double) * l);
    b += l * 2;
#else
    i = 0;
    while (i < l) {
        fixdcpy(REAL(val) + i, b);
        b += 2;
        i++;
}
#endif
    *buf = b;
    break;

Note the extra undocumented int vl = ptoi(*(b++)); in XT_ARRAY_BOOL.

@s-u
Copy link
Owner

s-u commented Aug 22, 2013

Thanks. Historically there were two versions of XT_ARRAY_BOOL - one aligned (the one you see) and one unaligned (the one described). At some point the unaligned one was replaced with the aligned one - both are described in Rsrv.h - they have in fact distinct codes. I have updated the documentation to match the current status and also fixed the XT_LIST_TAG doc bug.

@s-u s-u closed this as completed Aug 22, 2013
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

No branches or pull requests

2 participants