public class TableLoader extends LoadFunc implements LoadMetadata, LoadPushDown, IndexableLoadFunc, CollectableLoadFunc, OrderedLoadFunc
LoadPushDown.OperatorSet, LoadPushDown.RequiredField, LoadPushDown.RequiredFieldList, LoadPushDown.RequiredFieldResponse| Constructor and Description |
|---|
TableLoader()
default constructor
|
TableLoader(String projectionStr) |
TableLoader(String projectionStr,
String sorted) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
A method called by the Pig runtime to give an opportunity
for implementations to perform cleanup actions like closing
the underlying input stream.
|
void |
ensureAllKeyInstancesInSameSplit()
When this method is called, Pig is communicating to the Loader that it must
load data such that all instances of a key are in same split.
|
List<LoadPushDown.OperatorSet> |
getFeatures()
Determine the operators that can be pushed to the loader.
|
org.apache.hadoop.mapreduce.InputFormat |
getInputFormat()
This will be called during planning on the front end.
|
Tuple |
getNext()
Retrieves the next tuple to be processed.
|
String[] |
getPartitionKeys(String location,
org.apache.hadoop.mapreduce.Job job)
Find what columns are partition keys for this input.
|
ResourceSchema |
getSchema(String location,
org.apache.hadoop.mapreduce.Job job)
Get a schema for the data to be loaded.
|
org.apache.hadoop.io.WritableComparable<?> |
getSplitComparable(org.apache.hadoop.mapreduce.InputSplit split)
The WritableComparable object returned will be used to compare
the position of different splits in an ordered stream
|
ResourceStatistics |
getStatistics(String location,
org.apache.hadoop.mapreduce.Job job)
Get statistics about the data to be loaded.
|
void |
initialize(org.apache.hadoop.conf.Configuration conf)
This method is called by Pig run time to allow the
IndexableLoadFunc to perform any initialization actions
|
void |
prepareToRead(org.apache.hadoop.mapreduce.RecordReader reader,
PigSplit split)
Initializes LoadFunc for reading data.
|
LoadPushDown.RequiredFieldResponse |
pushProjection(LoadPushDown.RequiredFieldList requiredFieldList)
Indicate to the loader fields that will be needed.
|
void |
seekNear(Tuple tuple)
This method is called only once.
|
void |
setLocation(String location,
org.apache.hadoop.mapreduce.Job job)
This method is called by pig on both frontend and backend.
|
void |
setPartitionFilter(Expression partitionFilter)
Set the filter for partitioning.
|
void |
setUDFContextSignature(String signature)
This method will be called by Pig both in the front end and back end to
pass a unique signature to the
LoadFunc. |
getAbsolutePath, getLoadCaster, getPathStrings, join, relativeToAbsolutePath, warnpublic TableLoader()
public TableLoader(String projectionStr)
projectionStr - projection string passed from pig query.public TableLoader(String projectionStr, String sorted) throws IOException
projectionStr - projection string passed from pig query.sorted - need sorted table(s)?IOExceptionpublic void initialize(org.apache.hadoop.conf.Configuration conf)
throws IOException
IndexableLoadFuncinitialize in interface IndexableLoadFuncconf - The job configuration objectIOExceptionpublic void seekNear(Tuple tuple) throws IOException
seekNear in interface IndexableLoadFunctuple - Tuple with join keys (which are a prefix of the sort
keys of the input data). For example if the data is sorted on
columns in position 2,4,5 any of the following Tuples are
valid as an argument value:
(fieldAt(2))
(fieldAt(2), fieldAt(4))
(fieldAt(2), fieldAt(4), fieldAt(5))
The following are some invalid cases:
(fieldAt(4))
(fieldAt(2), fieldAt(5))
(fieldAt(4), fieldAt(5))IOException - When the loadFunc is unable to position
to the required point in its input streampublic Tuple getNext() throws IOException
LoadFuncgetNext in class LoadFuncIOException - if there is an exception while retrieving the next
tuplepublic void close()
throws IOException
IndexableLoadFuncclose in interface IndexableLoadFuncIOException - if the loadfunc is unable to perform
its close actions.public void prepareToRead(org.apache.hadoop.mapreduce.RecordReader reader,
PigSplit split)
throws IOException
LoadFuncprepareToRead in class LoadFuncreader - RecordReader to be used by this instance of the LoadFuncsplit - The input PigSplit to processIOException - if there is an exception during initializationpublic void setLocation(String location, org.apache.hadoop.mapreduce.Job job) throws IOException
setLocation in class LoadFunclocation - Location as returned by
LoadFunc.relativeToAbsolutePath(String, Path)job - the Job object
store or retrieve earlier stored information from the UDFContextIOException - if the location is not valid.public org.apache.hadoop.mapreduce.InputFormat getInputFormat()
throws IOException
LoadFuncgetInputFormat in class LoadFuncIOException - if there is an exception during InputFormat
constructionpublic String[] getPartitionKeys(String location, org.apache.hadoop.mapreduce.Job job) throws IOException
LoadMetadatagetPartitionKeys in interface LoadMetadatalocation - Location as returned by
LoadFunc.relativeToAbsolutePath(String, org.apache.hadoop.fs.Path)job - The Job object - this should be used only to obtain
cluster properties through JobContextImpl.getConfiguration() and not to set/query
any runtime job information.IOException - if an exception occurs while retrieving partition keyspublic ResourceSchema getSchema(String location, org.apache.hadoop.mapreduce.Job job) throws IOException
LoadMetadatagetSchema in interface LoadMetadatalocation - Location as returned by
LoadFunc.relativeToAbsolutePath(String, org.apache.hadoop.fs.Path)job - The Job object - this should be used only to obtain
cluster properties through JobContextImpl.getConfiguration() and not to set/query
any runtime job information.IOException - if an exception occurs while determining the schemapublic ResourceStatistics getStatistics(String location, org.apache.hadoop.mapreduce.Job job) throws IOException
LoadMetadataLoadFunc, then LoadFunc.setLocation(String, org.apache.hadoop.mapreduce.Job)
is guaranteed to be called before this method.getStatistics in interface LoadMetadatalocation - Location as returned by
LoadFunc.relativeToAbsolutePath(String, org.apache.hadoop.fs.Path)job - The Job object - this should be used only to obtain
cluster properties through JobContextImpl.getConfiguration() and not to set/query
any runtime job information.IOException - if an exception occurs while retrieving statisticspublic void setPartitionFilter(Expression partitionFilter) throws IOException
LoadMetadataLoadMetadata.getPartitionKeys(String, Job), then this method is not
called by Pig runtime. This method is also not called by the Pig runtime
if there are no partition filter conditions.setPartitionFilter in interface LoadMetadatapartitionFilter - that describes filter for partitioningIOException - if the filter is not compatible with the storage
mechanism or contains non-partition fields.public List<LoadPushDown.OperatorSet> getFeatures()
LoadPushDowngetFeatures in interface LoadPushDownpublic LoadPushDown.RequiredFieldResponse pushProjection(LoadPushDown.RequiredFieldList requiredFieldList) throws FrontendException
LoadPushDownpushProjection in interface LoadPushDownrequiredFieldList - RequiredFieldList indicating which columns will be needed.
This structure is read only. User cannot make change to it inside pushProjection.FrontendExceptionpublic void setUDFContextSignature(String signature)
LoadFuncLoadFunc. The signature can be used
to store into the UDFContext any information which the
LoadFunc needs to store between various method invocations in the
front end and back end. A use case is to store LoadPushDown.RequiredFieldList
passed to it in LoadPushDown.pushProjection(RequiredFieldList) for
use in the back end before returning tuples in LoadFunc.getNext().
This method will be call before other methods in LoadFuncsetUDFContextSignature in class LoadFuncsignature - a unique signature to identify this LoadFuncpublic org.apache.hadoop.io.WritableComparable<?> getSplitComparable(org.apache.hadoop.mapreduce.InputSplit split)
throws IOException
OrderedLoadFuncgetSplitComparable in interface OrderedLoadFuncsplit - An InputSplit from the InputFormat underlying this loader.IOExceptionpublic void ensureAllKeyInstancesInSameSplit()
throws IOException
CollectableLoadFuncensureAllKeyInstancesInSameSplit in interface CollectableLoadFuncIOExceptionCopyright © 2007-2012 The Apache Software Foundation