org.apache.sqoop.lib
Class BlobRef

java.lang.Object
  extended by org.apache.sqoop.lib.LobRef<DATATYPE,CONTAINERTYPE,ACCESSORTYPE>
      extended by com.cloudera.sqoop.lib.LobRef<byte[],org.apache.hadoop.io.BytesWritable,java.io.InputStream>
          extended by org.apache.sqoop.lib.BlobRef
All Implemented Interfaces:
java.io.Closeable, org.apache.hadoop.io.Writable
Direct Known Subclasses:
BlobRef

public class BlobRef
extends LobRef<byte[],org.apache.hadoop.io.BytesWritable,java.io.InputStream>

BlobRef is a wrapper that holds a BLOB either directly, or a reference to a file that holds the BLOB data.


Field Summary
static org.apache.commons.logging.Log LOG
           
 
Fields inherited from class com.cloudera.sqoop.lib.LobRef
EXTERNAL_MATCHER
 
Constructor Summary
BlobRef()
           
BlobRef(byte[] bytes)
           
BlobRef(java.lang.String file, long offset, long length)
          Initialize a BlobRef to an external BLOB.
 
Method Summary
protected  org.apache.hadoop.io.BytesWritable deepCopyData(org.apache.hadoop.io.BytesWritable data)
          Make a copy of the materialized data.
protected  java.io.InputStream getExternalSource(com.cloudera.sqoop.io.LobFile.Reader reader)
          Using the LobFile reader, get an accessor InputStream or Reader to the underlying data.
protected  byte[] getInternalData(org.apache.hadoop.io.BytesWritable data)
           
protected  java.io.InputStream getInternalSource(org.apache.hadoop.io.BytesWritable data)
          Wrap the materialized data in an InputStream or Reader.
static BlobRef parse(java.lang.String inputString)
          Create a BlobRef based on parsed data from a line of text.
 void readFieldsInternal(java.io.DataInput in)
          Perform the readFields() operation on a fully-materializable record.
 void writeInternal(java.io.DataOutput out)
          Perform the write() operation on a fully-materializable record.
 
Methods inherited from class org.apache.sqoop.lib.LobRef
clone, close, finalize, getData, getDataObj, getDataStream, getDataStream, isExternal, readFields, setDataObj, toString, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG
Constructor Detail

BlobRef

public BlobRef()

BlobRef

public BlobRef(byte[] bytes)

BlobRef

public BlobRef(java.lang.String file,
               long offset,
               long length)
Initialize a BlobRef to an external BLOB.

Parameters:
file - the filename to the BLOB. May be relative to the job dir.
offset - the offset (in bytes) into the LobFile for this record.
length - the length of the record in bytes.
Method Detail

getExternalSource

protected java.io.InputStream getExternalSource(com.cloudera.sqoop.io.LobFile.Reader reader)
                                         throws java.io.IOException
Description copied from class: LobRef
Using the LobFile reader, get an accessor InputStream or Reader to the underlying data.

Specified by:
getExternalSource in class LobRef<byte[],org.apache.hadoop.io.BytesWritable,java.io.InputStream>
Throws:
java.io.IOException

getInternalSource

protected java.io.InputStream getInternalSource(org.apache.hadoop.io.BytesWritable data)
Description copied from class: LobRef
Wrap the materialized data in an InputStream or Reader.

Specified by:
getInternalSource in class LobRef<byte[],org.apache.hadoop.io.BytesWritable,java.io.InputStream>

getInternalData

protected byte[] getInternalData(org.apache.hadoop.io.BytesWritable data)
Specified by:
getInternalData in class LobRef<byte[],org.apache.hadoop.io.BytesWritable,java.io.InputStream>
Returns:
the materialized data itself.

deepCopyData

protected org.apache.hadoop.io.BytesWritable deepCopyData(org.apache.hadoop.io.BytesWritable data)
Description copied from class: LobRef
Make a copy of the materialized data.

Specified by:
deepCopyData in class LobRef<byte[],org.apache.hadoop.io.BytesWritable,java.io.InputStream>

readFieldsInternal

public void readFieldsInternal(java.io.DataInput in)
                        throws java.io.IOException
Description copied from class: LobRef
Perform the readFields() operation on a fully-materializable record.

Specified by:
readFieldsInternal in class LobRef<byte[],org.apache.hadoop.io.BytesWritable,java.io.InputStream>
Parameters:
in - the DataInput to deserialize from.
Throws:
java.io.IOException

writeInternal

public void writeInternal(java.io.DataOutput out)
                   throws java.io.IOException
Description copied from class: LobRef
Perform the write() operation on a fully-materializable record.

Specified by:
writeInternal in class LobRef<byte[],org.apache.hadoop.io.BytesWritable,java.io.InputStream>
Parameters:
out - the DataOutput to deserialize to.
Throws:
java.io.IOException

parse

public static BlobRef parse(java.lang.String inputString)
Create a BlobRef based on parsed data from a line of text. This only operates correctly on external blobs; inline blobs are simply returned as null. You should store BLOB data in SequenceFile format if reparsing is necessary.

Parameters:
inputString - the text-based input data to parse.
Returns:
a new BlobRef containing a reference to an external BLOB, or an empty BlobRef if the data to be parsed is actually inline.


Copyright © 2011 The Apache Software Foundation