org.apache.hadoop.hive.ql.udf.generic
Class GenericUDFBaseNumeric

java.lang.Object
  extended by org.apache.hadoop.hive.ql.udf.generic.GenericUDF
      extended by org.apache.hadoop.hive.ql.udf.generic.GenericUDFBaseNumeric
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
GenericUDFOPDivide, GenericUDFOPMinus, GenericUDFOPMod, GenericUDFOPMultiply, GenericUDFOPPlus, GenericUDFPosMod

public abstract class GenericUDFBaseNumeric
extends GenericUDF

GenericUDF Base Class for operations.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hive.ql.udf.generic.GenericUDF
GenericUDF.DeferredJavaObject, GenericUDF.DeferredObject
 
Field Summary
protected  boolean ansiSqlArithmetic
           
protected  ByteWritable byteWritable
           
protected  boolean confLookupNeeded
           
protected  ObjectInspectorConverters.Converter converterLeft
           
protected  ObjectInspectorConverters.Converter converterRight
           
protected  HiveDecimalWritable decimalWritable
           
protected  DoubleWritable doubleWritable
           
protected  org.apache.hadoop.io.FloatWritable floatWritable
           
protected  org.apache.hadoop.io.IntWritable intWritable
           
protected  PrimitiveObjectInspector leftOI
           
protected  org.apache.hadoop.io.LongWritable longWritable
           
protected  String opDisplayName
           
protected  String opName
           
protected  PrimitiveObjectInspector resultOI
           
protected  PrimitiveObjectInspector rightOI
           
protected  ShortWritable shortWritable
           
 
Constructor Summary
GenericUDFBaseNumeric()
           
 
Method Summary
 void copyToNewInstance(Object newInstance)
          Some information may be set during initialize() which needs to be saved when the UDF is copied.
protected  PrimitiveTypeInfo deriveResultApproxTypeInfo()
          Default implementation for getting the approximate type info for the operator result.
protected  DecimalTypeInfo deriveResultDecimalTypeInfo()
          Derive the object inspector instance for the decimal result of the operator.
protected abstract  DecimalTypeInfo deriveResultDecimalTypeInfo(int prec1, int scale1, int prec2, int scale2)
           
protected  PrimitiveTypeInfo deriveResultExactTypeInfo()
          Default implementation for getting the exact type info for the operator result.
protected  ByteWritable evaluate(ByteWritable left, ByteWritable right)
           
protected  DoubleWritable evaluate(DoubleWritable left, DoubleWritable right)
           
protected  org.apache.hadoop.io.FloatWritable evaluate(org.apache.hadoop.io.FloatWritable left, org.apache.hadoop.io.FloatWritable right)
           
 Object evaluate(GenericUDF.DeferredObject[] arguments)
          Evaluate the GenericUDF with the arguments.
protected  HiveDecimalWritable evaluate(HiveDecimal left, HiveDecimal right)
           
protected  org.apache.hadoop.io.IntWritable evaluate(org.apache.hadoop.io.IntWritable left, org.apache.hadoop.io.IntWritable right)
           
protected  org.apache.hadoop.io.LongWritable evaluate(org.apache.hadoop.io.LongWritable left, org.apache.hadoop.io.LongWritable right)
           
protected  ShortWritable evaluate(ShortWritable left, ShortWritable right)
           
 String getDisplayString(String[] children)
          Get the String to be displayed in explain.
 ObjectInspector initialize(ObjectInspector[] arguments)
          Initialize this GenericUDF.
 
Methods inherited from class org.apache.hadoop.hive.ql.udf.generic.GenericUDF
close, configure, flip, getRequiredFiles, getRequiredJars, getUdfName, initializeAndFoldConstants
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

opName

protected String opName

opDisplayName

protected String opDisplayName

leftOI

protected transient PrimitiveObjectInspector leftOI

rightOI

protected transient PrimitiveObjectInspector rightOI

resultOI

protected transient PrimitiveObjectInspector resultOI

converterLeft

protected transient ObjectInspectorConverters.Converter converterLeft

converterRight

