ErasureDecoder (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.io.erasurecode.coder, class: ErasureDecoder

Package org.apache.hadoop.io.erasurecode.coder

# Class ErasureDecoder

java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.io.erasurecode.coder.ErasureDecoder

All Implemented Interfaces:
  `Configurable`, `ErasureCoder`

Direct Known Subclasses:
  `DummyErasureDecoder`, `HHXORErasureDecoder`, `RSErasureDecoder`, `XORErasureDecoder`

@Private public abstract class ErasureDecoder extends Configured implements ErasureCoder
An abstract erasure decoder that's to be inherited by new decoders. It implements the `ErasureCoder` interface.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ErasureDecoder(ErasureCoderOptions options)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ErasureCodingStep`
  `calculateCoding(ECBlockGroup blockGroup)`
  Calculate the encoding or decoding steps given a block blockGroup.
  `protected int[]`
  `getErasedIndexes(ECBlock[] inputBlocks)`
  Get indexes of erased blocks from inputBlocks
  `protected ECBlock[]`
  `getInputBlocks(ECBlockGroup blockGroup)`
  We have all the data blocks and parity blocks as input blocks for recovering by default.
  `int`
  `getNumDataUnits()`
  The number of data input units for the coding.
  `protected static int`
  `getNumErasedBlocks(ECBlock[] inputBlocks)`
  Find out how many blocks are erased.
  `protected int`
  `getNumErasedBlocks(ECBlockGroup blockGroup)`
  Get the number of erased blocks in the block group.
  `int`
  `getNumParityUnits()`
  The number of parity output units for the coding.
  `ErasureCoderOptions`
  `getOptions()`
  The options of erasure coder.
  `protected ECBlock[]`
  `getOutputBlocks(ECBlockGroup blockGroup)`
  Which blocks were erased ?
  `boolean`
  `preferDirectBuffer()`
  Tell if direct or off-heap buffer is preferred or not.
  `protected abstract ErasureCodingStep`
  `prepareDecodingStep(ECBlockGroup blockGroup)`
  Perform decoding against a block blockGroup.
  `void`
  `release()`
  Release the resources if any.

  ### Methods inherited from class org.apache.hadoop.conf.Configured

  `getConf, setConf`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.apache.hadoop.conf.Configurable

  `getConf, setConf`

- ## Constructor Details

  - ### ErasureDecoder

    public ErasureDecoder(ErasureCoderOptions options)

- ## Method Details

  - ### calculateCoding

    public ErasureCodingStep calculateCoding(ECBlockGroup blockGroup)
    Description copied from interface: `ErasureCoder`
    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.
    Specified by:
      `calculateCoding` in interface `ErasureCoder`
    Parameters:
      `blockGroup` - the erasure coding block group containing all necessary information for codec calculation
    Returns:
      ErasureCodingStep.

  - ### getNumDataUnits

    public int getNumDataUnits()
    Description copied from interface: `ErasureCoder`
    The number of data input units for the coding. A unit can be a byte, chunk or buffer or even a block.
    Specified by:
      `getNumDataUnits` in interface `ErasureCoder`
    Returns:
      count of data input units

  - ### getNumParityUnits

    public int getNumParityUnits()
    Description copied from interface: `ErasureCoder`
    The number of parity output units for the coding. A unit can be a byte, chunk, buffer or even a block.
    Specified by:
      `getNumParityUnits` in interface `ErasureCoder`
    Returns:
      count of parity output units

  - ### getOptions

    public ErasureCoderOptions getOptions()
    Description copied from interface: `ErasureCoder`
    The options of erasure coder. This option is passed to raw erasure coder as it is.
    Specified by:
      `getOptions` in interface `ErasureCoder`
    Returns:
      erasure coder options

  - ### getInputBlocks

    protected ECBlock[] getInputBlocks(ECBlockGroup blockGroup)
    We have all the data blocks and parity blocks as input blocks for recovering by default. It's codec specific
    Parameters:
      `blockGroup` - blockGroup.
    Returns:
      input blocks

  - ### getOutputBlocks

    protected ECBlock[] getOutputBlocks(ECBlockGroup blockGroup)
    Which blocks were erased ?
    Parameters:
      `blockGroup` - blockGroup.
    Returns:
      output blocks to recover

  - ### preferDirectBuffer

    public boolean preferDirectBuffer()
    Description copied from interface: `ErasureCoder`
    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.
    Specified by:
      `preferDirectBuffer` in interface `ErasureCoder`
    Returns:
      true if direct buffer is preferred for performance consideration, otherwise false.

  - ### release

    public void release()
    Description copied from interface: `ErasureCoder`
    Release the resources if any. Good chance to invoke RawErasureCoder#release.
    Specified by:
      `release` in interface `ErasureCoder`

  - ### prepareDecodingStep

    protected abstract ErasureCodingStep prepareDecodingStep(ECBlockGroup blockGroup)
    Perform decoding against a block blockGroup.
    Parameters:
      `blockGroup` - blockGroup.
    Returns:
      decoding step for caller to do the real work

  - ### getNumErasedBlocks

    protected int getNumErasedBlocks(ECBlockGroup blockGroup)
    Get the number of erased blocks in the block group.
    Parameters:
      `blockGroup` - blockGroup.
    Returns:
      number of erased blocks

  - ### getNumErasedBlocks

    protected static int getNumErasedBlocks(ECBlock[] inputBlocks)
    Find out how many blocks are erased.
    Parameters:
      `inputBlocks` - all the input blocks
    Returns:
      number of erased blocks

  - ### getErasedIndexes

    protected int[] getErasedIndexes(ECBlock[] inputBlocks)
    Get indexes of erased blocks from inputBlocks
    Parameters:
      `inputBlocks` - inputBlocks.
    Returns:
      indexes of erased blocks from inputBlocks