@InterfaceAudience.Private public final class BlockIOUtils extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
isByteBufferReadable(org.apache.hadoop.fs.FSDataInputStream is) |
static boolean |
preadWithExtra(ByteBuff buff,
org.apache.hadoop.fs.FSDataInputStream dis,
long position,
int necessaryLen,
int extraLen)
Read from an input stream at least
necessaryLen and if possible,
extraLen also if available. |
static void |
readFully(ByteBuff buf,
org.apache.hadoop.fs.FSDataInputStream dis,
int length)
Read length bytes into ByteBuffers directly.
|
static void |
readFullyWithHeapBuffer(InputStream in,
ByteBuff out,
int length)
Copying bytes from InputStream to
ByteBuff by using an temporary heap byte[] (default
size is 1024 now). |
static boolean |
readWithExtra(ByteBuff buf,
org.apache.hadoop.fs.FSDataInputStream dis,
int necessaryLen,
int extraLen)
Read bytes into ByteBuffers directly, those buffers either contains the extraLen bytes or only
contains necessaryLen bytes, which depends on how much bytes do the last time we read.
|
public static boolean isByteBufferReadable(org.apache.hadoop.fs.FSDataInputStream is)
public static void readFully(ByteBuff buf, org.apache.hadoop.fs.FSDataInputStream dis, int length) throws IOException
buf
- the destination ByteBuff
dis
- the HDFS input stream which implement the ByteBufferReadable interface.length
- bytes to read.IOException
- exception to throw if any error happenpublic static void readFullyWithHeapBuffer(InputStream in, ByteBuff out, int length) throws IOException
ByteBuff
by using an temporary heap byte[] (default
size is 1024 now).in
- the InputStream to readout
- the destination ByteBuff
length
- to readIOException
- if any io error encountered.public static boolean readWithExtra(ByteBuff buf, org.apache.hadoop.fs.FSDataInputStream dis, int necessaryLen, int extraLen) throws IOException
buf
- the destination ByteBuff
.dis
- input stream to read.necessaryLen
- bytes which we must readextraLen
- bytes which we may readIOException
- if failed to read the necessary bytes.public static boolean preadWithExtra(ByteBuff buff, org.apache.hadoop.fs.FSDataInputStream dis, long position, int necessaryLen, int extraLen) throws IOException
necessaryLen
and if possible,
extraLen
also if available. Analogous to
IOUtils.readFully(InputStream, byte[], int, int)
, but uses positional read and
specifies a number of "extra" bytes that would be desirable but not absolutely necessary to
read.buff
- ByteBuff to read into.dis
- the input stream to read fromposition
- the position within the stream from which to start readingnecessaryLen
- the number of bytes that are absolutely necessary to readextraLen
- the number of extra bytes that would be nice to readIOException
- if failed to read the necessary bytesCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.