Reads the attributes of an object serialized to disk.

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.

Value

the attributes fo the serialized object.

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.

Examples


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

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

print(attr1)
#> $names
#>  [1] "mpg"  "cyl"  "disp" "hp"   "drat" "wt"   "qsec" "vs"   "am"   "gear"
#> [11] "carb"
#> 
#> $row.names
#>  [1] "Mazda RX4"           "Mazda RX4 Wag"       "Datsun 710"         
#>  [4] "Hornet 4 Drive"      "Hornet Sportabout"   "Valiant"            
#>  [7] "Duster 360"          "Merc 240D"           "Merc 230"           
#> [10] "Merc 280"            "Merc 280C"           "Merc 450SE"         
#> [13] "Merc 450SL"          "Merc 450SLC"         "Cadillac Fleetwood" 
#> [16] "Lincoln Continental" "Chrysler Imperial"   "Fiat 128"           
#> [19] "Honda Civic"         "Toyota Corolla"      "Toyota Corona"      
#> [22] "Dodge Challenger"    "AMC Javelin"         "Camaro Z28"         
#> [25] "Pontiac Firebird"    "Fiat X1-9"           "Porsche 914-2"      
#> [28] "Lotus Europa"        "Ford Pantera L"      "Ferrari Dino"       
#> [31] "Maserati Bora"       "Volvo 142E"         
#> 
#> $class
#> [1] "data.frame"
#> 
# $names
# [1] "IAU Name"      "Designation"   "Const." ...

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

identical(attr1, attr2) # TRUE
#> [1] TRUE