use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.javaByteArrayObjectInspector in project hive by apache.
the class GenericUDTFGetSplits method initialize.
@Override
public StructObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
LOG.debug("initializing GenericUDFGetSplits");
validateInput(arguments);
List<String> names = Arrays.asList("split");
List<ObjectInspector> fieldOIs = Arrays.<ObjectInspector>asList(PrimitiveObjectInspectorFactory.javaByteArrayObjectInspector);
StructObjectInspector outputOI = ObjectInspectorFactory.getStandardStructObjectInspector(names, fieldOIs);
LOG.debug("done initializing GenericUDFGetSplits");
return outputOI;
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.javaByteArrayObjectInspector in project hive by apache.
the class GenericUDTFGetSQLSchema method initialize.
@Override
public StructObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
LOG.debug("initializing GenericUDTFGetSQLSchema");
if (SessionState.get() == null || SessionState.get().getConf() == null) {
throw new IllegalStateException("Cannot run GET_SQL_SCHEMA outside HS2");
}
LOG.debug("Initialized conf, jc and metastore connection");
if (arguments.length != 1) {
throw new UDFArgumentLengthException("The function GET_SQL_SCHEMA accepts 1 argument.");
} else if (!(arguments[0] instanceof StringObjectInspector)) {
LOG.error("Got " + arguments[0].getTypeName() + " instead of string.");
throw new UDFArgumentTypeException(0, "\"" + "string\" is expected at function GET_SQL_SCHEMA, " + "but \"" + arguments[0].getTypeName() + "\" is found");
}
stringOI = (StringObjectInspector) arguments[0];
List<String> names = Arrays.asList("col_name", "col_type");
List<ObjectInspector> fieldOIs = Arrays.asList(PrimitiveObjectInspectorFactory.javaByteArrayObjectInspector, PrimitiveObjectInspectorFactory.javaByteArrayObjectInspector);
StructObjectInspector outputOI = ObjectInspectorFactory.getStandardStructObjectInspector(names, fieldOIs);
LOG.debug("done initializing GenericUDTFGetSQLSchema");
return outputOI;
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.javaByteArrayObjectInspector in project hive by apache.
the class GenericUDTFGetSplits2 method initialize.
@Override
public StructObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
LOG.debug("initializing GenericUDFGetSplits2");
validateInput(arguments);
List<String> names = Arrays.asList("type", "split");
List<ObjectInspector> fieldOIs = Arrays.asList(PrimitiveObjectInspectorFactory.javaStringObjectInspector, PrimitiveObjectInspectorFactory.javaByteArrayObjectInspector);
StructObjectInspector outputOI = ObjectInspectorFactory.getStandardStructObjectInspector(names, fieldOIs);
LOG.debug("done initializing GenericUDFGetSplits2");
return outputOI;
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.javaByteArrayObjectInspector in project hive by apache.
the class TestGenericUDFDecode method verifyDecode.
public void verifyDecode(String string, String charsetName) throws UnsupportedEncodingException, HiveException {
GenericUDFDecode udf = new GenericUDFDecode();
byte[] bytes = string.getBytes(charsetName);
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);
}
use of org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.javaByteArrayObjectInspector in project hive by apache.
the class TestLazyBinarySerDe method testJavaBinaryObjectInspector.
/**
* Test to see if byte[] with correct contents is generated by
* JavaBinaryObjectInspector from input BytesWritable
* @throws Throwable
*/
@Test
public void testJavaBinaryObjectInspector() throws Throwable {
BytesWritable bW = getInputBytesWritable();
// create JavaBinaryObjectInspector
JavaBinaryObjectInspector binInspector = PrimitiveObjectInspectorFactory.javaByteArrayObjectInspector;
// convert BytesWritable to byte][
byte[] outBARef = binInspector.set(null, bW);
assertTrue("compare input and output BAs", Arrays.equals(inpBArray, outBARef));
}
Aggregations