Skip to content

Commit 6cfa8b9

Browse files
authored
testing for broken selfref pointer adapted for macos (#7324)
1 parent e473a08 commit 6cfa8b9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

inst/tests/froll.Rraw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1798,7 +1798,7 @@ if (use.fork) {
17981798
setDTthreads(2)
17991799
test(6010.763, frollapply(c(1, 9), N=1L, FUN=identity), c(1,9)) ## good only because threads >= input
18001800
test(6010.764, frollapply(c(1, 5, 9), N=1L, FUN=identity), c(5,5,9)) ## unexpected again
1801-
is.ok = function(x) {stopifnot(is.data.table(x)); capture.output(print(attr(x, ".internal.selfref", TRUE)))!="<pointer: (nil)>"}
1801+
is.ok = function(x) {stopifnot(is.data.table(x)); out=capture.output(print(attr(x, ".internal.selfref", TRUE))); out!="<pointer: (nil)>" && out!="<pointer: 0x0>"}
18021802
ans = frollapply(1:2, 2, data.table, simplify=FALSE) ## default: fill=NA
18031803
test(6010.770, is.ok(ans[[2L]])) ## frollapply detected DT and fixed
18041804
ans = frollapply(1:2, 2, data.table, fill=data.table(NA)) ## fill type match

man/frollapply.Rd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ setDTthreads(old)
8484
}
8585
\item Objects returned from forked processes, \code{FUN}, are serialized. This may cause problems for objects that are meant not to be serialized, like data.table. We are handling that for data.table class internally in \code{frollapply} whenever \code{FUN} is returning data.table (which is checked on the results of the first \code{FUN} call so it assumes function is type stable). If data.table is nested in another object returned from \code{FUN} then the problem may still manifest, in such case one has to call \code{setDT} on objects returned from \code{FUN}. This can be also nicely handled via \code{simplify} argument when passing a function that calls \code{setDT} on nested data.table objects returned from \code{FUN}. Anyway, returning data.table from \code{FUN} should, in majority of cases, be avoided from the performance reasons, see \emph{UDF optimization} section for details.
8686
\preformatted{
87-
is.ok = function(x) {stopifnot(is.data.table(x)); format(attr(x, ".internal.selfref", TRUE))!="<pointer: (nil)>"}
87+
is.ok = function(x) {
88+
stopifnot(is.data.table(x))
89+
out = capture.output(print(attr(x, ".internal.selfref", TRUE)))
90+
out!="<pointer: (nil)>" && out!="<pointer: 0x0>"
91+
}
8892

8993
setDTthreads(2, throttle=1) ## disable throttle
9094
## frollapply will fix DT in most cases

0 commit comments

Comments
 (0)