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
|
BigDecimal |
bytesToBigDecimal(byte[] b)
Cast data from bytearray to BigDecimal value.
|
BigInteger |
bytesToBigInteger(byte[] b)
Cast data from bytearray to BigInteger value.
|
Boolean |
bytesToBoolean(byte[] b)
TextLoader does not support conversion to Boolean
|
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
|
Double |
bytesToDouble(byte[] b)
TextLoader does not support conversion to Double
|
Float |
bytesToFloat(byte[] b)
TextLoader does not support conversion to Float
|
Integer |
bytesToInteger(byte[] b)
TextLoader does not support conversion to Integer
|
Long |
bytesToLong(byte[] b)
TextLoader does not support conversion to Long
|
Map<String,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(String location,
org.apache.hadoop.mapreduce.Job job)
Communicate to the loader the location of the object(s) being loaded.
|
byte[] |
toBytes(Boolean b) |
byte[] |
toBytes(DataBag bag) |
byte[] |
toBytes(org.joda.time.DateTime dt) |
byte[] |
toBytes(Double d) |
byte[] |
toBytes(Float f) |
byte[] |
toBytes(Integer i) |
byte[] |
toBytes(Long l) |
byte[] |
toBytes(Map<String,Object> m) |
byte[] |
toBytes(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 IOException
LoadFunc
getNext
in class LoadFunc
IOException
- if there is an exception while retrieving the next
tuplepublic Boolean bytesToBoolean(byte[] b) throws IOException
bytesToBoolean
in interface LoadCaster
b
- bytearray to be cast.IOException
- if the value cannot be cast.public Integer bytesToInteger(byte[] b) throws IOException
bytesToInteger
in interface LoadCaster
b
- bytearray to be cast.IOException
- if the value cannot be cast.public Long bytesToLong(byte[] b) throws IOException
bytesToLong
in interface LoadCaster
b
- bytearray to be cast.IOException
- if the value cannot be cast.public Float bytesToFloat(byte[] b) throws IOException
bytesToFloat
in interface LoadCaster
b
- bytearray to be cast.IOException
- if the value cannot be cast.public Double bytesToDouble(byte[] b) throws IOException
bytesToDouble
in interface LoadCaster
b
- bytearray to be cast.IOException
- if the value cannot be cast.public org.joda.time.DateTime bytesToDateTime(byte[] b) throws IOException
bytesToDateTime
in interface LoadCaster
b
- bytearray to be cast.IOException
- if the value cannot be cast.public String bytesToCharArray(byte[] b) throws IOException
bytesToCharArray
in interface LoadCaster
b
- byte array to be cast.IOException
- if the value cannot be cast.public Map<String,Object> bytesToMap(byte[] b, ResourceSchema.ResourceFieldSchema schema) throws IOException
LoadCaster
bytesToMap
in interface LoadCaster
b
- bytearray to be cast.schema
- field schema for the output mapIOException
- if the value cannot be cast.public Tuple bytesToTuple(byte[] b, ResourceSchema.ResourceFieldSchema schema) throws IOException
bytesToTuple
in interface LoadCaster
b
- bytearray to be cast.schema
- field schema for the output tupleIOException
- if the value cannot be cast.public DataBag bytesToBag(byte[] b, ResourceSchema.ResourceFieldSchema schema) throws IOException
bytesToBag
in interface LoadCaster
b
- bytearray to be cast.schema
- field schema for the output bagIOException
- if the value cannot be cast.public byte[] toBytes(DataBag bag) throws IOException
IOException
public byte[] toBytes(String s) throws IOException
IOException
public byte[] toBytes(Double d) throws IOException
IOException
public byte[] toBytes(Float f) throws IOException
IOException
public byte[] toBytes(Boolean b) throws IOException
IOException
public byte[] toBytes(Integer i) throws IOException
IOException
public byte[] toBytes(Long l) throws IOException
IOException
public byte[] toBytes(org.joda.time.DateTime dt) throws IOException
IOException
public byte[] toBytes(Map<String,Object> m) throws IOException
IOException
public byte[] toBytes(Tuple t) throws IOException
IOException
public BigInteger bytesToBigInteger(byte[] b) throws IOException
LoadCaster
bytesToBigInteger
in interface LoadCaster
b
- bytearray to be cast.IOException
- if the value cannot be cast.public BigDecimal bytesToBigDecimal(byte[] b) throws IOException
LoadCaster
bytesToBigDecimal
in interface LoadCaster
b
- bytearray to be cast.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(String location, org.apache.hadoop.mapreduce.Job job) throws 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
IOException
- if the location is not valid.Copyright © 2007-2017 The Apache Software Foundation