本文整理汇总了Java中org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory.STRING属性的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveCategory.STRING属性的具体用法?Java PrimitiveCategory.STRING怎么用?Java PrimitiveCategory.STRING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector.PrimitiveCategory
的用法示例。
在下文中一共展示了PrimitiveCategory.STRING属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MDSMapObjectInspector
public MDSMapObjectInspector( final MapTypeInfo typeInfo ){
TypeInfo keyTypeInfo = typeInfo.getMapKeyTypeInfo();
if( keyTypeInfo.getCategory() == ObjectInspector.Category.PRIMITIVE && ( (PrimitiveTypeInfo)keyTypeInfo ).getPrimitiveCategory() == PrimitiveCategory.STRING ){
keyObjectInspector = PrimitiveObjectInspectorFactory.javaStringObjectInspector;
}
else{
throw new RuntimeException( "Map key type is string only." );
}
valueObjectInspector = MDSObjectInspectorFactory.craeteObjectInspectorFromTypeInfo( typeInfo.getMapValueTypeInfo() );
if( valueObjectInspector.getCategory() == ObjectInspector.Category.PRIMITIVE ){
getField = new PrimitiveGetField( (PrimitiveObjectInspector)valueObjectInspector );
}
else if( valueObjectInspector.getCategory() == ObjectInspector.Category.UNION ){
getField = new UnionGetField( (UnionTypeInfo)( typeInfo.getMapValueTypeInfo() ) );
}
else{
getField = new NestedGetField();
}
}
示例2: initialize
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments.length != 1) {
throw new UDFArgumentLengthException(
"add_bias() has an single arguments: array<string> features");
}
switch (arguments[0].getCategory()) {
case LIST:
argumentOI = (ListObjectInspector) arguments[0];
ObjectInspector elmOI = argumentOI.getListElementObjectInspector();
if (elmOI.getCategory().equals(Category.PRIMITIVE)) {
if (((PrimitiveObjectInspector) elmOI).getPrimitiveCategory() == PrimitiveCategory.STRING) {
break;
}
}
default:
throw new UDFArgumentTypeException(0, "Type mismatch: features");
}
return ObjectInspectorFactory.getStandardListObjectInspector(argumentOI.getListElementObjectInspector());
}
示例3: initialize
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
throws UDFArgumentException {
if(arguments.length != 1
|| ! arguments[0].getCategory().equals( Category.PRIMITIVE)
|| ((PrimitiveObjectInspector)arguments[0]).getPrimitiveCategory() != PrimitiveCategory.STRING) {
throw new UDFArgumentException("Usage : json_split(jsonstring) ");
}
stringInspector = (StringObjectInspector) arguments[0];
ArrayList<String> outputColumns = new ArrayList<String>();
outputColumns.add("row_id");
outputColumns.add("json_string");
ArrayList<ObjectInspector> outputTypes = new ArrayList<ObjectInspector>();
outputTypes.add(PrimitiveObjectInspectorFactory.javaIntObjectInspector);
outputTypes.add(PrimitiveObjectInspectorFactory.javaStringObjectInspector);
return ObjectInspectorFactory.getStandardListObjectInspector
(ObjectInspectorFactory.getStandardStructObjectInspector( outputColumns, outputTypes));
}
示例4: initialize
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments.length != 1) {
throw new UDFArgumentLengthException("normalize() has an only single argument.");
}
switch (arguments[0].getCategory()) {
case LIST:
ObjectInspector elmOI = ((ListObjectInspector) arguments[0]).getListElementObjectInspector();
if (elmOI.getCategory().equals(Category.PRIMITIVE)) {
if (((PrimitiveObjectInspector) elmOI).getPrimitiveCategory() == PrimitiveCategory.STRING) {
break;
}
}
default:
throw new UDFArgumentTypeException(0,
"normalize() must have List[String] as an argument, but "
+ arguments[0].getTypeName() + " was found.");
}
// Create a ObjectInspector converter for arguments
ObjectInspector outputElemOI = ObjectInspectorFactory.getReflectionObjectInspector(
Text.class, ObjectInspectorOptions.JAVA);
ObjectInspector outputOI = ObjectInspectorFactory.getStandardListObjectInspector(outputElemOI);
toListText = ObjectInspectorConverters.getConverter(arguments[0], outputOI);
ObjectInspector listElemOI = PrimitiveObjectInspectorFactory.javaStringObjectInspector;
ObjectInspector returnElemOI = ObjectInspectorUtils.getStandardObjectInspector(listElemOI);
return ObjectInspectorFactory.getStandardListObjectInspector(returnElemOI);
}
示例5: initialize
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments.length != 1) {
throw new UDFArgumentLengthException(
"extract_weight() has an single arguments: string feature");
}
argumentOI = (PrimitiveObjectInspector) arguments[0];
if (argumentOI.getPrimitiveCategory() != PrimitiveCategory.STRING) {
throw new UDFArgumentTypeException(0, "Type mismatch: feature");
}
return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.DOUBLE);
}
示例6: initialize
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments.length != 1) {
throw new UDFArgumentLengthException(
"extract_feature() has an single arguments: string feature");
}
argumentOI = (PrimitiveObjectInspector) arguments[0];
if (argumentOI.getPrimitiveCategory() != PrimitiveCategory.STRING) {
throw new UDFArgumentTypeException(0, "Type mismatch: feature");
}
return PrimitiveObjectInspectorFactory.javaStringObjectInspector;
}
示例7: initialize
@Override
public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
if (arguments.length != 2) {
throw new UDFArgumentLengthException(
"minhashes() has 2 arguments: array<string> features, boolean noWeight");
}
// Check argument types
switch (arguments[0].getCategory()) {
case LIST:
featuresOI = (ListObjectInspector) arguments[0];
ObjectInspector elmOI = featuresOI.getListElementObjectInspector();
if (elmOI.getCategory().equals(Category.PRIMITIVE)) {
if (((PrimitiveObjectInspector) elmOI).getPrimitiveCategory() == PrimitiveCategory.STRING) {
break;
}
}
default:
throw new UDFArgumentTypeException(0, "Type mismatch: features");
}
noWeightOI = (PrimitiveObjectInspector) arguments[1];
if (noWeightOI.getPrimitiveCategory() != PrimitiveCategory.BOOLEAN) {
throw new UDFArgumentException("Type mismatch: noWeight");
}
return ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.INT));
}
示例8: initialize
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
throws UDFArgumentException {
if(arguments.length != 1
|| ! arguments[0].getCategory().equals( Category.PRIMITIVE)
|| ((PrimitiveObjectInspector)arguments[0]).getPrimitiveCategory() != PrimitiveCategory.STRING) {
throw new UDFArgumentException("Usage : json_split(jsonstring) ");
}
stringInspector = (StringObjectInspector) arguments[0];
return ObjectInspectorFactory.getStandardMapObjectInspector(PrimitiveObjectInspectorFactory.javaStringObjectInspector,
PrimitiveObjectInspectorFactory.javaStringObjectInspector);
}
示例9: initialize
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
throws UDFArgumentException {
if (arguments.length != 1) {
throw new UDFArgumentLengthException("ST_GeomFromJson takes only one argument");
}
ObjectInspector argJsonOI = arguments[0];
if (argJsonOI.getCategory() == Category.PRIMITIVE)
{
PrimitiveObjectInspector poi = (PrimitiveObjectInspector)argJsonOI;
if (poi.getPrimitiveCategory() != PrimitiveCategory.STRING)
{
throw new UDFArgumentTypeException(0, "ST_GeomFromJson argument category must be either a string primitive or struct");
}
} else if (argJsonOI.getCategory() != Category.STRUCT) {
} else {
throw new UDFArgumentTypeException(0, "ST_GeomFromJson argument category must be either a string primitive or struct");
}
jsonOI = argJsonOI;
return GeometryUtils.geometryTransportObjectInspector;
}
示例10: GenericUDFTestSTRING
public GenericUDFTestSTRING() {
super("testHiveUDFSTRING", PrimitiveCategory.STRING);
}
示例11: initializeDate
private ObjectInspector initializeDate(ObjectInspector[] arguments)
throws UDFArgumentLengthException, UDFArgumentTypeException {
if (arguments.length != 2) {
throw new UDFArgumentLengthException("trunc() requires 2 argument, got " + arguments.length);
}
if (arguments[0].getCategory() != ObjectInspector.Category.PRIMITIVE) {
throw new UDFArgumentTypeException(0, "Only primitive type arguments are accepted but "
+ arguments[0].getTypeName() + " is passed. as first arguments");
}
if (arguments[1].getCategory() != ObjectInspector.Category.PRIMITIVE) {
throw new UDFArgumentTypeException(1, "Only primitive type arguments are accepted but "
+ arguments[1].getTypeName() + " is passed. as second arguments");
}
ObjectInspector outputOI = PrimitiveObjectInspectorFactory.writableStringObjectInspector;
inputType1 = ((PrimitiveObjectInspector) arguments[0]).getPrimitiveCategory();
switch (inputType1) {
case STRING:
case VARCHAR:
case CHAR:
case VOID:
inputType1 = PrimitiveCategory.STRING;
textConverter1 = ObjectInspectorConverters.getConverter(arguments[0],
PrimitiveObjectInspectorFactory.writableStringObjectInspector);
break;
case TIMESTAMP:
timestampConverter = new TimestampConverter((PrimitiveObjectInspector) arguments[0],
PrimitiveObjectInspectorFactory.writableTimestampObjectInspector);
break;
case DATE:
dateWritableConverter = ObjectInspectorConverters.getConverter(arguments[0],
PrimitiveObjectInspectorFactory.writableDateObjectInspector);
break;
default:
throw new UDFArgumentTypeException(0,
"TRUNC() only takes STRING/TIMESTAMP/DATEWRITABLE types as first argument, got "
+ inputType1);
}
inputType2 = ((PrimitiveObjectInspector) arguments[1]).getPrimitiveCategory();
if (PrimitiveObjectInspectorUtils
.getPrimitiveGrouping(inputType2) != PrimitiveGrouping.STRING_GROUP
&& PrimitiveObjectInspectorUtils
.getPrimitiveGrouping(inputType2) != PrimitiveGrouping.VOID_GROUP) {
throw new UDFArgumentTypeException(1,
"trunk() only takes STRING/CHAR/VARCHAR types as second argument, got " + inputType2);
}
inputType2 = PrimitiveCategory.STRING;
if (arguments[1] instanceof ConstantObjectInspector) {
Object obj = ((ConstantObjectInspector) arguments[1]).getWritableConstantValue();
fmtInput = obj != null ? obj.toString() : null;
} else {
textConverter2 = ObjectInspectorConverters.getConverter(arguments[1],
PrimitiveObjectInspectorFactory.writableStringObjectInspector);
}
return outputOI;
}
示例12: isStringTypeInfo
public static boolean isStringTypeInfo(@Nonnull TypeInfo typeInfo) {
if (typeInfo.getCategory() != ObjectInspector.Category.PRIMITIVE) {
return false;
}
return ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory() == PrimitiveCategory.STRING;
}