brickhouse.udf.dcache
Class DistributedMapUDF

java.lang.Object
  extended by org.apache.hadoop.hive.ql.udf.generic.GenericUDF
      extended by brickhouse.udf.dcache.DistributedMapUDF

public class DistributedMapUDF
extends org.apache.hadoop.hive.ql.udf.generic.GenericUDF

UDF to access a distributed map file Assumes the file is a tab-separated file of name-value pairs, which has been placed in distributed cache using the "add file" command Example INSERT OVERWRITE LOCAL DIRECTORY mymap select key,value from my_map_table; ADD FILE mymap; select key, val* distributed_map( key, 'mymap') from the_table; If one argument is passed in, it is assumed to be a filename, containing a map of type map, and the entire map is returned. If two arguments are passed in, it is either filename, and a string specifying the type of the map ( i.e distributed_map('mymap','map'); ) and returns the entire map, or it is the key and the filename ( ie distributed_map( key, 'mymap'), and only the key's value is returned. If there are three arguments passed in, it is assumed to be the key, the filename, and the maptype, (i.e distributed_map( key, 'mymap', 'map') )


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hive.ql.udf.generic.GenericUDF
org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject, org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject
 
Constructor Summary
DistributedMapUDF()
           
 
Method Summary
 Object evaluate(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject[] arg0)
           
 String getDisplayString(String[] arg0)
           
 org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector initialize(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector[] arg0)
          Either one, two or three values can be passed in.
 String usage(String err)
           
 
Methods inherited from class org.apache.hadoop.hive.ql.udf.generic.GenericUDF
getRequiredFiles, getRequiredJars, initializeAndFoldConstants
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DistributedMapUDF

public DistributedMapUDF()
Method Detail

evaluate

public Object evaluate(org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject[] arg0)
                throws org.apache.hadoop.hive.ql.metadata.HiveException
Specified by:
evaluate in class org.apache.hadoop.hive.ql.udf.generic.GenericUDF
Throws:
org.apache.hadoop.hive.ql.metadata.HiveException

getDisplayString

public String getDisplayString(String[] arg0)
Specified by:
getDisplayString in class org.apache.hadoop.hive.ql.udf.generic.GenericUDF

usage

public String usage(String err)

initialize

public org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector initialize(org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector[] arg0)
                                                                         throws org.apache.hadoop.hive.ql.exec.UDFArgumentException
Either one, two or three values can be passed in. If one argument is passed it, it is implied that the return value is a map. If three arguments are passed in, then it is implied the arguments are the map key, the map filename, and the value type. If two arguments are passed in, it is implied that either) a map key, and a filename are being passed in, or a filename, and a map return type are being passed in.

Specified by:
initialize in class org.apache.hadoop.hive.ql.udf.generic.GenericUDF
Throws:
org.apache.hadoop.hive.ql.exec.UDFArgumentException


Copyright © 2013. All rights reserved.