Class Shard


public class Shard extends ShardMetadata
A slice is a fully independent unit that can be decoded in decoder side.
  • Method Details

    • getInstance

      public static Shard getInstance()
    • freeInstance

      public static void freeInstance(Shard shard)
    • reset

      public void reset()
      Reset all the values so that the instance can become reusable again.
      Overrides:
      reset in class ShardMetadata
    • splitData

      public void splitData(byte[] data, int index, int length)
      Split the given byte array into shards.
      Parameters:
      data - byte array to be encoded.
      index - starting index of the byte array.
      length - total length of bytes to be encoded. It is possible that all of this length were not fitted into this slice, in that case return value will be the length that were actually fitted into this slice.
    • mergeData

      public int mergeData(byte[] output, int index)
      Get all the data shards value into one single output array.
      Parameters:
      output - byte array where all the data shards will be copied.
      index - starting index of the output byte array
      Returns:
      the length of the output byte array after copying all data.
    • isDecodable

      public boolean isDecodable()
      Decide if there are enough presence shard to decode this slice.
      Returns:
      true, if this Shard can be decoded, otherwise, return false.
    • getData

      public byte[][] getData()
    • getPresence

      public boolean[] getPresence()
    • setPresence

      public void setPresence(int index)
      Set the presence of given index to true.
      Parameters:
      index - index of presence which need to be set true.