public abstract class AbstractAccumuloStorage extends LoadFunc implements StoreFuncInterface
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
ASTERISK |
protected org.apache.accumulo.core.security.Authorizations |
authorizations |
protected LoadStoreCaster |
caster |
protected static char |
COLON |
protected java.util.List<Column> |
columns |
protected java.lang.String |
columnSeparator |
protected static char |
COMMA |
protected org.apache.commons.cli.CommandLine |
commandLine |
protected java.lang.String |
contextSignature |
protected java.lang.String |
end |
protected boolean |
ignoreWhitespace |
protected java.lang.String |
inst |
protected long |
maxLatency |
protected long |
maxMutationBufferSize |
protected int |
maxWriteThreads |
protected java.lang.String |
password |
protected ResourceSchema |
schema |
protected java.lang.String |
start |
protected AccumuloStorageOptions |
storageOptions |
protected java.lang.String |
table |
protected org.apache.hadoop.io.Text |
tableName |
protected java.lang.String |
user |
protected java.lang.String |
zookeepers |
| Constructor and Description |
|---|
AbstractAccumuloStorage(java.lang.String columns,
java.lang.String args) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkSchema(ResourceSchema s)
Set the schema for data to be stored.
|
void |
cleanupOnFailure(java.lang.String failure,
org.apache.hadoop.mapreduce.Job job)
This method will be called by Pig if the job which contains this store
fails.
|
void |
cleanupOnSuccess(java.lang.String location,
org.apache.hadoop.mapreduce.Job job)
This method will be called by Pig if the job which contains this store
is successful, and some cleanup of intermediate resources is required.
|
protected void |
clearUnset(org.apache.hadoop.conf.Configuration conf,
java.util.Map<java.lang.String,java.lang.String> entriesToUnset)
Replaces the given entries in the configuration by clearing the
Configuration and re-adding the elements that aren't in the Map of
entries to unset
|
protected void |
configureInputFormat(org.apache.hadoop.mapreduce.Job job)
Method to allow specific implementations to add more elements to the Job
for reading data from Accumulo.
|
protected void |
configureOutputFormat(org.apache.hadoop.mapreduce.Job job)
Method to allow specific implementations to add more elements to the Job
for writing data to Accumulo.
|
protected void |
extractArgs(org.apache.commons.cli.CommandLine cli,
AccumuloStorageOptions opts)
Extract arguments passed into the constructor to avoid the URI
|
protected org.apache.commons.cli.CommandLine |
getCommandLine() |
protected java.util.Map<java.lang.String,java.lang.String> |
getEntries(org.apache.hadoop.conf.Configuration conf,
java.lang.String prefix)
Extract elements from the Configuration whose keys match the given prefix
|
org.apache.hadoop.mapreduce.InputFormat |
getInputFormat()
This will be called during planning on the front end.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getInputFormatEntries(org.apache.hadoop.conf.Configuration conf) |
LoadCaster |
getLoadCaster()
This will be called on both the front end and the back
end during execution.
|
protected abstract java.util.Collection<org.apache.accumulo.core.data.Mutation> |
getMutations(Tuple tuple) |
Tuple |
getNext()
Retrieves the next tuple to be processed.
|
org.apache.hadoop.mapreduce.OutputFormat |
getOutputFormat()
Return the OutputFormat associated with StoreFuncInterface.
|
protected java.util.Map<java.lang.String,java.lang.String> |
getOutputFormatEntries(org.apache.hadoop.conf.Configuration conf) |
protected abstract Tuple |
getTuple(org.apache.accumulo.core.data.Key key,
org.apache.accumulo.core.data.Value value) |
protected java.util.Properties |
getUDFProperties()
Returns UDFProperties based on
contextSignature. |
protected org.apache.hadoop.mapreduce.RecordWriter<org.apache.hadoop.io.Text,org.apache.accumulo.core.data.Mutation> |
getWriter() |
protected void |
loadDependentJars(org.apache.hadoop.conf.Configuration conf)
Ensure that Accumulo's dependent jars are added to the Configuration to
alleviate the need for clients to REGISTER dependency jars.
|
protected org.apache.accumulo.core.util.Pair<org.apache.hadoop.io.Text,org.apache.hadoop.io.Text> |
makePair(java.lang.String first,
java.lang.String second) |
protected org.apache.hadoop.io.Text |
objectToText(java.lang.Object o,
ResourceSchema.ResourceFieldSchema fieldSchema) |
protected byte[] |
objToBytes(java.lang.Object o,
byte type) |
protected org.apache.hadoop.io.Text |
objToText(java.lang.Object o,
byte type) |
void |
prepareToRead(org.apache.hadoop.mapreduce.RecordReader reader,
PigSplit split)
Initializes LoadFunc for reading data.
|
void |
prepareToWrite(org.apache.hadoop.mapreduce.RecordWriter writer)
Initialize StoreFuncInterface to write data.
|
void |
putNext(Tuple tuple)
Write a tuple to the data store.
|
java.lang.String |
relativeToAbsolutePath(java.lang.String location,
org.apache.hadoop.fs.Path curDir)
This method is called by the Pig runtime in the front end to convert the
input location to an absolute path if the location is relative.
|
java.lang.String |
relToAbsPathForStoreLocation(java.lang.String location,
org.apache.hadoop.fs.Path curDir)
This method is called by the Pig runtime in the front end to convert the
output location to an absolute path if the location is relative.
|
protected byte |
schemaToType(java.lang.Object o,
int i,
ResourceSchema.ResourceFieldSchema[] fieldSchemas) |
protected byte |
schemaToType(java.lang.Object o,
ResourceSchema.ResourceFieldSchema fieldSchema) |
void |
setLocation(java.lang.String location,
org.apache.hadoop.mapreduce.Job job)
Communicate to the loader the location of the object(s) being loaded.
|
void |
setStoreFuncUDFContextSignature(java.lang.String signature)
This method will be called by Pig both in the front end and back end to
pass a unique signature to the
StoreFuncInterface 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(java.lang.String location,
org.apache.hadoop.mapreduce.Job job)
Communicate to the storer the location where the data needs to be stored.
|
void |
setUDFContextSignature(java.lang.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. |
protected void |
simpleUnset(org.apache.hadoop.conf.Configuration conf,
java.util.Map<java.lang.String,java.lang.String> entriesToUnset)
Unsets elements in the Configuration using the unset method
|
protected byte[] |
tupleToBytes(Tuple tuple,
int i,
ResourceSchema.ResourceFieldSchema[] fieldSchemas) |
protected org.apache.hadoop.io.Text |
tupleToText(Tuple tuple,
int i,
ResourceSchema.ResourceFieldSchema[] fieldSchemas) |
protected void |
unsetEntriesFromConfiguration(org.apache.hadoop.conf.Configuration conf,
java.util.Map<java.lang.String,java.lang.String> entriesToUnset)
Removes the given values from the configuration, accounting for changes
in the Configuration API given the version of Hadoop being used.
|
addCredentials, getAbsolutePath, getCacheFiles, getGlobPaths, getPathStrings, getShipFiles, join, warnclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddCredentials, supportsParallelWriteToStoreLocationprotected static final char COLON
protected static final char COMMA
protected static final java.lang.String ASTERISK
protected final AccumuloStorageOptions storageOptions
protected final org.apache.commons.cli.CommandLine commandLine
protected java.lang.String inst
protected java.lang.String zookeepers
protected java.lang.String user
protected java.lang.String password
protected java.lang.String table
protected org.apache.hadoop.io.Text tableName
protected org.apache.accumulo.core.security.Authorizations authorizations
protected java.util.List<Column> columns
protected java.lang.String start
protected java.lang.String end
protected int maxWriteThreads
protected long maxMutationBufferSize
protected long maxLatency
protected java.lang.String columnSeparator
protected boolean ignoreWhitespace
protected LoadStoreCaster caster
protected ResourceSchema schema
protected java.lang.String contextSignature
public AbstractAccumuloStorage(java.lang.String columns,
java.lang.String args)
throws org.apache.commons.cli.ParseException,
java.io.IOException
org.apache.commons.cli.ParseExceptionjava.io.IOExceptionprotected void extractArgs(org.apache.commons.cli.CommandLine cli,
AccumuloStorageOptions opts)
throws java.io.IOException
cli - opts - java.io.IOExceptionprotected org.apache.commons.cli.CommandLine getCommandLine()
protected java.util.Map<java.lang.String,java.lang.String> getInputFormatEntries(org.apache.hadoop.conf.Configuration conf)
protected java.util.Map<java.lang.String,java.lang.String> getOutputFormatEntries(org.apache.hadoop.conf.Configuration conf)
protected void unsetEntriesFromConfiguration(org.apache.hadoop.conf.Configuration conf,
java.util.Map<java.lang.String,java.lang.String> entriesToUnset)
conf - entriesToUnset - protected void simpleUnset(org.apache.hadoop.conf.Configuration conf,
java.util.Map<java.lang.String,java.lang.String> entriesToUnset)
conf - entriesToUnset - protected void clearUnset(org.apache.hadoop.conf.Configuration conf,
java.util.Map<java.lang.String,java.lang.String> entriesToUnset)
conf - entriesToUnset - public Tuple getNext() throws java.io.IOException
LoadFuncprotected abstract Tuple getTuple(org.apache.accumulo.core.data.Key key, org.apache.accumulo.core.data.Value value) throws java.io.IOException
java.io.IOExceptionpublic org.apache.hadoop.mapreduce.InputFormat getInputFormat()
LoadFuncgetInputFormat in class LoadFuncpublic void prepareToRead(org.apache.hadoop.mapreduce.RecordReader reader,
PigSplit split)
LoadFuncprepareToRead in class LoadFuncreader - RecordReader to be used by this instance of the LoadFuncsplit - The input PigSplit to processprotected org.apache.hadoop.mapreduce.RecordWriter<org.apache.hadoop.io.Text,org.apache.accumulo.core.data.Mutation> getWriter()
protected java.util.Map<java.lang.String,java.lang.String> getEntries(org.apache.hadoop.conf.Configuration conf,
java.lang.String prefix)
conf - prefix - public void setLocation(java.lang.String location,
org.apache.hadoop.mapreduce.Job job)
throws java.io.IOException
LoadFuncLoadFunc.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 LoadFunclocation - Location as returned by
LoadFunc.relativeToAbsolutePath(String, Path)job - the Job object
store or retrieve earlier stored information from the UDFContextjava.io.IOException - if the location is not valid.protected org.apache.accumulo.core.util.Pair<org.apache.hadoop.io.Text,org.apache.hadoop.io.Text> makePair(java.lang.String first,
java.lang.String second)
protected void loadDependentJars(org.apache.hadoop.conf.Configuration conf)
throws java.io.IOException
job - The Mapreduce Job objectjava.io.IOExceptionprotected void configureInputFormat(org.apache.hadoop.mapreduce.Job job)
job - protected void configureOutputFormat(org.apache.hadoop.mapreduce.Job job)
job - public java.lang.String relativeToAbsolutePath(java.lang.String location,
org.apache.hadoop.fs.Path curDir)
throws java.io.IOException
LoadFuncrelativeToAbsolutePath in class LoadFunclocation - location as provided in the "load" statement of the scriptcurDir - the current working direction based on any "cd" statements
in the script before the "load" statement. If there are no "cd" statements
in the script, this would be the home directory -
/user/
java.io.IOException - if the conversion is not possiblepublic void setUDFContextSignature(java.lang.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 void setStoreFuncUDFContextSignature(java.lang.String signature)
StoreFuncInterfaceStoreFuncInterface 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 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.setStoreFuncUDFContextSignature in interface StoreFuncInterfacesignature - a unique signature to identify this StoreFuncInterfaceprotected java.util.Properties getUDFProperties()
contextSignature.public java.lang.String relToAbsPathForStoreLocation(java.lang.String location,
org.apache.hadoop.fs.Path curDir)
throws java.io.IOException
StoreFuncInterfaceLoadFunc.getAbsolutePath(java.lang.String, org.apache.hadoop.fs.Path) provides a default
implementation for hdfs and hadoop local file system and it can be used
to implement this method.relToAbsPathForStoreLocation in interface StoreFuncInterfacelocation - location as provided in the "store" statement of the scriptcurDir - the current working direction based on any "cd" statements
in the script before the "store" statement. If there are no "cd" statements
in the script, this would be the home directory -
/user/
java.io.IOException - if the conversion is not possiblepublic void setStoreLocation(java.lang.String location,
org.apache.hadoop.mapreduce.Job job)
throws java.io.IOException
StoreFuncInterfaceStoreFuncInterface here is the
return value of StoreFuncInterface.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.
StoreFuncInterface.checkSchema(ResourceSchema) will be called before any call to
StoreFuncInterface.setStoreLocation(String, Job).setStoreLocation in interface StoreFuncInterfacelocation - Location returned by
StoreFuncInterface.relToAbsPathForStoreLocation(String, Path)job - The Job objectjava.io.IOException - if the location is not valid.public org.apache.hadoop.mapreduce.OutputFormat getOutputFormat()
StoreFuncInterfacegetOutputFormat in interface StoreFuncInterfaceOutputFormat associated with StoreFuncInterfacepublic void prepareToWrite(org.apache.hadoop.mapreduce.RecordWriter writer)
StoreFuncInterfaceprepareToWrite in interface StoreFuncInterfacewriter - RecordWriter to use.protected abstract java.util.Collection<org.apache.accumulo.core.data.Mutation> getMutations(Tuple tuple) throws ExecException, java.io.IOException
ExecExceptionjava.io.IOExceptionpublic void putNext(Tuple tuple) throws ExecException, java.io.IOException
StoreFuncInterfaceputNext in interface StoreFuncInterfacetuple - the tuple to store.java.io.IOException - if an exception occurs during the writeExecExceptionpublic void cleanupOnFailure(java.lang.String failure,
org.apache.hadoop.mapreduce.Job job)
StoreFuncInterfacecleanupOnFailure in interface StoreFuncInterfacefailure - Location returned by
StoreFuncInterface.relToAbsPathForStoreLocation(String, 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.public void cleanupOnSuccess(java.lang.String location,
org.apache.hadoop.mapreduce.Job job)
StoreFuncInterfacecleanupOnSuccess in interface StoreFuncInterfacelocation - Location returned by
StoreFuncInterface.relToAbsPathForStoreLocation(String, 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.public void checkSchema(ResourceSchema s) throws java.io.IOException
StoreFuncInterfacecheckSchema in interface StoreFuncInterfaces - to be checkedjava.io.IOException - if this schema is not acceptable. It should include
a detailed error message indicating what is wrong with the schema.protected org.apache.hadoop.io.Text tupleToText(Tuple tuple, int i, ResourceSchema.ResourceFieldSchema[] fieldSchemas) throws java.io.IOException
java.io.IOExceptionprotected org.apache.hadoop.io.Text objectToText(java.lang.Object o,
ResourceSchema.ResourceFieldSchema fieldSchema)
throws java.io.IOException
java.io.IOExceptionprotected byte schemaToType(java.lang.Object o,
ResourceSchema.ResourceFieldSchema fieldSchema)
protected byte schemaToType(java.lang.Object o,
int i,
ResourceSchema.ResourceFieldSchema[] fieldSchemas)
protected byte[] tupleToBytes(Tuple tuple, int i, ResourceSchema.ResourceFieldSchema[] fieldSchemas) throws java.io.IOException
java.io.IOExceptionprotected org.apache.hadoop.io.Text objToText(java.lang.Object o,
byte type)
throws java.io.IOException
java.io.IOExceptionprotected byte[] objToBytes(java.lang.Object o,
byte type)
throws java.io.IOException
java.io.IOExceptionpublic LoadCaster getLoadCaster() throws java.io.IOException
LoadFuncgetLoadCaster in class LoadFuncLoadCaster associated with this loader. Returning null
indicates that casts from byte array are not supported for this loader.
constructionjava.io.IOException - if there is an exception during LoadCasterCopyright © 2007-2025 The Apache Software Foundation