本文整理汇总了Java中org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters类的典型用法代码示例。如果您正苦于以下问题:Java ObjectInspectorConverters类的具体用法?Java ObjectInspectorConverters怎么用?Java ObjectInspectorConverters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectInspectorConverters类属于org.apache.hadoop.hive.serde2.objectinspector包,在下文中一共展示了ObjectInspectorConverters类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: obtainIntConverter
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
public static void obtainIntConverter(ObjectInspector[] arguments, int i,
PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
PrimitiveCategory inputType = inOi.getPrimitiveCategory();
switch (inputType) {
case BYTE:
case SHORT:
case INT:
case VOID:
break;
default:
throw new UDFArgumentTypeException(i, "_FUNC_ only takes INT/SHORT/BYTE types as "
+ getArgOrder(i) + " argument, got " + inputType);
}
Converter converter = ObjectInspectorConverters.getConverter(arguments[i],
PrimitiveObjectInspectorFactory.writableIntObjectInspector);
converters[i] = converter;
inputTypes[i] = inputType;
}
开发者ID:myui,项目名称:hive-udf-backports,代码行数:21,代码来源:BackportUtils.java
示例2: obtainLongConverter
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
public static void obtainLongConverter(ObjectInspector[] arguments, int i,
PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
PrimitiveCategory inputType = inOi.getPrimitiveCategory();
switch (inputType) {
case BYTE:
case SHORT:
case INT:
case LONG:
break;
default:
throw new UDFArgumentTypeException(i,
"_FUNC_ only takes LONG/INT/SHORT/BYTE types as " + getArgOrder(i)
+ " argument, got " + inputType);
}
Converter converter = ObjectInspectorConverters.getConverter(arguments[i],
PrimitiveObjectInspectorFactory.writableIntObjectInspector);
converters[i] = converter;
inputTypes[i] = inputType;
}
开发者ID:myui,项目名称:hive-udf-backports,代码行数:22,代码来源:BackportUtils.java
示例3: obtainDateConverter
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
public static void obtainDateConverter(ObjectInspector[] arguments, int i,
PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
PrimitiveCategory inputType = inOi.getPrimitiveCategory();
ObjectInspector outOi;
switch (inputType) {
case STRING:
case VARCHAR:
case CHAR:
outOi = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
break;
case TIMESTAMP:
case DATE:
case VOID:
outOi = PrimitiveObjectInspectorFactory.writableDateObjectInspector;
break;
default:
throw new UDFArgumentTypeException(i,
"_FUNC_ only takes STRING_GROUP or DATE_GROUP types as " + getArgOrder(i)
+ " argument, got " + inputType);
}
converters[i] = ObjectInspectorConverters.getConverter(inOi, outOi);
inputTypes[i] = inputType;
}
开发者ID:myui,项目名称:hive-udf-backports,代码行数:25,代码来源:BackportUtils.java
示例4: obtainTimestampConverter
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
public static void obtainTimestampConverter(ObjectInspector[] arguments, int i,
PrimitiveCategory[] inputTypes, Converter[] converters) throws UDFArgumentTypeException {
PrimitiveObjectInspector inOi = (PrimitiveObjectInspector) arguments[i];
PrimitiveCategory inputType = inOi.getPrimitiveCategory();
ObjectInspector outOi;
switch (inputType) {
case STRING:
case VARCHAR:
case CHAR:
case TIMESTAMP:
case DATE:
break;
default:
throw new UDFArgumentTypeException(i,
"_FUNC_ only takes STRING_GROUP or DATE_GROUP types as " + getArgOrder(i)
+ " argument, got " + inputType);
}
outOi = PrimitiveObjectInspectorFactory.writableTimestampObjectInspector;
converters[i] = ObjectInspectorConverters.getConverter(inOi, outOi);
inputTypes[i] = inputType;
}
开发者ID:myui,项目名称:hive-udf-backports,代码行数:22,代码来源:BackportUtils.java
示例5: initialize
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments.length != 2) {
throw new UDFArgumentLengthException(
"The function COUNTRY(ip, geolocfile) takes exactly 2 arguments.");
}
converters = new ObjectInspectorConverters.Converter[arguments.length];
for (int i = 0; i < arguments.length; i++) {
converters[i] = ObjectInspectorConverters.getConverter(arguments[i],
PrimitiveObjectInspectorFactory.javaStringObjectInspector);
}
return PrimitiveObjectInspectorFactory
.getPrimitiveJavaObjectInspector(PrimitiveObjectInspector.PrimitiveCategory.STRING);
}
开发者ID:Hanmourang,项目名称:hiped2,代码行数:17,代码来源:Geoloc.java
示例6: initialize
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
throws UDFArgumentException {
if (arguments.length != 2) {
throw new UDFArgumentLengthException("SAMPLE expects two arguments.");
}
if (!arguments[0].getCategory().equals(Category.PRIMITIVE)) {
throw new UDFArgumentTypeException(0, "SAMPLE expects an INTEGER as its first argument");
}
int_converter = ObjectInspectorConverters.getConverter(arguments[0],
PrimitiveObjectInspectorFactory.writableIntObjectInspector);
if (!arguments[1].getCategory().equals(Category.LIST)) {
throw new UDFArgumentTypeException(1, "SAMPLE expects an ARRAY as its second argument");
}
arrayOI = (ListObjectInspector)arguments[1];
return arguments[1];
}
开发者ID:brndnmtthws,项目名称:facebook-hive-udfs,代码行数:22,代码来源:UDFSample.java
示例7: initialize
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
throws UDFArgumentException {
if (arguments.length != 2 && arguments.length != 3) {
throw new UDFArgumentLengthException("Expected 2 or 3 inputs, got " +
arguments.length);
}
int_converter1 = ObjectInspectorConverters.getConverter(arguments[1],
PrimitiveObjectInspectorFactory.writableIntObjectInspector);
if (arguments.length == 3) {
int_converter2 = ObjectInspectorConverters.getConverter(arguments[2],
PrimitiveObjectInspectorFactory.writableIntObjectInspector);
}
arrayOI = (ListObjectInspector) arguments[0];
return ObjectInspectorUtils.getStandardObjectInspector(arrayOI);
}
开发者ID:brndnmtthws,项目名称:facebook-hive-udfs,代码行数:20,代码来源:UDFArraySlice.java
示例8: initialize
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments.length != 2) {
throw new UDFArgumentLengthException(
"The function COUNTRY(ip, geolocfile) takes exactly 2 arguments.");
}
/*
* create covert used in evaluate method to convert all the arguments from their
* native type into java String
*/
converters = new ObjectInspectorConverters.Converter[arguments.length];
for (int i = 0; i < arguments.length; i++) {
converters[i] = ObjectInspectorConverters.getConverter(arguments[i],
PrimitiveObjectInspectorFactory.javaStringObjectInspector);
}
return PrimitiveObjectInspectorFactory
.getPrimitiveJavaObjectInspector(PrimitiveObjectInspector.PrimitiveCategory.STRING);
}
开发者ID:willddy,项目名称:bigdata_pattern,代码行数:21,代码来源:GeolocUDF.java
示例9: initialize
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments.length != 4) {
throw new UDFArgumentException("parseDate takes four arguments");
}
converters = new ObjectInspectorConverters.Converter[arguments.length];
for (int i = 0; i < arguments.length; i++) {
converters[i] = ObjectInspectorConverters
.getConverter(arguments[i], PrimitiveObjectInspectorFactory.writableStringObjectInspector);
}
return ObjectInspectorFactory.getStandardStructObjectInspector(Arrays.asList("year", "month", "day", "epoch"), Arrays
.<ObjectInspector>asList(
PrimitiveObjectInspectorFactory.javaIntObjectInspector,
PrimitiveObjectInspectorFactory.javaIntObjectInspector,
PrimitiveObjectInspectorFactory.javaIntObjectInspector,
PrimitiveObjectInspectorFactory.javaLongObjectInspector));
}
开发者ID:gbif,项目名称:occurrence,代码行数:20,代码来源:DateParseUDF.java
示例10: initialize
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments.length != argLength) {
throw new UDFArgumentException("compareLocationInterpretation takes 9 arguments");
}
converters = new ObjectInspectorConverters.Converter[arguments.length];
for (int i = 0; i < arguments.length; i++) {
converters[i] = ObjectInspectorConverters
.getConverter(arguments[i], PrimitiveObjectInspectorFactory.writableStringObjectInspector);
}
return ObjectInspectorFactory
.getStandardStructObjectInspector(Arrays.asList("decimallatitude", "decimallongitude", "countrycode"), Arrays
.<ObjectInspector>asList(PrimitiveObjectInspectorFactory.javaDoubleObjectInspector, PrimitiveObjectInspectorFactory.javaDoubleObjectInspector,
PrimitiveObjectInspectorFactory.javaStringObjectInspector));
}
开发者ID:gbif,项目名称:occurrence,代码行数:18,代码来源:ReinterpretLocationUDF.java
示例11: initialize
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments.length != 4) {
throw new UDFArgumentException("parseCoordinates takes four arguments");
}
converters = new ObjectInspectorConverters.Converter[arguments.length];
for (int i = 0; i < arguments.length; i++) {
converters[i] = ObjectInspectorConverters
.getConverter(arguments[i], PrimitiveObjectInspectorFactory.writableStringObjectInspector);
}
return ObjectInspectorFactory
.getStandardStructObjectInspector(Arrays.asList("latitude", "longitude", "country"), Arrays
.<ObjectInspector>asList(PrimitiveObjectInspectorFactory.javaDoubleObjectInspector,
PrimitiveObjectInspectorFactory.javaDoubleObjectInspector,
PrimitiveObjectInspectorFactory.javaStringObjectInspector));
}
开发者ID:gbif,项目名称:occurrence,代码行数:19,代码来源:CoordinateCountryParseUDF.java
示例12: initialize
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments.length < 2) {
throw new UDFArgumentLengthException(getFuncName() + " requires at least 2 arguments, got "
+ arguments.length);
}
if (arguments[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
throw new UDFArgumentException(getFuncName() + " only takes primitive types, got "
+ arguments[0].getTypeName());
}
argumentOIs = arguments;
converters = new Converter[arguments.length];
TypeInfo commonInfo = TypeInfoUtils.getTypeInfoFromObjectInspector(arguments[0]);
for (int i = 1; i < arguments.length; i++) {
PrimitiveTypeInfo currInfo = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromObjectInspector(arguments[i]);
commonInfo = FunctionRegistry.getCommonClassForComparison(
commonInfo, currInfo);
}
resultOI = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(
(commonInfo == null) ?
TypeInfoFactory.doubleTypeInfo : commonInfo);
for (int i = 0; i < arguments.length; i++) {
converters[i] = ObjectInspectorConverters.getConverter(arguments[i], resultOI);
}
return resultOI;
}
开发者ID:myui,项目名称:hive-udf-backports,代码行数:34,代码来源:GenericUDFBaseNwayCompare.java
示例13: obtainStringConverter
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
public static void obtainStringConverter(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.writableStringObjectInspector);
converters[i] = converter;
inputTypes[i] = inputType;
}
开发者ID:myui,项目名称:hive-udf-backports,代码行数:11,代码来源:BackportUtils.java
示例14: obtainDoubleConverter
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
public static void obtainDoubleConverter(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.writableDoubleObjectInspector);
converters[i] = converter;
inputTypes[i] = inputType;
}
开发者ID:myui,项目名称:hive-udf-backports,代码行数:10,代码来源:BackportUtils.java
示例15: obtainBinaryConverter
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
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;
}
开发者ID:myui,项目名称:hive-udf-backports,代码行数:11,代码来源:BackportUtils.java
示例16: initialize
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
throws UDFArgumentException {
if (arguments.length != 1) {
throw new UDFArgumentLengthException("The SplitAndCleanJSONArray takes only one argument");
}
converters = new ObjectInspectorConverters.Converter[arguments.length];
for (int i = 0; i < arguments.length; i++) {
converters[i] = ObjectInspectorConverters.getConverter(arguments[i], PrimitiveObjectInspectorFactory.writableStringObjectInspector);
}
return ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableStringObjectInspector);
}
开发者ID:therelaxist,项目名称:spring-usc,代码行数:13,代码来源:SplitAndCleanJSONArray.java
示例17: initialize
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
throws UDFArgumentException {
converters = new ObjectInspectorConverters.Converter[arguments.length];
for (int ii = 0; ii < arguments.length; ++ii) {
if (ii == 0) {
arrayOI = (ListObjectInspector)ObjectInspectorUtils
.getStandardObjectInspector(arguments[ii]);
}
converters[ii] = ObjectInspectorConverters.getConverter(arguments[ii], arrayOI);
}
return arrayOI;
}
开发者ID:brndnmtthws,项目名称:facebook-hive-udfs,代码行数:15,代码来源:UDFArrayConcat.java
示例18: initialize
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
throws UDFArgumentException {
ObjectInspector indexOI =
ObjectInspectorFactory.getStandardListObjectInspector(
PrimitiveObjectInspectorFactory.javaIntObjectInspector);
arrayOI = (ListObjectInspector)arguments[0];
converter =
ObjectInspectorConverters.getConverter(arguments[1], indexOI);
return arrayOI;
}
开发者ID:brndnmtthws,项目名称:facebook-hive-udfs,代码行数:15,代码来源:UDFArrayExclude.java
示例19: initialize
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
throws UDFArgumentException {
converter =
ObjectInspectorConverters.getConverter(arguments[0], arguments[1]);
return arguments[1];
}
开发者ID:brndnmtthws,项目名称:facebook-hive-udfs,代码行数:10,代码来源:UDFCast.java
示例20: initializeNumber
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入依赖的package包/类
private ObjectInspector initializeNumber(ObjectInspector[] arguments)
throws UDFArgumentException {
if (arguments.length < 1 || arguments.length > 2) {
throw new UDFArgumentLengthException(
"TRUNC requires one or two argument, got " + arguments.length);
}
if (arguments[0].getCategory() != Category.PRIMITIVE) {
throw new UDFArgumentTypeException(0,
"TRUNC input only takes primitive types, got " + arguments[0].getTypeName());
}
inputOI = (PrimitiveObjectInspector) arguments[0];
if (arguments.length == 2) {
if (arguments[1].getCategory() != Category.PRIMITIVE) {
throw new UDFArgumentTypeException(1,
"TRUNC second argument only takes primitive types, got " + arguments[1].getTypeName());
}
inputScaleOI = (PrimitiveObjectInspector) arguments[1];
inputSacleConst = arguments[1] instanceof ConstantObjectInspector;
if (inputSacleConst) {
try {
Object obj = ((ConstantObjectInspector) arguments[1]).getWritableConstantValue();
fmtInput = obj != null ? obj.toString() : null;
scale = Integer.parseInt(fmtInput);
} catch (Exception e) {
throw new UDFArgumentException("TRUNC input only takes integer values, got " + fmtInput);
}
} else {
switch (inputScaleOI.getPrimitiveCategory()) {
case BYTE:
byteConverter = ObjectInspectorConverters.getConverter(arguments[1],
PrimitiveObjectInspectorFactory.writableByteObjectInspector);
break;
case SHORT:
shortConverter = ObjectInspectorConverters.getConverter(arguments[1],
PrimitiveObjectInspectorFactory.writableShortObjectInspector);
break;
case INT:
intConverter = ObjectInspectorConverters.getConverter(arguments[1],
PrimitiveObjectInspectorFactory.writableIntObjectInspector);
break;
case LONG:
longConverter = ObjectInspectorConverters.getConverter(arguments[1],
PrimitiveObjectInspectorFactory.writableLongObjectInspector);
break;
default:
throw new UDFArgumentTypeException(1,
getFuncName().toUpperCase() + " second argument only takes integer values");
}
}
}
inputType1 = inputOI.getPrimitiveCategory();
ObjectInspector outputOI = null;
switch (inputType1) {
case DECIMAL:
outputOI = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(inputType1);
break;
case VOID:
case BYTE:
case SHORT:
case INT:
case LONG:
case FLOAT:
case DOUBLE:
outputOI = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(inputType1);
break;
default:
throw new UDFArgumentTypeException(0,
"Only numeric or string group data types are allowed for TRUNC function. Got "
+ inputType1.name());
}
return outputOI;
}
开发者ID:myui,项目名称:hive-udf-backports,代码行数:78,代码来源:GenericUDFTrunc.java
注:本文中的org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论