org.apache.pig.impl.util
Class Utils

java.lang.Object
  extended by org.apache.pig.impl.util.Utils

public class Utils
extends Object

Class with utility static methods


Constructor Summary
Utils()
           
 
Method Summary
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 ResourceSchema getSchema(LoadFunc wrappedLoadFunc, String location, boolean checkExistence, org.apache.hadoop.mapreduce.Job job)
           
static Schema getSchemaFromString(String schemaString)
           
static ResourceSchema getSchemaWithInputSourceTag(ResourceSchema schema)
          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 getStringFromArray(String[] arr)
           
static String getTmpFileCompressorName(PigContext pigContext)
           
static FileInputLoadFunc getTmpFileStorageObject(org.apache.hadoop.conf.Configuration conf)
           
static
<O> Collection<O>
mergeCollection(Collection<O> a, Collection<O> b)
           
static LogicalSchema parseSchema(String schemaString)
           
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 boolean tmpFileCompression(PigContext pigContext)
           
static String tmpFileCompressionCodec(PigContext pigContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

checkNullEquals

public 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. If either is null, check is made whether both are null. If both are non null, equality also is checked if so indicated

Parameters:
obj1 - first object to be compared
obj2 - second object to be compared
checkEquality - flag to indicate whether object equality should be checked if obj1 and obj2 are non-null
Returns:
true if the two objects are equal false otherwise

checkNullAndClass

public 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

Parameters:
obj1 - first object to compare
obj2 - second object to compare
Returns:
true if both objects are null or both are not null and if both are of the same class if not null false otherwise

getScriptSchema

public static Schema getScriptSchema(String loadFuncSignature,
                                     org.apache.hadoop.conf.Configuration conf)
                              throws IOException
A helper function for retrieving the script schema set by the LOLoad function.

Parameters:
loadFuncSignature -
conf -
Returns:
Schema
Throws:
IOException

getSchema

public static ResourceSchema getSchema(LoadFunc wrappedLoadFunc,
                                       String location,
                                       boolean checkExistence,
                                       org.apache.hadoop.mapreduce.Job job)
                                throws IOException
Throws:
IOException

getSchemaFromString

public static Schema getSchemaFromString(String schemaString)
                                  throws ParserException
Parameters:
schemaString -
Returns:
Schema instance
Throws:
ParserException

parseSchema

public static LogicalSchema parseSchema(String schemaString)
                                 throws ParserException
Throws:
ParserException

getSchemaWithInputSourceTag

public static ResourceSchema getSchemaWithInputSourceTag(ResourceSchema schema)
This method adds FieldSchema of 'input source tag/path' as the first field. This will be called only when PigStorage is invoked with '-tagsource' option and the schema file is present to be loaded.

Parameters:
schema -
Returns:
ResourceSchema

getTmpFileCompressorName

public static String getTmpFileCompressorName(PigContext pigContext)

getTmpFileStorageObject

public static FileInputLoadFunc getTmpFileStorageObject(org.apache.hadoop.conf.Configuration conf)
                                                 throws IOException
Throws:
IOException

tmpFileCompression

public static boolean tmpFileCompression(PigContext pigContext)

tmpFileCompressionCodec

public static String tmpFileCompressionCodec(PigContext pigContext)
                                      throws IOException
Throws:
IOException

getStringFromArray

public static String getStringFromArray(String[] arr)

buildSimpleFuncSpec

public static FuncSpec buildSimpleFuncSpec(String className,
                                           byte... types)

slashisize

public 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)

Parameters:
str -
Returns:
the resulting string

mergeCollection

public static <O> Collection<O> mergeCollection(Collection<O> a,
                                                Collection<O> b)


Copyright © 2007-2012 The Apache Software Foundation