tachyon.hadoop
Class TFileInputStreamHdfs

java.lang.Object
  extended by java.io.InputStream
      extended by tachyon.hadoop.TFileInputStreamHdfs
All Implemented Interfaces:
Closeable, org.apache.hadoop.fs.PositionedReadable, org.apache.hadoop.fs.Seekable

public class TFileInputStreamHdfs
extends InputStream
implements org.apache.hadoop.fs.Seekable, org.apache.hadoop.fs.PositionedReadable


Constructor Summary
TFileInputStreamHdfs(TachyonClient tachyonClient, int fileId, org.apache.hadoop.fs.Path hdfsPath, org.apache.hadoop.conf.Configuration conf, int bufferSize)
           
 
Method Summary
 void close()
           
 long getPos()
          Return the current offset from the start of the file
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 int read(long position, byte[] buffer, int offset, int length)
          Read upto the specified number of bytes, from a given position within a file, and return the number of bytes read.
 void readFully(long position, byte[] buffer)
          Read number of bytes equalt to the length of the buffer, from a given position within a file.
 void readFully(long position, byte[] buffer, int offset, int length)
          Read the specified number of bytes, from a given position within a file.
 void seek(long pos)
          Seek to the given offset from the start of the file.
 boolean seekToNewSource(long targetPos)
          Seeks a different copy of the data.
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TFileInputStreamHdfs

public TFileInputStreamHdfs(TachyonClient tachyonClient,
                            int fileId,
                            org.apache.hadoop.fs.Path hdfsPath,
                            org.apache.hadoop.conf.Configuration conf,
                            int bufferSize)
Method Detail

read

public int read(long position,
                byte[] buffer,
                int offset,
                int length)
         throws IOException
Read upto the specified number of bytes, from a given position within a file, and return the number of bytes read. This does not change the current offset of a file, and is thread-safe.

Specified by:
read in interface org.apache.hadoop.fs.PositionedReadable
Throws:
IOException

readFully

public void readFully(long position,
                      byte[] buffer)
               throws IOException
Read number of bytes equalt to the length of the buffer, from a given position within a file. This does not change the current offset of a file, and is thread-safe.

Specified by:
readFully in interface org.apache.hadoop.fs.PositionedReadable
Throws:
IOException

readFully

public void readFully(long position,
                      byte[] buffer,
                      int offset,
                      int length)
               throws IOException
Read the specified number of bytes, from a given position within a file. This does not change the current offset of a file, and is thread-safe.

Specified by:
readFully in interface org.apache.hadoop.fs.PositionedReadable
Throws:
IOException

getPos

public long getPos()
            throws IOException
Return the current offset from the start of the file

Specified by:
getPos in interface org.apache.hadoop.fs.Seekable
Throws:
IOException

seek

public void seek(long pos)
          throws IOException
Seek to the given offset from the start of the file. The next read() will be from that location. Can't seek past the end of the file.

Specified by:
seek in interface org.apache.hadoop.fs.Seekable
Throws:
IOException

seekToNewSource

public boolean seekToNewSource(long targetPos)
                        throws IOException
Seeks a different copy of the data. Returns true if found a new source, false otherwise.

Specified by:
seekToNewSource in interface org.apache.hadoop.fs.Seekable
Throws:
IOException

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException


Copyright © 2013. All Rights Reserved.