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
- Don't SET_TRUELENGTH by hand. All of our resizable vectors now have
the GROWABLE_BIT set, so when they are duplicated, TRUELENGTH is reset
to 0.
- Use a combination of R_isResizable and R_maxLength to replace other
uses of TRUELENGTH.
// modify DT by reference. Other than if new columns are being added and the allocVec() fails with
451
445
// out-of-memory. In that case the user will receive hard halt and know to rerun.
452
446
if (length(newcolnames)) {
453
-
oldtncol=TRUELENGTH(dt); // TO DO: oldtncol can be just called tl now, as we won't realloc here any more.
447
+
if (!R_isResizable(dt)) 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
448
+
oldtncol=R_maxLength(dt); // TO DO: oldtncol can be just called tl now, as we won't realloc here any more.
454
449
455
450
if (oldtncol<oldncol) {
456
-
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
if (oldtncol>oldncol+10000L) warning(_("truelength (%d) is greater than 10,000 items over-allocated (length = %d). See ?truelength. If you didn't set the datatable.alloccol option very large, please report to data.table issue tracker including the result of sessionInfo()."),oldtncol, oldncol);
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
464
458
// Can growVector at this point easily enough, but it shouldn't happen in first place so leave it as
465
459
// strong error message for now.
466
-
elseif (TRUELENGTH(names) !=oldtncol)
460
+
elseif (R_maxLength(names) !=oldtncol)
467
461
// Use (long long) to cast R_xlen_t to a fixed type to robustly avoid -Wformat compiler warnings, see #5768, PRId64 didn't work
468
-
internal_error(__func__, "selfrefnames is ok but tl names [%lld] != tl [%d]", (long long)TRUELENGTH(names), oldtncol); // # nocov
462
+
internal_error(__func__, "selfrefnames is ok but maxLength(names) [%lld] != maxLength(dt) [%d]", (long long)R_maxLength(names), oldtncol); // # nocov
469
463
if (!selfrefok(dt, verbose)) // #6410 setDT(dt) and subsequent attr<- can lead to invalid selfref
470
464
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."));
0 commit comments