protected transient ObjectInspectorConverters.Converter converterRight

byteWritable

protected ByteWritable byteWritable

shortWritable

protected ShortWritable shortWritable

intWritable

protected org.apache.hadoop.io.IntWritable intWritable

longWritable

protected org.apache.hadoop.io.LongWritable longWritable

floatWritable

protected org.apache.hadoop.io.FloatWritable floatWritable

doubleWritable

protected DoubleWritable doubleWritable

decimalWritable

protected HiveDecimalWritable decimalWritable

confLookupNeeded

protected boolean confLookupNeeded

ansiSqlArithmetic

protected boolean ansiSqlArithmetic
Constructor Detail

GenericUDFBaseNumeric

public GenericUDFBaseNumeric()
Method Detail

initialize

public ObjectInspector initialize(ObjectInspector[] arguments)
                           throws UDFArgumentException
Description copied from class: GenericUDF
Initialize this GenericUDF. This will be called once and only once per GenericUDF instance.

Specified by:
initialize in class GenericUDF
Parameters:
arguments - The ObjectInspector for the arguments
Returns:
The ObjectInspector for the return value
Throws:
UDFArgumentException - Thrown when arguments have wrong types, wrong length, etc.

evaluate

public Object evaluate(GenericUDF.DeferredObject[] arguments)
                throws HiveException
Description copied from class: GenericUDF
Evaluate the GenericUDF with the arguments.

Specified by:
evaluate in class GenericUDF
Parameters:
arguments - The arguments as DeferedObject, use DeferedObject.get() to get the actual argument Object. The Objects can be inspected by the ObjectInspectors passed in the initialize call.
Returns:
The
Throws:
HiveException

evaluate

protected ByteWritable evaluate(ByteWritable left,
                                ByteWritable right)

evaluate

protected ShortWritable evaluate(ShortWritable left,
                                 ShortWritable right)

evaluate

protected org.apache.hadoop.io.IntWritable evaluate(org.apache.hadoop.io.IntWritable left,
                                                    org.apache.hadoop.io.IntWritable right)

evaluate

protected org.apache.hadoop.io.LongWritable evaluate(org.apache.hadoop.io.LongWritable left,
                                                     org.apache.hadoop.io.LongWritable right)

evaluate

protected org.apache.hadoop.io.FloatWritable evaluate(org.apache.hadoop.io.FloatWritable left,
                                                      org.apache.hadoop.io.FloatWritable right)

evaluate

protected DoubleWritable evaluate(DoubleWritable left,
                                  DoubleWritable right)

evaluate

protected HiveDecimalWritable evaluate(HiveDecimal left,
                                       HiveDecimal right)

deriveResultApproxTypeInfo

protected PrimitiveTypeInfo deriveResultApproxTypeInfo()
Default implementation for getting the approximate type info for the operator result. Divide operator overrides this.

Returns:

deriveResultExactTypeInfo

protected PrimitiveTypeInfo deriveResultExactTypeInfo()
Default implementation for getting the exact type info for the operator result. It worked for all but divide operator.

Returns:

deriveResultDecimalTypeInfo

protected DecimalTypeInfo deriveResultDecimalTypeInfo()
Derive the object inspector instance for the decimal result of the operator.


deriveResultDecimalTypeInfo

protected abstract DecimalTypeInfo deriveResultDecimalTypeInfo(int prec1,
                                                               int scale1,
                                                               int prec2,
                                                               int scale2)

getDisplayString

public String getDisplayString(String[] children)
Description copied from class: GenericUDF
Get the String to be displayed in explain.

Specified by:
getDisplayString in class GenericUDF

copyToNewInstance

public void copyToNewInstance(Object newInstance)
                       throws UDFArgumentException
Description copied from class: GenericUDF
Some information may be set during initialize() which needs to be saved when the UDF is copied. This will be called by FunctionRegistry.cloneGenericUDF()

Overrides:
copyToNewInstance in class GenericUDF
Throws:
UDFArgumentException


Copyright © 2014 The Apache Software Foundation. All rights reserved.