Package com.reve.reed.solomon
Class ReedSolomon
java.lang.Object
com.reve.reed.solomon.ReedSolomon
Reed-Solomon Coding over 8-bit values.
-
Constructor Summary
ConstructorsConstructorDescriptionReedSolomon(int dataShardCount, int parityShardCount, CodingLoop codingLoop) Initializes a new encoder/decoder, with a chosen coding loop. -
Method Summary
Modifier and TypeMethodDescriptionstatic ReedSolomoncreate(int dataShardCount, int parityShardCount) Creates a ReedSolomon codec with the default coding loop.voiddecodeMissing(byte[][] shards, boolean[] shardPresent, int offset, int byteCount) Given a list of shards, some of which contain data, fills in the ones that don't have data.voidencodeParity(byte[][] shards, int offset, int byteCount) Encodes parity for a set of data shards.voidencodeParity(byte[][] shards, int offset, int byteCount, int dataShardCount, int parityShardCount) intReturns the number of data shards.intReturns the number of parity shards.intReturns the total number of shards.booleanisParityCorrect(byte[][] shards, int firstByte, int byteCount) Returns true if the parity shards contain the right data.booleanisParityCorrect(byte[][] shards, int firstByte, int byteCount, byte[] tempBuffer) Returns true if the parity shards contain the right data.
-
Constructor Details
-
ReedSolomon
Initializes a new encoder/decoder, with a chosen coding loop.
-
-
Method Details
-
create
Creates a ReedSolomon codec with the default coding loop. -
getDataShardCount
public int getDataShardCount()Returns the number of data shards. -
getParityShardCount
public int getParityShardCount()Returns the number of parity shards. -
getTotalShardCount
public int getTotalShardCount()Returns the total number of shards. -
encodeParity
public void encodeParity(byte[][] shards, int offset, int byteCount) Encodes parity for a set of data shards.- Parameters:
shards- An array containing data shards followed by parity shards. Each shard is a byte array, and they must all be the same size.offset- The index of the first byte in each shard to encode.byteCount- The number of bytes to encode in each shard.
-
encodeParity
public void encodeParity(byte[][] shards, int offset, int byteCount, int dataShardCount, int parityShardCount) -
isParityCorrect
public boolean isParityCorrect(byte[][] shards, int firstByte, int byteCount) Returns true if the parity shards contain the right data.- Parameters:
shards- An array containing data shards followed by parity shards. Each shard is a byte array, and they must all be the same size.firstByte- The index of the first byte in each shard to check.byteCount- The number of bytes to check in each shard.
-
isParityCorrect
public boolean isParityCorrect(byte[][] shards, int firstByte, int byteCount, byte[] tempBuffer) Returns true if the parity shards contain the right data. This method may be significantly faster than the one above that does not use a temporary buffer.- Parameters:
shards- An array containing data shards followed by parity shards. Each shard is a byte array, and they must all be the same size.firstByte- The index of the first byte in each shard to check.byteCount- The number of bytes to check in each shard.tempBuffer- A temporary buffer (the same size as each of the shards) to use when computing parity.
-
decodeMissing
public void decodeMissing(byte[][] shards, boolean[] shardPresent, int offset, int byteCount) Given a list of shards, some of which contain data, fills in the ones that don't have data. Quickly does nothing if all of the shards are present. If any shards are missing (based on the flags in shardsPresent), the data in those shards is recomputed and filled in.
-