本文整理汇总了Java中org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters.Converter方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectInspectorConverters.Converter方法的具体用法?Java ObjectInspectorConverters.Converter怎么用?Java ObjectInspectorConverters.Converter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters
的用法示例。
在下文中一共展示了ObjectInspectorConverters.Converter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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));
}
示例4: 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));
}
示例5: 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));
}
示例6: 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);
}
示例7: 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;
}
示例8: initialize
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters; //导入方法依赖的package包/类
@Override
public ObjectInspector initialize(ObjectInspector[] parameters) throws UDFArgumentException {
// argument check
if (parameters.length < 1) {
throw new UDFArgumentTypeException(parameters.length - 1,
"At least one argument is expected.");
}
scriptParamPos = 0;
if (parameters[0] instanceof WritableConstantStringObjectInspector) {
// no hint of return type found
returnOI = PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(
PrimitiveObjectInspector.PrimitiveCategory.STRING);
} else if (parameters.length >= 2 && parameters[1] instanceof WritableConstantStringObjectInspector) {
scriptParamPos = 1;
// 1st param is hint of return type
returnOI = RubyScriptingUtils.resolveOI(parameters[0]);
} else {
throw new UDFArgumentTypeException(0, "Couldn't find argument containing ruby method/script");
}
rbScriptParam = RubyScriptingUtils.getScriptParam(parameters[scriptParamPos]);
argsConverters = new ObjectInspectorConverters.Converter[parameters.length - scriptParamPos - 1];
for (int i = 0; i < argsConverters.length; i++) {
argsConverters[i] = ObjectInspectorConverters.getConverter(
parameters[i + scriptParamPos + 1],
RubyScriptingUtils.resolveOI(parameters[i + scriptParamPos + 1])
);
}
initializeJRubyRuntime();
StringBuilder sb = new StringBuilder();
sb.append("initialized rb_exec. return type is ");
sb.append(returnOI.getTypeName());
if (mode == MODE.METHOD) {
sb.append(", try to evaluate using method '");
sb.append(evaluateMethod);
sb.append("' defined in rb.script as:\n");
sb.append(rbEnvScript);
} else {
sb.append(", try to evaluate using this scriptlet: ");
sb.append(rbScriptParam);
}
LOG.info(sb.toString());
return returnOI;
}