-
Notifications
You must be signed in to change notification settings - Fork 1k
Closes #3639 -- proper handling of CPLXSXP in dogroups #3689
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
Changes from all commits
bf4fb10
24c8849
0288c5f
3f99784
6ae6639
5a35c71
34fec0c
781df7f
d64f339
8967ee0
d34989a
6bf80b1
8565008
4097e5f
5258421
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,6 +143,9 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX | |
| case REALSXP : | ||
| REAL(VECTOR_ELT(SDall,j))[0] = NA_REAL; | ||
| break; | ||
| case CPLXSXP : { | ||
| COMPLEX(VECTOR_ELT(SDall, j))[0] = NA_CPLX; | ||
| } break; | ||
| case STRSXP : | ||
| SET_STRING_ELT(VECTOR_ELT(SDall,j),0,NA_STRING); | ||
| break; | ||
|
|
@@ -167,14 +170,17 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX | |
| case REALSXP : | ||
| REAL(VECTOR_ELT(xSD,j))[0] = NA_REAL; | ||
| break; | ||
| case CPLXSXP : { | ||
| COMPLEX(VECTOR_ELT(xSD, j))[0] = NA_CPLX; | ||
| } break; | ||
| case STRSXP : | ||
| SET_STRING_ELT(VECTOR_ELT(xSD,j),0,NA_STRING); | ||
| break; | ||
| case VECSXP : | ||
| SET_VECTOR_ELT(VECTOR_ELT(xSD,j),0,R_NilValue); | ||
| break; | ||
| default: | ||
| error("Logical error. Type of column should have been checked by now"); | ||
| error("Logical error. Type of column should have been checked by now"); // #nocov | ||
| } | ||
| } | ||
| } else { | ||
|
|
@@ -214,13 +220,21 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX | |
| rownum = iI[k]-1; | ||
| td[k] = sd[rownum]; // on 32bit copies pointers too | ||
| } | ||
| } else { // size 8 | ||
| } else if (size==8) { | ||
| double *td = REAL(target); | ||
| const double *sd = REAL(source); | ||
| for (int k=0; k<grpn; ++k) { | ||
| rownum = iI[k]-1; | ||
| td[k] = sd[rownum]; // on 64bit copies pointers too | ||
| } | ||
| } else { // size 16 | ||
| // #3634 -- CPLXSXP columns have size 16 | ||
| Rcomplex *td = COMPLEX(target); | ||
| const Rcomplex *sd = COMPLEX(source); | ||
| for (int k=0; k<grpn; ++k) { | ||
| rownum = iI[k]-1; | ||
| td[k] = sd[rownum]; | ||
| } | ||
| } | ||
| } | ||
| if (LOGICAL(verbose)[0]) { tblock[1] += clock()-tstart; nblock[1]++; } | ||
|
|
@@ -302,7 +316,7 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX | |
| } | ||
| memrecycle(target, order, INTEGER(starts)[i]-1, grpn, RHS); // length mismatch checked above for all jval columns before starting to add any new columns | ||
| copyMostAttrib(RHS, target); // not names, otherwise test 778 would fail. | ||
| /* OLD FIX: commented now. The fix below resulted in segfault on factor columns because I dint set the "levels" | ||
| /* OLD FIX: commented now. The fix below resulted in segfault on factor columns because I didn't set the "levels" | ||
| Instead of fixing that, I just removed setting class if it's factor. Not appropriate fix. | ||
| Correct fix of copying all attributes (except names) added above. Now, everything should be alright. | ||
| Test 1144 (#5104) will provide the right output now. Modified accordingly. | ||
|
|
@@ -382,14 +396,20 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX | |
| for (int j=0; j<ngrpcols; ++j) { | ||
| target = VECTOR_ELT(ans,j); | ||
| source = VECTOR_ELT(groups, INTEGER(grpcols)[j]-1); // target and source the same type by construction above | ||
| if (SIZEOF(target)==4) { | ||
| int tsize = SIZEOF(target); | ||
| if (tsize==4) { | ||
| int *td = INTEGER(target); | ||
| int *sd = INTEGER(source); | ||
| for (int r=0; r<maxn; ++r) td[ansloc+r] = sd[igrp]; | ||
| } else { | ||
| } else if (tsize==8) { | ||
| double *td = REAL(target); | ||
| double *sd = REAL(source); | ||
| for (int r=0; r<maxn; ++r) td[ansloc+r] = sd[igrp]; | ||
| } else { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one is in the |
||
| // #3634 -- CPLXSXP columns have size 16 | ||
| Rcomplex *td = COMPLEX(target); | ||
| Rcomplex *sd = COMPLEX(source); | ||
| for (int r=0; r<maxn; ++r) td[ansloc+r] = sd[igrp]; | ||
|
MichaelChirico marked this conversation as resolved.
|
||
| } | ||
| // Shouldn't need SET_* to age objects here since groups, TO DO revisit. | ||
| } | ||
|
MichaelChirico marked this conversation as resolved.
|
||
|
|
@@ -415,6 +435,10 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX | |
| double *td = REAL(target)+thisansloc; | ||
| for (int r=0; r<maxn; ++r) td[r] = NA_REAL; | ||
| } break; | ||
| case CPLXSXP : { | ||
| Rcomplex *td = COMPLEX(target) + thisansloc; | ||
| for (int r=0; r<maxn; ++r) td[r] = NA_CPLX; | ||
| } break; | ||
| case STRSXP : | ||
| for (int r=0; r<maxn; ++r) SET_STRING_ELT(target,thisansloc+r,NA_STRING); | ||
| break; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,7 +77,6 @@ static void subsetVectorRaw(SEXP ans, SEXP source, SEXP idx, const bool anyNA) | |
| case CPLXSXP : { | ||
| Rcomplex *sp = COMPLEX(source); | ||
| Rcomplex *ap = COMPLEX(ans); | ||
| Rcomplex NA_CPLX = { NA_REAL, NA_REAL }; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking at it again, would just inlining
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think |
||
| PARLOOP(NA_CPLX) | ||
| } break; | ||
| case RAWSXP : { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we nocov this branch (or set it to error even?)
IIUC hitting this branch would require first joining on
VECSXPcolumn inon, I don't think we have any plan to support list-to-list joins?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't no cov it otherwise it'll drop off our todo list. I'd say don't error either because something somewhere might be using it. I'd say just leave it as-is for now until it can be covered at a later date.