You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// No method to set ALTREP_TRUELENGTH (gives error): https://github.com/wch/r-source/blob/2640a203d13473f95c9c7508eb2976fefb5c931c/src/include/Defn.h#L388
// modify DT by reference. Other than if new columns are being added and the allocVec() fails with
515
515
// out-of-memory. In that case the user will receive hard halt and know to rerun.
516
516
if (length(newcolnames)) {
517
-
oldtncol=TRUELENGTH(dt); // TO DO: oldtncol can be just called tl now, as we won't realloc here any more.
517
+
oldtncol=TRULEN(dt); // TO DO: oldtncol can be just called tl now, as we won't realloc here any more.
518
518
519
519
if (oldtncol<oldncol) {
520
520
if (oldtncol==0) error(_("This data.table has either been loaded from disk (e.g. using readRDS()/load()) or constructed manually (e.g. using structure()). Please run setDT() or setalloccol() on it first (to pre-allocate space for new columns) before assigning by reference to it.")); // #2996
error(_("It appears that at some earlier point, names of this data.table have been reassigned. Please ensure to use setnames() rather than names<- or colnames<-. Otherwise, please report to data.table issue tracker.")); // # nocov
528
528
// Can growVector at this point easily enough, but it shouldn't happen in first place so leave it as
529
529
// strong error message for now.
530
-
elseif (TRUELENGTH(names) !=oldtncol)
530
+
elseif (TRULEN(names) !=oldtncol)
531
531
// Use (long long) to cast R_xlen_t to a fixed type to robustly avoid -Wformat compiler warnings, see #5768, PRId64 didn't work
532
-
internal_error(__func__, "selfrefnames is ok but tl names [%lld] != tl [%d]", (long long)TRUELENGTH(names), oldtncol); // # nocov
532
+
internal_error(__func__, "selfrefnames is ok but tl names [%lld] != tl [%d]", (long long)TRULEN(names), oldtncol); // # nocov
533
533
if (!selfrefok(dt, verbose)) // #6410 setDT(dt) and subsequent attr<- can lead to invalid selfref
534
534
error(_("It appears that at some earlier point, attributes of this data.table have been reassigned. Please use setattr(DT, name, value) rather than attr(DT, name) <- value. If that doesn't apply to you, please report your case to the data.table issue tracker."));
@@ -830,26 +830,26 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
830
830
savetl_init();
831
831
for (intk=0; k<nTargetLevels; ++k) {
832
832
constSEXPs=targetLevelsD[k];
833
-
constinttl=TRUELENGTH(s);
833
+
constinttl=TRULEN(s);
834
834
if (tl>0) {
835
835
savetl(s);
836
836
} elseif (tl<0) {
837
837
// # nocov start
838
-
for (intj=0; j<k; ++j) SET_TRUELENGTH(s, 0); // wipe our negative usage and restore 0
838
+
for (intj=0; j<k; ++j) SET_TRULEN(s, 0); // wipe our negative usage and restore 0
839
839
savetl_end(); // then restore R's own usage (if any)
840
840
internal_error(__func__, "levels of target are either not unique or have truelength<0"); // # nocov
841
841
// # nocov end
842
842
}
843
-
SET_TRUELENGTH(s, -k-1);
843
+
SET_TRULEN(s, -k-1);
844
844
}
845
845
intnAdd=0;
846
846
for (intk=0; k<nSourceLevels; ++k) {
847
847
constSEXPs=sourceLevelsD[k];
848
-
constinttl=TRUELENGTH(s);
848
+
constinttl=TRULEN(s);
849
849
if (tl>=0) {
850
850
if (!sourceIsFactor&&s==NA_STRING) continue; // don't create NA factor level when assigning character to factor; test 2117
851
851
if (tl>0) savetl(s);
852
-
SET_TRUELENGTH(s, -nTargetLevels-(++nAdd));
852
+
SET_TRULEN(s, -nTargetLevels-(++nAdd));
853
853
} // else, when sourceIsString, it's normal for there to be duplicates here
854
854
}
855
855
constintnSource=length(source);
@@ -858,34 +858,34 @@ const char *memrecycle(const SEXP target, const SEXP where, const int start, con
858
858
constint*sourceD=INTEGER(source);
859
859
for (inti=0; i<nSource; ++i) { // convert source integers to refer to target levels
860
860
constintval=sourceD[i];
861
-
newSourceD[i] =val==NA_INTEGER ? NA_INTEGER : -TRUELENGTH(sourceLevelsD[val-1]); // retains NA factor levels here via TL(NA_STRING); e.g. ordered factor
861
+
newSourceD[i] =val==NA_INTEGER ? NA_INTEGER : -TRULEN(sourceLevelsD[val-1]); // retains NA factor levels here via TL(NA_STRING); e.g. ordered factor
862
862
}
863
863
} else {
864
864
constSEXP*sourceD=STRING_PTR_RO(source);
865
865
for (inti=0; i<nSource; ++i) { // convert source integers to refer to target levels
for (inti=0; i<tablelen; i++) SET_TRUELENGTH(td[i], 0);
103
+
for (inti=0; i<tablelen; i++) SET_TRULEN(td[i], 0);
104
104
savetl_end();
105
105
error(_("Failed to allocate %"PRIu64" bytes working memory in chmatchdup: length(table)=%d length(unique(table))=%d"), ((uint64_t)tablelen*2+nuniq)*sizeof(int), tablelen, nuniq);
106
106
// # nocov end
107
107
}
108
-
for (inti=0; i<tablelen; ++i) counts[-TRUELENGTH(td[i])-1]++;
108
+
for (inti=0; i<tablelen; ++i) counts[-TRULEN(td[i])-1]++;
109
109
for (inti=0, sum=0; i<nuniq; ++i) { inttt=counts[i]; counts[i]=sum; sum+=tt+1; }
110
-
for (inti=0; i<tablelen; ++i) map[counts[-TRUELENGTH(td[i])-1]++] =i+1; // 0 is left ending each group thanks to the calloc
110
+
for (inti=0; i<tablelen; ++i) map[counts[-TRULEN(td[i])-1]++] =i+1; // 0 is left ending each group thanks to the calloc
111
111
for (inti=0, last=0; i<nuniq; ++i) {inttt=counts[i]+1; counts[i]=last; last=tt;} // rewind counts to the beginning of each group
112
112
for (inti=0; i<xlen; ++i) {
113
-
intu=TRUELENGTH(xd[i]);
113
+
intu=TRULEN(xd[i]);
114
114
if (u<0) {
115
115
constintw=counts[-u-1]++;
116
116
if (map[w]) { ansd[i]=map[w]; continue; }
117
-
SET_TRUELENGTH(xd[i],0); // w falls on ending 0 marker: dups used up; any more dups should return nomatch
117
+
SET_TRULEN(xd[i],0); // w falls on ending 0 marker: dups used up; any more dups should return nomatch
118
118
// we still need the 0-setting loop at the end of this function because often there will be some values in table that are not matched to at all.
0 commit comments