package com.neulion.hive.udf;

import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;

public class UDFDetermineAppType extends GenericUDF {

    @Override
    public Object evaluate(DeferredObject[] arg0) throws HiveException {
        return null;
    }

    @Override
    public String getDisplayString(String[] arg0) {
        return null;
    }

    @Override
    public ObjectInspector initialize(ObjectInspector[] arg0) throws UDFArgumentException {
        return null;
    }
    
}

@@ -62,27 +62,144 @@
 ql.exec.
-UDFArgument
+Description;%0Aimport org.apache.hadoop.hive.ql.exec.UDFArgumentException;%0Aimport org.apache.hadoop.hive.ql.exec.UDFArgumentLength
 Exceptio
@@ -389,171 +389,1086 @@
 or;%0A
-%0Apublic class UDFDetermineAppType extends GenericUDF %7B%0A%0A    @Override%0A    public Object evaluate(DeferredObject%5B%5D arg0) throws HiveException %7B%0A        return null;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.JavaStringObjectInspector;%0Aimport org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;%0A%0A@Description(value=%22__FUNC__ get appType from deviceType and appType. %22%0A        + %22Some message miss appType field, we need to determine the appType from deviceType%22, %0A        name=%22determineAppType%22)%0Apublic class UDFDetermineAppType extends GenericUDF %7B%0A%0A    private JavaStringObjectInspector stringInspector;%0A    %0A    @Override%0A    public Object evaluate(DeferredObject%5B%5D arg0) throws HiveException %7B%0A        if (arg0.length != 2) %7B%0A            throw new UDFArgumentLengthException(%22Determine App Type take two arguments, %22%0A                    + %22first is the deviceType, second is the appType%22);%0A        %7D%0A        String deviceType = stringInspector.getPrimitiveJavaObject(arg0%5B0%5D.get());%0A        String appType = stringInspector.getPrimitiveJavaObject(arg0%5B1%5D.get());%0A        if (%22%22.equals(appType)) %7B%0A            return deviceType;%0A        %7D else %7B%0A            return appType;%0A        %7D
 %0A   
@@ -1544,36 +1544,52 @@
 %0A        return 
-null
+%22Determine App Type%22
 ;%0A    %7D%0A%0A    @Ov
@@ -1699,19 +1699,162 @@
     
-return null
+this.stringInspector = PrimitiveObjectInspectorFactory.javaStringObjectInspector;%0A        return PrimitiveObjectInspectorFactory.javaStringObjectInspector
 ;%0A  
@@ -1863,9 +1863,8 @@
 %7D%0A    %0A%7D
-%0A

add determine app type