use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableBinaryObjectInspector in project hive by apache.
the class GenericUDFParamUtils method obtainBinaryConverter.
public static void obtainBinaryConverter(ObjectInspector[] arguments, int i, PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
PrimitiveCategory inputType = inOi.getPrimitiveCategory();
Converter converter = ObjectInspectorConverters.getConverter(arguments[i], PrimitiveObjectInspectorFactory.writableBinaryObjectInspector);
converters[i] = converter;
inputTypes[i] = inputType;
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableBinaryObjectInspector in project hive by apache.
the class GenericUDFLength method initialize.
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments.length != 1) {
throw new UDFArgumentLengthException("LENGTH requires 1 argument, got " + arguments.length);
}
if (arguments[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
throw new UDFArgumentException("LENGTH only takes primitive types, got " + argumentOI.getTypeName());
}
argumentOI = (PrimitiveObjectInspector) arguments[0];
PrimitiveObjectInspector.PrimitiveCategory inputType = argumentOI.getPrimitiveCategory();
ObjectInspector outputOI = null;
switch(inputType) {
case CHAR:
case VARCHAR:
case STRING:
isInputString = true;
stringConverter = new PrimitiveObjectInspectorConverter.StringConverter(argumentOI);
break;
case BINARY:
isInputString = false;
binaryConverter = new PrimitiveObjectInspectorConverter.BinaryConverter(argumentOI, PrimitiveObjectInspectorFactory.writableBinaryObjectInspector);
break;
default:
throw new UDFArgumentException(" LENGTH() only takes STRING/CHAR/VARCHAR/BINARY types as first argument, got " + inputType);
}
outputOI = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
return outputOI;
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableBinaryObjectInspector in project hive by apache.
the class TestGenericUDFAesDecrypt method testAesDecKeyNullBin.
@Test
public void testAesDecKeyNullBin() throws HiveException {
GenericUDFAesDecrypt udf = new GenericUDFAesDecrypt();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
BytesWritable keyWr = null;
runAndVerifyBin("y6Ss+zCYObpCbgfWfyNWTw==", keyWr, null, udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableBinaryObjectInspector in project hive by apache.
the class TestGenericUDFAesDecrypt method testAesDec128ConstBin.
@Test
public void testAesDec128ConstBin() throws HiveException {
GenericUDFAesDecrypt udf = new GenericUDFAesDecrypt();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
BytesWritable keyWr = new BytesWritable("1234567890123456".getBytes());
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.binaryTypeInfo, keyWr);
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
runAndVerifyBin("y6Ss+zCYObpCbgfWfyNWTw==", keyWr, "ABC", udf);
runAndVerifyBin("BQGHoM3lqYcsurCRq3PlUw==", keyWr, "", udf);
// null
runAndVerifyBin(null, keyWr, null, udf);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableBinaryObjectInspector in project hive by apache.
the class TestGenericUDFAesDecrypt method testAesDec128ConstStr.
@Test
public void testAesDec128ConstStr() throws HiveException {
GenericUDFAesDecrypt udf = new GenericUDFAesDecrypt();
ObjectInspector valueOI0 = PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
Text keyWr = new Text("1234567890123456");
ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector(TypeInfoFactory.stringTypeInfo, keyWr);
ObjectInspector[] arguments = { valueOI0, valueOI1 };
udf.initialize(arguments);
runAndVerifyStr("y6Ss+zCYObpCbgfWfyNWTw==", keyWr, "ABC", udf);
runAndVerifyStr("BQGHoM3lqYcsurCRq3PlUw==", keyWr, "", udf);
// null
runAndVerifyStr(null, keyWr, null, udf);
}
Aggregations