Package com.reve.reed.solomon
Class ReveReedSolomon
java.lang.Object
com.reve.reed.solomon.ReveReedSolomon
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault value for loss percentage while getting theReedSolomonOptimizedinstance fromsolomonMapstatic final intMax value of the array above.static final intstatic final intMaximum number of bytes for each row of shards [][] array. -
Method Summary
Modifier and TypeMethodDescriptionintdecodeParity(Shard shard, byte[] output, int outOffset) Decode the given instance ofShardand save the decoded bytes into given output array.intdecodeParity(Shard shard, int lossPercentage, byte[] output, int outOffset) Decode the given instance ofShardand save the decoded bytes into given output array.encodeParity(byte[] data, int offset, int length) Encode the given byte array usingDEFAULT_LOSS_PERCENTAGEinstance ofReedSolomonOptimizedThis method will try to encode bytes with as most data shard count as possible.encodeParity(byte[] data, int offset, int length, int lossPercentage) Encode the given byte array using given loss percentage instance ofReedSolomonOptimizedThis method will try to encode bytes with as most data shard count as possible.static ReveReedSolomonGet the single-ton instance.
-
Field Details
-
MAX_DATA_SHARD_COUNT
public static final int MAX_DATA_SHARD_COUNTMax value of the array above. Must make sure this variable contains the max value of the array AVAILABLE_DATA_SHARDS- See Also:
-
DEFAULT_LOSS_PERCENTAGE
public static final int DEFAULT_LOSS_PERCENTAGEDefault value for loss percentage while getting theReedSolomonOptimizedinstance fromsolomonMap- See Also:
-
MAX_SHARD_SIZE
public static final int MAX_SHARD_SIZEMaximum number of bytes for each row of shards [][] array.- See Also:
-
MAX_LOSS_PERCENTAGE_FOR_MAX_SIZE
public static final int MAX_LOSS_PERCENTAGE_FOR_MAX_SIZE- See Also:
-
-
Method Details
-
getInstance
Get the single-ton instance. Create if required.- Returns:
- the single-ton instance.
-
encodeParity
Encode the given byte array usingDEFAULT_LOSS_PERCENTAGEinstance ofReedSolomonOptimizedThis method will try to encode bytes with as most data shard count as possible. In worst case it may try all possible data shards count presents inAVAILABLE_DATA_SHARDS- Parameters:
data- byte array to be encoded.offset- starting index of the byte array.length- total length of bytes to be encoded.- Returns:
- the list of
Shardcontaining all the encoded chunks.
-
encodeParity
Encode the given byte array using given loss percentage instance ofReedSolomonOptimizedThis method will try to encode bytes with as most data shard count as possible. In worst case it may try all possible data shards count presents inAVAILABLE_DATA_SHARDS- Parameters:
data- byte array to be encoded.offset- starting index of the byte array.length- total length of bytes to be encoded.lossPercentage- loss percentage to be considered. This value is required to calculate the parity shard count- Returns:
- the list of
Shardcontaining all the encoded chunks.
-
decodeParity
Decode the given instance ofShardand save the decoded bytes into given output array.- Parameters:
shard- Contains the encoded slice and all related information.output- Output array where decoded data will be saved.outOffset- Starting index of output byte array.- Returns:
- the length of the decoded byte array.
-
decodeParity
Decode the given instance ofShardand save the decoded bytes into given output array.- Parameters:
shard- Contains the encoded slice and all related information.lossPercentage- percentage of loss to be considered. This value is required to calculate the parity shard countoutput- Output array where decoded data will be saved.outOffset- Starting index of output byte array.- Returns:
- the length of the decoded byte array.
-