Package org.aksw.commons.io.hadoop
Class SeekableInputStreams
- java.lang.Object
-
- org.aksw.commons.io.hadoop.SeekableInputStreams
-
public class SeekableInputStreams extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSeekableInputStreams.GetPositionstatic interfaceSeekableInputStreams.GetPositionFn<T>static interfaceSeekableInputStreams.SetPositionstatic interfaceSeekableInputStreams.SetPositionFn<T>
-
Constructor Summary
Constructors Constructor Description SeekableInputStreams()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ReadableByteChanneladvertiseEndOfBlock(InputStream decodedIn, int endOfBlockMarker)The argument for invoking this methods must be a seekable input streams that implements hadoop's protocol for splittable codecs using READ_MODE.BYBLOCK.static <T extends ReadableByteChannel>
SeekableInputStreamcreate(InputStream in, SeekableInputStreams.GetPosition getPosition, SeekableInputStreams.SetPosition setPosition)static SeekableInputStreamcreate(InputStream in, org.apache.hadoop.fs.Seekable seekable)static <T extends ReadableByteChannel>
SeekableInputStreamcreate(T channel, SeekableInputStreams.GetPositionFn<? super T> getPosition, SeekableInputStreams.SetPositionFn<? super T> setPosition)static org.apache.hadoop.fs.SeekablecreateSeekable(SeekableInputStreams.GetPosition getPosition, SeekableInputStreams.SetPosition setPosition)static org.aksw.commons.io.input.SeekableReadableChannel<byte[]>wrap(SeekableInputStream in)Bridge SeekableInputStream to the channel API
-
-
-
Method Detail
-
createSeekable
public static org.apache.hadoop.fs.Seekable createSeekable(SeekableInputStreams.GetPosition getPosition, SeekableInputStreams.SetPosition setPosition)
-
create
public static <T extends ReadableByteChannel> SeekableInputStream create(T channel, SeekableInputStreams.GetPositionFn<? super T> getPosition, SeekableInputStreams.SetPositionFn<? super T> setPosition)
-
wrap
public static org.aksw.commons.io.input.SeekableReadableChannel<byte[]> wrap(SeekableInputStream in)
Bridge SeekableInputStream to the channel API
-
create
public static <T extends ReadableByteChannel> SeekableInputStream create(InputStream in, SeekableInputStreams.GetPosition getPosition, SeekableInputStreams.SetPosition setPosition)
-
create
public static SeekableInputStream create(InputStream in, org.apache.hadoop.fs.Seekable seekable)
-
advertiseEndOfBlock
public static ReadableByteChannel advertiseEndOfBlock(InputStream decodedIn, int endOfBlockMarker) throws IOException
The argument for invoking this methods must be a seekable input streams that implements hadoop's protocol for splittable codecs using READ_MODE.BYBLOCK. Whereas hadoop's protocol will alawys read 1 byte beyond the split boundary, this wrapper will stop exactly at that boundary. Internally a push-back input stream is used to push that single "read-ahead" byte back once it is encountered. A block boundary is advertised by a call to read() by returing -2. This return value indicates that read() may be called again and will return at least one more byte. A return value of -1 indicates "end of file" just as usual.- Parameters:
decodedIn-endOfBlockMarker- The value to return when an end of block is detected- Returns:
- Throws:
IOException
-
-