本文整理汇总了Java中org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory.writableBinaryObjectInspector方法的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveObjectInspectorFactory.writableBinaryObjectInspector方法的具体用法?Java PrimitiveObjectInspectorFactory.writableBinaryObjectInspector怎么用?Java PrimitiveObjectInspectorFactory.writableBinaryObjectInspector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory
的用法示例。
在下文中一共展示了PrimitiveObjectInspectorFactory.writableBinaryObjectInspector方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
/**
*
* Initialize HiveUDF and create object inspectors. It requires that the argument length is = 1 and that the ObjectInspector of arguments[0] is of type StructObjectInspector
*
* @param arguments array of length 1 containing one StructObjectInspector
*
* @return ObjectInspector that is able to parse the result of the evaluate method of the UDF (BinaryWritable)
*
* @throws org.apache.hadoop.hive.ql.exec.UDFArgumentException in case the first argument is not of StructObjectInspector
* @throws org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException in case the number of arguments is != 1
*
*/
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments==null) {
throw new UDFArgumentLengthException("bitcoinTransactionHash only takes one argument: Struct<BitcoinTransaction> ");
}
if (arguments.length != 1) {
throw new UDFArgumentLengthException("bitcoinTransactionHash only takes one argument: Struct<BitcoinTransaction> ");
}
if (!(arguments[0] instanceof StructObjectInspector)) {
throw new UDFArgumentException("first argument must be a Struct containing a BitcoinTransaction");
}
this.soi = (StructObjectInspector)arguments[0];
// these are only used for bitcointransaction structs exported to other formats, such as ORC
this.wboi = PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
this.wioi = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
this.wloi = PrimitiveObjectInspectorFactory.writableLongObjectInspector;
// the UDF returns the hash value of a BitcoinTransaction as byte array
return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
}
示例2: initialize
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
/**
*
* Initialize HiveUDF and create object inspectors. It requires that the argument length is = 1 and that the ObjectInspector of arguments[0] is of type StructObjectInspector
*
* @param arguments array of length 1 containing one StructObjectInspector
*
* @return ObjectInspector that is able to parse the result of the evaluate method of the UDF (BinaryWritable)
*
* @throws org.apache.hadoop.hive.ql.exec.UDFArgumentException in case the first argument is not of StructObjectInspector
* @throws org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException in case the number of arguments is != 1
*
*/
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments==null) {
throw new UDFArgumentLengthException("bitcoinTransactionHash only takes one argument: Struct<BitcoinTransaction> ");
}
if (arguments.length != 1) {
throw new UDFArgumentLengthException("bitcoinTransactionHash only takes one argument: Struct<BitcoinTransaction> ");
}
if (!(arguments[0] instanceof StructObjectInspector)) {
throw new UDFArgumentException("first argument must be a Struct containing a BitcoinTransaction");
}
this.soi = (StructObjectInspector)arguments[0];
// these are only used for bitcointransaction structs exported to other formats, such as ORC
this.wboi = PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
this.wioi = PrimitiveObjectInspectorFactory.writableIntObjectInspector;
this.wloi = PrimitiveObjectInspectorFactory.writableLongObjectInspector;
this.wbyoi = PrimitiveObjectInspectorFactory.writableByteObjectInspector;
// the UDF returns the hash value of a BitcoinTransaction as byte array
return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
}
示例3: extractNamecoinFieldFirstUpdate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
@Test
public void extractNamecoinFieldFirstUpdate() throws HiveException {
String firstUpdateScript ="520A642F666C6173687570641460C7B068EDEA60281DAF424C38D8DAB87C96CF993D7B226970223A223134352E3234392E3130362E323238222C226D6170223A7B222A223A7B226970223A223134352E3234392E3130362E323238227D7D7D6D6D76A91451B4FC93AAB8CBDBD0AC9BC8EAF824643FC1E29B88AC";
byte[] firstUpdateScriptBytes = BitcoinUtil.convertHexStringToByteArray(firstUpdateScript);
NamecoinExtractFieldUDF nefu = new NamecoinExtractFieldUDF();
ObjectInspector[] arguments = new ObjectInspector[1];
arguments[0] = PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;;
nefu.initialize(arguments);
GenericUDF.DeferredObject[] doa = new GenericUDF.DeferredObject[1];
doa[0]=new GenericUDF.DeferredJavaObject(new BytesWritable(firstUpdateScriptBytes));
List<Text> resultList = (List<Text>) nefu.evaluate(doa);
Text[] result=resultList.toArray(new Text[resultList.size()]);
assertNotNull( result,"Valid result obtained");
// test for domain name
assertEquals("d/flashupd",result[0].toString(),"Domain name of first update detected correctly");
// test for domain value
assertEquals("{\"ip\":\"145.249.106.228\",\"map\":{\"*\":{\"ip\":\"145.249.106.228\"}}}",result[1].toString(),"Domain value of first update detected correctly");
}
示例4: extractNamecoinFieldUpdate
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
@Test
public void extractNamecoinFieldUpdate() throws HiveException {
String updateScript = "5309642F70616E656C6B612D7B226970223A22382E382E382E38222C226D6170223A7B222A223A7B226970223A22382E382E382E38227D7D7D6D7576A9148D804B079AC79AD0CA108A4E5B679DB591FF069B88AC";
byte[] updateScriptBytes = BitcoinUtil.convertHexStringToByteArray(updateScript);
NamecoinExtractFieldUDF nefu = new NamecoinExtractFieldUDF();
ObjectInspector[] arguments = new ObjectInspector[1];
arguments[0] = PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;;
nefu.initialize(arguments);
GenericUDF.DeferredObject[] doa = new GenericUDF.DeferredObject[1];
doa[0]=new GenericUDF.DeferredJavaObject(new BytesWritable(updateScriptBytes));
List<Text> resultList = (List<Text>) nefu.evaluate(doa);
Text[] result=resultList.toArray(new Text[resultList.size()]);
assertNotNull( result,"Valid result obtained");
// test for domain name
assertEquals("d/panelka",result[0].toString(),"Domain name of first update detected correctly");
// test for domain value
assertEquals("{\"ip\":\"8.8.8.8\",\"map\":{\"*\":{\"ip\":\"8.8.8.8\"}}}",result[1].toString(),"Domain value of first update detected correctly");
}
示例5: initialize
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
if (argOIs.length != 1 && argOIs.length != 2) {
throw new UDFArgumentException("_FUNC_ takes 1 or 2 arguments");
}
this.stringOI = HiveUtils.asStringOI(argOIs[0]);
int level = Deflater.DEFAULT_COMPRESSION;
if (argOIs.length == 2) {
level = HiveUtils.getConstInt(argOIs[1]);
if ((level < 0 || level > 9) && level != Deflater.DEFAULT_COMPRESSION) {
throw new UDFArgumentException("Invalid compression level: " + level);
}
}
this.compressionLevel = level;
return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
}
示例6: initialize
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments==null) {
throw new UDFArgumentLengthException("ethereumGetSendAddress only takes one argument: Struct<EthereumTransction> ");
}
if (arguments.length != 1) {
throw new UDFArgumentLengthException("ethereumGetSendAddress only takes one argument: Struct<EthereumTransction> ");
}
if (!(arguments[0] instanceof StructObjectInspector)) {
throw new UDFArgumentException("first argument must be a Struct containing a EthereumTransction");
}
this.ethereumUDFUtil=new EthereumUDFUtil((StructObjectInspector) arguments[0]);
return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
}
示例7: initialize
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments==null) {
throw new UDFArgumentLengthException("ethereumGetTransactionHash only takes one argument: Struct<EthereumTransction> ");
}
if (arguments.length != 1) {
throw new UDFArgumentLengthException("ethereumGetTransactionHash only takes one argument: Struct<EthereumTransction> ");
}
if (!(arguments[0] instanceof StructObjectInspector)) {
throw new UDFArgumentException("first argument must be a Struct containing a EthereumTransction");
}
this.ethereumUDFUtil=new EthereumUDFUtil((StructObjectInspector) arguments[0]);
return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
}
示例8: initialize
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] argOIs) throws UDFArgumentException {
if (argOIs.length != 1) {
throw new UDFArgumentException("_FUNC_ takes exactly 1 argument");
}
this.stringOI = HiveUtils.asStringOI(argOIs[0]);
return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
}
示例9: craeteObjectInspectorFromTypeInfo
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
public static ObjectInspector craeteObjectInspectorFromTypeInfo( final TypeInfo typeInfo ){
switch ( typeInfo.getCategory() ){
case STRUCT:
return new MDSStructObjectInspector( (StructTypeInfo)typeInfo );
case MAP:
return new MDSMapObjectInspector( (MapTypeInfo)typeInfo );
case LIST:
return new MDSListObjectInspector( (ListTypeInfo)typeInfo );
case UNION:
UnionTypeInfo unionTypeInfo = (UnionTypeInfo)typeInfo;
List<ObjectInspector> unionList = new ArrayList<ObjectInspector>();
for( TypeInfo childTypeInfo : unionTypeInfo.getAllUnionObjectTypeInfos() ){
unionList.add( craeteObjectInspectorFromTypeInfo( childTypeInfo ) );
}
return ObjectInspectorFactory.getStandardUnionObjectInspector( unionList );
case PRIMITIVE:
PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo)typeInfo;
switch( primitiveTypeInfo.getPrimitiveCategory() ){
case STRING:
return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
case BINARY:
return PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
case BOOLEAN:
return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
case BYTE:
return PrimitiveObjectInspectorFactory.writableByteObjectInspector;
case DOUBLE:
return PrimitiveObjectInspectorFactory.writableDoubleObjectInspector;
case FLOAT:
return PrimitiveObjectInspectorFactory.writableFloatObjectInspector;
case INT:
return PrimitiveObjectInspectorFactory.writableIntObjectInspector;
case LONG:
return PrimitiveObjectInspectorFactory.writableLongObjectInspector;
case SHORT:
return PrimitiveObjectInspectorFactory.writableShortObjectInspector;
case DATE:
case DECIMAL:
case TIMESTAMP:
case VOID:
default:
throw new UnsupportedOperationException( "Unknown primitive category " + primitiveTypeInfo.getPrimitiveCategory() );
}
default:
throw new UnsupportedOperationException( "Unknown category " + typeInfo.getCategory() );
}
}
示例10: initialize
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
checkArgsSize(arguments, 2, 2);
checkArgPrimitive(arguments, 0);
checkArgPrimitive(arguments, 1);
// the function should support both string and binary input types
if (canParam0BeStr()) {
checkArgGroups(arguments, 0, inputTypes, STRING_GROUP, BINARY_GROUP);
} else {
checkArgGroups(arguments, 0, inputTypes, BINARY_GROUP);
}
checkArgGroups(arguments, 1, inputTypes, STRING_GROUP, BINARY_GROUP);
if (isStr0 = PrimitiveObjectInspectorUtils.getPrimitiveGrouping(inputTypes[0]) == STRING_GROUP) {
obtainStringConverter(arguments, 0, inputTypes, converters);
} else {
obtainBinaryConverter(arguments, 0, inputTypes, converters);
}
isKeyConstant = arguments[1] instanceof ConstantObjectInspector;
byte[] key = null;
int keyLength = 0;
if (isStr1 = PrimitiveObjectInspectorUtils.getPrimitiveGrouping(inputTypes[1]) == STRING_GROUP) {
if (isKeyConstant) {
String keyStr = getConstantStringValue(arguments, 1);
if (keyStr != null) {
key = keyStr.getBytes();
keyLength = key.length;
}
} else {
obtainStringConverter(arguments, 1, inputTypes, converters);
}
} else {
if (isKeyConstant) {
BytesWritable keyWr = getConstantBytesValue(arguments, 1);
if (keyWr != null) {
key = keyWr.getBytes();
keyLength = keyWr.getLength();
}
} else {
obtainBinaryConverter(arguments, 1, inputTypes, converters);
}
}
if (key != null) {
secretKey = getSecretKey(key, keyLength);
}
try {
cipher = Cipher.getInstance("AES");
} catch (NoSuchPaddingException | NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
ObjectInspector outputOI = PrimitiveObjectInspectorFactory.writableBinaryObjectInspector;
return outputOI;
}