Class BlobRef

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, org.apache.hadoop.io.Writable

    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

      Fields 
      Modifier and Type Field Description
      static org.apache.commons.logging.Log LOG  
    • Constructor Summary

      Constructors 
      Constructor Description
      BlobRef()  
      BlobRef​(byte[] bytes)  
      BlobRef​(java.lang.String file, long offset, long length)
      Initialize a BlobRef to an external BLOB.
    • 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​(org.apache.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.