public class TextLoader extends LoadFunc implements LoadCaster
Modifier and Type | Field and Description |
---|---|
protected org.apache.hadoop.mapreduce.RecordReader |
in |
protected org.apache.commons.logging.Log |
mLog |
Constructor and Description |
---|
TextLoader() |
Modifier and Type | Method and Description |
---|---|
DataBag |
bytesToBag(byte[] b,
ResourceSchema.ResourceFieldSchema schema)
TextLoader does not support conversion to Bag
|
java.math.BigDecimal |
bytesToBigDecimal(byte[] b)
Cast data from bytearray to BigDecimal value.
|
java.math.BigInteger |
bytesToBigInteger(byte[] b)
Cast data from bytearray to BigInteger value.
|
java.lang.Boolean |
bytesToBoolean(byte[] b)
TextLoader does not support conversion to Boolean
|
java.lang.String |
bytesToCharArray(byte[] b)
Cast data from bytes to chararray value.
|
org.joda.time.DateTime |
bytesToDateTime(byte[] b)
TextLoader does not support conversion to DateTime
|
java.lang.Double |
bytesToDouble(byte[] b)
TextLoader does not support conversion to Double
|
java.lang.Float |
bytesToFloat(byte[] b)
TextLoader does not support conversion to Float
|
java.lang.Integer |
bytesToInteger(byte[] b)
TextLoader does not support conversion to Integer
|
java.lang.Long |
bytesToLong(byte[] b)
TextLoader does not support conversion to Long
|
java.util.Map<java.lang.String,java.lang.Object> |
bytesToMap(byte[] b,
ResourceSchema.ResourceFieldSchema schema)
Cast data from bytearray to map value.
|
Tuple |
bytesToTuple(byte[] b,
ResourceSchema.ResourceFieldSchema schema)
TextLoader does not support conversion to Tuple
|
org.apache.hadoop.mapreduce.InputFormat |
getInputFormat()
This will be called during planning on the front end.
|
LoadCaster |
getLoadCaster()
This will be called on both the front end and the back
end during execution.
|
Tuple |
getNext()
Retrieves the next tuple to be processed.
|
void |
prepareToRead(org.apache.hadoop.mapreduce.RecordReader reader,
PigSplit split)
Initializes LoadFunc for reading data.
|
void |
setLocation(java.lang.String location,
org.apache.hadoop.mapreduce.Job job)
Communicate to the loader the location of the object(s) being loaded.
|
byte[] |
toBytes(java.lang.Boolean b) |
byte[] |
toBytes(DataBag bag) |
byte[] |
toBytes(org.joda.time.DateTime dt) |
byte[] |
toBytes(java.lang.Double d) |
byte[] |
toBytes(java.lang.Float f) |
byte[] |
toBytes(java.lang.Integer i) |
byte[] |
toBytes(java.lang.Long l) |
byte[] |
toBytes(java.util.Map<java.lang.String,java.lang.Object> m) |
byte[] |
toBytes(java.lang.String s) |
byte[] |
toBytes(Tuple t) |
getAbsolutePath, getCacheFiles, getPathStrings, getShipFiles, join, relativeToAbsolutePath, setUDFContextSignature, warn
protected org.apache.hadoop.mapreduce.RecordReader in
protected final org.apache.commons.logging.Log mLog
public Tuple getNext() throws java.io.IOException
LoadFunc
public java.lang.Boolean bytesToBoolean(byte[] b) throws java.io.IOException
bytesToBoolean
in interface LoadCaster
b
- bytearray to be cast.java.io.IOException
- if the value cannot be cast.public java.lang.Integer bytesToInteger(byte[] b) throws java.io.IOException
bytesToInteger
in interface LoadCaster
b
- bytearray to be cast.java.io.IOException
- if the value cannot be cast.public java.lang.Long bytesToLong(byte[] b) throws java.io.IOException
bytesToLong
in interface LoadCaster
b
- bytearray to be cast.java.io.IOException
- if the value cannot be cast.public java.lang.Float bytesToFloat(byte[] b) throws java.io.IOException
bytesToFloat
in interface LoadCaster
b
- bytearray to be cast.java.io.IOException
- if the value cannot be cast.public java.lang.Double bytesToDouble(byte[] b) throws java.io.IOException
bytesToDouble
in interface LoadCaster
b
- bytearray to be cast.java.io.IOException
- if the value cannot be cast.public org.joda.time.DateTime bytesToDateTime(byte[] b) throws java.io.IOException
bytesToDateTime
in interface LoadCaster
b
- bytearray to be cast.java.io.IOException
- if the value cannot be cast.public java.lang.String bytesToCharArray(byte[] b) throws java.io.IOException
bytesToCharArray
in interface LoadCaster
b
- byte array to be cast.java.io.IOException
- if the value cannot be cast.public java.util.Map<java.lang.String,java.lang.Object> bytesToMap(byte[] b, ResourceSchema.ResourceFieldSchema schema) throws java.io.IOException
LoadCaster
bytesToMap
in interface LoadCaster
b
- bytearray to be cast.schema
- field schema for the output mapjava.io.IOException
- if the value cannot be cast.public Tuple bytesToTuple(byte[] b, ResourceSchema.ResourceFieldSchema schema) throws java.io.IOException
bytesToTuple
in interface LoadCaster
b
- bytearray to be cast.schema
- field schema for the output tuplejava.io.IOException
- if the value cannot be cast.public DataBag bytesToBag(byte[] b, ResourceSchema.ResourceFieldSchema schema) throws java.io.IOException
bytesToBag
in interface LoadCaster
b
- bytearray to be cast.schema
- field schema for the output bagjava.io.IOException
- if the value cannot be cast.public byte[] toBytes(DataBag bag) throws java.io.IOException
java.io.IOException
public byte[] toBytes(java.lang.String s) throws java.io.IOException
java.io.IOException
public byte[] toBytes(java.lang.Double d) throws java.io.IOException
java.io.IOException
public byte[] toBytes(java.lang.Float f) throws java.io.IOException
java.io.IOException
public byte[] toBytes(java.lang.Boolean b) throws java.io.IOException
java.io.IOException
public byte[] toBytes(java.lang.Integer i) throws java.io.IOException
java.io.IOException
public byte[] toBytes(java.lang.Long l) throws java.io.IOException
java.io.IOException
public byte[] toBytes(org.joda.time.DateTime dt) throws java.io.IOException
java.io.IOException
public byte[] toBytes(java.util.Map<java.lang.String,java.lang.Object> m) throws java.io.IOException
java.io.IOException
public byte[] toBytes(Tuple t) throws java.io.IOException
java.io.IOException
public java.math.BigInteger bytesToBigInteger(byte[] b) throws java.io.IOException
LoadCaster
bytesToBigInteger
in interface LoadCaster
b
- bytearray to be cast.java.io.IOException
- if the value cannot be cast.public java.math.BigDecimal bytesToBigDecimal(byte[] b) throws java.io.IOException
LoadCaster
bytesToBigDecimal
in interface LoadCaster
b
- bytearray to be cast.java.io.IOException
- if the value cannot be cast.public org.apache.hadoop.mapreduce.InputFormat getInputFormat()
LoadFunc
getInputFormat
in class LoadFunc
public LoadCaster getLoadCaster()
LoadFunc
getLoadCaster
in class LoadFunc
LoadCaster
associated with this loader. Returning null
indicates that casts from byte array are not supported for this loader.
constructionpublic void prepareToRead(org.apache.hadoop.mapreduce.RecordReader reader, PigSplit split)
LoadFunc
prepareToRead
in class LoadFunc
reader
- RecordReader
to be used by this instance of the LoadFuncsplit
- The input PigSplit
to processpublic void setLocation(java.lang.String location, org.apache.hadoop.mapreduce.Job job) throws java.io.IOException
LoadFunc
LoadFunc.relativeToAbsolutePath(String, Path)
. Implementations
should use this method to communicate the location (and any other information)
to its underlying InputFormat through the Job object.
This method will be called in the frontend and backend multiple times. Implementations
should bear in mind that this method is called multiple times and should
ensure there are no inconsistent side effects due to the multiple calls.setLocation
in class LoadFunc
location
- Location as returned by
LoadFunc.relativeToAbsolutePath(String, Path)
job
- the Job
object
store or retrieve earlier stored information from the UDFContext
java.io.IOException
- if the location is not valid.Copyright © 2007-2017 The Apache Software Foundation