Class ReveReedSolomon

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

public class ReveReedSolomon extends Object
  • Field Details

    • MAX_DATA_SHARD_COUNT

      public static final int MAX_DATA_SHARD_COUNT
      Max 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_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:
    • MAX_LOSS_PERCENTAGE_FOR_MAX_SIZE

      public static final int MAX_LOSS_PERCENTAGE_FOR_MAX_SIZE
      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.
    • setMaxAllowedShardSize

      public static void setMaxAllowedShardSize(int maxAllowedShardSize)
    • encodeParity

      public Shard encodeParity(byte[] data, int offset, int length, int lossPercentage)
    • 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.