public class Utils extends Object
Modifier and Type | Field and Description |
---|---|
static org.apache.hadoop.fs.PathFilter |
VISIBLE_FILES
A PathFilter that filters out invisible files.
|
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static FuncSpec |
buildSimpleFuncSpec(String className,
byte... types) |
static boolean |
checkNullAndClass(Object obj1,
Object obj2)
This method is a helper for classes to implement
Object.equals(java.lang.Object)
The method checks whether the two arguments are both null or both not null and
whether they are of the same class |
static boolean |
checkNullEquals(Object obj1,
Object obj2,
boolean checkEquality)
This method is a helper for classes to implement
Object.equals(java.lang.Object)
checks if two objects are equals - two levels of checks are
made - first if both are null or not null. |
static org.apache.hadoop.fs.Path |
depthFirstSearchForFile(org.apache.hadoop.fs.FileStatus[] statusArray,
org.apache.hadoop.fs.FileSystem fileSystem)
Finds a valid path for a file from a FileStatus object.
|
static org.apache.hadoop.fs.Path |
depthFirstSearchForFile(org.apache.hadoop.fs.FileStatus[] statusArray,
org.apache.hadoop.fs.FileSystem fileSystem,
org.apache.hadoop.fs.PathFilter filter)
Finds a valid path for a file from an array of FileStatus objects.
|
static int |
extractHeapSizeInMB(String input) |
static InputStream |
getCompositeStream(InputStream in,
Properties properties) |
static ResourceSchema |
getSchema(LoadFunc wrappedLoadFunc,
String location,
boolean checkExistence,
org.apache.hadoop.mapreduce.Job job) |
static Schema |
getSchemaFromBagSchemaString(String schemaString)
getSchemaFromBagSchemaString
NOTE: use this call when you need to generate a Schema object
from the representation generated by
Schema#toString . |
static Schema |
getSchemaFromString(String schemaString) |
static ResourceSchema |
getSchemaWithInputSourceTag(ResourceSchema schema,
String fieldName)
This method adds FieldSchema of 'input source tag/path' as the first
field.
|
static Schema |
getScriptSchema(String loadFuncSignature,
org.apache.hadoop.conf.Configuration conf)
A helper function for retrieving the script schema set by the LOLoad
function.
|
static String |
getScriptSchemaKey(String loadFuncSignature) |
static String |
getStackStraceStr(Throwable e) |
static String |
getStringFromArray(String[] arr) |
static String |
getTmpFileCompressorName(PigContext pigContext) |
static Class<? extends FileInputLoadFunc> |
getTmpFileStorageClass(Properties properties) |
static FileInputLoadFunc |
getTmpFileStorageObject(org.apache.hadoop.conf.Configuration conf) |
static boolean |
is64bitJVM() |
static boolean |
isHadoop2() |
static boolean |
isHadoop23() |
static boolean |
isLocal(org.apache.hadoop.conf.Configuration conf) |
static boolean |
isLocal(PigContext pigContext,
org.apache.hadoop.conf.Configuration conf) |
static boolean |
isVendorIBM()
This method checks whether JVM vendor is IBM
|
static <O> Collection<O> |
mergeCollection(Collection<O> a,
Collection<O> b) |
static Object |
parseConstant(String constantString) |
static LogicalSchema |
parseSchema(String schemaString) |
static void |
recomputeProperties(org.apache.hadoop.mapred.JobConf jobConf,
Properties properties)
Method to apply pig properties to JobConf (replaces properties with
resulting jobConf values).
|
static void |
setDefaultTimeZone(org.apache.hadoop.conf.Configuration conf) |
static void |
setMapredCompressionCodecProps(org.apache.hadoop.conf.Configuration conf) |
static void |
setTmpFileCompressionOnConf(PigContext pigContext,
org.apache.hadoop.conf.Configuration conf) |
static String |
slashisize(String str)
Replace sequences of two slashes ("\\") with one slash ("\")
(not escaping a slash in grunt is disallowed, but a double slash doesn't get converted
into a regular slash, so we have to do it instead)
|
static String |
substituteVars(String expr) |
public static final org.apache.hadoop.fs.PathFilter VISIBLE_FILES
public static boolean isVendorIBM()
public static boolean isHadoop23()
public static boolean isHadoop2()
public static boolean is64bitJVM()
public static boolean checkNullEquals(Object obj1, Object obj2, boolean checkEquality)
Object.equals(java.lang.Object)
checks if two objects are equals - two levels of checks are
made - first if both are null or not null. If either is null,
check is made whether both are null.
If both are non null, equality also is checked if so indicatedobj1
- first object to be comparedobj2
- second object to be comparedcheckEquality
- flag to indicate whether object equality should
be checked if obj1 and obj2 are non-nullpublic static boolean checkNullAndClass(Object obj1, Object obj2)
Object.equals(java.lang.Object)
The method checks whether the two arguments are both null or both not null and
whether they are of the same classobj1
- first object to compareobj2
- second object to comparepublic static Schema getScriptSchema(String loadFuncSignature, org.apache.hadoop.conf.Configuration conf) throws IOException
loadFuncSignature
- conf
- IOException
public static ResourceSchema getSchema(LoadFunc wrappedLoadFunc, String location, boolean checkExistence, org.apache.hadoop.mapreduce.Job job) throws IOException
IOException
public static Schema getSchemaFromString(String schemaString) throws ParserException
schemaString
- a String representation of the Schema without
any enclosing curly-braces.Not for use with
Schema#toString
ParserException
public static Schema getSchemaFromBagSchemaString(String schemaString) throws ParserException
Schema#toString
.
This call strips the enclosing outer curly braces from the toString
representation, which are placed there because the actual representation of
the schema data is as a Bag-type relation.schemaString
- a String representation of the Schema to instantiate,
in the form generated by Schema.toString()
ParserException
public static LogicalSchema parseSchema(String schemaString) throws ParserException
ParserException
public static Object parseConstant(String constantString) throws ParserException
ParserException
public static ResourceSchema getSchemaWithInputSourceTag(ResourceSchema schema, String fieldName)
schema
- fieldName
- public static String getTmpFileCompressorName(PigContext pigContext)
public static FileInputLoadFunc getTmpFileStorageObject(org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
public static Class<? extends FileInputLoadFunc> getTmpFileStorageClass(Properties properties)
public static void setMapredCompressionCodecProps(org.apache.hadoop.conf.Configuration conf)
public static void setTmpFileCompressionOnConf(PigContext pigContext, org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
public static String slashisize(String str)
str
- public static <O> Collection<O> mergeCollection(Collection<O> a, Collection<O> b)
public static InputStream getCompositeStream(InputStream in, Properties properties)
public static void recomputeProperties(org.apache.hadoop.mapred.JobConf jobConf, Properties properties)
conf
- JobConf with appropriate hadoop resource filesproperties
- Pig properties that will override hadoop properties;
properties might be modifiedpublic static boolean isLocal(PigContext pigContext, org.apache.hadoop.conf.Configuration conf)
public static boolean isLocal(org.apache.hadoop.conf.Configuration conf)
public static org.apache.hadoop.fs.Path depthFirstSearchForFile(org.apache.hadoop.fs.FileStatus[] statusArray, org.apache.hadoop.fs.FileSystem fileSystem) throws IOException
fileStatus
- FileStatus object corresponding to a file,
or a directory.fileSystem
- FileSystem in with the file should be foundIOException
public static org.apache.hadoop.fs.Path depthFirstSearchForFile(org.apache.hadoop.fs.FileStatus[] statusArray, org.apache.hadoop.fs.FileSystem fileSystem, org.apache.hadoop.fs.PathFilter filter) throws IOException
statusArray
- Array of FileStatus objects in which to search
for the file.fileSystem
- FileSystem in which to search for the first file.IOException
public static int extractHeapSizeInMB(String input)
public static void setDefaultTimeZone(org.apache.hadoop.conf.Configuration conf)
Copyright © 2007-2012 The Apache Software Foundation