Interface ErasureCoder

All Superinterfaces:
Configurable
All Known Implementing Classes:
DummyErasureDecoder, DummyErasureEncoder, ErasureDecoder, ErasureEncoder, HHXORErasureDecoder, HHXORErasureEncoder, RSErasureDecoder, RSErasureEncoder, XORErasureDecoder, XORErasureEncoder

@Private public interface ErasureCoder extends Configurable
An erasure coder to perform encoding or decoding given a group. Generally it involves calculating necessary internal steps according to codec logic. For each step,it calculates necessary input blocks to read chunks from and output parity blocks to write parity chunks into from the group. It also takes care of appropriate raw coder to use for the step. And encapsulates all the necessary info (input blocks, output blocks and raw coder) into a step represented by ErasureCodingStep. ErasureCoder callers can use the step to do the real work with retrieved input and output chunks. Note, currently only one coding step is supported. Will support complex cases of multiple coding steps.
  • Method Details

    • getNumDataUnits

      int getNumDataUnits()
      The number of data input units for the coding. A unit can be a byte, chunk or buffer or even a block.
      Returns:
      count of data input units
    • getNumParityUnits

      int getNumParityUnits()
      The number of parity output units for the coding. A unit can be a byte, chunk, buffer or even a block.
      Returns:
      count of parity output units
    • getOptions

      ErasureCoderOptions getOptions()
      The options of erasure coder. This option is passed to raw erasure coder as it is.
      Returns:
      erasure coder options
    • calculateCoding

      ErasureCodingStep calculateCoding(ECBlockGroup blockGroup)
      Calculate the encoding or decoding steps given a block blockGroup. Note, currently only one coding step is supported. Will support complex cases of multiple coding steps.
      Parameters:
      blockGroup - the erasure coding block group containing all necessary information for codec calculation
      Returns:
      ErasureCodingStep.
    • preferDirectBuffer

      boolean preferDirectBuffer()
      Tell if direct or off-heap buffer is preferred or not. It's for callers to decide how to allocate coding chunk buffers, either on heap or off heap. It will return false by default.
      Returns:
      true if direct buffer is preferred for performance consideration, otherwise false.
    • release

      void release()
      Release the resources if any. Good chance to invoke RawErasureCoder#release.