Package org.apache.hadoop.hive.ql.udf.generic.GenericUDF

Examples of org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject


    ObjectInspector valueOI = PrimitiveObjectInspectorFactory.javaByteArrayObjectInspector;
    ObjectInspector charsetOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector;
    ObjectInspector[] initArguments = {valueOI, charsetOI};
    udf.initialize(initArguments);

    DeferredObject valueObj = new DeferredJavaObject(bytes);
    DeferredObject charsetObj = new DeferredJavaObject(charsetName);
    DeferredObject[] arguments = {valueObj, charsetObj};
    String output = (String) udf.evaluate(arguments);

    assertEquals("Decoding failed for CharSet: " + charsetName, string, output);
  }
View Full Code Here


    ObjectInspector valueOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector;
    ObjectInspector charsetOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector;
    ObjectInspector[] initArguments = {valueOI, charsetOI};
    udf.initialize(initArguments);

    DeferredObject valueObj = new DeferredJavaObject(string);
    DeferredObject charsetObj = new DeferredJavaObject(charsetName);
    DeferredObject[] arguments = {valueObj, charsetObj};
    BytesWritable outputWritable = (BytesWritable) udf.evaluate(arguments);

    byte[] output = outputWritable.getBytes();
    assertTrue("Encoding failed for CharSet: " + charsetName, expected.length == outputWritable.getLength());
View Full Code Here

        PrimitiveObjectInspectorFactory.
          getPrimitiveWritableConstantObjectInspector(
            PrimitiveObjectInspector.PrimitiveCategory.INT, y),
    };
    arguments = new DeferredObject[] {
        new DeferredJavaObject(x),
        new DeferredJavaObject(y)
    };
  }
View Full Code Here

    {
        checkArgument(objectInspector.getCategory() == Category.PRIMITIVE, "Unsupported object inspector category %s", objectInspector.getCategory());
        PrimitiveObjectInspector poi = ((PrimitiveObjectInspector) objectInspector);
        switch (poi.getPrimitiveCategory()) {
            case BOOLEAN:
                return new DeferredJavaObject(object);
            case BYTE:
                return new DeferredJavaObject(((Long) object).byteValue());
            case SHORT:
                return new DeferredJavaObject(((Long) object).shortValue());
            case INT:
                return new DeferredJavaObject(((Long) object).intValue());
            case LONG:
                return new DeferredJavaObject(object);
            case STRING:
                return new DeferredJavaObject(object);
        }
        throw new RuntimeException("Unsupported type: " + poi.getPrimitiveCategory());
    }
View Full Code Here

    {
        checkArgument(objectInspector.getCategory() == Category.PRIMITIVE, "Unsupported object inspector category %s", objectInspector.getCategory());
        PrimitiveObjectInspector poi = ((PrimitiveObjectInspector) objectInspector);
        switch (poi.getPrimitiveCategory()) {
            case BOOLEAN:
                return new DeferredJavaObject(object);
            case BYTE:
                return new DeferredJavaObject(((Long) object).byteValue());
            case SHORT:
                return new DeferredJavaObject(((Long) object).shortValue());
            case INT:
                return new DeferredJavaObject(((Long) object).intValue());
            case LONG:
                return new DeferredJavaObject(object);
            case STRING:
                return new DeferredJavaObject(object);
        }
        throw new RuntimeException("Unsupported type: " + poi.getPrimitiveCategory());
    }
View Full Code Here

    {
        checkArgument(objectInspector.getCategory() == Category.PRIMITIVE, "Unsupported object inspector category %s", objectInspector.getCategory());
        PrimitiveObjectInspector poi = ((PrimitiveObjectInspector) objectInspector);
        switch (poi.getPrimitiveCategory()) {
            case BOOLEAN:
                return new DeferredJavaObject(object);
            case BYTE:
                return new DeferredJavaObject(((Long) object).byteValue());
            case SHORT:
                return new DeferredJavaObject(((Long) object).shortValue());
            case INT:
                return new DeferredJavaObject(((Long) object).intValue());
            case LONG:
                return new DeferredJavaObject(object);
            case STRING:
                return new DeferredJavaObject(((Slice) object).toStringUtf8());
        }
        throw new RuntimeException("Unsupported type: " + poi.getPrimitiveCategory());
    }
View Full Code Here

    runAndVerify("   ", "", udf);
  }

  private void runAndVerify(String str, String expResult, GenericUDF udf) throws HiveException {

    DeferredObject valueObj = new DeferredJavaObject(new Text(str));
    DeferredObject[] args = { valueObj };
    Text output = (Text) udf.evaluate(args);
    assertEquals("trim() test ", expResult, output.toString());
  }
View Full Code Here

        PrimitiveObjectInspectorFactory.
          getPrimitiveWritableConstantObjectInspector(
              TypeInfoFactory.intTypeInfo, y),
    };
    arguments = new DeferredObject[] {
        new DeferredJavaObject(x),
        new DeferredJavaObject(y)
    };
  }
View Full Code Here

public class TestGenericUDFToUnixTimestamp extends TestCase {

  public static void runAndVerify(GenericUDFToUnixTimeStamp udf,
      Object arg, Object expected) throws HiveException {
    DeferredObject[] args = { new DeferredJavaObject(arg) };
    Object result = udf.evaluate(args);
    if (expected == null) {
      assertNull(result);
    } else {
      assertEquals(expected.toString(), result.toString());
View Full Code Here

    }
  }

  public static void runAndVerify(GenericUDFToUnixTimeStamp udf,
      Object arg1, Object arg2, Object expected) throws HiveException {
    DeferredObject[] args = { new DeferredJavaObject(arg1), new DeferredJavaObject(arg2) };
    Object result = udf.evaluate(args);
    if (expected == null) {
      assertNull(result);
    } else {
      assertEquals(expected.toString(), result.toString());
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.