Skip to contents

In rare situations, as presented in examples below, a data.table object may lose its internal attribute that holds a self-reference. This function tests just that.

It is not expected that many end users will have need for this highly technical function about data.table internals.

Usage

.selfref.ok(x)

Arguments

x

A data.table.

Value

TRUE if self reference attribute is properly set, FALSE otherwise.

Examples

d1 = list(V1=1L)
class(d1) = c("data.table", "data.frame")
.selfref.ok(d1)
#> [1] FALSE
setDT(d1)
.selfref.ok(d1)
#> [1] TRUE

saveRDS(d1, f<-tempfile())
d2 = readRDS(f)
.selfref.ok(d2)
#> [1] FALSE
invisible(file.remove(f))
setDT(d2)
.selfref.ok(d2)
#> [1] TRUE

d3 = unserialize(serialize(d2, NULL))
.selfref.ok(d3)
#> [1] FALSE
setDT(d3)
.selfref.ok(d3)
#> [1] TRUE