Package net.sansa_stack.nio.util
Class ReadableByteChannelFromInputStream
- java.lang.Object
-
- net.sansa_stack.nio.util.ReadableByteChannelFromInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,ReadableByteChannel
- Direct Known Subclasses:
SeekableByteChannelFromSeekableInputStream
public class ReadableByteChannelFromInputStream extends Object implements ReadableByteChannel
A replacement for Channels.newChannel with the following changes for interoperability with hadoop and our GenericRecordReader: - Does not close the underlying stream on interrupt - This implementation's read method just delegates to the input stream (without additional buffering / repeated reads). This way hadoop's posititon advertising remains usable.
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
buf
protected InputStream
in
protected boolean
open
-
Constructor Summary
Constructors Constructor Description ReadableByteChannelFromInputStream(InputStream in)
-
-
-
Field Detail
-
in
protected InputStream in
-
buf
protected byte[] buf
-
open
protected boolean open
-
-
Constructor Detail
-
ReadableByteChannelFromInputStream
public ReadableByteChannelFromInputStream(InputStream in)
-
-
Method Detail
-
read
public int read(ByteBuffer dst) throws IOException
- Specified by:
read
in interfaceReadableByteChannel
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-