-
Notifications
You must be signed in to change notification settings - Fork 1k
Replace ATTRIB, SET_ATTRIB
#7487
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
Open
aitap
wants to merge
18
commits into
master
Choose a base branch
from
attrib
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+172
−110
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0a6e0e7
frev: drop SET_ATTRIB
aitap 2e0c389
mergeIndexAttrib: drop SET_ATTRIB
aitap 58d586b
cbindlist: use ANY_ATTRIB
aitap 402f0d5
nafillR: use ANY_ATTRIB
aitap 0f47f29
Backport R_mapAttrib
aitap ff280b5
anySpecialStatic: switch to R_mapAttrib
aitap e4f1788
dogroups: construct rownames anew
aitap 3c66757
mergeIndexAttrib: switch to R_mapAttrib
aitap 2c10c37
assign: factor out index fixup
aitap e1fa0a6
assign: drop indexLength
HughParsonage 09b1f7e
assign: fix index unmarking
HughParsonage 1a408bf
Comments, better field names
aitap fa2df39
Merge branch 'master' into attrib
ben-schwen 7381ec8
Update src/dogroups.c
aitap 987c613
mapAttrib: protect the attribute value
aitap ca0e85c
dogroups: look up rownames using mapAttrib
ben-schwen 012cf3a
Fix comment, function name
aitap b1daaab
Protect the newly found rownames attribute
aitap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,8 @@ | |||||
| #include <fcntl.h> | ||||||
| #include <time.h> | ||||||
|
|
||||||
| static SEXP anySpecialAttribute(SEXP key, SEXP val, void *ctx); | ||||||
|
|
||||||
| static bool anySpecialStatic(SEXP x, hashtab * specials) { | ||||||
| // Special refers to special symbols .BY, .I, .N, and .GRP; see special-symbols.Rd | ||||||
| // Static because these are like C static arrays which are the same memory for each group; e.g., dogroups | ||||||
|
|
@@ -39,7 +41,7 @@ static bool anySpecialStatic(SEXP x, hashtab * specials) { | |||||
| // with PR#4164 started to copy input list columns too much. Hence PR#4655 in v1.13.2 moved that copy here just where it is needed. | ||||||
| // Currently the marker is negative truelength. These specials are protected by us here and before we release them | ||||||
| // we restore the true truelength for when R starts to use vector truelength. | ||||||
| SEXP attribs, list_el; | ||||||
| SEXP list_el; | ||||||
| const int n = length(x); | ||||||
| // use length() not LENGTH() because isNewList() is true for NULL | ||||||
| if (n==0) | ||||||
|
|
@@ -53,20 +55,29 @@ static bool anySpecialStatic(SEXP x, hashtab * specials) { | |||||
| list_el = VECTOR_ELT(x,i); | ||||||
| if (anySpecialStatic(list_el, specials)) | ||||||
| return true; | ||||||
| for(attribs = ATTRIB(list_el); attribs != R_NilValue; attribs = CDR(attribs)) { | ||||||
| if (anySpecialStatic(CAR(attribs), specials)) | ||||||
| return true; // #4936 | ||||||
| } | ||||||
| if (R_mapAttrib(list_el, anySpecialAttribute, specials)) | ||||||
| return true; // #4936 | ||||||
| } | ||||||
| } | ||||||
| return false; | ||||||
| } | ||||||
|
|
||||||
| static SEXP anySpecialAttribute(SEXP key, SEXP val, void *specials) { | ||||||
| (void)key; | ||||||
| return anySpecialStatic(val, specials) ? R_NilValue : NULL; | ||||||
| } | ||||||
|
|
||||||
| static SEXP findRowNames(SEXP key, SEXP val, void *data) { | ||||||
| (void)data; | ||||||
| if (key == R_RowNamesSymbol) return val; | ||||||
| return NULL; | ||||||
| } | ||||||
|
|
||||||
| SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEXP xjiscols, SEXP grporder, SEXP order, SEXP starts, SEXP lens, SEXP jexp, SEXP env, SEXP lhs, SEXP newnames, SEXP on, SEXP verboseArg, SEXP showProgressArg) | ||||||
| { | ||||||
| R_len_t ngrp, nrowgroups, njval=0, ngrpcols, ansloc=0, maxn, estn=-1, thisansloc, grpn, thislen, igrp; | ||||||
| int nprotect=0; | ||||||
| SEXP ans=NULL, jval, thiscol, BY, N, I, GRP, iSD, xSD, rownames, s, RHS, target, source; | ||||||
| SEXP ans=NULL, jval, thiscol, BY, N, I, GRP, iSD, xSD, s, RHS, target, source; | ||||||
|
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.
Suggested change
|
||||||
| Rboolean wasvector, firstalloc=FALSE, NullWarnDone=FALSE; | ||||||
| const bool verbose = LOGICAL(verboseArg)[0]==1; | ||||||
| double tstart=0, tblock[10]={0}; int nblock[10]={0}; // For verbose printing, tstart is updated each block | ||||||
|
|
@@ -129,11 +140,11 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX | |||||
| R_LockBinding(install(".I"), env); | ||||||
|
|
||||||
| SEXP dtnames = PROTECT(getAttrib(dt, R_NamesSymbol)); nprotect++; // added here to fix #91 - `:=` did not issue recycling warning during "by" | ||||||
| // fetch rownames of .SD. rownames[1] is set to -thislen for each group, in case .SD is passed to | ||||||
|
|
||||||
| // override rownames of .SD. rownames[1] is set to -thislen for each group, in case .SD is passed to | ||||||
| // non data.table aware package that uses rownames | ||||||
| for (s = ATTRIB(SD); s != R_NilValue && TAG(s)!=R_RowNamesSymbol; s = CDR(s)); // getAttrib0 basically but that's hidden in attrib.c; #loop_counter_not_local_scope_ok | ||||||
| if (s==R_NilValue) error(_("row.names attribute of .SD not found")); | ||||||
| rownames = CAR(s); | ||||||
| SEXP rownames = PROTECT(R_mapAttrib(SD, findRowNames, NULL)); nprotect++; | ||||||
| if (rownames == NULL) error(_("row.names attribute of .SD not found")); | ||||||
| if (!isInteger(rownames) || LENGTH(rownames)!=2 || INTEGER(rownames)[0]!=NA_INTEGER) error(_("row.names of .SD isn't integer length 2 with NA as first item; i.e., .set_row_names(). [%s %d %d]"),type2char(TYPEOF(rownames)),LENGTH(rownames),INTEGER(rownames)[0]); | ||||||
|
|
||||||
| // fetch names of .SD and prepare symbols. In case they are copied-on-write by user assigning to those variables | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.