com.cloudera.sqoop.io
Class LobFile.Reader

java.lang.Object
  extended by com.cloudera.sqoop.io.LobFile.Reader
All Implemented Interfaces:
java.io.Closeable
Enclosing class:
LobFile

public abstract static class LobFile.Reader
extends java.lang.Object
implements java.io.Closeable

Class that can read a LobFile. Create with LobFile.open().


Constructor Summary
LobFile.Reader()
           
 
Method Summary
protected  void checkForNull(java.io.InputStream in)
          Checks whether an underlying stream is present or null.
abstract  void close()
          Closes the reader.
protected  void finalize()
           
abstract  org.apache.hadoop.fs.Path getPath()
          If this Reader is reading from a physical LobFile, then this returns the file path it is reading from.
abstract  long getRecordId()
          Return the entryId of the current record to the user.
abstract  long getRecordLen()
          Reports the length of the record to the user.
abstract  long getRecordOffset()
          Return the byte offset at which the current record starts.
abstract  boolean isClosed()
           
abstract  boolean isRecordAvailable()
           
abstract  boolean next()
          Advances to the next record in the file.
abstract  java.io.InputStream readBlobRecord()
           
abstract  java.io.Reader readClobRecord()
           
abstract  void seek(long pos)
          Move the file pointer to the first available full record beginning at position 'pos', relative to the start of the file.
abstract  long tell()
          Report the current position in the file.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LobFile.Reader

public LobFile.Reader()
Method Detail

getPath

public abstract org.apache.hadoop.fs.Path getPath()
If this Reader is reading from a physical LobFile, then this returns the file path it is reading from. Otherwise it returns null.

Returns:
the fully-qualified path being read by this reader.

tell

public abstract long tell()
                   throws java.io.IOException
Report the current position in the file. Note that the internal cursor may move in an unpredictable fashion; e.g., to fetch additional data from the index stored at the end of the file. Clients may be more interested in the getRecordOffset() method which returns the starting offset of the current record.

Returns:
the current offset from the start of the file in bytes.
Throws:
java.io.IOException

seek

public abstract void seek(long pos)
                   throws java.io.IOException
Move the file pointer to the first available full record beginning at position 'pos', relative to the start of the file. After calling seek(), you will need to call next() to move to the record itself.

Parameters:
pos - the position to seek to or past.
Throws:
java.io.IOException

next

public abstract boolean next()
                      throws java.io.IOException
Advances to the next record in the file.

Returns:
true if another record exists, or false if the end of the file has been reached.
Throws:
java.io.IOException

isRecordAvailable

public abstract boolean isRecordAvailable()
Returns:
true if we have aligned the Reader (through a call to next()) onto a record.

getRecordLen

public abstract long getRecordLen()
Reports the length of the record to the user. If next() has not been called, or seek() has been called without a subsequent call to next(), or next() returned false, the return value of this method is undefined.

Returns:
the 'claimedLen' field of the current record. For character-based records, this is often in characters, not bytes. Records may have more bytes associated with them than are reported by this method, but never fewer.

getRecordId

public abstract long getRecordId()
Return the entryId of the current record to the user. If next() has not been called, or seek() has been called without a subsequent call to next(), or next() returned false, the return value of this method is undefined.

Returns:
the 'entryId' field of the current record.

getRecordOffset

public abstract long getRecordOffset()
Return the byte offset at which the current record starts. If next() has not been called, or seek() has been called without a subsequent call to next(), or next() returned false, the return value of this method is undefined.

Returns:
the byte offset of the beginning of the current record.

readBlobRecord

public abstract java.io.InputStream readBlobRecord()
                                            throws java.io.IOException
Returns:
an InputStream allowing the user to read the next binary record from the file.
Throws:
java.io.IOException

readClobRecord

public abstract java.io.Reader readClobRecord()
                                       throws java.io.IOException
Returns:
a java.io.Reader allowing the user to read the next character record from the file.
Throws:
java.io.IOException

close

public abstract void close()
                    throws java.io.IOException
Closes the reader.

Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException

checkForNull

protected void checkForNull(java.io.InputStream in)
                     throws java.io.IOException
Checks whether an underlying stream is present or null.

Parameters:
in - the stream to check for null-ness.
Throws:
java.io.IOException - if in is null.

isClosed

public abstract boolean isClosed()
Returns:
true if the Reader.close() method has been called.

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable


Copyright © 2010 Cloudera, Inc.