Package org.apache.hadoop.fs.store
Class DataBlocks
java.lang.Object
org.apache.hadoop.fs.store.DataBlocks
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBase class for block factories.static final classThe output information for an upload.static classThis represents a block being uploaded. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic DataBlocks.BlockFactorycreateFactory(String keyToBufferDir, Configuration configuration, String name) Create a factory.static voidvalidateWriteArgs(byte[] b, int off, int len) Validate args to a write command.
-
Field Details
-
DATA_BLOCKS_BUFFER_DISK
Buffer blocks to disk. Capacity is limited to available disk space.- See Also:
-
DATA_BLOCKS_BYTEBUFFER
Use a byte buffer.- See Also:
-
DATA_BLOCKS_BUFFER_ARRAY
Use an in-memory array. Fast but will run of heap rapidly.- See Also:
-
-
Method Details
-
validateWriteArgs
Validate args to a write command. These are the same validation checks expected for any implementation ofOutputStream.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 bufferIndexOutOfBoundsException- if indices are out of rangeIOException- 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 fromCommonConfigurationKeys.- Returns:
- the factory, ready to be initialized.
- Throws:
IllegalArgumentException- if the name is unknown.
-