| Title: | Forward Error Correction and Erasure Coding |
|---|---|
| Description: | Forward error correction and erasure coding. Repair damaged files using pre-generated repair blocks. |
| Authors: | Mike Cheng [aut, cre, cph], Zooko O'Whielacronx [aut, cph] (zfec author), Luigi Rizzo [aut, cph] (Author of original 'fec.c' code), Phil Karn [ctb] (zfec contributor), Robert Morelos-Zaragoza [ctb] (zfec contributor), Dan Rubenstein [ctb] (zfec contributor) |
| Maintainer: | Mike Cheng <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-06-01 08:53:55 UTC |
| Source: | https://github.com/coolbutuseless/feck |
Calculate the 64-bit chibli hash for the given data
chiblihash64(raw_vec, skip = 0, len = length(raw_vec))chiblihash64(raw_vec, skip = 0, len = length(raw_vec))
raw_vec |
raw vector |
skip |
number of bytes to skip at start |
len |
Number of bytes to hash |
String containing the chibli hash
zz <- as.raw(1:100) chiblihash64(zz) chiblihash64(zz) zz[1] <- as.raw(199) chiblihash64(zz)zz <- as.raw(1:100) chiblihash64(zz) chiblihash64(zz) zz[1] <- as.raw(199) chiblihash64(zz)
Create blocks for a file
fec_prepare_file( filename, blocks_filename = NULL, k = 10, n = 2, verbosity = 0L )fec_prepare_file( filename, blocks_filename = NULL, k = 10, n = 2, verbosity = 0L )
filename |
filename |
blocks_filename |
Default: NULL, suffix with ".feck" |
k |
number of chunks to split data into. Larger 'k' will mean the file will be chunked into more, smaller blocks. This will help isolate errors, but can increase computation time. |
n |
number of repair chunks to create. Each repair chunk will be able to repair one bad chunk in the data. |
verbosity |
Default: 0 |
Invisibly return the raw vector of repair blocks
Create recovery blocks
fec_prepare_raw(raw_vec, k = 10, n = 2, verbosity = 0L)fec_prepare_raw(raw_vec, k = 10, n = 2, verbosity = 0L)
raw_vec |
raw vector |
k |
number of chunks to split data into. Larger 'k' will mean the file will be chunked into more, smaller blocks. This will help isolate errors, but can increase computation time. |
n |
number of repair chunks to create. Each repair chunk will be able to repair one bad chunk in the data. |
verbosity |
Default: 0 |
Raw vector of meta-data and recovery blocks
set.seed(1) dat <- as.raw(sample(0:255, 1e3, replace = TRUE)) rblocks <- fec_prepare_raw(dat, verbosity = 1)set.seed(1) dat <- as.raw(sample(0:255, 1e3, replace = TRUE)) rblocks <- fec_prepare_raw(dat, verbosity = 1)
Repair file
fec_repair_file(filename, blocks_filename = NULL, verbosity = 0L)fec_repair_file(filename, blocks_filename = NULL, verbosity = 0L)
filename |
filename. Repaired file will have suffix ".repaired" |
blocks_filename |
Default: NULL, suffix with ".feck" |
verbosity |
Default: 0 |
Invisibly return a raw vector of the contents of the repaired file. If repair is not possible, an error will be raised.
Recover damaged data in a raw vector
fec_repair_raw(raw_vec, blocks, verbosity = 0L)fec_repair_raw(raw_vec, blocks, verbosity = 0L)
raw_vec |
raw vector |
blocks |
raw vector of recovery blocks as created by |
verbosity |
Default: 0 |
Repaired data, or NULL if repair not possible
set.seed(1) dat0 <- dat <- as.raw(sample(0:255, 1e4, replace = TRUE)) rblocks <- fec_prepare_raw(dat, verbosity = 1) # simulate damange to data dat[1:100] <- as.raw(0) identical(dat, dat0) dat_repaired <- fec_repair_raw(dat, rblocks, verbosity = 1) identical(dat_repaired, dat0)set.seed(1) dat0 <- dat <- as.raw(sample(0:255, 1e4, replace = TRUE)) rblocks <- fec_prepare_raw(dat, verbosity = 1) # simulate damange to data dat[1:100] <- as.raw(0) identical(dat, dat0) dat_repaired <- fec_repair_raw(dat, rblocks, verbosity = 1) identical(dat_repaired, dat0)
Print repair blocks
## S3 method for class 'fec_blocks' print(x, ...)## S3 method for class 'fec_blocks' print(x, ...)
x |
Repair blocks created by |
... |
ignored |
None
rblocks <- fec_prepare_raw(as.raw(1:1000)) print(rblocks)rblocks <- fec_prepare_raw(as.raw(1:1000)) print(rblocks)