Class DataBlocks

java.lang.Object
org.apache.hadoop.fs.store.DataBlocks

public final class DataBlocks extends Object
A class to provide disk, byteBuffer and byteArray option for Filesystem OutputStreams.
  • Disk: Uses Disk space to write the blocks. Is suited best to avoid OutOfMemory Errors in Java heap space.
  • byteBuffer: Uses DirectByteBuffer to allocate memory off-heap to provide faster writing of DataBlocks with some risk of running OutOfMemory.
  • byteArray: Uses byte[] to write a block of data. On heap and does have risk of running OutOfMemory fairly easily.

Implementation of DataBlocks taken from HADOOP-13560 to support huge file uploads in S3A with different options rather than one.

  • Field Details

    • DATA_BLOCKS_BUFFER_DISK

      public static final String DATA_BLOCKS_BUFFER_DISK
      Buffer blocks to disk. Capacity is limited to available disk space.
      See Also:
    • DATA_BLOCKS_BYTEBUFFER

      public static final String DATA_BLOCKS_BYTEBUFFER
      Use a byte buffer.
      See Also:
    • DATA_BLOCKS_BUFFER_ARRAY

      public static final String DATA_BLOCKS_BUFFER_ARRAY
      Use an in-memory array. Fast but will run of heap rapidly.
      See Also:
  • Method Details

    • validateWriteArgs

      public static void validateWriteArgs(byte[] b, int off, int len) throws IOException
      Validate args to a write command. These are the same validation checks expected for any implementation of OutputStream.write().
      Parameters:
      b - byte array containing data.
      off - offset in array where to start.
      len - number of bytes to be written.
      Throws:
      NullPointerException - for a null buffer
      IndexOutOfBoundsException - if indices are out of range
      IOException - raised on errors performing I/O.
    • createFactory

      public static DataBlocks.BlockFactory createFactory(String keyToBufferDir, Configuration configuration, String name)
      Create a factory.
      Parameters:
      keyToBufferDir - Key to buffer directory config for a FS.
      configuration - factory configurations.
      name - factory name -the option from CommonConfigurationKeys.
      Returns:
      the factory, ready to be initialized.
      Throws:
      IllegalArgumentException - if the name is unknown.