Class ReveReedSolomon

java.lang.Object
com.reve.reed.solomon.ReveReedSolomon

public class ReveReedSolomon extends Object
  • Field Details

    • DEFAULT_LOSS_PERCENTAGE

      public static final int DEFAULT_LOSS_PERCENTAGE
      Default value for loss percentage while getting the ReedSolomonOptimized instance from solomonMap
      See Also:
    • MAX_SHARD_SIZE

      public static final int MAX_SHARD_SIZE
      Maximum number of bytes for each row of shards [][] array.
      See Also:
  • Method Details

    • getInstance

      public static ReveReedSolomon getInstance()
      Get the single-ton instance. Create if required.
      Returns:
      the single-ton instance.
    • encodeParity

      public Shard encodeParity(byte[] data, int offset, int length)
      Encode the given byte array using DEFAULT_LOSS_PERCENTAGE instance of ReedSolomonOptimized This 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 in AVAILABLE_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 Shard containing all the encoded chunks.
    • encodeParity

      public Shard encodeParity(byte[] data, int offset, int length, int lossPercentage)
      Encode the given byte array using given loss percentage instance of ReedSolomonOptimized This 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 in AVAILABLE_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 Shard containing all the encoded chunks.
    • decodeParity

      public int decodeParity(Shard shard, byte[] output, int outOffset)
      Decode the given instance of Shard and 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

      public int decodeParity(Shard shard, int lossPercentage, byte[] output, int outOffset)
      Decode the given instance of Shard and 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 count
      output - Output array where decoded data will be saved.
      outOffset - Starting index of output byte array.
      Returns:
      the length of the decoded byte array.