use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFAesEncrypt method testAesEnc256ConstStr.
@Test
public void testAesEnc256ConstStr() throws HiveException, NoSuchAlgorithmException {
int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES");
// Jurisdiction Policy Files not installed
if (maxKeyLen < 256) {
return;
}
GenericUDFAesEncrypt udf = new GenericUDFAesEncrypt();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
Text keyWr = new Text("1234567890123456" + "1234567890123456");
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.stringTypeInfo, keyWr);
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
runAndVerifyStr("ABC", keyWr, "nYfCuJeRd5eD60yXDw7WEA==", udf);
runAndVerifyStr("", keyWr, "mVClVqZ6W4VF6b842FOgCA==", udf);
// null
runAndVerifyStr(null, keyWr, null, udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFAesEncrypt method testAesEncKeyNullStr.
@Test
public void testAesEncKeyNullStr() throws HiveException {
GenericUDFAesEncrypt udf = new GenericUDFAesEncrypt();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
Text keyWr = null;
runAndVerifyStr("ABC", keyWr, null, udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFAesEncrypt method testAesEncKeyNullConstStr.
@Test
public void testAesEncKeyNullConstStr() throws HiveException {
GenericUDFAesEncrypt udf = new GenericUDFAesEncrypt();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
Text keyWr = null;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.stringTypeInfo, keyWr);
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
runAndVerifyStr("ABC", keyWr, null, udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFPrintf method testVarcharFormat.
@Test
public void testVarcharFormat() throws HiveException {
GenericUDFPrintf udf = new GenericUDFPrintf();
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.getVarcharTypeInfo(7)), PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.getCharTypeInfo(5)) };
HiveCharWritable argChar = new HiveCharWritable();
argChar.set("hello");
HiveVarcharWritable formatVarchar = new HiveVarcharWritable();
formatVarchar.set("arg1=%s");
DeferredObject[] args = { new DeferredJavaObject(formatVarchar), new DeferredJavaObject(argChar) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(PrimitiveObjectInspectorFactory.writableStringObjectInspector, oi);
Text res = (Text) udf.evaluate(args);
Assert.assertEquals("arg1=hello", res.toString());
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableStringObjectInspector in project hive by apache.
the class TestGenericUDFPrintf method testDecimalArgs.
@Test
public void testDecimalArgs() throws HiveException {
GenericUDFPrintf udf = new GenericUDFPrintf();
ObjectInspector[] inputOIs = { PrimitiveObjectInspectorFactory.writableStringObjectInspector, PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.getDecimalTypeInfo(5, 2)), PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(TypeInfoFactory.getDecimalTypeInfo(3, 2)) };
HiveDecimalWritable argDec1 = new HiveDecimalWritable();
argDec1.set(HiveDecimal.create("234.789"));
HiveDecimalWritable argDec2 = new HiveDecimalWritable();
argDec2.set(HiveDecimal.create("3.5"));
DeferredObject[] args = { new DeferredJavaObject(new Text("1st: %s, 2nd: %s")), new DeferredJavaObject(argDec1), new DeferredJavaObject(argDec2) };
PrimitiveObjectInspector oi = (PrimitiveObjectInspector) udf.initialize(inputOIs);
Assert.assertEquals(PrimitiveObjectInspectorFactory.writableStringObjectInspector, oi);
Text res = (Text) udf.evaluate(args);
Assert.assertEquals("1st: 234.79, 2nd: 3.5", res.toString());
}
Aggregations