Class ReedSolomonOptimized

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

public class ReedSolomonOptimized extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final int
     
    final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ReedSolomonOptimized(int dataShardCount, int parityShardCount, CodingLoop codingLoop)
    Initializes a new encoder/decoder, with a chosen coding loop.
  • Method Summary

    Modifier and Type
    Method
    Description
    create(int dataShardCount, int parityShardCount)
     
    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.
    void
    decodeMissing(byte[][] shards, boolean[] shardPresent, int offset, int byteCount, int dataShardCount, int parityShardCount)
    Given a list of shards, some of which contain data, fills in the ones that don't have data.
    void
    encodeParity(byte[][] shards, int offset, int byteCount)
     
    void
    encodeParity(byte[][] shards, int offset, int byteCount, int dataShardCount, int parityShardCount)
     
    boolean
    isParityCorrect(byte[][] shards, int firstByte, int byteCount, int dataShardCount, int parityShardCount)
    Returns true if the parity shards contain the right data.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • dataShardCount

      public final int dataShardCount
    • parityShardsCount

      public final int parityShardsCount
  • Constructor Details

    • ReedSolomonOptimized

      public ReedSolomonOptimized(int dataShardCount, int parityShardCount, CodingLoop codingLoop)
      Initializes a new encoder/decoder, with a chosen coding loop.
  • Method Details

    • create

      public static ReedSolomonOptimized create(int dataShardCount, int parityShardCount)
    • isParityCorrect

      public boolean isParityCorrect(byte[][] shards, int firstByte, int byteCount, int dataShardCount, int parityShardCount)
      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.
    • encodeParity

      public void encodeParity(byte[][] shards, int offset, int byteCount)
    • encodeParity

      public void encodeParity(byte[][] shards, int offset, int byteCount, int dataShardCount, int parityShardCount)
    • 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 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.

    • decodeMissing

      public void decodeMissing(byte[][] shards, boolean[] shardPresent, int offset, int byteCount, int dataShardCount, int parityShardCount)
      Given a list of shards, some of which contain data, fills in the ones that don't have data.

      Quickly does nothing if all 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.