|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.pig.StoreFunc
org.apache.pig.piggybank.storage.FixedWidthStorer
public class FixedWidthStorer
Stores Pig records in a fixed-width file format. Takes a string argument specifying the ranges of each column in a unix 'cut'-like format. Ex: '-5, 10-12, 14, 20-' Ranges are comma-separated, 1-indexed (for ease of use with 1-indexed text editors), and inclusive. A single-column field at position n may be specified as either 'n-n' or simply 'n'. A second optional argument specifies whether to write a header record with the names of each field. 'WRITE_HEADER' writes a header record; 'NO_HEADER' and the default does not write one. All datetimes are stored in UTC. Column spec idea and syntax parser borrowed from Russ Lankenau's FixedWidthLoader implementation at https://github.com/rlankenau/fixed-width-pig-loader
Constructor Summary | |
---|---|
FixedWidthStorer()
|
|
FixedWidthStorer(String columnSpec)
|
|
FixedWidthStorer(String columnSpec,
String headerStr)
|
Method Summary | |
---|---|
void |
checkSchema(ResourceSchema s)
Set the schema for data to be stored. |
org.apache.hadoop.mapreduce.OutputFormat |
getOutputFormat()
Return the OutputFormat associated with StoreFunc. |
String[] |
getPartitionKeys(String location,
org.apache.hadoop.mapreduce.Job job)
|
ResourceStatistics |
getStatistics(String location,
org.apache.hadoop.mapreduce.Job job)
|
void |
prepareToWrite(org.apache.hadoop.mapreduce.RecordWriter writer)
Initialize StoreFunc to write data. |
void |
putNext(Tuple t)
Write a tuple to the data store. |
void |
setPartitionFilter(Expression partitionFilter)
|
void |
setStoreFuncUDFContextSignature(String signature)
This method will be called by Pig both in the front end and back end to pass a unique signature to the StoreFunc which it can use to store
information in the UDFContext which it needs to store between
various method invocations in the front end and back end. |
void |
setStoreLocation(String location,
org.apache.hadoop.mapreduce.Job job)
Communicate to the storer the location where the data needs to be stored. |
void |
storeStatistics(ResourceStatistics stats,
String location,
org.apache.hadoop.mapreduce.Job job)
|
Methods inherited from class org.apache.pig.StoreFunc |
---|
cleanupOnFailure, cleanupOnFailureImpl, cleanupOnSuccess, relToAbsPathForStoreLocation, warn |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FixedWidthStorer()
public FixedWidthStorer(String columnSpec)
public FixedWidthStorer(String columnSpec, String headerStr)
Method Detail |
---|
public org.apache.hadoop.mapreduce.OutputFormat getOutputFormat() throws IOException
StoreFunc
getOutputFormat
in interface StoreFuncInterface
getOutputFormat
in class StoreFunc
OutputFormat
associated with StoreFunc
IOException
- if an exception occurs while constructing the
OutputFormatpublic void setStoreLocation(String location, org.apache.hadoop.mapreduce.Job job) throws IOException
StoreFunc
StoreFunc
here is the
return value of StoreFunc.relToAbsPathForStoreLocation(String, Path)
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.
StoreFunc.checkSchema(ResourceSchema)
will be called before any call to
StoreFunc.setStoreLocation(String, Job)
.
setStoreLocation
in interface StoreFuncInterface
setStoreLocation
in class StoreFunc
location
- Location returned by
StoreFunc.relToAbsPathForStoreLocation(String, Path)
job
- The Job
object
IOException
- if the location is not valid.public void setStoreFuncUDFContextSignature(String signature)
StoreFunc
StoreFunc
which it can use to store
information in the UDFContext
which it needs to store between
various method invocations in the front end and back end. This method
will be called before other methods in StoreFunc
. This is necessary
because in a Pig Latin script with multiple stores, the different
instances of store functions need to be able to find their (and only their)
data in the UDFContext object. The default implementation is a no-op.
setStoreFuncUDFContextSignature
in interface StoreFuncInterface
setStoreFuncUDFContextSignature
in class StoreFunc
signature
- a unique signature to identify this StoreFuncpublic void checkSchema(ResourceSchema s) throws IOException
StoreFunc
checkSchema
in interface StoreFuncInterface
checkSchema
in class StoreFunc
s
- to be checked
IOException
- if this schema is not acceptable. It should include
a detailed error message indicating what is wrong with the schema.public void prepareToWrite(org.apache.hadoop.mapreduce.RecordWriter writer) throws IOException
StoreFunc
prepareToWrite
in interface StoreFuncInterface
prepareToWrite
in class StoreFunc
writer
- RecordWriter to use.
IOException
- if an exception occurs during initializationpublic void putNext(Tuple t) throws IOException
StoreFunc
putNext
in interface StoreFuncInterface
putNext
in class StoreFunc
t
- the tuple to store.
IOException
- if an exception occurs during the writepublic ResourceStatistics getStatistics(String location, org.apache.hadoop.mapreduce.Job job) throws IOException
IOException
public void storeStatistics(ResourceStatistics stats, String location, org.apache.hadoop.mapreduce.Job job) throws IOException
IOException
public String[] getPartitionKeys(String location, org.apache.hadoop.mapreduce.Job job) throws IOException
IOException
public void setPartitionFilter(Expression partitionFilter) throws IOException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |