qattributes: qattributes

View source: R/zz_help_files.R

qattributesR Documentation

qattributes

Description

Reads the attributes of an object serialized to disk.

Usage

qattributes(file, use_alt_rep=FALSE, strict=FALSE, nthreads=1)

Arguments

file

The file name/path.

use_alt_rep

Use ALTREP when reading in string data (default FALSE). On R versions prior to 3.5.0, this parameter does nothing.

strict

Whether to throw an error or just report a warning (default: FALSE, i.e. report warning).

nthreads

Number of threads to use. Default 1.

Details

Equivalent to:

attributes(qread(file))

But more efficient. Attributes are stored towards the end of the file. This function will read through the contents of the file (without de-serializing the object itself), and then de-serializes the attributes only.

Because it is necessary to read through the file, pulling out attributes could take a long time if the file is large. However, it should be much faster than de-serializing the entire object first.

Value

the attributes fo the serialized object.

Examples


file <- tempfile()
qsave(mtcars, file)

attr1 <- qattributes(file)
attr2 <- attributes(qread(file))

print(attr1)
# $names
# [1] "IAU Name"      "Designation"   "Const." ...

# $row.names
# [1] 1 2 3 4 5
# $class
# [1] "data.frame"

identical(attr1, attr2) # TRUE


qs documentation built on March 7, 2023, 7:55 p.m.