reedsolomon-go/examples
Klaus Post 7761c8f7cd
Use Workflows (#169)
* Use Workflows
* Go 1.17 build tags
* Do races separately.
2021-09-01 18:55:02 +02:00
..
README.md Add streaming API examples. 2015-10-27 13:56:36 +01:00
simple-decoder.go Use Workflows (#169) 2021-09-01 18:55:02 +02:00
simple-encoder.go Use Workflows (#169) 2021-09-01 18:55:02 +02:00
stream-decoder.go Use Workflows (#169) 2021-09-01 18:55:02 +02:00
stream-encoder.go Use Workflows (#169) 2021-09-01 18:55:02 +02:00

README.md

Examples

This folder contains usage examples of the Reed-Solomon encoder.

Simple Encoder/Decoder

Shows basic use of the encoder, and will encode a single file into a number of data and parity shards. This is meant as an example and is not meant for production use since there is a number of shotcomings noted below.

To build an executable use:

go build simple-decoder.go
go build simple-encoder.go

Streamin API examples

There are streaming examples of the same functionality, which streams data instead of keeping it in memory.

To build the executables use:

go build stream-decoder.go
go build stream-encoder.go

Shortcomings

  • If the file size of the input isn't diviable by the number of data shards the output will contain extra zeroes
  • If the shard numbers isn't the same for the decoder as in the encoder, invalid output will be generated.
  • If values have changed in a shard, it cannot be reconstructed.
  • If two shards have been swapped, reconstruction will always fail. You need to supply the shards in the same order as they were given to you.

The solution for this is to save a metadata file containing:

  • File size.
  • The number of data/parity shards.
  • HASH of each shard.
  • Order of the shards.

If you save these properties, you should abe able to detect file corruption in a shard and be able to reconstruct your data if you have the needed number of shards left.