Skip to contents

precise_read() reads the RDS envelope written by precise_dist's file= argument and returns the standard typed tibble with the run ledger attached. A current cache in state "complete" returns the exact object the original call returned. A cache in state "partial" (the run was interrupted, crashed, or is still in flight) is reconstructed from the completed native matrices, with a message summarizing how far the run got; the ledger tells you exactly which metrics completed, errored, were skipped, were unavailable, or were never attempted.

Usage

precise_read(file, metrics = NULL)

Arguments

file

Path to a cache file written by precise_dist.

metrics

NULL (all completed metrics) or a character vector of distance keys to keep. Keys that were requested but did not complete error with their ledger status; unknown keys error with the available choices. The attached ledger always describes the full run regardless of subsetting.

Value

The typed tibble (columns distance, metric, matrix, type, time_taken_seconds) with the run ledger attached as the "precise_dist_run" attribute (see precise_run_report).

Details

Bare-list and version-2 caches predate the enforced matrix-validity contract. They cannot be loaded safely into the typed spine and are rejected with a clear recomputation error; readRDS() remains available for manual recovery. Version-3 caches use the former capitalized column schema and are normalized to the current lowercase schema in memory without modifying the cache file.

Author

Brian Muchmore

Examples

cache <- tempfile(fileext = ".rds")
x <- matrix(seq_len(18), nrow = 6)
saved <- precise_dist(
  x,
  dists = "euclidean",
  file = cache,
  verbose = FALSE
)
restored <- precise_read(cache)
identical(saved, restored)
#> [1] TRUE